Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
cellSource Class Reference

This function object provides a 'cell source' variant of the fieldValues function object. Given a list of user-specified fields and a selection of mesh cells, a number of operations can be performed, such as sums, averages and integrations. More...

Inheritance diagram for cellSource:
Inheritance graph
[legend]
Collaboration diagram for cellSource:
Collaboration graph
[legend]

Public Types

enum  sourceType { stCellZone, stAll }
 Source type enumeration. More...
 
enum  operationType {
  opNone, opSum, opSumMag, opAverage,
  opWeightedAverage, opVolAverage, opWeightedVolAverage, opVolIntegrate,
  opMin, opMax, opCoV
}
 Operation type enumeration. More...
 

Public Member Functions

 TypeName ("cellSource")
 Run-time type information. More...
 
 cellSource (const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false)
 Construct from components. More...
 
virtual ~cellSource ()
 Destructor. More...
 
const sourceTypesource () const
 Return the source type. More...
 
const labelListcellId () const
 Return the local list of cell IDs. More...
 
virtual void read (const dictionary &)
 Read from dictionary. More...
 
virtual void write ()
 Calculate and write. More...
 
template<class Type >
bool writeValues (const word &fieldName)
 Templated helper function to output field values. More...
 
template<class Type >
tmp< Field< Type > > filterField (const Field< Type > &field) const
 Filter a field according to cellIds. More...
 
template<class Type >
Foam::tmp< Foam::Field< Type > > setFieldValues (const word &fieldName, const bool mustGet) const
 
template<class Type >
Foam::tmp< Foam::Field< Type > > filterField (const Field< Type > &field) const
 
- Public Member Functions inherited from fieldValue
 TypeName ("fieldValue")
 Run-time type information. More...
 
 declareRunTimeSelectionTable (autoPtr, fieldValue, dictionary,( const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles ),(name, obr, dict, loadFromFiles))
 
 fieldValue (const word &name, const objectRegistry &obr, const dictionary &dict, const word &valueType, const bool loadFromFiles=false)
 Construct from components. More...
 
virtual ~fieldValue ()
 Destructor. More...
 
const wordname () const
 Return the name of the geometric source. More...
 
const objectRegistryobr () const
 Return the reference to the object registry. More...
 
const dictionarydict () const
 Return the reference to the construction dictionary. More...
 
bool active () const
 Return the active flag. More...
 
const Switchlog () const
 Return the switch to send output to Info as well as to file. More...
 
const wordsourceName () const
 Return the source name. More...
 
const wordListfields () const
 Return the list of field names. More...
 
const SwitchvalueOutput () const
 Return the output field values flag. More...
 
const fvMeshmesh () const
 Helper function to return the reference to the mesh. More...
 
const dictionaryresultDict () const
 Return access to the latest set of results. More...
 
virtual void execute ()
 Execute. More...
 
virtual void end ()
 Execute the at the final time-loop, currently does nothing. More...
 
virtual void timeSet ()
 Called when time was set at the end of the Time::operator++. More...
 
virtual void updateMesh (const mapPolyMesh &)
 Update mesh. More...
 
virtual void movePoints (const polyMesh &)
 Move points. More...
 
template<class Type >
void combineFields (Field< Type > &field)
 Combine fields from all processor domains into single field. More...
 
template<class Type >
void combineFields (tmp< Field< Type > > &)
 Combine fields from all processor domains into single field. More...
 
- Public Member Functions inherited from functionObjectFile
 functionObjectFile (const objectRegistry &obr, const word &prefix)
 Construct null. More...
 
 functionObjectFile (const objectRegistry &obr, const word &prefix, const word &name)
 Construct from components. More...
 
 functionObjectFile (const objectRegistry &obr, const word &prefix, const wordList &names)
 Construct from components. More...
 
virtual ~functionObjectFile ()
 Destructor. More...
 
const wordListnames () const
 Return const access to the names. More...
 
OFstreamfile ()
 Return access to the file (if only 1) More...
 
PtrList< OFstream > & files ()
 Return access to the files. More...
 
OFstreamfile (const label i)
 Return file 'i'. More...
 
void writeCommented (Ostream &os, const string &str) const
 Write a commented string to stream. More...
 
void writeTabbed (Ostream &os, const string &str) const
 Write a tabbed string to stream. More...
 
void writeHeader (Ostream &os, const string &str) const
 Write a commented header to stream. More...
 
template<class Type >
void writeHeaderValue (Ostream &os, const string &property, const Type &value) const
 Write a (commented) header property and value pair. More...
 
label charWidth () const
 Return width of character stream output. More...
 

Static Public Attributes

