meshOctreeModifierReduceMemoryConsumption.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh 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.
15 
16  cfMesh 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.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "meshOctreeModifier.H"
29 #include "triSurf.H"
30 #include "demandDrivenData.H"
31 
32 // #define DEBUGSearch
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
42 {
43  //createListOfLeaves();
44 
46 
47  forAll(octree_.dataSlots_, slotI)
48  {
49  //- deleting triangles
50  VRWGraph& containedTriangles =
51  octree_.dataSlots_[slotI].containedTriangles_;
52  label nElmts = containedTriangles.size();
53  boolList mayDeleteData(nElmts, true);
54  forAll(leaves, leafI)
55  {
56  const meshOctreeCube& oc = *leaves[leafI];
57 
58  if(
59  oc.hasContainedElements() &&
60  oc.slotPtr() == &octree_.dataSlots_[slotI]
61  )
62  mayDeleteData[oc.containedElements()] = false;
63  }
64 
65  for(label i=0;i<nElmts;++i)
66  if( mayDeleteData[i] )
67  containedTriangles.setRowSize(i, 0);
68  containedTriangles.optimizeMemoryUsage();
69 
70  //- deleting edges
71  VRWGraph& containedEdges =
72  octree_.dataSlots_[slotI].containedEdges_;
73  nElmts = containedEdges.size();
74  mayDeleteData.setSize(nElmts);
75  mayDeleteData = true;
76  forAll(leaves, leafI)
77  {
78  const meshOctreeCube& oc = *leaves[leafI];
79 
80  if(
81  oc.hasContainedEdges() &&
82  oc.slotPtr() == &octree_.dataSlots_[slotI]
83  )
84  mayDeleteData[oc.containedEdges()] = false;
85  }
86 
87  for(label i=0;i<nElmts;++i)
88  if( mayDeleteData[i] )
89  containedEdges.setRowSize(i, 0);
90 
91  containedEdges.optimizeMemoryUsage();
92  }
93 }
94 
95 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96 
97 } // End namespace Foam
98 
99 // ************************************************************************* //
triSurf.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::meshOctreeCube::containedEdges
label containedEdges() const
Definition: meshOctreeCubeI.H:102
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::meshOctreeCube::hasContainedElements
bool hasContainedElements() const
return true if the box contains some triangles
Definition: meshOctreeCubeI.H:81
Foam::meshOctree::dataSlots_
List< meshOctreeSlot > dataSlots_
List of slots containing data generated by each processor.
Definition: meshOctree.H:86
Foam::meshOctreeModifier::reduceMemoryConsumption
void reduceMemoryConsumption()
reduce memory consumption by deleting unnecessary data
Definition: meshOctreeModifierReduceMemoryConsumption.C:41
meshOctreeModifier.H
Foam::meshOctreeCube::hasContainedEdges
bool hasContainedEdges() const
returns true if the box contains some edges
Definition: meshOctreeCubeI.H:94
Foam::LongList
Definition: LongList.H:55
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::VRWGraph::optimizeMemoryUsage
void optimizeMemoryUsage()
optimize memory usage
Definition: VRWGraph.C:86
Foam::VRWGraph::size
label size() const
Returns the number of rows.
Definition: VRWGraphI.H:122
Foam::meshOctreeCube::slotPtr
const meshOctreeSlot * slotPtr() const
return the pointer to the slot containing the cube
Definition: meshOctreeCubeI.H:58
Foam::meshOctree::leaves_
LongList< meshOctreeCube * > leaves_
list of cubes which are leaves of the octree
Definition: meshOctree.H:89
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::meshOctreeCube
Definition: meshOctreeCube.H:56
Foam::meshOctreeCube::containedElements
label containedElements() const
Definition: meshOctreeCubeI.H:89
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::VRWGraph::setRowSize
void setRowSize(const label rowI, const label newSize)
Reset the size of the given row.
Definition: VRWGraphI.H:204
Foam::meshOctreeModifier::octree_
meshOctree & octree_
Reference to the octree.
Definition: meshOctreeModifier.H:52