42 void Foam::ccm::writer::addLinearMap
44 const string& mapName,
68 data[i] = start + 1 + i;
85 Foam::label Foam::ccm::writer::findDefaultBoundary()
const 87 return mesh_.boundaryMesh().findPatchID(defaultBoundaryName);
91 void Foam::ccm::writer::writeBoundaryRegion
107 dict.readIfPresent(
"Label", nameEntry)
108 &&
dict.readIfPresent(
"BoundaryType", typeEntry)
109 && !typeDict.found(nameEntry)
112 typeDict.add(nameEntry, typeEntry);
116 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
118 label defaultId = findDefaultBoundary();
123 CCMIONewIndexedEntity
125 &(globalState_->error),
127 kCCMIOBoundaryRegion,
150 word patchName =
patches[patchI].name();
151 word patchType =
patches[patchI].type();
153 label regionId = patchI;
154 if (regionId == defaultId)
158 else if (defaultId == -1 || regionId < defaultId)
164 typeDict.readIfPresent(patchName, patchType);
167 CCMIONewIndexedEntity
169 &(globalState_->error),
171 kCCMIOBoundaryRegion,
194 void Foam::ccm::writer::writeCellTable
196 const ccmID& probNode
199 if (!cellTable_.size())
209 label intVal = iter.key();
212 CCMIONewIndexedEntity
214 &(globalState_->error),
223 for (
const word& keyword :
toc)
225 int pos = keyword.find(
"Id");
230 dict.readEntry(keyword, intVal);
242 const word strVal(
dict.get<word>(keyword));
260 void Foam::ccm::writer::writeProblem
262 const ccmID& stateNode
268 &(globalState_->error),
269 (globalState_->root),
270 kCCMIOProblemDescription,
275 writeCellTable(probNode);
276 writeBoundaryRegion(probNode);
281 &(globalState_->error),
291 Foam::ccm::writer::writer
309 boundaryRegion_(
mesh),
317 Info<<
"moved existing file -> " << fileName(file +
".bak*") <<
nl;
320 else if (
exists(file,
false))
323 Info<<
"removed existing file: " << file <<
nl;
327 globalState_->error = CCMIOOpenFile
332 &(globalState_->root)
334 assertNoError(
"Error opening file for writing");
348 maps_->internalFaces,
349 mesh_.nInternalFaces()
352 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
353 maps_->boundary.setSize(
patches.size());
358 if (
patches[patchI].size() > 0)
360 string mapName =
"boundaryMap-" +
Foam::name(patchI);
365 maps_->boundary[patchI],
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
A class for handling file names.
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.
static bool assertNoError(int err, const char *msg)
Die with msg if there is an error.
#define forAll(list, i)
Loop across all elements in list.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
dimensionedScalar pos(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Internal bits for wrapping libccmio - do not use directly.
List< word > wordList
List of word.
label index() const noexcept
Return index of model in the model list.
const polyBoundaryMesh & patches
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.
~writer()
Destructor (closes file)
A class for handling character strings derived from std::string.
static string defaultMeshName
The name for the topology file reference.
List< label > toc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
forAllConstIters(mixture.phases(), phase)
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.