ccmReader.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::ccm::reader
28
29Description
30 Reads CCM files as written by PROSTAR/STARCCM
31
32 - arbitrary polyhedral meshs
33 - writes interfaces (baffles) to constant/polymesh/interfaces
34 - experimental handling of monitoring (internal) boundaries
35 - does not handle cyclics. Use createPatch to recreate these
36 - does patch names only if they are in the problem description
37 - reads cell and face solution data
38 - reads Lagrangian data
39
40 The Default_Boundary_Region (region 0) is a special region that serves
41 two purposes:
42 -# it contains all wall and baffle boundaries that have not otherwise
43 been assigned.
44 -# it holds the outer bounds of flow domains (fluid/porous/solid)
45
46 The CCM node \c Meshes/FaceBasedTopology/Cells/Interfaces holds the mapping
47 of the corresponding mesh faces, which can be used to merge these internal
48 boundaries.
49
50 If solid cells exist, there are three possible courses of action:
51 -# Remove all solid cells for subsequent flow calculations.
52 This is the default.
53 -# Treat solid cells like fluid cells, but convert the corresponding
54 Default_Boundary_Region to Default_Boundary_Solid for easier
55 identification.
56 This treatment is useful for visualization purposes.
57 -# Move solid cells to a separate mesh region.
58 This would be useful for conjugate heat transfer, but
59 is not implemented.
60
61 \par Files
62
63 The <tt>constant/remapping</tt> file is an \c IOdictionary that is
64 \c READ_IF_PRESENT and can be used to remap certain information. eg,
65
66 \verbatim
67 // rename/combine cellTable entries
68 // newName ( listOldNames );
69 cellTable
70 {
71 fluid ( inletRegion outletRegion );
72 cat1 ( CAT1 "cat1_(Back|Front|Gamma)" );
73 }
74
75 // rename boundary regions
76 // newName oldName;
77 boundaryRegion
78 {
79 inlet_4 inlet_1;
80 inlet_5 inlet_2;
81 inlet_6 inlet_3;
82 }
83 \endverbatim
84
85 The <tt>constant/boundaryRegion</tt> file is an \c IOMap<dictionary>
86 that is written. It contains the boundary type and names. eg,
87
88 \verbatim
89 (
90 0
91 {
92 BoundaryType wall;
93 Label Default_Boundary_Region;
94 }
95 1
96 {
97 BoundaryType inlet;
98 Label inlet_1;
99 }
100 ...
101
102 4
103 {
104 BoundaryType pressure;
105 Label outlet;
106 }
107 )
108 \endverbatim
109
110 The <tt>constant/cellTable</tt> file is an \c IOMap<dictionary> that is
111 written. It contains the cellTable information.
112 eg,
113
114 \verbatim
115 (
116 1
117 {
118 Label inletRegion;
119 MaterialType fluid;
120 MaterialId 1;
121 }
122 2
123 {
124 Label cat1;
125 MaterialType fluid;
126 MaterialId 1;
127 PorosityId 1;
128 }
129 3
130 {
131 Label outletRegion;
132 MaterialType fluid;
133 MaterialId 1;
134 }
135 )
136 \endverbatim
137
138Note
139 this class is still under development
140 - any/all of the class names and members may change
141
142SourceFiles
143 ccmReader.C
144 ccmReaderAux.C
145 ccmReaderMesh.C
146 ccmReaderSolution.C
147
148\*---------------------------------------------------------------------------*/
149
150#ifndef ccmReader_H
151#define ccmReader_H
152
153#include "ccmBase.H"
154#include "STARCDCore.H"
155
156#include "labelList.H"
157#include "ListOps.H"
158#include "polyMesh.H"
159#include "boundaryRegion.H"
160#include "cellTable.H"
162#include "ccmSolutionTable.H"
163
164// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165
166namespace Foam
167{
168namespace ccm
169{
170
171// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
172
173class ccmID;
174class ccmNODE;
175class ccmGlobalState;
176class reader;
177
178// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179
180/*---------------------------------------------------------------------------*\
181 Class ccm::reader Declaration
182\*---------------------------------------------------------------------------*/
184class reader
185:
186 public base,
188{
189public:
190
191 // Forward declarations
192 class options;
193
194
195private:
196
197 // Static Data
198
199 //- cellTable integer options
200 static const char* cellTableOpti[];
201
202 //- cellTable string options
203 static const char* cellTableOptstr[];
204
205
206 // Private Data
207
208 //- Reader options
209 const unique_ptr<options> options_;
210
211
212 //- Enumeration defining the status of a ccmio node
213 enum nodeStatus
214 {
215 UNKNOWN, BAD, OKAY, READ
216 };
217
218
219 //- status of the geometry (topology) information
220 nodeStatus geometryStatus_;
221
222 //- status of the solution (field) information
223 nodeStatus solutionStatus_;
224
225 // Persistent data
226
227 //- ccm node: /InterfaceDefinitions
228 interfaceDefinitions interfaceDefinitions_;
229
230 //- ccm node: ProblemDescriptions/boundaryRegion
231 boundaryRegion boundaryRegion_;
232
233 //- ccm node: ProblemDescriptions/cellType
234 cellTable cellTable_;
235
236 //- Number of points
237 label nPoints_;
238
239 //- Number of internal faces
240 label nInternalFaces_;
241
242 //- Number of faces
243 label nFaces_;
244
245 //- Number of cells
246 label nCells_;
247
248 //- Minimum mesh data
249
250 //- Points
251 pointField points_;
252
253 //- Faces
254 faceList faces_;
255
256 //- Face-owner cells
257 labelList faceOwner_;
258
259 //- Face-neighbour cells
260 labelList faceNeighbour_;
261
262 // List of interface pairs (baffles)
263 List<labelPair> bafInterfaces_;
264
265 //- List of interface pairs between mesh regions (domains)
266 List<labelPair> domInterfaces_;
267
268 //- Face sets for monitoring
269 HashTable<labelList> monitoringSets_;
270
271
272 // Mesh Maps
273
274 //- Map to original face id
275 labelList origFaceId_;
276
277 //- Map to original cell id
278 labelList origCellId_;
279
280 //- Cell table id for each cell
281 labelList cellTableId_;
282
283 //- List of the original ccm boundary region number
284 labelList origBndId_;
285
286 //- Patching and region info
287 labelList patchSizes_;
288
289 //- Solution information
290 solutionTable solutionTable_;
291
292 //- Field information
293 fieldTable fieldTable_;
294
295 //- Field information
296 fieldTable lagrangianTable_;
297
298
299 // Private Member Functions
300
301 //- No copy construct
302 reader(const reader&) = delete;
303
304 //- No copy assignment
305 void operator=(const reader&) = delete;
306
307
308 //- Calculate patch starts from given index with current patch sizes
309 inline labelList patchStartList(label initial) const;
310
311 //- Report mesh sizes to stdout
312 void printSizes() const;
313
314 //- Simulate CCMIOGetEntityIndex for Nodes (not ids)
315 int ccmGetEntityIndex(ccmNODE node);
316
317 //- Read string option from specified ccm node
318 // return empty string on failure
319 std::string ccmReadNodestr(const char* opt, ccmNODE node);
320
321 //- Read string option from specified ccm node
322 // return empty string on failure
323 std::string ccmReadOptstr(const char* opt, ccmID node);
324
325 //- Read map data and check error
326 void readMap(const ccmID& mapId, labelList& data);
327
328 //- Determine if the geometry looks good
329 bool detectGeometry();
330
331 //- Get interfaces, cellTable and boundaryRegion information
332 void readProblemDescription(const ccmID& probNode);
333
334 //- Get /InterfaceDefinitions, used by STARCCM to define in-place
335 // interfaces, etc.
336 // Only handle in-place (IN_PLACE) ones at the moment
337 void readInterfaceDefinitions();
338
339 //- Get boundaryRegion information
340 void readProblemDescription_boundaryRegion(const ccmID& probNode);
341
342 //- Get cellTable information
343 void readProblemDescription_cellTable(const ccmID& probNode);
344
345 //- Read the geometry without any sorting or renumbering
346 void readMeshTopology(const scalar scaleFactor=1.0);
347
348 //- Read the vertices
349 labelList readVertices
350 (
351 const ccmID& verticesNode,
352 const scalar scaleFactor = 1.0
353 );
354
355 //- Read the cells
356 void readCells(const ccmID& topoNode);
357
358 //- Read the interfaces
359 void readInterfaces(const ccmID& cellsNode);
360
361 //- Read the monitoring
362 void readMonitoring(const ccmID& topoId);
363
364 //- Move solid faces from Default_Boundary_Region to
365 // Default_Boundary_Solid
366 void juggleSolids();
367
368 //- Remove unwanted fluid/porous/solid regions
369 void removeUnwanted();
370
371 //- Remove interfaces with face >= nFace
372 void validateInterface(List<labelPair>&);
373
374 //- Renumber interface faces
375 void renumberInterfaces(const labelUList& oldToNew);
376
377 //- Remove interfaces between domains (fluid/porosity; fluid/solid, etc)
378 // reorganize baffle interfaces into [0-N/2; N/2-N] lists at the
379 // beginning of the corresponding patch
380 void cleanupInterfaces();
381
382 //- Merge the points and faces of in-place conformal interfaces
383 void mergeInplaceInterfaces();
384
385 //- Re-order mesh and ensure upper-triangular order
386 void reorderMesh();
387
388 //- Write interface (baffle) mapping
389 void writeInterfaces(const objectRegistry&) const;
390
391 //- Write List<label> in constant/polyMesh
392 void writeMeshLabelList
393 (
394 const objectRegistry& registry,
395 const word& propertyName,
396 const labelList& list,
397 IOstreamOption streamOpt
398 ) const;
399
400 // polyMesh Friend Functions
401 void addPatches(polyMesh& mesh) const;
402
403 //- Add faceZones based on monitoring boundary conditions
404 void addFaceZones(polyMesh& mesh) const;
405
406 //- Get information about all available solutions
407 bool detectSolution();
408
409 //- Get information about available fields
410 // assume that all fields are available for all solution intervals
411 void determineFieldInfo
412 (
413 const ccmID& fieldSetNode,
414 fieldTable& table
415 );
416
417
418 // Static Members
419
420 //- Get map of porous regions
421 static Map<word> selectPorous(const Map<dictionary>& table);
422
423
424public:
425
426 // Static Members
427
428 //- Warn about repeated name
429 static void warnDuplicates(const word& context, const wordList& lst);
430
431
432 // Constructors
433
434 //- Open a file for reading
435 reader(const fileName& file, const reader::options& opts);
436
437
438 //- Destructor (closes file)
439 ~reader();
440
441
442 // Member Functions
443
444 // Access
445
446 //- Reference to the reader options
447 const reader::options& option() const;
448
449
450 //- Construct the polyMesh from the read geometry
451 // provide optional remapping dictionary
453 (
454 const objectRegistry& registry,
455 const fileName& remappingDictName = fileName::null
456 );
457
458
459 // label nPoints() const { return nPoints_; }
460 // label nInternalFaces() const { return nInternalFaces_; }
461 // label nFaces() const { return nFaces_; }
462 // label nCells() const { return nCells_; }
463
464 // const faceList& faces() const { return faces_; }
465 // const labelList& faceOwner() const { return faceOwner_; }
466 // const labelList& faceNeighbour() const { return faceNeighbour_; }
467 // const pointField& points() const { return points_; }
468
469
470 // Check
471
472 //- Return true if file has geometry associated with it
473 bool hasGeometry();
474
475 //- Return true if file has solutions associated with it
476 bool hasSolution();
477
478
479 // Edit
480
481 //- Remap cellTable and boundaryRegion according to dictionary
482 bool remapMeshInfo
483 (
484 const objectRegistry& registry,
485 const fileName& remappingDictName = fileName::null
486 );
487
488
489 // Write
490
491 //- Write the polyMesh
492 void writeMesh
493 (
494 const polyMesh& mesh,
496 ) const;
497
498 //- Write cellTable, boundaryRegion and interface information
499 void writeAux(const objectRegistry& registry) const;
500
501 //- Detect and read geometry if possible
502 bool readGeometry(const scalar scaleFactor = 1.0);
503
504 //- Print general information about the mesh
505 void printInfo() const;
506
507 //- Clear out some information after obtaining a polyMesh
508 void clearGeom();
509
510 //- Map to original cell Id
511 const labelList& origCellId() const
512 {
513 return origCellId_;
514 }
515
516 //- Map to original face Id
517 const labelList& origFaceId() const
518 {
519 return origFaceId_;
520 }
521
522 //- Return interface definitions map
524 {
525 return interfaceDefinitions_;
526 }
527
528 //- Return boundaryRegion table
529 const boundaryRegion& boundaryTableInfo() const
530 {
531 return boundaryRegion_;
532 }
533
534 //- Return cell table
535 const cellTable& cellTableInfo() const
536 {
537 return cellTable_;
538 }
539
540 //- Return a list of names corresponding to fluids
541 Map<word> fluids() const
542 {
543 return cellTable_.fluids();
544 }
545
546 //- Return a list of names corresponding to solids
547 Map<word> solids() const
548 {
549 return cellTable_.solids();
550 }
551
552 //- Return table of available solutions
553 const solutionTable& solutions()
554 {
555 detectSolution();
556 return solutionTable_;
557 }
558
559 //- Return table of available fields
560 const fieldTable& fields()
561 {
562 detectSolution();
563 return fieldTable_;
564 }
565
566 //- Return table of available lagrangian fields
567 const fieldTable& lagrangian()
568 {
569 detectSolution();
570 return lagrangianTable_;
571 }
572
573 //- Read solution and field combination
575 (
576 const word& solutionName,
577 const word& fieldName,
578 const bool wallData = false
579 );
580
581};
582
583
584/*---------------------------------------------------------------------------*\
585 Class ccm::reader::options Declaration
586\*---------------------------------------------------------------------------*/
588class reader::options
589{
590 // Private data
591
592 //- Keep fluid regions (default true)
593 bool keepFluid_;
594
595 //- Keep porous regions (default true)
596 bool keepPorous_;
597
598 //- Keep solid regions (default true)
599 bool keepSolid_;
600
601 //- Merge in-place interfaces (default true)
602 bool mergeInterfaces_;
603
604 //- Rename interface boundaries as InterfaceN_0, InterfaceN_1
605 // (default true)
606 bool renameInterfaces_;
607
608 //- Remove baffles by merging their respective faces (default false)
609 bool removeBaffles_;
610
611 //- Use numbered names (eg, patch_0, zone_0) instead of human-readable
612 // names (default false)
613 bool useNumberedNames_;
614
615 //- merge tolerance for points (default 0.05e-3)
616 scalar mergeTol_;
617
618 //- Value to assign for undefined solutions (default: NaN)
619 scalar undefScalar_;
620
621
622public:
623
624 // Constructors
625
626 //- Construct with the defaults
627 options();
628
629
630 // Member Functions
631
632 // Access
633
634 //- Keep fluid regions (default true)
635 bool keepFluid() const;
636
637 //- Keep porous regions (default true)
638 bool keepPorous() const;
639
640 //- Keep solid regions (default true)
641 bool keepSolid() const;
642
643 //- Some region (fluid, porous, solid) is kept.
644 bool keptSomeRegion() const;
645
646 //- Merge in-place interfaces (default true)
647 bool mergeInterfaces() const;
648
649 //- Rename interface boundaries as InterfaceN_0, InterfaceN_1
650 // (default true)
651 bool renameInterfaces() const;
652
653 //- Remove baffles by merging their respective faces (default false)
654 bool removeBaffles() const;
655
656 //- Use numbered names (eg, patch_0, zone_0) instead of human-readable
657 // names (default false)
658 bool useNumberedNames() const;
659
660 //- Merge tolerance for points (default 0.05e-3)
661 scalar mergeTol() const;
662
663 //- Value to assign for undefined solutions (default: NaN)
664 scalar undefScalar() const;
665
666
667 // Edit
668
669 //- Keep fluid regions
670 void keepFluid(bool b);
671
672 //- Keep porous regions
673 void keepPorous(bool b);
674
675 //- Keep solid regions
676 void keepSolid(bool b);
677
678 //- Merge in-place interfaces
679 void mergeInterfaces(bool b);
680
681 //- Rename interface boundaries as InterfaceN_0, InterfaceN_1
682 void renameInterfaces(bool b);
683
684
685 //- Remove baffles by merging their respective faces
686 void removeBaffles(bool b);
687
688 //- Use numbered names (eg, patch_0, zone_0) instead of human-readable
689 void useNumberedNames(bool b);
690
691 //- Merge tolerance for points (default 0.05e-3)
692 void mergeTol(const scalar& tol);
693
694 //- Value to assign for undefined solutions (default: NaN)
695 void undefScalar(const scalar& val);
696
697};
698
699
700// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
701
702} // End namespace ccm
703} // End namespace Foam
704
705// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
706
707#endif
708
709// ************************************************************************* //
Various functions to operate on Lists.
Containers for holding STARCCM interface definitions.
Containers for holding ccm solution and field listings.
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
The IOstreamOption is a simple container for options an IOstream can normally have.
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
The boundaryRegion persistent data saved as a Map<dictionary>.
Base functionality common to reader and writer classes.
Definition: ccmBase.H:63
A list of the available fields.
A list of available interface definitions.
bool keepFluid() const
Keep fluid regions (default true)
bool mergeInterfaces() const
Merge in-place interfaces (default true)
bool useNumberedNames() const
Use numbered names (eg, patch_0, zone_0) instead of human-readable.
bool removeBaffles() const
Remove baffles by merging their respective faces (default false)
bool keptSomeRegion() const
Some region (fluid, porous, solid) is kept.
bool keepSolid() const
Keep solid regions (default true)
scalar undefScalar() const
Value to assign for undefined solutions (default: NaN)
bool renameInterfaces() const
Rename interface boundaries as InterfaceN_0, InterfaceN_1.
bool keepPorous() const
Keep porous regions (default true)
scalar mergeTol() const
Merge tolerance for points (default 0.05e-3)
options()
Construct with the defaults.
Reads CCM files as written by PROSTAR/STARCCM.
Definition: ccmReader.H:187
void writeMesh(const polyMesh &mesh, IOstreamOption streamOpt=IOstreamOption(IOstreamOption::BINARY)) const
Write the polyMesh.
Definition: ccmReader.C:579
const labelList & origFaceId() const
Map to original face Id.
Definition: ccmReader.H:516
bool remapMeshInfo(const objectRegistry &registry, const fileName &remappingDictName=fileName::null)
Remap cellTable and boundaryRegion according to dictionary.
Definition: ccmReader.C:593
void clearGeom()
Clear out some information after obtaining a polyMesh.
const cellTable & cellTableInfo() const
Return cell table.
Definition: ccmReader.H:534
~reader()
Destructor (closes file)
Definition: ccmReader.C:709
bool hasSolution()
Return true if file has solutions associated with it.
Definition: ccmReader.C:571
const interfaceDefinitions & interfaceDefinitionsInfo() const
Return interface definitions map.
Definition: ccmReader.H:522
const reader::options & option() const
Reference to the reader options.
Definition: ccmReader.C:717
bool hasGeometry()
Return true if file has geometry associated with it.
Definition: ccmReader.C:564
bool readGeometry(const scalar scaleFactor=1.0)
Detect and read geometry if possible.
Definition: ccmReader.C:536
const solutionTable & solutions()
Return table of available solutions.
Definition: ccmReader.H:552
void printInfo() const
Print general information about the mesh.
Definition: ccmReader.C:522
const fieldTable & lagrangian()
Return table of available lagrangian fields.
Definition: ccmReader.H:566
const boundaryRegion & boundaryTableInfo() const
Return boundaryRegion table.
Definition: ccmReader.H:528
const fieldTable & fields()
Return table of available fields.
Definition: ccmReader.H:559
tmp< scalarField > readField(const word &solutionName, const word &fieldName, const bool wallData=false)
Read solution and field combination.
const labelList & origCellId() const
Map to original cell Id.
Definition: ccmReader.H:510
Map< word > fluids() const
Return a list of names corresponding to fluids.
Definition: ccmReader.H:540
void writeAux(const objectRegistry &registry) const
Write cellTable, boundaryRegion and interface information.
Definition: ccmReaderAux.C:182
Map< word > solids() const
Return a list of names corresponding to solids.
Definition: ccmReader.H:546
static void warnDuplicates(const word &context, const wordList &lst)
Warn about repeated name.
Definition: ccmReaderAux.C:70
The cellTable persistent data saved as a Map<dictionary>.
Definition: cellTable.H:83
Map< word > solids() const
Return a Map of (id => name) for solids.
Definition: cellTable.C:275
Map< word > fluids() const
Return a Map of (id => name) for fluids.
Definition: cellTable.C:269
Database for solution data, solver performance and other reduced data.
Definition: data.H:58
Core routines used when reading/writing PROSTAR vrt/cel/bnd files.
Definition: STARCDCore.H:60
A class for handling file names.
Definition: fileName.H:76
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Namespace for OpenFOAM.
volScalarField & b
Definition: createFields.H:27