33 bool Foam::genericPatchFieldBase::checkFieldSize
35 const label fieldSize,
36 const label patchSize,
37 const word& patchName,
42 const bool ok = (fieldSize == patchSize);
47 <<
"\n size of field " <<
key 48 <<
" (" << fieldSize <<
") != patch size (" << patchSize <<
')' 49 <<
"\n on patch " << patchName
50 <<
" of field " <<
io.name() <<
" in file " 51 <<
io.objectPath() <<
nl 77 actualTypeName_(rhs.actualTypeName_),
86 const word& patchName,
91 <<
" (actual type " << actualTypeName_ <<
')' 92 <<
"\n on patch " << patchName
95 <<
" You are probably trying to solve for a field with a " 96 "generic boundary condition." <<
nl;
102 const word& entryName,
103 const word& patchName,
109 <<
" Missing required '" << entryName <<
"' entry" 110 <<
" on patch " << patchName
112 <<
" (Actual type " << actualTypeName_ <<
')' <<
nl <<
nl 113 <<
" Please add the '" << entryName <<
"' entry to the" 114 " write function of the user-defined boundary-condition" <<
nl 121 const label patchSize,
122 const word& patchName,
124 const bool separateValue
127 for (
const entry& dEntry : dict_)
131 if (
key ==
"type" || (separateValue &&
key ==
"value"))
137 processEntry(dEntry, patchSize, patchName,
io);
146 const label patchSize,
147 const word& patchName,
151 if (!dEntry.isStream())
156 const keyType&
key = dEntry.keyword();
157 ITstream& is = dEntry.stream();
164 #undef FIELDSIZE_CHECK 165 #define FIELDSIZE_CHECK(fieldLen) \ 166 checkFieldSize(fieldLen, patchSize, patchName, key, io) 172 if (tok.isWord(
"nonuniform"))
183 else if (!tok.isCompound())
186 <<
"\n non-compound token following 'nonuniform'" 187 <<
"\n on patch " << patchName <<
" field " 188 <<
io.
name() <<
" in file " 195 tok.compoundToken().type()
196 == token::Compound<List<scalar>>::typeName
205 tok.transferCompoundToken(is)
214 scalarFields_.insert(
key, fPtr);
218 tok.compoundToken().type()
219 == token::Compound<List<vector>>::typeName
228 tok.transferCompoundToken(is)
236 vectorFields_.insert(
key, fPtr);
240 tok.compoundToken().type()
241 == token::Compound<List<sphericalTensor>>::typeName
248 dynamicCast<token::Compound<List<sphericalTensor>>>
250 tok.transferCompoundToken(is)
259 sphTensorFields_.insert(
key, fPtr);
263 tok.compoundToken().type()
264 == token::Compound<List<symmTensor>>::typeName
273 tok.transferCompoundToken(is)
282 symmTensorFields_.insert(
key, fPtr);
286 tok.compoundToken().type()
287 == token::Compound<List<tensor>>::typeName
296 tok.transferCompoundToken(is)
305 tensorFields_.insert(
key, fPtr);
310 <<
"\n unsupported compound " << tok.compoundToken()
311 <<
"\n on patch " << patchName <<
" of field " 312 <<
io.
name() <<
" in file " 318 else if (tok.isWord(
"uniform"))
322 if (!tok.isPunctuation())
337 if (list.size() == vector::nComponents)
339 vector vs(list[0], list[1], list[2]);
355 sphTensorFields_.insert
369 list[0], list[1], list[2],
374 symmTensorFields_.insert
384 else if (list.size() == tensor::nComponents)
388 list[0], list[1], list[2],
389 list[3], list[4], list[5],
390 list[6], list[7], list[8]
406 <<
"\n unrecognised native type " <<
flatOutput(list)
407 <<
"\n on patch " << patchName <<
" of field " 408 <<
io.
name() <<
" in file " 416 #undef FIELDSIZE_CHECK 434 &&
e.stream()[0].isWord(
"nonuniform")
437 if (scalarFields_.found(
key))
439 scalarFields_.cfind(
key)()->writeEntry(
key,
os);
441 else if (vectorFields_.found(
key))
443 vectorFields_.cfind(
key)()->writeEntry(
key,
os);
445 else if (sphTensorFields_.found(
key))
447 sphTensorFields_.cfind(
key)()->writeEntry(
key,
os);
449 else if (symmTensorFields_.found(
key))
451 symmTensorFields_.cfind(
key)()->writeEntry(
key,
os);
453 else if (tensorFields_.found(
key))
455 tensorFields_.cfind(
key)()->writeEntry(
key,
os);
468 const bool separateValue
473 for (
const entry& dEntry : dict_)
475 const keyType&
key = dEntry.keyword();
477 if (
key ==
"type" || (separateValue &&
key ==
"value"))
483 putEntry(dEntry,
os);
491 const genericPatchFieldBase& rhs,
497 const auto iter2 = rhs.scalarFields_.cfind(iter.key());
501 (*iter)->rmap(*iter2(), addr);
507 const auto iter2 = rhs.vectorFields_.cfind(iter.key());
511 (*iter)->rmap(*iter2(), addr);
517 const auto iter2 = rhs.sphTensorFields_.cfind(iter.key());
521 (*iter)->rmap(*iter2(), addr);
527 const auto iter2 = rhs.symmTensorFields_.cfind(iter.key());
531 (*iter)->rmap(*iter2(), addr);
537 const auto iter2 = rhs.tensorFields_.find(iter.key());
541 (*iter)->rmap(*iter2(), addr);
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
A class for handling keywords in dictionaries.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
void writeGeneric(Ostream &os, const bool separateValue) const
Write all generic entries from dictionary, optionally treating the "value" entry separately.
const word & name() const noexcept
Return the object name.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
bool processEntry(const entry &dEntry, const label patchSize, const word &patchName, const IOobject &io)
fileName objectPath() const
The complete path + object name.
void reportMissingEntry(const word &entryName, const word &patchName, const IOobject &io) const
FatalError for missing entry.
#define FIELDSIZE_CHECK(fieldLen)
const dimensionedScalar e
Elementary charge.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
const keyType & keyword() const noexcept
Return keyword.
void genericFatalSolveError(const word &patchName, const IOobject &io) const
Add error message to FatalError about solving with generic condition.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
A class for handling words, derived from Foam::string.
List< scalar > scalarList
A List of scalars.
void processGeneric(const label patchSize, const word &patchName, const IOobject &io, const bool separateValue)
#define forAllIters(container, iter)
Iterate across all elements in the container object.
static constexpr direction nComponents
Number of components in this vector space.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void rmapGeneric(const genericPatchFieldBase &rhs, const labelList &addr)
Implementation for reverse map given patch field onto this patch field.
OBJstream os(runTime.globalPath()/outputName)
Type & dynamicCast(U &obj)
A dynamic_cast (for references) that generates FatalError on failed casts.
Generic infrastructure for reading/writing unknown patch types.
void putEntry(const entry &e, Ostream &os) const
Write a single entry, with lookup of hashed values.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
List< label > labelList
A List of labels.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Defines the attributes of an object for which implicit objectRegistry management is supported...
genericPatchFieldBase()=default
Default construct, generally not useful.
A keyword and a list of tokens is an 'entry'.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...