Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::nearestFaceAMI
28
29Description
30 Nearest-face Arbitrary Mesh Interface (AMI) method
31
32SourceFiles
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
45namespace Foam
46{
48/*---------------------------------------------------------------------------*\
49 Class nearestFaceAMI Declaration
50\*---------------------------------------------------------------------------*/
51
54 public AMIInterpolation
55{
56public:
57
59
60 //- Helper class for finding nearest
61 class nearestEqOp
62 {
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
83private:
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
112public:
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// ************************************************************************* //
scalar y
bool reverseTarget() const noexcept
Access to the reverseTarget flag.
AMIInterpolation(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
bool requireMatch() const noexcept
Return the requireMatch flag.
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition Tuple2.H:51
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Helper class for finding nearest.
void operator()(nearestAndDist &x, const nearestAndDist &y) const
Nearest-face Arbitrary Mesh Interface (AMI) method.
virtual autoPtr< AMIInterpolation > clone() const
Construct and return a clone.
TypeName("nearestFaceAMI")
Runtime type information.
virtual ~nearestFaceAMI()=default
Destructor.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing and weights.
Tuple2< pointIndexHit, scalar > nearestAndDist
nearestFaceAMI(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< scalarList > scalarListList
List of scalarList.
Definition scalarList.H:35
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
runTime write()
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68