Skip to content
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
7 changes: 4 additions & 3 deletions applications/solvers/dfLowMachFoam/YEqn.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ const surfaceScalarField phiUc = linearInterpolate(sumYDiffError) & mesh.Sf();
{
if (!splitting)
{
start = std::clock();
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
combustion->correct();
label flag_mpi_init;
MPI_Initialized(&flag_mpi_init);
if(flag_mpi_init) MPI_Barrier(PstreamGlobals::MPI_COMM_FOAM);
end = std::clock();
time_monitor_chem += double(end - start) / double(CLOCKS_PER_SEC);
std::chrono::steady_clock::time_point stop = std::chrono::steady_clock::now();
std::chrono::duration<double> processingTime = std::chrono::duration_cast<std::chrono::duration<double>>(stop - start);
time_monitor_chem += processingTime.count();
}

volScalarField Yt(0.0*Y[0]);
Expand Down
12 changes: 12 additions & 0 deletions applications/solvers/dfLowMachFoam/dfLowMachFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ int main(int argc, char *argv[])

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
#ifdef USE_PYTORCH
<< " allsolveTime = " << chemistry->time_allsolve() << " s"
<< " submasterTime = " << chemistry->time_submaster() << " s" << nl
<< " sendProblemTime = " << chemistry->time_sendProblem() << " s"
<< " recvProblemTime = " << chemistry->time_RecvProblem() << " s"
<< " sendRecvSolutionTime = " << chemistry->time_sendRecvSolution() << " s" << nl
<< " getDNNinputsTime = " << chemistry->time_getDNNinputs() << " s"
<< " DNNinferenceTime = " << chemistry->time_DNNinference() << " s"
<< " updateSolutionBufferTime = " << chemistry->time_updateSolutionBuffer() << " s" << nl
<< " vec2ndarrayTime = " << chemistry->time_vec2ndarray() << " s"
<< " pythonTime = " << chemistry->time_python() << " s"
#endif
<< nl << endl;
}

Expand Down
6 changes: 3 additions & 3 deletions src/dfChemistryModel/dfChemistryModel.C
Original file line number Diff line number Diff line change
Expand Up @@ -1382,9 +1382,9 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::torchDCUSolve(
std::chrono::steady_clock::time_point start7 = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point start8 = std::chrono::steady_clock::now();

pybind11::array_t<double> vec0 = pybind11::cast(DNNinputs[0]); // cast vector to np.array
pybind11::array_t<double> vec1 = pybind11::cast(DNNinputs[1]);
pybind11::array_t<double> vec2 = pybind11::cast(DNNinputs[2]);
pybind11::array_t<double> vec0 = pybind11::array_t<double>({DNNinputs[0].size()}, {8}, &DNNinputs[0][0]); // cast vector to np.array
pybind11::array_t<double> vec1 = pybind11::array_t<double>({DNNinputs[1].size()}, {8}, &DNNinputs[1][0]);
pybind11::array_t<double> vec2 = pybind11::array_t<double>({DNNinputs[2].size()}, {8}, &DNNinputs[2][0]);

std::chrono::steady_clock::time_point stop8 = std::chrono::steady_clock::now();
std::chrono::duration<double> processingTime8 = std::chrono::duration_cast<std::chrono::duration<double>>(stop8 - start8);
Expand Down
18 changes: 17 additions & 1 deletion src/dfChemistryModel/dfChemistryModel.H
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ SourceFiles
#ifdef USE_PYTORCH
#include <pybind11/embed.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h> //used to convert
#include <pybind11/stl.h>
#include <pybind11/stl_bind.h>
#include "GpuProblem.H"
#include "GpuSolution.H"
#include "DynamicBuffer.H"
Expand Down Expand Up @@ -293,6 +294,21 @@ public:
ThermoType& thermo() {return thermo_;}

const CanteraMixture& mixture() {return mixture_;}

// profiling
#ifdef USE_PYTORCH
double time_allsolve() {return time_allsolve_;}
double time_submaster() {return time_submaster_;}
double time_sendProblem() {return time_sendProblem_;}
double time_RecvProblem() {return time_RecvProblem_;}
double time_sendRecvSolution() {return time_sendRecvSolution_;}
double time_getDNNinputs() {return time_getDNNinputs_;}
double time_DNNinference() {return time_DNNinference_;}
double time_updateSolutionBuffer() {return time_updateSolutionBuffer_;}
double time_vec2ndarray() {return time_vec2ndarray_;}
double time_python() {return time_python_;}
#endif

};


Expand Down