Changeset 15430
- Timestamp:
- 07/04/13 14:55:22 (12 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r15417 r15430 243 243 ./modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp\ 244 244 ./modules/ModelProcessorx/NodesPartitioning.cpp\ 245 ./modules/ModelProcessorx/ProcessMesh2d.cpp\ 245 246 ./modules/ModelProcessorx/SortDataSets.cpp\ 246 247 ./modules/ModelProcessorx/UpdateCounters.cpp\ -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r15428 r15430 64 64 65 65 /*Initialize permanent data: */ 66 this->my_elements=NULL; 67 this->my_nodes=NULL; 68 this->my_vertices=NULL; 69 66 this->my_elements = NULL; 67 this->my_nodes = NULL; 68 this->my_vertices = NULL; 70 69 FetchData(&this->dim,MeshDimensionEnum); 71 70 FetchData(&this->numberofvertices,MeshNumberofverticesEnum); 72 71 FetchData(&this->numberofelements,MeshNumberofelementsEnum); 73 72 FetchData(&this->elements,NULL,NULL,MeshElementsEnum); 74 this->edges=NULL; 75 this->singlenodetoelementconnectivity=NULL; 76 this->numbernodetoelementconnectivity=NULL; 73 this->edges = NULL; 74 this->elementedgeconnectivity = NULL; 75 this->singlenodetoelementconnectivity = NULL; 76 this->numbernodetoelementconnectivity = NULL; 77 77 78 78 this->nodecounter=0; … … 83 83 /*FUNCTION IoModel::~IoModel(){{{*/ 84 84 IoModel::~IoModel(){ 85 86 if(this->constants) delete this->constants;87 85 88 86 /*Some checks in debugging mode*/ … … 97 95 #endif 98 96 97 if(this->constants) delete this->constants; 98 99 99 xDelete<IssmDouble*>(this->data); 100 100 xDelete<bool>(this->independents); 101 101 if(this->independent_objects)delete this->independent_objects; 102 102 103 xDelete<bool>(this->my_elements); 103 104 xDelete<bool>(this->my_nodes); 104 105 xDelete<int>(this->my_vertices); 106 105 107 xDelete<int>(this->elements); 106 108 xDelete<int>(this->edges); 109 xDelete<int>(this->elementedgeconnectivity); 107 110 xDelete<int>(this->singlenodetoelementconnectivity); 108 111 xDelete<int>(this->numbernodetoelementconnectivity); -
issm/trunk-jpl/src/c/classes/IoModel.h
r15428 r15430 35 35 int numberofvertices; 36 36 int numberofelements; 37 int numberofedges; 37 38 int *elements; 38 39 int *edges; 40 int *elementedgeconnectivity; 39 41 int *singlenodetoelementconnectivity; 40 42 int *numbernodetoelementconnectivity; -
issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp
r15428 r15430 33 33 /*}}}*/ 34 34 /*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/ 35 Numericalflux::Numericalflux(int numericalflux_id,int i, 35 Numericalflux::Numericalflux(int numericalflux_id,int i,int index,IoModel* iomodel, int in_analysis_type){ 36 36 37 37 /* Intermediary */ 38 int e1,e2;39 int i1,i2;40 38 int j; 41 39 int pos1,pos2,pos3,pos4; … … 50 48 int numericalflux_type; 51 49 52 int numberofelements;53 54 /*Fetch parameters: */55 iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);56 57 50 /* Get MatPar id */ 58 numericalflux_mparid=numberofelements+1; //matlab indexing 51 numericalflux_mparid=iomodel->numberofelements+1; //matlab indexing 52 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]; 59 58 60 59 /*First, see wether this is an internal or boundary edge (if e2=-1)*/ 61 if (iomodel->Data(MeshEdgesEnum)[4*i+3]==-1.){ //edges are [node1 node2 elem1 elem2]60 if(e2==-1){ 62 61 /* Boundary edge, only one element */ 63 e1=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2]); 64 e2=reCast<int>(UNDEF); 65 num_elems=1; 66 num_nodes=2; 62 num_elems=1; num_nodes=2; 67 63 numericalflux_type=BoundaryEnum; 68 64 numericalflux_elem_ids[0]=e1; … … 70 66 else{ 71 67 /* internal edge: connected to 2 elements */ 72 e1=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2]); 73 e2=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+3]); 74 num_elems=2; 75 num_nodes=4; 68 num_elems=2; num_nodes=4; 76 69 numericalflux_type=InternalEnum; 77 70 numericalflux_elem_ids[0]=e1; … … 80 73 81 74 /*1: Get vertices ids*/ 82 i1=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+0]);83 i2=reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+1]);84 75 numericalflux_vertex_ids[0]=i1; 85 76 numericalflux_vertex_ids[1]=i2; … … 93 84 pos1=pos2=pos3=pos4=UNDEF; 94 85 for(j=0;j<3;j++){ 95 if 96 if 97 if 98 if 86 if(iomodel->elements[3*(e1-1)+j]==i1) pos1=j+1; 87 if(iomodel->elements[3*(e1-1)+j]==i2) pos2=j+1; 88 if(iomodel->elements[3*(e2-1)+j]==i1) pos3=j+1; 89 if(iomodel->elements[3*(e2-1)+j]==i2) pos4=j+1; 99 90 } 100 91 _assert_(pos1!=UNDEF && pos2!=UNDEF && pos3!=UNDEF && pos4!=UNDEF); … … 112 103 pos1=pos2=UNDEF; 113 104 for(j=0;j<3;j++){ 114 if 115 if 105 if(iomodel->elements[3*(e1-1)+j]==i1) pos1=j+1; 106 if(iomodel->elements[3*(e1-1)+j]==i2) pos2=j+1; 116 107 } 117 108 _assert_(pos1!=UNDEF && pos2!=UNDEF); -
issm/trunk-jpl/src/c/classes/Loads/Numericalflux.h
r15373 r15430 37 37 /*Numericalflux constructors,destructors {{{*/ 38 38 Numericalflux(); 39 Numericalflux(int numericalflux_id,int i, 39 Numericalflux(int numericalflux_id,int i,int index,IoModel* iomodel,int analysis_type); 40 40 ~Numericalflux(); 41 41 /*}}}*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp
r15428 r15430 12 12 int element; 13 13 int stabilization; 14 int numberofedges;15 14 16 15 /*Fetch parameters: */ 17 16 iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum); 18 iomodel->Constant(&numberofedges,MeshNumberofedgesEnum);19 17 20 18 /*Recover pointer: */ … … 28 26 29 27 /*Get edges and elements*/ 30 iomodel->FetchData(2,MeshEdgesEnum,ThicknessEnum); 28 ProcessMesh2d(&iomodel->edges,&iomodel->numberofedges,NULL,iomodel->elements,iomodel->numberofelements,iomodel->numberofvertices); 29 iomodel->FetchData(1,ThicknessEnum); 31 30 32 31 /*First load data:*/ 33 for (int i=0;i<numberofedges;i++){32 for(int i=0;i<iomodel->numberofedges;i++){ 34 33 35 34 /*Get left and right elements*/ 36 element= reCast<int,IssmDouble>(iomodel->Data(MeshEdgesEnum)[4*i+2])-1; //edges are [node1 node2 elem1 elem2]35 element=iomodel->edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2] 37 36 38 37 /*Now, if this element is not in the partition, pass: */ … … 40 39 41 40 /* Add load */ 42 loads->AddObject(new Numericalflux(iomodel->loadcounter+i+1,i,i omodel,BalancethicknessAnalysisEnum));41 loads->AddObject(new Numericalflux(iomodel->loadcounter+i+1,i,i,iomodel,BalancethicknessAnalysisEnum)); 43 42 } 44 43 45 44 /*Free data: */ 46 iomodel->DeleteData( 2,MeshEdgesEnum,ThicknessEnum);45 iomodel->DeleteData(1,ThicknessEnum); 47 46 } 48 47 -
issm/trunk-jpl/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp
r15428 r15430 49 49 50 50 if(false){ 51 51 52 /*Quadratic element*/ 52 int numberofedges;53 ProcessMesh2d(&iomodel->edges,&iomodel->numberofedges,NULL,iomodel->elements,iomodel->numberofelements,iomodel->numberofvertices); 53 54 int element1,element2; 54 55 bool my_edge; 55 56 56 iomodel->Constant(&numberofedges,MeshNumberofedgesEnum); 57 58 for(int i=0;i<numberofedges;i++){ 57 for(int i=0;i<iomodel->numberofedges;i++){ 59 58 60 59 /*Get left and right elements*/ 61 element1= reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2])-1; //edges are [node1 node2 elem1 elem2]62 element2= reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+3])-1; //edges are [node1 node2 elem1 elem2]60 element1=iomodel->edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2] 61 element2=iomodel->edges[4*i+3]-1; //edges are [node1 node2 elem1 elem2] 63 62 64 63 /*Check whether we should include this edge (element2 is -2 for boundary edges)*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h
r15037 r15430 13 13 14 14 /*Creation of fem datasets: general drivers*/ 15 void 16 void 17 void 18 void 19 void 20 void 21 void 22 void 23 void 24 void 15 void CreateDataSets(Elements** pelements,Nodes** pnodes,Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads,Parameters** pparameters,IoModel* iomodel,char* rootpath,const int solution_type,int analysis_type,const int nummodels,int analysis_counter); 16 void CreateElementsVerticesAndMaterials(Elements** pelements,Vertices** pvertices,Materials** pmaterials, IoModel* iomodel,const int nummodels); 17 void CreateParameters(Parameters** pparameters,IoModel* iomodel,char* rootpath,const int solution_type,int analysis_type,int analysis_counter); 18 void CreateParametersAutodiff(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type); 19 void CreateParametersControl(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type); 20 void CreateParametersDakota(Parameters** pparameters,IoModel* iomodel,char* rootpath,int solution_type,int analysis_type); 21 void CreateParametersHydrologyShreve(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type); 22 void CreateParametersHydrologyDCInefficient(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type); 23 void CreateParametersHydrologyDCEfficient(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type); 24 void UpdateElementsAndMaterialsControl(Elements* elements,Materials* materials, IoModel* iomodel); 25 25 26 26 /*Creation of fem datasets: specialised drivers: */ 27 27 28 28 /*diagnostic horizontal*/ 29 void 30 void 31 void 32 void 29 void CreateNodesDiagnosticHoriz(Nodes** pnodes,IoModel* iomodel); 30 void CreateConstraintsDiagnosticHoriz(Constraints** pconstraints,IoModel* iomodel); 31 void CreateLoadsDiagnosticHoriz(Loads** ploads, IoModel* iomodel); 32 void UpdateElementsDiagnosticHoriz(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 33 33 34 34 /*diagnostic vertical*/ … … 71 71 72 72 /*enthalpy:*/ 73 void 74 void 75 void 76 void 73 void CreateNodesEnthalpy(Nodes** pnodes,IoModel* iomodel); 74 void CreateConstraintsEnthalpy(Constraints** pconstraints,IoModel* iomodel); 75 void CreateLoadsEnthalpy(Loads** ploads, IoModel* iomodel); 76 void UpdateElementsEnthalpy(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 77 77 78 78 /*hydrology Shreve:*/ 79 void 80 void 81 void 82 void 79 void CreateNodesHydrologyShreve(Nodes** pnodes,IoModel* iomodel); 80 void CreateConstraintsHydrologyShreve(Constraints** pconstraints,IoModel* iomodel); 81 void CreateLoadsHydrologyShreve(Loads** ploads, IoModel* iomodel); 82 void UpdateElementsHydrologyShreve(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 83 83 84 84 /*hydrology DC:*/ 85 void 86 void 87 void 88 void 89 void 90 void 91 void 92 void 85 void CreateNodesHydrologyDCInefficient(Nodes** pnodes,IoModel* iomodel); 86 void CreateConstraintsHydrologyDCInefficient(Constraints** pconstraints,IoModel* iomodel); 87 void CreateLoadsHydrologyDCInefficient(Loads** ploads, IoModel* iomodel); 88 void UpdateElementsHydrologyDCInefficient(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 89 void CreateNodesHydrologyDCEfficient(Nodes** pnodes,IoModel* iomodel); 90 void CreateConstraintsHydrologyDCEfficient(Constraints** pconstraints,IoModel* iomodel); 91 void CreateLoadsHydrologyDCEfficient(Loads** ploads, IoModel* iomodel); 92 void UpdateElementsHydrologyDCEfficient(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 93 93 94 94 /*melting:*/ 95 void 96 void 97 void 98 void 95 void CreateNodesMelting(Nodes** pnodes,IoModel* iomodel); 96 void CreateConstraintsMelting(Constraints** pconstraints,IoModel* iomodel); 97 void CreateLoadsMelting(Loads** ploads, IoModel* iomodel); 98 void UpdateElementsMelting(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 99 99 100 100 /*prognostic:*/ 101 void 102 void 103 void 104 void 101 void CreateNodesPrognostic(Nodes** pnodes,IoModel* iomodel); 102 void CreateConstraintsPrognostic(Constraints** pconstraints,IoModel* iomodel); 103 void CreateLoadsPrognostic(Loads** ploads, IoModel* iomodel); 104 void UpdateElementsPrognostic(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 105 105 106 106 /*balancedthickness:*/ 107 void 108 void 109 void 110 void 107 void CreateNodesBalancethickness(Nodes** pnodes,IoModel* iomodel); 108 void CreateConstraintsBalancethickness(Constraints** pconstraints,IoModel* iomodel); 109 void CreateLoadsBalancethickness(Loads** ploads, IoModel* iomodel); 110 void UpdateElementsBalancethickness(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type); 111 111 112 112 /*transient: */ 113 void 113 void UpdateElementsTransient(Elements* elements,Parameters* parameters,IoModel* iomodel,int analysis_counter,int analysis_type); 114 114 115 115 /*partitioning: */ 116 void 117 void 116 void ElementsAndVerticesPartitioning(bool** pmy_elements, int** pmy_vertices, IoModel* iomodel); 117 void NodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel, bool continuous); 118 118 119 119 /*Connectivity*/ 120 void CreateSingleNodeToElementConnectivity(IoModel* iomodel); 121 void CreateNumberNodeToElementConnectivity(IoModel* iomodel); 120 void ProcessMesh2d(int**,int*,int**,int* index,int numberofelements,int numberofvertices); 121 void CreateSingleNodeToElementConnectivity(IoModel* iomodel); 122 void CreateNumberNodeToElementConnectivity(IoModel* iomodel); 122 123 123 124 /*Diverse: */ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/NodesPartitioning.cpp
r15428 r15430 20 20 void NodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel, bool continuous){ 21 21 22 /*First thing, this is a new partition for a new analysis_type, therefore, to avoid a leak, erase the nodes partition that might come through pmy_nodes: */ 22 /*First thing, this is a new partition for a new analysis_type, therefore, 23 * to avoid a leak, erase the nodes partition that might come through 24 * pmy_nodes: */ 23 25 xDelete<bool>(*pmy_nodes); 24 26 … … 42 44 void DiscontinuousGalerkinNodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel){ 43 45 44 /*each element has it own nodes (as many as vertices) + additional nodes from neighbouring elements for each edge. This yields to a very different partition for 45 * the nodes and the vertices. The vertices are similar to continuous galerkin, but the nodes partitioning involves edges, which mess up sorting of 46 * ids. */ 46 /* Each element has it own nodes (as many as vertices) + additional nodes 47 * from neighboring elements for each edge. This yields to a very different 48 * partition for the nodes and the vertices. The vertices are similar to 49 * continuous galerkin, but the nodes partitioning involves edges, which 50 * mess up sorting of ids. */ 47 51 48 /*output: */49 bool* my_nodes=NULL;50 52 53 /*Intermediaries*/ 51 54 int i,i1,i2; 52 55 int cols; 53 56 int e1,e2; 54 57 int pos; 55 int numberofedges; 56 int *edges = NULL;57 int *elements = NULL;58 59 /*Get edges and elements*/ 60 ProcessMesh2d(&iomodel->edges,&iomodel->numberofedges,NULL,iomodel->elements,iomodel->numberofelements,iomodel->numberofvertices); 58 61 59 62 /*Build discontinuous node partitioning … … 67 70 68 71 /*Allocate*/ 69 my_nodes=xNewZeroInit<bool>(3*iomodel->numberofelements);72 bool* my_nodes=xNewZeroInit<bool>(3*iomodel->numberofelements); 70 73 71 74 /*First: add all the nodes of all the elements belonging to this cpu*/ … … 86 89 87 90 /*Get edges and elements*/ 88 iomodel->FetchData(&edges,&numberofedges,&cols,MeshEdgesEnum); 89 if (cols!=4) _error_("field edges should have 4 columns"); 91 ProcessMesh2d(&iomodel->edges,&iomodel->numberofedges,NULL,iomodel->elements,iomodel->numberofelements,iomodel->numberofvertices); 90 92 91 93 /*!All elements have been partitioned above, only create elements for this CPU: */ 92 for (i=0;i<numberofedges;i++){94 for(int i=0;i<iomodel->numberofedges;i++){ 93 95 94 96 /*Get left and right elements*/ 95 e1= edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2]96 e2= edges[4*i+3]-1; //edges are [node1 node2 elem1 elem2]97 e1=iomodel->edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2] 98 e2=iomodel->edges[4*i+3]-1; //edges are [node1 node2 elem1 elem2] 97 99 98 100 /* 1) If the element e1 is in the current partition … … 104 106 105 107 /*1: Get vertices ids*/ 106 i1= edges[4*i+0];107 i2= edges[4*i+1];108 i1=iomodel->edges[4*i+0]; 109 i2=iomodel->edges[4*i+1]; 108 110 109 111 /*2: Get the column where these ids are located in the index*/ … … 115 117 /*3: We have the id of the elements and the position of the vertices in the index 116 118 * we can now create the corresponding nodes:*/ 117 if 119 if(pos==0){ 118 120 my_nodes[e2*3+0]=true; 119 121 my_nodes[e2*3+2]=true; … … 123 125 my_nodes[e2*3+0]=true; 124 126 } 125 else if 127 else if(pos==2){ 126 128 my_nodes[e2*3+2]=true; 127 129 my_nodes[e2*3+1]=true; … … 133 135 } 134 136 135 /*Free data: */ 136 xDelete<int>(edges); 137 138 /*Assign output pointers:*/ 137 /*Free data and assign output pointers */ 139 138 *pmy_nodes=my_nodes; 140 139 } -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
r15428 r15430 10 10 11 11 /*Intermediaries*/ 12 int i;13 12 int element; 14 13 int penpair_ids[2]; 15 14 int count=0; 16 15 int stabilization; 17 int numberofedges;18 16 int numvertex_pairing; 19 17 20 18 /*Fetch parameters: */ 21 19 iomodel->Constant(&stabilization,PrognosticStabilizationEnum); 22 iomodel->Constant(&numberofedges,MeshNumberofedgesEnum);23 20 24 21 /*Recover pointer: */ … … 32 29 33 30 /*Get edges and elements*/ 34 iomodel->FetchData(2,MeshEdgesEnum,ThicknessEnum); 31 ProcessMesh2d(&iomodel->edges,&iomodel->numberofedges,NULL,iomodel->elements,iomodel->numberofelements,iomodel->numberofvertices); 32 iomodel->FetchData(1,ThicknessEnum); 35 33 36 34 /*First load data:*/ 37 for (i=0;i<numberofedges;i++){35 for(int i=0;i<iomodel->numberofedges;i++){ 38 36 39 37 /*Get left and right elements*/ 40 element= reCast<int>(iomodel->Data(MeshEdgesEnum)[4*i+2])-1; //edges are [node1 node2 elem1 elem2]38 element=iomodel->edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2] 41 39 42 40 /*Now, if this element is not in the partition, pass: */ … … 44 42 45 43 /* Add load */ 46 loads->AddObject(new Numericalflux(iomodel->loadcounter+i+1,i,i omodel,PrognosticAnalysisEnum));44 loads->AddObject(new Numericalflux(iomodel->loadcounter+i+1,i,i,iomodel,PrognosticAnalysisEnum)); 47 45 } 48 46 49 47 /*Free data: */ 50 iomodel->DeleteData( 2,MeshEdgesEnum,ThicknessEnum);48 iomodel->DeleteData(1,ThicknessEnum); 51 49 } 52 50 … … 57 55 iomodel->FetchData(&nodeonbed,NULL,NULL,MeshVertexonbedEnum); 58 56 59 for(i =0;i<numvertex_pairing;i++){57 for(int i=0;i<numvertex_pairing;i++){ 60 58 61 59 if(iomodel->my_vertices[reCast<int>(vertex_pairing[2*i+0])-1]){
Note:
See TracChangeset
for help on using the changeset viewer.