Moving cfMesh into place. Updated contibutors list
[foam-extend-3.2.git] / src / mesh / cfMesh / meshLibrary / utilities / octrees / meshOctree / meshOctreeModifier / meshOctreeModifierReduceMemoryConsumption.C
blob6981376391fc4cb40d1f7a1e0d638cb484d6fe87
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.
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.
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.
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/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 #include "meshOctreeModifier.H"
29 #include "triSurf.H"
30 #include "demandDrivenData.H"
32 // #define DEBUGSearch
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 void meshOctreeModifier::reduceMemoryConsumption()
43     //createListOfLeaves();
45     const LongList<meshOctreeCube*>& leaves = octree_.leaves_;
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];
58             if(
59                 oc.hasContainedElements() &&
60                 oc.slotPtr() == &octree_.dataSlots_[slotI]
61             )
62                 mayDeleteData[oc.containedElements()] = false;
63         }
65         for(label i=0;i<nElmts;++i)
66             if( mayDeleteData[i] )
67                 containedTriangles.setRowSize(i, 0);
68         containedTriangles.optimizeMemoryUsage();
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];
80             if(
81                 oc.hasContainedEdges() &&
82                 oc.slotPtr() == &octree_.dataSlots_[slotI]
83             )
84                 mayDeleteData[oc.containedEdges()] = false;
85         }
87         for(label i=0;i<nElmts;++i)
88             if( mayDeleteData[i] )
89                 containedEdges.setRowSize(i, 0);
91         containedEdges.optimizeMemoryUsage();
92     }
95 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97 } // End namespace Foam
99 // ************************************************************************* //