Alpine3D

Alpine3D Svn Source Tree

Root/trunk/alpine3d/snowdrift/Cell.cc

1/***********************************************************************************/
2/* Copyright 2009-2015 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3/***********************************************************************************/
4/* This file is part of Alpine3D.
5 Alpine3D is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Alpine3D is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with Alpine3D. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include <alpine3d/snowdrift/Cell.h>
19
20Cell::Cell()
21{
22initialize();
23}
24
25/**
26 * @brief arrays to select the interior nodes of a boundary element located either on
27 * faces, corners, or bars. Note: the corners are enumerated from the
28 * bottom layer to the top layer in the usual order of enumeration
29 * used for the local node indices in an element. The faces are
30 * ordered according to: front, right, back, lef,t bottom, top. the
31 * bars are in order: 1) horizontal bars in the bottom: front right
32 * back left 2) horizontal bars on the top: same order 3) vertical
33 * bars: starting from front-left
34 */
35void Cell::initialize()
36{
37const int aux1[6][4] = { {2, 3, 6, 7},
38{0, 3, 4, 7},
39{0, 1, 4, 5},
40{1, 2, 5, 6},
41{4, 5, 6, 7},
42{0, 1, 2, 3} };
43
44for ( int i = 0; i < 6; i++) {
45for ( int j = 0; j < 4; j++) {
46FACE[i][j] = aux1[i][j];
47}
48}
49
50
51const int aux2[12][2] = { {6,7}, {4,7}, {4,5},
52{5,6}, {2,3}, {0,3},
53{0,1}, {1,2}, {2,6},
54{3,7}, {0,4}, {1,5} };
55
56for ( int i = 0; i < 12; i++) {
57for ( int j = 0; j < 2; j++) {
58BAR[i][j] = aux2[i][j];
59}
60}
61
62
63const int aux3[8] = {6, 7, 4, 5, 2, 3, 0, 1};
64
65for ( int i = 0; i < 8; i++) {
66CORNER[i] = aux3[i];
67}
68
69// array to pick out the boundary nodes of an element located on a face,
70// hence: NODE[i][] = {0,1,2..7} \ FACE[i][]
71const int aux4[6][4] = { {0, 1, 4, 5},
72{1, 2, 5, 6},
73{2, 3, 6, 7},
74{0, 3, 4, 7},
75{0, 1, 2, 3},
76{4, 5, 6, 7} };
77
78for ( int i = 0; i < 6; i++) {
79for ( int j = 0; j < 4; j++) {
80NODE[i][j] = aux4[i][j];
81}
82}
83}
84
85void Cell::classifyNodes(int* dofNode,
86 int* nDofNodes,
87 int* nBoundaryNodes,
88 const std::string& type,
89 int number) const
90{
91if ( type == "interior" ) {
92for (int i = 0; i < 8; i++) {
93dofNode[i]=i;
94}
95*nDofNodes = 8;
96*nBoundaryNodes = 0;
97} else if ( type == "face" ) {
98//specify the nodes of the element which are interior nodes
99for (int i = 0; i < 4; i++) {
100dofNode[i] = FACE[number][i];
101}
102*nDofNodes=4;
103
104//specify the nodes of the element which are boundary nodes
105for (int i = 0; i < 4; i++) {
106dofNode[i+*nDofNodes] = NODE[number][i];
107}
108*nBoundaryNodes = 4;
109} else if ( type == "bar" ) {
110//specify the nodes of the element which are interior nodes
111dofNode[0] = BAR[number][0];
112dofNode[1] = BAR[number][1];
113
114*nDofNodes=2;
115
116//specify the nodes of the element which are boundary nodes
117//works only iff BAR[bar][0] < BAR[bar][1] for all bar
118for (int i = 0; i < BAR[number][0]; i++) {
119dofNode[i+*nDofNodes]=i;
120}
121for (int i = BAR[number][0]; i < BAR[number][1] - 1; i++) {
122dofNode[i+*nDofNodes]=i+1;
123}
124for (int i = BAR[number][1]-1; i < 6; i++) {
125dofNode[i+*nDofNodes]=i+2;
126}
127*nBoundaryNodes = 6;
128} else if ( type == "corner" ) {
129//specify the nodes of the element which are interior nodes
130dofNode[0] = CORNER[number];
131*nDofNodes = 1;
132
133//specify the nodes of the element which are boundary nodes
134for (int i = 0; i < CORNER[number]; i++) {
135dofNode[i+*nDofNodes]=i;
136}
137for (int i = CORNER[number]; i < 8; i++) {
138dofNode[i+*nDofNodes]=i+1;
139}
140*nBoundaryNodes = 7;
141} else {
142exit(1);
143}
144}

Archive Download this file

Revision: HEAD