meshPointPatch.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) 2016 OpenFOAM Foundation
9  Copyright (C) 2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "meshPointPatch.H"
31 #include "pointMesh.H"
32 #include "pointConstraint.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 defineTypeNameAndDebug(meshPointPatch, 0);
42 
43 //- Needs run-time selection table on pointPatch, not facePointPatch
45 (
49 );
50 
52 {
53  List<pointConstraint> cs(normals.size());
54 
55  forAll(cs, i)
56  {
57  cs[i].applyConstraint(normals[i]);
58  }
59  return cs;
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 } // End namespace Foam
66 
67 
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 
70 Foam::meshPointPatch::meshPointPatch
71 (
72  const word& name,
73  const labelUList& meshPoints,
74  const List<pointConstraint>& constraints,
75  const label index,
76  const pointBoundaryMesh& bm,
77  const word& patchType
78 )
79 :
80  pointPatch(name, index, bm, word::null, wordList()),
81  meshPoints_(meshPoints),
82  constraints_(constraints)
83 {
84  if (meshPoints_.size() != constraints_.size())
85  {
86  FatalErrorInFunction << "patch " << name
87  << " size of meshPoints " << meshPoints_.size()
88  << " differs from size of constraints " << constraints_.size()
89  << exit(FatalError);
90  }
91 }
92 
93 
94 Foam::meshPointPatch::meshPointPatch
95 (
96  const word& name,
97  const labelUList& meshPoints,
98  const vectorField& pointNormals,
99  const label index,
100  const pointBoundaryMesh& bm,
101  const word& patchType
102 )
103 :
104  pointPatch(name, index, bm, word::null, wordList()),
105  meshPoints_(meshPoints),
106  constraints_(makeConstraints(pointNormals))
107 {
108  if (meshPoints_.size() != pointNormals.size())
109  {
110  FatalErrorInFunction << "patch " << name
111  << " size of meshPoints " << meshPoints_.size()
112  << " differs from size of pointNormals " << pointNormals.size()
113  << exit(FatalError);
114  }
115 }
116 
117 
118 Foam::meshPointPatch::meshPointPatch
119 (
120  const word& name,
121  const dictionary& dict,
122  const label index,
123  const pointBoundaryMesh& bm,
124  const word& patchType
125 )
126 :
127  pointPatch(name, dict, index, bm),
128  meshPoints_(dict.get<labelList>("meshPoints")),
129  constraints_(dict.get<List<pointConstraint>>("constraints"))
130 {}
131 
132 
133 Foam::meshPointPatch::meshPointPatch
134 (
135  const meshPointPatch& pp,
136  const pointBoundaryMesh& bm,
137  const label index,
138  const labelUList& mapAddressing,
139  const labelUList& reversePointMap
140 )
141 :
143  (
144  pp.name(),
145  labelList(reversePointMap, labelList(pp.meshPoints(), mapAddressing)),
146  List<pointConstraint>(pp.constraints(), mapAddressing),
147  index,
148  bm,
149  pp.type()
150  )
151 {}
152 
153 
154 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
155 
157 {
158  localPointsPtr_.reset(nullptr);
159 
160  // Recalculate the point normals? Something like
161  //if (owner())
162  //{
163  // const primitivePatch pp(mesh.boundaryMesh().faces(), mesh.points());
164  //
165  // for (const label pointi : meshPoints())
166  // {
167  // const auto fnd(pp.meshPointMap().find(pointi));
168  // if (fnd)
169  // {
170  // const label patchPointi = fnd();
171  // // Determine point patch equiv
172  //
173  // const auto& point
174  //
175  //
176 }
177 
178 
180 {
181  localPointsPtr_.reset(nullptr);
182  pointNormalsPtr_.reset(nullptr);
183  // Do what to constraints_? Don't know what the new mesh points are
184 }
185 
186 
188 {
189  if (!localPointsPtr_)
190  {
191  localPointsPtr_.reset
192  (
193  new pointField
194  (
195  boundaryMesh().mesh().mesh().points(),
196  meshPoints()
197  )
198  );
199  }
200  return localPointsPtr_();
201 }
202 
203 
205 {
206  if (!pointNormalsPtr_)
207  {
208  pointNormalsPtr_.reset(new vectorField(size()));
209  vectorField& pointNormals = pointNormalsPtr_();
210  forAll(constraints_, i)
211  {
212  pointNormals[i] = constraints_[i].second();
213  }
214  }
215  return pointNormalsPtr_();
216 }
217 
218 
219 void Foam::meshPointPatch::write(Ostream& os) const
220 {
222  meshPoints().writeEntry("meshPoints", os);
223  constraints().writeEntry("constraints", os);
224 }
225 
226 
227 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
pointPatch with explicitly provided points instead of using the points of a polyPatch.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
A pointBoundaryMesh is a pointPatch list with registered IO, a reference to the associated pointMesh...
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:600
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Definition: boundaryMesh.H:58
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
Definition: UList.H:76
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:286
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:801
static List< pointConstraint > makeConstraints(const vectorField &normals)
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
virtual const pointField & localPoints() const
Return pointField of points in patch.
const pointField & points
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual const vectorField & pointNormals() const
Return point unit normals. Assumes single constraint.
virtual void write(Ostream &) const
Write the pointPatch data as a dictionary.
Definition: pointPatch.C:41
Accumulates point constraints through successive applications of the applyConstraint function...
const word & name() const noexcept
The patch name.
virtual void write(Ostream &) const
Write the pointPatch data as a dictionary.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
Buffers for inter-processor communications streams (UOPstream, UIPstream).
List< word > wordList
List of word.
Definition: fileName.H:59
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
const labelList meshPoints_
Explicit mesh points.
void writeEntry(Ostream &os) const
Write the UList with its compound type.
Definition: UListIO.C:29
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
Definition: List.H:61
volScalarField & p
const List< pointConstraint > constraints_
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)