OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
sloanlevelstruct.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
35 /* Modified and optimized by: Borek Patzak */
36 /* Author: Milan Jirasek */
37 
38 #include "sloanlevelstruct.h"
39 #include "sloangraphnode.h"
40 #include "sloangraph.h"
41 #include "intarray.h"
42 #include "domain.h"
43 
44 namespace oofem {
45 #define LEVEL_LIST_GROW_CHUNK 50
46 
48 {
49  destroyLevels();
50 }
51 
52 void
54 {
55  Structure.clear();
56 }
57 
58 int
60 {
61  if ( ! Structure.empty() ) {
62  return 1;
63  }
64 
65  int nnodes = Graph->giveDomain()->giveNumberOfDofManagers();
66  IntArray nodalStatuses(nnodes);
67  IntArray Level = {Root};
68 
69  // mark root
70  nodalStatuses.at(Root) = 1;
71 
72  while ( !Level.isEmpty() ) { /* loop over levels */
73  Structure.push_back(Level);
74  /* start new level */
75  /* loop over nodes on prev. level */
76  Level.resize(0);
77  int CurrLevelWidth = 0;
78  for ( int inode: Structure.back() ) {
79  for ( int n: Graph->giveNode( inode ).giveNeighborList() ) {
80  if ( nodalStatuses.at(n) == 0 ) {
82  nodalStatuses.at(n) = 1;
83  if ( ( limitWidth > 0 ) && ( ++CurrLevelWidth > limitWidth ) ) {
84  this->destroyLevels();
85  return 0; // zero mean aborted assembly
86  }
87  }
88  }
89  }
90  }
91 
92  return 1;
93 }
94 
95 void
97 {
98  this->formYourself();
99  Depth = Structure.size();
100 }
101 
102 void
104 {
105  Width = 0;
106  for ( int i = 1; i <= giveDepth(); i++ ) {
107  int LevelWidth = giveLevel(i).giveSize();
108  if ( Width < LevelWidth ) {
109  Width = LevelWidth;
110  }
111  }
112 }
113 
114 IntArray &
116 {
117  if ( Structure.empty() ) {
118  this->formYourself();
119  }
120 
121  if ( num < 1 || num > giveDepth() ) {
122  OOFEM_ERROR("out of bounds (%d)", num);
123  }
124 
125  return Structure [ num - 1 ];
126 }
127 } // end namespace oofem
int formYourself(int limitWidth=-1)
Builds the level structure.
#define LEVEL_LIST_GROW_CHUNK
int giveDepth()
Returns the depth of receiver.
bool isEmpty() const
Checks if receiver is empty (i.e., zero sized).
Definition: intarray.h:208
int Width
Width of structure defined as max number of nodes in all levels.
~SloanLevelStructure()
Destructor.
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
#define OOFEM_ERROR(...)
Definition: error.h:61
Class representing the special graph constructed from two polygons that is used to perform boolean op...
Definition: geotoolbox.h:191
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
IntArray & giveLevel(int num)
Returns the i-th level of receiver.
int Root
Root node of level structure.
void followedBy(const IntArray &b, int allocChunk=0)
Appends array b at the end of receiver.
Definition: intarray.C:145
std::vector< IntArray > Structure
Data representation of structure: List of arrays, one array for each level.
void computeDepth()
Computes depth of receiver.
int giveSize() const
Definition: intarray.h:203
the oofem namespace is to define a context or scope in which all oofem names are defined.
void destroyLevels()
Destroys all levels.
void computeWidth()
Computes the Width of receiver.
int Depth
Depth of structure defined as number of levels.

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:31 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011