static const NamedEnum< sourceType, 2 > sourceTypeNames_
 Source type names. More...
 
static const NamedEnum< operationType, 11 > operationTypeNames_
 Operation type names. More...
 
- Static Public Attributes inherited from functionObjectFile
static const word outputPrefix = "postProcessing"
 Directory prefix. More...
 
static label addChars = 7
 Additional characters for writing. More...
 

Protected Member Functions

void initialise (const dictionary &dict)
 Initialise, e.g. cell addressing. More...
 
template<class Type >
bool validField (const word &fieldName) const
 Return true if the field name is valid. More...
 
template<class Type >
tmp< Field< Type > > setFieldValues (const word &fieldName, const bool mustGet=false) const
 Insert field values into values list. More...
 
template<class Type >
Type processValues (const Field< Type > &values, const scalarField &V, const scalarField &weightField) const
 Apply the 'operation' to the values. More...
 
virtual void writeFileHeader (const label i)
 Output file header information. More...
 
- Protected Member Functions inherited from functionObjectFile
virtual void initStream (Ostream &os) const
 Initialise the output stream for writing. More...
 
virtual fileName baseFileDir () const
 Return the base directory for output. More...
 
virtual fileName baseTimeDir () const
 Return the base directory for the current time value. More...
 
virtual void createFiles ()
 Create the output file. More...
 
virtual void resetNames (const wordList &names)
 Reset the list of names from a wordList. More...
 
virtual void resetName (const word &name)
 Reset the list of names to a single name entry. More...
 
virtual Omanip< int > valueWidth (const label offset=0) const
 Return the value width when writing to stream with optional offset. More...
 
 functionObjectFile (const functionObjectFile &)
 Disallow default bitwise copy construct. More...
 
void operator= (const functionObjectFile &)
 Disallow default bitwise assignment. More...
 

Protected Attributes

sourceType source_
 Source type. More...
 
operationType operation_
 Operation to apply to values. More...
 
label nCells_
 Global number of cells. More...
 
labelList cellId_
 Local list of cell IDs. More...
 
word weightFieldName_
 Weight field name - only used for opWeightedAverage mode. More...
 
scalar volume_
 Volume of the cellSource. More...
 
bool writeVolume_
 Optionally write the volume of the cellSource. More...
 
- Protected Attributes inherited from fieldValue
word name_
 Name of this fieldValue object. More...
 
const objectRegistryobr_
 Database this class is registered to. More...
 
dictionary dict_
 Construction dictionary. More...
 
bool active_
 Active flag. More...
 
Switch log_
 Switch to send output to Info as well as to file. More...
 
word sourceName_
 Name of source object. More...
 
wordList fields_
 List of field names to operate on. More...
 
Switch valueOutput_
 Output field values flag. More...
 
dictionary resultDict_
 Results dictionary for external access of results. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from fieldValue
static autoPtr< fieldValueNew (const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false, const bool output=true)
 Return a reference to the selected fieldValue. More...
 

Detailed Description

This function object provides a 'cell source' variant of the fieldValues function object. Given a list of user-specified fields and a selection of mesh cells, a number of operations can be performed, such as sums, averages and integrations.

Example of function object specification:

cellSource1
{
    type            cellSource;
    functionObjectLibs ("libfieldFunctionObjects.so");
    ...
    log             true;
    valueOutput     true;
    source          cellZone;
    sourceName      c0;
    operation       volAverage;
    weightField     alpha1;
    fields
    (
        p
        U
    );
}


Function object usage

Property Description Required Default value
type Type name: cellSource yes
log Write data to standard output no no
valueOutput Write the raw output values yes
writeVolume Write the volume of the cellSource no
source cell source: see below yes
sourceName name of cell source if required no
operation operation to perform yes
weightField name of field to apply weighting no
fields list of fields to operate on yes


Where source is defined by

cellZone : requires a 'sourceName' entry to specify the cellZone
all : all cells


The operation is one of:

none : no operation
sum : sum
sumMag : sum of component magnitudes
average : ensemble average
weightedAverage : weighted average
volAverage : volume weighted average
weightedVolAverage : weighted volume average
volIntegrate : volume integral
min : minimum
max : maximum
CoV : coefficient of variation: standard deviation/mean
See also
Foam::fieldValues Foam::functionObject Foam::OutputFilterFunctionObject
Source files

Definition at line 225 of file cellSource.H.

Member Enumeration Documentation

enum sourceType

Source type enumeration.

Enumerator
stCellZone 
stAll 

Definition at line 235 of file cellSource.H.

Operation type enumeration.

