|
[Sponsors] |
Understanding code of inletOutlet / outletInlet |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 4, 2013, 10:54 |
Understanding code of inletOutlet / outletInlet
|
#1 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
Hello everybody,
I would like to create a new boundary condition derived from the outletInlet. I want a "zeroGradient" as outlet and a "slip" / "symmetry" as inlet. But before coding this, I went to study the source code of inletOutlet and outletInlet. I know that depending of the sign of "phi" (flux on the patch field), the code switch from one or the other boundary. However, I cannot understand the piece of code in charge of this process. For the inletOutlet: (opt/openfoam220/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C) Code:
template<class Type> Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField ( const fvPatch& p, const DimensionedField<Type, volMesh>& iF, const dictionary& dict ) : mixedFvPatchField<Type>(p, iF), phiName_(dict.lookupOrDefault<word>("phi", "phi")) // get the flux name { this->refValue() = Field<Type>("inletValue", dict, p.size()); // get the desired fixed value at the inlet if (dict.found("value")) // ??? if the flux go outside the domain ??? { fvPatchField<Type>::operator= ( Field<Type>("value", dict, p.size()) // the patch get the field value ); } else // ??? if the flux go inside the domain ??? { fvPatchField<Type>::operator=(this->refValue()); // the patch get the desired fixed value } this->refGrad() = pTraits<Type>::zero; // set the zero gradient vector this->valueFraction() = 0.0; // ??? for multiphase flow ? ??? } (opt/openfoam220/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C) Code:
template<class Type> Foam::outletInletFvPatchField<Type>::outletInletFvPatchField ( const fvPatch& p, const DimensionedField<Type, volMesh>& iF, const dictionary& dict ) : mixedFvPatchField<Type>(p, iF), phiName_(dict.lookupOrDefault<word>("phi", "phi")) // get the flux name { this->refValue() = Field<Type>("outletValue", dict, p.size()); // get the desired fixed value at the inlet if (dict.found("value")) // ??? if the flux go inside the domain ??? { fvPatchField<Type>::operator= ( Field<Type>("value", dict, p.size()) // the patch get the field value ); } else // ??? if the flux go outside the domain ??? { fvPatchField<Type>::operator=(this->refValue()); // the patch get the desired fixed value } this->refGrad() = pTraits<Type>::zero; // set the zero gradient vector this->valueFraction() = 0.0; // ??? for multiphase flow ? ??? } inletOutlet: Code:
if (dict.found("value")) // ??? if the flux go outside the domain ??? Code:
if (dict.found("value")) // ??? if the flux go inside the domain ??? inletOutlet: Code:
template<class Type> void Foam::inletOutletFvPatchField<Type>::updateCoeffs() { if (this->updated()) { return; } const Field<scalar>& phip = this->patch().template lookupPatchField<surfaceScalarField, scalar> ( phiName_ ); this->valueFraction() = 1.0 - pos(phip); // The difference is here mixedFvPatchField<Type>::updateCoeffs(); } Code:
template<class Type> void Foam::outletInletFvPatchField<Type>::updateCoeffs() { if (this->updated()) { return; } const fvsPatchField<scalar>& phip = this->patch().template lookupPatchField<surfaceScalarField, scalar> ( phiName_ ); this->valueFraction() = pos(phip); // The difference is here mixedFvPatchField<Type>::updateCoeffs(); } |
|
May 6, 2013, 13:54 |
|
#2 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
a small up
|
|
June 12, 2013, 07:10 |
|
#3 |
New Member
Pedro Pastilha
Join Date: Mar 2013
Location: Madrid
Posts: 3
Rep Power: 13 |
Hi,
I just started looking into this BC and I am also struggling a bit with the code. In my case, I would like to apply a profile (which is dependant on patch point coordinates) when the flux is positive (entering the domain) and keep zeroGradient when the flux is negative (exiting the domain). I have already implemented the profile boundary condition as an fvPatchVectorField, but now I would like to (ambitiously) merge it with inletOutlet. Frédéric, have you been able to shed some light into this? Anyone? Any help would be kindly appreciated. I will share anything I can work out on my own! I've had a couple of half-witted yet successful atempts at customizing boundary conditions in the past (fvPatchVectorFields and fvPatchFields mostly), but clearly my feeble OpenFoam/C++ skills have reached a wall with this one... Cheers, Pedro |
|
June 12, 2013, 07:17 |
|
#4 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
Sorry, I haven't been able to learn more about it... I didn't really have time so I gave up. But if you succeed, please leave me a comment
|
|
June 12, 2013, 07:57 |
|
#5 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi all,
that code you posted it not the code you Need couse you posted the Constructor of that function Code:
// Constructor type with three arguments Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField ( constfvPatch& , // Argument 1 const DimensionedField<Type, volMesh>& iF, // Argument 2 const dictionary& dict // Argument 3 ) : mixedFvPatchField<Type>(p, iF), // init var phiName_(dict.lookupOrDefault<word>("phi", "phi")) // init var // Constructor functions - what to do at the beginning (if you create that class) { this->refValue() = Field<Type>("inletValue", dict, p.size()); // inletOultet value if (dict.found("value")) // looking if the user that the initial value; if yes do the following { fvPatchField<Type>::operator= ( Field<Type>("value", dict, p.size()) ); } else // if no - set the inletOutlet value { fvPatchField<Type>::operator=(this->refValue()); } this->refGrad() = pTraits<Type>::zero; this->valueFraction() = 0.0; } // Constructor functions end Here are the member functions for the class like: Foam::inletOutletFvPatchField<Type>::calculate() { // Here is the function you are searching for! } What you Need is the correct or calculate function!!! PS: You should learn how C++ and functions or classes are working. With that knowledge it s very easy to read the code! So far Tobi |
|
June 12, 2013, 08:54 |
|
#6 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
The member functions are given at the end of my first post (the 2 last code quotes):
Code:
void Foam::inletOutletFvPatchField<Type>::updateCoeffs() ... Edit, it is the OF 2.2 source code |
|
June 12, 2013, 13:09 |
|
#8 |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
No problem, thx anyway for trying to help me !
I will take a look again this summer when I have some free time. |
|
June 12, 2013, 14:56 |
|
#9 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Hello Frederic,
All the "magic" happen in the parent class mixed<something>, which you will probably be able to find in the fvPatchField/basic folder, if I am not mistaken. You are indeed pointing to the important point in the code, because the valueFraction field is essentially a switch between the Dirichlet and Neumann conditions. Again, if I recall correctly, then if the valueFraction takes a value of 1, then the Dirichlet condition is used, where the Neumann is used for a value of 0. The Code:
pos(phi) I hope that this has clarified some things. Kind regards Niels |
|
June 13, 2013, 08:02 |
|
#10 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi Niels,
thanks for the replay. Here I found the Definition of pos(): Code:
Positive (boolean) pos(s) Last edited by Tobi; June 13, 2013 at 11:07. |
|
June 13, 2013, 13:45 |
|
#11 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Hi
I do know that some of the functions are outdated, but the following document (especially pp. 23-25) give a nice overview of the different functionalities and their return value: http://sourceforge.net/p/openfoam-ex...mmersGuide.pdf Kind regards NIels |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
The FOAM Documentation Project - SHUT-DOWN | holger_marschall | OpenFOAM | 242 | March 7, 2013 13:30 |
understanding kEpsilon model source code | jet | OpenFOAM Programming & Development | 5 | November 15, 2009 09:52 |
Understanding k-omega SST model source code | tmhonka | OpenFOAM Programming & Development | 1 | September 8, 2009 08:33 |
Design Integration with CFD? | John C. Chien | Main CFD Forum | 19 | May 17, 2001 16:56 |
What is the Better Way to Do CFD? | John C. Chien | Main CFD Forum | 54 | April 23, 2001 09:10 |