37const char* Foam::ccm::reader::cellTableOpti[] =
39 "MaterialId",
"PorosityId",
"SpinId",
"GroupId",
"ColorIdx",
nullptr
43const char* Foam::ccm::reader::cellTableOptstr[] =
45 "MaterialType",
nullptr
52int Foam::ccm::reader::ccmGetEntityIndex(ccmNODE node)
55 char name[kCCMIOMaxStringLength + 1];
68 char const *
pos = strrchr(
name,
'-');
88std::string Foam::ccm::reader::ccmReadNodestr
123std::string Foam::ccm::reader::ccmReadOptstr
146 char* strval =
new char[len + 1];
171void Foam::ccm::reader::readMap
177 if (globalState_->hasError())
184 &(globalState_->error),
190 assertNoError(
"error reading map");
197void 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;
218void 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);
309void 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);
424void 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);
515 cellTable_.insert(Id,
dict);
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())
630 if (remapDict.
isDict(
"cellTable"))
632 cellTable_.combine(remapDict.
subDict(
"cellTable"), cellTableId_);
637 if (remapDict.
isDict(
"boundaryRegion"))
639 boundaryRegion_.rename(remapDict.
subDict(
"boundaryRegion"));
654 geometryStatus_(UNKNOWN),
655 solutionStatus_(UNKNOWN),
656 interfaceDefinitions_(),
678 if (!
option().keptSomeRegion())
681 <<
"must retain at least one region type: fluid | porous | solid"
688 <<
"Cannot read file " << file
Internal bits for wrapping libccmio - do not use directly.
Input from file stream, using an ISstream.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
The IOstreamOption is a simple container for options an IOstream can normally have.
A bounding box defined in terms of min/max extrema points.
Base functionality common to reader and writer classes.
std::unique_ptr< ccmGlobalState > globalState_
Maintain overall global states (error, root-node)
static bool assertNoError(int err, const char *msg)
Die with msg if there is an error.
static bool isInPlace(const std::string &configurationType)
Check for in-place interfaces.
Reads CCM files as written by PROSTAR/STARCCM.
bool remapMeshInfo(const objectRegistry ®istry, const fileName &remappingDictName=fileName::null)
Remap cellTable and boundaryRegion according to dictionary.
~reader()
Destructor (closes file)
bool hasSolution()
Return true if file has solutions associated with it.
const reader::options & option() const
Reference to the reader options.
bool hasGeometry()
Return true if file has geometry associated with it.
bool readGeometry(const scalar scaleFactor=1.0)
Detect and read geometry if possible.
void printInfo() const
Print general information about the mesh.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
bool isDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Check if entry is found and is a sub-dictionary.
void writeMesh() const
Write equivalent mesh information at the polyMesh faceInstances time.
A class for handling file names.
virtual void validate()
Validate the turbulence fields after construction.
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedScalar pos(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)