
[Sponsors] 
How the boundary conditions are called in the OpenFOAM solvers? 

LinkBack  Thread Tools  Display Modes 
February 1, 2014, 10:05 
How the boundary conditions are called in the OpenFOAM solvers?

#1 
Senior Member
Join Date: Jan 2013
Posts: 297
Rep Power: 6 
Dear All,
I was wondering how the boundary conditions subroutines are called ? Let us take an example: Code:
OpenFOAM/OpenFOAM2.1.1/tutorials/compressible/rhoPimpleFoam/les/pitzDaily Code:
U/0 Code:
inlet { type turbulentInlet; referenceField uniform (10 0 0); fluctuationScale (0.02 0.01 0.01); value uniform (10 0 0); } Thank you in advance! 

February 3, 2014, 01:54 

#2 
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,781
Rep Power: 22 
Easy:
 on correctBoundaryConditions() for a field  on updateCoeffs() at matrix creation correctBoundaryConditions is also called after the linear solver call automatically. Enjoy, Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk 

February 3, 2014, 12:16 

#3 
Senior Member
Join Date: Jan 2013
Posts: 297
Rep Power: 6 
Thank you so much, Hrvoje!
About the first one, I get it in the Code:
src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C Code:
// Correct the boundary conditions template<class Type, template<class> class PatchField, class GeoMesh> void Foam::GeometricField<Type, PatchField, GeoMesh>:: correctBoundaryConditions() { this>setUpToDate(); storeOldTimes(); boundaryField_.evaluate(); } Code:
src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H Code:
// Evaluate boundary conditions void evaluate(); 

February 3, 2014, 12:21 

