nearestFaceAMI.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::nearestFaceAMI
28 
29 Description
30  Nearest-face Arbitrary Mesh Interface (AMI) method
31 
32 SourceFiles
33  nearestFaceAMI.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef nearestFaceAMI_H
38 #define nearestFaceAMI_H
39 
40 #include "AMIInterpolation.H"
41 #include "pointIndexHit.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class nearestFaceAMI Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class nearestFaceAMI
53 :
54  public AMIInterpolation
55 {
56 public:
57 
59 
60  //- Helper class for finding nearest
61  class nearestEqOp
62  {
63 
64  public:
65 
66  void operator()(nearestAndDist& x, const nearestAndDist& y) const
67  {
68  if (y.first().hit())
69  {
70  if (!x.first().hit())
71  {
72  x = y;
73  }
74  else if (y.second() < x.second())
75  {
76  x = y;
77  }
78  }
79  }
80  };
81 
82 
83 private:
84 
85  // Private Data
86 
87  //- Maximum squared distance
88  scalar maxDistance2_;
89 
90 
91  // Private Member Functions
92 
93  //- No copy assignment
94  void operator=(const nearestFaceAMI&) = delete;
95 
96  autoPtr<mapDistribute> calcFaceMap
97  (
98  const List<nearestAndDist>& localInfo,
99  const primitivePatch& srcPatch,
100  const primitivePatch& tgtPatch
101  ) const;
102 
103  autoPtr<mapDistribute> calcDistributed
104  (
105  const primitivePatch& src,
106  const primitivePatch& tgt,
107  labelListList& srcToTgtAddr,
108  scalarListList& srcToTgtWght
109  ) const;
110 
111 
112 public:
113 
114  //- Runtime type information
115  TypeName("nearestFaceAMI");
116 
117 
118  // Constructors
119 
120  //- Construct from dictionary
122  (
123  const dictionary& dict,
124  const bool reverseTarget = false
125  );
126 
127  //- Construct from components
129  (
130  const bool requireMatch = true,
131  const bool reverseTarget = false,
132  const scalar lowWeightCorrection = -1
133  );
134 
135  //- Construct as copy
136  nearestFaceAMI(const nearestFaceAMI& ami);
137 
138  //- Construct and return a clone
139  virtual autoPtr<AMIInterpolation> clone() const
140  {
141  return autoPtr<AMIInterpolation>(new nearestFaceAMI(*this));
142  }
143 
144 
145  //- Destructor
146  virtual ~nearestFaceAMI() = default;
147 
148 
149  // Member Functions
151  //- Update addressing and weights
152  virtual bool calculate
153  (
154  const primitivePatch& srcPatch,
155  const primitivePatch& tgtPatch,
156  const autoPtr<searchableSurface>& surfPtr = nullptr
157  );
158 
159  //- Write
160  virtual void write(Ostream& os) const;
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
Helper class for finding nearest.
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:54
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
bool requireMatch() const noexcept
Return the requireMatch flag.
Tuple2< pointIndexHit, scalar > nearestAndDist
scalar y
A list of faces which address into the list of points.
void operator()(nearestAndDist &x, const nearestAndDist &y) const
TypeName("nearestFaceAMI")
Runtime type information.
Nearest-face Arbitrary Mesh Interface (AMI) method.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
bool reverseTarget() const noexcept
Access to the reverseTarget flag.
virtual ~nearestFaceAMI()=default
Destructor.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing and weights.
virtual void write(Ostream &os) const
Write.
nearestFaceAMI(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
virtual autoPtr< AMIInterpolation > clone() const
Construct and return a clone.
Namespace for OpenFOAM.