76Foam::tmp<Foam::volScalarField>
77Foam::functionObjects::electricPotential::sigma()
const
79 const IOobject sigmaIO
86 tmp<volScalarField> tsigma = phases_[0]*sigmas_[0];
88 for (label i = 1; i < phases_.size(); ++i)
90 tsigma.ref() += phases_[i]*sigmas_[i];
111Foam::tmp<Foam::volScalarField>
112Foam::functionObjects::electricPotential::epsilonm()
const
121 const IOobject epsilonrIO
128 tmp<volScalarField> tepsilonr = phases_[0]*epsilonrs_[0];
130 for (label i = 1; i < phases_.size(); ++i)
132 tepsilonr.ref() += phases_[i]*epsilonrs_[i];
155Foam::functionObjects::electricPotential::electricPotential
163 phasesDict_(
dict.subOrEmptyDict(
"phases")),
172 dict.getCheckOrDefault<scalar>
186 dict.getCheckOrDefault<scalar>
213 writeDerivedFields_(false),
214 electricField_(false)
259 dict.readIfPresent(
"sigma", sigma_);
260 dict.readIfPresent(
"epsilonr", epsilonr_);
261 dict.readIfPresent(
"nCorr", nCorr_);
262 dict.readIfPresent(
"tolerance", tol_);
263 dict.readIfPresent(
"writeDerivedFields", writeDerivedFields_);
264 dict.readIfPresent(
"electricField", electricField_);
267 if (!phasesDict_.empty())
269 phaseNames_.setSize(phasesDict_.size());
270 phases_.setSize(phasesDict_.size());
271 sigmas_.setSize(phasesDict_.size());
273 if (writeDerivedFields_)
275 epsilonrs_.setSize(phasesDict_.size());
279 for (
const entry& dEntry : phasesDict_)
281 const word&
key = dEntry.keyword();
283 if (!dEntry.isDict())
286 <<
"Entry " <<
key <<
" is not a dictionary" <<
nl
300 subDict.getCheck<scalar>
308 if (writeDerivedFields_)
316 subDict.getCheck<scalar>
340 fvOptions_.reset(*dictptr);
352 bool converged =
false;
356 const auto&
sigma = tsigma();
360 for (
int i = 1; i <= nCorr_; ++i)
369 fvOptions_.constrain(eVEqn);
372 converged = (eVEqn.
solve().initialResidual() < tol_);
373 if (converged)
break;
378 auto& E = lookupObjectRef<volVectorField>(Ename_);
385 << eV.
name() <<
" is converged." <<
nl
386 <<
tab <<
"initial-residual tolerance: " << tol_ <<
nl
387 <<
tab <<
"outer iteration: " << iter <<
nl;
406 const auto& E = lookupObject<volVectorField>(Ename_);
413 if (writeDerivedFields_)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
static tmp< GeometricField< vector, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< vector >::calculatedType())
void correctBoundaryConditions()
Correct boundary field.
@ NO_REGISTER
Do not request registration (bool: false).
@ REGISTER
Request registration (bool: true).
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
static MinMax< scalar > ge(const scalar &minVal)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getCheck(const word &keyword, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T with additional checking FatalIOError if not found, or if the number of tokens is...
A keyword and a list of tokens is an 'entry'.
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.
word scopedName(const word &name) const
Return a scoped (prefixed) name.
Computes the steady-state equation of charge conservation to obtain the electric potential by strictl...
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function-object results.
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.
const ObjectType & lookupObject(const word &fieldName) const
Lookup and return object (eg, a field) from the (sub) objectRegistry.
ObjectType * getObjectPtr(const word &fieldName) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
ObjectType & lookupObjectRef(const word &fieldName) const
Lookup and return object (eg, a field) from the (sub) objectRegistry.
void relax(const scalar alpha)
Relax matrix (for steady-state solution).
SolverPerformance< Type > solve(const dictionary &)
Solve returning the solution statistics.
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
const Time & time() const
Return the top-level database.
static const word & calculatedType() noexcept
The type name for calculated patch fields.
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
bool store()
Register object with its registry and transfer ownership to the registry.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
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.
const dimensionedScalar epsilon0
Electric constant: default SI units: [F/m].
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
GeometricField< vector, fvPatchField, volMesh > volVectorField
const dimensionSet dimless
Dimensionless.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensionedScalar pow3(const dimensionedScalar &ds)
fvMatrix< scalar > fvScalarMatrix
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
const dimensionSet dimCurrent(0, 0, 0, 0, 0, 1, 0)
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.
dimensionedScalar pow4(const dimensionedScalar &ds)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
constexpr char nl
The newline '\n' character (0x0a).
constexpr char tab
The tab '\t' character(0x09).
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
#define forAll(list, i)
Loop across all elements in list.