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/)
-   -   Defining custom Cp library under 2.2.x (https://www.cfd-online.com/Forums/openfoam-programming-development/120888-defining-custom-cp-library-under-2-2-x.html)

zqlhzx October 5, 2013 21:43

1 Attachment(s)
Dear dkxls:
Thank you for your previous replies!
I think I still have to use "absoluteEnthalpy".I am new to OpenFOAM.I had a great progress by your help about my problem ,But if I would like to solve my problemcompletely, your help is necessary for me.
According to your "myThermos.C",I add the following codes into "myThermos.C":
Code:

makeReactionMixtureThermo
(
psiThermo,
psiReactionThermo,
hePsiThermo,
homogeneousMixture,
gasHaThermoPhysics
);
makeReactionMixtureThermo
(
psiThermo,
psiReactionThermo,
hePsiThermo,
inhomogeneousMixture,
gasHaThermoPhysics
);
makeReactionMixtureThermo
(
psiThermo,
psiReactionThermo,
hePsiThermo,
veryInhomogeneousMixture,
gasHaThermoPhysics
);

Then I can define the new four thermotypes like the following:

Quote:

thermoType
{
type hePsiThermo;
mixture homogeneousMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
}
thermoType
{
type hePsiThermo;
mixture inhomogeneousMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
}
thermoType
{
type hePsiThermo;
mixture veryInhomogeneousMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
}
thermoType
{
type hePsiThermo;
mixture multiComponentMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
}
However the thermotype I want to use is
thermoType
{
type hePsiThermo;
mixture reactingMixture;
transport sutherland;
thermo janaf;
energy absoluteEnthalpy;
equationOfState perfectGas;
specie specie;
},so I add the codes:
Code:

makeReactionMixtureThermo
(
psiThermo,
psiReactionThermo,
hePsiThermo,
reactingMixture,
gasHaThermoPhysics
)

into "myThermos.C".When I run my case ,it gave me error :
Quote:

FOAM Warning :
From function dlOpen(const fileName&, const bool)
in file POSIX.C at line 1179
dlopen error : /home/administrator/OpenFOAM/administrator-2.2.1/platforms/linuxGccDPOpt/lib/libmyThermos.so: undefined symbol: _ZN4Foam15chemistryReaderINS_19sutherlandTransport INS_7species6thermoINS_11janafThermoINS_10perfectG asINS_6specieEEEEENS_16absoluteEnthalpyEEEEEE30dic tionaryConstructorTablePtr_E
--> FOAM Warning :
From function dlLibraryTable::open(const fileName&, const bool)
in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99
could not load "libmyThermos.so"
FOAM Warning :
From function dlOpen(const fileName&, const bool)
in file POSIX.C at line 1179
dlopen error : /home/administrator/OpenFOAM/administrator-2.2.1/platforms/linuxGccDPOpt/lib/libmyThermos.so: undefined symbol: _ZN4Foam15chemistryReaderINS_19sutherlandTransport INS_7species6thermoINS_11janafThermoINS_10perfectG asINS_6specieEEEEENS_16absoluteEnthalpyEEEEEE30dic tionaryConstructorTablePtr_E
--> FOAM Warning :
From function dlLibraryTable::open(const fileName&, const bool)
in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99
could not load "libmyThermos.so"
I also add the file of "mymakeChemistrySolvers.C","mypsiChemistryMode ls", I still failed with the same error.I think I should also add the file of "mymakeChemistryReaders.C",but I do not know how to do it.How should I change the codes to correct the above error?Please take a look on my attachment.Thanks in advance!After reading your replies on CFD-online,I am sure you are experted in OpenFOAM and C++.
Attachment 25835

Bryan S December 9, 2013 12:26

Quote:

Originally Posted by dkxls (Post 451645)
OK here is how you enable e.g. the absolute enthalpy in your solver. The coding involved is very simple, once you know what to do. :)
1. Create a new library that assembles the necessary bits:
I attached a zip archive with the necessary code to include the standard OpenFOAM absolute enthalpy thermo, but this can be extended easily to own implementations of e.g. Cp or viscosity as well.

2. Link your solver against that new library:
I assume you know how to link your solver against new libraries, at least there should be some tutorial/wiki somewhere.

-Armin

Hi Armin,
I'm trying to create a thermo model that combines hConst thermodynamics with Sutherland transport for a multiComponentMixture. I edited a couple lines in the files you provided to do this, but when I try to wmake I get the following error:
Quote:

/opt/openfoam220/src/finiteVolume/lnInclude/cyclicAMIFvPatchField.H:62:40: fatal error: cyclicAMILduInterfaceField.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/myThermos.o] Error 1
Any suggestions for a fix?

Also I'm not clear how to link a solver against a new library, do you think you could give me a quick step-by-step? Thanks.
-B

dkxls December 10, 2013 03:23

Can you upload your modified version?

The error looks rather strange as a thermo shouldn't pull in any dependencies on AMI or the like.

dkxls December 10, 2013 03:28

I posted earlier some instructions on how to include a lib in a solver (or even a case):
http://www.cfd-online.com/Forums/ope...tml#post452252
http://www.cfd-online.com/Forums/ope...tml#post451937

