KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
split_triangle.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Pooyan Dadvand
11 // Riccardo Rossi
12 // Nelson Lafontaine
13 //
14 //
15 
16 #if !defined(KRATOS_SPLIT_TRIANGLE)
17 #define KRATOS_SPLIT_TRIANGLE
18 
19 namespace Kratos {
50 public:
64  static void TriangleSplitMode(const int aux_ids[6], int edge_ids[3]) {
65  /*edge 01*/
66  if (aux_ids[3] < 0)
67  if (aux_ids[0] > aux_ids[1]) edge_ids[0] = 0;
68  else edge_ids[0] = 1;
69  else
70  edge_ids[0] = 3;
71 
72  /*edge 12*/
73  if (aux_ids[4] < 0)
74  if (aux_ids[1] > aux_ids[2]) edge_ids[1] = 1;
75  else edge_ids[1] = 2;
76  else
77  edge_ids[1] = 4;
78 
79  /*edge 20*/
80  if (aux_ids[5] < 0)
81  if (aux_ids[2] > aux_ids[0]) edge_ids[2] = 2;
82  else edge_ids[2] = 0;
83  else
84  edge_ids[2] = 5;
85  }
86 
96  inline static void TriangleGetNewConnectivityGID(const int triangle_index,
97  const int t[12],
98  const int aux_ids[6],
99  int* id0, int* id1, int* id2) {
100  unsigned int base = triangle_index * 3;
101  *id0 = aux_ids[t[base]];
102  *id1 = aux_ids[t[base + 1]];
103  *id2 = aux_ids[t[base + 2]];
104  }
105 
106 
108 
117  static int Split_Triangle(const int edges[3], int t[12], int* nel, int* splitted_edges, int* nint) {
118  *splitted_edges = 0;
119  int topology[3];
120  topology[0] = 0;
121  topology[1] = 0;
122  topology[2] = 0;
123  for (unsigned int i = 0; i < 3; i++) {
124  if (edges[i] > 2) {
125  topology[i] = 1;
126  *splitted_edges = *splitted_edges + 1;
127  }
128  }
129 
130  if (*splitted_edges == 0 && *nint == 0) {
131  /*no splitting needed*/
132  *nel = 1;
133  t[0] = 0;
134  t[1] = 1;
135  t[2] = 2;
136  return 0;
137  }
138  /*WARNING = case new central node needed*/
139  else if (*splitted_edges == 0 && *nint == 1) {
140  *nel = 3;
141 
142  t[0] = 3;
143  t[1] = 0;
144  t[2] = 1;
145 
146  t[3] = 3;
147  t[4] = 1;
148  t[5] = 2;
149 
150  t[5] = 3;
151  t[5] = 2;
152  t[5] = 0;
153  return 1;
154  }
155 
156  else if (*splitted_edges == 1) {
157  *nel = 2;
158  /* caso 1*/
159  if (topology[0] == 1) {
160  t[0] = 3;
161  t[1] = 2;
162  t[2] = 0;
163 
164  t[3] = 3;
165  t[4] = 1;
166  t[5] = 2;
167  }
168 
169  /* caso 2*/
170  else if (topology[1] == 1) {
171  t[0] = 4;
172  t[1] = 0;
173  t[2] = 1;
174 
175  t[3] = 4;
176  t[4] = 2;
177  t[5] = 0;
178  }
179  /* caso 3*/
180  else if (topology[2] == 1) {
181  t[0] = 5;
182  t[1] = 1;
183  t[2] = 2;
184 
185  t[3] = 5;
186  t[4] = 0;
187  t[5] = 1;
188  }
189 
190  return 1;
191 
192  }
193 
194  else if (*splitted_edges == 2) {
195  *nel = 3;
196  /* caso 4*/
197  if (topology[0] == 1 && topology[1] == 1) {
198  if (edges[2] == 0) // si colapso al nodo 0 local
199  {
200  t[0] = 4;
201  t[1] = 3;
202  t[2] = 1;
203 
204  t[3] = 4;
205  t[4] = 0;
206  t[5] = 3;
207 
208  t[6] = 4;
209  t[7] = 2;
210  t[8] = 0;
211  }
212  else if (edges[2] == 2) // si colapso al nodo 2 local
213  {
214  t[0] = 4;
215  t[1] = 3;
216  t[2] = 1;
217 
218  t[3] = 4;
219  t[4] = 2;
220  t[5] = 3;
221 
222  t[6] = 3;
223  t[7] = 2;
224  t[8] = 0;
225  }
226 
227  }
228  /* caso 5*/
229  else if (topology[1] == 1 && topology[2] == 1) {
230  if (edges[0] == 0) // si colapso al nodo 0 local
231  {
232  t[0] = 5;
233  t[1] = 4;
234  t[2] = 2;
235 
236  t[3] = 5;
237  t[4] = 0;
238  t[5] = 4;
239 
240  t[6] = 4;
241  t[7] = 0;
242  t[8] = 1;
243  }
244  else if (edges[0] == 1)
245  {
246  t[0] = 5;
247  t[1] = 4;
248  t[2] = 2;
249 
250  t[3] = 5;
251  t[4] = 1;
252  t[5] = 4;
253 
254  t[6] = 5;
255  t[7] = 0;
256  t[8] = 1;
257  }
258  }
259 
260 
261  /* caso 3*/
262  else if (topology[0] == 1 && topology[2] == 1) {
263  if (edges[1] == 1)
264  {
265  t[0] = 5;
266  t[1] = 0;
267  t[2] = 3;
268 
269  t[3] = 5;
270  t[4] = 3;
271  t[5] = 1;
272 
273  t[6] = 5;
274  t[7] = 1;
275  t[8] = 2;
276  }
277  else if (edges[1] == 2)
278  {
279  t[0] = 5;
280  t[1] = 0;
281  t[2] = 3;
282 
283  t[3] = 5;
284  t[4] = 3;
285  t[5] = 2;
286 
287  t[6] = 3;
288  t[7] = 1;
289  t[8] = 2;
290  }
291 
292  }
293 
294  return 1;
295  }
296  else if (*splitted_edges == 3) {
297  *nel = 4;
298  t[0] = 5;
299  t[1] = 0;
300  t[2] = 3;
301 
302  t[3] = 5;
303  t[4] = 3;
304  t[5] = 4;
305 
306  t[6] = 4;
307  t[7] = 3;
308  t[8] = 1;
309 
310  t[9] = 5;
311  t[10] = 4;
312  t[11] = 2;
313 
314  return 1;
315  } else {
316  return 0;
317  }
318 
319  }
320 }; //class TriangleSplit
321 } //Namespace Kratos
322 
323 #endif /* KRATOS_SPLIT_TRIANGLE defined */
324 
325 
Definition: split_triangle.h:49
static void TriangleSplitMode(const int aux_ids[6], int edge_ids[3])
Definition: split_triangle.h:64
static int Split_Triangle(const int edges[3], int t[12], int *nel, int *splitted_edges, int *nint)
Utility to split triangles.
Definition: split_triangle.h:117
static void TriangleGetNewConnectivityGID(const int triangle_index, const int t[12], const int aux_ids[6], int *id0, int *id1, int *id2)
Definition: split_triangle.h:96
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
int t
Definition: ode_solve.py:392
integer i
Definition: TensorModule.f:17