ccmWriter.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-2020 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::writer
28
29Description
30 Write OpenFOAM meshes and/or results to CCM format
31
32 - partial support for interfaces
33 - no monitoring (internal) boundaries
34 - does not handle Lagrangian data
35
36 \par Files
37
38 The <tt>constant/boundaryRegion</tt> and <tt>constant/cellTable</tt> files,
39 which are described in ccmReader, are used to construct the CCM
40 \c ProblemDescription node.
41
42 The <tt>constant/remapping</tt> file is an \c IOdictionary that is
43 \c READ_IF_PRESENT and can be used to remap certain information.
44 eg,
45
46 \verbatim
47 // map OpenFOAM scalar fields to CCM output fields
48 fields
49 {
50 tracer0
51 {
52 name CONC_001;
53 Label "tracer0";
54 }
55 tracer1
56 {
57 name CONC_002;
58 Label "tracer1";
59 }
60 tracer2
61 {
62 name CONC_003;
63 Label "tracer2";
64 }
65 divPhi
66 {
67 name CONC_004;
68 Label "divPhi";
69 }
70 // an example with units:
71 p
72 {
73 name P;
74 Label "Pressure";
75 units "Pa";
76 }
77 }
78 \endverbatim
79
80Note
81 This class is in development
82 - any/all of the class names and members may change
83
84SourceFiles
85 ccmWriter.C
86 ccmWriterMesh.C
87 ccmWriterSolution.C
88
89\*---------------------------------------------------------------------------*/
90
91#ifndef ccmWriter_H
92#define ccmWriter_H
93
94#include "ccmBase.H"
95#include "STARCDCore.H"
96
97#include "fvMesh.H"
98#include "boundaryRegion.H"
99#include "cellTable.H"
100#include "IOobjectList.H"
101
102// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103
104namespace Foam
105{
106namespace ccm
107{
108
109// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
110
111class ccmID;
112class ccmMaps;
113class ccmDimension;
114class ccmGlobalState;
115
116/*---------------------------------------------------------------------------*\
117 Class ccm::writer Declaration
118\*---------------------------------------------------------------------------*/
120class writer
121:
122 public base,
124{
125 // Private Data
126
127 // Static Data
128
129 //- The OpenFOAM -> CCM field mappings
130 static dictionary defaultNameMapping;
131
132
133 // Member Data
134
135 //- MapIds for various components (cell, internalFaces, boundaries)
136 unique_ptr<ccmMaps> maps_;
137
138 //- mesh reference
139 const polyMesh& mesh_;
140
141 //- Lookup between cellModel shape and PROSTAR shape
142 const Map<label> prostarShapeLookup_;
143
144 //- ccm node: ProblemDescriptions/boundaryRegion
145 boundaryRegion boundaryRegion_;
146
147 // ccm node: ProblemDescriptions/cellType
148 cellTable cellTable_;
149
150
151 // Private Member Functions
152
153 //- No copy construct
154 writer(const writer&) = delete;
155
156 //- No copy assignment
157 void operator=(const writer&) = delete;
158
159
160 //- create a filled linear map with 'size' from 'start + 1'
161 void addLinearMap
162 (
163 const string& mapName,
164 ccmID& mapId,
165 label size,
166 label start = 0
167 ) const;
168
169 void writeBoundaryRegion(const ccmID& probNode) const;
170
171 void writeCellTable(const ccmID& probNode) const;
172
173 //- write out problem description
174 void writeProblem(const ccmID& stateNode) const;
175
176 //- Return the PROSTAR face id for the given cell/face
177 label prostarCellFaceId(const label& cellId, const label& faceI) const;
178
179 // write the faces, the number of vertices appears before each entry
180 void writeFaces
181 (
182 const ccmID& nodeId,
183 const ccmID& mapId,
184 bool isBoundary, // boundary or internal faces
185 label size,
186 label start = 0
187 ) const;
188
189 void writeVertices(const ccmID& verticesNode) const;
190
191 // - write internal faces with owner/neighbour
192 void writeInternalFaces(const ccmID& topoNode) const;
193
194 // - write boundary faces with owner
195 void writeBoundaryFaces(const ccmID& topoNode) const;
196
197 void writeCells(const ccmID& topoNode);
198
199 void writeInterfaces(const ccmID& cellsNode) const;
200
201 bool newFieldNode
202 (
203 const ccmID& phaseNode,
204 const word& fieldName,
205 const dictionary& nameMapping,
206 const ccmDimension& ccmDim,
207 ccmID& fieldNode
208 ) const;
209
210
211 //- Return patch named 'Default_Boundary_Region' or -1 on error
212 label findDefaultBoundary() const;
213
214public:
215
216 // Static data members
217
218 //- The name for the topology file reference
219 static string defaultMeshName;
220
221
222 // Constructors
223
224 //- Open a file for writing, with backup/overwrite existing file
225 writer
226 (
227 const fileName& file,
228 const polyMesh& mesh,
229 const bool backup=true
230 );
231
232
233 //- Destructor (closes file)
234 ~writer();
235
236
237 // Member Functions
238
239 // Write
240
241 //- Write the mesh
242 void writeGeometry();
243
244 //- Write the solutions
245 // provide optional remapping dictionary
246 void writeSolution
247 (
248 const IOobjectList& objects,
249 const fileName& remappingDictName = fileName::null
250 );
251
252};
253
254
255// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256
257} // End namespace ccm
258} // End namespace Foam
259
260// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261
262#endif
263
264// ************************************************************************* //
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
The boundaryRegion persistent data saved as a Map<dictionary>.
Base functionality common to reader and writer classes.
Definition: ccmBase.H:63
Write OpenFOAM meshes and/or results to CCM format.
Definition: ccmWriter.H:123
~writer()
Destructor (closes file)
Definition: ccmWriter.C:376
void writeGeometry()
Write the mesh.
void writeSolution(const IOobjectList &objects, const fileName &remappingDictName=fileName::null)
Write the solutions.
static string defaultMeshName
The name for the topology file reference.
Definition: ccmWriter.H:218
The cellTable persistent data saved as a Map<dictionary>.
Definition: cellTable.H:83
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
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
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
label cellId
Namespace for OpenFOAM.