Enumerator
opNone 
opSum 
opSumMag 
opAverage 
opWeightedAverage 
opVolAverage 
opWeightedVolAverage 
opVolIntegrate 
opMin 
opMax 
opCoV 

Definition at line 246 of file cellSource.H.

Constructor & Destructor Documentation

cellSource ( const word name,
const objectRegistry obr,
const dictionary dict,
const bool  loadFromFiles = false 
)

Construct from components.

Definition at line 192 of file cellSource.C.

References Foam::read().

Referenced by cellSource::writeFileHeader().

Here is the call graph for this function:

Here is the caller graph for this function:

~cellSource ( )
virtual

Destructor.

Definition at line 213 of file cellSource.C.

Member Function Documentation

void initialise ( const dictionary dict)
protected

Initialise, e.g. cell addressing.

Definition at line 129 of file cellSource.C.

References Foam::endl(), Foam::Info, Foam::nl, dictionary::readIfPresent(), Foam::type(), and WarningIn.

Here is the call graph for this function:

bool validField ( const word fieldName) const
protected

Return true if the field name is valid.

Definition at line 32 of file cellSourceTemplates.C.

References objectRegistry::foundObject(), fieldValue::obr_, and cellSource::setFieldValues().

Here is the call graph for this function:

tmp<Field<Type> > setFieldValues ( const word fieldName,
const bool  mustGet = false 
) const
protected

Insert field values into values list.

Referenced by cellSource::validField().

Here is the caller graph for this function:

Type processValues ( const Field< Type > &  values,
const scalarField V,
const scalarField weightField 
) const
protected
void writeFileHeader ( const label  i)
protectedvirtual

Output file header information.

Reimplemented from functionObjectFile.

Definition at line 163 of file cellSource.C.

References cellSource::cellSource(), Foam::endl(), forAll, and Foam::tab.

Here is the call graph for this function:

TypeName ( "cellSource"  )

Run-time type information.

const Foam::fieldValues::cellSource::sourceType & source ( ) const
inline

Return the source type.

Definition at line 31 of file cellSourceI.H.

References cellSource::source_.

const Foam::labelList & cellId ( ) const
inline

Return the local list of cell IDs.

Definition at line 38 of file cellSourceI.H.

References cellSource::cellId_.

void read ( const dictionary dict)
virtual

Read from dictionary.

Reimplemented from fieldValue.

Definition at line 219 of file cellSource.C.

References fieldValue::read().

Here is the call graph for this function:

void write ( )
virtual

Calculate and write.

Reimplemented from fieldValue.

Definition at line 231 of file cellSource.C.

References Foam::endl(), forAll, Foam::Info, UPstream::master(), Foam::tab, WarningIn, and fieldValue::write().

Here is the call graph for this function:

bool writeValues ( const word fieldName)
tmp<Field<Type> > filterField ( const Field< Type > &  field) const

Filter a field according to cellIds.

Referenced by cellSource::setFieldValues(), and cellSource::writeValues().

Here is the caller graph for this function:

Foam::tmp<Foam::Field<Type> > setFieldValues ( const word fieldName,
const bool  mustGet 
) const
Foam::tmp<Foam::Field<Type> > filterField ( const Field< Type > &  field) const

Definition at line 222 of file cellSourceTemplates.C.

References cellSource::cellId_.

Member Data Documentation

const Foam::NamedEnum< Foam::fieldValues::cellSource::sourceType, 2 > sourceTypeNames_
static

Source type names.

Definition at line 242 of file cellSource.H.

Referenced by cellSource::writeValues().

const Foam::NamedEnum< Foam::fieldValues::cellSource::operationType, 11 > operationTypeNames_
static

Operation type names.

Definition at line 262 of file cellSource.H.

Referenced by cellSource::writeValues().

sourceType source_
protected

Source type.

Definition at line 284 of file cellSource.H.

Referenced by cellSource::source(), and cellSource::writeValues().

operationType operation_
protected

Operation to apply to values.

Definition at line 287 of file cellSource.H.

Referenced by cellSource::processValues(), and cellSource::writeValues().

label nCells_
protected

Global number of cells.

Definition at line 290 of file cellSource.H.

labelList cellId_
protected

Local list of cell IDs.

Definition at line 293 of file cellSource.H.

Referenced by cellSource::cellId(), and cellSource::filterField().

word weightFieldName_
protected

Weight field name - only used for opWeightedAverage mode.

Definition at line 296 of file cellSource.H.

Referenced by cellSource::writeValues().

scalar volume_
protected

Volume of the cellSource.

Definition at line 299 of file cellSource.H.

bool writeVolume_
protected

Optionally write the volume of the cellSource.

Definition at line 302 of file cellSource.H.


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