/[escript]/trunk/finley/src/Mesh_createNodeFileMappings.c
ViewVC logotype

Diff of /trunk/finley/src/Mesh_createNodeFileMappings.c

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

revision 1741 by gross, Mon Sep 1 04:06:41 2008 UTC revision 1804 by gross, Wed Sep 24 07:52:19 2008 UTC
# Line 23  Line 23 
23  #include "Mesh.h"  #include "Mesh.h"
24  #define UNUSED -1  #define UNUSED -1
25    
 #define BOUNDS_CHECK 1  
   
26  /**************************************************************/  /**************************************************************/
27    
28  void Mesh_createDOFMappingAndCoupling(Finley_Mesh* in, bool_t use_reduced_elements)  void Mesh_createDOFMappingAndCoupling(Finley_Mesh* in, bool_t use_reduced_elements)
# Line 255  void Mesh_createDOFMappingAndCoupling(Fi Line 253  void Mesh_createDOFMappingAndCoupling(Fi
253    }    }
254  }  }
255    
256  void Finley_Mesh_createMappings(Finley_Mesh* mesh, index_t* distribution) {  void Finley_Mesh_createMappings(Finley_Mesh* mesh, index_t* dof_distribution, index_t* node_distribution) {
257    int i;    int i;
258    index_t *maskReducedNodes=NULL, *indexReducedNodes=NULL;    index_t *maskReducedNodes=NULL, *indexReducedNodes=NULL;
259    dim_t numReducedNodes;    dim_t numReducedNodes;
# Line 267  void Finley_Mesh_createMappings(Finley_M Line 265  void Finley_Mesh_createMappings(Finley_M
265      #pragma omp parallel for private(i) schedule(static)      #pragma omp parallel for private(i) schedule(static)
266      for (i=0;i<mesh->Nodes->numNodes;++i) maskReducedNodes[i]=-1;      for (i=0;i<mesh->Nodes->numNodes;++i) maskReducedNodes[i]=-1;
267      Finley_Mesh_markNodes(maskReducedNodes,0,mesh,TRUE);      Finley_Mesh_markNodes(maskReducedNodes,0,mesh,TRUE);
268    
269      numReducedNodes=Finley_Util_packMask(mesh->Nodes->numNodes,maskReducedNodes,indexReducedNodes);      numReducedNodes=Finley_Util_packMask(mesh->Nodes->numNodes,maskReducedNodes,indexReducedNodes);
270      if (Finley_noError()) Finley_Mesh_createNodeFileMappings(mesh,numReducedNodes,indexReducedNodes,distribution);      if (Finley_noError()) Finley_Mesh_createNodeFileMappings(mesh,numReducedNodes,indexReducedNodes,dof_distribution, node_distribution);
271    }    }
272    
273    TMPMEMFREE(maskReducedNodes);    TMPMEMFREE(maskReducedNodes);
274    TMPMEMFREE(indexReducedNodes);    TMPMEMFREE(indexReducedNodes);
275  }  }
276    
277  void Finley_Mesh_createNodeFileMappings(Finley_Mesh* in, dim_t numReducedNodes, index_t* indexReducedNodes, index_t* dof_first_component) {  void Finley_Mesh_createNodeFileMappings(Finley_Mesh* in, dim_t numReducedNodes, index_t* indexReducedNodes, index_t* dof_first_component, index_t* nodes_first_component) {
278    
279    
280    index_t myFirstDOF, myLastDOF, myFirstNode, myLastNode, *reduced_dof_first_component=NULL, *nodeMask=NULL,    index_t myFirstDOF, myLastDOF, myFirstNode, myLastNode, *reduced_dof_first_component=NULL, *nodeMask=NULL,
281           *reduced_nodes_first_component=NULL, *nodes_first_component=NULL,k,           *reduced_nodes_first_component=NULL, k,*maskMyReducedDOF=NULL, *indexMyReducedDOF=NULL, *maskMyReducedNodes=NULL, *indexMyReducedNodes=NULL;
          *maskMyReducedDOF=NULL, *indexMyReducedDOF=NULL, *maskMyReducedNodes=NULL, *indexMyReducedNodes=NULL;  
282    dim_t myNumDOF, myNumNodes, myNumReducedNodes, myNumReducedDOF, globalNumReducedNodes, globalNumReducedDOF,i,mpiSize, minGlobalNodeIndex,maxGlobalNodeIndex;    dim_t myNumDOF, myNumNodes, myNumReducedNodes, myNumReducedDOF, globalNumReducedNodes, globalNumReducedDOF,i,mpiSize, minGlobalNodeIndex,maxGlobalNodeIndex;
283    Paso_MPI_rank myRank;    Paso_MPI_rank myRank;
284    
285    mpiSize=in->Nodes->MPIInfo->size;    mpiSize=in->Nodes->MPIInfo->size;
286    myRank=in->Nodes->MPIInfo->rank;    myRank=in->Nodes->MPIInfo->rank;
287    
288    /* mark the nodes used by the reduced mesh */    /* mark the nodes used by the reduced mesh */
289    
290    reduced_dof_first_component=TMPMEMALLOC(mpiSize+1,index_t);    reduced_dof_first_component=TMPMEMALLOC(mpiSize+1,index_t);
291    reduced_nodes_first_component=TMPMEMALLOC(mpiSize+1,index_t);    reduced_nodes_first_component=TMPMEMALLOC(mpiSize+1,index_t);
   nodes_first_component=TMPMEMALLOC(mpiSize+1,index_t);  
   
   if (! ( Finley_checkPtr(reduced_dof_first_component) || Finley_checkPtr(reduced_nodes_first_component) || Finley_checkPtr(nodes_first_component)  ) ) {  
292    
293       Finley_NodeFile_setGlobalNodeIDIndexRange(&minGlobalNodeIndex,&maxGlobalNodeIndex,in->Nodes);    if (! ( Finley_checkPtr(reduced_dof_first_component) || Finley_checkPtr(reduced_nodes_first_component) ) ) {
      Paso_MPIInfo_setDistribution(in->Nodes->MPIInfo,minGlobalNodeIndex,maxGlobalNodeIndex,nodes_first_component);  
294    
295       myFirstDOF=dof_first_component[myRank];       myFirstDOF=dof_first_component[myRank];
296       myLastDOF=dof_first_component[myRank+1];       myLastDOF=dof_first_component[myRank+1];
297       myNumDOF=myLastDOF-myFirstDOF;       myNumDOF=myLastDOF-myFirstDOF;
298    
299       myFirstNode=nodes_first_component[myRank];       myFirstNode=nodes_first_component[myRank];
300       myLastNode=nodes_first_component[myRank+1];       myLastNode=nodes_first_component[myRank+1];
301       myNumNodes=myLastNode-myFirstNode;       myNumNodes=myLastNode-myFirstNode;
# Line 351  void Finley_Mesh_createNodeFileMappings( Line 347  void Finley_Mesh_createNodeFileMappings(
347          reduced_nodes_first_component[mpiSize]=globalNumReducedNodes;          reduced_nodes_first_component[mpiSize]=globalNumReducedNodes;
348          reduced_dof_first_component[mpiSize]=globalNumReducedDOF;          reduced_dof_first_component[mpiSize]=globalNumReducedDOF;
349          /* ==== distribution of Nodes ===============================*/          /* ==== distribution of Nodes ===============================*/
         Paso_MPIInfo_setDistribution(in->Nodes->MPIInfo,minGlobalNodeIndex,maxGlobalNodeIndex,nodes_first_component);  
350          in->Nodes->nodesDistribution=Paso_Distribution_alloc(in->Nodes->MPIInfo,nodes_first_component,1,0);          in->Nodes->nodesDistribution=Paso_Distribution_alloc(in->Nodes->MPIInfo,nodes_first_component,1,0);
351            
352          /* ==== distribution of Nodes ===============================*/          /* ==== distribution of DOFs ===============================*/
353          in->Nodes->degreesOfFreedomDistribution=Paso_Distribution_alloc(in->Nodes->MPIInfo,dof_first_component,1,0);          in->Nodes->degreesOfFreedomDistribution=Paso_Distribution_alloc(in->Nodes->MPIInfo,dof_first_component,1,0);
354            
355          /* ==== distribution of reduced Nodes ===============================*/          /* ==== distribution of reduced Nodes ===============================*/
         reduced_nodes_first_component[mpiSize]=globalNumReducedNodes;  
356          in->Nodes->reducedNodesDistribution=Paso_Distribution_alloc(in->Nodes->MPIInfo,reduced_nodes_first_component,1,0);          in->Nodes->reducedNodesDistribution=Paso_Distribution_alloc(in->Nodes->MPIInfo,reduced_nodes_first_component,1,0);
357            
358          /* ==== distribution of reduced DOF ===============================*/          /* ==== distribution of reduced DOF ===============================*/
# Line 371  void Finley_Mesh_createNodeFileMappings( Line 365  void Finley_Mesh_createNodeFileMappings(
365    }    }
366    TMPMEMFREE(reduced_dof_first_component);    TMPMEMFREE(reduced_dof_first_component);
367    TMPMEMFREE(reduced_nodes_first_component);    TMPMEMFREE(reduced_nodes_first_component);
   TMPMEMFREE(nodes_first_component);  
368    
369    nodeMask=TMPMEMALLOC(in->Nodes->numNodes,index_t);    nodeMask=TMPMEMALLOC(in->Nodes->numNodes,index_t);
370    if (! Finley_checkPtr(nodeMask) && Finley_noError()) {    if (! Finley_checkPtr(nodeMask) && Finley_noError()) {
# Line 387  void Finley_Mesh_createNodeFileMappings( Line 380  void Finley_Mesh_createNodeFileMappings(
380      #pragma omp parallel for private(i) schedule(static)      #pragma omp parallel for private(i) schedule(static)
381      for (i=0;i<numReducedNodes;++i) nodeMask[indexReducedNodes[i]]=i;      for (i=0;i<numReducedNodes;++i) nodeMask[indexReducedNodes[i]]=i;
382      in->Nodes->reducedNodesMapping=Finley_NodeMapping_alloc(in->Nodes->numNodes,nodeMask,UNUSED);      in->Nodes->reducedNodesMapping=Finley_NodeMapping_alloc(in->Nodes->numNodes,nodeMask,UNUSED);
   
383    }    }
384    TMPMEMFREE(nodeMask);    TMPMEMFREE(nodeMask);
385    /* ==== mapping between nodes and DOFs + DOF connector ========== */    /* ==== mapping between nodes and DOFs + DOF connector ========== */

Legend:
Removed from v.1741  
changed lines
  Added in v.1804

  ViewVC Help
Powered by ViewVC 1.1.26