1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "pointPatchMapper.H"
28 #include "pointPatch.H"
29 #include "mapPolyMesh.H"
30 #include "faceMapper.H"
31 #include "demandDrivenData.H"
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35 void Foam::pointPatchMapper::calcAddressing() const
40 || interpolationAddrPtr_
46 "void pointPatchMapper::calcAddressing() const"
47 ) << "Addressing already calculated"
54 directAddrPtr_ = new labelList(mpm_.patchPointMap()[patch_.index()]);
55 labelList& addr = *directAddrPtr_;
67 // Interpolative mapping.
70 // FOR NOW only takes first patch point instead of averaging all
71 // patch points. Problem is we don't know what points were in the patch
72 // for points that were merged.
74 interpolationAddrPtr_ = new labelListList(size());
75 labelListList& addr = *interpolationAddrPtr_;
77 weightsPtr_ = new scalarListList(addr.size());
78 scalarListList& w = *weightsPtr_;
80 const labelList& ppm = mpm_.patchPointMap()[patch_.index()];
86 addr[i] = labelList(1, ppm[i]);
87 w[i] = scalarList(1, 1.0);
91 // Inserted point. Map from point0 (arbitrary choice)
92 addr[i] = labelList(1, 0);
93 w[i] = scalarList(1, 1.0);
100 void Foam::pointPatchMapper::clearOut()
102 deleteDemandDrivenData(directAddrPtr_);
103 deleteDemandDrivenData(interpolationAddrPtr_);
104 deleteDemandDrivenData(weightsPtr_);
108 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
110 // Construct from components
111 Foam::pointPatchMapper::pointPatchMapper
113 const pointPatch& patch,
114 const pointMapper& pointMap,
115 const mapPolyMesh& mpm
118 pointPatchFieldMapper(),
120 pointMapper_(pointMap),
124 patch_.index() < mpm_.oldPatchNMeshPoints().size()
125 ? mpm_.oldPatchNMeshPoints()[patch_.index()]
128 directAddrPtr_(NULL),
129 interpolationAddrPtr_(NULL),
134 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
136 Foam::pointPatchMapper::~pointPatchMapper()
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 const Foam::unallocLabelList& Foam::pointPatchMapper::directAddressing() const
150 "const unallocLabelList& pointPatchMapper::directAddressing() const"
151 ) << "Requested direct addressing for an interpolative mapper."
152 << abort(FatalError);
160 return *directAddrPtr_;
164 const Foam::labelListList& Foam::pointPatchMapper::addressing() const
170 "const labelListList& pointPatchMapper::addressing() const"
171 ) << "Requested interpolative addressing for a direct mapper."
172 << abort(FatalError);
175 if (!interpolationAddrPtr_)
180 return *interpolationAddrPtr_;
184 const Foam::scalarListList& Foam::pointPatchMapper::weights() const
190 "const scalarListList& pointPatchMapper::weights() const"
191 ) << "Requested interpolative weights for a direct mapper."
192 << abort(FatalError);
204 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
207 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
210 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
213 // ************************************************************************* //