Report patch name instead of index in debug
[foam-extend-3.2.git] / src / foam / interpolations / MixingPlaneInterpolation / MixingPlaneInterpolationTemplate.C
blob035af22c48afca2662aa8688977dabc913d2f7d1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Description
25     Mixing plane class dealing with transfer of data between two
26     primitivePatches
28 Author
29     Martin Beaudoin, Hydro-Quebec, 2009.  All rights reserved
31 Contributor
32     Hrvoje Jasak, Wikki Ltd.
34 \*---------------------------------------------------------------------------*/
36 #include "MixingPlaneInterpolationTemplate.H"
37 #include "demandDrivenData.H"
38 #include "PrimitivePatchTemplate.H"
39 #include "IOmanip.H"
40 #include "transform.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
49 template<class MasterPatch, class SlavePatch>
50 Foam::direction
51 MixingPlaneInterpolation<MasterPatch, SlavePatch>::sweepAxisSwitch() const
53     // SweepAxis switch
54     switch (sweepAxisType_)
55     {
56         case SWEEP_X:
57         case SWEEP_R:
58         {
59             return vector::X;
60         }
61         break;
63         case SWEEP_Y:
64         case SWEEP_THETA:
65         {
66             return vector::Y;
67         }
68         break;
70         case SWEEP_Z:
71         {
72             return vector::Z;
73         }
74         break;
76         default:
77         {
78             FatalErrorIn
79             (
80                 "direction MixingPlaneInterpolation<MasterPatch, "
81                 "SlavePatch>::sweepAxisSwitch() const"
82             )   << "Bad sweepAxis type: "
83                 << MixingPlaneInterpolationName::sweepAxisNames_
84                        [sweepAxisType_]
85                 << "Available types: "
86                 << MixingPlaneInterpolationName::sweepAxisNames_
87                 << abort(FatalError);
89             // Dummy return
90             return vector::X;
91         }
92     }
96 template<class MasterPatch, class SlavePatch>
97 Foam::direction
98 MixingPlaneInterpolation<MasterPatch, SlavePatch>::stackAxisSwitch() const
100     // stackAxis switch
101     switch (stackAxisType_)
102     {
103         case STACK_X:
104         case STACK_R:
105         {
106             return vector::X;
107         }
108         break;
110         case STACK_Y:
111         case STACK_THETA:
112         {
113             return vector::Y;
114         }
115         break;
117         case STACK_Z:
118         {
119             return vector::Z;
120         }
121         break;
123         default:
124         {
125             FatalErrorIn
126             (
127                 "direction MixingPlaneInterpolation<MasterPatch, "
128                 "SlavePatch>::stackAxisSwitch() const"
129             )   << "Bad stackAxis type: "
130                 << MixingPlaneInterpolationName::stackAxisNames_
131                        [stackAxisType_]
132                 << "Available types: "
133                 << MixingPlaneInterpolationName::stackAxisNames_
134                 << abort(FatalError);
136             // Dummy return
137             return vector::X;
138         }
139     }
143 template<class MasterPatch, class SlavePatch>
144 void MixingPlaneInterpolation<MasterPatch, SlavePatch>::clearOut()
146     clearTransfomedPatches();
147     clearMixingPlanePatch();
149     clearAddressing();
150     clearTransforms();
154 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
156 template<class MasterPatch, class SlavePatch>
157 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
158 MixingPlaneInterpolation
160     const MasterPatch& masterPatch,
161     const SlavePatch& slavePatch,
162     const coordinateSystem& cs,
163     const MixingPlaneInterpolationName::discretisation& discretisationType,
164     const MixingPlaneInterpolationName::sweepAxis& sweepAxisType,
165     const MixingPlaneInterpolationName::stackAxis& stackAxisType,
166     const pointField& interpolationProfile
169     masterPatch_(masterPatch),
170     slavePatch_(slavePatch),
171     cs_(cs),
172     discretisationType_(discretisationType),
173     sweepAxisType_(sweepAxisType),
174     stackAxisType_(stackAxisType),
175     interpolationProfile_(interpolationProfile),
177     forwardT_(),
178     reverseT_(),
179     forwardSep_(),
181     transformedMasterPatchPtr_(NULL),
182     transformedShadowPatchPtr_(NULL),
183     mixingPlanePatchPtr_(NULL),
185     masterPatchToProfileTPtr_(NULL),
186     masterProfileToPatchTPtr_(NULL),
187     slavePatchToProfileTPtr_(NULL),
188     slaveProfileToPatchTPtr_(NULL),
190     masterPatchToProfileAddrPtr_(NULL),
191     masterProfileToPatchAddrPtr_(NULL),
192     masterPatchToProfileWeightsPtr_(NULL),
193     masterProfileToPatchWeightsPtr_(NULL),
195     slavePatchToProfileAddrPtr_(NULL),
196     slaveProfileToPatchAddrPtr_(NULL),
197     slavePatchToProfileWeightsPtr_(NULL),
198     slaveProfileToPatchWeightsPtr_(NULL)
201     // Check size of transform.  They should be equal to slave patch size
202     // if the transform is not constant
203     if (forwardT_.size() > 1 || reverseT_.size() > 1)
204     {
205         if
206         (
207             forwardT_.size() != slavePatch_.size()
208          || reverseT_.size() != masterPatch_.size()
209         )
210         {
211             FatalErrorIn
212             (
213                 "MixingPlaneInterpolation<MasterPatch, "
214                 "SlavePatch>::MixingPlaneInterpolation"
215             )   << "Incorrectly defined transform: forwardT: "
216                 << forwardT_.size() << " patch: " << slavePatch_.size()
217                 << " reverseT: " << reverseT_.size()
218                 << " patch: " << masterPatch_.size()
219                 << abort(FatalError);
220         }
221     }
223     masterPatchToProfileAddr();
227 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
229 template<class MasterPatch, class SlavePatch>
230 MixingPlaneInterpolation<MasterPatch, SlavePatch>::~MixingPlaneInterpolation()
232     clearOut();
236 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
238 template<class MasterPatch, class SlavePatch>
239 const Foam::standAlonePatch&
240 MixingPlaneInterpolation<MasterPatch, SlavePatch>::mixingPlanePatch() const
242     if (!mixingPlanePatchPtr_)
243     {
244         calcMixingPlanePatch();
245     }
247     return *mixingPlanePatchPtr_;
251 template<class MasterPatch, class SlavePatch>
252 const Foam::standAlonePatch&
253 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
254 transformedMasterPatch() const
256     if (!transformedMasterPatchPtr_)
257     {
258         calcTransformedPatches();
259     }
261     return *transformedMasterPatchPtr_;
265 template<class MasterPatch, class SlavePatch>
266 const Foam::standAlonePatch&
267 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
268 transformedShadowPatch() const
270     if (!transformedShadowPatchPtr_)
271     {
272         calcTransformedPatches();
273     }
275     return *transformedShadowPatchPtr_;
279 template<class MasterPatch, class SlavePatch>
280 const labelListList&
281 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
282 masterPatchToProfileAddr() const
284     if (!masterPatchToProfileAddrPtr_)
285     {
286         calcAddressing();
287     }
289     return *masterPatchToProfileAddrPtr_;
293 template<class MasterPatch, class SlavePatch>
294 const labelListList&
295 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
296 masterProfileToPatchAddr() const
298     if (!masterProfileToPatchAddrPtr_)
299     {
300         calcAddressing();
301     }
303     return *masterProfileToPatchAddrPtr_;
307 template<class MasterPatch, class SlavePatch>
308 const scalarListList&
309 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
310 masterPatchToProfileWeights() const
312     if (!masterPatchToProfileWeightsPtr_)
313     {
314         calcAddressing();
315     }
317     return *masterPatchToProfileWeightsPtr_;
321 template<class MasterPatch, class SlavePatch>
322 const scalarListList&
323 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
324 masterProfileToPatchWeights() const
326     if (!masterProfileToPatchWeightsPtr_)
327     {
328         calcAddressing();
329     }
331     return *masterProfileToPatchWeightsPtr_;
335 template<class MasterPatch, class SlavePatch>
336 const labelListList&
337 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
338 slavePatchToProfileAddr() const
340     if (!slavePatchToProfileAddrPtr_)
341     {
342         calcAddressing();
343     }
345     return *slavePatchToProfileAddrPtr_;
349 template<class MasterPatch, class SlavePatch>
350 const labelListList&
351 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
352 slaveProfileToPatchAddr() const
354     if (!slaveProfileToPatchAddrPtr_)
355     {
356         calcAddressing();
357     }
359     return *slaveProfileToPatchAddrPtr_;
363 template<class MasterPatch, class SlavePatch>
364 const scalarListList&
365 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
366 slavePatchToProfileWeights() const
368     if (!slavePatchToProfileWeightsPtr_)
369     {
370         calcAddressing();
371     }
373     return *slavePatchToProfileWeightsPtr_;
377 template<class MasterPatch, class SlavePatch>
378 const scalarListList&
379 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
380 slaveProfileToPatchWeights() const
382     if (!slaveProfileToPatchWeightsPtr_)
383     {
384         calcAddressing();
385     }
387     return *slaveProfileToPatchWeightsPtr_;
391 template<class MasterPatch, class SlavePatch>
392 const tensorField&
393 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
394 masterPatchToProfileT() const
396     if (!masterPatchToProfileTPtr_)
397     {
398         calcTransforms();
399     }
401     return *masterPatchToProfileTPtr_;
405 template<class MasterPatch, class SlavePatch>
406 const tensorField&
407 MixingPlaneInterpolation<MasterPatch, SlavePatch>::
408 masterProfileToPatchT() const
410     if (!masterProfileToPatchTPtr_)
411     {
412         calcTransforms();
413     }
415     return *masterProfileToPatchTPtr_;
419 template<class MasterPatch, class SlavePatch>
420 const tensorField&
421 MixingPlaneInterpolation<MasterPatch, SlavePatch>::slavePatchToProfileT() const
423     if (!slavePatchToProfileTPtr_)
424     {
425         calcTransforms();
426     }
428     return *slavePatchToProfileTPtr_;
432 template<class MasterPatch, class SlavePatch>
433 const tensorField&
434 MixingPlaneInterpolation<MasterPatch, SlavePatch>::slaveProfileToPatchT() const
436     if (!slaveProfileToPatchTPtr_)
437     {
438         calcTransforms();
439     }
441     return *slaveProfileToPatchTPtr_;
445 template<class MasterPatch, class SlavePatch>
446 bool MixingPlaneInterpolation<MasterPatch, SlavePatch>::movePoints()
448     clearOut();
450     return true;
454 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
456 } // End namespace Foam
458 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
461 // ************************************************************************* //