displacementPoints0.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "displacementPoints0.H"
27 #include "polyDistributionMap.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace pointMeshMovers
34 {
36 }
37 }
38 
39 
41 (
42  const polyMesh& mesh
43 )
44 {
45  const word instance
46  (
48  (
49  ".",
50  "points0",
52  )
53  );
54 
55  if (instance != mesh.time().constant())
56  {
57  // Points0 written to a time folder
58 
59  return pointVectorField
60  (
61  IOobject
62  (
63  "points0",
64  instance,
65  mesh,
68  false
69  ),
72  );
73  }
74  else
75  {
76  // Return copy of original mesh points
77 
79  (
80  IOobject
81  (
82  "points",
83  mesh.time().constant(),
85  mesh,
88  false
89  )
90  );
91 
93  (
94  IOobject
95  (
96  "points0",
97  instance,
98  mesh,
101  false
102  ),
105  );
106 
107  points0.primitiveFieldRef() = points;
108 
109  return points0;
110  }
111 }
112 
113 
114 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
115 
117 (
118  const polyMesh& mesh,
119  const dictionary& dict,
120  const word& type
121 )
122 :
124  points0_(readPoints0(mesh))
125 {
126  if (points0_.size() != mesh.nPoints())
127  {
129  << "Number of points in mesh " << mesh.nPoints()
130  << " differs from number of points " << points0_.size()
131  << " read from file "
133  (
134  "points",
135  mesh.time().constant(),
137  mesh,
140  false
141  ).filePath()
142  << exit(FatalError);
143  }
144 }
145 
146 
147 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
148 
150 {}
151 
152 
153 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
154 
156 {}
157 
158 
160 (
161  const polyTopoChangeMap& map
162 )
163 {
164  // Pending implementation of the inverse transformation of points0
166 }
167 
168 
170 {
171  points0_.primitiveFieldRef() = poly().points();
172 
173  // The processor boundaries may have changed, so we need to update the
174  // boundary field. There is no data in this field, so we don't need to map
175  // anything. We can just reset it to a freshly created calculated field.
176  points0_.boundaryFieldRef().reset
177  (
179  (
180  points0_.mesh().boundary(),
181  points0_.internalField(),
183  )
184  );
185 }
186 
187 
189 (
190  const polyDistributionMap& map
191 )
192 {
193  map.distributePointData(points0_.primitiveFieldRef());
194 
195  // See above
196  points0_.boundaryFieldRef().reset
197  (
199  (
200  points0_.mesh().boundary(),
201  points0_.internalField(),
203  )
204  );
205 }
206 
207 
209 {
210  if (points0_.writeOpt() == IOobject::AUTO_WRITE)
211  {
212  points0_.write();
213  }
214 
215  return pointMeshMover::write();
216 }
217 
218 
219 // ************************************************************************* //
static pointMesh & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Generic GeometricBoundaryField class.
A primitive field of type <Type> with automated input and output.
Definition: IOField.H:53
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static const word & constant()
Return constant name.
Definition: TimePaths.H:122
word findInstance(const fileName &dir, const word &name=word::null, const IOobject::readOption rOpt=IOobject::MUST_READ, const word &stopInstance=word::null) const
Return the location of "dir" containing the file "name".
Definition: Time.C:666
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:433
Abstract base class for pointMesh movers.
virtual bool write() const
Optionally write motion state information for restart.
virtual void topoChange(const polyTopoChangeMap &)
Update local data for topology changes.
virtual void distribute(const polyDistributionMap &)
Update corresponding to the given distribution map.
static pointVectorField readPoints0(const polyMesh &mesh)
virtual void mapMesh(const polyMeshMap &)=0
Update from another mesh using the given map.
virtual void movePoints(const pointField &)
Update local data for geometry changes.
virtual bool write() const
Write points0 if the mesh topology changed.
pointVectorField points0_
Starting points.
pointField & points0()
Return reference to the reference field.
displacementPoints0(const polyMesh &, const dictionary &, const word &type)
Construct from mesh and dictionary.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
void distributePointData(List< T > &lst) const
Distribute list of point data.
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:263
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
label nPoints() const
Templated form of IOobject providing type information for file reading and header type checking.
Definition: IOobject.H:545
fileName filePath() const
Return the path for the file for this Type.
Definition: IOobject.H:577
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const pointField & points
const dimensionSet length
defineTypeNameAndDebug(externalDisplacement, 0)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
const dimensionSet & dimLength
Definition: dimensions.C:276
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
PointField< vector > pointVectorField
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
error FatalError
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
dictionary dict