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