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

Understanding code of inletOutlet / outletInlet

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   May 4, 2013, 09:54
Default Understanding code of inletOutlet / outletInlet
  #1
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 121
Rep Power: 4
fredo490 is on a distinguished road
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 ? ???
}
And for the outletInlet
(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 ? ???
}
My problem is that the same code should do two opposite things:
inletOutlet:
Code:
if (dict.found("value")) // ??? if the flux go outside the domain ???
outletInlet:
Code:
if (dict.found("value")) // ??? if the flux go inside the domain ???
The only difference I have found is in the member function.
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();
}
outletInlet
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();
}
Does anyone know how this code works ? I am a bit lost
fredo490 is offline   Reply With Quote

Old   May 6, 2013, 12:54
Default
  #2
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 121
Rep Power: 4
fredo490 is on a distinguished road
a small up
fredo490 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The FOAM Documentation Project - SHUT-DOWN holger_marschall OpenFOAM 242 March 7, 2013 12:30
understanding kEpsilon model source code jet OpenFOAM Programming & Development 5 November 15, 2009 08:52
Understanding k-omega SST model source code tmhonka OpenFOAM Programming & Development 1 September 8, 2009 07:33
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 15:56
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 08:10


All times are GMT -4. The time now is 22:45.