Skip to content

Commit

Permalink
Changes for compiling in v2112 AD mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
friedenhe committed Dec 13, 2024
1 parent 21620ee commit 8f17fa6
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 6 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
default:
(cd src && python setup.py build_ext --inplace)
(mv src/*.so pyofm)
(cd src && ./Allmake && cd -)

clean:
(cd src && rm -rf *.cpp *.so build)
(cd src && ./Allclean && cd -)
(rm -rf */__pycache__ */*/__pycache__)
4 changes: 4 additions & 0 deletions src/Allclean
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

rm -rf build *.so *.cpp *.h
wclean
13 changes: 13 additions & 0 deletions src/Allmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# the script will exit if there is any error
set -e

if [ -z "$WM_PROJECT" ]; then
echo "OpenFOAM environment not found, forgot to source the OpenFOAM bashrc?"
exit 1
fi

cythonize -3 pyOFMesh.pyx
wmake -j
cp -r *.so ../pyofm/
4 changes: 4 additions & 0 deletions src/Make/files
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
OFMesh.C
pyOFMesh.cpp

LIB = pyOFMesh.$(shell python3 -c 'import sysconfig; ext_suffix = sysconfig.get_config_var("EXT_SUFFIX"); print(ext_suffix.split(".")[1])')
18 changes: 18 additions & 0 deletions src/Make/options
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(MPI_ARCH_PATH)/include \
-I$(MPI_ARCH_PATH)/include64 \
$(shell python3 -c "import numpy; print('-I' + numpy.get_include())") \
$(shell python3-config --includes) \


LIB_LIBS = \
-lmeshTools \
-lfiniteVolume \
-L$(MPI_ARCH_PATH)/lib \
-L$(MPI_ARCH_PATH)/lib64 \
$(shell python3-config --ldflags)
12 changes: 10 additions & 2 deletions src/OFMesh.H
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public:
const label pointI,
const label compI) const
{
#if defined(CODI_AD_FORWARD) || defined(CODI_AD_REVERSE)
#if defined(DAOF_AD_MODE_T1S) || defined(DAOF_AD_MODE_A1S)
return meshPtr_().points()[pointI][compI].getValue();
#else
return meshPtr_().points()[pointI][compI];
Expand Down Expand Up @@ -192,7 +192,11 @@ public:

forAll(state, cellI)
{
#if defined(DAOF_AD_MODE_T1S) || defined(DAOF_AD_MODE_A1S)
field[cellI] = state[cellI].getValue();
#else
field[cellI] = state[cellI];
#endif
}
}
else if (fieldType == "volVectorField")
Expand All @@ -212,7 +216,11 @@ public:
{
for (label i = 0; i < 3; i++)
{
field[counterI] = state[cellI][i];
#if defined(DAOF_AD_MODE_T1S) || defined(DAOF_AD_MODE_A1S)
field[counterI] = state[cellI][i].getValue();
#else
field[counterI] = state[cellI][i];
#endif
counterI++;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"-m64",
"-pthread",
"-DOPENFOAM=2112",
"-DDAOF_AD_TOOL_DCO_FOAM",
"-DDAOF_AD_TOOL_CODI"
"-DDAOF_AD_MODE_A1S",
#"-Dlinux64",
#"-DWM_ARCH_OPTION=64",
"-DWM_DP",
Expand Down

0 comments on commit 8f17fa6

Please sign in to comment.