CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Writing themophysical propoerties during runtime by controldict

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 5, 2023, 12:20
Default Writing themophysical propoerties during runtime by controldict
  #1
New Member
 
Join Date: Mar 2021
Posts: 8
Rep Power: 5
nukecrafts is on a distinguished road
Hello there,
I'm using OF10 (rhoPimpleFoam). Previously I was modifying createFields.H file to get mu, cp, kappa etc. by using following example entry.
Code:
volScalarField mu
(
    IOobject
    (
        "mu",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    thermo.mu()
);
But I want to do this via functionobject in controldict. I tried following but It's not creating anything.

Code:
writeviscosity
{
    type            coded;
    libs            ("libutilityFunctionObjects.so" "libOpenFOAM.so");
    region          main;
    executeControl  timeStep;
    executeInterval 1;
    writeControl    writeTime;
    log             true;
    code
    #{
        #include "fvCFD.H"
        #include "volFields.H"
        const volScalarField& mu = mesh().thermo.mu();
    volScalarField mu
(
    IOobject
    (
        "mu",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mu
);
    #};
}
Can you help me to make this idea work? It would be very practical for everyone trying to do such thing I believe.
nukecrafts is offline   Reply With Quote

Old   April 5, 2023, 17:45
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
You are almost there. In your first example, you are creating the field, registering it and using AUTO_WRITE to make sure that it is being written.


With your updated code, the created field goes out ouf scope immediately so there is nothing hanging about for a later AUTO_WRITE to do at all.


What you want is to write it yourself. Here's an example,



https://develop.openfoam.com/Develop...em/controlDict
olesen is offline   Reply With Quote

Reply

Tags
function object, runtime processing, thermophysical properties, write data


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
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 02:36
SU2 7.0.7 Built on CentOS 7, parallel computation pyscript mpi exit error? EternalSeekerX SU2 3 October 9, 2020 18:28
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 05:38
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 18:57
[snappyHexMesh] crash sHM H25E OpenFOAM Meshing & Mesh Conversion 11 November 10, 2014 11:27


All times are GMT -4. The time now is 23:25.