FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 Description
25  Interpolation class dealing with transfer of data between two
26  primitivePatches
27 
28 \*---------------------------------------------------------------------------*/
29 
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
40 template<class FromPatch, class ToPatch>
41 const scalar
42 PatchToPatchInterpolation<FromPatch, ToPatch>::directHitTol = 1e-5;
43 
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 
46 template<class FromPatch, class ToPatch>
47 const labelList&
48 PatchToPatchInterpolation<FromPatch, ToPatch>::pointAddr() const
49 {
50  if (!pointAddressingPtr_)
51  {
52  calcPointAddressing();
53  }
54 
55  return *pointAddressingPtr_;
56 }
57 
58 
59 template<class FromPatch, class ToPatch>
60 const FieldField<Field, scalar>&
61 PatchToPatchInterpolation<FromPatch, ToPatch>::pointWeights() const
62 {
63  if (!pointWeightsPtr_)
64  {
65  calcPointAddressing();
66  }
67 
68  return *pointWeightsPtr_;
69 }
70 
71 
72 template<class FromPatch, class ToPatch>
73 const labelList&
74 PatchToPatchInterpolation<FromPatch, ToPatch>::faceAddr() const
75 {
76  if (!faceAddressingPtr_)
77  {
79  }
80 
81  return *faceAddressingPtr_;
82 }
83 
84 
85 template<class FromPatch, class ToPatch>
86 const FieldField<Field, scalar>&
87 PatchToPatchInterpolation<FromPatch, ToPatch>::faceWeights() const
88 {
89  if (!faceWeightsPtr_)
90  {
92  }
93 
94  return *faceWeightsPtr_;
95 }
96 
97 
98 template<class FromPatch, class ToPatch>
99 void PatchToPatchInterpolation<FromPatch, ToPatch>::clearOut()
100 {
101  deleteDemandDrivenData(pointAddressingPtr_);
102  deleteDemandDrivenData(pointWeightsPtr_);
103  deleteDemandDrivenData(pointDistancePtr_);
104  deleteDemandDrivenData(faceAddressingPtr_);
105  deleteDemandDrivenData(faceWeightsPtr_);
106  deleteDemandDrivenData(faceDistancePtr_);
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
111 
112 // Construct from components
113 template<class FromPatch, class ToPatch>
114 PatchToPatchInterpolation<FromPatch, ToPatch>::PatchToPatchInterpolation
115 (
116  const FromPatch& fromPatch,
117  const ToPatch& toPatch,
119  const intersection::direction dir
120 )
121 :
122  fromPatch_(fromPatch),
123  toPatch_(toPatch),
124  alg_(alg),
125  dir_(dir),
126  pointAddressingPtr_(NULL),
127  pointWeightsPtr_(NULL),
128  pointDistancePtr_(NULL),
129  faceAddressingPtr_(NULL),
130  faceWeightsPtr_(NULL),
131  faceDistancePtr_(NULL)
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
136 
137 template<class FromPatch, class ToPatch>
139 {
140  clearOut();
141 }
142 
143 
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 
146 template<class FromPatch, class ToPatch>
147 const scalarField&
150 {
151  if (!pointDistancePtr_)
152  {
153  calcPointAddressing();
154  }
155 
156  return *pointDistancePtr_;
157 }
158 
159 
160 template<class FromPatch, class ToPatch>
161 const scalarField&
164 {
165  if (!faceDistancePtr_)
166  {
168  }
169 
170  return *faceDistancePtr_;
171 }
172 
173 
174 template<class FromPatch, class ToPatch>
176 {
177  clearOut();
178 
179  return true;
180 }
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
191 
192 // ************************ vim: set sw=4 sts=4 et: ************************ //