Report patch name instead of index in debug
[foam-extend-3.2.git] / src / foam / interpolations / GGIInterpolation / GGIInterpolation.C
blob35b42de232a34eec7f1724493c97aee9f71f6af9
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     Interpolation class dealing with transfer of data between two
26     primitivePatches
28 Author
29     Hrvoje Jasak, Wikki Ltd.
31 Contributor:
32     Martin Beaudoin, Hydro-Quebec, (2008)
34 \*---------------------------------------------------------------------------*/
36 #include "GGIInterpolationTemplate.H"
37 #include "demandDrivenData.H"
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 namespace Foam
44 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
46 template<class MasterPatch, class SlavePatch>
47 void GGIInterpolation<MasterPatch, SlavePatch>::clearOut()
49     deleteDemandDrivenData(masterAddrPtr_);
50     deleteDemandDrivenData(masterWeightsPtr_);
51     deleteDemandDrivenData(slaveAddrPtr_);
52     deleteDemandDrivenData(slaveWeightsPtr_);
54     deleteDemandDrivenData(uncoveredMasterAddrPtr_);
55     deleteDemandDrivenData(uncoveredSlaveAddrPtr_);
59 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
61 // Construct from components
62 template<class MasterPatch, class SlavePatch>
63 GGIInterpolation<MasterPatch, SlavePatch>::GGIInterpolation
65     const MasterPatch& masterPatch,
66     const SlavePatch&  slavePatch,
67     const tensorField& forwardT,
68     const tensorField& reverseT,
69     const vectorField& forwardSep,
70     const scalar masterNonOverlapFaceTol,
71     const scalar slaveNonOverlapFaceTol,
72     const bool rescaleGGIWeightingFactors,
73     const quickReject reject
76     masterPatch_(masterPatch),
77     slavePatch_(slavePatch),
78     forwardT_(forwardT),
79     reverseT_(reverseT),
80     forwardSep_(forwardSep),
81     masterNonOverlapFaceTol_(masterNonOverlapFaceTol),
82     slaveNonOverlapFaceTol_(slaveNonOverlapFaceTol),
83     rescaleGGIWeightingFactors_(rescaleGGIWeightingFactors),
84     reject_(reject),
85     masterAddrPtr_(NULL),
86     masterWeightsPtr_(NULL),
87     slaveAddrPtr_(NULL),
88     slaveWeightsPtr_(NULL),
89     uncoveredMasterAddrPtr_(NULL),
90     uncoveredSlaveAddrPtr_(NULL)
92     // Check size of transform.  They should be equal to slave patch size
93     // if the transform is not constant
94     if (forwardT_.size() > 1 || reverseT_.size() > 1)
95     {
96         if
97         (
98             forwardT_.size() != slavePatch_.size()
99          || reverseT_.size() != masterPatch_.size()
100         )
101         {
102             FatalErrorIn
103             (
104                 "GGIInterpolation<MasterPatch, SlavePatch>::GGIInterpolation"
105             )   << "Incorrectly defined transform: forwardT: "
106                 << forwardT_.size() << " patch: " << slavePatch_.size()
107                 << " reverseT: " << reverseT_.size()
108                 << " patch: " << masterPatch_.size()
109                 << abort(FatalError);
110         }
111     }
115 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
117 template<class MasterPatch, class SlavePatch>
118 GGIInterpolation<MasterPatch, SlavePatch>::~GGIInterpolation()
120     clearOut();
124 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
126 template<class MasterPatch, class SlavePatch>
127 const labelListList&
128 GGIInterpolation<MasterPatch, SlavePatch>::masterAddr() const
130     if (!masterAddrPtr_)
131     {
132         calcAddressing();
133     }
135     return *masterAddrPtr_;
139 template<class MasterPatch, class SlavePatch>
140 const scalarListList&
141 GGIInterpolation<MasterPatch, SlavePatch>::masterWeights() const
143     if (!masterWeightsPtr_)
144     {
145         calcAddressing();
146     }
148     return *masterWeightsPtr_;
152 template<class MasterPatch, class SlavePatch>
153 const labelListList&
154 GGIInterpolation<MasterPatch, SlavePatch>::slaveAddr() const
156     if (!slaveAddrPtr_)
157     {
158         calcAddressing();
159     }
161     return *slaveAddrPtr_;
165 template<class MasterPatch, class SlavePatch>
166 const scalarListList&
167 GGIInterpolation<MasterPatch, SlavePatch>::slaveWeights() const
169     if (!slaveWeightsPtr_)
170     {
171         calcAddressing();
172     }
174     return *slaveWeightsPtr_;
178 template<class MasterPatch, class SlavePatch>
179 const labelList&
180 GGIInterpolation<MasterPatch, SlavePatch>::uncoveredMasterFaces() const
182     if (!uncoveredMasterAddrPtr_)
183     {
184         calcAddressing();
185     }
187     return *uncoveredMasterAddrPtr_;
191 template<class MasterPatch, class SlavePatch>
192 const labelList&
193 GGIInterpolation<MasterPatch, SlavePatch>::uncoveredSlaveFaces() const
195     if (!uncoveredSlaveAddrPtr_)
196     {
197         calcAddressing();
198     }
200     return *uncoveredSlaveAddrPtr_;
204 template<class MasterPatch, class SlavePatch>
205 bool GGIInterpolation<MasterPatch, SlavePatch>::movePoints
207     const tensorField& forwardT,
208     const tensorField& reverseT,
209     const vectorField& forwardSep
212     this->forwardT_ = forwardT;
213     this->reverseT_ = reverseT;
214     this->forwardSep_ = forwardSep;
216     clearOut();
218     return true;
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 } // End namespace Foam
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 #   include "GGIInterpolationPolygonIntersection.C"
229 #   include "GGIInterpolationQuickRejectTests.C"
230 #   include "GGIInterpolationWeights.C"
231 #   include "GGIInterpolate.C"
233 // ************************************************************************* //