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
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"
63 #include "labelHashSet.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 mutable autoPtr<pointMesh> pointMeshSubsetPtr_;
176 //- Point mapping array
179 //- Face mapping array
182 //- Cell mapping array
185 //- Patch mapping array
189 // Private Member Functions
191 //- Check if subset has been performed
192 bool checkCellSubset() const;
194 //- Mark points in Map
195 static void markPoints(const labelList&, Map<label>&);
197 //- Mark points (with 0) in labelList
198 static void markPoints(const labelList&, labelList&);
200 //- Adapt nCellsUsingFace for coupled faces becoming 'uncoupled'.
201 void doCoupledPatches
204 labelList& nCellsUsingFace
208 static labelList subset
211 const labelList& selectedElements,
212 const labelList& subsetMap
215 //- Create zones for submesh
218 //- Disallow default bitwise copy construct
219 fvMeshSubset(const fvMeshSubset&);
221 //- Disallow default bitwise assignment
222 void operator=(const fvMeshSubset&);
228 //- Construct given a mesh to subset
229 explicit fvMeshSubset(const fvMesh&);
236 //- Set the subset. Create "oldInternalFaces" patch for exposed
237 // internal faces (patchID==-1) or use supplied patch.
238 // Does not handle coupled patches correctly if only one side
242 const labelHashSet& globalCellMap,
243 const label patchID = -1
246 //- Set the subset from all cells with region == currentRegion.
247 // Create "oldInternalFaces" patch for exposed
248 // internal faces (patchID==-1) or use supplied patch.
249 // Handles coupled patches by if nessecary making coupled patch
250 // face part of patchID (so uncoupled)
251 void setLargeCellSubset
253 const labelList& region,
254 const label currentRegion,
255 const label patchID = -1,
256 const bool syncCouples = true
259 //- setLargeCellSubset but with labelHashSet.
260 void setLargeCellSubset
262 const labelHashSet& globalCellMap,
263 const label patchID = -1,
264 const bool syncPar = true
271 const fvMesh& baseMesh() const
276 //- Return reference to subset mesh
277 const fvMesh& subMesh() const;
281 //- Return reference to demand-driven subset pointMesh
282 const pointMesh& subPointMesh() const;
284 pointMesh& subPointMesh();
287 const labelList& pointMap() const;
290 const labelList& faceMap() const;
293 const labelList& cellMap() const;
296 const labelList& patchMap() const;
303 static tmp<GeometricField<Type, fvPatchField, volMesh> >
306 const GeometricField<Type, fvPatchField, volMesh>&,
308 const labelList& patchMap,
309 const labelList& cellMap,
310 const labelList& faceMap
314 tmp<GeometricField<Type, fvPatchField, volMesh> >
317 const GeometricField<Type, fvPatchField, volMesh>&
320 //- Map surface field
322 static tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
325 const GeometricField<Type, fvsPatchField, surfaceMesh>&,
327 const labelList& patchMap,
328 const labelList& faceMap
332 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
335 const GeometricField<Type, fvsPatchField, surfaceMesh>&
340 static tmp<GeometricField<Type, pointPatchField, pointMesh> >
343 const GeometricField<Type, pointPatchField, pointMesh>&,
344 const pointMesh& sMesh,
345 const objectRegistry& reg,
346 const labelList& patchMap,
347 const labelList& pointMap
351 tmp<GeometricField<Type, pointPatchField, pointMesh> >
354 const GeometricField<Type, pointPatchField, pointMesh>&
359 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 } // End namespace Foam
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
366 # include "fvMeshSubsetInterpolate.C"
369 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
373 // ************************************************************************* //