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/df0DFoam/Make/options
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
-include $(GENERAL_RULES)/mplibType

EXE_INC = -std=c++14 \
-Wno-old-style-cast \
$(PFLAGS) $(PINC) \
$(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
Expand All @@ -20,8 +21,8 @@ EXE_INC = -std=c++14 \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,) \
$(if $(BOOST_ARCH_PATH),-I$(BOOST_ARCH_PATH),) \
$(if $(BOOST_ARCH_PATH),-DBOOST_ARCH_PATH_FOUNDD,) \
$(PYTHON_INC_DIR)
$(PYTHON_INC_DIR)



EXE_LIBS = \
Expand Down
3 changes: 2 additions & 1 deletion applications/solvers/dfHighSpeedFoam/Make/options
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
-include $(GENERAL_RULES)/mplibType

EXE_INC = -std=c++14 \
-Wno-old-style-cast \
$(PFLAGS) $(PINC) \
$(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
-I$(FOAM_APP)/solvers/compressible/rhoCentralFoam/BCs/lnInclude \
-I$(LIB_SRC)/finiteVolume/cfdTools \
-I$(LIB_SRC)/finiteVolume/lnInclude \
Expand Down
3 changes: 2 additions & 1 deletion applications/solvers/dfLowMachFoam/Make/options
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
-include $(GENERAL_RULES)/mplibType

EXE_INC = -std=c++14 \
-Wno-old-style-cast \
$(PFLAGS) $(PINC) \
$(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
Expand Down
3 changes: 2 additions & 1 deletion applications/solvers/dfSprayFoam/Make/options
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-include $(GENERAL_RULES)/mplibType

EXE_INC = -std=c++14 \
-Wno-old-style-cast \
-I. \
-I$(FOAM_APP)/solvers/lagrangian/reactingParcelFoam \
-I$(FOAM_APP)/solvers/compressible/rhoPimpleFoam \
Expand Down Expand Up @@ -31,7 +32,7 @@ EXE_INC = -std=c++14 \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include,) \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,) \
$(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
$(PYTHON_INC_DIR)

EXE_LIBS = \
Expand Down
7 changes: 6 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/sh


unset USE_LIBTORCH
unset USE_PYTORCH
unset LIBTORCH_DIR
unset LIBCANTERA_DIR
unset PYTORCH_INC
unset PYTORCH_LIB

print_usage() {
echo "Usage: . install.sh --libtorch_no (default) | --libtorch_dir _path_to_libtorch | --libtorch_autodownload | --use_pytorch | --libcantera_dir _path_to_libcantera"
Expand Down
2 changes: 1 addition & 1 deletion src/CanteraMixture/CanteraMixture.H
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public:
scalarList Cp_R(nSpecies());
CanteraGas_->getCp_R(Cp_R.begin());
CpTemp_ = Cp_R*RR;
for(int i=0; i<nSpecies(); ++i)
for(int i=0; i<(int)nSpecies(); ++i)
{
CvTemp_[i] = CpTemp_[i] - RR;
}
Expand Down
1 change: 1 addition & 0 deletions src/CanteraMixture/Make/options
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
EXE_INC = \
-Wno-old-style-cast \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
Expand Down
1 change: 1 addition & 0 deletions src/dfChemistryModel/Make/options
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-include $(GENERAL_RULES)/mplibType

EXE_INC = -std=c++14 \
-Wno-old-style-cast \
$(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
Expand Down
48 changes: 24 additions & 24 deletions src/dfChemistryModel/dfChemistryModel.C
Original file line number Diff line number Diff line change
Expand Up @@ -520,34 +520,34 @@ Foam::dfChemistryModel<ThermoType>::getGPUProblems
// choose DNN module
if ((Qdot_[cellI] < Qdotact2_) && (T_[cellI] < Tact2_) && ( T_[cellI] >= Tact1_))//choose1
{
problem.DNNid = 0;
problem.DNNid = 0;
problemList.append(problem);
continue;
}
if(((Qdot_[cellI] >= Qdotact2_) && (T_[cellI] < Tact2_)&&(T_[cellI] >= Tact1_))||((Qdot_[cellI] > Qdotact3_) && T_[cellI] > Tact2_)) //choose2
{
problem.DNNid = 1;
problem.DNNid = 1;
problemList.append(problem);
continue;
}
if ((Qdot_[cellI] < Qdotact3_) && (T_[cellI] >= Tact2_) && (Qdot_[cellI]!=0)) //choose3
{
problem.DNNid = 2;
problem.DNNid = 2;
problemList.append(problem);
continue;
}

}

return problemList;
return problemList;
}

template <class ThermoType>
void Foam::dfChemistryModel<ThermoType>::getDNNinputs
(
const Foam::DynamicBuffer<GpuProblem>& problemBuffer,
const Foam::DynamicBuffer<GpuProblem>& problemBuffer,
std::vector<label>& outputLength,
std::vector<std::vector<double>>& DNNinputs,
std::vector<std::vector<double>>& DNNinputs,
std::vector<Foam::DynamicBuffer<label>>& cellIDBuffer,
std::vector<std::vector<label>>& problemCounter
)
Expand Down Expand Up @@ -610,7 +610,7 @@ void Foam::dfChemistryModel<ThermoType>::getDNNinputs
counter2++;
cellIDList2.append(problemBuffer[i][cellI].cellid);
break;

default:
Info<<"invalid input"<<endl;
break;
Expand Down Expand Up @@ -638,7 +638,7 @@ void Foam::dfChemistryModel<ThermoType>::getDNNinputs
// auto inputTensor1 = torch::tensor(inputsDNN1);
// inputTensor1 = inputTensor1.reshape({length1, mixture_.nSpecies() + 3});
// auto inputTensor2 = torch::tensor(inputsDNN2);
// inputTensor2 = inputTensor2.reshape({length2, mixture_.nSpecies() + 3});
// inputTensor2 = inputTensor2.reshape({length2, mixture_.nSpecies() + 3});

// set output
outputLength = {length0, length1, length2};
Expand All @@ -658,7 +658,7 @@ void Foam::dfChemistryModel<ThermoType>::getDNNinputs
template <class ThermoType>
void Foam::dfChemistryModel<ThermoType>::updateSolutionBuffer
(
Foam::DynamicBuffer<Foam::GpuSolution>& solutionBuffer,
Foam::DynamicBuffer<Foam::GpuSolution>& solutionBuffer,
const std::vector<std::vector<double>>& results,
const std::vector<Foam::label>& outputLength,
const std::vector<Foam::DynamicBuffer<Foam::label>>& cellIDBuffer,
Expand Down Expand Up @@ -731,14 +731,14 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::solve_DNN_GPU(
/*==============================send problems==============================*/
std::chrono::steady_clock::time_point start2 = std::chrono::steady_clock::now();

PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
if (Pstream::myProcNo() % coresPerGPU) //for slave
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
if (Pstream::myProcNo() % coresPerGPU) //for slave
{
UOPstream send((Pstream::myProcNo()/coresPerGPU)*coresPerGPU, pBufs);// sending problem to master
send << problemList;
}
pBufs.finishedSends();

DynamicBuffer<GpuSolution> solutionBuffer;

std::chrono::steady_clock::time_point stop2 = std::chrono::steady_clock::now();
Expand All @@ -751,7 +751,7 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::solve_DNN_GPU(
{
std::chrono::steady_clock::time_point start1 = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point start3 = std::chrono::steady_clock::now();

label problemSize = 0; // problemSize is defined to debug
DynamicBuffer<GpuProblem> problemBuffer(coresPerGPU);//each submaster init a local problemBuffer TODO:rename it

Expand Down Expand Up @@ -804,10 +804,10 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::solve_DNN_GPU(
std::chrono::duration<double> processingTime6 = std::chrono::duration_cast<std::chrono::duration<double>>(stop6 - start6);
std::cout << "updateSolutionBufferTime = " << processingTime6.count() << std::endl;
time_updateSolutionBuffer_ += processingTime6.count();

std::chrono::steady_clock::time_point stop1 = std::chrono::steady_clock::now();
std::chrono::duration<double> processingTime1 = std::chrono::duration_cast<std::chrono::duration<double>>(stop1 - start1);
std::cout << "submasterTime = " << processingTime1.count() << std::endl;
std::cout << "submasterTime = " << processingTime1.count() << std::endl;
time_submaster_ += processingTime1.count();
}

Expand All @@ -821,19 +821,19 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::solve_DNN_GPU(
finalList = solutionBuffer[0];
for (label i = 1; i < coresPerGPU; i++)
{

UOPstream send(i + Pstream::myProcNo(), pBufs2);
send << solutionBuffer[i];
}
}
pBufs2.finishedSends();

if (Pstream::myProcNo() % coresPerGPU)
{
UIPstream recv((Pstream::myProcNo()/coresPerGPU)*coresPerGPU, pBufs2);
recv >> finalList;
}

std::chrono::steady_clock::time_point stop4 = std::chrono::steady_clock::now();
std::chrono::duration<double> processingTime4 = std::chrono::duration_cast<std::chrono::duration<double>>(stop4 - start4);
std::cout << "SendRecvSolutionTime = " << processingTime4.count() << std::endl;
Expand Down Expand Up @@ -1078,7 +1078,7 @@ Foam::dfChemistryModel<ThermoType>::getProblems
forAll(T, celli)
{
{
for(label i = 0; i < mixture_.nSpecies(); i++)
for(label i = 0; i < (int)(mixture_.nSpecies()); i++)
{
yTemp_[i] = Y_[i][celli];
}
Expand Down Expand Up @@ -1155,7 +1155,7 @@ Foam::dfChemistryModel<ThermoType>::updateReactionRates
for(const auto& solution : array)
{

for(label j = 0; j < mixture_.nSpecies(); j++)
for(label j = 0; j < int(mixture_.nSpecies()); j++)
{
this->RR_[j][solution.cellid] = solution.RRi[j];
}
Expand Down Expand Up @@ -1452,23 +1452,23 @@ Foam::dfChemistryModel<ThermoType>::getGPUProblems
// choose DNN module
if ((Qdot_[cellI] < Qdotact2_) && (T_[cellI] < Tact2_) && ( T_[cellI] >= Tact1_))//choose1
{
problem.DNNid = 0;
problem.DNNid = 0;
problemList.append(problem);
continue;
}
if(((Qdot_[cellI] >= Qdotact2_) && (T_[cellI] < Tact2_)&&(T_[cellI] >= Tact1_))||((Qdot_[cellI] > Qdotact3_) && T_[cellI] > Tact2_)) //choose2
{
problem.DNNid = 1;
problem.DNNid = 1;
problemList.append(problem);
continue;
}
if ((Qdot_[cellI] < Qdotact3_) && (T_[cellI] >= Tact2_) && (Qdot_[cellI]!=0)) //choose3
{
problem.DNNid = 2;
problem.DNNid = 2;
problemList.append(problem);
continue;
}

}

return problemList;
Expand Down
3 changes: 2 additions & 1 deletion src/dfCombustionModels/Make/options
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
-include $(GENERAL_RULES)/mplibType

EXE_INC = -std=c++14 \
-Wno-old-style-cast \
$(if $(LIBTORCH_ROOT),-DUSE_LIBTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
$(if $(PYTHON_INC_DIR),-DUSE_PYTORCH,) \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
Expand Down
2 changes: 1 addition & 1 deletion src/functionObjects/field/Make/options
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ LIB_LIBS = \
-lfileFormats \
-lsampling \
-lsurfMesh \
-L$(FOAM_USER_LIBBIN) \
-L$(FOAM_USER_LIBBIN) \
-ldfFluidThermophysicalModels
1 change: 1 addition & 0 deletions src/lagrangian/intermediate/Make/options
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
EXE_INC = \
-Wno-old-style-cast \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
-I$(DF_SRC)/lagrangian/intermediate/lnInclude \
Expand Down
1 change: 1 addition & 0 deletions src/lagrangian/spray/Make/options
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
EXE_INC = \
-Wno-old-style-cast \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(DF_SRC)/lagrangian/intermediate/lnInclude \
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
Expand Down
1 change: 1 addition & 0 deletions src/lagrangian/turbulence/Make/options
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
EXE_INC = \
-Wno-old-style-cast \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(DF_SRC)/lagrangian/intermediate/lnInclude \
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
Expand Down
1 change: 1 addition & 0 deletions src/regionModels/surfaceFilmModels/Make/options
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
EXE_INC = \
-Wno-old-style-cast \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(DF_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \
Expand Down
1 change: 1 addition & 0 deletions src/thermophysicalModels/SLGThermo/Make/options
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
EXE_INC = \
-Wno-old-style-cast \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(DF_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \
Expand Down