/[escript]/trunk/finley/src/Mesh_prepare.cpp
ViewVC logotype

Diff of /trunk/finley/src/Mesh_prepare.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4346 by jfenwick, Tue Apr 2 04:46:45 2013 UTC revision 4492 by caltinay, Tue Jul 2 01:44:11 2013 UTC
# Line 22  Line 22 
22    
23  #include "Mesh.h"  #include "Mesh.h"
24    
25  /************************************************************************************/  using namespace finley;
26    
27  void Finley_Mesh_prepare(Finley_Mesh* in, bool_t optimize) {  void Finley_Mesh_prepare(Finley_Mesh* in, bool_t optimize) {
28       dim_t newGlobalNumDOFs=0, numReducedNodes=0,i;       dim_t newGlobalNumDOFs=0, numReducedNodes=0,i;
29       index_t* distribution=NULL, *maskReducedNodes=NULL, *indexReducedNodes=NULL, *node_distribution=NULL;       index_t* distribution=NULL, *maskReducedNodes=NULL, *node_distribution=NULL;
30       if (in==NULL) return;       if (in==NULL) return;
31       if (in->Nodes == NULL) return;       if (in->Nodes == NULL) return;
32    
# Line 39  void Finley_Mesh_prepare(Finley_Mesh* in Line 39  void Finley_Mesh_prepare(Finley_Mesh* in
39       if (! (Finley_checkPtr(distribution) || Finley_checkPtr(node_distribution))) {       if (! (Finley_checkPtr(distribution) || Finley_checkPtr(node_distribution))) {
40          /* first we create dense labeling for the DOFs */          /* first we create dense labeling for the DOFs */
41    
42          newGlobalNumDOFs=Finley_NodeFile_createDenseDOFLabeling(in->Nodes);          newGlobalNumDOFs=in->Nodes->createDenseDOFLabeling();
43    
44          /* create a distribution of the global DOFs and determine          /* create a distribution of the global DOFs and determine
45             the MPI_rank controlling the DOFs on this processor      */             the MPI_rank controlling the DOFs on this processor      */
# Line 70  void Finley_Mesh_prepare(Finley_Mesh* in Line 70  void Finley_Mesh_prepare(Finley_Mesh* in
70    
71    
72          maskReducedNodes=new index_t[in->Nodes->numNodes];          maskReducedNodes=new index_t[in->Nodes->numNodes];
73          indexReducedNodes=new index_t[in->Nodes->numNodes];          std::vector<int> indexReducedNodes(in->Nodes->numNodes);
74          if (! ( Finley_checkPtr(maskReducedNodes) ||  Finley_checkPtr(indexReducedNodes) ) ) {          if (!Finley_checkPtr(maskReducedNodes)) {
75    
76  /* useful DEBUG:  /* useful DEBUG:
77  {index_t MIN_id,MAX_id;  {index_t MIN_id,MAX_id;
78  printf("Mesh_prepare: global DOF : %d\n",newGlobalNumDOFs);  printf("Mesh_prepare: global DOF : %d\n",newGlobalNumDOFs);
79  Finley_NodeFile_setGlobalIdRange(&MIN_id,&MAX_id,in->Nodes);  in->Nodes->setGlobalIdRange(&MIN_id,&MAX_id);
80  printf("Mesh_prepare: global node id range = %d :%d\n", MIN_id,MAX_id);  printf("Mesh_prepare: global node id range = %d :%d\n", MIN_id,MAX_id);
81  Finley_NodeFile_setIdRange(&MIN_id,&MAX_id,in->Nodes);  in->Nodes->setIdRange(&MIN_id,&MAX_id);
82  printf("Mesh_prepare: local node id range = %d :%d\n", MIN_id,MAX_id);  printf("Mesh_prepare: local node id range = %d :%d\n", MIN_id,MAX_id);
83  }  }
84  */  */
# Line 87  printf("Mesh_prepare: local node id rang Line 87  printf("Mesh_prepare: local node id rang
87    
88            Finley_Mesh_markNodes(maskReducedNodes,0,in,TRUE);            Finley_Mesh_markNodes(maskReducedNodes,0,in,TRUE);
89        
90            numReducedNodes=Finley_Util_packMask(in->Nodes->numNodes,maskReducedNodes,indexReducedNodes);            numReducedNodes=util::packMask(in->Nodes->numNodes,maskReducedNodes,&indexReducedNodes[0]);
91    
92            Finley_NodeFile_createDenseNodeLabeling(in->Nodes, node_distribution, distribution);            in->Nodes->createDenseNodeLabeling(node_distribution, distribution);
93            Finley_NodeFile_createDenseReducedDOFLabeling(in->Nodes,maskReducedNodes);            // created reduced DOF labeling
94            Finley_NodeFile_createDenseReducedNodeLabeling(in->Nodes,maskReducedNodes);            in->Nodes->createDenseReducedLabeling(maskReducedNodes, false);
95            /* create the missing mappings */            // created reduced node labeling
96              in->Nodes->createDenseReducedLabeling(maskReducedNodes, true);
97    
98            if (Finley_noError()) Finley_Mesh_createNodeFileMappings(in,numReducedNodes,indexReducedNodes,distribution, node_distribution);            /* create the missing mappings */
99              if (Finley_noError())
100                    in->Nodes->createNodeMappings(numReducedNodes,indexReducedNodes,distribution, node_distribution);
101          }          }
102    
103          delete[] maskReducedNodes;          delete[] maskReducedNodes;
         delete[] indexReducedNodes;  
104       }       }
105    
106       delete[] distribution;       delete[] distribution;
107       delete[] node_distribution;       delete[] node_distribution;
108    
109       Finley_Mesh_setTagsInUse(in);       Finley_Mesh_setTagsInUse(in);
      return;  
110  }  }
111    
112  /*                                                      */  /*                                                      */
113  /*  tries to reduce the coloring for all element files: */  /*  tries to reduce the coloring for all element files: */
114  /*                                                      */  /*                                                      */
115  void Finley_Mesh_createColoring(Finley_Mesh* in, index_t *node_localDOF_map) {  void Finley_Mesh_createColoring(Finley_Mesh* in, index_t *node_localDOF_map) {
116    if (Finley_noError()) Finley_ElementFile_createColoring(in->Elements,in->Nodes->numNodes,node_localDOF_map);    if (Finley_noError()) in->Elements->createColoring(in->Nodes->numNodes,node_localDOF_map);
117    if (Finley_noError()) Finley_ElementFile_createColoring(in->FaceElements,in->Nodes->numNodes,node_localDOF_map);    if (Finley_noError()) in->FaceElements->createColoring(in->Nodes->numNodes,node_localDOF_map);
118    if (Finley_noError()) Finley_ElementFile_createColoring(in->Points,in->Nodes->numNodes,node_localDOF_map);    if (Finley_noError()) in->Points->createColoring(in->Nodes->numNodes,node_localDOF_map);
119    if (Finley_noError()) Finley_ElementFile_createColoring(in->ContactElements,in->Nodes->numNodes,node_localDOF_map);    if (Finley_noError()) in->ContactElements->createColoring(in->Nodes->numNodes,node_localDOF_map);
120  }  }
121  /*                                                                    */  /*                                                                    */
122  /*  redistribute elements to minimize communication during assemblage */  /*  redistribute elements to minimize communication during assemblage */
123  /*                                                                    */  /*                                                                    */
124  void Finley_Mesh_optimizeElementOrdering(Finley_Mesh* in) {  void Finley_Mesh_optimizeElementOrdering(Finley_Mesh* in) {
125    if (Finley_noError()) Finley_ElementFile_optimizeOrdering(&(in->Elements));    if (Finley_noError()) in->Elements->optimizeOrdering();
126    if (Finley_noError()) Finley_ElementFile_optimizeOrdering(&(in->FaceElements));    if (Finley_noError()) in->FaceElements->optimizeOrdering();
127    if (Finley_noError()) Finley_ElementFile_optimizeOrdering(&(in->Points));    if (Finley_noError()) in->Points->optimizeOrdering();
128    if (Finley_noError()) Finley_ElementFile_optimizeOrdering(&(in->ContactElements));    if (Finley_noError()) in->ContactElements->optimizeOrdering();
129  }  }
130    
 /*                                                                    */  
 /*  redistribute elements to minimize communication during assemblage */  
131  void Finley_Mesh_setTagsInUse(Finley_Mesh* in)  void Finley_Mesh_setTagsInUse(Finley_Mesh* in)
132  {  {
133      if (Finley_noError()) Finley_NodeFile_setTagsInUse(in->Nodes);      if (Finley_noError()) in->Nodes->updateTagList();
134      if (Finley_noError()) Finley_ElementFile_setTagsInUse(in->Elements);      if (Finley_noError()) in->Elements->updateTagList();
135      if (Finley_noError()) Finley_ElementFile_setTagsInUse(in->FaceElements);      if (Finley_noError()) in->FaceElements->updateTagList();
136      if (Finley_noError()) Finley_ElementFile_setTagsInUse(in->Points);      if (Finley_noError()) in->Points->updateTagList();
137      if (Finley_noError()) Finley_ElementFile_setTagsInUse(in->ContactElements);      if (Finley_noError()) in->ContactElements->updateTagList();
138  }  }
139    

Legend:
Removed from v.4346  
changed lines
  Added in v.4492

  ViewVC Help
Powered by ViewVC 1.1.26