Ice Sheet System Model  4.18
Code documentation
Functions
NodeConnectivityx.h File Reference

header file for node connectivity computation More...

Go to the source code of this file.

Functions

void NodeConnectivityx (int **pconnectivity, int *pwidth, int *elements, int nels, int nods)
 

Detailed Description

header file for node connectivity computation

Definition in file NodeConnectivityx.h.

Function Documentation

◆ NodeConnectivityx()

void NodeConnectivityx ( int **  pconnectivity,
int *  pwidth,
int *  elements,
int  nels,
int  nods 
)

Definition at line 18 of file NodeConnectivityx.cpp.

18  {
19 
20  int i,j,n;
21  const int maxels=50;
22  const int width=maxels+1;
23 
24  /*intermediary: */
25  int node;
26  int index;
27  int num_elements;
28  int already_plugged=0;
29  int element;
30 
31  /*Allocate connectivity: */
32  int* connectivity=xNewZeroInit<int>(nods*width);
33 
34  /*Go through all elements, and for each elements, plug into the connectivity, all the nodes.
35  * If nodes are already plugged into the connectivity, skip them.: */
36  for(n=0;n<nels;n++){
37 
38  element=n+1; //matlab indexing
39 
40  for(i=0;i<3;i++){
41 
42  node=elements[n*3+i]; //already matlab indexed, elements comes directly from the workspace.
43  index=node-1;
44 
45  num_elements=connectivity[width*index+maxels]; //retrieve number of elements already plugged into the connectivity of this node.
46 
47  already_plugged=0;
48  for(j=0;j<num_elements;j++){
49  if (element==*(connectivity+width*index+j)){
50  already_plugged=1;
51  break;
52  }
53  }
54  if(already_plugged)break;
55 
56  /*this elements is not yet plugged into the connectivity for this node, do it, and increase counter: */
57  connectivity[width*index+num_elements]=element;
58  connectivity[width*index+maxels]=num_elements+1;
59 
60  }
61  }
62 
63  /*Last check: is the number of elements on last column of the connectivity superior to maxels? If so, then error out and
64  * warn the user to increase the connectivity width: */
65  for(i=0;i<nods;i++){
66  if (*(connectivity+width*i+maxels)>maxels)
67  _error_("max connectivity width reached (" << *(connectivity+width*i+maxels) << ")! increase width of connectivity table");
68  }
69 
70  /*Assign output pointers: */
71  *pconnectivity=connectivity;
72  *pwidth=width;
73 }
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49