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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::ccm::writer
28 
29 Description
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 
80 Note
81  This class is in development
82  - any/all of the class names and members may change
83 
84 SourceFiles
85  ccmWriter.C
86  ccmWriterMesh.C
87  ccmWriterSolution.C
88 
89 \*---------------------------------------------------------------------------*/
90 #ifndef ccmWriter_H
91 #define ccmWriter_H
92 
93 #include "ccmBase.H"
94 #include "STARCDCore.H"
95 
96 #include "fvMesh.H"
97 #include "boundaryRegion.H"
98 #include "cellTable.H"
99 #include "IOobjectList.H"
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 namespace Foam
104 {
105 namespace ccm
106 {
107 
108 // * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
109 
110 class ccmID;
111 class ccmMaps;
112 class ccmDimension;
113 class ccmGlobalState;
114 
115 /*---------------------------------------------------------------------------*\
116  Class ccm::writer Declaration
117 \*---------------------------------------------------------------------------*/
118 
119 class writer
120 :
121  public base,
122  protected fileFormats::STARCDCore
123 {
124  // Private Data
125 
126  // Static Data
127 
128  //- The OpenFOAM -> CCM field mappings
129  static dictionary defaultNameMapping;
130 
131 
132  // Member Data
133 
134  //- MapIds for various components (cell, internalFaces, boundaries)
135  unique_ptr<ccmMaps> maps_;
136 
137  //- mesh reference
138  const polyMesh& mesh_;
139 
140  //- Lookup between cellModel shape and PROSTAR shape
141  const Map<label> prostarShapeLookup_;
142 
143  //- ccm node: ProblemDescriptions/boundaryRegion
144  boundaryRegion boundaryRegion_;
145 
146  // ccm node: ProblemDescriptions/cellType
147  cellTable cellTable_;
148 
149 
150  // Private Member Functions
151 
152  //- No copy construct
153  writer(const writer&) = delete;
154 
155  //- No copy assignment
156  void operator=(const writer&) = delete;
157 
158 
159  //- create a filled linear map with 'size' from 'start + 1'
160  void addLinearMap
161  (
162  const string& mapName,
163  ccmID& mapId,
164  label size,
165  label start = 0
166  ) const;
167 
168  void writeBoundaryRegion(const ccmID& probNode) const;
169 
170  void writeCellTable(const ccmID& probNode) const;
171 
172  //- write out problem description
173  void writeProblem(const ccmID& stateNode) const;
174 
175  //- Return the PROSTAR face id for the given cell/face
176  label prostarCellFaceId(const label& cellId, const label& faceI) const;
177 
178  // write the faces, the number of vertices appears before each entry
179  void writeFaces
180  (
181  const ccmID& nodeId,
182  const ccmID& mapId,
183  bool isBoundary, // boundary or internal faces
184  label size,
185  label start = 0
186  ) const;
187 
188  void writeVertices(const ccmID& verticesNode) const;
189 
190  // - write internal faces with owner/neighbour
191  void writeInternalFaces(const ccmID& topoNode) const;
192 
193  // - write boundary faces with owner
194  void writeBoundaryFaces(const ccmID& topoNode) const;
195 
196  void writeCells(const ccmID& topoNode);
197 
198  void writeInterfaces(const ccmID& cellsNode) const;
199 
200  bool newFieldNode
201  (
202  const ccmID& phaseNode,
203  const word& fieldName,
204  const dictionary& nameMapping,
205  const ccmDimension& ccmDim,
206  ccmID& fieldNode
207  ) const;
208 
209 
210  //- Return patch named 'Default_Boundary_Region' or -1 on error
211  label findDefaultBoundary() const;
212 
213 public:
214 
215  // Static data members
216 
217  //- The name for the topology file reference
218  static string defaultMeshName;
219 
220 
221  // Constructors
222 
223  //- Open a file for writing, with backup/overwrite existing file
224  writer
225  (
226  const fileName& file,
227  const polyMesh& mesh,
228  const bool backup=true
229  );
230 
231 
232  //- Destructor (closes file)
233  ~writer();
234 
235 
236  // Member Functions
237 
238  // Write
239 
240  //- Write the mesh
241  void writeGeometry();
242 
243  //- Write the solutions
244  // provide optional remapping dictionary
245  void writeSolution
246  (
247  const IOobjectList& objects,
248  const fileName& remappingDictName = fileName::null
249  );
250 
251 };
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace ccm
257 } // End namespace Foam
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #endif
262 
263 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::ccm::writer::defaultMeshName
static string defaultMeshName
The name for the topology file reference.
Definition: ccmWriter.H:217
Foam::boundaryRegion
The boundaryRegion persistent data saved as a Map<dictionary>.
Definition: boundaryRegion.H:72
Foam::Map< label >
Foam::ccm::writer::writeSolution
void writeSolution(const IOobjectList &objects, const fileName &remappingDictName=fileName::null)
Write the solutions.
Definition: ccmWriterSolution.C:126
IOobjectList.H
cellTable.H
STARCDCore.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::fileFormats::STARCDCore
Core routines used when reading/writing PROSTAR vrt/cel/bnd files.
Definition: STARCDCore.H:59
Foam::ccm::writer::~writer
~writer()
Destructor (closes file)
Definition: ccmWriter.C:376
Foam::cellTable
The cellTable persistent data saved as a Map<dictionary>.
Definition: cellTable.H:80
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:55
Foam::fileName::null
static const fileName null
An empty fileName.
Definition: fileName.H:97
cellId
label cellId
Definition: interrogateWallPatches.H:67
ccmBase.H
Foam::ccm::writer::writeGeometry
void writeGeometry()
Write the mesh.
Definition: ccmWriterMesh.C:717
boundaryRegion.H
Foam::ccm::base
Base functionality common to reader and writer classes.
Definition: ccmBase.H:62
Foam::ccm::writer
Write OpenFOAM meshes and/or results to CCM format.
Definition: ccmWriter.H:118