/[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 1738 by gross, Fri Aug 29 05:06:45 2008 UTC revision 1920 by phornby, Thu Oct 23 10:05:27 2008 UTC
# Line 1  Line 1 
1    
 /* $Id:$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2008 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  /**************************************************************/  /**************************************************************/
16    
# Line 23  Line 22 
22  #include "Mesh.h"  #include "Mesh.h"
23  #define UNUSED -1  #define UNUSED -1
24    
 #define BOUNDS_CHECK 1  
   
25  /**************************************************************/  /**************************************************************/
26    
27  void Mesh_createDOFMappingAndCoupling(Finley_Mesh* in, bool_t use_reduced_elements)  void Mesh_createDOFMappingAndCoupling(Finley_Mesh* in, bool_t use_reduced_elements)
# Line 187  void Mesh_createDOFMappingAndCoupling(Fi Line 184  void Mesh_createDOFMappingAndCoupling(Fi
184      #ifdef PASO_MPI      #ifdef PASO_MPI
185           MPI_Alltoall(rcv_len,1,MPI_INT,snd_len,1,MPI_INT,mpi_info->comm);           MPI_Alltoall(rcv_len,1,MPI_INT,snd_len,1,MPI_INT,mpi_info->comm);
186      #else      #else
187          for (p=0;p<mpiSize;++p) snd_len[p]=rcv_count[p];          for (p=0;p<mpiSize;++p) snd_len[p]=rcv_len[p];
188      #endif      #endif
189      count=0;      count=0;
190      for (p=0;p<rcv_shcomp->numNeighbors;p++) {      for (p=0;p<rcv_shcomp->numNeighbors;p++) {
# Line 255  void Mesh_createDOFMappingAndCoupling(Fi Line 252  void Mesh_createDOFMappingAndCoupling(Fi
252    }    }
253  }  }
254    
255  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) {
256    int i;    int i;
257    index_t *maskReducedNodes=NULL, *indexReducedNodes=NULL;    index_t *maskReducedNodes=NULL, *indexReducedNodes=NULL;
258    dim_t numReducedNodes;    dim_t numReducedNodes;
# Line 267  void Finley_Mesh_createMappings(Finley_M Line 264  void Finley_Mesh_createMappings(Finley_M
264      #pragma omp parallel for private(i) schedule(static)      #pragma omp parallel for private(i) schedule(static)
265      for (i=0;i<mesh->Nodes->numNodes;++i) maskReducedNodes[i]=-1;      for (i=0;i<mesh->Nodes->numNodes;++i) maskReducedNodes[i]=-1;
266      Finley_Mesh_markNodes(maskReducedNodes,0,mesh,TRUE);      Finley_Mesh_markNodes(maskReducedNodes,0,mesh,TRUE);
267    
268      numReducedNodes=Finley_Util_packMask(mesh->Nodes->numNodes,maskReducedNodes,indexReducedNodes);      numReducedNodes=Finley_Util_packMask(mesh->Nodes->numNodes,maskReducedNodes,indexReducedNodes);
269      if (Finley_noError()) Finley_Mesh_createNodeFileMappings(mesh,numReducedNodes,indexReducedNodes,distribution);      if (Finley_noError()) Finley_Mesh_createNodeFileMappings(mesh,numReducedNodes,indexReducedNodes,dof_distribution, node_distribution);
270    }    }
271    
272    TMPMEMFREE(maskReducedNodes);    TMPMEMFREE(maskReducedNodes);
273    TMPMEMFREE(indexReducedNodes);    TMPMEMFREE(indexReducedNodes);
274  }  }
275    
276  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) {
277    
278    
279    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,
280           *reduced_nodes_first_component=NULL, *nodes_first_component=NULL,k,           *reduced_nodes_first_component=NULL, k,*maskMyReducedDOF=NULL, *indexMyReducedDOF=NULL, *maskMyReducedNodes=NULL, *indexMyReducedNodes=NULL;
281           *maskMyReducedDOF=NULL, *indexMyReducedDOF=NULL, *maskMyReducedNodes=NULL, *indexMyReducedNodes=NULL;    dim_t myNumDOF, myNumNodes, myNumReducedNodes, myNumReducedDOF, globalNumReducedNodes, globalNumReducedDOF,i,mpiSize;
   dim_t myNumDOF, myNumNodes, myNumReducedNodes, myNumReducedDOF, globalNumReducedNodes, globalNumReducedDOF,i,mpiSize, minGlobalNodeIndex,maxGlobalNodeIndex;  
282    Paso_MPI_rank myRank;    Paso_MPI_rank myRank;
283    
284    mpiSize=in->Nodes->MPIInfo->size;    mpiSize=in->Nodes->MPIInfo->size;
285    myRank=in->Nodes->MPIInfo->rank;    myRank=in->Nodes->MPIInfo->rank;
286    
287    /* mark the nodes used by the reduced mesh */    /* mark the nodes used by the reduced mesh */
288    
289    reduced_dof_first_component=TMPMEMALLOC(mpiSize+1,index_t);    reduced_dof_first_component=TMPMEMALLOC(mpiSize+1,index_t);
290    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);  
291    
292    if (! ( Finley_checkPtr(reduced_dof_first_component) || Finley_checkPtr(reduced_nodes_first_component) || Finley_checkPtr(nodes_first_component)  ) ) {    if (! ( Finley_checkPtr(reduced_dof_first_component) || Finley_checkPtr(reduced_nodes_first_component) ) ) {
   
      Finley_NodeFile_setGlobalNodeIDIndexRange(&minGlobalNodeIndex,&maxGlobalNodeIndex,in->Nodes);  
      Paso_MPIInfo_setDistribution(in->Nodes->MPIInfo,minGlobalNodeIndex,maxGlobalNodeIndex,nodes_first_component);  
293    
294       myFirstDOF=dof_first_component[myRank];       myFirstDOF=dof_first_component[myRank];
295       myLastDOF=dof_first_component[myRank+1];       myLastDOF=dof_first_component[myRank+1];
296       myNumDOF=myLastDOF-myFirstDOF;       myNumDOF=myLastDOF-myFirstDOF;
297    
298       myFirstNode=nodes_first_component[myRank];       myFirstNode=nodes_first_component[myRank];
299       myLastNode=nodes_first_component[myRank+1];       myLastNode=nodes_first_component[myRank+1];
300       myNumNodes=myLastNode-myFirstNode;       myNumNodes=myLastNode-myFirstNode;
# Line 351  void Finley_Mesh_createNodeFileMappings( Line 346  void Finley_Mesh_createNodeFileMappings(
346          reduced_nodes_first_component[mpiSize]=globalNumReducedNodes;          reduced_nodes_first_component[mpiSize]=globalNumReducedNodes;
347          reduced_dof_first_component[mpiSize]=globalNumReducedDOF;          reduced_dof_first_component[mpiSize]=globalNumReducedDOF;
348          /* ==== distribution of Nodes ===============================*/          /* ==== distribution of Nodes ===============================*/
         Paso_MPIInfo_setDistribution(in->Nodes->MPIInfo,minGlobalNodeIndex,maxGlobalNodeIndex,nodes_first_component);  
349          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);
350            
351          /* ==== distribution of Nodes ===============================*/          /* ==== distribution of DOFs ===============================*/
352          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);
353            
354          /* ==== distribution of reduced Nodes ===============================*/          /* ==== distribution of reduced Nodes ===============================*/
         reduced_nodes_first_component[mpiSize]=globalNumReducedNodes;  
