mappedPatchBaseI.H
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-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 
28 {
29  return mode_;
30 }
31 
32 
34 {
35  if (sampleRegion_.empty())
36  {
37  if (!coupleGroup_.valid())
38  {
40  << "Supply either a regionName or a coupleGroup"
41  << " for patch " << patch_.name()
42  << " in region " << patch_.boundaryMesh().mesh().name()
43  << exit(FatalError);
44  }
45 
46  // Try and use patchGroup to find samplePatch and sampleRegion
47  label samplePatchID = coupleGroup_.findOtherPatchID
48  (
49  patch_,
51  );
52 
53  samplePatch_ = sampleMesh().boundaryMesh()[samplePatchID].name();
54  }
55  return sampleRegion_;
56 }
57 
58 
60 {
61  if (samplePatch_.empty())
62  {
63  if (!coupleGroup_.valid())
64  {
66  << "Supply either a patchName or a coupleGroup"
67  << " for patch " << patch_.name()
68  << " in region " << patch_.boundaryMesh().mesh().name()
69  << exit(FatalError);
70  }
71 
72  // Try and use patchGroup to find samplePatch and sampleRegion
73  label samplePatchID = coupleGroup_.findOtherPatchID
74  (
75  patch_,
77  );
78 
79  samplePatch_ = sampleMesh().boundaryMesh()[samplePatchID].name();
80  }
81  return samplePatch_;
82 }
83 
84 
86 {
87  return coupleGroup_.name();
88 }
89 
90 
92 {
93  switch (mode_)
94  {
96  {
97  return samplePolyPatch().size();
98  }
99  case NEARESTCELL:
100  {
101  return sampleMesh().nCells();
102  }
103  case NEARESTPATCHFACE:
104  {
105  return samplePolyPatch().size();
106  }
107  case NEARESTPATCHPOINT:
108  {
109  return samplePolyPatch().nPoints();
110  }
111  case NEARESTFACE:
112  {
113  const polyMesh& mesh = sampleMesh();
114  return mesh.nFaces() - mesh.nInternalFaces();
115  }
116  default:
117  {
119  << "problem." << abort(FatalError);
120  return -1;
121  }
122  }
123 }
124 
125 
127 {
128  return offset_;
129 }
130 
131 
133 {
134  return offsets_;
135 }
136 
137 
139 {
140  return sameRegion_;
141 }
142 
143 
145 {
146  if (mapPtr_.empty())
147  {
148  calcMapping();
149  }
150 
151  return mapPtr_();
152 }
153 
154 
156 (
157  bool forceUpdate
158 ) const
159 {
160  if (forceUpdate || AMIPtr_.empty())
161  {
162  calcAMI();
163  }
164 
165  return AMIPtr_();
166 }
167 
168 
169 // ************************************************************************* //
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:453
word samplePatch_
Patch (if in sampleMode NEARESTPATCH*)
label nPoints() const
Return number of points supporting patch faces.
vector offset_
Offset vector (uniform)
const word & name() const
Return name.
const word & name() const
Return name.
Definition: IOobject.H:315
bool sameRegion() const
Cached sampleRegion != mesh.name()
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
word sampleRegion_
Region to sample.
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
const polyPatch & patch_
Patch to sample.
const polyMesh & sampleMesh() const
Get the region mesh.
label nInternalFaces() const
bool sameRegion_
Same region.
label nFaces() const
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:297
const coupleGroupIdentifier coupleGroup_
PatchGroup (if in sampleMode NEARESTPATCH*)
label nCells() const
fvMesh & mesh
autoPtr< AMIInterpolation > AMIPtr_
Pointer to AMI interpolator.
vectorField offsets_
Offset vector (nonuniform)
const AMIInterpolation & AMI(const bool forceUpdate=false) const
Return reference to the AMI interpolator.
const sampleMode & mode() const
What to sample.
bool valid() const
Is a valid patchGroup.
A class for handling words, derived from string.
Definition: word.H:59
const distributionMap & map() const
Return reference to the parallel distribution map.
void calcMapping() const
Calculate mapping.
const polyMesh & mesh() const
Return the mesh reference.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const vector & offset() const
Offset vector (from patch faces to destination mesh objects)
label sampleSize() const
Return size of mapped mesh/patch/boundary.
const word & name() const
Name of patchGroup.
Class containing processor-to-processor mapping information.
void calcAMI() const
Calculate AMI interpolator.
const word & coupleGroup() const
PatchGroup (only if NEARESTPATCHFACE)
sampleMode
Mesh items to sample.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
const vectorField & offsets() const
Offset vector (from patch faces to destination mesh objects)
const word & samplePatch() const
Patch (only if NEARESTPATCHFACE)
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
const word & sampleRegion() const
Region to sample.
const polyPatch & samplePolyPatch() const
Get the patch on the region.
autoPtr< distributionMap > mapPtr_
Communication schedule:
const sampleMode mode_
What to sample.