fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fvMesh / fvMeshMapper / fvSurfaceMapper.C
blob57652c46867ae5cb23b1e4768fb8a983b218c40a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 Description
26     FV surface mapper.
28 \*---------------------------------------------------------------------------*/
30 #include "fvSurfaceMapper.H"
31 #include "fvMesh.H"
32 #include "mapPolyMesh.H"
33 #include "faceMapper.H"
35 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
37 void Foam::fvSurfaceMapper::calcAddressing() const
39     if
40     (
41         directAddrPtr_
42      || interpolationAddrPtr_
43      || weightsPtr_
44      || insertedObjectLabelsPtr_
45     )
46     {
47         FatalErrorIn("void fvSurfaceMapper::calcAddressing() const)")
48             << "Addressing already calculated"
49             << abort(FatalError);
50     }
52     // Mapping
54     const label oldNInternal = faceMap_.nOldInternalFaces();
56     // Assemble the maps
57     if (direct())
58     {
59         // Direct mapping - slice to size
60         directAddrPtr_ =
61             new labelList
62             (
63                 labelList::subList(faceMap_.directAddressing(), size())
64             );
65         labelList& addr = *directAddrPtr_;
67         // Adjust for creation of an internal face from a boundary face
68         forAll (addr, faceI)
69         {
70             if (addr[faceI] >= oldNInternal)
71             {
72                 addr[faceI] = 0;
73             }
74         }
75     }
76     else
77     {
78         // Interpolative mapping - slice to size
79         interpolationAddrPtr_ =
80             new labelListList
81             (
82                 labelListList::subList(faceMap_.addressing(), size())
83             );
84         labelListList& addr = *interpolationAddrPtr_;
86         weightsPtr_ =
87             new scalarListList
88             (
89                 scalarListList::subList(faceMap_.weights(), size())
90             );
91         scalarListList& w = *weightsPtr_;
92         
93         // Adjust for creation of an internal face from a boundary face
94         forAll (addr, faceI)
95         {
96             if (max(addr[faceI]) >= oldNInternal)
97             {
98                 addr[faceI] = labelList(1, 0);
99                 w[faceI] = scalarList(1, 1.0);
100             }
101         }
102     }
104     // Inserted objects
106     // If there are, assemble the labels
107     if (insertedObjects())
108     {
109         const labelList& insFaces = faceMap_.insertedObjectLabels();
111         insertedObjectLabelsPtr_ = new labelList(insFaces.size());
112         labelList& ins = *insertedObjectLabelsPtr_;
114         label nIns = 0;
116         forAll (insFaces, faceI)
117         {
118             // If the face is internal, keep it here
119             if (insFaces[faceI] < size())
120             {
121                 ins[nIns] = insFaces[faceI];
122                 nIns++;
123             }
124         }
126         ins.setSize(nIns);
127     }
128     else
129     {
130         // No inserted objects
131         insertedObjectLabelsPtr_ = new labelList(0);
132     }
136 void Foam::fvSurfaceMapper::clearOut()
138     deleteDemandDrivenData(directAddrPtr_);
139     deleteDemandDrivenData(interpolationAddrPtr_);
140     deleteDemandDrivenData(weightsPtr_);
142     deleteDemandDrivenData(insertedObjectLabelsPtr_);
146 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
148 // Construct from components
149 Foam::fvSurfaceMapper::fvSurfaceMapper
151     const fvMesh& mesh,
152     const faceMapper& fMapper
155     mesh_(mesh),
156     faceMap_(fMapper),
157     directAddrPtr_(NULL),
158     interpolationAddrPtr_(NULL),
159     weightsPtr_(NULL),
160     insertedObjectLabelsPtr_(NULL)
164 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
166 Foam::fvSurfaceMapper::~fvSurfaceMapper()
168     clearOut();
172 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
174 const Foam::unallocLabelList& Foam::fvSurfaceMapper::directAddressing() const
176     if (!direct())
177     {
178         FatalErrorIn
179         (
180             "const unallocLabelList& fvSurfaceMapper::"
181             "directAddressing() const"
182         )   << "Requested direct addressing for an interpolative mapper."
183             << abort(FatalError);
184     }
186     if (!directAddrPtr_)
187     {
188         calcAddressing();
189     }
191     return *directAddrPtr_;
195 const Foam::labelListList& Foam::fvSurfaceMapper::addressing() const
197     if (direct())
198     {
199         FatalErrorIn
200         (
201             "const labelListList& fvSurfaceMapper::addressing() const"
202         )   << "Requested interpolative addressing for a direct mapper."
203             << abort(FatalError);
204     }
206     if (!interpolationAddrPtr_)
207     {
208         calcAddressing();
209     }
211     return *interpolationAddrPtr_;
215 const Foam::scalarListList& Foam::fvSurfaceMapper::weights() const
217     if (direct())
218     {
219         FatalErrorIn
220         (
221             "const scalarListList& fvSurfaceMapper::weights() const"
222         )   << "Requested interpolative weights for a direct mapper."
223             << abort(FatalError);
224     }
226     if (!weightsPtr_)
227     {
228         calcAddressing();
229     }
231     return *weightsPtr_;
235 const Foam::labelList& Foam::fvSurfaceMapper::insertedObjectLabels() const
237     if (!insertedObjectLabelsPtr_)
238     {
239         calcAddressing();
240     }
242     return *insertedObjectLabelsPtr_;
246 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
249 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
252 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
255 // ************************************************************************* //