355          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);
356            
357          /* ==== distribution of reduced DOF ===============================*/          /* ==== distribution of reduced DOF ===============================*/
# Line 371  void Finley_Mesh_createNodeFileMappings( Line 364  void Finley_Mesh_createNodeFileMappings(
364    }    }
365    TMPMEMFREE(reduced_dof_first_component);    TMPMEMFREE(reduced_dof_first_component);
366    TMPMEMFREE(reduced_nodes_first_component);    TMPMEMFREE(reduced_nodes_first_component);
   TMPMEMFREE(nodes_first_component);  
367    
368    nodeMask=TMPMEMALLOC(in->Nodes->numNodes,index_t);    nodeMask=TMPMEMALLOC(in->Nodes->numNodes,index_t);
369    if (! Finley_checkPtr(nodeMask) && Finley_noError()) {    if (! Finley_checkPtr(nodeMask) && Finley_noError()) {
# Line 387  void Finley_Mesh_createNodeFileMappings( Line 379  void Finley_Mesh_createNodeFileMappings(
379      #pragma omp parallel for private(i) schedule(static)      #pragma omp parallel for private(i) schedule(static)
380      for (i=0;i<numReducedNodes;++i) nodeMask[indexReducedNodes[i]]=i;      for (i=0;i<numReducedNodes;++i) nodeMask[indexReducedNodes[i]]=i;
381      in->Nodes->reducedNodesMapping=Finley_NodeMapping_alloc(in->Nodes->numNodes,nodeMask,UNUSED);      in->Nodes->reducedNodesMapping=Finley_NodeMapping_alloc(in->Nodes->numNodes,nodeMask,UNUSED);
   
382    }    }
383    TMPMEMFREE(nodeMask);    TMPMEMFREE(nodeMask);
384    /* ==== mapping between nodes and DOFs + DOF connector ========== */    /* ==== mapping between nodes and DOFs + DOF connector ========== */

Legend:
Removed from v.1738  
changed lines
  Added in v.1920

  ViewVC Help
Powered by ViewVC 1.1.26