55void Foam::functionObjects::surfaceCourantNumber::writeFileHeader(
Ostream&
os)
80 resultName_(
"surfaceCo"),
98 dict.readIfPresent(
"result", resultName_);
99 dict.readIfPresent(
"phis", phisName_);
100 dict.readIfPresent(
"rho", rhoName_);
108 <<
"No finite-area object registry is available."
113 if (!
dict.readIfPresent(
"area", areaName))
115 wordList available = faRegistry->sortedNames<faMesh>();
116 if (!available.empty())
118 areaName = available.front();
122 faMeshPtr_ = faRegistry->cfindObject<faMesh>(areaName);
127 <<
"No finite-area mesh available."
137 const auto* phiPtr = faMeshPtr_->cfindObject<
edgeScalarField>(phisName_);
142 <<
"No edge flux field is available. "
143 <<
"Name of provided edge flux field (phi): " << phisName_
149 const auto&
phi = *phiPtr;
151 tmp<areaScalarField::Internal> tCo =
153 (0.5*faMeshPtr_->time().deltaT())
164 auto* resultPtr = faMeshPtr_->getObjectPtr<
areaScalarField>(resultName_);
173 faMeshPtr_->time().timeName(),
183 auto& result = *resultPtr;
186 result.correctBoundaryConditions();
190 const scalar mean =
gAverage(result.primitiveField());
192 Log <<
"Surface Courant number: "
194 <<
" max: " <<
limits.max()
199 if (!writtenHeader_) writeFileHeader(file());
201 writeCurrentTime(file());
215 const auto* result = faMeshPtr_->cfindObject<
areaScalarField>(resultName_);
222 Log <<
type() <<
" " <<
name() <<
" write: " << result->name() <<
endl;
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Internal & internalFieldRef(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
T & front()
Access first element of the list, position [0].
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
static const objectRegistry * registry(const polyMesh &pMesh)
Find the singleton parent registry (on the polyMesh) that contains all objects related to finite-area...
static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
Abstract base-class for Time/database function objects.
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const fvMesh & mesh_
Reference to the fvMesh.
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Computes the surface Courant number field at finite-area face centres.
surfaceCourantNumber(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
virtual bool execute()
Calculate the Courant number field and return true if successful.
virtual bool write()
Write the result field.
virtual bool read(const dictionary &)
Read the surfaceCourantNumber data.
Base class for writing single files from the function objects.
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
virtual bool read(const dictionary &dict)
Read.
bool writtenHeader_
Flag to identify whether the header has been written.
virtual OFstream & file()
Return access to the file (if only 1).
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
virtual void writeCurrentTime(Ostream &os) const
Write the current time to stream.
virtual bool writeToFile() const
Flag to allow writing to file.
bool store()
Register object with its registry and transfer ownership to the registry.
A class for managing temporary objects.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
Edge integrate edgeField creating a areaField. Edge sum a edgeField creating a areaField.
#define WarningInFunction
Report a warning using Foam::Warning.
tmp< GeometricField< Type, faPatchField, areaMesh > > edgeSum(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
List< word > wordList
List of word.
const dimensionSet dimless
Dimensionless.
bool read(const char *buf, int32_t &val)
Same as readInt32.
MinMax< scalar > scalarMinMax
A scalar min/max range.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
errorManip< error > abort(error &err)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0).
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimDensity