pointMesh.C
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) 2011-2013 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
27 
28 #include "pointMesh.H"
29 #include "globalMeshData.H"
30 #include "pointMeshMapper.H"
31 #include "pointFields.H"
32 #include "MapGeometricFields.H"
33 #include "MapPointField.H"
34 
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(pointMesh, 0);
41 }
42 
44 
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
48 void Foam::pointMesh::mapFields(const mapPolyMesh& mpm)
49 {
50  if (debug)
51  {
52  Pout<< "void pointMesh::mapFields(const mapPolyMesh&): "
53  << "Mapping all registered pointFields."
54  << endl;
55  }
56  // Create a mapper
57  const pointMeshMapper m(*this, mpm);
58 
59  MapGeometricFields<scalar, pointPatchField, pointMeshMapper, pointMesh>(m);
60  MapGeometricFields<vector, pointPatchField, pointMeshMapper, pointMesh>(m);
62  <
64  pointPatchField,
65  pointMeshMapper,
66  pointMesh
67  >(m);
68  MapGeometricFields<symmTensor, pointPatchField, pointMeshMapper, pointMesh>
69  (m);
70  MapGeometricFields<tensor, pointPatchField, pointMeshMapper, pointMesh>(m);
71 }
72 
73 
74 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
75 
76 Foam::pointMesh::pointMesh(const polyMesh& pMesh)
77 :
78  MeshObject_type(pMesh),
79  GeoMesh<polyMesh>(pMesh),
80  boundary_(*this, pMesh.boundaryMesh())
81 {
82  if (debug)
83  {
84  Pout<< "pointMesh::pointMesh(const polyMesh&): "
85  << "Constructing from polyMesh " << pMesh.name()
86  << endl;
87  }
88 
89  // Calculate the geometry for the patches (transformation tensors etc.)
90  boundary_.calcGeometry();
91 }
92 
93 
94 Foam::pointMesh::pointMesh(const polyMesh& pMesh, const IOobject& io)
95 :
96  MeshObject<polyMesh, Foam::UpdateableMeshObject, pointMesh>(pMesh),
97  GeoMesh<polyMesh>(pMesh),
98  boundary_(io, *this, pMesh.boundaryMesh())
99 {
100  if (debug)
101  {
102  Pout<< "pointMesh::pointMesh(const polyMesh&): "
103  << "Constructing from IO " << io.objectRelPath()
104  << endl;
105  }
107  // Calculate the geometry for the patches (transformation tensors etc.)
108  boundary_.calcGeometry();
109 }
110 
111 
112 Foam::pointMesh::pointMesh
113 (
114  const polyMesh& pMesh,
115  const IOobjectOption::readOption rOpt
116 )
117 :
118  pointMesh
119  (
120  pMesh,
121  IOobject
122  (
123  pMesh.name(), // polyMesh region
124  pMesh.facesInstance(), // polyMesh topology instance
125  pMesh.time(),
126  rOpt,
127  Foam::IOobject::NO_WRITE
128  )
129  )
130 {}
131 
132 
133 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
134 
136 (
137  const fileName& inst,
138  const IOobjectOption::writeOption wOpt
139 )
140 {
141  if (debug)
142  {
143  Pout<< "pointMesh::setInstance(): "
144  << "Setting instance to " << inst << endl;
145  }
146  this->writeOpt(wOpt);
147  this->instance() = inst;
148 
149  boundary_.writeOpt(wOpt);
150  boundary_.instance() = inst;
151 }
152 
153 
155 {
156  if (debug)
157  {
158  Pout<< "pointMesh::movePoints(): "
159  << "Moving points." << endl;
160  }
162  boundary_.movePoints(GeoMesh<polyMesh>::mesh_.points());
163 
164  return true;
165 }
166 
167 
169 {
170  if (debug)
171  {
172  Pout<< "pointMesh::updateMesh(const mapPolyMesh&): "
173  << "Updating for topology changes." << nl << endl;
174  }
175  boundary_.updateMesh();
177  // Map all registered point fields
178  mapFields(mpm);
179 }
180 
181 
183 (
184  IOstreamOption streamOpt,
185  const bool writeOnProc
186 ) const
187 {
188  if (debug)
189  {
190  Pout<< "pointMesh::writeObject(IOstreamOption, const bool): "
191  << "Writing to " << boundary_.objectRelPath() << endl;
192  }
193  return boundary_.writeObject(streamOpt, writeOnProc);
194 }
195 
196 
197 // ************************************************************************* //
bool movePoints()
Move points.
Definition: pointMesh.C:147
writeOption
Enumeration defining write preferences.
A class for handling file names.
Definition: fileName.H:72
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Definition: boundaryMesh.H:58
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:529
void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
Definition: pointMesh.C:161
A simple container for options an IOstream can normally have.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
void MapGeometricFields(const MeshMapper &mapper)
Generic Geometric field mapper.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc=true) const
Write.
Definition: pointMesh.C:176
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:45
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
const pointField & points
A class for handling words, derived from Foam::string.
Definition: word.H:63
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
Definition: pointMesh.C:129
static word meshSubDir
Return the mesh sub-directory name (usually "pointMesh")
Definition: pointMesh.H:107
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:45
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Namespace for OpenFOAM.
readOption
Enumeration defining read preferences.