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  ),
71  );
72  }
73  else
74  {
75  // Return copy of original mesh points
76 
78  (
79  IOobject
80  (
81  "points",
82  mesh.time().constant(),
84  mesh,
87  false
88  )
89  );
90 
92  (
93  IOobject
94  (
95  "points0",
96  instance,
97  mesh,
100  false
101  ),
104  );
105 
106  points0.primitiveFieldRef() = points;
107 
108  return points0;
109  }
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
114 
116 (
117  const polyMesh& mesh,
118  const dictionary& dict,
119  const word& type
120 )
121 :
123  points0_(readPoints0(mesh))
124 {
125  if (points0_.size() != mesh.nPoints())
126  {
128  << "Number of points in mesh " << mesh.nPoints()
129  << " differs from number of points " << points0_.size()
130  << " read from file "
132  (
133  "points",
134  mesh.time().constant(),
136  mesh,
139  false
140  ).filePath()
141  << exit(FatalError);
142  }
143 }
144 
145 
146 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
147 
149 {}
150 
151 
152 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
153 
155 {}
156 
157 
159 (
160  const polyTopoChangeMap& map
161 )
162 {
163  // Pending implementation of the inverse transformation of points0
165 }
166 
167 
169 {
170  points0_.primitiveFieldRef() = poly().points();
171 
172  // The processor boundaries may have changed, so we need to update the
173  // boundary field. There is no data in this field, so we don't need to map
174  // anything. We can just reset it to a freshly created calculated field.
175  points0_.boundaryFieldRef().reset
176  (
178  (
179  points0_.mesh().boundary(),
180  points0_.internalField(),
182  )
183  );
184 }
185 
186 
188 (
189  const polyDistributionMap& map
190 )
191 {
192  map.distributePointData(points0_.primitiveFieldRef());
193 
194  // See above
195  points0_.boundaryFieldRef().reset
196  (
198  (
199  points0_.mesh().boundary(),
200  points0_.internalField(),
202  )
203  );
204 }
205 
206 
208 {
209  if (points0_.writeOpt() == IOobject::AUTO_WRITE)
210  {
211  points0_.write();
212  }
213 
214  return pointMeshMover::write();
215 }
216 
217 
218 // ************************************************************************* //
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
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:141
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