All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
regionCoupledBase.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-2020 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 Class
25  Foam::regionCoupledBase
26 
27 Description
28  Base class with common functionality for regionCoupled polyPatch.
29  It includes AMI.
30 
31 
32 SourceFiles
33  regionCoupledBase.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef regionCoupledBase_H
38 #define regionCoupledBase_H
39 
40 #include "AMIInterpolation.H"
41 #include "polyBoundaryMesh.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class regionCoupledBase Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 {
54  // Private Data
55 
56  //- Patch to sample
57  const polyPatch& patch_;
58 
59  //- Name of other half
60  const word nbrPatchName_;
61 
62  //- Index of other half
63  mutable label nbrPatchID_;
64 
65  //- Name of other region
66  const word nbrRegionName_;
67 
68  //- Same region
69  const bool sameRegion_;
70 
71  //- AMI interpolation class
72  mutable autoPtr<AMIInterpolation> AMIPtr_;
73 
74  //- Flag to indicate that slave patch should be reversed for AMI
75  const bool AMIReverse_;
76 
77  //- Projection surface
78  mutable autoPtr<searchableSurface> surfPtr_;
79 
80  //- Dictionary used during projection surface construction
81  const dictionary surfDict_;
82 
83 
84  // Private Member Functions
85 
86  //- Reset the AMI interpolator
87  void resetAMI() const;
88 
89 
90 protected:
91 
92 
93  //- Clear geometry
94  virtual void clearGeom();
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("regionCoupledBase");
101 
102 
103  // Constructors
104 
105  //- Construct from patch
107 
108  //- Construct from dictionary
109  regionCoupledBase(const polyPatch&, const dictionary&);
110 
111  //- Construct as copy, resetting patch
113 
114 
115  //- Destructor
116  virtual ~regionCoupledBase();
117 
118 
119  // Member Functions
120 
121 
122  // Access
123 
124  //- Neighbour patch name
125  const word& nbrPatchName() const
126  {
127  return nbrPatchName_;
128  }
129 
130  //- Neighbour region name
131  const word& nbrRegionName() const
132  {
133  return nbrRegionName_;
134  }
135 
136  //- Cached sampleRegion != mesh.name()
137  bool sameRegion() const
138  {
139  return sameRegion_;
140  }
141 
142  //- Neighbour patch ID
143  label nbrPatchID() const;
144 
145  //- Does this side own the patch?
146  bool owner() const;
147 
148  //- Return a reference to the neighbour patch
149  const regionCoupledBase& nbrPatch() const;
150 
151  //- Return a reference to the projection surface
152  const autoPtr<searchableSurface>& surfPtr() const;
153 
154  //- Return a reference to the AMI interpolator
155  const AMIInterpolation& AMI() const;
156 
157 
158  // Interpolations
159 
160  //- Interpolate field
161  template<class Type>
163 
164  //- Interpolate tmp field
165  template<class Type>
167  (
168  const tmp<Field<Type>>& tFld
169  ) const;
170 
171  //- Low-level interpolate List
172  template<class Type, class BinaryOp>
173  void interpolate
174  (
175  const UList<Type>& fld,
176  const BinaryOp& bop,
177  List<Type>& result
178  ) const;
179 
180 
181  //- Return new ordering for primitivePatch.
182  // Ordering is -faceMap: for every face
183  // index of the new face -rotation:for every new face the clockwise
184  // shift of the original face. Return false if nothing changes
185  // (faceMap is identity, rotation is 0), true otherwise.
186  virtual bool order
187  (
189  const primitivePatch&,
191  labelList& rotation
192  ) const;
193 
194 
195  //- Return the type
196  virtual const word& regionCoupleType() const = 0;
197 
198  //- Write the polyPatch data as a dictionary
199  virtual void write(Ostream&) const;
200 };
201 
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace Foam
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #ifdef NoRepository
211 #endif
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #endif
216 
217 // ************************************************************************* //
Base class with common functionality for regionCoupled polyPatch. It includes AMI.
label nbrPatchID() const
Neighbour patch ID.
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
const regionCoupledBase & nbrPatch() const
Return a reference to the neighbour patch.
virtual void clearGeom()
Clear geometry.
const AMIInterpolation & AMI() const
Return a reference to the AMI interpolator.
bool owner() const
Does this side own the patch?
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A list of faces which address into the list of points.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Pre-declare SubField and related Field type.
Definition: Field.H:56
A class for handling words, derived from string.
Definition: word.H:59
virtual const word & regionCoupleType() const =0
Return the type.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
TypeName("regionCoupledBase")
Runtime type information.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual ~regionCoupledBase()
Destructor.
tmp< Field< Type > > interpolate(const Field< Type > &fld) const
Interpolate field.
bool sameRegion() const
Cached sampleRegion != mesh.name()
regionCoupledBase(const polyPatch &)
Construct from patch.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
const word & nbrRegionName() const
Neighbour region name.
const word & nbrPatchName() const
Neighbour patch name.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
A class for managing temporary objects.
Definition: PtrList.H:53
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
const autoPtr< searchableSurface > & surfPtr() const
Return a reference to the projection surface.
Namespace for OpenFOAM.