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

Access fields from function objects

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By mAlletto

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 6, 2021, 05:45
Default Access fields from function objects
  #1
Senior Member
 
Simbelmynė's Avatar
 
Join Date: May 2012
Posts: 546
Rep Power: 15
Simbelmynė is on a distinguished road
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?
Simbelmynė is offline   Reply With Quote

Old   February 8, 2021, 06:55
Default
  #2
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
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
mAlletto is offline   Reply With Quote

Old   February 8, 2021, 07:16
Default
  #3
Senior Member
 
Simbelmynė's Avatar
 
Join Date: May 2012
Posts: 546
Rep Power: 15
Simbelmynė is on a distinguished road
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.



}
I have tried to do this modification in the custom solver, and in doing so I add vapour to createFields.H. This seems to override the function object in controlDict and it does not solve for transport any more.



So basically: I wish to use (if possible) a function object and I wish to modify the function object from a custom solver.
Simbelmynė is offline   Reply With Quote

Old   February 8, 2021, 08:37
Default
  #4
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
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
mAlletto is offline   Reply With Quote

Old   February 8, 2021, 12:25
Default
  #5
Senior Member
 
Simbelmynė's Avatar
 
Join Date: May 2012
Posts: 546
Rep Power: 15
Simbelmynė is on a distinguished road
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?
Simbelmynė is offline   Reply With Quote

Old   February 8, 2021, 16:01
Default
  #6
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
Code:
volScalarField& vapor =
const_cast<volScalarField&>
(
mesh().lookupObject<volScalarField>("vapor")
)
Lookupobject gives you a constant reference and you have to cast it to modify it
wht likes this.
mAlletto 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
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


All times are GMT -4. The time now is 18:53.