Bryan S December 10, 2013 12:18

1 Attachment(s)
Quote:

Originally Posted by dkxls (Post 465642)
Can you upload your modified version?

The error looks rather strange as a thermo shouldn't pull in any dependencies on AMI or the like.

Sure, I just changed a couple lines from the files you uploaded to reflect the model I want to use.

dkxls December 11, 2013 04:28

I checked your code and it seems fine.
I also don't get any compilation error, it just compiles fine!

Just to make sure:
1. You need OpenFOAM version 2.2.x
2. Compiling is done like this:
Code:

cd path/to/myThermo
wmake libso

3. Linking your solver against myThermo is done by editing the options file of your solver to look like this (here e.g. reactingFoam):
Code:

EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/fvOptions/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \
    -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
    -I$(LIB_SRC)/ODE/lnInclude \
    -I$(LIB_SRC)/combustionModels/lnInclude

EXE_LIBS = \
    -L$(FOAM_USER_LIBBIN) \
    -lfiniteVolume \
    -lfvOptions \
    -lmeshTools \
    -lsampling \
    -lcompressibleTurbulenceModel \
    -lcompressibleRASModels \
    -lcompressibleLESModels \
    -lreactionThermophysicalModels \
    -lspecie \
    -lfluidThermophysicalModels \
    -lchemistryModel \
    -lODE \
    -lcombustionModels \
  -lmyThermo


Bryan S December 11, 2013 12:26

Thanks, I'm still getting the same error. The full message looks like this:

Code:

~/OpenFOAM/bschmidt-2.2.0/src/thermoPhysicalModels/myThermo$ wmake libso

wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file myThermos.C
could not open file cyclicAMILduInterfaceField.H for source file myThermos.C
could not open file cyclicAMILduInterface.H for source file myThermos.C
could not open file cyclicAMIPolyPatch.H for source file myThermos.C
SOURCE=myThermos.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam220/src/thermophysicalModels/specie/lnInclude -I/opt/openfoam220/src/thermophysicalModels/reactionThermo/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/myThermos.o
In file included from /opt/openfoam220/src/finiteVolume/lnInclude/jumpCyclicAMIFvPatchField.H:47:0,
                from /opt/openfoam220/src/finiteVolume/lnInclude/fixedJumpAMIFvPatchField.H:71,
                from /opt/openfoam220/src/finiteVolume/lnInclude/fixedJumpAMIFvPatchFields.H:29,
                from /opt/openfoam220/src/thermophysicalModels/basic/lnInclude/heThermo.C:32,
                from /opt/openfoam220/src/thermophysicalModels/basic/lnInclude/heThermo.H:320,
                from /opt/openfoam220/src/thermophysicalModels/basic/lnInclude/hePsiThermo.H:39,
                from myThermos.C:30:
/opt/openfoam220/src/finiteVolume/lnInclude/cyclicAMIFvPatchField.H:62:40: fatal error: cyclicAMILduInterfaceField.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/myThermos.o] Error 1

I have OpenFOAM 2.2.0, I can't find where it's trying to call cyclicAMILduInterfaceField.H from, and I don't know why it would be calling that in the first place.

dkxls December 11, 2013 13:39

OK, sounds a bit strange. I doubt that it has something to do with the OF version (I never used 2.2.0 though, I upgraded directly from 2.0.x to a 2.2.x git version newer than 2.2.1).

Are these files (cyclicAMILduInterfaceField.H, ...) listed in your myThermos.dep file?
In mine they are not, actually there is no *AMI*.H file at all in my myThermos.dep.

Just to make sure:
You ran 'wclean' in the 'myThermo' directory?
And there is no old 'myThermos.dep' left? (You can savely remove the *.dep files, wmake will generate new ones.)

Otherwise, I have no idea since I cannot reproduce your error.

Bryan S December 11, 2013 13:58

Those files are not in my dependency file, and I always run wclean before wmake. The only *AMI* files in myThermos.dep are *AMIFvPatch* files. I was trying to trace back from the error message what line of code was calling for this *AMILdu* file, but I can't find it.

Maybe you can help me with this: why does the Make/options file need to include a link to the $LIB_SRC/finiteVolume/lnInclude folder? I can't find anything in the .C file or .H file that link to anything there. Maybe that will help me find where the erroneous call to *AMILdu* is being made.

dkxls December 11, 2013 16:10

The files you include in your lib will include themselves new dependencies and you need to tell the compiler where to find them.

Something you could try is to change the options file to match the one in the thermo library:
https://github.com/OpenFOAM/OpenFOAM...o/Make/options

Bryan S December 11, 2013 16:44

Ha! That worked! I only had to include one more line in the file,
Code:

-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude
No idea why it works now and not before, but such is the nature of programming. Thanks for your help!

SH_Zhong July 25, 2017 02:29

Hi dkxls,
Have you shared your code to calculate the mixture viscosity and conductivity to public.

"For mixture I use the formulations due to Wilke (viscosity) and Mathur (conductivity)"

If you can share the code with me, it will be very helpful. And many thanks in advance.

Zhong


All times are GMT -4. The time now is 15:29.