CodedSource< Type > Class Template Reference

Constructs on-the-fly fvOption source. More...

Inheritance diagram for CodedSource< Type >:
Collaboration diagram for CodedSource< Type >:

Public Member Functions

 TypeName ("coded")
 Runtime type information. More...
 
 CodedSource (const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
 Construct from components. More...
 
optionredirectFvOption () const
 Dynamically compiled fvOption. More...
 
virtual void correct (GeometricField< Type, fvPatchField, volMesh > &)
 Correct field. More...
 
virtual void addSup (fvMatrix< Type > &eqn, const label fieldi)
 Explicit and implicit matrix contributions. More...
 
virtual void addSup (const volScalarField &rho, fvMatrix< Type > &eqn, const label fieldi)
 Explicit and implicit matrix contributions. More...
 
virtual void constrain (fvMatrix< Type > &eqn, const label fieldi)
 Set value. More...
 
virtual bool read (const dictionary &dict)
 Read source dictionary. More...
 
- Public Member Functions inherited from cellSetOption
 TypeName ("cellSetOption")
 Runtime type information. More...
 
 cellSetOption (const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
 Construct from components. More...
 
virtual ~cellSetOption ()
 Destructor. More...
 
scalar timeStart () const
 Return const access to the time start. More...
 
scalar duration () const
 Return const access to the duration. More...
 
bool inTimeLimits (const scalar time) const
 Return true if within time limits. More...
 
const selectionModeTypeselectionMode () const
 Return const access to the cell selection mode. More...
 
const wordcellSetName () const
 Return const access to the name of cell set for "cellSet". More...
 
scalar V () const
 Return const access to the total cell volume. More...
 
const labelListcells () const
 Return const access to the cell set. More...
 
scalar & timeStart ()
 Return access to the time start. More...
 
scalar & duration ()
 Return access to the duration. More...
 
virtual bool isActive ()
 Is the source active? More...
 
- Public Member Functions inherited from option
 TypeName ("option")
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, option, dictionary,(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh),(name, modelType, dict, mesh))
 
 option (const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
 Construct from components. More...
 
autoPtr< optionclone () const
 Return clone. More...
 
virtual ~option ()
 Destructor. More...
 
const wordname () const
 Return const access to the source name. More...
 
const fvMeshmesh () const
 Return const access to the mesh database. More...
 
const dictionarycoeffs () const
 Return dictionary. More...
 
bool active () const
 Return const access to the source active flag. More...
 
void setApplied (const label fieldi)
 Set the applied flag to true for field index fieldi. More...
 
Switchactive ()
 Return access to the source active flag. More...
 
virtual label applyToField (const word &fieldName) const
 Return index of field name if found in fieldNames list. More...
 
virtual void checkApplied () const
 Check that the source has been applied. More...
 
virtual void addSup (fvMatrix< scalar > &eqn, const label fieldi)
 
virtual void addSup (fvMatrix< vector > &eqn, const label fieldi)
 
virtual void addSup (fvMatrix< symmTensor > &eqn, const label fieldi)
 
virtual void addSup (fvMatrix< sphericalTensor > &eqn, const label fieldi)
 
virtual void addSup (fvMatrix< tensor > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &rho, fvMatrix< scalar > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &rho, fvMatrix< vector > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &rho, fvMatrix< symmTensor > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &rho, fvMatrix< sphericalTensor > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &rho, fvMatrix< tensor > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &alpha, const volScalarField &rho, fvMatrix< scalar > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &alpha, const volScalarField &rho, fvMatrix< vector > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &alpha, const volScalarField &rho, fvMatrix< symmTensor > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &alpha, const volScalarField &rho, fvMatrix< sphericalTensor > &eqn, const label fieldi)
 
virtual void addSup (const volScalarField &alpha, const volScalarField &rho, fvMatrix< tensor > &eqn, const label fieldi)
 
virtual void constrain (fvMatrix< scalar > &eqn, const label fieldi)
 
virtual void constrain (fvMatrix< vector > &eqn, const label fieldi)
 
virtual void constrain (fvMatrix< sphericalTensor > &eqn, const label fieldi)
 
virtual void constrain (fvMatrix< symmTensor > &eqn, const label fieldi)
 
virtual void constrain (fvMatrix< tensor > &eqn, const label fieldi)
 
virtual void correct (volScalarField &field)
 
virtual void correct (volVectorField &field)
 
virtual void correct (volSphericalTensorField &field)
 
virtual void correct (volSymmTensorField &field)
 
virtual void correct (volTensorField &field)
 
virtual void writeHeader (Ostream &) const
 Write the source header information. More...
 
virtual void writeFooter (Ostream &) const
 Write the source footer information. More...
 
virtual void writeData (Ostream &) const
 Write the source properties. More...
 
- Public Member Functions inherited from codedBase
 ClassName ("codedBase")
 Runtime type information. More...
 
 codedBase ()
 Construct null. More...
 
 codedBase (const codedBase &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~codedBase ()
 Destructor. More...
 
void operator= (const codedBase &)=delete
 Disallow default bitwise assignment. More...
 

Protected Member Functions

virtual dlLibraryTablelibs () const
 Get the loaded dynamic libraries. More...
 
virtual void prepare (dynamicCode &, const dynamicCodeContext &) const
 Adapt the context for the current object. More...
 
virtual string description () const
 Return a description (type + name) for the output. More...
 
virtual void clearRedirect () const
 Clear any redirected objects. More...
 
virtual const dictionarycodeDict () const
 Get the dictionary to initialize the codeContext. More...
 
virtual const wordListcodeKeys () const
 Get the keywords associated with source code. More...
 
- Protected Member Functions inherited from cellSetOption
void setSelection (const dictionary &dict)
 Set the cellSet or points selection. More...
 
void setCellSet ()
 Set the cell set based on the user input selection mode. More...
 
- Protected Member Functions inherited from codedBase
void updateLibrary (const word &name) const
 Update library as required. More...
 

Protected Attributes

word name_
 The name. More...
 
autoPtr< optionredirectFvOptionPtr_
 Underlying functionObject. More...
 
- Protected Attributes inherited from cellSetOption
scalar timeStart_
 Time start. More...
 
scalar duration_
 Duration. More...
 
selectionModeType selectionMode_
 Cell selection mode. More...
 
word cellSetName_
 Name of cell set for "cellSet" and "cellZone" selectionMode. More...
 
List< pointpoints_
 List of points for "points" selectionMode. More...
 
labelList cells_
 Set of cells to apply source to. More...
 
scalar V_
 Sum of cell volumes. More...
 
- Protected Attributes inherited from option
const word name_
 Source name. More...
 
const word modelType_
 Model type. More...
 
const fvMeshmesh_
 Reference to the mesh database. More...
 
dictionary dict_
 Top level source dictionary. More...
 
dictionary coeffs_
 Dictionary containing source coefficients. More...
 
Switch active_
 Source active flag. More...
 
wordList fieldNames_
 Field names to apply source to - populated by derived models. More...
 
List< bool > applied_
 Applied flag list - corresponds to each fieldNames_ entry. More...
 

Static Protected Attributes

static const wordList codeKeys_
 The keywords associated with source code. More...
 

Additional Inherited Members

- Public Types inherited from cellSetOption
enum  selectionModeType { smPoints, smCellSet, smCellZone, smAll }
 Enumeration for selection mode types. More...
 
- Static Public Member Functions inherited from option
static autoPtr< optionNew (const word &name, const dictionary &dict, const fvMesh &mesh)
 Return a reference to the selected fvOption model. More...
 
- Static Public Attributes inherited from cellSetOption
static const NamedEnum< selectionModeType, 4 > selectionModeTypeNames_
 Word list of selection mode type names. More...
 

Detailed Description

template<class Type>
class Foam::fv::CodedSource< Type >

Constructs on-the-fly fvOption source.

The hook functions take the following arguments:

codeCorrect ( GeometricField<Type, fvPatchField, volMesh>& field )

codeAddSup ( fvMatrix<Type}>& eqn, const label fieldi )

constrain ( fvMatrix<Type}>& eqn, const label fieldi )

where : field is the field in fieldNames eqn is the fvMatrix

Usage
Example usage in controlDict:
energySource
{
    type            scalarCodedSource;

    active          yes;

    name    sourceTime;

    scalarCodedSourceCoeffs
    {
        selectionMode   all;

        fields          (h);

        codeInclude
        #{

        #};

        codeCorrect
        #{
            Pout<< "**codeCorrect**" << endl;
        #};

        codeAddSup
        #{
            const Time& time = mesh().time();
            const scalarField& V = mesh_.V();
            scalarField& heSource = eqn.source();
            heSource -= 0.1*sqr(time.value())*V;
        #};

        codeSetValue
        #{
            Pout<< "**codeSetValue**" << endl;
        #};
    }

    sourceTimeCoeffs
    {
        $scalarCodedSourceCoeffs;
    }
}
Source files

Definition at line 124 of file CodedSource.H.

Constructor & Destructor Documentation

◆ CodedSource()

CodedSource ( const word name,
const word modelType,
const dictionary dict,
const fvMesh mesh 
)

Construct from components.

Definition at line 124 of file CodedSource.C.

References Foam::blockMeshTools::read().

Referenced by CodedSource< Type >::codeKeys().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ libs()

Foam::dlLibraryTable & libs ( ) const
protectedvirtual

Get the loaded dynamic libraries.

Implements codedBase.

Definition at line 86 of file CodedSource.C.

◆ prepare()

void prepare ( dynamicCode dynCode,
const dynamicCodeContext context 
) const
protectedvirtual

Adapt the context for the current object.

Implements codedBase.

Definition at line 43 of file CodedSource.C.

References dynamicCode::addCompileFile(), dynamicCode::addCopyFile(), dynamicCodeContext::libs(), dynamicCodeContext::options(), dynamicCode::setFilterVariable(), and dynamicCode::setMakeOptions().

Here is the call graph for this function:

◆ description()

Foam::string description ( ) const
protectedvirtual

Return a description (type + name) for the output.

Implements codedBase.

Definition at line 93 of file CodedSource.C.

◆ clearRedirect()

void clearRedirect ( ) const
protectedvirtual

Clear any redirected objects.

Implements codedBase.

Definition at line 100 of file CodedSource.C.

◆ codeDict()

const Foam::dictionary & codeDict ( ) const
protectedvirtual

Get the dictionary to initialize the codeContext.

Implements codedBase.

Definition at line 107 of file CodedSource.C.

◆ codeKeys()

const Foam::wordList & codeKeys ( ) const
protectedvirtual

Get the keywords associated with source code.

Implements codedBase.

Definition at line 114 of file CodedSource.C.

References CodedSource< Type >::CodedSource().

Here is the call graph for this function:

◆ TypeName()

TypeName ( "coded"  )

Runtime type information.

◆ redirectFvOption()

Foam::fv::option & redirectFvOption ( ) const

Dynamically compiled fvOption.

Definition at line 140 of file CodedSource.C.

References CodedSource< Type >::correct(), Foam::New(), and dictionary::set().

Here is the call graph for this function:

◆ correct()

void correct ( GeometricField< Type, fvPatchField, volMesh > &  field)
virtual

Correct field.

Definition at line 160 of file CodedSource.C.

References CodedSource< Type >::addSup(), Foam::endl(), and Foam::Info.

Referenced by CodedSource< Type >::redirectFvOption().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addSup() [1/2]

void addSup ( fvMatrix< Type > &  eqn,
const label  fieldi 
)
virtual

Explicit and implicit matrix contributions.

Definition at line 177 of file CodedSource.C.

References Foam::endl(), and Foam::Info.

Referenced by CodedSource< Type >::correct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addSup() [2/2]

void addSup ( const volScalarField rho,
fvMatrix< Type > &  eqn,
const label  fieldi 
)
virtual

Explicit and implicit matrix contributions.

to compressible equation

Definition at line 195 of file CodedSource.C.

References CodedSource< Type >::constrain(), Foam::endl(), and Foam::Info.

Here is the call graph for this function:

◆ constrain()

void constrain ( fvMatrix< Type > &  eqn,
const label  fieldi 
)
virtual

Set value.

Definition at line 214 of file CodedSource.C.

References Foam::endl(), and Foam::Info.

Referenced by CodedSource< Type >::addSup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

bool read ( const dictionary dict)
virtual

Read source dictionary.

Reimplemented from cellSetOption.

Definition at line 32 of file CodedSourceIO.C.

References dictionary::lookup(), dictionary::lookupOrDefault(), and Foam::blockMeshTools::read().

Here is the call graph for this function:

Member Data Documentation

◆ codeKeys_

const Foam::wordList codeKeys_
staticprotected
Initial value:
=
{"codeAddSup", "codeCorrect", "codeInclude", "codeSetValue", "localCode"}

The keywords associated with source code.

Definition at line 134 of file CodedSource.H.

◆ name_

word name_
protected

The name.

Definition at line 140 of file CodedSource.H.

◆ redirectFvOptionPtr_

autoPtr<option> redirectFvOptionPtr_
mutableprotected

Underlying functionObject.

Definition at line 143 of file CodedSource.H.


The documentation for this class was generated from the following files: