PatchToPatchInterpolation.C
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-2018 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 
27 #include "demandDrivenData.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 template<class FromPatch, class ToPatch>
37 const scalar
38 PatchToPatchInterpolation<FromPatch, ToPatch>::directHitTol = 1e-5;
39 
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
41 
42 template<class FromPatch, class ToPatch>
43 const labelList&
44 PatchToPatchInterpolation<FromPatch, ToPatch>::pointAddr() const
45 {
46  if (!pointAddressingPtr_)
47  {
48  calcPointAddressing();
49  }
50 
51  return *pointAddressingPtr_;
52 }
53 
54 
55 template<class FromPatch, class ToPatch>
56 const FieldField<Field, scalar>&
57 PatchToPatchInterpolation<FromPatch, ToPatch>::pointWeights() const
58 {
59  if (!pointWeightsPtr_)
60  {
61  calcPointAddressing();
62  }
63 
64  return *pointWeightsPtr_;
65 }
66 
67 
68 template<class FromPatch, class ToPatch>
69 const labelList&
70 PatchToPatchInterpolation<FromPatch, ToPatch>::faceAddr() const
71 {
72  if (!faceAddressingPtr_)
73  {
74  calcFaceAddressing();
75  }
76 
77  return *faceAddressingPtr_;
78 }
79 
80 
81 template<class FromPatch, class ToPatch>
82 const FieldField<Field, scalar>&
83 PatchToPatchInterpolation<FromPatch, ToPatch>::faceWeights() const
84 {
85  if (!faceWeightsPtr_)
86  {
87  calcFaceAddressing();
88  }
89 
90  return *faceWeightsPtr_;
91 }
92 
93 
94 template<class FromPatch, class ToPatch>
95 void PatchToPatchInterpolation<FromPatch, ToPatch>::clearOut()
96 {
97  deleteDemandDrivenData(pointAddressingPtr_);
98  deleteDemandDrivenData(pointWeightsPtr_);
99  deleteDemandDrivenData(pointDistancePtr_);
100  deleteDemandDrivenData(faceAddressingPtr_);
101  deleteDemandDrivenData(faceWeightsPtr_);
102  deleteDemandDrivenData(faceDistancePtr_);
103 }
104 
105 
106 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
107 
108 template<class FromPatch, class ToPatch>
109 PatchToPatchInterpolation<FromPatch, ToPatch>::PatchToPatchInterpolation
110 (
111  const FromPatch& fromPatch,
112  const ToPatch& toPatch,
114  const intersection::direction dir
115 )
116 :
117  fromPatch_(fromPatch),
118  toPatch_(toPatch),
119  alg_(alg),
120  dir_(dir),
121  pointAddressingPtr_(nullptr),
122  pointWeightsPtr_(nullptr),
123  pointDistancePtr_(nullptr),
124  faceAddressingPtr_(nullptr),
125  faceWeightsPtr_(nullptr),
126  faceDistancePtr_(nullptr)
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
131 
132 template<class FromPatch, class ToPatch>
134 {
135  clearOut();
136 }
137 
138 
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 
141 template<class FromPatch, class ToPatch>
142 const scalarField&
145 {
146  if (!pointDistancePtr_)
147  {
148  calcPointAddressing();
149  }
150 
151  return *pointDistancePtr_;
152 }
153 
154 
155 template<class FromPatch, class ToPatch>
156 const scalarField&
159 {
160  if (!faceDistancePtr_)
161  {
162  calcFaceAddressing();
163  }
164 
165  return *faceDistancePtr_;
166 }
167 
168 
169 template<class FromPatch, class ToPatch>
171 {
172  clearOut();
173 
174  return true;
175 }
176 
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184  #include "CalcPatchToPatchWeights.C"
185  #include "PatchToPatchInterpolate.C"
186 
187 // ************************************************************************* //
const scalarField & faceDistanceToIntersection() const
Return distance to intersection for patch face centres.
const scalarField & pointDistanceToIntersection() const
Return distance to intersection for patch points.
List< label > labelList
A List of labels.
Definition: labelList.H:56
Template functions to aid in the implementation of demand driven data.
bool movePoints()
Correct weighting factors for moving mesh.
Patch to patch interpolation functions.
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:98
void deleteDemandDrivenData(DataPtr &dataPtr)
Namespace for OpenFOAM.