polyMeshGen.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "polyMeshGen.H"
29 #include "demandDrivenData.H"
30 #include "OFstream.H"
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
38 :
40  metaDict_
41  (
42  IOobject
43  (
44  "meshMetaDict",
45  runTime_.constant(),
46  "polyMesh",
47  runTime_,
48  IOobject::READ_IF_PRESENT,
49  IOobject::NO_WRITE
50  )
51  )
52 {}
53 
54 //- Construct from components without the boundary
56 (
57  const Time& t,
58  const pointField& points,
59  const faceList& faces,
60  const cellList& cells
61 )
62 :
63  polyMeshGenCells(t, points, faces, cells),
64  metaDict_
65  (
66  IOobject
67  (
68  "meshMetaDict",
69  runTime_.constant(),
70  "polyMesh",
71  runTime_,
74  )
75  )
76 {}
77 
78 //- Construct from components with the boundary
80 (
81  const Time& t,
82  const pointField& points,
83  const faceList& faces,
84  const cellList& cells,
85  const wordList& patchNames,
86  const labelList& patchStart,
87  const labelList& nFacesInPatch
88 )
89 :
91  (
92  t,
93  points,
94  faces,
95  cells,
96  patchNames,
97  patchStart,
98  nFacesInPatch
99  ),
100  metaDict_
101  (
102  IOobject
103  (
104  "meshMetaDict",
105  runTime_.constant(),
106  "polyMesh",
107  runTime_,
110  )
111  )
112 {}
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 // Destructor
117 {}
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
122 {
124 }
125 
126 void polyMeshGen::write() const
127 {
128  //- remove old mesh before writting
129  const fileName meshDir = runTime_.path()/runTime_.constant()/"polyMesh";
130 
131  rm(meshDir/"points");
132  rm(meshDir/"faces");
133  rm(meshDir/"owner");
134  rm(meshDir/"neighbour");
135  rm(meshDir/"cells");
136  rm(meshDir/"boundary");
137  rm(meshDir/"pointZones");
138  rm(meshDir/"faceZones");
139  rm(meshDir/"cellZones");
140  rm(meshDir/"meshModifiers");
141  rm(meshDir/"parallelData");
142  rm(meshDir/"meshMetaDict");
143 
144  // remove sets if they exist
145  if (isDir(meshDir/"sets"))
146  {
147  rmDir(meshDir/"sets");
148  }
149 
150  //- write the mesh
152 
153  //- write meta data
154  OFstream fName(meshDir/"meshMetaDict");
155 
156  metaDict_.writeHeader(fName);
157  metaDict_.writeData(fName);
158 }
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::rm
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
Definition: POSIX.C:954
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::polyMeshGen::~polyMeshGen
~polyMeshGen()
Definition: polyMeshGen.C:116
Foam::polyMeshGenCells::read
void read()
Definition: polyMeshGenCells.C:414
Foam::polyMeshGen::polyMeshGen
polyMeshGen(const Time &t)
Null constructor.
Definition: polyMeshGen.C:37
Foam::IOdictionary::writeData
bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Definition: IOdictionaryIO.C:157
Foam::polyMeshGen::read
void read()
Definition: polyMeshGen.C:121
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
constant
Constant dispersed-phase particle diameter model.
OFstream.H
Foam::IOobject::writeHeader
bool writeHeader(Ostream &) const
Write header.
Definition: IOobjectWriteHeader.C:67
Foam::polyMeshGenCells
Definition: polyMeshGenCells.H:49
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
polyMeshGen.H
Foam::polyMeshGenCells::write
void write() const
Definition: polyMeshGenCells.C:475
patchNames
wordList patchNames(nPatches)
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::isDir
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
Definition: POSIX.C:615
Foam::OFstream
Output to file stream.
Definition: OFstream.H:81
Foam::Time::path
fileName path() const
Return path.
Definition: Time.H:281
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::polyMeshGen::write
void write() const
Definition: polyMeshGen.C:126
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePaths.H:130
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::polyMeshGenPoints::runTime_
const Time & runTime_
reference to the Time registry
Definition: polyMeshGenPoints.H:61
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::IOobject::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: IOobject.H:110
Foam::polyMeshGen::metaDict_
IOdictionary metaDict_
meta data about the meshing process
Definition: polyMeshGen.H:51
Foam::rmDir
bool rmDir(const fileName &)
Remove a dirctory and its contents.
Definition: POSIX.C:974