PatchToPatchInterpolation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 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 // Construct from components
109 template<class FromPatch, class ToPatch>
110 PatchToPatchInterpolation<FromPatch, ToPatch>::PatchToPatchInterpolation
111 (
112  const FromPatch& fromPatch,
113  const ToPatch& toPatch,
115  const intersection::direction dir
116 )
117 :
118  fromPatch_(fromPatch),
119  toPatch_(toPatch),
120  alg_(alg),
121  dir_(dir),
122  pointAddressingPtr_(NULL),
123  pointWeightsPtr_(NULL),
124  pointDistancePtr_(NULL),
125  faceAddressingPtr_(NULL),
126  faceWeightsPtr_(NULL),
127  faceDistancePtr_(NULL)
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
132 
133 template<class FromPatch, class ToPatch>
135 {
136  clearOut();
137 }
138 
139 
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 
142 template<class FromPatch, class ToPatch>
143 const scalarField&
146 {
147  if (!pointDistancePtr_)
148  {
149  calcPointAddressing();
150  }
151 
152  return *pointDistancePtr_;
153 }
154 
155 
156 template<class FromPatch, class ToPatch>
157 const scalarField&
160 {
161  if (!faceDistancePtr_)
162  {
163  calcFaceAddressing();
164  }
165 
166  return *faceDistancePtr_;
167 }
168 
169 
170 template<class FromPatch, class ToPatch>
172 {
173  clearOut();
174 
175  return true;
176 }
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 # include "CalcPatchToPatchWeights.C"
186 # include "PatchToPatchInterpolate.C"
187 
188 // ************************************************************************* //
const scalarField & pointDistanceToIntersection() const
Return distance to intersection for patch points.
void deleteDemandDrivenData(DataPtr &dataPtr)
Namespace for OpenFOAM.
const double e
Elementary charge.
Definition: doubleFloat.H:78
bool movePoints()
Correct weighting factors for moving mesh.
Template functions to aid in the implementation of demand driven data.
const scalarField & faceDistanceToIntersection() const
Return distance to intersection for patch face centres.
Patch to patch interpolation functions.
List< label > labelList
A List of labels.
Definition: labelList.H:56