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] Problems with implementing groovy BC (https://www.cfd-online.com/Forums/openfoam-community-contributions/162648-problems-implementing-groovy-bc.html)

STutexas November 14, 2015 20:47

Problems with implementing groovy BC
 
Hi

I am using OpenFoam to solve the magnetization decay problem and the boundary condition that I have looks like this:

D.n.delta(M)+b.M = 0

where,
D is scalar constant,
n is the surface normal to the boundary face
delta is the gradient operator
b is a constant
M is a vector field

I tried using:

boundaryField
{
fixedWalls
{
type groovyBC;
refValue uniform (0 0 1);
refGradient uniform (0 0 0);
valueFraction uniform 1;
value uniform (0 0 1);
valueExpression "Tinf";
gradientExpression "0";
fractionExpression "f";
evaluateDuringConstruction 0;
variables
4
(
"D=3e-09;"
"rho=10e-06;"
"Tinf=D/rho*snGrad(M);"
"f=I;"
)
;
timelines (
);
lookuptables (
);
}
}
but it gives me an error. Pleas let me know how I can code my boundary condition.

Thank you.

Nicole November 18, 2015 05:07

Hi Saurabh,

I am a novice myself, but perhaps if you post your error message then someone smarter can help you better.

One quick check:
Did you add
Code:

libs ( "libgroovyBC.so");
to your controlDict file?

You need to do this if you want groovyBC to work.

Your code looks ok at first glance. I don't normally put the "4" in front of the variables list, but I'm not sure if this would cause a problem.

STutexas November 18, 2015 21:25

Hi

Thank you for replying to my post.

This is the full context of the error that I get for my simulations:

I use this file, for initial conditions:

FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object M;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 -2 0 0 0 1 0];

internalField nonuniform List<vector>
64000
( ..list of values..
);

boundaryField
{
fixedWalls
{
type groovyBC;
value uniform (0 0 0);
valueExpression "vector (0, 0, 0)";
gradientExpression "vector (0, 0, 0)";
fractionExpression "f";
variables
4
(
"D=3e-09;"
"rho=10e-06;"
"Tinf=vector (0, 0, 0);"
"f=tensor(1/(1+D/(rho*mag(delta()))), 0, 0, 0, 1/(1+D/(rho*mag(delta()))), 0, 0, 0, 1/(1+D/(rho*mag(delta()))));"
)
;
timelines (
);
lookuptables (
);
}
}


So far so good? So when I run the code this is the error that I get.

swak4Foam: Allocating new repository for sampledGlobalVariables
--> FOAM FATAL ERROR:
The expected return type scalar is different from the stored result type "tensor"
From function tmp<Field<Type> > ExpressionResult::getResult()
in file ../swak4FoamParsers/lnInclude/ExpressionResultI.H at line 247.

Please let me know if you can understand this error and help me rectify it.
Thanks again.

Saurabh

Nicole November 19, 2015 01:43

Hi Saurabh,

Your error message says that something is a tensor when groovyBC is expecting a scalar.

Code:

--> FOAM FATAL ERROR:
The expected return type scalar is different from the stored result type "tensor"

This might have something to do with "f" in your variables.

STutexas November 19, 2015 01:53

Hi Nicole

Thank you for replying so quickly. Please peruse the post

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

This describes the use of tensor for f in the case you have vector field instead of a scalar field. I am following these instructions. But you are right, in case of scalar field you have scalar f instead of a tensor. But it keeps giving me an error. Thanks again.

Saurabh

Nicole November 19, 2015 02:49

Hi Saurabh,

Sorry, I have not worked with tensors so I am rather out of my depth by now. Have you tried adding a space between the declaration and the bracket like this f= tensor (....etc . I think I saw something about that in a post once.

Unfortunately that is all that I can think of with my limited understanding. Sorry I can't be more help :(

STutexas November 19, 2015 03:03

Well, no problem. Thank you for the help. I will try it using refCast now.
Saurabh

nlc December 5, 2015 21:42

Im not certain of what is gonig on is valueFraction is a scalar or it is a symmTensor field like in directionmix boundary condition

valueFraction uniform 1; ???

Would you be open to share your case so i can run it to see what is going on. I would binterested in your simulation and boundary condition. Maibe you can send me the case by dropbox or on a zip on this forum.

Regards

STutexas December 5, 2015 22:27

I was a little confused as well.

When you use GroovyBC the valueFraction or the refValue fraction should be a scalar. GroovyBC cannot handle tensors. But when you run a code like funkySetFields it will define a weird set of values for your variables that you see in my post.

When you use directionMixed BC value fraction should be a tensor. Like you mentioned it can be symmetric tensor.

In my problem I have to define value fraction as a non-symmetric surface tensor field. That's why I am a little confused. If you read my post you will understand why I need to do that.

nlc December 5, 2015 23:11

In the BC directionMixed valuefraction is a by dfi ition a symmTensor field when I look at the c++ code. To have a non symmetric tensor field as valuefraction you can copy and modify dirctionMixed and replace symmTensor with tensor recompile ...

Would you be open to share exemple case of what you try to do ? I would be interested to run it and look at the specific BC you need

regard

STutexas December 5, 2015 23:19

Right now I am trying to use fixed value BC in the simulation. I use refCast to extract the values at the boundaries and then modify the values in accordance with my BC at the beginning of each time step. But I will try and modify the the tensor in the future. I can let you know how I do then. Thanks again for your advice.

Saurabh


All times are GMT -4. The time now is 08:37.