1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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
29 Post-processing mesh subset tool. Given the original mesh and the
30 list of selected cells, it creates the mesh consisting only of the
31 desired cells, with the mapping list for points, faces, and cells.
33 Puts all exposed internal faces into either
34 - a user supplied patch
35 - a newly created patch "oldInternalFaces"
37 - setCellSubset is for small subsets. Uses Maps to minimize memory.
38 - setLargeCellSubset is for largish subsets (>10% of mesh).
39 Uses labelLists instead.
41 - setLargeCellSubset does coupled patch subsetting as well. If it detects
42 a face on a coupled patch 'losing' its neighbour it will move the
43 face into the oldInternalFaces patch.
45 - if a user supplied patch is used the mapping becomes a problem.
46 Do the new faces get the value of the internal face they came from?
47 What if e.g. the user supplied patch is a fixedValue 0? So for now
48 they get the face of existing patch face 0.
53 \*---------------------------------------------------------------------------*/
55 #ifndef fvMeshSubset_H
56 #define fvMeshSubset_H
59 #include "pointMesh.H"
60 #include "fvPatchFieldMapper.H"
61 #include "pointPatchFieldMapper.H"
62 #include "GeometricField.H"
64 #include "surfaceMesh.H"
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 /*---------------------------------------------------------------------------*\
72 Class fvMeshSubset Declaration
73 \*---------------------------------------------------------------------------*/
80 //- Patch-field subset interpolation class
81 class patchFieldSubset
83 public fvPatchFieldMapper
85 const labelList& directAddressing_;
91 //- Construct given addressing
92 patchFieldSubset(const labelList& directAddressing)
94 directAddressing_(directAddressing)
99 virtual ~patchFieldSubset()
107 return directAddressing_.size();
115 const unallocLabelList& directAddressing() const
117 return directAddressing_;
122 //- Patch-field subset interpolation class
123 class pointPatchFieldSubset
125 public pointPatchFieldMapper
127 const labelList& directAddressing_;
133 //- Construct given addressing
134 pointPatchFieldSubset(const labelList& directAddressing)
136 directAddressing_(directAddressing)
141 virtual ~pointPatchFieldSubset()
149 return directAddressing_.size();
157 const unallocLabelList& directAddressing() const
159 return directAddressing_;
168 //- Mesh to subset from
169 const fvMesh& baseMesh_;
171 //- Subset mesh pointer
172 autoPtr<fvMesh> fvMeshSubsetPtr_;
174 //- Point mapping array
177 //- Face mapping array
180 //- Cell mapping array
183 //- Patch mapping array
187 // Private Member Functions
189 //- Check if subset has been performed
190 bool checkCellSubset() const;
192 //- Mark points in Map
193 static void markPoints(const labelList&, Map<label>&);
195 //- Mark points (with 0) in labelList
196 static void markPoints(const labelList&, labelList&);
198 //- Adapt nCellsUsingFace for coupled faces becoming 'uncoupled'.
199 void doCoupledPatches
202 labelList& nCellsUsingFace
206 static labelList subset
209 const labelList& selectedElements,
210 const labelList& subsetMap
213 //- Create zones for submesh
216 //- Disallow default bitwise copy construct
217 fvMeshSubset(const fvMeshSubset&);
219 //- Disallow default bitwise assignment
220 void operator=(const fvMeshSubset&);
226 //- Construct given a mesh to subset
227 explicit fvMeshSubset(const fvMesh&);
234 //- Set the subset. Create "oldInternalFaces" patch for exposed
235 // internal faces (patchID==-1) or use supplied patch.
236 // Does not handle coupled patches correctly if only one side
240 const labelHashSet& globalCellMap,
241 const label patchID = -1
244 //- Set the subset from all cells with region == currentRegion.
245 // Create "oldInternalFaces" patch for exposed
246 // internal faces (patchID==-1) or use supplied patch.
247 // Handles coupled patches by if nessecary making coupled patch
248 // face part of patchID (so uncoupled)
249 void setLargeCellSubset
251 const labelList& region,
252 const label currentRegion,
253 const label patchID = -1,
254 const bool syncCouples = true
257 //- setLargeCellSubset but with labelHashSet.
258 void setLargeCellSubset
260 const labelHashSet& globalCellMap,
261 const label patchID = -1,
262 const bool syncPar = true
269 const fvMesh& baseMesh() const
274 //- Return reference to subset mesh
275 const fvMesh& subMesh() const;
280 const labelList& pointMap() const;
283 const labelList& faceMap() const;
286 const labelList& cellMap() const;
289 const labelList& patchMap() const;
296 static tmp<GeometricField<Type, fvPatchField, volMesh> >
299 const GeometricField<Type, fvPatchField, volMesh>&,
301 const labelList& patchMap,
302 const labelList& cellMap,
303 const labelList& faceMap
307 tmp<GeometricField<Type, fvPatchField, volMesh> >
310 const GeometricField<Type, fvPatchField, volMesh>&
313 //- Map surface field
315 static tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
318 const GeometricField<Type, fvsPatchField, surfaceMesh>&,
320 const labelList& patchMap,
321 const labelList& faceMap
325 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
328 const GeometricField<Type, fvsPatchField, surfaceMesh>&
333 static tmp<GeometricField<Type, pointPatchField, pointMesh> >
336 const GeometricField<Type, pointPatchField, pointMesh>&,
337 const pointMesh& sMesh,
338 const labelList& patchMap,
339 const labelList& pointMap
343 tmp<GeometricField<Type, pointPatchField, pointMesh> >
346 const GeometricField<Type, pointPatchField, pointMesh>&
351 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353 } // End namespace Foam
355 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358 # include "fvMeshSubsetInterpolate.C"
361 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
365 // ************************************************************************* //