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
15 changes: 13 additions & 2 deletions applications/solvers/df0DFoam/Make/options
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
-include $(GENERAL_RULES)/mplibType
PYTHON_INC_DIR := $(shell python3 -m pybind11 --includes)
PYTHON_LIB_DIR := $(shell python3 -c "from distutils import sysconfig; \
import os.path as op; v = sysconfig.get_config_vars(); \
fpaths = [op.join(v[pv], v['LDLIBRARY']) for pv in ('LIBDIR', 'LIBPL')]; \
print(list(filter(op.exists, fpaths))[0])" | xargs dirname)

EXE_INC = -std=c++14 \
$(PFLAGS) $(PINC) \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
Expand All @@ -14,7 +22,8 @@ EXE_INC = -std=c++14 \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include,) \
$(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,)
$(if $(BOOST_ARCH_PATH),-DBOOST_ARCH_PATH_FOUNDD,) \
$(PYTHON_INC_DIR)

EXE_LIBS = \
-lcompressibleTransportModels \
Expand All @@ -33,4 +42,6 @@ EXE_LIBS = \
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libtorch.so,) \
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libc10.so,) \
$(if $(LIBTORCH_ROOT),-rdynamic,) \
$(if $(LIBTORCH_ROOT),-lpthread,)
$(if $(LIBTORCH_ROOT),-lpthread,) \
-L$(PYTHON_LIB_DIR) \
-lpython3.8
11 changes: 10 additions & 1 deletion applications/solvers/df0DFoam/df0DFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Description
#include "dfChemistryModel.H"
#include "CanteraMixture.H"
#include "hePsiThermo.H"
#include <pybind11/embed.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h> //used to convert

#include "fvCFD.H"
#include "dynamicFvMesh.H"
Expand All @@ -44,9 +47,15 @@ Description

int main(int argc, char *argv[])
{
pybind11::scoped_interpreter guard{}; //start python interpreter

#include "postProcess.H"

#include "setRootCaseLists.H"
// #include "setRootCaseLists.H"
#include "listOptions.H"
#include "setRootCase2.H"
#include "listOutput.H"

#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "createDyMControls.H"
Expand Down
5 changes: 5 additions & 0 deletions applications/solvers/df0DFoam/setRootCase2.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Foam::argList args(argc,argv,true,true,/*initialise=*/false);
if (!args.checkRootCase())
{
Foam::FatalError.exit();
}
12 changes: 10 additions & 2 deletions applications/solvers/dfHighSpeedFoam/Make/options
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
-include $(GENERAL_RULES)/mplibType
PYTHON_INC_DIR := $(shell python3 -m pybind11 --includes)
PYTHON_LIB_DIR := $(shell python3 -c "from distutils import sysconfig; \
import os.path as op; v = sysconfig.get_config_vars(); \
fpaths = [op.join(v[pv], v['LDLIBRARY']) for pv in ('LIBDIR', 'LIBPL')]; \
print(list(filter(op.exists, fpaths))[0])" | xargs dirname)

EXE_INC = -std=c++14 \
$(PFLAGS) $(PINC) \
Expand All @@ -17,7 +22,8 @@ EXE_INC = -std=c++14 \
-I$(DF_SRC)/dfChemistryModel/lnInclude \
-I$(CANTERA_ROOT)/include \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include,) \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,)
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,) \
$(PYTHON_INC_DIR)

EXE_LIBS = \
-lfiniteVolume \
Expand All @@ -35,4 +41,6 @@ EXE_LIBS = \
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libtorch.so,) \
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libc10.so,) \
$(if $(LIBTORCH_ROOT),-rdynamic,) \
$(if $(LIBTORCH_ROOT),-lpthread,)
$(if $(LIBTORCH_ROOT),-lpthread,) \
-L$(PYTHON_LIB_DIR) \
-lpython3.8
8 changes: 7 additions & 1 deletion applications/solvers/dfHighSpeedFoam/dfHighSpeedFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Description
#include "dfChemistryModel.H"
#include "CanteraMixture.H"
#include "hePsiThermo.H"
#include <pybind11/embed.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h> //used to convert

#include "fvCFD.H"
#include "dynamicFvMesh.H"
Expand All @@ -51,7 +54,10 @@ int main(int argc, char *argv[])
#define NO_CONTROL
#include "postProcess.H"

