Changeset 15611
- Timestamp:
- 07/25/13 09:32:50 (12 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 2 added
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r15464 r15611 244 244 ./modules/ModelProcessorx/NodesPartitioning.cpp\ 245 245 ./modules/ModelProcessorx/EdgesPartitioning.cpp\ 246 ./modules/ModelProcessorx/FacesPartitioning.cpp\ 246 247 ./modules/ModelProcessorx/SortDataSets.cpp\ 247 248 ./modules/ModelProcessorx/UpdateCounters.cpp\ … … 249 250 ./modules/ModelProcessorx/CreateParameters.cpp\ 250 251 ./modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp\ 252 ./modules/ModelProcessorx/CreateFaces.cpp\ 251 253 ./modules/ModelProcessorx/CreateEdges.cpp\ 252 ./modules/ModelProcessorx/CreateElementToEdgeConnectivity.cpp\253 254 ./modules/ModelProcessorx/CreateSingleNodeToElementConnectivity.cpp\ 254 255 ./modules/ModelProcessorx/CreateNumberNodeToElementConnectivity.cpp\ -
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r15595 r15611 50 50 51 51 /*intialize inputs and results: */ 52 this->inputs =new Inputs();53 this->results =new Results();52 this->inputs = new Inputs(); 53 this->results = new Results(); 54 54 55 55 /*initialize pointers:*/ -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r15461 r15611 33 33 this->numberofvertices=-1; 34 34 this->numberofelements=-1; 35 this->numberoffaces=-1; 35 36 this->numberofedges=-1; 36 37 this->elements=NULL; 38 this->faces=NULL; 37 39 this->edges=NULL; 38 40 this->elementtoedgeconnectivity =NULL; … … 75 77 FetchData(&this->numberofelements,MeshNumberofelementsEnum); 76 78 FetchData(&this->elements,NULL,NULL,MeshElementsEnum); 79 this->faces = NULL; 77 80 this->edges = NULL; 78 81 this->elementtoedgeconnectivity = NULL; … … 109 112 110 113 xDelete<int>(this->elements); 114 xDelete<int>(this->faces); 111 115 xDelete<int>(this->edges); 112 116 xDelete<int>(this->elementtoedgeconnectivity); -
issm/trunk-jpl/src/c/classes/IoModel.h
r15461 r15611 34 34 int numberofvertices; 35 35 int numberofelements; 36 int numberoffaces; 36 37 int numberofedges; 37 38 int *elements; 39 int *faces; 38 40 int *edges; 39 41 int *elementtoedgeconnectivity; -
issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp
r15430 r15611 52 52 53 53 /*Get edge*/ 54 int i1 = iomodel-> edges[4*index+0];55 int i2 = iomodel-> edges[4*index+1];56 int e1 = iomodel-> edges[4*index+2];57 int e2 = iomodel-> edges[4*index+3];54 int i1 = iomodel->faces[4*index+0]; 55 int i2 = iomodel->faces[4*index+1]; 56 int e1 = iomodel->faces[4*index+2]; 57 int e2 = iomodel->faces[4*index+3]; 58 58 59 59 /*First, see wether this is an internal or boundary edge (if e2=-1)*/ -
issm/trunk-jpl/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp
r15489 r15611 57 57 for(i=0;i<iomodel->numberofedges;i++){ 58 58 if(my_edges[i]){ 59 v1 = iomodel->edges[ 4*i+0]-1;60 v2 = iomodel->edges[ 4*i+1]-1;59 v1 = iomodel->edges[2*i+0]-1; 60 v2 = iomodel->edges[2*i+1]-1; 61 61 if(!xIsNan<IssmDouble>(spcdata[v1]) && !xIsNan<IssmDouble>(spcdata[v2])){ 62 62 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+iomodel->numberofvertices+i+1, … … 99 99 for(i=0;i<iomodel->numberofedges;i++){ 100 100 if(my_edges[i]){ 101 v1 = iomodel->edges[ 4*i+0]-1;102 v2 = iomodel->edges[ 4*i+1]-1;101 v1 = iomodel->edges[2*i+0]-1; 102 v2 = iomodel->edges[2*i+1]-1; 103 103 values=xNew<IssmDouble>(N); 104 104 spcpresent=false; -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp
r15465 r15611 22 22 if (stabilization==3){ 23 23 24 /*Get edges and elements*/25 Create Edges(iomodel);24 /*Get faces and elements*/ 25 CreateFaces(iomodel); 26 26 iomodel->FetchData(1,ThicknessEnum); 27 27 28 28 /*First load data:*/ 29 for(int i=0;i<iomodel->numberof edges;i++){29 for(int i=0;i<iomodel->numberoffaces;i++){ 30 30 31 31 /*Get left and right elements*/ 32 element=iomodel-> edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2]32 element=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2] 33 33 34 34 /*Now, if this element is not in the partition, pass: */ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateEdges.cpp
r15435 r15611 12 12 13 13 /*Check Iomodel properties*/ 14 if(iomodel->dim!=2) _error_("only 2d model are supported");15 14 if(iomodel->numberofvertices<3) _error_("not enough elements in mesh"); 16 15 _assert_(iomodel->elements); … … 19 18 bool exist; 20 19 int i,j,v1,v2,v3; 21 int maxnbe,nbe; 20 int maxnbe,nbe,elementnbe,elementnbv; 21 int *elementedges = NULL; 22 23 /*Mesh dependent variables*/ 24 if(iomodel->dim==2){ 25 elementnbv = 3; 26 elementnbe = 3; 27 elementedges=xNew<int>(elementnbe*2); 28 elementedges[2*0+0] = 1; elementedges[2*0+1] = 2; 29 elementedges[2*1+0] = 2; elementedges[2*1+1] = 0; 30 elementedges[2*2+0] = 0; elementedges[2*2+1] = 1; 31 } 32 else if(iomodel->dim==3){ 33 elementnbv = 6; 34 elementnbe = 9; 35 elementedges=xNew<int>(elementnbe*2); 36 elementedges[2*0+0] = 0; elementedges[2*0+1] = 3; 37 elementedges[2*1+0] = 1; elementedges[2*1+1] = 4; 38 elementedges[2*2+0] = 2; elementedges[2*2+1] = 5; 39 elementedges[2*3+0] = 1; elementedges[2*3+1] = 2; 40 elementedges[2*4+0] = 2; elementedges[2*4+1] = 0; 41 elementedges[2*5+0] = 0; elementedges[2*5+1] = 1; 42 elementedges[2*6+0] = 4; elementedges[2*6+1] = 5; 43 elementedges[2*7+0] = 5; elementedges[2*7+1] = 3; 44 elementedges[2*8+0] = 3; elementedges[2*8+1] = 4; 45 } 46 else{ 47 _error_("mesh dimension not supported yet"); 48 } 22 49 23 50 /*Maximum number of edges*/ 24 maxnbe = 3*iomodel->numberofelements;51 maxnbe = elementnbe*iomodel->numberofelements; 25 52 26 53 /*Initialize intermediaries*/ 27 int* edgestemp = xNew<int>(maxnbe*4); /*format: [vertex1 vertex2 element1 element2] */ 28 bool* exchange = xNewZeroInit<bool>(maxnbe); /*Edges are ordered, we need to keep track of vertex swapping*/ 29 for(i=0;i<maxnbe;i++) edgestemp[i*4+3]=-1; /*Initialize last column of edges as -1 (boundary edge) */ 54 int *edgestemp = xNew<int>(maxnbe*2); /*format: [vertex1 vertex2] */ 55 int *element_edge_connectivity = xNew<int>(iomodel->numberofelements*elementnbe); /*format: [edge1 edge2 ... edgen] */ 30 56 31 57 /*Initialize chain*/ … … 38 64 39 65 for(i=0;i<iomodel->numberofelements;i++){ 40 for(j=0;j< 3;j++){66 for(j=0;j<elementnbe;j++){ 41 67 42 /*Get the two indices of the edge number j of the ith triangle*/ 43 v1 = iomodel->elements[i*3+j]; 44 if(j==2) 45 v2 = iomodel->elements[i*3+0]; 46 else 47 v2 = iomodel->elements[i*3+j+1]; 68 /*Get the two indices of the edge number j of the ith element*/ 69 v1 = iomodel->elements[i*elementnbv+elementedges[2*j+0]]-1; _assert_(v1>=0 & v1<iomodel->numberofvertices); 70 v2 = iomodel->elements[i*elementnbv+elementedges[2*j+1]]-1; _assert_(v2>=0 & v2<iomodel->numberofvertices); 48 71 49 72 /*v1 and v2 must be sorted*/ … … 56 79 57 80 /*Go through all processed edges connected to v1 and check whether we have seen this edge yet*/ 58 _assert_(v1>=0 & v1<iomodel->numberofvertices);59 81 for(int e=head_minv[v1]; e!=-1; e=next_edge[e]){ 60 if(edgestemp[e* 4+1]==v2){82 if(edgestemp[e*2+1]==v2+1){ 61 83 exist = true; 62 e dgestemp[e*4+3]=i+1;84 element_edge_connectivity[i*elementnbv+j]=e; 63 85 break; 64 86 } … … 70 92 71 93 /*Update edges*/ 72 edgestemp[nbe*4+0] = v1; 73 edgestemp[nbe*4+1] = v2; 74 edgestemp[nbe*4+2] = i+1; 75 if(v1!=iomodel->elements[i*3+j]) exchange[nbe]=true; 94 edgestemp[nbe*2+0] = v1+1; 95 edgestemp[nbe*2+1] = v2+1; 96 97 /*Update Connectivity*/ 98 element_edge_connectivity[i*elementnbv+j]=nbe; 76 99 77 100 /*Update chain*/ … … 90 113 91 114 /*Create final edges*/ 92 int* edges = xNew<int>(nbe*4); /*vertex1 vertex2 element1 element2*/ 93 for(int i=0;i<nbe;i++){ 94 if(exchange[i]){ 95 edges[i*4+0]=edgestemp[i*4+1]; 96 edges[i*4+1]=edgestemp[i*4+0]; 97 } 98 else{ 99 edges[i*4+0]=edgestemp[i*4+0]; 100 edges[i*4+1]=edgestemp[i*4+1]; 101 } 102 edges[i*4+2]=edgestemp[i*4+2]; 103 edges[i*4+3]=edgestemp[i*4+3]; 104 } 115 int* edges = xNew<int>(nbe*2); /*vertex1 vertex2*/ 116 for(int i=0;i<2*nbe;i++) edges[i] = edgestemp[i]; 117 118 /*Clean up*/ 105 119 xDelete<int>(edgestemp); 106 xDelete< bool>(exchange);120 xDelete<int>(elementedges); 107 121 108 122 /*Assign output pointers*/ 109 iomodel->edges = edges; 110 iomodel->numberofedges = nbe; 123 iomodel->edges = edges; 124 iomodel->elementtoedgeconnectivity = element_edge_connectivity; 125 iomodel->numberofedges = nbe; 111 126 } -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateNodes.cpp
r15583 r15611 45 45 case P2Enum: 46 46 EdgesPartitioning(&my_edges,iomodel); 47 CreateElementToEdgeConnectivity(iomodel);48 47 for(i=0;i<iomodel->numberofvertices;i++){ 49 48 if(iomodel->my_vertices[i]){ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
r15567 r15611 325 325 if(my_edges[i]){ 326 326 327 v1 = iomodel->edges[ 4*i+0]-1;328 v2 = iomodel->edges[ 4*i+1]-1;327 v1 = iomodel->edges[2*i+0]-1; 328 v2 = iomodel->edges[2*i+1]-1; 329 329 330 330 if(!xIsNan<IssmDouble>(spcvx[v1]) && !xIsNan<IssmDouble>(spcvx[v2])){ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/EdgesPartitioning.cpp
r15461 r15611 11 11 12 12 /*Intermediaries*/ 13 int el1,el2; 14 bool my_edge; 13 int elementnbe; 15 14 16 15 /*Get edges and elements*/ 17 16 CreateEdges(iomodel); 17 _assert_(iomodel->elementtoedgeconnectivity); 18 18 19 /*Mesh dependent variables*/ 20 if(iomodel->dim==2){ 21 elementnbe = 3; 22 } 23 else if(iomodel->dim==3){ 24 elementnbe = 9; 25 } 26 else{ 27 _error_("mesh dimension not supported yet"); 28 } 19 29 /*output: */ 20 bool* my_edges=xNew <bool>(iomodel->numberofedges);30 bool* my_edges=xNewZeroInit<bool>(iomodel->numberofedges); 21 31 22 for(int i=0;i<iomodel->numberofedges;i++){ 23 24 /*Get left and right elements*/ 25 el1=iomodel->edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2] 26 el2=iomodel->edges[4*i+3]-1; //edges are [node1 node2 elem1 elem2] 27 28 /*Check whether we should include this edge (el2 is -2 for boundary edges)*/ 29 my_edge = iomodel->my_elements[el1]; 30 if(!my_edge && el2>=0){ 31 my_edge = iomodel->my_elements[el2]; 32 for(int i=0;i<iomodel->numberofelements;i++){ 33 if(iomodel->my_elements[i]){ 34 for(int j=0;j<elementnbe;j++){ 35 my_edges[iomodel->elementtoedgeconnectivity[i*elementnbe+j]] = true; 36 } 32 37 } 33 34 my_edges[i] = my_edge;35 38 } 36 39 -
issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h
r15583 r15611 117 117 void ElementsAndVerticesPartitioning(bool** pmy_elements, int** pmy_vertices, IoModel* iomodel); 118 118 void NodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel, bool continuous); 119 void EdgesPartitioning(bool** pmy_nodes,IoModel* iomodel); 119 void FacesPartitioning(bool** pmy_faces,IoModel* iomodel); 120 void EdgesPartitioning(bool** pmy_edges,IoModel* iomodel); 121 122 /*Mesh properties*/ 123 void CreateFaces(IoModel* iomodel); 124 void CreateEdges(IoModel* iomodel); 120 125 121 126 /*Connectivity*/ 122 void CreateEdges(IoModel* iomodel);123 void CreateElementToEdgeConnectivity(IoModel* iomodel);124 127 void CreateSingleNodeToElementConnectivity(IoModel* iomodel); 125 128 void CreateNumberNodeToElementConnectivity(IoModel* iomodel); -
issm/trunk-jpl/src/c/modules/ModelProcessorx/NodesPartitioning.cpp
r15461 r15611 39 39 40 40 /* Each element has it own nodes (as many as vertices) + additional nodes 41 * from neighboring elements for each edge. This yields to a very different41 * from neighboring elements for each face. This yields to a very different 42 42 * partition for the nodes and the vertices. The vertices are similar to 43 * continuous galerkin, but the nodes partitioning involves edges, which44 * mess up sorting of ids. */43 * continuous galerkin, but the nodes partitioning involves faces, which 44 * messes up sorting of ids. */ 45 45 46 46 … … 51 51 int pos; 52 52 53 /*Get edges and elements*/53 /*Get faces and elements*/ 54 54 CreateEdges(iomodel); 55 55 … … 57 57 * - there are three nodes per element (discontinous) 58 58 * - for each element present of each partition, its three nodes will be in this partition 59 * - the edges require the dofs of the 2 nodes of each elements sharing the edge.60 * if the 2 elements sharing the edge are on 2 different cpus, we must duplicate61 * the two nodes that are not on the cpus so that the edge can access the dofs of59 * - the faces require the dofs of the 2 nodes of each elements sharing the face. 60 * if the 2 elements sharing the face are on 2 different cpus, we must duplicate 61 * the two nodes that are not on the cpus so that the face can access the dofs of 62 62 * all its 4 nodes 63 63 */ … … 67 67 68 68 /*First: add all the nodes of all the elements belonging to this cpu*/ 69 if 69 if(iomodel->dim==2){ 70 70 for (i=0;i<iomodel->numberofelements;i++){ 71 71 if (my_elements[i]){ … … 82 82 /*Second: add all missing nodes*/ 83 83 84 /*Get edges and elements*/85 Create Edges(iomodel);84 /*Get faces and elements*/ 85 CreateFaces(iomodel); 86 86 87 87 /*!All elements have been partitioned above, only create elements for this CPU: */ 88 for(int i=0;i<iomodel->numberof edges;i++){88 for(int i=0;i<iomodel->numberoffaces;i++){ 89 89 90 90 /*Get left and right elements*/ 91 e1=iomodel-> edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2]92 e2=iomodel-> edges[4*i+3]-1; //edges are [node1 node2 elem1 elem2]91 e1=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2] 92 e2=iomodel->faces[4*i+3]-1; //faces are [node1 node2 elem1 elem2] 93 93 94 94 /* 1) If the element e1 is in the current partition 95 * 2) and if the edge of the element is shared by another element (internal edge)95 * 2) and if the face of the element is shared by another element (internal face) 96 96 * 3) and if this element is not in the same partition: 97 97 * we must clone the nodes on this partition so that the loads (Numericalflux) … … 100 100 101 101 /*1: Get vertices ids*/ 102 i1=iomodel-> edges[4*i+0];103 i2=iomodel-> edges[4*i+1];102 i1=iomodel->faces[4*i+0]; 103 i2=iomodel->faces[4*i+1]; 104 104 105 105 /*2: Get the column where these ids are located in the index*/ … … 124 124 } 125 125 else{ 126 _error_("Problem in edges creation");126 _error_("Problem in faces creation"); 127 127 } 128 128 } -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
r15465 r15611 25 25 if (stabilization==3){ 26 26 27 /*Get edges and elements*/28 Create Edges(iomodel);27 /*Get faces and elements*/ 28 CreateFaces(iomodel); 29 29 iomodel->FetchData(1,ThicknessEnum); 30 30 31 31 /*First load data:*/ 32 for(int i=0;i<iomodel->numberof edges;i++){32 for(int i=0;i<iomodel->numberoffaces;i++){ 33 33 34 34 /*Get left and right elements*/ 35 element=iomodel-> edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2]35 element=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2] 36 36 37 37 /*Now, if this element is not in the partition, pass: */
Note:
See TracChangeset
for help on using the changeset viewer.