|
[Sponsors] |
February 6, 2021, 05:45 |
Access fields from function objects
|
#1 |
Senior Member
Join Date: May 2012
Posts: 546
Rep Power: 15 |
Hi,
I would like to modify a function object that solves some scalar transport, let's say for T. I use the multiphaseEulerFoam as basis for this and if I try to access the T field in multiphaseEulerFoam.C it is not declared. If I declare it in createFields.H then I can access it, however, then it seems that the function object becomes dormant (i.e. there is no transport of T). Is there any way around this or do I have to ignore the function object and implement the transport equations for T explicitly? |
|
February 8, 2021, 06:55 |
|
#2 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
I did not exactly understand what you want to do but there is a scalarTransport function object OF
https://www.openfoam.com/documentati...transport.html |
|
February 8, 2021, 07:16 |
|
#3 |
Senior Member
Join Date: May 2012
Posts: 546
Rep Power: 15 |
Thank you for your reply. So if we use your link as example then perhaps I can explain better.
In the example we have a field called "vapour". I assume that we add this information to the controlDict, so there is no compilation of a custom solver involved. I wish to perform a modification to the vapor field during the solution process. Let's say I just wish to change the value: Code:
forAll(vapour, i) { vapour[i] += 1.; // The real value is dependant on other field variables such as density and temperature. } So basically: I wish to use (if possible) a function object and I wish to modify the function object from a custom solver. |
|
February 8, 2021, 08:37 |
|
#4 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
There are coded function objects. Is this from help?
If there are two fields with the same name one may beoverridden. The fields are stored via a hash table in the database. The key is the name of the field |
|
February 8, 2021, 12:25 |
|
#5 |
Senior Member
Join Date: May 2012
Posts: 546
Rep Power: 15 |
Yes, this seems reasonable.
Any suggestion on how to access and modify a variable (e.g. "vapour") from within the solver? Is it possible or should I just define the scalar transport equations in the solver and ignore to use the scalar transport function object? |
|
February 8, 2021, 16:01 |
|
#6 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
Code:
volScalarField& vapor = const_cast<volScalarField&> ( mesh().lookupObject<volScalarField>("vapor") ) |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
whats the cause of error? | immortality | OpenFOAM Running, Solving & CFD | 13 | March 24, 2021 07:15 |
Question about function objects | ce73stargazer | OpenFOAM Post-Processing | 3 | January 8, 2016 02:22 |
[swak4Foam] Incorrect results of SWAK4FOAM function objects if Parallelisation involved | wstapel | OpenFOAM Community Contributions | 0 | December 17, 2015 09:57 |
Compilation errors in ThirdPartymallochoard | feng_w | OpenFOAM Installation | 1 | January 25, 2009 06:59 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 17:51 |