#include "setRootCaseLists.H"
// #include "setRootCaseLists.H"
#include "listOptions.H"
#include "setRootCase2.H"
#include "listOutput.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "createFields.H"
Expand Down
5 changes: 5 additions & 0 deletions applications/solvers/dfHighSpeedFoam/setRootCase2.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Foam::argList args(argc,argv,true,true,/*initialise=*/false);
if (!args.checkRootCase())
{
Foam::FatalError.exit();
}
12 changes: 10 additions & 2 deletions applications/solvers/dfLowMachFoam/Make/options
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
-include $(GENERAL_RULES)/mplibType
PYTHON_INC_DIR := $(shell python3 -m pybind11 --includes)
PYTHON_LIB_DIR := $(shell python3 -c "from distutils import sysconfig; \
import os.path as op; v = sysconfig.get_config_vars(); \
fpaths = [op.join(v[pv], v['LDLIBRARY']) for pv in ('LIBDIR', 'LIBPL')]; \
print(list(filter(op.exists, fpaths))[0])" | xargs dirname)

EXE_INC = -std=c++14 \
$(PFLAGS) $(PINC) \
Expand All @@ -17,7 +22,8 @@ EXE_INC = -std=c++14 \
-I$(DF_SRC)/dfCombustionModels/lnInclude \
-I$(CANTERA_ROOT)/include \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include,) \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,)
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,) \
$(PYTHON_INC_DIR)

EXE_LIBS = \
-lcompressibleTransportModels \
Expand All @@ -35,4 +41,6 @@ EXE_LIBS = \
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libtorch.so,) \
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libc10.so,) \
$(if $(LIBTORCH_ROOT),-rdynamic,) \
$(if $(LIBTORCH_ROOT),-lpthread,)
$(if $(LIBTORCH_ROOT),-lpthread,) \
-L$(PYTHON_LIB_DIR) \
-lpython3.8
9 changes: 8 additions & 1 deletion applications/solvers/dfLowMachFoam/dfLowMachFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ Description
#include "dfChemistryModel.H"
#include "CanteraMixture.H"
#include "hePsiThermo.H"
#include <pybind11/embed.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h> //used to convert

#include "fvCFD.H"
#include "fluidThermo.H"
Expand All @@ -54,7 +57,11 @@ int main(int argc, char *argv[])
{
#include "postProcess.H"

#include "setRootCaseLists.H"
// #include "setRootCaseLists.H"
#include "listOptions.H"
#include "setRootCase2.H"
#include "listOutput.H"

#include "createTime.H"
#include "createMesh.H"
#include "createDyMControls.H"
Expand Down
5 changes: 5 additions & 0 deletions applications/solvers/dfLowMachFoam/setRootCase2.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Foam::argList args(argc,argv,true,true,/*initialise=*/false);
if (!args.checkRootCase())
{
Foam::FatalError.exit();
}
14 changes: 12 additions & 2 deletions applications/solvers/dfSprayFoam/Make/options
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-include $(GENERAL_RULES)/mplibType
PYTHON_INC_DIR := $(shell python3 -m pybind11 --includes)
PYTHON_LIB_DIR := $(shell python3 -c "from distutils import sysconfig; \
import os.path as op; v = sysconfig.get_config_vars(); \
fpaths = [op.join(v[pv], v['LDLIBRARY']) for pv in ('LIBDIR', 'LIBPL')]; \
print(list(filter(op.exists, fpaths))[0])" | xargs dirname)

EXE_INC = -std=c++14 \
-I. \
-I$(FOAM_APP)/solvers/lagrangian/reactingParcelFoam \
Expand Down Expand Up @@ -27,7 +34,8 @@ EXE_INC = -std=c++14 \
-I$(DF_SRC)/dfCombustionModels/lnInclude \
-I$(CANTERA_ROOT)/include \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include,) \
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,)
$(if $(LIBTORCH_ROOT),-I$(LIBTORCH_ROOT)/include/torch/csrc/api/include,) \
$(PYTHON_INC_DIR)

