mappedPatchBaseI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2013 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  {
39  FatalErrorIn("mappedPatchBase::sampleRegion()")
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  {
65  FatalErrorIn("mappedPatchBase::samplePolyPatch()")
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  {
118  FatalErrorIn("mappedPatchBase::sampleSize()")
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 // ************************************************************************* //
vector offset_
Offset vector (uniform)
word samplePatch_
Patch (if in sampleMode NEARESTPATCH*)
autoPtr< AMIPatchToPatchInterpolation > AMIPtr_
Pointer to AMI interpolator.
label nFaces() const
autoPtr< mapDistribute > mapPtr_
Communication schedule:
const word & coupleGroup() const
PatchGroup (only if NEARESTPATCHFACE)
const word & name() const
Return name.
const polyMesh & sampleMesh() const
Get the region mesh.
const word & samplePatch() const
Patch (only if NEARESTPATCHFACE)
Class containing processor-to-processor mapping information.
bool valid() const
Is a valid patchGroup.
const word & name() const
Name of patchGroup.
const coupleGroupIdentifier coupleGroup_
PatchGroup (if in sampleMode NEARESTPATCH*)
A class for handling words, derived from string.
Definition: word.H:59
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
word sampleRegion_
Region to sample.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
label nCells() const
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:278
dynamicFvMesh & mesh
const vectorField & offsets() const
Offset vector (from patch faces to destination mesh objects)
label nPoints() const
Return number of points supporting patch faces.
void calcAMI() const
Calculate AMI interpolator.
vectorField offsets_
Offset vector (nonuniform)
const mapDistribute & map() const
Return reference to the parallel distribution map.
bool sameRegion() const
Cached sampleRegion != mesh.name()
const polyPatch & samplePolyPatch() const
Get the patch on the region.
const sampleMode mode_
What to sample.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
const word & sampleRegion() const
Region to sample.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const word & name() const
Return name.
Definition: IOobject.H:260
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
const AMIPatchToPatchInterpolation & AMI(const bool forceUpdate=false) const
Return reference to the AMI interpolator.
label nInternalFaces() const
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
const sampleMode & mode() const
What to sample.
error FatalError
const polyMesh & mesh() const
Return the mesh reference.
const vector & offset() const
Offset vector (from patch faces to destination mesh objects)
sampleMode
Mesh items to sample.
void calcMapping() const
Calculate mapping.
const polyPatch & patch_
Patch to sample.
bool sameRegion_
Same region.
label sampleSize() const
Return size of mapped mesh/patch/boundary.