CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   fvOptions: how does it work or how to use the "fvOptions" ? (https://www.cfd-online.com/Forums/openfoam-programming-development/161722-fvoptions-how-does-work-how-use-fvoptions.html)

dsqx October 27, 2015 05:39

fvOptions: how does it work or how to use the "fvOptions" ?
 
:confused:i saw the "fvOptions(U)" in simpleFoam/UEqn.H. i know the "fvOptions" is about the source term but how does it work or how to use the "fvOptions" ?

regards:)

alexeym October 27, 2015 08:54

Hi,

1. This is how it works (since your question is about fvOptions(U), I show only this functionality):

fvOptions is an object of Foam::fv::optionList class. It has operator ():

Code:

            //- Return source for equation
            template<class Type>
            tmp<fvMatrix<Type> > operator()
            (
                GeometricField<Type, fvPatchField, volMesh>& fld
            );

which in turn is implemented like this:

Code:

template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
    GeometricField<Type, fvPatchField, volMesh>& fld
)
{
    return this->operator()(fld, fld.name());
}

template<class Type>
Foam::tmp<Foam::fvMatrix<Type> > Foam::fv::optionList::operator()
(
    GeometricField<Type, fvPatchField, volMesh>& fld,
    const word& fieldName
)
{
    checkApplied();

    const dimensionSet ds = fld.dimensions()/dimTime*dimVolume;

    tmp<fvMatrix<Type> > tmtx(new fvMatrix<Type>(fld, ds));

    fvMatrix<Type>& mtx = tmtx();


    forAll(*this, i)
    {
        option& source = this->operator[](i);
   
        label fieldI = source.applyToField(fieldName);

        if (fieldI != -1)
        {
            source.setApplied(fieldI);

            if (source.isActive())
            {
                if (debug)
                {
                    Info<< "Applying source " << source.name() << " to field "
                        << fieldName << endl;
                }

                source.addSup(mtx, fieldI);
            }
        }
    }

    return tmtx;
}

addSup implementation depends on fvOption.

2. How to use.

Code:

$ cd $FOAM_TUTORIALS
$ find . -name 'fvOptions'
...
./incompressible/simpleFoam/mixerVessel2D/system/fvOptions
./incompressible/simpleFoam/turbineSiting/system/fvOptions

you can find available sources in $FOAM_SRC/fvOptions/sources.


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