EXE_LIBS = \
-lturbulenceModels \
Expand Down Expand Up @@ -55,4 +63,6 @@ EXE_LIBS = \
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libtorch.so,) \
$(if $(LIBTORCH_ROOT),$(LIBTORCH_ROOT)/lib/libc10.so,) \
$(if $(LIBTORCH_ROOT),-rdynamic,) \
$(if $(LIBTORCH_ROOT),-lpthread,)
$(if $(LIBTORCH_ROOT),-lpthread,) \
-L$(PYTHON_LIB_DIR) \
-lpython3.8
9 changes: 8 additions & 1 deletion applications/solvers/dfSprayFoam/dfSprayFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Description
#include "CanteraMixture.H"
#include "hePsiThermo.H"
#include "turbulentFluidThermoModel.H"
#include <pybind11/embed.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h> //used to convert

#include "fvCFD.H"
#include "dynamicFvMesh.H"
Expand All @@ -52,7 +55,11 @@ int main(int argc, char *argv[])
{
#include "postProcess.H"

#include "setRootCaseLists.H"
// #include "setRootCaseLists.H"
#include "listOptions.H"
#include "setRootCase2.H"
#include "listOutput.H"

#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "createDyMControls.H"
Expand Down
5 changes: 5 additions & 0 deletions applications/solvers/dfSprayFoam/setRootCase2.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Foam::argList args(argc,argv,true,true,/*initialise=*/false);
if (!args.checkRootCase())
{
Foam::FatalError.exit();
}
23 changes: 17 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh

if [ -z "$CONDA_PREFIX" ]; then
echo "You should run this script only when the conda enviorment including libcantera-devel activated."
return
fi
# if [ -z "$CONDA_PREFIX" ]; then
# echo "You should run this script only when the conda enviorment including libcantera-devel activated."
# return
# fi

print_usage() {
#printf "Usage: ...\n"
Expand Down Expand Up @@ -42,6 +42,17 @@ while test $# -gt 0; do
--libtorch_no)
shift
;;
--libcantera_dir)
shift
if test $# -gt 0; then
LIBCANTERA_DIR=$1
echo LIBCANTERA_DIR = $LIBCANTERA_DIR
else
print_usage
return
fi
shift
;;
*)
echo "$1 is not a recognized flag!"
print_usage
Expand Down Expand Up @@ -73,8 +84,8 @@ fi

cp bashrc.in bashrc
sed -i s#pwd#$PWD#g ./bashrc
echo "CONDA_PREFIX is set to $CONDA_PREFIX"
sed -i s#CONDA_PREFIX#$CONDA_PREFIX#g ./bashrc
#echo "LIBCANTERA_DIR is set to $CONDA_PREFIX"
sed -i s#CONDA_PREFIX#$LIBCANTERA_DIR#g ./bashrc
sed -i s#LIBTORCH_DIR#$LIBTORCH_DIR#g ./bashrc


Expand Down
28 changes: 28 additions & 0 deletions src/dfChemistryModel/GpuInference/DynamicBuffer.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | DLBFoam: Dynamic Load Balancing
\\ / O peration | for fast reactive simulations
\\ / A nd |
\\/ M anipulation | 2020, Aalto University, Finland
-------------------------------------------------------------------------------
License
This file is part of DLBFoam library, derived from OpenFOAM.

https://github.com/blttkgl/DLBFoam

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/
#include "DynamicBuffer.H"
namespace Foam{

}
48 changes: 48 additions & 0 deletions src/dfChemistryModel/GpuInference/DynamicBuffer.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | DLBFoam: Dynamic Load Balancing
\\ / O peration | for fast reactive simulations
\\ / A nd |
\\/ M anipulation | 2020, Aalto University, Finland
-------------------------------------------------------------------------------
License
This file is part of DLBFoam library, derived from OpenFOAM.

https://github.com/blttkgl/DLBFoam

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

Class
Foam::DynamicBuffer

Description
Currently just a typedef to DynamicList<DynamicList>. Could possibly be made
constant size at some point to avoid allocations during runtime.

\*---------------------------------------------------------------------------*/

#ifndef DynamicBuffer_H
#define DynamicBuffer_H

#include "DynamicList.H"

namespace Foam
{

template <class T>
using DynamicBuffer = DynamicList<DynamicList<T>>;

}

#endif
29 changes: 29 additions & 0 deletions src/dfChemistryModel/GpuInference/GpuProblem.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "GpuProblem.H"
namespace Foam{

}
Loading