Ice Sheet System Model  4.18
Code documentation
CreateNumberNodeToElementConnectivity.cpp
Go to the documentation of this file.
1 
5 #ifdef HAVE_CONFIG_H
6 #include <config.h>
7 #else
8 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9 #endif
10 
11 #include "../../shared/shared.h"
12 #include "../../classes/classes.h"
13 #include "../../shared/io/io.h"
14 #include "./ModelProcessorx.h"
15 
17 
18  /*Intermediary*/
19  int i,j;
20  int vertexid;
21  int elementswidth;
22 
23  /*output*/
24  int* connectivity=NULL;
25 
26  /*Check that this has not been done yet*/
27  if(iomodel->numbernodetoelementconnectivity) return;
28 
29  /*Some checks if debugging*/
30  _assert_(iomodel->numberofvertices);
31  _assert_(iomodel->numberofelements);
32  _assert_(iomodel->elements);
33 
34  /*Allocate ouput*/
35  connectivity=xNewZeroInit<int>(iomodel->numberofvertices);
36 
37  /*Get element width*/
38  switch(iomodel->meshelementtype){
39  case TriaEnum: elementswidth=3; break;
40  case TetraEnum: elementswidth=4; break;
41  case PentaEnum: elementswidth=6; break;
42  default: _error_("mesh not supported yet");
43  }
44 
45  /*Create connectivity table*/
46  for (i=0;i<iomodel->numberofelements;i++){
47  for (j=0;j<elementswidth;j++){
48  vertexid=iomodel->elements[elementswidth*i+j];
49  _assert_(vertexid>0 && vertexid-1<iomodel->numberofvertices);
50  connectivity[vertexid-1]+=1;
51  }
52  }
53 
54  /*Assign to iomodel*/
55  iomodel->numbernodetoelementconnectivity=connectivity;
56 }
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
TetraEnum
@ TetraEnum
Definition: EnumDefinitions.h:1300
IoModel::numbernodetoelementconnectivity
int * numbernodetoelementconnectivity
Definition: IoModel.h:92
IoModel::numberofvertices
int numberofvertices
Definition: IoModel.h:99
IoModel::numberofelements
int numberofelements
Definition: IoModel.h:96
CreateNumberNodeToElementConnectivity
void CreateNumberNodeToElementConnectivity(IoModel *iomodel)
Definition: CreateNumberNodeToElementConnectivity.cpp:16
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
PentaEnum
@ PentaEnum
Definition: EnumDefinitions.h:1231
IoModel::elements
int * elements
Definition: IoModel.h:79
IoModel
Definition: IoModel.h:48
IoModel::meshelementtype
int meshelementtype
Definition: IoModel.h:91
ModelProcessorx.h
TriaEnum
@ TriaEnum
Definition: EnumDefinitions.h:1318