Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update torchFunctions #383

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/dfChemistryModel/pytorchFunctions.H
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::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<pybind11::array_t<double>>().data();
std::vector<double> outputsVec0(star, star+outputLength[0] * 7); //the float number is sample_length*sample_number
std::vector<double> outputsVec1(star+outputLength[0] * 7, star+outputLength[1] * 7);
std::vector<double> outputsVec2(star+outputLength[1] * 7, star+outputLength[2] * 7);
std::vector<double> outputsVec0(star, star+outputLength[0] * mixture_.nSpecies()); //the float number is sample_length*sample_number
std::vector<double> outputsVec1(star+outputLength[0] * mixture_.nSpecies(), star+outputLength[1] * mixture_.nSpecies());
std::vector<double> outputsVec2(star+outputLength[1] * mixture_.nSpecies(), star+outputLength[2] * mixture_.nSpecies());
std::vector<std::vector<double>> results = {outputsVec0, outputsVec1, outputsVec2};
updateSolutionBuffer(solutionBuffer, results, cellIDBuffer, problemCounter);
DynamicList<GpuSolution> finalList;
Expand All @@ -301,4 +301,4 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::solve_DNN(const DeltaTType &del
time_allsolve_ += processingTime.count();

return deltaTMin;
}
}
6 changes: 3 additions & 3 deletions src/dfChemistryModel/torchFunctions.H
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ void Foam::dfChemistryModel<ThermoType>::getDNNinputs

if (gpulog_)
{
std::cout<<"inputsDNN0 = "<<inputsDNN0.size()/10 << "\n";
std::cout<<"inputsDNN1 = "<<inputsDNN1.size()/10 << "\n";
std::cout<<"inputsDNN2 = "<<inputsDNN2.size()/10 << "\n";
std::cout<<"inputsDNN0 = "<<inputsDNN0.size()/(mixture_.nSpecies()+3) << "\n";
std::cout<<"inputsDNN1 = "<<inputsDNN1.size()/(mixture_.nSpecies()+3) << "\n";
std::cout<<"inputsDNN2 = "<<inputsDNN2.size()/(mixture_.nSpecies()+3) << "\n";
}

return;
Expand Down
Loading