/[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 1562 by gross, Wed May 21 13:04:40 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 27  Line 26 
26    
27  void Mesh_createDOFMappingAndCoupling(Finley_Mesh* in, bool_t use_reduced_elements)  void Mesh_createDOFMappingAndCoupling(Finley_Mesh* in, bool_t use_reduced_elements)
28  {  {
29    index_t min_DOF, max_DOF, *shared=NULL, *offsetInShared=NULL, *locDOFMask=NULL, i, k, myFirstDOF, myLastDOF, *nodeMask=NULL, firstDOF, lastDOF, *globalDOFIndex;    index_t min_DOF, max_DOF, *shared=NULL, *offsetInShared=NULL, *locDOFMask=NULL, i, k, myFirstDOF, myLastDOF, *nodeMask=NULL, firstDOF, lastDOF, *globalDOFIndex, *wanted_DOFs=NULL;
30    dim_t mpiSize, len_loc_dof, numNeighbors, n, lastn, numNodes;    dim_t mpiSize, len_loc_dof, numNeighbors, n, lastn, numNodes,*rcv_len=NULL, *snd_len=NULL, count;
31    Paso_MPI_rank myRank,p,p_min,p_max, *neighbor=NULL;    Paso_MPI_rank myRank,p,p_min,p_max, *neighbor=NULL;
32    Paso_SharedComponents *rcv_shcomp=NULL, *snd_shcomp=NULL;    Paso_SharedComponents *rcv_shcomp=NULL, *snd_shcomp=NULL;
33    Finley_NodeMapping *this_mapping=NULL;    Finley_NodeMapping *this_mapping=NULL;
34    Paso_Connector* this_connector=NULL;    Paso_Connector* this_connector=NULL;
35    Paso_Distribution* dof_distribution;    Paso_Distribution* dof_distribution;
36        Paso_MPIInfo *mpi_info = in->MPIInfo;
37      #ifdef PASO_MPI
38          MPI_Request* mpi_requests=NULL;
39          MPI_Status* mpi_stati=NULL;
40      #else
41          int *mpi_requests=NULL, *mpi_stati=NULL;
42      #endif
43    
44    numNodes=in->Nodes->numNodes;    numNodes=in->Nodes->numNodes;
45    if (use_reduced_elements) {    if (use_reduced_elements) {
46      dof_distribution=in->Nodes->reducedDegreesOfFreedomDistribution;      dof_distribution=in->Nodes->reducedDegreesOfFreedomDistribution;
47      globalDOFIndex=in->Nodes->globalReducedDOFIndex;      globalDOFIndex=in->Nodes->globalReducedDOFIndex;
     Finley_NodeFile_setReducedDOFRange(&min_DOF, &max_DOF,in->Nodes);  
48    } else {    } else {
49      dof_distribution=in->Nodes->degreesOfFreedomDistribution;      dof_distribution=in->Nodes->degreesOfFreedomDistribution;
50      globalDOFIndex=in->Nodes->globalDegreesOfFreedom;      globalDOFIndex=in->Nodes->globalDegreesOfFreedom;
     Finley_NodeFile_setDOFRange(&min_DOF, &max_DOF,in->Nodes);  
51    }    }
52      myFirstDOF=Paso_Distribution_getFirstComponent(dof_distribution);
53      myLastDOF=Paso_Distribution_getLastComponent(dof_distribution);
54    
55    mpiSize=dof_distribution->mpi_info->size;  
56    myRank=dof_distribution->mpi_info->rank;    mpiSize=mpi_info->size;
57      myRank=mpi_info->rank;
58    
59    min_DOF=Finley_Util_getFlaggedMinInt(1,numNodes,globalDOFIndex,-1);    min_DOF=Finley_Util_getFlaggedMinInt(1,numNodes,globalDOFIndex,-1);
60    max_DOF=Finley_Util_getFlaggedMaxInt(1,numNodes,globalDOFIndex,-1);    max_DOF=Finley_Util_getFlaggedMaxInt(1,numNodes,globalDOFIndex,-1);
61    
62      if (max_DOF < min_DOF) {
63          min_DOF=myFirstDOF;
64          max_DOF=myLastDOF-1;
65      }
66    
67    p_min=mpiSize;    p_min=mpiSize;
68    p_max=-1;    p_max=-1;
69      if (max_DOF >= min_DOF) {
70    for (p=0; p<mpiSize; ++p) {        for (p=0; p<mpiSize; ++p) {
71        if (dof_distribution->first_component[p]<=min_DOF) p_min=p;           if (dof_distribution->first_component[p]<=min_DOF) p_min=p;
72        if (dof_distribution->first_component[p]<=max_DOF) p_max=p;           if (dof_distribution->first_component[p]<=max_DOF) p_max=p;
73    }       }
74       }
75    
76    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);  
77    if (! ((min_DOF<=myFirstDOF) && (myLastDOF-1<=max_DOF)) ) {    if (! ((min_DOF<=myFirstDOF) && (myLastDOF-1<=max_DOF)) ) {
78        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.");
79        return;        return;
80    }    }
81      rcv_len=TMPMEMALLOC(mpiSize,dim_t);
82      snd_len=TMPMEMALLOC(mpiSize,dim_t);
83      #ifdef PASO_MPI
84        mpi_requests=MEMALLOC(mpiSize*2,MPI_Request);
85        mpi_stati=MEMALLOC(mpiSize*2,MPI_Status);
86      #else
87        mpi_requests=MEMALLOC(mpiSize*2,int);
88        mpi_stati=MEMALLOC(mpiSize*2,int);
89      #endif
90      wanted_DOFs=TMPMEMALLOC(numNodes,index_t);
91    nodeMask=TMPMEMALLOC(numNodes,index_t);    nodeMask=TMPMEMALLOC(numNodes,index_t);
92    neighbor=TMPMEMALLOC(mpiSize,Paso_MPI_rank);    neighbor=TMPMEMALLOC(mpiSize,Paso_MPI_rank);
93    shared=TMPMEMALLOC(numNodes*(p_max-p_min+1),index_t);    shared=TMPMEMALLOC(numNodes*(p_max-p_min+1),index_t);
94    offsetInShared=TMPMEMALLOC(mpiSize+1,index_t);    offsetInShared=TMPMEMALLOC(mpiSize+1,index_t);
95    locDOFMask=TMPMEMALLOC(len_loc_dof, index_t);    locDOFMask=TMPMEMALLOC(len_loc_dof, index_t);
96    if (! ( Finley_checkPtr(neighbor) || Finley_checkPtr(shared) || Finley_checkPtr(offsetInShared) || Finley_checkPtr(locDOFMask) || Finley_checkPtr(nodeMask) ))  {    if (! ( Finley_checkPtr(neighbor) || Finley_checkPtr(shared) || Finley_checkPtr(offsetInShared) || Finley_checkPtr(locDOFMask) ||
97         Finley_checkPtr(nodeMask) || Finley_checkPtr(rcv_len) || Finley_checkPtr(snd_len) || Finley_checkPtr(mpi_requests) || Finley_checkPtr(mpi_stati) ||
98         Finley_checkPtr(mpi_stati) )) {
99      #pragma omp parallel for private(i) schedule(static)  
100      for (i=0;i<len_loc_dof;++i) locDOFMask[i]=UNUSED;      memset(rcv_len,0,sizeof(dim_t)*mpiSize);
101      #pragma omp parallel for private(i) schedule(static)      #pragma omp parallel
102      for (i=0;i<numNodes;++i) nodeMask[i]=UNUSED;      {
103            #pragma omp for private(i) schedule(static)
104      for (i=0;i<numNodes;++i) {          for (i=0;i<len_loc_dof;++i) locDOFMask[i]=UNUSED;
105         k=globalDOFIndex[i];          #pragma omp for private(i) schedule(static)
106  #ifdef BOUNDS_CHECK          for (i=0;i<numNodes;++i) nodeMask[i]=UNUSED;
107         if ((k-min_DOF) >= len_loc_dof) { printf("BOUNDS_CHECK %s %d i=%d k=%d min_DOF=%d\n", __FILE__, __LINE__, i, k, min_DOF); exit(1); }          #pragma omp for private(i,k) schedule(static)
108  #endif          for (i=0;i<numNodes;++i) {
109         if (k>-1) locDOFMask[k-min_DOF]=UNUSED-1;             k=globalDOFIndex[i];
110      }             if (k>-1) {
111                  locDOFMask[k-min_DOF]=UNUSED-1;
112                  #ifdef BOUNDS_CHECK
113                  if ((k-min_DOF) >= len_loc_dof) { printf("BOUNDS_CHECK %s %d i=%d k=%d min_DOF=%d\n", __FILE__, __LINE__, i, k, min_DOF); exit(1); }
114                  #endif
115               }
116            }
117    
118      for (i=myFirstDOF-min_DOF;i<myLastDOF-min_DOF;++i) {          #pragma omp for private(i) schedule(static)
119        locDOFMask[i]=i-myFirstDOF+min_DOF;          for (i=myFirstDOF-min_DOF;i<myLastDOF-min_DOF;++i) {
120  #ifdef BOUNDS_CHECK            locDOFMask[i]=i-myFirstDOF+min_DOF;
121        if (i < 0 || i >= len_loc_dof) { printf("BOUNDS_CHECK %s %d i=%d\n", __FILE__, __LINE__, i); exit(1); }            #ifdef BOUNDS_CHECK
122  #endif            if (i < 0 || i >= len_loc_dof) { printf("BOUNDS_CHECK %s %d i=%d\n", __FILE__, __LINE__, i); exit(1); }
123              #endif
124            }
125      }      }
126    
127      numNeighbors=0;      numNeighbors=0;
# Line 104  void Mesh_createDOFMappingAndCoupling(Fi Line 132  void Mesh_createDOFMappingAndCoupling(Fi
132         lastDOF=MIN(max_DOF+1,dof_distribution->first_component[p+1]);         lastDOF=MIN(max_DOF+1,dof_distribution->first_component[p+1]);
133         if (p != myRank) {         if (p != myRank) {
134             for (i=firstDOF-min_DOF;i<lastDOF-min_DOF;++i) {             for (i=firstDOF-min_DOF;i<lastDOF-min_DOF;++i) {
135  #ifdef BOUNDS_CHECK                  #ifdef BOUNDS_CHECK
136                     if (i < 0 || i >= len_loc_dof) { printf("BOUNDS_CHECK %s %d p=%d i=%d\n", __FILE__, __LINE__, p, i); exit(1); }                  if (i < 0 || i >= len_loc_dof) { printf("BOUNDS_CHECK %s %d p=%d i=%d\n", __FILE__, __LINE__, p, i); exit(1); }
137  #endif                  #endif
138                  if (locDOFMask[i] == UNUSED-1) {                  if (locDOFMask[i] == UNUSED-1) {
139                     locDOFMask[i]=myLastDOF-myFirstDOF+n;                     locDOFMask[i]=myLastDOF-myFirstDOF+n;
140                       wanted_DOFs[n]=i+min_DOF;
141                     ++n;                     ++n;
142                  }                  }
143             }             }
144             if (n>lastn) {             if (n>lastn) {
145                  rcv_len[p]=n-lastn;
146                neighbor[numNeighbors]=p;                neighbor[numNeighbors]=p;
147  #ifdef BOUNDS_CHECK                #ifdef BOUNDS_CHECK
148                if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %d p=%d numNeighbors=%d n=%d\n", __FILE__, __LINE__, p, numNeighbors, n); exit(1); }                if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %d p=%d numNeighbors=%d n=%d\n", __FILE__, __LINE__, p, numNeighbors, n); exit(1); }
149  #endif                #endif
150                offsetInShared[numNeighbors]=lastn;                offsetInShared[numNeighbors]=lastn;
151                numNeighbors++;                numNeighbors++;
152                lastn=n;                lastn=n;
# Line 138  void Mesh_createDOFMappingAndCoupling(Fi Line 168  void Mesh_createDOFMappingAndCoupling(Fi
168      /* now we can set the mapping from nodes to local DOFs */      /* now we can set the mapping from nodes to local DOFs */
169      this_mapping=Finley_NodeMapping_alloc(numNodes,nodeMask,UNUSED);      this_mapping=Finley_NodeMapping_alloc(numNodes,nodeMask,UNUSED);
170      /* define how to get DOF values for controlled bu other processors */      /* define how to get DOF values for controlled bu other processors */
171  #ifdef BOUNDS_CHECK      #ifdef BOUNDS_CHECK
172      for (i=0;i<offsetInShared[numNeighbors];++i) {      for (i=0;i<offsetInShared[numNeighbors];++i) {
173        if (i < 0 || i >= numNodes*(p_max-p_min+1)) { printf("BOUNDS_CHECK %s %d i=%d\n", __FILE__, __LINE__, i); exit(1); }        if (i < 0 || i >= numNodes*(p_max-p_min+1)) { printf("BOUNDS_CHECK %s %d i=%d\n", __FILE__, __LINE__, i); exit(1); }
174      }      }
175  #endif      #endif
176      #pragma omp parallel for private(i) schedule(static)      #pragma omp parallel for private(i) schedule(static)
177      for (i=0;i<offsetInShared[numNeighbors];++i) shared[i]=myLastDOF-myFirstDOF+i;      for (i=0;i<offsetInShared[numNeighbors];++i) shared[i]=myLastDOF-myFirstDOF+i;
178    
179      rcv_shcomp=Paso_SharedComponents_alloc(myLastDOF-myFirstDOF,numNeighbors,neighbor,shared,offsetInShared,1,0,dof_distribution->mpi_info);      rcv_shcomp=Paso_SharedComponents_alloc(myLastDOF-myFirstDOF,numNeighbors,neighbor,shared,offsetInShared,1,0,mpi_info);
180    
181      /* now it is determined which DOFs needs to be send off:*/      /*
182      #pragma omp parallel for private(i) schedule(static)       *    now we build the sender
183      for (i=0;i<len_loc_dof;++i) locDOFMask[i]=UNUSED;       */
184        #ifdef PASO_MPI
185             MPI_Alltoall(rcv_len,1,MPI_INT,snd_len,1,MPI_INT,mpi_info->comm);
186        #else
187            for (p=0;p<mpiSize;++p) snd_len[p]=rcv_len[p];
188        #endif
189        count=0;
190        for (p=0;p<rcv_shcomp->numNeighbors;p++) {
191           #ifdef PASO_MPI
192           MPI_Isend(&(wanted_DOFs[rcv_shcomp->offsetInShared[p]]), rcv_shcomp->offsetInShared[p+1]-rcv_shcomp->offsetInShared[p],
193                      MPI_INT,rcv_shcomp->neighbor[p],mpi_info->msg_tag_counter+myRank,mpi_info->comm,&mpi_requests[count]);
194            #endif
195            count++;
196        }
197      n=0;      n=0;
198      numNeighbors=0;      numNeighbors=0;
199      lastn=n;      for (p=0;p<mpiSize;p++) {
200      for (p=p_min;p<=p_max;++p) {           if (snd_len[p] > 0) {
201         firstDOF=dof_distribution->first_component[p];              #ifdef PASO_MPI
202         lastDOF=dof_distribution->first_component[p+1];              MPI_Irecv(&(shared[n]),snd_len[p],
203         if (p != myRank) {                        MPI_INT, p, mpi_info->msg_tag_counter+p, mpi_info->comm, &mpi_requests[count]);
204             /* mark a DOF by p if it will be requested by processor p */              #endif
205             Finley_Mesh_markDOFsConnectedToRange(locDOFMask,min_DOF,p,firstDOF,lastDOF,in,use_reduced_elements);              count++;
206                neighbor[numNeighbors]=p;
207             for (i=myFirstDOF-min_DOF;i<myLastDOF-min_DOF;++i) {              offsetInShared[numNeighbors]=n;
208                  if (locDOFMask[i] == p) {              numNeighbors++;
209  #ifdef BOUNDS_CHECK              n+=snd_len[p];
210             if (n < 0 || n >= numNodes*(p_max-p_min+1)) { printf("BOUNDS_CHECK %s %d p=%d i=%d n=%d\n", __FILE__, __LINE__, p, i, n); exit(1); }           }
 #endif  
                    shared[n]=i-myFirstDOF+min_DOF;  
                    ++n;  
                 }  
            }  
            if (n>lastn) {  
               neighbor[numNeighbors]=p;  
 #ifdef BOUNDS_CHECK  
               if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %d p=%d n=%d numNeighbors=%d\n", __FILE__, __LINE__, p, n, numNeighbors); exit(1); }  
 #endif  
               offsetInShared[numNeighbors]=lastn;  
               numNeighbors++;  
               lastn=n;  
            }  
         }  
211      }      }
212  #ifdef BOUNDS_CHECK      mpi_info->msg_tag_counter+=mpi_info->size;
213      if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %d numNeighbors=%d\n", __FILE__, __LINE__, numNeighbors); exit(1); }      offsetInShared[numNeighbors]=n;
214  #endif      #ifdef PASO_MPI
215      offsetInShared[numNeighbors]=lastn;      MPI_Waitall(count,mpi_requests,mpi_stati);
216        #endif
217        /* map global ids to local id's */
218        #pragma omp parallel for private(i) schedule(static)
219        for (i=0;i<offsetInShared[numNeighbors];++i) {
220            shared[i]=locDOFMask[shared[i]-min_DOF];
221        }
222    
223      snd_shcomp=Paso_SharedComponents_alloc(myLastDOF-myFirstDOF,numNeighbors,neighbor,shared,offsetInShared,1,0,dof_distribution->mpi_info);      snd_shcomp=Paso_SharedComponents_alloc(myLastDOF-myFirstDOF,numNeighbors,neighbor,shared,offsetInShared,1,0,dof_distribution->mpi_info);
224    
225      if (Finley_noError()) this_connector=Paso_Connector_alloc(snd_shcomp,rcv_shcomp);      if (Finley_noError()) this_connector=Paso_Connector_alloc(snd_shcomp,rcv_shcomp);
# Line 192  void Mesh_createDOFMappingAndCoupling(Fi Line 227  void Mesh_createDOFMappingAndCoupling(Fi
227      Paso_SharedComponents_free(rcv_shcomp);      Paso_SharedComponents_free(rcv_shcomp);
228      Paso_SharedComponents_free(snd_shcomp);      Paso_SharedComponents_free(snd_shcomp);
229    }    }
230      TMPMEMFREE(rcv_len);
231      TMPMEMFREE(snd_len);
232      TMPMEMFREE(mpi_requests);
233      TMPMEMFREE(mpi_stati);
234      TMPMEMFREE(wanted_DOFs);
235    TMPMEMFREE(nodeMask);    TMPMEMFREE(nodeMask);
236    TMPMEMFREE(neighbor);    TMPMEMFREE(neighbor);
237    TMPMEMFREE(shared);    TMPMEMFREE(shared);
# Line 212  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 224  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, globalNumNodes, n, lastn,n0, numNeighbors;  
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);  
   
   if (! ( Finley_checkPtr(reduced_dof_first_component) || Finley_checkPtr(reduced_nodes_first_component) || Finley_checkPtr(nodes_first_component)  ) ) {  
291    
292       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);  
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 279  void Finley_Mesh_createNodeFileMappings( Line 317  void Finley_Mesh_createNodeFileMappings(
317                 k=in->Nodes->globalNodesIndex[indexReducedNodes[i]];                 k=in->Nodes->globalNodesIndex[indexReducedNodes[i]];
318                 if ( (k>=myFirstNode) && (myLastNode>k) ) maskMyReducedNodes[k-myFirstNode]=i;                 if ( (k>=myFirstNode) && (myLastNode>k) ) maskMyReducedNodes[k-myFirstNode]=i;
319                 k=in->Nodes->globalDegreesOfFreedom[indexReducedNodes[i]];                 k=in->Nodes->globalDegreesOfFreedom[indexReducedNodes[i]];
320                 if ( (k>=myFirstDOF) && (myLastDOF>k) ) maskMyReducedDOF[k-myFirstDOF]=i;                 if ( (k>=myFirstDOF) && (myLastDOF>k) ) {
321                      maskMyReducedDOF[k-myFirstDOF]=i;
322                   }
323              }              }
324          }          }
325          myNumReducedNodes=Finley_Util_packMask(myNumNodes,maskMyReducedNodes,indexMyReducedNodes);          myNumReducedNodes=Finley_Util_packMask(myNumNodes,maskMyReducedNodes,indexMyReducedNodes);
# Line 306  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,0,globalNumNodes-1,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 326  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 342  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.1562  
changed lines
  Added in v.1920

  ViewVC Help
Powered by ViewVC 1.1.26