From 79b64c308433f838c7790a70a4d08837cffc2999 Mon Sep 17 00:00:00 2001 From: minzhang0929 <78373564+minzhang0929@users.noreply.github.com> Date: Tue, 31 Oct 2023 20:45:09 +0800 Subject: [PATCH 1/3] Update pytorchFunctions.H --- src/dfChemistryModel/pytorchFunctions.H | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dfChemistryModel/pytorchFunctions.H b/src/dfChemistryModel/pytorchFunctions.H index 535a7418b..af2c224d3 100644 --- a/src/dfChemistryModel/pytorchFunctions.H +++ b/src/dfChemistryModel/pytorchFunctions.H @@ -275,9 +275,9 @@ Foam::scalar Foam::dfChemistryModel::solve_DNN(const DeltaTType &del pybind11::module_ call_torch = pybind11::module_::import("inference"); // import python file pybind11::object result = call_torch.attr("inference")(vec0, vec1, vec2); // call python function const double* star = result.cast>().data(); - std::vector outputsVec0(star, star+outputLength[0] * 7); //the float number is sample_length*sample_number - std::vector outputsVec1(star+outputLength[0] * 7, star+outputLength[1] * 7); - std::vector outputsVec2(star+outputLength[1] * 7, star+outputLength[2] * 7); + std::vector outputsVec0(star, star+outputLength[0] * mixture_.nSpecies()); //the float number is sample_length*sample_number + std::vector outputsVec1(star+outputLength[0] * mixture_.nSpecies(), star+outputLength[1] * mixture_.nSpecies()); + std::vector outputsVec2(star+outputLength[1] * mixture_.nSpecies(), star+outputLength[2] * mixture_.nSpecies()); std::vector> results = {outputsVec0, outputsVec1, outputsVec2}; updateSolutionBuffer(solutionBuffer, results, cellIDBuffer, problemCounter); DynamicList finalList; @@ -301,4 +301,4 @@ Foam::scalar Foam::dfChemistryModel::solve_DNN(const DeltaTType &del time_allsolve_ += processingTime.count(); return deltaTMin; -} \ No newline at end of file +} From d13a9c6297fae619cff17b89bb13450e3a1001d5 Mon Sep 17 00:00:00 2001 From: minzhang0929 <78373564+minzhang0929@users.noreply.github.com> Date: Tue, 31 Oct 2023 20:45:44 +0800 Subject: [PATCH 2/3] Update torchFunctions.H --- src/dfChemistryModel/torchFunctions.H | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dfChemistryModel/torchFunctions.H b/src/dfChemistryModel/torchFunctions.H index 1639d2870..f7d9a83c7 100644 --- a/src/dfChemistryModel/torchFunctions.H +++ b/src/dfChemistryModel/torchFunctions.H @@ -149,9 +149,9 @@ void Foam::dfChemistryModel::getDNNinputs if (gpulog_) { - std::cout<<"inputsDNN0 = "< Date: Mon, 6 Nov 2023 20:54:55 +0800 Subject: [PATCH 3/3] Update pytorchFunctions.H --- src/dfChemistryModel/pytorchFunctions.H | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dfChemistryModel/pytorchFunctions.H b/src/dfChemistryModel/pytorchFunctions.H index af2c224d3..dfaf439c8 100644 --- a/src/dfChemistryModel/pytorchFunctions.H +++ b/src/dfChemistryModel/pytorchFunctions.H @@ -145,9 +145,9 @@ Foam::scalar Foam::dfChemistryModel::solve_DNN(const DeltaTType &del /*=============================construct solutions=============================*/ std::chrono::steady_clock::time_point start6 = std::chrono::steady_clock::now(); - std::vector outputsVec0(star, star+outputLength[0] * 7); //the float number is sample_length*sample_number - std::vector outputsVec1(star+outputLength[0] * 7, star+outputLength[1] * 7); - std::vector outputsVec2(star+outputLength[1] * 7, star+outputLength[2] * 7); + std::vector outputsVec0(star, star+outputLength[0] * mixture_.nSpecies()); //the float number is sample_length*sample_number + std::vector outputsVec1(star+outputLength[0] * mixture_.nSpecies(), star+outputLength[1] * mixture_.nSpecies()); + std::vector outputsVec2(star+outputLength[1] * mixture_.nSpecies(), star+outputLength[2] * mixture_.nSpecies()); std::vector> results = {outputsVec0, outputsVec1, outputsVec2}; updateSolutionBuffer(solutionBuffer, results, cellIDBuffer, problemCounter); std::chrono::steady_clock::time_point stop6 = std::chrono::steady_clock::now();