|
[Sponsors] |
time dependent gravity based on codeStream OF v18 |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 26, 2019, 09:24 |
time dependent gravity based on codeStream OF v18
|
#1 |
Member
Join Date: Jun 2015
Posts: 30
Rep Power: 11 |
Hi all,
I'm trying to use the codeStream to have a time dependent gravity. But can't make it work. I get the following compilation error: (I'm using openfoam v18) Code:
Reading g Using #codeStream at line 19 in file "/home/mme/OpenFOAM/mme-v1812/run/tutorial/gravityTime/constant/g" Using #codeStream with "/home/mme/OpenFOAM/mme-v1812/run/tutorial/gravityTime/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_daf99d91d91255ca8bb76a32c6753335187daeae.so" Creating new library in "dynamicCode/_daf99d91d91255ca8bb76a32c6753335187daeae/platforms/linux64GccDPInt32Opt/lib/libcodeStream_daf99d91d91255ca8bb76a32c6753335187daeae.so" Invoking wmake libso /home/mme/OpenFOAM/mme-v1812/run/tutorial/gravityTime/dynamicCode/_daf99d91d91255ca8bb76a32c6753335187daeae wmake libso /home/mme/OpenFOAM/mme-v1812/run/tutorial/gravityTime/dynamicCode/_daf99d91d91255ca8bb76a32c6753335187daeae ln: ./lnInclude dep: codeStreamTemplate.C Ctoo: codeStreamTemplate.C /home/mme/OpenFOAM/mme-v1812/run/tutorial/gravityTime/constant/g.#codeStream:0:10: fatal error: fvCFD.H: No such file or directory compilation terminated. /home/mme/OpenFOAM/OpenFOAM-v1812/wmake/rules/General/transform:34: recipe for target 'Make/linux64GccDPInt32Opt/codeStreamTemplate.o' failed make: *** [Make/linux64GccDPInt32Opt/codeStreamTemplate.o] Error 1 --> FOAM FATAL IO ERROR: Failed wmake "dynamicCode/_daf99d91d91255ca8bb76a32c6753335187daeae/platforms/linux64GccDPInt32Opt/lib/libcodeStream_daf99d91d91255ca8bb76a32c6753335187daeae.so" file: /home/mme/OpenFOAM/mme-v1812/run/tutorial/gravityTime/constant/g From function static void (* Foam::functionEntries::codeStream::getFunction(const Foam::dictionary&, const Foam::dictionary&))(Foam::Ostream&, const Foam::dictionary&) in file db/dictionary/functionEntries/codeStream/codeStream.C at line 215. FOAM exiting Here is the file for gravity "g" that I'm trying to modify at run-time. For now I just have a constant value just to make sure things are already working ... Code:
FoamFile { version 2.0; format ascii; class uniformDimensionedVectorField; location "constant"; object g; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -2 0 0 0 0]; value #codeStream { codeInclude #{ #include "fvCFD.H" #include <cmath> #include <iostream> #}; code #{ const scalar gravity=9.81; scalar t = this->db().time().value(); vector gravityVector = vector (0,0, gravity); gravity.writeEntry("", os); #}; }; Best Ali |
|
April 26, 2019, 10:54 |
|
#2 |
Senior Member
|
Hi,
To compile your fragment, you can add codeOptions section as shown in the example here: https://cpp.openfoam.org/v6/classFoa...odeStream.html. But I would suggest to use coded fvOption (based on buoyancyForce fvOption) instead. uniformDimensionedVectorField is not supposed to be time dependent. |
|
May 6, 2019, 09:30 |
time dependent gravity based on codeStream OF v18
|
#3 |
Member
Join Date: Jun 2015
Posts: 30
Rep Power: 11 |
Thanks Alexey for the reply.
Here is the updated code: Code:
dimensions [0 1 -2 0 0 0 0]; value #codeStream { codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/meshTools/lnInclude #}; codeInclude #{ #include "fvCFD.H" // #include <cmath> // #include <iostream> #}; code #{ const scalar gravity=9.81; scalar t = d.db().time().value(); vector gravityVector = vector (0,0, gravity); gravity.writeEntry("", os); #}; }; Code:
Using #codeStream at line 19 in file "/home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/constant/g" Using #codeStream with "/home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_2f2c559a762c6d5171aca347a50dcdcf31a28a70.so" Creating new library in "dynamicCode/_2f2c559a762c6d5171aca347a50dcdcf31a28a70/platforms/linux64GccDPInt32Opt/lib/libcodeStream_2f2c559a762c6d5171aca347a50dcdcf31a28a70.so" Invoking wmake libso /home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/dynamicCode/_2f2c559a762c6d5171aca347a50dcdcf31a28a70 wmake libso /home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/dynamicCode/_2f2c559a762c6d5171aca347a50dcdcf31a28a70 Make/linux64GccDPInt32Opt/options:61: *** missing separator. Stop. Make/linux64GccDPInt32Opt/options:61: *** missing separator. Stop. wmake error: file 'Make/linux64GccDPInt32Opt/sourceFiles' could not be created in /home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/dynamicCode/_2f2c559a762c6d5171aca347a50dcdcf31a28a70 --> FOAM FATAL IO ERROR: Failed wmake "dynamicCode/_2f2c559a762c6d5171aca347a50dcdcf31a28a70/platforms/linux64GccDPInt32Opt/lib/libcodeStream_2f2c559a762c6d5171aca347a50dcdcf31a28a70.so" file: /home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/constant/g From function static void (* Foam::functionEntries::codeStream::getFunction(const Foam::dictionary&, const Foam::dictionary&))(Foam::Ostream&, const Foam::dictionary&) in file db/dictionary/functionEntries/codeStream/codeStream.C at line 215. FOAM exiting I looked at the floating object tutorial ( multiphase/interFoam/RAS/floatingObject/constant/dynamicMeshDict.sixDoF) in which only the diagTensor library is included. So if I simplify the problem by just calling vector.H, it works. Code:
dimensions [0 1 -2 0 0 0 0]; value #codeStream { codeInclude #{ #include "vector.H" #}; code #{ const scalar gravity=9.81; vector gravityVector = vector (0,0, gravity); os << gravityVector; #}; }; Also thanks for your suggestion regarding the buoyancyForce fvOption, but I was wondering whether there is a restriction regarding time dependence on the uniformDimensionedVectorField. I found a similar example here: https://www.youtube.com/watch?v=Zgnk6jSK_YM In the description they mention the following : " a time varying gravity vector was implemented using codeStream." . So I'm assuming this should be possible? Thanks Ali |
|
May 6, 2019, 12:09 |
|
#4 |
Senior Member
|
Hi,
Since codeOptions part goes to Makefile, you should join multiple files with continuation symbol: Code:
codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; Code:
codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/meshTools/lnInclude #}; |
|
May 7, 2019, 08:48 |
time dependent gravity based on codeStream OF v18
|
#5 |
Member
Join Date: Jun 2015
Posts: 30
Rep Power: 11 |
Hi,
Thanks for the reply and your time. I made the correction you mentioned and it works. However if I make the gravity time dependent: Code:
dimensions [0 1 -2 0 0 0 0]; value #codeStream { codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; //libs needed to visualize BC in paraview codeLibs #{ -lmeshTools \ -lfiniteVolume #}; codeInclude #{ // #include "fvCFD.H" #include "fvCFD.H" #include <cmath> #include <iostream> #}; code #{ const scalar gravity=9.81; const IOdictionary& d = static_cast<const IOdictionary&>(dict); scalar t = d.db().time().value(); vector gravityVector = vector ((t<1.5) ? gravity : 0 ,0,gravity) os << gravityVector; //gravityVector.writeEntry("", os); #}; }; Code:
Reading g Using #codeStream at line 19 in file "/home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/constant/g" Using #codeStream with "/home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_7b26292c40d786917a6d1a2dd698837bf4407965.so" Creating new library in "dynamicCode/_7b26292c40d786917a6d1a2dd698837bf4407965/platforms/linux64GccDPInt32Opt/lib/libcodeStream_7b26292c40d786917a6d1a2dd698837bf4407965.so" Invoking wmake libso /home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/dynamicCode/_7b26292c40d786917a6d1a2dd698837bf4407965 wmake libso /home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/dynamicCode/_7b26292c40d786917a6d1a2dd698837bf4407965 ln: ./lnInclude dep: codeStreamTemplate.C Ctoo: codeStreamTemplate.C ld: /home/mme/OpenFOAM/mme-v1812/run/sloshingTankProject/tutorials/sloshingBox_gravityTime/dynamicCode/_7b26292c40d786917a6d1a2dd698837bf4407965/../platforms/linux64GccDPInt32Opt/lib/libcodeStream_7b26292c40d786917a6d1a2dd698837bf4407965.so #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 ? in /lib/x86_64-linux-gnu/libc.so.6 #3 codeStream_7b26292c40d786917a6d1a2dd698837bf4407965 at constant/g.#codeStream:4 #4 Foam::functionEntries::codeStream::execute(Foam::dictionary const&, Foam::primitiveEntry&, Foam::Istream&) at ??:? #5 Foam::functionEntry::execute(Foam::word const&, Foam::dictionary const&, Foam::primitiveEntry&, Foam::Istream&) at ??:? #6 Foam::primitiveEntry::acceptToken(Foam::token const&, Foam::dictionary const&, Foam::Istream&) at ??:? #7 Foam::primitiveEntry::read(Foam::dictionary const&, Foam::Istream&) at ??:? #8 Foam::primitiveEntry::readEntry(Foam::dictionary const&, Foam::Istream&) at ??:? #9 Foam::primitiveEntry::primitiveEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:? #10 Foam::entry::New(Foam::dictionary&, Foam::Istream&, Foam::entry::inputMode, int) at ??:? #11 Foam::dictionary::read(Foam::Istream&, bool) at ??:? #12 Foam::dictionary::dictionary(Foam::Istream&, bool) at ??:? #13 Foam::UniformDimensionedField<Foam::Vector<double> >::readData(Foam::Istream&) in ~/OpenFOAM/OpenFOAM-v1812/platforms/linux64GccDPInt32Opt/bin/interFoam #14 Foam::fileOperations::uncollatedFileOperation::read(Foam::regIOobject&, bool, Foam::IOstreamOption::streamFormat, Foam::word const&) const at ??:? #15 Foam::regIOobject::readHeaderOk(Foam::IOstreamOption::streamFormat, Foam::word const&) at ??:? #16 Foam::meshObjects::gravity::New(Foam::Time const&) in ~/OpenFOAM/OpenFOAM-v1812/platforms/linux64GccDPInt32Opt/bin/interFoam #17 ? in ~/OpenFOAM/OpenFOAM-v1812/platforms/linux64GccDPInt32Opt/bin/interFoam #18 __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 #19 ? in ~/OpenFOAM/OpenFOAM-v1812/platforms/linux64GccDPInt32Opt/bin/interFoam Segmentation fault (core dumped) Regarding fvOption , so either I have to make a new fvOption which as you mentioned the bouyantForce is the closest, or a codedSource. I think the following seems to be a good start (scroll to comment #10) How to add a body force to a momentum equation One last thing which might be trivial, but I don't see how codeStream would come into play in all this as I don't see any existing fvOptions which within the respective dictionary I can use codeStream ... Best Ali |
|
May 9, 2019, 16:50 |
|
#6 |
Senior Member
|
Hi,
sigSegv in fact is caused by access to Time object. It seems static cast gives you rather strange IOdictionary. If you use in the codeStream, for example Code:
os << "(0 -9.81 0)"; You can start with the example provided in message 10. The easiest way to learn what Wolfdynamics meant by codeStream is to ask them directly, either through comment on Youtube, or through contact e-main on their web-site. One can call code inside codedFvOption configuration sections "codeStream". |
|
May 13, 2019, 18:06 |
|
#7 |
Member
Join Date: Oct 2016
Posts: 31
Rep Power: 10 |
Hello Ali Blues,
I am trying to implement same thing in of v1812. Have you solved the issue? If yes, I would appreciate you sharing solution. Best regards, Tonnykz |
|
Tags |
codestream, time dependent gravity |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
pressure in incompressible solvers e.g. simpleFoam | chrizzl | OpenFOAM Running, Solving & CFD | 13 | March 28, 2017 06:49 |
Extrusion with OpenFoam problem No. Iterations 0 | Lord Kelvin | OpenFOAM Running, Solving & CFD | 8 | March 28, 2016 12:08 |
Pressure inlet vs outlet position, transient, time dependent pressure and gravity | silent2608 | FLUENT | 0 | February 6, 2016 11:19 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
dynamic Mesh is faster than MRF???? | sharonyue | OpenFOAM Running, Solving & CFD | 14 | August 26, 2013 08:47 |