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 {
32  defineTypeNameAndDebug(points0MotionSolver, 0);
33 }
34 
35 
37 (
38  const polyMesh& mesh
39 )
40 {
41  const word instance
42  (
43  mesh.time().findInstance
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  ),
66  pointMesh::New(mesh)
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 
87  pointVectorField points0
88  (
89  IOobject
90  (
91  "points0",
92  instance,
93  mesh,
95  IOobject::NO_WRITE,
96  false
97  ),
98  pointMesh::New(mesh),
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_ == 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().timeName();
179  points0_.write();
180  }
181 
182  return motionSolver::write();
183 }
184 
185 
186 // ************************************************************************* //
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
virtual void distribute(const polyDistributionMap &)
Update corresponding to the given distribution map.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Templated form of IOobject providing type information for file reading and header type checking...
Definition: IOobject.H:537
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:328
points0MotionSolver(const word &name, const polyMesh &, const dictionary &, const word &type)
Construct from mesh and dictionary.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
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:689
virtual bool write() const
Optionally write motion state information for restart.
Definition: motionSolver.C:128
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
Virtual base class for mesh motion solver.
Definition: motionSolver.H:56
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:372
fvMesh & mesh
virtual bool write() const
Write points0 if the mesh topology changed.
const dimensionSet dimLength
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1211
const pointField & points
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
Definition: Time.C:666
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
virtual void movePoints(const pointField &)
Update local data for geometry changes.
const word & constant() const
Return constant name.
Definition: TimePaths.H:123
static const zero Zero
Definition: zero.H:97
virtual void topoChange(const polyTopoChangeMap &)
Update local data for topology changes.
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal field.
const Time & time() const
Return time.
defineTypeNameAndDebug(combustionModel, 0)
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
static pointVectorField readPoints0(const polyMesh &mesh)
virtual ~points0MotionSolver()
Destructor.
label nPoints() const
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
A primitive field of type <T> with automated input and output.
Definition: IOField.H:50
Namespace for OpenFOAM.