/[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 1735 by gross, Fri Aug 29 00:18:26 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 52  void Mesh_createDOFMappingAndCoupling(Fi Line 50  void Mesh_createDOFMappingAndCoupling(Fi
50      dof_distribution=in->Nodes->degreesOfFreedomDistribution;      dof_distribution=in->Nodes->degreesOfFreedomDistribution;
51      globalDOFIndex=in->Nodes->globalDegreesOfFreedom;      globalDOFIndex=in->Nodes->globalDegreesOfFreedom;
52    }    }
53      myFirstDOF=Paso_Distribution_getFirstComponent(dof_distribution);
54      myLastDOF=Paso_Distribution_getLastComponent(dof_distribution);
55    
56    
57    mpiSize=mpi_info->size;    mpiSize=mpi_info->size;
58    myRank=mpi_info->rank;    myRank=mpi_info->rank;
# Line 59  void Mesh_createDOFMappingAndCoupling(Fi Line 60  void Mesh_createDOFMappingAndCoupling(Fi
60    min_DOF=Finley_Util_getFlaggedMinInt(1,numNodes,globalDOFIndex,-1);    min_DOF=Finley_Util_getFlaggedMinInt(1,numNodes,globalDOFIndex,-1);
61    max_DOF=Finley_Util_getFlaggedMaxInt(1,numNodes,globalDOFIndex,-1);    max_DOF=Finley_Util_getFlaggedMaxInt(1,numNodes,globalDOFIndex,-1);
62    
63      if (max_DOF < min_DOF) {
64          min_DOF=myFirstDOF;
65          max_DOF=myLastDOF-1;
66      }
67    
68    p_min=mpiSize;    p_min=mpiSize;
69    p_max=-1;    p_max=-1;
70      if (max_DOF >= min_DOF) {
71    for (p=0; p<mpiSize; ++p) {        for (p=0; p<mpiSize; ++p) {
72        if (dof_distribution->first_component[p]<=min_DOF) p_min=p;           if (dof_distribution->first_component[p]<=min_DOF) p_min=p;
73        if (dof_distribution->first_component[p]<=max_DOF) p_max=p;           if (dof_distribution->first_component[p]<=max_DOF) p_max=p;
74    }       }
75       }
76    
77    len_loc_dof=max_DOF-min_DOF+1;    len_loc_dof=max_DOF-min_DOF+1;
   myFirstDOF=Paso_Distribution_getFirstComponent(dof_distribution);  
   myLastDOF=Paso_Distribution_getLastComponent(dof_distribution);  
78    if (! ((min_DOF<=myFirstDOF) && (myLastDOF-1<=max_DOF)) ) {    if (! ((min_DOF<=myFirstDOF) && (myLastDOF-1<=max_DOF)) ) {
79        Finley_setError(SYSTEM_ERROR,"Local elements do not span local degrees of freedom.");        Finley_setError(SYSTEM_ERROR,"Local elements do not span local degrees of freedom.");
80        return;        return;
# Line 180  void Mesh_createDOFMappingAndCoupling(Fi Line 185  void Mesh_createDOFMappingAndCoupling(Fi
185      #ifdef PASO_MPI      #ifdef PASO_MPI
186           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);
187      #else      #else
188          for (p=0;p<mpiSize;++p) snd_len[p]=rcv_count[p];          for (p=0;p<mpiSize;++p) snd_len[p]=rcv_len[p];
189      #endif      #endif
190      count=0;      count=0;
191      for (p=0;p<rcv_shcomp->numNeighbors;p++) {      for (p=0;p<rcv_shcomp->numNeighbors;p++) {
# Line 248  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 260  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;
282           *maskMyReducedDOF=NULL, *indexMyReducedDOF=NULL, *maskMyReducedNodes=NULL, *indexMyReducedNodes=NULL;    dim_t myNumDOF, myNumNodes, myNumReducedNodes, myNumReducedDOF, globalNumReducedNodes, globalNumReducedDOF,i,mpiSize, minGlobalNodeIndex,maxGlobalNodeIndex;
   dim_t myNumDOF, myNumNodes, myNumReducedNodes, myNumReducedDOF, globalNumReducedNodes, globalNumReducedDOF,i,mpiSize, globalNumNodes;  
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       globalNumNodes=Finley_NodeFile_maxGlobalNodeIDIndex(in->Nodes)+1;    if (! ( Finley_checkPtr(reduced_dof_first_component) || Finley_checkPtr(reduced_nodes_first_component) ) ) {
      Paso_MPIInfo_setDistribution(in->Nodes->MPIInfo,0,globalNumNodes-1,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 344  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,0,globalNumNodes-1,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 364  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 380  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.1735  
changed lines
  Added in v.1804

  ViewVC Help
Powered by ViewVC 1.1.26