/[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

trunk/finley/src/Mesh_prepare.c revision 1766 by gross, Mon Sep 8 02:51:14 2008 UTC trunk/finley/src/Mesh_prepare.cpp revision 4346 by jfenwick, Tue Apr 2 04:46:45 2013 UTC
# Line 1  Line 1 
1    
2  /* $Id$ */  /*****************************************************************************
3    *
4    * Copyright (c) 2003-2013 by University of Queensland
5    * http://www.uq.edu.au
6    *
7    * Primary Business: Queensland, Australia
8    * Licensed under the Open Software License version 3.0
9    * http://www.opensource.org/licenses/osl-3.0.php
10    *
11    * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12    * Development since 2012 by School of Earth Sciences
13    *
14    *****************************************************************************/
15    
 /*******************************************************  
  *  
  *           Copyright 2003-2007 by ACceSS MNRF  
  *       Copyright 2007 by University of Queensland  
  *  
  *                http://esscc.uq.edu.au  
  *        Primary Business: Queensland, Australia  
  *  Licensed under the Open Software License version 3.0  
  *     http://www.opensource.org/licenses/osl-3.0.php  
  *  
  *******************************************************/  
16    
17  /**************************************************************/  /************************************************************************************/
18    
19  /*   Finley: Mesh: prepares the mesh for further calculations  */  /*   Finley: Mesh: prepares the mesh for further calculations  */
20    
21  /**************************************************************/  /************************************************************************************/
22    
23  #include "Mesh.h"  #include "Mesh.h"
24    
25  /**************************************************************/  /************************************************************************************/
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;
# Line 29  void Finley_Mesh_prepare(Finley_Mesh* in Line 30  void Finley_Mesh_prepare(Finley_Mesh* in
30       if (in==NULL) return;       if (in==NULL) return;
31       if (in->Nodes == NULL) return;       if (in->Nodes == NULL) return;
32    
33         Finley_Mesh_setOrders(in);
34    
35       /* first step is to distribute the elements according to a global distribution of DOF */       /* first step is to distribute the elements according to a global distribution of DOF */
36    
37       distribution=TMPMEMALLOC(in->MPIInfo->size+1,index_t);       distribution=new index_t[in->MPIInfo->size+1];
38       node_distribution=TMPMEMALLOC(in->MPIInfo->size+1,index_t);       node_distribution=new index_t[in->MPIInfo->size+1];
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=Finley_NodeFile_createDenseDOFLabeling(in->Nodes);
43    
44          /* create a distribution of the global DOFs and determine          /* create a distribution of the global DOFs and determine
45             the MPI_rank controling the DOFs on this processor      */             the MPI_rank controlling the DOFs on this processor      */
46          Paso_MPIInfo_setDistribution(in->MPIInfo,0,newGlobalNumDOFs-1,distribution);          Esys_MPIInfo_setDistribution(in->MPIInfo,0,newGlobalNumDOFs-1,distribution);
47    
48          /* now the mesh is re-distributed according to the mpiRankOfDOF vector */          /* now the mesh is re-distributed according to the mpiRankOfDOF vector */
49          /* this will redistribute the Nodes and Elements including overlap and will create an element coloring          /* this will redistribute the Nodes and Elements including overlap and will create an element coloring
50             but will not create any mappings (see later in this function)                                   */             but will not create any mappings (see later in this function) */
51          if (Finley_noError()) Finley_Mesh_distributeByRankOfDOF(in,distribution);          if (Finley_noError()) Finley_Mesh_distributeByRankOfDOF(in,distribution);
52       }       }
53    
54       /* at this stage we are able to start an optimization of the DOF distribution using ParaMetis */       /* at this stage we are able to start an optimization of the DOF distribution using ParMetis */
55       /* on return distribution is altered and new DOF ids have been assigned */       /* on return distribution is altered and new DOF ids have been assigned */
56       if (Finley_noError() && optimize && in->MPIInfo->size>1) {       if (Finley_noError() && optimize && in->MPIInfo->size>1) {
57           Finley_Mesh_optimizeDOFDistribution(in,distribution);           Finley_Mesh_optimizeDOFDistribution(in,distribution);
58           if (Finley_noError()) Finley_Mesh_distributeByRankOfDOF(in,distribution);           if (Finley_noError()) Finley_Mesh_distributeByRankOfDOF(in,distribution);
59       }       }
60       /* the local labeling of the degrees of free is optimized */       /* the local labelling of the degrees of freedom is optimized */
61       if (Finley_noError() && optimize) {       if (Finley_noError() && optimize) {
62         Finley_Mesh_optimizeDOFLabeling(in,distribution);         Finley_Mesh_optimizeDOFLabeling(in,distribution);
63       }       }
# Line 66  void Finley_Mesh_prepare(Finley_Mesh* in Line 69  void Finley_Mesh_prepare(Finley_Mesh* in
69       if (Finley_noError()) {       if (Finley_noError()) {
70    
71    
72          maskReducedNodes=TMPMEMALLOC(in->Nodes->numNodes,index_t);          maskReducedNodes=new index_t[in->Nodes->numNodes];
73          indexReducedNodes=TMPMEMALLOC(in->Nodes->numNodes,index_t);          indexReducedNodes=new index_t[in->Nodes->numNodes];
74          if (! ( Finley_checkPtr(maskReducedNodes) ||  Finley_checkPtr(indexReducedNodes) ) ) {          if (! ( Finley_checkPtr(maskReducedNodes) ||  Finley_checkPtr(indexReducedNodes) ) ) {
75    
76  /* useful DEBUG:  /* useful DEBUG:
# Line 94  printf("Mesh_prepare: local node id rang Line 97  printf("Mesh_prepare: local node id rang
97            if (Finley_noError()) Finley_Mesh_createNodeFileMappings(in,numReducedNodes,indexReducedNodes,distribution, node_distribution);            if (Finley_noError()) Finley_Mesh_createNodeFileMappings(in,numReducedNodes,indexReducedNodes,distribution, node_distribution);
98          }          }
99    
100          TMPMEMFREE(maskReducedNodes);          delete[] maskReducedNodes;
101          TMPMEMFREE(indexReducedNodes);          delete[] indexReducedNodes;
102       }       }
103    
104       TMPMEMFREE(distribution);       delete[] distribution;
105       TMPMEMFREE(node_distribution);       delete[] node_distribution;
106    
107       Finley_Mesh_setTagsInUse(in);       Finley_Mesh_setTagsInUse(in);
108       return;       return;

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

  ViewVC Help
Powered by ViewVC 1.1.26