#4 
Senior Member
Join Date: Jan 2013
Posts: 297
Rep Power: 6 
About the updateCoeffs in the turbulentInlet boundary conditions
Code:
OpenFOAM/OpenFOAM2.1.1/src/finiteVolume/fields/fvPatchFields/derived/turbulentInlet Code:
template<class Type> void turbulentInletFvPatchField<Type>::updateCoeffs() { if (this>updated()) { return; } if (curTimeIndex_ != this>db().time().timeIndex()) { Field<Type>& patchField = *this; Field<Type> randomField(this>size()); forAll(patchField, facei) { ranGen_.randomise(randomField[facei]); } // Correctionfactor to compensate for the loss of RMS fluctuation // due to the temporal correlation introduced by the alpha parameter. scalar rmsCorr = sqrt(12*(2*alpha_  sqr(alpha_)))/alpha_; patchField = (1  alpha_)*patchField + alpha_* ( referenceField_ + rmsCorr*cmptMultiply ( randomField  0.5*pTraits<Type>::one, fluctuationScale_ )*mag(referenceField_) ); curTimeIndex_ = this>db().time().timeIndex(); } fixedValueFvPatchField<Type>::updateCoeffs(); } Code:
fixedValueFvPatchField<Type>::updateCoeffs(); ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++ As a record how I understand this, I put the answer here: evaluate() is defined in Code:
src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C Code:
template<class Type, template<class> class PatchField, class GeoMesh> void Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField:: evaluate() { if (debug) { Info<< "GeometricField<Type, PatchField, GeoMesh>::" "GeometricBoundaryField::" "evaluate()" << endl; } if ( Pstream::defaultCommsType == Pstream::blocking  Pstream::defaultCommsType == Pstream::nonBlocking ) { label nReq = Pstream::nRequests(); forAll(*this, patchi) { this>operator[](patchi).initEvaluate(Pstream::defaultCommsType); } // Block for any outstanding requests if ( Pstream::parRun() && Pstream::defaultCommsType == Pstream::nonBlocking ) { Pstream::waitRequests(nReq); } forAll(*this, patchi) { this>operator[](patchi).evaluate(Pstream::defaultCommsType); } } else if (Pstream::defaultCommsType == Pstream::scheduled) { const lduSchedule& patchSchedule = bmesh_.mesh().globalData().patchSchedule(); forAll(patchSchedule, patchEvali) { if (patchSchedule[patchEvali].init) { this>operator[](patchSchedule[patchEvali].patch) .initEvaluate(Pstream::scheduled); } else { this>operator[](patchSchedule[patchEvali].patch) .evaluate(Pstream::scheduled); } } } else { FatalErrorIn("GeometricBoundaryField::evaluate()") << "Unsuported communications type " << Pstream::commsTypeNames[Pstream::defaultCommsType] << exit(FatalError); } } 

February 5, 2014, 07:50 

#5 
Senior Member
Join Date: Jan 2013
Posts: 297
Rep Power: 6 
No Body also interested in this issue?


February 5, 2014, 10:27 

#6  
New Member
Y
Join Date: Feb 2013
Location: Dresden =)
Posts: 24
Rep Power: 5 
As a newbie I asked a similar question in my latest post:
How can I make heat flux an external coupled BC like tempratur? Quote:
Code:
correctBoundaryConditions() { this>setUpToDate(); storeOldTimes(); boundaryField_.evaluate(); } Am I right? 

February 5, 2014, 18:33 

#7 
Senior Member
Join Date: Jan 2013
Posts: 297
Rep Power: 6 
Yes, I agree with you. I also did some digging into the source files. But do you know the role of the following lines:
Code:
fixedValueFvPatchField<Type>::updateCoeffs(); 

February 20, 2014, 16:46 

#8 
Senior Member
Join Date: Jan 2013
Posts: 297
Rep Power: 6 
I did not find this function in the source:
fixedValueFvPatchField.H Sorry for my limit C++ skills. Does anybody know where I can find this function, Code:
fixedValueFvPatchField<Type>::updateCoeffs(); 

February 20, 2014, 17:02 

#9 
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,781
Rep Power: 22 
Please read up on virtual functions  this is basic C++
Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk 

April 10, 2014, 06:30 

#10  
Senior Member
Join Date: Jan 2013
Posts: 297
Rep Power: 6 
For my record, actually, the following lines:
Code:
fixedValueFvPatchField<Type>::updateCoeffs(); The function updateCoeffs is defined in: Code:
fvPatchField.H Quote:


April 10, 2014, 06:32 

#11 
Senior Member
Join Date: Jan 2013
Posts: 297
Rep Power: 6 
Dear Dr Jasak,
The second item you mentioned: Code:
updateCoeffs() OFFO 

April 16, 2014, 17:54 

#12 
New Member
Y
Join Date: Feb 2013
Location: Dresden =)
Posts: 24
Rep Power: 5 
my understanding so far is:
Those BC types that need updating and evaluation at each time step, they either have updateCoeffs() or evaluate() in the class definition, virtual of course. When a fvMatrix<type> Eqn is created, the updateCoeffs() is called in its constructor. Then in Eqn().solve() the function correctBoundaryConditions() is called, which contains evaluate(). Now the two functions are implemented differently in every BC, and the solver would also execute different things out according to each BC type defined. Thanks for corrections and improvement. peter 

December 19, 2014, 02:26 

#13 
New Member
Abtin Ansari
Join Date: Oct 2014
Posts: 2
Rep Power: 0 
My understanding is that functions like updateCoeffs() and evaluate() are defined first in the upper code level virtually like in GeometricBoundaryField.C and overloaded(redefined) later in specific derived classes where actual math manipulation is done. For example lets look at fixedGradientFvPatchField.C in /src/finiteVolume/fields/fvPatchFields/basic/fixedGradient :
template<class Type> void fixedGradientFvPatchField<Type>::evaluate(const Pstream::commsTypes) { if (!this>updated()) { this>updateCoeffs(); } Field<Type>:perator= ( this>patchInternalField() + gradient_/this>patch().deltaCoeffs() ); fvPatchField<Type>::evaluate(); } Here , the value is updated based on specified gradient in BC file. Can somebody please verify since I'm I also new to C++? 

December 19, 2014, 13:38 

#14  
Senior Member
Join Date: Jan 2013
Posts: 297
Rep Power: 6 
I think what you said is correct.
Quote:


Tags 
boundary condition 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Question about heat transfer coefficient setting for CFX  Anna Tian  CFX  1  June 16, 2013 06:28 
exporting boundary conditions with pointwise > openFoam  ebah6  OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ...  2  September 16, 2012 16:57 
CFX13 Post Periodic interface  EtaEta  CFX  7  December 8, 2011 18:15 
New OpenFOAM Forum Structure  jola  OpenFOAM  2  October 19, 2011 06:55 
RPM in Wind Turbine  Pankaj  CFX  9  November 23, 2009 05:05 