|
[Sponsors] |
September 24, 2013, 05:46 |
updateCoeffs() and evaluate()
|
#1 |
New Member
Join Date: Nov 2012
Posts: 13
Rep Power: 14 |
Hi Foamers,
I am confused with the two functions in boundary condition classes: updateCoeffs() and evaluate(). Sometimes updateCoeffs() is called, but in some BCs evaluate() is called (e.g., src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C ). And in the body of evaluate(), there is a call to updateCoeffs() first. Code:
template<class Type> void fixedGradientFvPatchField<Type>::evaluate(const Pstream::commsTypes) { if (!this->updated()) { this->updateCoeffs(); } Field<Type>::operator= ( this->patchInternalField() + gradient_/this->patch().deltaCoeffs() ); fvPatchField<Type>::evaluate(); } Another problem is why sometimes a BC have to deal specially with the parallel mode (say, in src/finiteVolume/fields/fvPatchFields/derived/mappedFixedValue/mappedFixedValueFvPatchField.C, updateCoeffs()) while others don't have to do so? Is there guideline for this? Many thanks, Xianxiang |
|
October 3, 2013, 05:00 |
|
#2 |
New Member
Join Date: Nov 2012
Posts: 13
Rep Power: 14 |
Hi anybody can help here? Or this is a really stupid question to ask?
|
|
October 5, 2013, 09:25 |
|
#3 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Xianxiang,
When in doubt, check the code documentation: http://foam.sourceforge.net/docs/cpp/index.html I did a quick search regarding each method and it should be somewhat self-explanatory from their documentation (namely the comments from the header files):
Best regards, Bruno
__________________
|
||
April 29, 2015, 05:43 |
|
#4 |
Senior Member
Timofey Mukha
Join Date: Mar 2012
Location: Stockholm, Sweden
Posts: 119
Rep Power: 14 |
Hello!
Bruno, I think the matter is actually more involved, or, maybe I misunderstand something. Both evaluate() and updateCoeffs() seem to do more or less the same thing. Calculate some stuff relevant to the boundary condition and then enforce the changes. The latter can take the form of an assignment via == or =, or through the change of some relevant parameters, like weights in the mixed b.c. As indicated in this thread here the evaluate() method seems to be implemented only in the highest levels of hierarchy and commonly deals with more "complicated" stuff like the case of coupled patches. The updateCoeffs() seems to do all the complicated work in the classes that are further downstream in the hierarchy. I am personally looking at wall-functions for LES and the one that exists in OF implements everything in updateCoeffs(), including an iterative procedure to calculate u_tau at each face. In my view this definitely qualifies as "processing the flow", but maybe you meant something else. The main relationship between the methods is that evaluate() always calls updateCoeffs(). In fvPatchField.C/H we have Code:
template<class Type> void Foam::fvPatchField<Type>::evaluate(const Pstream::commsTypes) { if (!updated_) { updateCoeffs(); } updated_ = false; } virtual void updateCoeffs() { updated_ = true; } |
|
May 3, 2015, 14:11 |
|
#5 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Timofey,
I wrote that post about a year ago and today I still don't know everything about OpenFOAM The thread you mentioned does give some clearer insight: Quote:
Best regards, Bruno |
||
February 10, 2020, 06:12 |
|
#6 | |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16 |
Quote:
Hi I want to check value of a variable inside the updateCoeffs() function however simple putting Info statement inside the code of the updateCoeffs() does not work do you know how to do it?
__________________
best regards pblasiak |
||
April 16, 2020, 13:49 |
|
#7 | |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
For future reference, quoted from https://www.openfoam.com/documentati...s.html#details:
Quote:
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
||
April 16, 2020, 17:17 |
|
#8 |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16 |
Thank you for your response HPE. It will be useful.
Besides that I managed to use Info statement inside BC. I do not know why it did not work earlier. Maybe I compiled it in debug version and run opt version, by mistake.
__________________
best regards pblasiak |
|
August 12, 2020, 15:36 |
|
#9 |
Senior Member
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 11 |
Hi,
So updateCoeffs() will affect the current solution and evaluate() will affect solution for the next step? Thanks, Rdf |
|
August 12, 2020, 16:21 |
|
#10 | |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11 |
Quote:
No. Usually evaluate() makes a call to updateCoeffs() somewhere up the inheritance, where the updated_ flag (a boolean variable) is set to true. In theory you can update your boundary condition with either function and the effects are the same, but using updateCoeffs() you could (potentially) take advantage of the updated_ flag so that the values are only updated once per time step, instead of once per (inner and outer) solver iteration. Hope that helps, Gerry. P.S. - I also agree with tiam (response #4 above). I leave all the heavy lifting to evaluate(), and have updateCoeffs() perform the final write to the solver coefficients. |
||
August 12, 2020, 16:26 |
|
#11 |
Senior Member
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 11 |
Gerry,
I see. We are on the same page. However, in the fixedGradientFvPatchField, there is no definition of updateCoeffs(); what will this->updateCoeffs(); do ? Thanks, Rdf |
|
August 12, 2020, 16:41 |
|
#12 | |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11 |
Quote:
this->updateCoeffs() calls the shallowest inherited virtual function definition. Since updateCoeffs() is not defined in fixedGradient, it will call the updateCoeffs() in fvPatchField, one level up the inheritance tree, which is defined. However, if you define your own updateCoeffs() in your variant of fixedGradient, this->updateCoeffs() will call that instead. Also, if memory serves, fixedGradientFvPatchField::evaluate() calls its parent virtual function fvPatchField::evaluate(), which in turn calls fvPatchField::updateCoeffs(). fvPatchField::updateCoeffs() serves only to toggle the value of updated_ to true. So this reinforces the idea that you can implement your B.C. in either function. Hope that helps, Gerry. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Purposes of updateCoeffs, initEvaluate and evaluate....? | philippose | OpenFOAM Programming & Development | 9 | September 29, 2020 06:09 |
implementation of wallHeatTransfer BC | Tobi | OpenFOAM Programming & Development | 1 | August 8, 2012 09:21 |