CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Defining custom Cp library under 2.2.x

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree4Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 5, 2013, 22:43
Default
  #21
Member
 
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 12
zqlhzx is on a distinguished road
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:pen(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:pen(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++.
myThermo.zip
zqlhzx is offline   Reply With Quote

Old   December 9, 2013, 13:26
Default
  #22
New Member
 
Bryan Schmidt
Join Date: Sep 2013
Posts: 18
Rep Power: 12
Bryan S is on a distinguished road
Quote:
Originally Posted by dkxls View Post
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
Bryan S is offline   Reply With Quote

Old   December 10, 2013, 04:23
Default
  #23
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
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 is offline   Reply With Quote

Old   December 10, 2013, 04:28
Default
  #24
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
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
dkxls is offline   Reply With Quote

Old   December 10, 2013, 13:18
Default
  #25
New Member
 
Bryan Schmidt
Join Date: Sep 2013
Posts: 18
Rep Power: 12
Bryan S is on a distinguished road
Quote:
Originally Posted by dkxls View Post
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.
Attached Files
File Type: zip myThermo.zip (6.0 KB, 24 views)
Bryan S is offline   Reply With Quote

Old   December 11, 2013, 05:28
Default
  #26
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
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
dkxls is offline   Reply With Quote

Old   December 11, 2013, 13:26
Default
  #27
New Member
 
Bryan Schmidt
Join Date: Sep 2013
Posts: 18
Rep Power: 12
Bryan S is on a distinguished road
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.
Bryan S is offline   Reply With Quote

Old   December 11, 2013, 14:39
Default
  #28
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
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.
dkxls is offline   Reply With Quote

Old   December 11, 2013, 14:58
Default
  #29
New Member
 
Bryan Schmidt
Join Date: Sep 2013
Posts: 18
Rep Power: 12
Bryan S is on a distinguished road
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.
Bryan S is offline   Reply With Quote

Old   December 11, 2013, 17:10
Default
  #30
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
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
dkxls is offline   Reply With Quote

Old   December 11, 2013, 17:44
Default
  #31
New Member
 
Bryan Schmidt
Join Date: Sep 2013
Posts: 18
Rep Power: 12
Bryan S is on a distinguished road
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!
Bryan S is offline   Reply With Quote

Old   July 25, 2017, 03:29
Default
  #32
New Member
 
Join Date: Jan 2016
Posts: 15
Rep Power: 10
SH_Zhong is on a distinguished road
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
SH_Zhong is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] Multi species mass transport library [update] novyno OpenFOAM Community Contributions 111 November 10, 2021 00:37
flow solver won't recognize custom library hakonbar OpenFOAM Programming & Development 2 April 7, 2014 09:09
Compiled library vs. inInclude Files, DSMC solver crashes after run GPesch OpenFOAM Programming & Development 8 April 18, 2013 08:17
defining custom convetive terms CFD user CFX 1 February 22, 2009 23:40
OpenFOAM141dev linking error on IBM AIX 52 matthias OpenFOAM Installation 24 April 28, 2008 16:49


All times are GMT -4. The time now is 03:19.