CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] groovyBC and funkySetFields married and got a kid named swak4Foam (https://www.cfd-online.com/Forums/openfoam-community-contributions/80048-groovybc-funkysetfields-married-got-kid-named-swak4foam.html)

alfa_8C November 29, 2010 09:20

Hello Eelco,

I followed your thread above but as I am not a C++ programmer I have some problems to understand what you actually did.
I need to set a time dependent BC for heatflux. What I did so far is to create a ramp over time. But if I want the ramp to become a constant value at a certain point in time I don't know how realize it. My idea was to define two expressions, from which one is true for the first part of the calculation, and the other one for the second part, controlling it with an if then else condition like: if time()<=t1 the use expression one, else use expression two.
Is this somehow realizable? If so, how is the syntax?

Thank you in advance
Best, Tony

gschaider November 29, 2010 10:36

Quote:

Originally Posted by alfa_8C (Post 285207)
Hello Bernhard,

I am currently trying to setup a case using groovyBC for a heatflux BC. The heatflux is adressed to a surface. The area of the surface is fixed but apperently far too small for the given heat release rate - the temperatures close to the surface are exorbitant high. In CFX I would define a subdomain with a volume source term. Is this with your new tool possible?

Best, Tony

The problem is that probably the solver doesn't know about source terms for the energy equations so you'll have to do a little bit of C++-programming.
There is an example solver for swak-source-terms in the examples (basically you'll have to add the source-term to the equation and the source term has to be read)
How you specify the zone is up to you: either by an expression or using a cellSet. cellSets can be created with the cellSet-utility. Either use one of the standard cellSet-methods or the one supplied by swak for that. There is a (simple) example for that too

Canesin December 1, 2010 17:28

Failing to compile interfoamwithsources
 
Hi Bernhard,

I'm getting error compiling InterFoamWithSources:
Code:

M/OpenFOAM-1.7.x/src/OpenFOAM/lnInclude -I/home/fabioc/OpenFOAM/OpenFOAM-1.7.x/src/OSspecific/POSIX/lnInclude  -fPIC -Xlinker --add-needed Make/linux64GccDPOpt/interFoamWithSources.o -L/home/fabioc/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt \
            -linterfaceProperties    -lincompressibleTransportModels    -lincompressibleTurbulenceModel    -lincompressibleRASModels    -lincompressibleLESModels    -lfiniteVolume    -L/home/fabioc/OpenFOAM/fabioc-1.7.x/lib/linux64GccDPOpt    -lswak4FoamParsers    -lswakSourceFields -lOpenFOAM -liberty -ldl  -lm -o /home/fabioc/OpenFOAM/fabioc-1.7.x/applications/bin/linux64GccDPOpt/interFoamWithSources
/home/fabioc/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt/libinterfaceProperties.so: undefined reference to `typeinfo for Foam::alphaContactAngleFvPatchScalarField'
collect2: ld returned 1 exit status
make: *** [/home/fabioc/OpenFOAM/fabioc-1.7.x/applications/bin/linux64GccDPOpt/interFoamWithSources] Error 1

Also the nem versions of chtMultiRegionFoam use hrhoThermo.. and the example for groovyBC still uses hPsiThermo, have no sure ideia what you should do....

Using OF-1.7.x... will try latter with OF-1.6-ext ..

harshad December 3, 2010 04:31

Not able to compile swak4foam
 
Hi,

When I try to do wmake in swak4FoamParsers I get following error

SOURCE=FieldValueExpressionParser.yy ; rm -f Make/linux64GccDPOpt/FieldValueExpressionParser.C Make/linux64GccDPOpt/FieldValueExpressionParser.tab.hh; bison -ra -v -d $SOURCE ; mv *.tab.cc Make/linux64GccDPOpt/FieldValueExpressionParser.C ; sed -i.bak "s/position.hh/FieldValueExpressionParser_position.hh/" location.hh ; mv location.hh lnInclude/FieldValueExpressionParser_location.hh ; mv stack.hh lnInclude/FieldValueExpressionParser_stack.hh ; mv position.hh lnInclude/FieldValueExpressionParser_position.hh ; sed -i.bak "s/stack.hh/FieldValueExpressionParser_stack.hh/;s/location.hh/FieldValueExpressionParser_location.hh/" FieldValu[harshad@headhpccluster swak4FoamParsers]$ wmake
SOURCE=FieldValueExpressionParser.yy ; rm -f Make/linux64GccDPOpt/FieldValueExpressionParser.C Make/linux64GccDPOpt/FieldValueExpressionParser.tab.hh; bison -ra -v -d $SOURCE ; mv *.tab.cc Make/linux64GccDPOpt/FieldValueExpressionParser.C ; sed -i.bak "s/position.hh/FieldValueExpressionParser_position.hh/" location.hh ; mv location.hh lnInclude/FieldValueExpressionParser_location.hh ; mv stack.hh lnInclude/FieldValueExpressionParser_stack.hh ; mv position.hh lnInclude/FieldValueExpressionParser_position.hh ; sed -i.bak "s/stack.hh/FieldValueExpressionParser_stack.hh/;s/location.hh/FieldValueExpressionParser_location.hh/" FieldValueExpressionParser.tab.hh ;mv *.hh lnInclude ; touch -r $SOURCE lnInclude/FieldValueExpressionParser*.hh ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -IMake/linux64GccDPOpt -I/home/harshad/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude -I/home/harshad/OpenFOAM/OpenFOAM-1.6/src/meshTools/lnInclude -IlnInclude -I. -I/home/harshad/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/home/harshad/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude -fPIC -c Make/linux64GccDPOpt/FieldValueExpressionParser.C -o Make/linux64GccDPOpt/FieldValueExpressionParser.o
FieldValueExpressionParser.yy:40.1-15: invalid directive: `%initial-action'
FieldValueExpressionParser.yy:41.1-44.1: syntax error, unexpected "{...}"
mv: cannot stat `*.tab.cc': No such file or directory
sed: can't read location.hh: No such file or directory
mv: cannot stat `location.hh': No such file or directory
mv: cannot stat `stack.hh': No such file or directory
mv: cannot stat `position.hh': No such file or directory
sed: can't read FieldValueExpressionParser.tab.hh: No such file or directory
mv: cannot stat `*.hh': No such file or directory
g++: Make/linux64GccDPOpt/FieldValueExpressionParser.C: No such file or directory
g++: no input files
make: *** [Make/linux64GccDPOpt/FieldValueExpressionParser.o] Error 1


Can anybody help me?

gschaider December 3, 2010 08:11

Quote:

Originally Posted by Canesin (Post 285659)
Hi Bernhard,

I'm getting error compiling InterFoamWithSources:
Code:

M/OpenFOAM-1.7.x/src/OpenFOAM/lnInclude -I/home/fabioc/OpenFOAM/OpenFOAM-1.7.x/src/OSspecific/POSIX/lnInclude  -fPIC -Xlinker --add-needed Make/linux64GccDPOpt/interFoamWithSources.o -L/home/fabioc/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt \
        -linterfaceProperties    -lincompressibleTransportModels    -lincompressibleTurbulenceModel    -lincompressibleRASModels    -lincompressibleLESModels    -lfiniteVolume    -L/home/fabioc/OpenFOAM/fabioc-1.7.x/lib/linux64GccDPOpt    -lswak4FoamParsers    -lswakSourceFields -lOpenFOAM -liberty -ldl  -lm -o /home/fabioc/OpenFOAM/fabioc-1.7.x/applications/bin/linux64GccDPOpt/interFoamWithSources
/home/fabioc/OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt/libinterfaceProperties.so: undefined reference to `typeinfo for Foam::alphaContactAngleFvPatchScalarField'
collect2: ld returned 1 exit status
make: *** [/home/fabioc/OpenFOAM/fabioc-1.7.x/applications/bin/linux64GccDPOpt/interFoamWithSources] Error 1

Also the nem versions of chtMultiRegionFoam use hrhoThermo.. and the example for groovyBC still uses hPsiThermo, have no sure ideia what you should do....

Using OF-1.7.x... will try latter with OF-1.6-ext ..

Sorry. Can't reproduce this with 1.7.x
Try wclean. Have a look whether the regular interFoam compiles for you

gschaider December 3, 2010 08:14

Quote:

Originally Posted by harshad (Post 285834)
Hi,

Make/linux64GccDPOpt/FieldValueExpressionParser.C -o Make/linux64GccDPOpt/FieldValueExpressionParser.o
FieldValueExpressionParser.yy:40.1-15: invalid directive: `%initial-action'
FieldValueExpressionParser.yy:41.1-44.1: syntax error, unexpected "{...}"
mv: cannot stat `*.tab.cc': No such file or directory
sed: can't read location.hh: No such file or directory
mv: cannot stat `location.hh': No such file or directory
mv: cannot stat `stack.hh': No such file or directory
mv: cannot stat `position.hh': No such file or directory
sed: can't read FieldValueExpressionParser.tab.hh: No such file or directory
mv: cannot stat `*.hh': No such file or directory
g++: Make/linux64GccDPOpt/FieldValueExpressionParser.C: No such file or directory
g++: no input files
make: *** [Make/linux64GccDPOpt/FieldValueExpressionParser.o] Error 1


Can anybody help me?

Which version of bison do you have (check with "bison -V")?

harshad December 5, 2010 23:38

bison version: 1.875c

Thanks

harshad December 5, 2010 23:40

Thanks for reply
I am using bison 1.875c

Could not 'make' latest version so tried using existing version.

gschaider December 6, 2010 05:13

Quote:

Originally Posted by harshad (Post 286131)
bison version: 1.875c

Thanks

If I googled this correctly this version is from 2003. I don't think that any bison versions with a 1 before the comma knows how to play along with C++. So this version won't work.

Bernhard

harshad December 6, 2010 05:52

Ok
I will try installing latest bison again
Thanks for clarifications

alfa_8C December 6, 2010 09:17

Hy Bernhard,

I've implemented now volume sources for momentum,mass and energy in reactingFoam and now I need to control the sources by an expression, which describes the source behavior over time. But as you can see below, in my source properties I can only specify a constant value instead of an expression.

FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object massSourcesProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

(
source1
{
active true;
timeStart 0.001;
duration 0.05;
selectionMode cellSet;
volumeMode absolute;
fieldData
(
(H2O 1e-1) // kg/s
(CO2 1e-1)
(N2 1e-1)
(O2 1e-1)

);

cellSet heatSource;
}
);

Is this now a case that can be solved with swak4Foam? If so, could you point me to the right example or post where to add the expression and synthax of it. The source zone in the mesh is defined with cellSets.

Thank you in advance
Tony

gschaider December 6, 2010 16:50

Quote:

Originally Posted by alfa_8C (Post 286208)
Hy Bernhard,

I've implemented now volume sources for momentum,mass and energy in reactingFoam and now I need to control the sources by an expression, which describes the source behavior over time. But as you can see below, in my source properties I can only specify a constant value instead of an expression.

FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object massSourcesProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

(
source1
{
active true;
timeStart 0.001;
duration 0.05;
selectionMode cellSet;
volumeMode absolute;
fieldData
(
(H2O 1e-1) // kg/s
(CO2 1e-1)
(N2 1e-1)
(O2 1e-1)

);

cellSet heatSource;
}
);

Is this now a case that can be solved with swak4Foam? If so, could you point me to the right example or post where to add the expression and synthax of it. The source zone in the mesh is defined with cellSets.

Thank you in advance
Tony

Yep. In principle it can be done. The only thing is that the solver has to be slightly modified (and of course the case-files). Have a look at the example interFoamWithSources (that comes with the distro) and how it differs from regular interFoam (then modify your solver accordingly). There is also a small example case.

To specify the source just in a cell set foo use this expression "set(foo) ? 1 : 0" instead of 1 use the expression you want to use

Bernhard

alfa_8C December 7, 2010 05:35

Hello Bernhard,

thanx for your quick reply.

One difference is in the createFields.H file:

expressionSource<vector> momentumSource
(
IOdictionary
(
IOobject
(
"momentumSourceDict",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
mesh
);

In my case I need to add additionally energySources and massSources. EnergySources shouldn't be a problem, as the only changes to make are to set <vector> to <scalar> and to change momentumSource to energySource and so on. But what about massSources. I mean is it possible to control different species over a single massSourceDict? Or do I have to specify for each specie an own dict?

One last question. Is this synthax right in the .C File? I just took the momentumSource synthax from interFoamWithSourcesFoam and adapted it to mass and energy...

if (runTime.write())
{
chemistry.dQ()().write();

volVectorField momSrc=momentumSource();
momSrc.rename("momSrc");
momSrc.write();

volVectorField enegSrc=energySource();
momSrc.rename("enegSrc");
momSrc.write();

volVectorField masSrc=massSource();
momSrc.rename("masSrc");
momSrc.write();
}

Thank you very much,
Tony

alfa_8C December 7, 2010 05:41

oh I'm sorry... like this of course!!!!

if (runTime.write())
{
chemistry.dQ()().write();

volVectorField momSrc=momentumSource();
momSrc.rename("momSrc");
momSrc.write();

volScalarField enegSrc=energySource();
enegSrc.rename("enegSrc");
enegSrc.write();

volScalarField masSrc=massSource();
masSrc.rename("masSrc");
masSrc.write();
}

gschaider December 7, 2010 14:42

Quote:

Originally Posted by alfa_8C (Post 286341)
Hello Bernhard,

thanx for your quick reply.

One difference is in the createFields.H file:

expressionSource<vector> momentumSource
(
IOdictionary
(
IOobject
(
"momentumSourceDict",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
mesh
);

In my case I need to add additionally energySources and massSources. EnergySources shouldn't be a problem, as the only changes to make are to set <vector> to <scalar> and to change momentumSource to energySource and so on. But what about massSources. I mean is it possible to control different species over a single massSourceDict? Or do I have to specify for each specie an own dict?

You're right. That is not as simple as the other sources. But feasible. Basically the way to go would be to create a PtrList of expressionSource<scalar> that is as big as the composition Y. Those sources would have to be initialized in a loop and the appropriate source would have to be used for each species. For getting the specification you either use a separate file for each species (something like 'Y[i].name()+"SourceDict"') or you have one file for all mass sources and get the appropriate dictionary by using 'sourcesDict.subDict(Y[i].name())'. (Both examples are from memory, I'm sure you can work out the details)

BTW: I'm sure you've included the overall mass-source into the continuity equation

Quote:

Originally Posted by alfa_8C (Post 286341)
One last question. Is this synthax right in the .C File? I just took the momentumSource synthax from interFoamWithSourcesFoam and adapted it to mass and energy...

if (runTime.write())
{
chemistry.dQ()().write();

volVectorField momSrc=momentumSource();
momSrc.rename("momSrc");
momSrc.write();

volVectorField enegSrc=energySource();
momSrc.rename("enegSrc");
momSrc.write();

volVectorField masSrc=massSource();
momSrc.rename("masSrc");
momSrc.write();
}

Thank you very much,
Tony

That should work. Of course because this happens after the calculation it is possible that the values that are written to disk are slightly different from those used in the equations.

Bernhard

mvoss December 10, 2010 07:01

Quote:

Originally Posted by gschaider (Post 285871)
Sorry. Can't reproduce this with 1.7.x
Try wclean. Have a look whether the regular interFoam compiles for you

hi,

i am facing the same problem (ld returned 1 exit status). Is it possible that this is somehow related to where the *.o file is written... because i had to manually change the Make/files when compiling swak4Foam. I changed from ../Libraries/... to ../lib/.. and this fixed the "earlier" problem..

neewbie

ziad December 12, 2010 12:04

Hi Bernhard,

I've compiled swak4Foam for both 1.6-ext and 1.7.0. Everything seems okay except for the simpleSwakFunctionObjects library. It is mentioned on the wiki page but does not appear with the other libraries. Looking in the make log file the only reference to simpleFunctionObjects appears in this segment below:

Code:

wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file general/swakExpressionFunctionObject.C
could not open file timelineFunctionObject.H for source file general/swakExpressionFunctionObject.C
Making dependency list for source file patch/patchExpressionFunctionObject.C
could not open file patchFunctionObject.H for source file patch/patchExpressionFunctionObject.C
SOURCE=general/swakExpressionFunctionObject.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-40 -I/home/binkz/OpenFOAM/binkz-1.7.0/Libraries/simpleFunctionObjects/lnInclude    -I../swak4FoamParsers/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/meshTools/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/sampling/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/triSurface/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/lagrangian/basic/lnInclude  -IlnInclude -I. -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/swakExpressionFunctionObject.o
In file included from general/swakExpressionFunctionObject.C:28:0:
general/swakExpressionFunctionObject.H:40:36: fatal error: timelineFunctionObject.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/swakExpressionFunctionObject.o] Error 1

where files timelineFunctionObject.H and patchFunctionObject.H are also missing. Any ides where to get those header files?

Thanks,
Ziad

gschaider December 12, 2010 16:18

Quote:

Originally Posted by ziad (Post 287105)
Hi Bernhard,

I've compiled swak4Foam for both 1.6-ext and 1.7.0. Everything seems okay except for the simpleSwakFunctionObjects library. It is mentioned on the wiki page but does not appear with the other libraries. Looking in the make log file the only reference to simpleFunctionObjects appears in this segment below:

Code:

wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file general/swakExpressionFunctionObject.C
could not open file timelineFunctionObject.H for source file general/swakExpressionFunctionObject.C
Making dependency list for source file patch/patchExpressionFunctionObject.C
could not open file patchFunctionObject.H for source file patch/patchExpressionFunctionObject.C
SOURCE=general/swakExpressionFunctionObject.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-40 -I/home/binkz/OpenFOAM/binkz-1.7.0/Libraries/simpleFunctionObjects/lnInclude    -I../swak4FoamParsers/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/meshTools/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/sampling/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/triSurface/lnInclude    -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/lagrangian/basic/lnInclude  -IlnInclude -I. -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude -I/home/binkz/OpenFOAM/OpenFOAM-1.7.0/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/swakExpressionFunctionObject.o
In file included from general/swakExpressionFunctionObject.C:28:0:
general/swakExpressionFunctionObject.H:40:36: fatal error: timelineFunctionObject.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/swakExpressionFunctionObject.o] Error 1

where files timelineFunctionObject.H and patchFunctionObject.H are also missing. Any ides where to get those header files?

Yes I have an idea. That information was "hidden in plain sight":
Let me quote from the README-file (sometimes I wonder why I write that stuff):

Code:

** Requirements
  - Version 1.7 of OpenFOAM (1.6 should work, too)
  - the compiler generators =bison= and =flex=
  - =simpleSwakFunctionObjects= needs the =simpleFunctionObjects=
    (see
    http://openfoamwiki.net/index.php/Contrib_simpleFunctionObjects)
    all other functionality has no additional requirements
    (=simpleSwakFunctionObjects= is only required by some examples)
    It is assumed that the sources are installed at
    =$WM_PROJECT_USER_DIR/Libraries/simpleFunctionObjects=


ziad December 12, 2010 16:54

Right! I had simpleFunctionObjects, just not in $WM_PROJECT_USER_DIR/Libraries

Thanks for the "tip".

alfa_8C December 13, 2010 03:14

Hello Bernhard,

two short questions:

1. what exactly do you mean with your comment:

BTW: I'm sure you've included the overall mass-source into the continuity equation

My Eqns look like this:

UEqn:

fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
+ turbulence->divDevRhoReff(U)
==
//rho*g
rho.dimensionedInternalField()*g
+ momentumSource.Su()
);

UEqn.relax();

if (momentumPredictor)
{
solve(UEqn == -fvc::grad(p));
}


...and

YEqn:

for (label i=0; i<Y.size(); i++)
{
if (Y[i].name() != inertSpecie)
{
volScalarField& Yi = Y[i];

solve
(
fvm::ddt(rho, Yi)
+ mvConvection->fvmDiv(phi, Yi)
- fvm::laplacian(turbulence->muEff(), Yi)
==
//kappa*chemistry.RR(i),
kappa*chemistry.RR(i)().dimensionedInternalField()
+ massSource.Su(i),
mesh.solver("Yi")
);

Yi.max(0.0);
Yt += Yi;

Is there something wrong regarding the specie fractions or what else do you mean?

2. Do you know where to get the properties set for CO in the same "form" like other species used for reactingFoam? OpenFOAM support doesn't help unfortunately...

Many thanx in advance,
Tony


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