nonConformalMappedPatchBase.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) 2011-2025 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 
27 #include "nonConformalBoundary.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
34 }
35 
36 
37 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
38 
40 {
41  const polyPatch& pp = patch_.patch();
42 
43  const word& regionName = pp.boundaryMesh().mesh().name();
44  const word& patchName = pp.name();
45 
46  if (regionName != nbrRegionName())
47  {
48  return regionName < nbrRegionName();
49  }
50 
51  if (patchName != nbrPatchName())
52  {
53  return patchName < nbrPatchName();
54  }
55 
57  << "Patch " << patch_.patch().name() << " of type "
58  << nonConformalMappedPatchBase::typeName << " maps to itself"
59  << exit(FatalError);
60 
61  return false;
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 
68 (
69  const nonConformalPolyPatch& ncPp
70 )
71 :
72  mappedPatchBaseBase(ncPp.patch()),
73  patch_(ncPp),
74  owner_(calcOwner()),
75  intersectionIsValid_(0),
76  intersection_(false)
77 {}
78 
79 
81 (
82  const nonConformalPolyPatch& ncPp,
83  const word& nbrRegionName,
84  const word& nbrPatchName,
86  const bool owner
87 )
88 :
89  mappedPatchBaseBase(ncPp.patch(), nbrRegionName, nbrPatchName, transform),
90  patch_(ncPp),
91  owner_(owner),
92  intersectionIsValid_(0),
93  intersection_(false)
94 {}
95 
96 
98 (
99  const nonConformalPolyPatch& ncPp,
100  const dictionary& dict,
101  const transformType tt
102 )
103 :
104  mappedPatchBaseBase(ncPp.patch(), dict, tt),
105  patch_(ncPp),
106  owner_(dict.lookupOrDefault<bool>("owner", calcOwner())),
107  intersectionIsValid_(0),
108  intersection_(false)
109 {}
110 
111 
113 (
114  const nonConformalPolyPatch& ncPp,
115  const nonConformalMappedPatchBase& mpb
116 )
117 :
118  mappedPatchBaseBase(ncPp.patch(), mpb),
119  patch_(ncPp),
120  owner_(mpb.owner_),
121  intersectionIsValid_(0),
122  intersection_(false)
123 {}
124 
125 
126 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
127 
129 {}
130 
131 
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 
135 {
136  return owner_;
137 }
138 
139 
142 {
143  if (!owner())
144  {
146  << "The non-conformal mapped intersection is only available to "
147  << "the owner patch" << abort(FatalError);
148  }
149 
150  const label bothIntersectionIsValid =
151  min(intersectionIsValid_, nbrMappedPatch().intersectionIsValid_);
152 
153  const bool intersectionIsValid =
154  (bothIntersectionIsValid == 2)
155  || (
156  bothIntersectionIsValid == 1
158  (
159  patch_.origPatch(),
160  nbrMappedPatch().patch_.origPatch()
161  )
162  );
163 
164  if (!intersectionIsValid)
165  {
166  const polyMesh& mesh =
168 
170 
171  intersection_.update
172  (
173  patch_.origPatch(),
174  ncb.patchPointNormals(patch_.origPatchIndex()),
175  nbrMappedPatch().patch_.origPatch(),
176  transform_.transform(),
177  {
178  patch_.origPatchName()
179  + " in region "
180  + mesh.name(),
181  nbrMappedPatch().patch_.origPatchName()
182  + " in region "
183  + nbrRegionName()
184  },
185  transform_.str()
186  );
187 
188  intersectionIsValid_ = 2;
189 
190  nbrMappedPatch().intersectionIsValid_ = 2;
191  }
192 
193  return intersection_;
194 }
195 
196 
198 {
199  if (move && moveUpdate_ == moveUpdate::never)
200  {
201  // Do nothing
202  }
203  else if (move && moveUpdate_ == moveUpdate::detect)
204  {
205  intersectionIsValid_ = min(intersectionIsValid_, 1);
206  }
207  else
208  {
209  intersectionIsValid_ = 0;
210  }
211 }
212 
213 
215 {
217  writeEntry(os, "owner", owner_);
218 }
219 
220 
221 // ************************************************************************* //
static nonConformalBoundary & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
const word & name() const
Return name.
Definition: IOobject.H:307
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Cyclic plane transformation.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Base class for engines and poly patches which provide mapping between two poly patches.
const polyPatch & patch_
Patch to map to.
virtual void write(Ostream &) const
Write as a dictionary.
const word & nbrPatchName() const
Name of the patch to map from.
const word & nbrRegionName() const
Name of the region to map from.
transformType
The type of the transformation permitted/required by this patch.
static bool moving(const polyPatch &patch, const polyPatch &nbrPatch)
Return whether or not the patches have moved.
Mesh object that stores an all boundary patch and mapping to and from it and the mesh and the individ...
tmp< vectorField > patchPointNormals(const label patchi) const
Get parallel consistent point normals for the patch.
Base class for poly patches which provides non-conformal mapping between two potentially non-globally...
bool owner() const
Does this side own the patch?
virtual void write(Ostream &) const
Write as a dictionary.
const nonConformalPolyPatch & patch_
Non-conformal patch to map to.
void clearOut(const bool move)
Clear out data on mesh change.
nonConformalMappedPatchBase(const nonConformalPolyPatch &ncPp)
Construct from non-conformal patch.
const patchToPatches::intersection & intersection() const
Access the intersection engine.
bool calcOwner() const
Constructor helper for owner.
Non-conformal poly patch. This patch is a placeholder and must have no faces. This patch is linked to...
const polyPatch & patch() const
Reference to the polyPatch.
const word & name() const
Return name.
Class to generate patchToPatch coupling geometry. A full geometric intersection is done between a fac...
const polyMesh & mesh() const
Return the mesh reference.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:270
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const word & regionName(const solver &region)
Definition: solver.H:218
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:501
defineTypeNameAndDebug(combustionModel, 0)
error FatalError
dictionary dict