points0MotionSolver.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-2022 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 "points0MotionSolver.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
33 }
34 
35 
37 (
38  const polyMesh& mesh
39 )
40 {
41  const word instance
42  (
44  (
45  ".",
46  "points0",
48  )
49  );
50 
51  if (instance != mesh.time().constant())
52  {
53  // Points0 written to a time folder
54 
55  return pointVectorField
56  (
57  IOobject
58  (
59  "points0",
60  instance,
61  mesh,
64  false
65  ),
67  );
68  }
69  else
70  {
71  // Return copy of original mesh points
72 
74  (
75  IOobject
76  (
77  "points",
78  mesh.time().constant(),
80  mesh,
83  false
84  )
85  );
86 
88  (
89  IOobject
90  (
91  "points0",
92  instance,
93  mesh,
96  false
97  ),
100  );
101 
102  points0.primitiveFieldRef() = points;
103 
104  return points0;
105  }
106 }
107 
108 
109 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
110 
112 (
113  const word& name,
114  const polyMesh& mesh,
115  const dictionary& dict,
116  const word& type
117 )
118 :
119  motionSolver(name, mesh, dict, type),
120  points0_(readPoints0(mesh))
121 {
122  if (points0_.size() != mesh.nPoints())
123  {
125  << "Number of points in mesh " << mesh.nPoints()
126  << " differs from number of points " << points0_.size()
127  << " read from file "
129  (
130  "points",
131  mesh.time().constant(),
133  mesh,
136  false
137  ).filePath()
138  << exit(FatalError);
139  }
140 }
141 
142 
143 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
144 
146 {}
147 
148 
149 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
150 
152 {}
153 
154 
156 {
158 }
159 
160 
162 {
163  points0_.primitiveFieldRef() = mesh().points();
164 }
165 
166 
168 (
169  const polyDistributionMap& map
170 )
171 {}
172 
173 
175 {
176  if (mesh().topoChanged())
177  {
178  points0_.instance() = mesh().time().name();
179  points0_.write();
180  }
181 
182  return motionSolver::write();
183 }
184 
185 
186 // ************************************************************************* //
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
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:647
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Virtual base class for mesh motion solver.
Definition: motionSolver.H:57
virtual bool write() const
Optionally write motion state information for restart.
Definition: motionSolver.C:128
const polyMesh & mesh() const
Return reference to mesh.
Definition: motionSolver.H:137
const Time & time() const
Return time.
Virtual base class for displacement motion solvers.
points0MotionSolver(const word &name, const polyMesh &, const dictionary &, const word &type)
Construct from mesh and dictionary.
virtual ~points0MotionSolver()
Destructor.
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 &)
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.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:269
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:531
fileName filePath() const
Return the path for the file for this Type.
Definition: IOobject.H:563
A class for handling words, derived from string.
Definition: word.H:62
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
const pointField & points
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
defineTypeNameAndDebug(combustionModel, 0)
PointField< vector > pointVectorField
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
error FatalError
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
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