CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Question for setting User Defined Variables at runtime for monitoring

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 31, 2021, 17:35
Default Question for setting User Defined Variables at runtime for monitoring
  #1
New Member
 
Donghun Kang
Join Date: Jan 2021
Posts: 4
Rep Power: 5
Paul_AERO is on a distinguished road
Greetings,

I am a beginner of OF. I have trouble compiling user defined variable (pprime) in the system/controldict. (version: v2012)

functions
{
pprime
{

type coded;
libs (utilityFunctionObjects);
name pprime;

writeControl timeStep;
writeInterval 1;

codeWrite //(or codeExecute)
#{
const volScalarField& p = mesh().lookupObject<volScalarField>("p");
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
volScalarField pprime
(
IOobject
(
"pprime",
mesh().time().timeName(),
p.mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p
);
pprime=p-101325;
#};

fields
(
pprime
{
base time;
}
);
}

}

I referred to Create registered object at runtime using a functionObject

But mine does not work, showing:
--> Could not load "...

Before running, is there any command to compile?
My current sequence to simulate is mpirun -np 16 rhoPimpleFoam -parallel

Thanks,

Paul
Paul_AERO is offline   Reply With Quote

Old   February 9, 2021, 17:56
Default
  #2
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 14
clapointe is on a distinguished road
Without seeing the full error it is hard to help. However, if we check out the codedFunctionObject.H file, we find the following template :

Code:
    {
        type coded;
        libs (utilityFunctionObjects);

        // Name of on-the-fly generated functionObject
        name writeMagU;
        codeWrite
        #{
            // Lookup U
            const volVectorField& U = mesh().lookupObject<volVectorField>("U");

            // Write
            mag(U)().write();
        #};
    }
So if we update this for your case, we get :

Code:
    pprime
    {
        type coded;
        libs (utilityFunctionObjects);

        // Name of on-the-fly generated functionObject
        name writePPrime;
        codeWrite
        #{
            // Lookup p, name pprime
            const volScalarField& pprime = mesh().lookupObject<volScalarField>("p");

            //Update pprime
            pprime -= dimensionedScalar("refP", pprime.dimensions(), 101325);

            // Write
            pprime.write();
        #};
    }
Note that I've not tested the above code, but if it doesn't work out of the box hopefully it'll point you in the right direction.

Caelan
clapointe is offline   Reply With Quote

Old   September 7, 2021, 17:43
Default
  #3
New Member
 
Donghun Kang
Join Date: Jan 2021
Posts: 4
Rep Power: 5
Paul_AERO is on a distinguished road
Thanks Caelan!

I have resolved that issue

Paul
Paul_AERO is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF value to large for defined data type Anna73 Fluent UDF and Scheme Programming 9 September 30, 2018 22:18
Read Result Files or User Defined Result Aquilaris ANSYS 0 February 9, 2011 05:25
User Defined Scalar (UDS) question (units) D FLUENT 0 March 1, 2006 20:04
Usage of user defined functions Gowrish FLUENT 1 October 26, 2005 07:44
User defined memory Hp FLUENT 0 September 24, 2004 00:10


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