Forward compatibility: flex
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / meshes / polyMeshGen / polyMeshGen.C
blob6d625b5bbeb488d83f5547ccc34964d9e068aeb7
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.
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.
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.
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/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 #include "polyMeshGen.H"
29 #include "demandDrivenData.H"
30 #include "OFstream.H"
32 namespace Foam
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 polyMeshGen::polyMeshGen(const Time& t)
39     polyMeshGenCells(t),
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     )
54 //- Construct from components without the boundary
55 polyMeshGen::polyMeshGen
57     const Time& t,
58     const pointField& points,
59     const faceList& faces,
60     const cellList& cells
63     polyMeshGenCells(t, points, faces, cells),
64     metaDict_
65     (
66         IOobject
67         (
68             "meshMetaDict",
69             runTime_.constant(),
70             "polyMesh",
71             runTime_,
72             IOobject::READ_IF_PRESENT,
73             IOobject::NO_WRITE
74         )
75     )
78 //- Construct from components with the boundary
79 polyMeshGen::polyMeshGen
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
90     polyMeshGenCells
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_,
108             IOobject::READ_IF_PRESENT,
109             IOobject::NO_WRITE
110         )
111     )
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 // Destructor
116 polyMeshGen::~polyMeshGen()
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 void polyMeshGen::read()
123     polyMeshGenCells::read();
126 void polyMeshGen::write() const
128     //- remove old mesh before writting
129     const fileName meshDir = runTime_.path()/runTime_.constant()/"polyMesh";
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");
144     // remove sets if they exist
145     if (isDir(meshDir/"sets"))
146     {
147         rmDir(meshDir/"sets");
148     }
150     //- write the mesh
151     polyMeshGenCells::write();
153     //- write meta data
154     OFstream fName(meshDir/"meshMetaDict");
156     metaDict_.writeHeader(fName);
157     metaDict_.writeData(fName);
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 } // End namespace Foam
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //