Go to the documentation of this file.
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
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,
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()
205 tok.transferCompoundToken(is)
214 scalarFields_.insert(
key, fPtr);
218 tok.compoundToken().type()
228 tok.transferCompoundToken(is)
236 vectorFields_.insert(
key, fPtr);
240 tok.compoundToken().type()
250 tok.transferCompoundToken(is)
259 sphTensorFields_.insert(
key, fPtr);
263 tok.compoundToken().type()
273 tok.transferCompoundToken(is)
282 symmTensorFields_.insert(
key, fPtr);
286 tok.compoundToken().type()
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())
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_)
477 if (
key ==
"type" || (separateValue &&
key ==
"value"))
483 putEntry(dEntry,
os);
501 (*iter)->rmap(*iter2(), addr);
511 (*iter)->rmap(*iter2(), addr);
521 (*iter)->rmap(*iter2(), addr);
531 (*iter)->rmap(*iter2(), addr);
541 (*iter)->rmap(*iter2(), addr);
A keyword and a list of tokens is an 'entry'.
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A class for handling words, derived from Foam::string.
A templated class for holding compound tokens.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
Generic infrastructure for reading/writing unknown patch types.
void reportMissingEntry(const word &entryName, const word &patchName, const IOobject &io) const
FatalError for missing entry.
virtual bool isStream() const noexcept
Return true if this entry is a stream.
void genericFatalSolveError(const word &patchName, const IOobject &io) const
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
const keyType & keyword() const noexcept
Return keyword.
A token holds an item read from Istream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
void writeGeneric(Ostream &os, const bool separateValue) const
HashPtrTable< vectorField > vectorFields_
#define FIELDSIZE_CHECK(fieldLen)
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE)
A class for handling keywords in dictionaries.
An input stream of tokens.
void rmapGeneric(const genericPatchFieldBase &rhs, const labelList &addr)
HashPtrTable< symmTensorField > symmTensorFields_
HashPtrTable< tensorField > tensorFields_
#define forAllIters(container, iter)
Iterate across all elements in the container object.
bool processEntry(const entry &dEntry, const label patchSize, const word &patchName, const IOobject &io)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
HashPtrTable< sphericalTensorField > sphTensorFields_
errorManipArg< error, int > exit(error &err, const int errNo=1)
void processGeneric(const label patchSize, const word &patchName, const IOobject &io, const bool separateValue)
const word & name() const noexcept
Return name.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
genericPatchFieldBase()=default
Default construct, generally not useful.
To & dynamicCast(From &r)
HashPtrTable< scalarField > scalarFields_
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
const dimensionedScalar e
Elementary charge.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
fileName objectPath() const
The complete path + object name.
void putEntry(const entry &e, Ostream &os) const
Write a single entry, with lookup of hashed values.
static constexpr direction nComponents
Number of components in this vector space.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
word actualTypeName_
The non-generic patch name.