CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to create a new mapFields functionObjects? (https://www.cfd-online.com/Forums/openfoam-programming-development/250481-how-create-new-mapfields-functionobjects.html)

quarkz June 17, 2023 06:57

How to create a new mapFields functionObjects?
 
Hi,

I need to modify mapFields to create a custom mapper as mentioned here:
https://www.cfd-online.com/Forums/op...mapfields.html

I start off by just making a clone of mapFields, called mapFields_dynamicMesh to make sure that's it's working.

I tried to follow the tutorial by Prof Nilsson, just changing the names to work on mapFields:
https://www.tfd.chalmers.se/~hani/ku...tionObject.pdf

The steps are:

cp -r --parents src/functionObjects/field/mapFields $WM_PROJECT_USER_DIR
cd $WM_PROJECT_USER_DIR/src/functionObjects/field
mv mapFields mapFields_dynamicMesh
cd mapFields_dynamicMesh
sed -i 's/mapFields/mapFields_dynamicMesh/g' *
rename 's/mapFields/mapFields_dynamicMesh/' *

Make/files:

Code:

mapFields_dynamicMesh/mapFields_dynamicMesh.C

LIB = $(FOAM_USER_LIBBIN)/libmyFieldFunctionObjects

Make/options:

Code:

EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/finiteArea/lnInclude \
    -I$(LIB_SRC)/fileFormats/lnInclude \
    -I$(LIB_SRC)/surfMesh/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/dynamicMesh/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude \
    -I$(LIB_SRC)/lagrangian/basic/lnInclude \
    -I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/compressible/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/schemes/lnInclude \
    -I$(LIB_SRC)/transportModels/compressible/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
    -I$(LIB_SRC)/fvAgglomerationMethods/pairPatchAgglomeration/lnInclude \
    -I$(LIB_SRC)/phaseSystemModels/multiphaseInter/phasesSystem/lnInclude \
    -I$(LIB_SRC)/phaseSystemModels/reactingEuler/multiphaseSystem/lnInclude \
    -I$(LIB_SRC)/functionObjects/field/lnInclude

LIB_LIBS = \
    -lfiniteVolume \
    -lfiniteArea \
    -lfileFormats \
    -lsurfMesh \
    -lmeshTools \
    -ldynamicMesh \
    -lsampling \
    -llagrangian \
    -ldistributionModels \
    -lfluidThermophysicalModels \
    -lsolidThermo \
    -lincompressibleTransportModels \
    -lturbulenceModels \
    -lcompressibleTransportModels \
    -lincompressibleTurbulenceModels \
    -lcompressibleTurbulenceModels \
    -lturbulenceModelSchemes \
    -lchemistryModel \
    -lreactionThermophysicalModels \
    -lpairPatchAgglomeration \
    -lincompressibleMultiphaseSystems \
    -lreactingMultiphaseSystem \
    -lfieldFunctionObjects

It compiled w/o error but it seems to compile to a libmyFieldFunctionObjects library instead of an application like mapFields

So what should I change to make it work?

I think I have to do something like:

EXE = $(FOAM_USER_APPBIN)/mapFields_dynamicMesh

but I'm not sure how.

Can someone help?

Thanks!

einstein_zee June 17, 2023 15:20

Hi there,

I didn't get completely what you want to achieve. And it seems the things you discussed are different from each other. mapFields function object refers to "Maps input fields from local mesh to secondary mesh at runtime." (@https://develop.openfoam.com/Development/openfoam/-/blob/OpenFOAM-v2212/src/functionObjects/field/mapFields/mapFields.H) and mapFields as a standalone application is a preProcessing tool which is described as "Maps volume fields from one mesh to another, reading and interpolating all fields present in the time directory of both cases" (@https://develop.openfoam.com/Development/openfoam/-/blob/OpenFOAM-v2212/applications/utilities/preProcessing/mapFields/mapFields.C). So depending on which one you need for your case you need to modify the corresponding one. If you need the function object one, you should use it like every other function object. Just as an example refer to OpenFOAM-v2212/tutorials/incompressible/pimpleFoam/laminar/cylinder2D.


All times are GMT -4. The time now is 09:25.