OOFEM 3.0
Loading...
Searching...
No Matches
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 - 2025 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
44namespace oofem {
45#define LEVEL_LIST_GROW_CHUNK 50
46
47SloanLevelStructure :: ~SloanLevelStructure()
48{
50}
51
52void
53SloanLevelStructure :: destroyLevels()
54{
55 Structure.clear();
56}
57
58int
59SloanLevelStructure :: formYourself(int limitWidth)
60{
61 if ( ! Structure.empty() ) {
62 return 1;
63 }
64
65 int nnodes = Graph->getNumberOfNodes();
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
95void
96SloanLevelStructure :: computeDepth()
97{
98 this->formYourself();
99 Depth = (int) Structure.size();
100}
101
102void
103SloanLevelStructure :: computeWidth()
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
114IntArray &
115SloanLevelStructure :: giveLevel(int num)
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
void followedBy(const IntArray &b, int allocChunk=0)
Definition intarray.C:94
void resize(int n)
Definition intarray.C:73
bool isEmpty() const
Definition intarray.h:217
int & at(std::size_t i)
Definition intarray.h:104
int Root
Root node of level structure.
int Width
Width of structure defined as max number of nodes in all levels.
std::vector< IntArray > Structure
Data representation of structure: List of arrays, one array for each level.
SloanGraph * Graph
Reference to corresponding graph.
int formYourself(int limitWidth=-1)
int Depth
Depth of structure defined as number of levels.
void destroyLevels()
Destroys all levels.
int giveDepth()
Returns the depth of receiver.
IntArray & giveLevel(int num)
Returns the i-th level of receiver.
#define OOFEM_ERROR(...)
Definition error.h:79
#define LEVEL_LIST_GROW_CHUNK

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011