source: issm/trunk-jpl/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp

Last change on this file was 25627, checked in by jdquinn, 4 years ago

CHG: Merging changes from Eric’s branch (still need to get Eric to look at rigid); blocking warning about deprecated ‘register’ in Dakota

File size: 2.6 KB
RevLine 
[1105]1/*!\file NodeConnectivityx
2 * \brief: compute node connectivity table, using elements connectivity table.
3 *
4 * For each node, we want to know how many elements are connected to this element, and which they are.
5 * Given that the 2d meshes we create in ISSM are triangular for now, and they are delaunay conforming,
6 * each triangle has a minimum angle of 30 degrees, which implies a connectivity <=6. We therefore return
7 * a nods x 7 connectivity table, with the 7'th column giving us the number of elements connected to each
8 * row node, and the first 6 columns giving us the elements numbers.
9 * Amend that: sounds like some triangles get up to 9 connectivity. Take 10 to be on the safe side.
10 * In order to be compatible with matlab output, the connectivity table is given in matlab indexing (starts at 1).
11 */
12
13#include "./NodeConnectivityx.h"
14
[3913]15#include "../../shared/shared.h"
16#include "../../toolkits/toolkits.h"
[1105]17
[14016]18void NodeConnectivityx(int** pconnectivity,int* pwidth,int* elements, int nels, int nods){
[1105]19
20 int i,j,n;
[25627]21 const int maxels=100;
[1105]22 const int width=maxels+1;
23
24 /*intermediary: */
25 int node;
26 int index;
27 int num_elements;
28 int already_plugged=0;
[14016]29 int element;
[1105]30
31 /*Allocate connectivity: */
[14016]32 int* connectivity=xNewZeroInit<int>(nods*width);
[1105]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.: */
[14016]36 for(n=0;n<nels;n++){
[1105]37
[14016]38 element=n+1; //matlab indexing
[1105]39
40 for(i=0;i<3;i++){
[13622]41
[14016]42 node=elements[n*3+i]; //already matlab indexed, elements comes directly from the workspace.
[1105]43 index=node-1;
44
[14016]45 num_elements=connectivity[width*index+maxels]; //retrieve number of elements already plugged into the connectivity of this node.
[13622]46
[1105]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: */
[14016]57 connectivity[width*index+num_elements]=element;
58 connectivity[width*index+maxels]=num_elements+1;
[13622]59
[1105]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++){
[14016]66 if (*(connectivity+width*i+maxels)>maxels)
67 _error_("max connectivity width reached (" << *(connectivity+width*i+maxels) << ")! increase width of connectivity table");
[1105]68 }
69
70 /*Assign output pointers: */
71 *pconnectivity=connectivity;
72 *pwidth=width;
73}
Note: See TracBrowser for help on using the repository browser.