|
[Sponsors] |
accessing 0 time directory in coded functionObject |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 21, 2018, 09:34 |
accessing 0 time directory in coded functionObject
|
#1 |
Member
Join Date: Apr 2018
Location: UK
Posts: 78
Rep Power: 8 |
Hi there,
I am hoping to get some help with coded function objects in openFoam. I have written a function object to compute the radius of a bubble based on volume fraction alpha and cell volume as follows (compressibleInterFoam): Code:
// section of coded to be executed, in controlDict forAll(centers, I) { if (alpha[I] < th) { // TO COMPUTE RADIUS // compute numerator, time-varying sumNumerator += (1-alpha[I])*(V[I]); // per time-step // compute denominator, constant at t = 0 sumDenominator += (1-alpha[I])*(V[I]); // CHANGE TO ACCESS VALUES AT TIME = 0 -- how? // At each time-step bracket = pow(sumNumerator/sumDenominator, 1/3); // compute Radius Radius = Rstart*bracket; } } The code compiles and runs but with the above setting the radius clearly stays constant for all time-directories. Please help. Any advice will be greatly appreciated. p.s. I know I can do something similar in swak4Foam but so far I have not managed to make this work for my current version (v5.0) and I want to try out some coding in OpenFOAM and c++ as an exercise (still a newbie). |
|
December 18, 2018, 11:06 |
|
#2 |
New Member
Francisco
Join Date: Sep 2018
Location: Portugal
Posts: 27
Rep Power: 8 |
Hi! I'm also a newbie, so I'm not sure if this'll help, but have you tried to compile that function as a functionObject? That way it would available as postProcess utility (I think).
I haven't done this myself, yet, if it works, you can employ it at time 0 by stating Code:
postProcess -func Nameofutility -time 0 EDIT: Now that I'm checking, it's been a while since this was posted... Sorry if it qualifies as necroing! |
|
December 19, 2018, 13:20 |
Suggestion
|
#3 |
Member
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 8 |
Hey,
here is a suggestion how you could compute the volume of your bubble (or whatever you would like to calculate). Sometimes, I'm doing this myself in order to get some calculations done when the simulation is already over. The way is to write some postprocessing utility. Write a tool, wmake it and run it on your case. This can look like this: bubbleVolume.C Code:
#include "timeSelector.H" #include "Time.H" #include "fvMesh.H" #include "volFields.H" using namespace Foam; int main(int argc, char *argv[]) { timeselector::addOptions(); #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" // create a list of the times, from time directories given the time arguments // example: -time <ranges> or -latestTime instantList timeDirs = timeSelector::select0(runTime, args); // loop over this list forAll(timeDirs,timeI) { runTime.setTime(timeDirs[timeI],timeI); mesh.readUpdate(); // now get the fields you need for computation volScalarField fieldNeeded ( IOobject ( "fieldNeeded", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); scalar bubbleVolume; // .... // compute bubbleVolume // .... Info << runTime.timeName() << " " << bubbleVolume << nl; } return 0; } Best regards and good luck RP |
|
May 26, 2023, 17:50 |
|
#4 |
Member
Uttam
Join Date: May 2020
Location: Southampton, United Kingdom
Posts: 35
Rep Power: 6 |
You are a legend. Thanks for this.
__________________
Best Regards Uttam ----------------------------------------------------------------- “When everything seem to be going against you, remember that the airplane takes off against the wind, not with it.” – Henry Ford. |
|
Tags |
coded function object, compressibleinterfoam, directories, functionobjects |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to calculate mass flow rate on patches and summation of that during the run? | immortality | OpenFOAM Post-Processing | 104 | February 16, 2021 09:46 |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 04:30 |
pressure in incompressible solvers e.g. simpleFoam | chrizzl | OpenFOAM Running, Solving & CFD | 13 | March 28, 2017 06:49 |
High Courant Number @ icoFoam | Artex85 | OpenFOAM Running, Solving & CFD | 11 | February 16, 2017 14:40 |
same geometry,structured and unstructured mesh,different behaviour. | sharonyue | OpenFOAM Running, Solving & CFD | 13 | January 2, 2013 23:40 |