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/)
-   -   creating a new/derived field and writing at output time (https://www.cfd-online.com/Forums/openfoam-solving/181194-creating-new-derived-field-writing-output-time.html)

cfd@kgp December 9, 2016 07:20

creating a new/derived field and writing at output time
 
Dear Foamers',

I want to create a new/derived field and write it at the output time.

lets visualize a new volScalarField of mag(U).

I found out there three ways to do it---

1. edit the application (I want to omit this option)

2. using Swak4foam with expressionField. I tried it by editing the controlDict

Quote:

velocityMagSquared
{
type expressionField;
//outputControl outputTime;
//outputInterval 1;
fieldName UMag2;
expression "U&U";
autowrite true;
}
I also get the output file written in the corresponding output/time directory.

But problem is paraview do not import thes new field, it do not have this information.

the last way is using coded function/dynamic code,

I tried this, by adding the following lines in controlDict

Quote:

compute_ptot
{
functionObjectLibs ( "libutilityFunctionObjects.so" );
type coded;
enabled true;
redirectType ptot;
// outputControl outputTime;
// outputInterval 1;
code
#{

const volVectorField& U = mesh().lookupObject<volVectorField>("U");
volScalarField ptot
(
IOobject
(
"ptot",
mesh().time().timeName(),
U.mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mag(U)
);


#};
}
I neither get any new file in the corresponding output/time directory nor any visualization..:confused::confused::confused:

Please give me some suggesions with option 2 or 3.

I am trying this in OF 3.x and using following libraries,
Quote:

libs (
"libOpenFOAM.so"
"libsimpleSwakFunctionObjects.so"
"libswakFunctionObjects.so"
"libgroovyBC.so"
"mylibfvOptions.so"

);
Thanks,


All times are GMT -4. The time now is 15:59.