Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
36namespace Foam
37{
38
39// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40
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
70Foam::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{
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
94Foam::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{
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
118Foam::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
133Foam::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 )
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 (
196 meshPoints()
197 )
198 );
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 }
215 return pointNormalsPtr_();
216}
217
218
219void Foam::meshPointPatch::write(Ostream& os) const
220{
222 meshPoints().writeEntry("meshPoints", os);
223 constraints().writeEntry("constraints", os);
224}
225
226
227// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
pointPatch with explicitly provided points instead of using the points of a polyPatch.
virtual const pointField & localPoints() const
Return pointField of points in patch.
virtual label size() const
Return size.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
autoPtr< pointField > localPointsPtr_
Demand-driven local points.
virtual void write(Ostream &) const
Write the pointPatch data as a dictionary.
autoPtr< pointField > pointNormalsPtr_
Demand-driven local normals (assumes constructed with pointNormals.
virtual const List< pointConstraint > & constraints() const
Return constraints.
const List< pointConstraint > constraints_
virtual const labelList & meshPoints() const
Return mesh points.
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
const labelList meshPoints_
Explicit mesh points.
virtual const vectorField & pointNormals() const
Return point unit normals. Assumes single constraint.
label index() const noexcept
The index of this patch in the boundaryMesh.
A pointBoundaryMesh is a pointPatch list with registered IO, a reference to the associated pointMesh,...
Accumulates point constraints through successive applications of the applyConstraint function.
Basic pointPatch represents a set of points from the mesh.
Definition pointPatch.H:67
virtual void write(Ostream &) const
Write the pointPatch data as a dictionary.
Definition pointPatch.C:41
const pointBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition pointPatch.H:250
friend class pointBoundaryMesh
Definition pointPatch.H:81
pointPatch(const pointPatch &)=delete
No copy construct.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
volScalarField & p
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
static List< pointConstraint > makeConstraints(const vectorField &normals)
List< label > labelList
A List of labels.
Definition List.H:62
Field< vector > vectorField
Specialisation of Field<T> for vector.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299