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 the dynamic cousin of funkySetFields that lives on the suburb of the mesh (https://www.cfd-online.com/Forums/openfoam-community-contributions/60685-groovybc-dynamic-cousin-funkysetfields-lives-suburb-mesh.html)

gschaider February 3, 2011 08:30

Quote:

Originally Posted by usergk (Post 293450)
Hi

Thanks for your reply.

Here is the 0/T file:

dimensions [ 0 0 0 1 0 0 0 ];

internalField uniform 293;

boundaryField
{
inlet
{
type fixedValue;
value uniform 293;
}
outlet
{
type inletOutlet;
inletValue uniform 293;
value uniform 293;
}
upperWall
{
type groovyBC;
variables "htot=100.0;Tinf=298.15;rho=2700.0;cp=900.0;k=DT*r ho*cp;";
valueExpression "Tinf";
fractionExpression "1.0/(1.0 + k/(mag(delta())*htot))";
}
lowerWall
{
type groovyBC;
variables "htot=100.0;Tinf=298.15;rho=2700.0;cp=900.0;k=DT*r ho*cp;";
valueExpression "Tinf";
fractionExpression "1.0/(1.0 + k/(mag(delta())*htot))";
}
frontAndBack
{
type groovyBC;
variables "htot=100.0;Tinf=298.15;rho=2700.0;cp=900.0;k=DT*r ho*cp;";
valueExpression "Tinf";
fractionExpression "1.0/(1.0 + k/(mag(delta())*htot))";
}
}

Please note that I have also changed frontAndBack boundary type from 'cyclic' to 'wall' so that I could give the groovyBC; the upperWall and lowerWall are also of boundary type 'wall'.

When I change the BC at the walls to fixedValue (isothermal BC) simulations seem to run fine.

Thanks,
gk

Does the problem occur immidiatly at the first step or are there any calculated before that? Are the cylics still cyclic in the boundary file? Try commenting out the fractionExpressions (because then the case should degenerate to your previous fixedValue-setup

Bernhard

usergk February 3, 2011 08:56

Hello

Thanks for replying.

The problem occurs immediately, and yes, I did change the type from cyclic to wall in the blockMeshDict and boundary files.

Also, when I comment out fractionExpression, while leaving the other lines the same (ie type groovyBC etc.), I still get the error.

Thanks,
gk

Error log:

Create time

Create mesh for time = 0

Reading combustion properties

Found ignition cells:
8(43926 40685 40686 40687 40866 43925 43927 44106)

Ignition on

Reading g
Reading thermophysical properties

Selecting thermodynamics package hhuMixtureThermo<homogeneousMixture<sutherlandTran sport<specieThermo<janafThermo<perfectGas>>>>>

--> FOAM FATAL ERROR:
attempt to use janafThermo<equationOfState> out of temperature range 200 -> 5000; T = 0

gschaider February 3, 2011 10:00

Quote:

Originally Posted by usergk (Post 293465)
Hello

Thanks for replying.

The problem occurs immediately, and yes, I did change the type from cyclic to wall in the blockMeshDict and boundary files.

Also, when I comment out fractionExpression, while leaving the other lines the same (ie type groovyBC etc.), I still get the error.

Thanks,
gk

Error log:

Create time

Create mesh for time = 0

Reading combustion properties

Found ignition cells:
8(43926 40685 40686 40687 40866 43925 43927 44106)

Ignition on

Reading g
Reading thermophysical properties

Selecting thermodynamics package hhuMixtureThermo<homogeneousMixture<sutherlandTran sport<specieThermo<janafThermo<perfectGas>>>>>

--> FOAM FATAL ERROR:
attempt to use janafThermo<equationOfState> out of temperature range 200 -> 5000; T = 0

Try adding an entry

value uniform 298.15;

to the boundaries. To make sure that the thermophysical model has SOME value as long as the boundaryCondition has not been updated.

If that does not work try replacing the value expressions "Tinf" with "298.15" (but that would be a very weird bug in groovyBC)

Bernhard

usergk February 3, 2011 10:43

Hi Bernhard,

Thanks for your reply.

Adding the value did seem to avoid the janafThermo error, but then I got the following:

Time = 1.19999e-07

diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG: Solving for Ux, Initial residual = 1, Final residual = 4.54047e-07, No Iterations 1
DILUPBiCG: Solving for Uy, Initial residual = 1, Final residual = 5.33651e-07, No Iterations 1
DILUPBiCG: Solving for Uz, Initial residual = 1, Final residual = 5.62639e-07, No Iterations 1
Max St-Courant Number = 7.86145e-06
Igniting cell 43926 state : 1 1 0.135 2.12673e-13
Igniting cell 40685 state : 1 1 0.135 1.47286e-13
Igniting cell 40686 state : 1 1 0.135 1.65015e-13
Igniting cell 40687 state : 1 1 0.135 2.17713e-13
Igniting cell 40866 state : 1 1 0.135 1.40006e-13
Igniting cell 43925 state : 1 1 0.135 4.56461e-13
Igniting cell 43927 state : 1 1 0.135 2.50109e-13
Igniting cell 44106 state : 1 1 0.135 1.30268e-13
DILUPBiCG: Solving for b, Initial residual = 1, Final residual = 4.10428e-08, No Iterations 1
min(b) = 0.99976
DILUPBiCG: Solving for Su, Initial residual = 0.999999, Final residual = 7.40651e-07, No Iterations 21
DILUPBiCG: Solving for Xi, Initial residual = 1, Final residual = 4.13749e-08, No Iterations 19
max(Xi) = 1
max(XiEq) = 1.00103
Combustion progress = 6.34009e-07%


--> FOAM FATAL ERROR:
Parser Error at "1.1-2" :"field DT not existing or of wrong type"
"DT*rho*cp"
" ^^ "

From function parsingValue
in file PatchValueExpressionDriver.C at line 192.

FOAM aborting (FOAM_ABORT set)

#0 Foam::error::printStack(Foam::Ostream&) in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::error::abort() in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libOpenFOAM.so"
#2 Foam::error::exit(int) in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libOpenFOAM.so"
#3 Foam::PatchValueExpressionDriver::error(pve::locat ion const&, std::string const&) in "/home/gk/OpenFOAM/gk-1.7.1/lib/linux64GccDPOpt/libgroovyBC.so"
#4 pvelex(pve::PatchValueExpressionParser::semantic_t ype*, pve::location*, Foam::PatchValueExpressionDriver&) in "/home/gk/OpenFOAM/gk-1.7.1/lib/linux64GccDPOpt/libgroovyBC.so"
#5 pve::PatchValueExpressionParser::parse() in "/home/gk/OpenFOAM/gk-1.7.1/lib/linux64GccDPOpt/libgroovyBC.so"
#6 Foam::PatchValueExpressionDriver::parse(std::strin g const&) in "/home/gk/OpenFOAM/gk-1.7.1/lib/linux64GccDPOpt/libgroovyBC.so"
#7 Foam::PatchValueExpressionDriver::evaluateVariable (Foam::word const&, Foam::string const&) in "/home/gk/OpenFOAM/gk-1.7.1/lib/linux64GccDPOpt/libgroovyBC.so"
#8 Foam::PatchValueExpressionDriver::addVariables(Foa m::string const&, bool) in "/home/gk/OpenFOAM/gk-1.7.1/lib/linux64GccDPOpt/libgroovyBC.so"
#9 Foam::groovyBCFvPatchField<double>::updateCoeffs() in "/home/gk/OpenFOAM/gk-1.7.1/lib/linux64GccDPOpt/libgroovyBC.so"
#10 Foam::mixedFvPatchField<double>::evaluate(Foam::Ps tream::commsTypes) in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libcompressibleRASModels.so"
#11 Foam::mixedUnburntEnthalpyFvPatchScalarField::upda teCoeffs() in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libreactionThermophysicalModels.so"
#12 Foam::fvMatrix<double>::fvMatrix(Foam::GeometricFi eld<double, Foam::fvPatchField, Foam::volMesh>&, Foam::dimensionSet const&) in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/applications/bin/linux64GccDPOpt/XiFoam"
#13 Foam::fv::gaussLaplacianScheme<double, double>::fvmLaplacianUncorrected(Foam::GeometricFi eld<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&) in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libfiniteVolume.so"
#14 Foam::fv::gaussLaplacianScheme<double, double>::fvmLaplacian(Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&) in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libfiniteVolume.so"
#15 Foam::fv::laplacianScheme<double, double>::fvmLaplacian(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&) in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libfiniteVolume.so"
#16 Foam::tmp<Foam::fvMatrix<double> > Foam::fvm::laplacian<double, double>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::word const&) in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/applications/bin/linux64GccDPOpt/XiFoam"
#17 Foam::tmp<Foam::fvMatrix<double> > Foam::fvm::laplacian<double, double>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&) in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/applications/bin/linux64GccDPOpt/XiFoam"
#18
in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/applications/bin/linux64GccDPOpt/XiFoam"
#19 __libc_start_main in "/lib/libc.so.6"
#20
in "/home/gk/OpenFOAM/OpenFOAM-1.7.1/applications/bin/linux64GccDPOpt/XiFoam"
Aborted


Any ideas?

Thanks,
gk

gschaider February 3, 2011 11:31

Quote:

Originally Posted by usergk (Post 293486)
Hi Bernhard,

Thanks for your reply.

Adding the value did seem to avoid the janafThermo error, but then I got the following:

Thats fine

Quote:

Originally Posted by usergk (Post 293486)
--> FOAM FATAL ERROR:
Parser Error at "1.1-2" :"field DT not existing or of wrong type"
"DT*rho*cp"
" ^^ "

From function parsingValue
in file PatchValueExpressionDriver.C at line 192.

FOAM aborting (FOAM_ABORT set)

Well. It is perfectly OK for groovyBC to complain: DT is not one of your variables. If there is no volScalarField with that name in memory, what shall it do? Guess?

usergk February 3, 2011 12:39

Hi

Thanks Bernhard . I had actually referred to this post:

http://www.cfd-online.com/Forums/ope...acianfoam.html

gk

gschaider February 3, 2011 16:54

Quote:

Originally Posted by usergk (Post 293504)
Hi

Thanks Bernhard . I had actually referred to this post:

http://www.cfd-online.com/Forums/ope...acianfoam.html

gk

That is a different solver. DT is the diffusion (heat conduction) coefficient there if I remember correctly. And it doesn't have a rho and cp (which your solver has so you don't have to define them as variables).

So you'll have to rework your expression

Bernhard

usergk February 3, 2011 18:04

Thanks a lot for your reply, Bernhard. I really appreciate it.


I tried to change the expression as:

upperWall
{
type groovyBC;
value uniform 293;
gradientExpression "gradT";
fractionExpression "0";
variables "htot=100.0;Tinf=298.15;Cp=1000;k=alphaEff*rho*Cp; gradT=htot*(Tinf-T)/k;";
}

I wasn't sure how to call Cp() inside the 0/T file, so defined a value for it, just to see if it works.

However, I got the janafThermo error again:

--> FOAM FATAL ERROR:
attempt to use janafThermo<equationOfState> out of temperature range 100 -> 5000; T = 0

From function janafThermo<equationOfState>::checkT(const scalar T) const
in file /home/gk/OpenFOAM/OpenFOAM-1.7.1/src/thermophysicalModels/specie/lnInclude/janafThermoI.H at line 63.


The code is based on a related post:
http://www.cfd-online.com/Forums/ope...tml#post293538

Thanks,
gk

usergk February 4, 2011 14:51

Hello,

I implemented the groovyBC in the XiFoam solver, and it appears to run fine; however, when I include radiation in the solver, and implement the BC, I get the following error:

"field alphaEff not existing or of wrong type"

which is weird, since all that I did was to include radiation, and because alphaEff is defined in turbulenceModel.H; but still the error seems to come up.

Looking at a previous post, I replaced alphaEff with (alphat + alpha), then I get the error:
Parser Error at "1.2-7" :"field alphat not existing or of wrong type"
"(alphat + alpha)* rho* cp"
" ^^^^^^ "

which is possibly because alphat is not defined in turbulenceModel.H


Has anyone faced a similar problem, and knows how to get rid of it?

Thanks
gk

gschaider February 4, 2011 17:49

Quote:

Originally Posted by usergk (Post 293726)
I implemented the groovyBC in the XiFoam solver, and it appears to run fine; however, when I include radiation in the solver, and implement the BC, I get the following error:

"field alphaEff not existing or of wrong type"

which is weird, since all that I did was to include radiation, and because alphaEff is defined in turbulenceModel.H; but still the error seems to come up.

Looking at a previous post, I replaced alphaEff with (alphat + alpha), then I get the error:
Parser Error at "1.2-7" :"field alphat not existing or of wrong type"
"(alphat + alpha)* rho* cp"
" ^^^^^^ "

which is possibly because alphat is not defined in turbulenceModel.H


Has anyone faced a similar problem, and knows how to get rid of it?

That problem is that groovyBC can only work with the fields that are currently in memory. alphaEff is a temporary that is not in memory. alphat should be there IF the turbulence model defines it (not every one does)

usergk February 4, 2011 18:07

Hi Bernhard

Thanks for replying.

Actually, the BC does work (while using alphaEff in the BC definition) when I use the XiFoam solver that is provided with OpenFoam.
Surprisingly, however, once I include radiation effects, it does not.

Anyway, I'll try to see if alphat can be defined in the turbulence model.

Thank you,
gk

about February 7, 2011 02:37

frequency of sine-wave
 
Hi all, in pulsed pitzdaily the sine-wave has the expression:
"1*(1+0.5*sin(500*time()))*para";

What frequency does this represent, i.e. How long is one period over time.
I would like to have one period to be 4/3 s but cant figure it out.
Sorry to bother you with quite a rudimentary mathematical problem like this.

gschaider February 7, 2011 10:38

Quote:

Originally Posted by about (Post 293907)
Hi all, in pulsed pitzdaily the sine-wave has the expression:
"1*(1+0.5*sin(500*time()))*para";

What frequency does this represent, i.e. How long is one period over time.
I would like to have one period to be 4/3 s but cant figure it out.
Sorry to bother you with quite a rudimentary mathematical problem like this.

I think the piece of information you were missing is that sin wants radians as the unit for his input (not degrees). So replace 500 with your period (4/3) and 2*pi. One of these has to be multiplied the other divided (which one has to be divided with is left to you as an exercise)

yapalparvi February 16, 2011 11:44

Groovy BC +Wavetank
 
Hi all,

I am trying to run this demo groovywave tank and I seem to be getting the following error



Selecting incompressible transport model Newtonian
Selecting incompressible transport model Newtonian
Calculating field g.h

time step continuity errors : sum local = 0, global = 0, cumulative = 0


Attempt to return dictionary entry as a primitive

file: /home/ramesh/OpenFOAM/ramesh-1.5/run/tutorials/interFoam/groovyWaveTank/system/fvSolution::pcorr::preconditioner from line 23 to line 35.

From function ITstream& primitiveEntry::stream() const
in file db/dictionary/dictionaryEntry/dictionaryEntry.C at line 83.

FOAM aborting

#0 Foam::error::printStack(Foam::Ostream&) in "/home/ramesh/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::IOerror::abort() in "/home/ramesh/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#2 Foam::dictionaryEntry::stream() const in "/home/ramesh/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#3 Foam::dictionary::lookup(Foam::word const&, bool) const in "/home/ramesh/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#4 Foam::PCG::solve(Foam::Field<double>&, Foam::Field<double> const&, unsigned char) const in "/home/ramesh/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#5 Foam::fvMatrix<double>::solve(Foam::Istream&) in "/home/ramesh/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libfiniteVolume.so"
#6 main in "/home/ramesh/OpenFOAM/OpenFOAM-1.5/applications/bin/linuxGccDPOpt/interFoam"
#7 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#8 _start at /build/buildd/glibc-2.9/csu/../sysdeps/i386/elf/start.S:122
Aborted

gschaider February 16, 2011 17:59

Quote:

Originally Posted by yapalparvi (Post 295560)
Hi all,

I am trying to run this demo groovywave tank and I seem to be getting the following error



Selecting incompressible transport model Newtonian
Selecting incompressible transport model Newtonian
Calculating field g.h

time step continuity errors : sum local = 0, global = 0, cumulative = 0


Attempt to return dictionary entry as a primitive

file: /home/ramesh/OpenFOAM/ramesh-1.5/run/tutorials/interFoam/groovyWaveTank/system/fvSolution::pcorr::preconditioner from line 23 to line 35.

From function ITstream& primitiveEntry::stream() const
in file db/dictionary/dictionaryEntry/dictionaryEntry.C at line 83.

FOAM aborting

The problem is not with groovyBC, but that the definition of one of the linear solvers is not compatible with the version of OF you're using. I'm not sure for which version of OF groovyTankBC was made and of course I don't know which version you're using. But one tip would be to look at fvSolution in the interFoam-tutorials of your OF-installation and adapting the fvSolution of groovyTank accordingly

ivan_cozza March 1, 2011 06:09

Hi Foamers, and in particular groovyBc users,
I am quite new in using this great utility, and I need some hints from experts in it!
I have to do some compressible simulations of rarefied gases in a channel, with rhoSimpleFoam. To take into account the rarefaction, I would like to use the following slip wall b.c.

U_slip = {(2-sigma)/sigma * lambda * [d(U dot tau)/dn + d(U dot n)/dtau ]} tau ,

where U_slip is the velocity at wall, sigma is an accomodation coefficient, lambda the mean free path, tau and n the tangential and normal vector to the wall, dot is the scalar product.

Reading the threads about the heat flux b.c. I immagine that groovyBc could solve my problem, but I have no idea on how to implement this formula in it. Could anyone give me some hint to do that?

Thank you in advance,
Ivan

T.D. March 1, 2011 08:10

hi this is an example of a parabolic inlet velocity type BC
inlet
{
type groovyBC;
variables "Umax=1;c=pos().y;cc=1*c;d=pow(c,2);e=cc-d;speed=4*Umax*e;";
valueExpression "vector (speed, 0, 0)";

}

you can do similarly by placing your expression.
For differnet expressions syntax see: http://openfoamwiki.net/index.php/Contrib_groovyBC

Good Luck !

T.D.

ivan_cozza March 1, 2011 08:15

Quote:

Originally Posted by T.D. (Post 297468)
hi this is an example of a parabolic inlet velocity type BC
inlet
{
type groovyBC;
variables "Umax=1;c=pos().y;cc=1*c;d=pow(c,2);e=cc-d;speed=4*Umax*e;";
valueExpression "vector (speed, 0, 0)";

}

you can do similarly by placing your expression.
For differnet expressions syntax see: http://openfoamwiki.net/index.php/Contrib_groovyBC

Good Luck !

T.D.

Thank you T.D. for your quick answer, but it doesn't solve my issue, as this expression is for a Dirichlet type b.c., but I need a Robin (or mixed) b.c., so I have to play with gradient in some way, but I don't know how...

gschaider March 1, 2011 13:09

Quote:

Originally Posted by ivan_cozza (Post 297469)
Thank you T.D. for your quick answer, but it doesn't solve my issue, as this expression is for a Dirichlet type b.c., but I need a Robin (or mixed) b.c., so I have to play with gradient in some way, but I don't know how...

I'm not sure whether groovyBC can achive what you want to do (it HAS its limit, you know ;) ). I trust you had a look at the Wiki-page T.D. gave. So at least you stumbled upon normal() for the normal vecotor. U.snGrad() should give you the surface normal of U, but that is not what you want. Another problem is your tau. For a patch as it is 2D you'll always have 2 orthogonal tangential directions so you'll probably want to reformulate (x dot tau) as mag(x-normal()*(normal() dot x)).

Did I understand your formulation correctly that if you can calculate U_slip correctly from the current flow conditions, then you can set it on the boundary as a Dirichlet? Otherwise you'll have to reformulate it. But as I said: you'll have to play around (not sur how to implement the d/dTau in you equation) and I can't guarantee success

Bernhard

ivan_cozza March 2, 2011 03:57

Hi Bernhard, and thank you for your answer.

Quote:

Originally Posted by gschaider (Post 297514)
I trust you had a look at the Wiki-page T.D. gave.

Yes, I take a look there sometimes ago.

Quote:

Originally Posted by gschaider (Post 297514)
So at least you stumbled upon normal() for the normal vecotor. U.snGrad() should give you the surface normal of U, but that is not what you want.

Correct, I don't need U.snGrad(), or at least not only it.

Quote:

Originally Posted by gschaider (Post 297514)
Another problem is your tau. For a patch as it is 2D you'll always have 2 orthogonal tangential directions so you'll probably want to reformulate (x dot tau) as mag(x-normal()*(normal() dot x)).

Again correct, in my case tau is the tangential vector aligned with the flow velocity U, so (U dot tau) = mag(U-normal()*(normal() dot U)).

Quote:

Originally Posted by gschaider (Post 297514)
Did I understand your formulation correctly that if you can calculate U_slip correctly from the current flow conditions, then you can set it on the boundary as a Dirichlet? Otherwise you'll have to reformulate it. But as I said: you'll have to play around (not sur how to implement the d/dTau in you equation) and I can't guarantee success

What I want to do is set the slip velocity at wall, so at the end a Dirichlet b.c. for U is possible. On the other end, for stability reasons I need to evaluate U_slip in an implicit way, so I can't just discretize the derivatives and solve.
For d(U dot n)/dtau, maybe it could be rewritten as grad(U dot n) dot tau

Any other ideas? I definitely hope that groovyBc would do the trick...
Thanks, Ivan


All times are GMT -4. The time now is 00:33.