37 const char* Foam::ccm::reader::cellTableOpti[] =
39 "MaterialId",
"PorosityId",
"SpinId",
"GroupId",
"ColorIdx",
nullptr 43 const char* Foam::ccm::reader::cellTableOptstr[] =
45 "MaterialType",
nullptr 52 int Foam::ccm::reader::ccmGetEntityIndex(ccmNODE node)
55 char name[kCCMIOMaxStringLength + 1];
68 char const *
pos = strrchr(
name,
'-');
88 std::string Foam::ccm::reader::ccmReadNodestr
123 std::string Foam::ccm::reader::ccmReadOptstr
146 char* strval =
new char[len + 1];
171 void Foam::ccm::reader::readMap
177 if (globalState_->hasError())
184 &(globalState_->error),
190 assertNoError(
"error reading map");
197 void Foam::ccm::reader::readProblemDescription
199 const ccmID& probNode
202 readInterfaceDefinitions();
203 readProblemDescription_boundaryRegion(probNode);
204 readProblemDescription_cellTable(probNode);
206 #ifdef DEBUG_CCMIOREAD 207 Info<<
"InterfaceDefinitions: " << interfaceDefinitions_ <<
nl 208 <<
"cellTable" << cellTable_ <<
nl 209 <<
"boundaryRegion" << boundaryRegion_ <<
endl;
218 void Foam::ccm::reader::readInterfaceDefinitions()
220 interfaceDefinitions_.clear();
226 CCMIONode interfaceDefNode;
234 (globalState_->root),
245 "InterfaceDefinitions",
251 CCMIONode interfaceNode;
257 CCMIOGetNextChildWithLabel
268 interfaceEntry ifentry(ccmGetEntityIndex(interfaceNode));
293 ccmReadNodestr(
"Configuration", interfaceNode)
297 interfaceDefinitions_.add(ifentry);
309 void Foam::ccm::reader::readProblemDescription_boundaryRegion
311 const ccmID& probNode
314 if (option().useNumberedNames())
316 Info<<
"using numbered patch/zone names" <<
endl;
319 boundaryRegion_.clear();
332 kCCMIOBoundaryRegion,
343 &(globalState_->error),
347 assertNoError(
"error reading boundaryRegion index");
355 const char* opt =
"BoundaryType";
356 std::string str = ccmReadOptstr(opt, node);
360 dict.add(opt,
"empty");
362 else if (str ==
"internal")
365 dict.add(opt,
"monitoring");
379 const char* opt =
"Label";
382 if (option().useNumberedNames())
388 option().renameInterfaces()
389 && interfaceDefinitions_.isInterface(Id)
392 #ifdef DEBUG_CCMIOREAD 393 Info<<
"boundary is on an interface: remap name for " 397 str = interfaceDefinitions_.interfaceName(Id);
401 (str = ccmReadOptstr(opt, node)).empty()
402 && (str = ccmReadOptstr(
"BoundaryName", node)).empty()
415 boundaryRegion_.insert(Id,
dict);
424 void Foam::ccm::reader::readProblemDescription_cellTable
426 const ccmID& probNode
453 &(globalState_->error),
457 assertNoError(
"error reading cellTable index");
463 const char* opt =
"Label";
466 if (!option().useNumberedNames())
468 str = ccmReadOptstr(opt, node);
481 for (
int i=0; cellTableOptstr[i]; ++i)
483 const char* opt = cellTableOptstr[i];
484 std::string str = ccmReadOptstr(opt, node);
493 for (
int i=0; cellTableOpti[i]; ++i)
495 const char* opt = cellTableOpti[i];
511 dict.add(opt, intval);
524 Info<<
"Mesh Information" <<
nl 525 <<
"----------------" <<
nl 527 <<
"nPoints: " << nPoints_ <<
nl 528 <<
"nCells: " << nCells_ <<
nl 529 <<
"nFaces: " << nFaces_ <<
nl 530 <<
"nInternalFaces: " << nInternalFaces_ <<
nl 531 <<
"nBaffles: " << bafInterfaces_.size() <<
endl;
537 const scalar scaleFactor
542 if (geometryStatus_ == OKAY)
546 readMeshTopology(scaleFactor <= VSMALL ? 1 : scaleFactor);
550 if (nCells_ && points_.size())
552 geometryStatus_ = READ;
556 geometryStatus_ = BAD;
560 return (geometryStatus_ == OKAY || geometryStatus_ == READ);
567 return (geometryStatus_ == OKAY || geometryStatus_ == READ);
574 return (solutionStatus_ == OKAY || solutionStatus_ == READ);
587 mesh.writeObject(streamOpt,
true);
600 if (remappingDictName.empty())
623 if (remapDict.empty())
628 const dictionary* subDictPtr =
nullptr;
631 if ((subDictPtr = remapDict.
findDict(
"cellTable")) !=
nullptr)
633 cellTable_.combine(*subDictPtr, cellTableId_);
638 if ((subDictPtr = remapDict.
findDict(
"boundaryRegion")) !=
nullptr)
640 boundaryRegion_.rename(*subDictPtr);
654 options_(new options(opts)),
655 geometryStatus_(UNKNOWN),
656 solutionStatus_(UNKNOWN),
657 interfaceDefinitions_(),
679 if (!
option().keptSomeRegion())
682 <<
"must retain at least one region type: fluid | porous | solid" 689 <<
"Cannot read file " << file
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
void printInfo() const
Print general information about the mesh.
A class for handling file names.
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...
static bool isInPlace(const std::string &configurationType)
Check for in-place interfaces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Base functionality common to reader and writer classes.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A bounding box defined in terms of min/max extrema points.
A simple container for options an IOstream can normally have.
static bool assertNoError(int err, const char *msg)
Die with msg if there is an error.
Ignore writing from objectRegistry::writeObject()
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
const reader::options & option() const
Reference to the reader options.
dimensionedScalar pos(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
bool hasGeometry()
Return true if file has geometry associated with it.
Reading is optional [identical to LAZY_READ].
bool hasSolution()
Return true if file has solutions associated with it.
~reader()
Destructor (closes file)
Internal bits for wrapping libccmio - do not use directly.
Input from file stream, using an ISstream.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
bool remapMeshInfo(const objectRegistry ®istry, const fileName &remappingDictName=fileName::null)
Remap cellTable and boundaryRegion according to dictionary.
bool readGeometry(const scalar scaleFactor=1.0)
Detect and read geometry if possible.
void writeMesh(const polyMesh &mesh, IOstreamOption streamOpt=IOstreamOption(IOstreamOption::BINARY)) const
Write the polyMesh.
std::unique_ptr< ccmGlobalState > globalState_
Maintain overall global states (error, root-node)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
Registry of regIOobjects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Do not request registration (bool: false)
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and a sub-dictionary) otherwise return nullptr...