CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Issue with volTensorField calculation (https://www.cfd-online.com/Forums/openfoam-solving/143011-issue-voltensorfield-calculation.html)

Surly October 14, 2014 09:20

Issue with volTensorField calculation
 
Hello everyone,
I am trying out different ways to calculate Lyapunov exponents for my current calculations.
For one of them I am interested in calculating jacobian of particle positions, as a test I started using the cell centres as my positions
volVectorField Ct = mesh.C();
volTensorField gradCt = fvc::grad(Ct);

However as I run the code (in parallel), I get the error message below.
Having looked at similar things being done in Openfoam where for example the velocity field U is used, I don't understand why it happens.

Any help would be greatly appreciated. Thanks

[25] --> FOAM FATAL ERROR:
[25] Not implemented
[25]
[25] From function slicedFvPatchField<Type>::snGrad()
[25] in file lnInclude/slicedFvPatchField.C at line 171.

cnsidero October 14, 2014 11:00

This isn't a solution, simply a diagnosis so apologies if you've already figured this out.

First, as you've found out slicedFvPatch field does not have snGrad defined (not most others). Check out:

Code:

$WM_PROJECT_DIR/finiteVolume/fields/fvPatchFields/basic/sliced/slicedFvPatchField.C
and you'll find many of the members functions and constructors are not implemented.

If you dig into the mesh.C() you'll find it creates a slicedVolVectorField which has internal and boundary fields, the later the cause of the error. Check out line 138 in:

Code:

./finiteVolume/fvMesh/fvMeshGeometry.C
You'll have to figure out an alternate way to compute the gradients of the cell centers that doesn't create a slicedGeometricField. Sorry I'm not more helpful.

Surly October 14, 2014 12:27

Thanks for the help!
Indeed I did looked at that in the end, and those "sliced" fields will just have to go..... or maybe not....
Anyway, I'll find a way.

cnsidero October 14, 2014 13:13

Just thought of something, since (I think) you're interested in the Jacobian of _only_ the cell centers of the volume mesh, you could just try returning the internalField of the volume mesh and apply the gradient to that, i.e.:

Code:

volVectorField Ct_i = mesh.C().internalField();
volTensorField gradCt_i = fvc::grad(Ct_i);

I haven't looked at the code and can't confirm it'll work. I'm assuming it's only the undefined snGrad that's not defined so it's just a guess.

hjasak October 15, 2014 06:29

Sorry, Chris, no: internalField is just a field and you need a volField to calculate a gradient.

Please make a plain field; make a COPY of the field C and called grad. However, you are just testing discretisation errors: grad(x) = 1 (in 1-D).

I think you need something different...

Hrv

Surly October 15, 2014 11:24

Hello Hrvoje, thank you for your response.

What do you mean by "plain field" and then use the COPY of the mesh.C() field?

hjasak October 15, 2014 11:40

volVectorField centres
(
IOobject
(
"centres",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimLength
);

centres == mesh.C();

fvc::grad(centres) should now work.

Hrv


All times are GMT -4. The time now is 22:13.