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
150 
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 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #endif
168 
169 // ************************************************************************* //
pointIndexHit.H
Foam::nearestFaceAMI::~nearestFaceAMI
virtual ~nearestFaceAMI()=default
Destructor.
Foam::nearestFaceAMI::calculate
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing and weights.
Definition: nearestFaceAMI.C:267
Foam::nearestFaceAMI::nearestFaceAMI
nearestFaceAMI(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
Definition: nearestFaceAMI.C:235
Foam::nearestFaceAMI::clone
virtual autoPtr< AMIInterpolation > clone() const
Construct and return a clone.
Definition: nearestFaceAMI.H:138
Foam::nearestFaceAMI::nearestEqOp::operator()
void operator()(nearestAndDist &x, const nearestAndDist &y) const
Definition: nearestFaceAMI.H:65
AMIInterpolation.H
Foam::nearestFaceAMI::TypeName
TypeName("nearestFaceAMI")
Runtime type information.
Foam::AMIInterpolation::requireMatch
bool requireMatch() const
Access to the requireMatch flag.
Definition: AMIInterpolationI.H:74
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::nearestFaceAMI::nearestAndDist
Tuple2< pointIndexHit, scalar > nearestAndDist
Definition: nearestFaceAMI.H:57
Foam::AMIInterpolation::lowWeightCorrection
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
Definition: AMIInterpolationI.H:99
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::AMIInterpolation
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
Definition: AMIInterpolation.H:79
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::AMIInterpolation::reverseTarget
bool reverseTarget() const
Access to the reverseTarget flag.
Definition: AMIInterpolationI.H:93
Foam::nearestFaceAMI::nearestEqOp
Helper class for finding nearest.
Definition: nearestFaceAMI.H:60
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:60
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79
Foam::nearestFaceAMI
Nearest-face Arbitrary Mesh Interface (AMI) method.
Definition: nearestFaceAMI.H:51