Ice Sheet System Model  4.18
Code documentation
Functions
NodesPartitioning.cpp File Reference

: partition elements and nodes and vertices More...

#include <string.h>
#include "../../classes/classes.h"
#include "../../shared/shared.h"
#include "../MeshPartitionx/MeshPartitionx.h"
#include "../ModelProcessorx/ModelProcessorx.h"

Go to the source code of this file.

Functions

void DiscontinuousGalerkinNodesPartitioning (bool **pmy_nodes, bool *my_elements, bool *my_vertices, IoModel *iomodel)
 

Detailed Description

: partition elements and nodes and vertices

Definition in file NodesPartitioning.cpp.

Function Documentation

◆ DiscontinuousGalerkinNodesPartitioning()

void DiscontinuousGalerkinNodesPartitioning ( bool **  pmy_nodes,
bool *  my_elements,
bool *  my_vertices,
IoModel iomodel 
)

All elements have been partitioned above, only create elements for this CPU:

Definition at line 17 of file NodesPartitioning.cpp.

17  {
18 
19  /* Each element has it own nodes (as many as vertices) + additional nodes
20  * from neighboring elements for each face. This yields to a very different
21  * partition for the nodes and the vertices. The vertices are similar to
22  * continuous galerkin, but the nodes partitioning involves faces, which
23  * messes up sorting of ids. */
24 
25  /*Intermediaries*/
26  int i,i1,i2;
27  int e1,e2;
28  int pos;
29 
30  /*Get faces and elements*/
31  CreateEdges(iomodel);
32 
33  /*Build discontinuous node partitioning
34  * - there are three nodes per element (discontinous)
35  * - for each element present of each partition, its three nodes will be in this partition
36  * - the faces require the dofs of the 2 nodes of each elements sharing the face.
37  * if the 2 elements sharing the face are on 2 different cpus, we must duplicate
38  * the two nodes that are not on the cpus so that the face can access the dofs of
39  * all its 4 nodes
40  */
41 
42  /*Allocate*/
43  bool* my_nodes=xNewZeroInit<bool>(3*iomodel->numberofelements);
44 
45  /*First: add all the nodes of all the elements belonging to this cpu*/
47  for (i=0;i<iomodel->numberofelements;i++){
48  if (my_elements[i]){
49  my_nodes[3*i+0]=true;
50  my_nodes[3*i+1]=true;
51  my_nodes[3*i+2]=true;
52  }
53  }
54  }
55  else{
56  _error_("not implemented yet");
57  }
58 
59  /*Second: add all missing nodes*/
60 
61  /*Get faces and elements*/
62  CreateFaces(iomodel);
63 
64  if(iomodel->domaintype==Domain2DhorizontalEnum){
66  for(int i=0;i<iomodel->numberoffaces;i++){
67 
68  /*Get left and right elements*/
69  e1=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2]
70  e2=iomodel->faces[4*i+3]-1; //faces are [node1 node2 elem1 elem2]
71 
72  /* 1) If the element e1 is in the current partition
73  * 2) and if the face of the element is shared by another element (internal face)
74  * 3) and if this element is not in the same partition:
75  * we must clone the nodes on this partition so that the loads (Numericalflux)
76  * will have access to their properties (dofs,...)*/
77  if(my_elements[e1] && e2!=-2 && !my_elements[e2]){
78 
79  /*1: Get vertices ids*/
80  i1=iomodel->faces[4*i+0];
81  i2=iomodel->faces[4*i+1];
82 
83  /*2: Get the column where these ids are located in the index*/
84  pos=UNDEF;
85  for(int j=0;j<3;j++){
86  if(iomodel->elements[3*e2+j]==i1) pos=j;
87  }
88 
89  /*3: We have the id of the elements and the position of the vertices in the index
90  * we can now create the corresponding nodes:*/
91  if(pos==0){
92  my_nodes[e2*3+0]=true;
93  my_nodes[e2*3+2]=true;
94  }
95  else if(pos==1){
96  my_nodes[e2*3+1]=true;
97  my_nodes[e2*3+0]=true;
98  }
99  else if(pos==2){
100  my_nodes[e2*3+2]=true;
101  my_nodes[e2*3+1]=true;
102  }
103  else{
104  _error_("Problem in faces creation");
105  }
106  }
107  }
108  }
109 
110  /*Free data and assign output pointers */
111  *pmy_nodes=my_nodes;
112 }
CreateEdges
void CreateEdges(IoModel *iomodel)
Definition: CreateEdges.cpp:9
IoModel::numberoffaces
int numberoffaces
Definition: IoModel.h:97
Domain2DhorizontalEnum
@ Domain2DhorizontalEnum
Definition: EnumDefinitions.h:534
IoModel::numberofelements
int numberofelements
Definition: IoModel.h:96
UNDEF
#define UNDEF
Definition: constants.h:8
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
IoModel::faces
int * faces
Definition: IoModel.h:88
IoModel::elements
int * elements
Definition: IoModel.h:79
CreateFaces
void CreateFaces(IoModel *iomodel)
Definition: CreateFaces.cpp:9
IoModel::domaintype
int domaintype
Definition: IoModel.h:78
Domain2DverticalEnum
@ Domain2DverticalEnum
Definition: EnumDefinitions.h:535