/[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 1315 by ksteube, Tue Sep 25 02:41:13 2007 UTC revision 1552 by gross, Thu May 8 08:52:41 2008 UTC
# Line 32  void Mesh_createDOFMappingAndCoupling(Fi Line 32  void Mesh_createDOFMappingAndCoupling(Fi
32    Paso_MPI_rank myRank,p,p_min,p_max, *neighbor=NULL;    Paso_MPI_rank myRank,p,p_min,p_max, *neighbor=NULL;
33    Paso_SharedComponents *rcv_shcomp=NULL, *snd_shcomp=NULL;    Paso_SharedComponents *rcv_shcomp=NULL, *snd_shcomp=NULL;
34    Finley_NodeMapping *this_mapping=NULL;    Finley_NodeMapping *this_mapping=NULL;
35    Paso_Coupler* this_coupler=NULL;    Paso_Connector* this_connector=NULL;
36    Paso_Distribution* dof_distribution;    Paso_Distribution* dof_distribution;
37        
38    numNodes=in->Nodes->numNodes;    numNodes=in->Nodes->numNodes;
# Line 84  void Mesh_createDOFMappingAndCoupling(Fi Line 84  void Mesh_createDOFMappingAndCoupling(Fi
84      for (i=0;i<numNodes;++i) {      for (i=0;i<numNodes;++i) {
85         k=globalDOFIndex[i];         k=globalDOFIndex[i];
86  #ifdef BOUNDS_CHECK  #ifdef BOUNDS_CHECK
87         if ((k-min_DOF) >= len_loc_dof) { printf("BOUNDS_CHECK %s %i i=%i k=%i min_DOF=%i\n", __FILE__, __LINE__, i, k, min_DOF); exit(1); }         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); }
88  #endif  #endif
89         if (k>-1) locDOFMask[k-min_DOF]=UNUSED-1;         if (k>-1) locDOFMask[k-min_DOF]=UNUSED-1;
90      }      }
# Line 92  void Mesh_createDOFMappingAndCoupling(Fi Line 92  void Mesh_createDOFMappingAndCoupling(Fi
92      for (i=myFirstDOF-min_DOF;i<myLastDOF-min_DOF;++i) {      for (i=myFirstDOF-min_DOF;i<myLastDOF-min_DOF;++i) {
93        locDOFMask[i]=i-myFirstDOF+min_DOF;        locDOFMask[i]=i-myFirstDOF+min_DOF;
94  #ifdef BOUNDS_CHECK  #ifdef BOUNDS_CHECK
95        if (i < 0 || i >= len_loc_dof) { printf("BOUNDS_CHECK %s %i i=%i\n", __FILE__, __LINE__, i); exit(1); }        if (i < 0 || i >= len_loc_dof) { printf("BOUNDS_CHECK %s %d i=%d\n", __FILE__, __LINE__, i); exit(1); }
96  #endif  #endif
97      }      }
98    
# Line 105  void Mesh_createDOFMappingAndCoupling(Fi Line 105  void Mesh_createDOFMappingAndCoupling(Fi
105         if (p != myRank) {         if (p != myRank) {
106             for (i=firstDOF-min_DOF;i<lastDOF-min_DOF;++i) {             for (i=firstDOF-min_DOF;i<lastDOF-min_DOF;++i) {
107  #ifdef BOUNDS_CHECK  #ifdef BOUNDS_CHECK
108                     if (i < 0 || i >= len_loc_dof) { printf("BOUNDS_CHECK %s %i p=%i i=%i\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); }
109  #endif  #endif
110                  if (locDOFMask[i] == UNUSED-1) {                  if (locDOFMask[i] == UNUSED-1) {
111                     locDOFMask[i]=myLastDOF-myFirstDOF+n;                     locDOFMask[i]=myLastDOF-myFirstDOF+n;
# Line 115  void Mesh_createDOFMappingAndCoupling(Fi Line 115  void Mesh_createDOFMappingAndCoupling(Fi
115             if (n>lastn) {             if (n>lastn) {
116                neighbor[numNeighbors]=p;                neighbor[numNeighbors]=p;
117  #ifdef BOUNDS_CHECK  #ifdef BOUNDS_CHECK
118                if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %i p=%i numNeighbors=%i n=%i\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); }
119  #endif  #endif
120                offsetInShared[numNeighbors]=lastn;                offsetInShared[numNeighbors]=lastn;
121                numNeighbors++;                numNeighbors++;
# Line 124  void Mesh_createDOFMappingAndCoupling(Fi Line 124  void Mesh_createDOFMappingAndCoupling(Fi
124          }          }
125      }      }
126  #ifdef BOUNDS_CHECK  #ifdef BOUNDS_CHECK
127      if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %i numNeighbors=%i\n", __FILE__, __LINE__, numNeighbors); exit(1); }      if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %d numNeighbors=%d\n", __FILE__, __LINE__, numNeighbors); exit(1); }
128  #endif  #endif
129      offsetInShared[numNeighbors]=lastn;      offsetInShared[numNeighbors]=lastn;
130    
# Line 140  void Mesh_createDOFMappingAndCoupling(Fi Line 140  void Mesh_createDOFMappingAndCoupling(Fi
140      /* define how to get DOF values for controlled bu other processors */      /* define how to get DOF values for controlled bu other processors */
141  #ifdef BOUNDS_CHECK  #ifdef BOUNDS_CHECK
142      for (i=0;i<offsetInShared[numNeighbors];++i) {      for (i=0;i<offsetInShared[numNeighbors];++i) {
143        if (i < 0 || i >= numNodes*(p_max-p_min+1)) { printf("BOUNDS_CHECK %s %i i=%i\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); }
144      }      }
145  #endif  #endif
146      #pragma omp parallel for private(i) schedule(static)      #pragma omp parallel for private(i) schedule(static)
# Line 164  void Mesh_createDOFMappingAndCoupling(Fi Line 164  void Mesh_createDOFMappingAndCoupling(Fi
164             for (i=myFirstDOF-min_DOF;i<myLastDOF-min_DOF;++i) {             for (i=myFirstDOF-min_DOF;i<myLastDOF-min_DOF;++i) {
165                  if (locDOFMask[i] == p) {                  if (locDOFMask[i] == p) {
166  #ifdef BOUNDS_CHECK  #ifdef BOUNDS_CHECK
167             if (n < 0 || n >= numNodes*(p_max-p_min+1)) { printf("BOUNDS_CHECK %s %i p=%i i=%i n=%i\n", __FILE__, __LINE__, p, i, n); exit(1); }             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); }
168  #endif  #endif
169                     shared[n]=i-myFirstDOF+min_DOF;                     shared[n]=i-myFirstDOF+min_DOF;
170                     ++n;                     ++n;
# Line 173  void Mesh_createDOFMappingAndCoupling(Fi Line 173  void Mesh_createDOFMappingAndCoupling(Fi
173             if (n>lastn) {             if (n>lastn) {
174                neighbor[numNeighbors]=p;                neighbor[numNeighbors]=p;
175  #ifdef BOUNDS_CHECK  #ifdef BOUNDS_CHECK
176                if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %i p=%i n=%i numNeighbors=%i\n", __FILE__, __LINE__, p, n, numNeighbors); exit(1); }                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); }
177  #endif  #endif
178                offsetInShared[numNeighbors]=lastn;                offsetInShared[numNeighbors]=lastn;
179                numNeighbors++;                numNeighbors++;
# Line 182  void Mesh_createDOFMappingAndCoupling(Fi Line 182  void Mesh_createDOFMappingAndCoupling(Fi
182          }          }
183      }      }
184  #ifdef BOUNDS_CHECK  #ifdef BOUNDS_CHECK
185      if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %i numNeighbors=%i\n", __FILE__, __LINE__, numNeighbors); exit(1); }      if (numNeighbors < 0 || numNeighbors >= mpiSize+1) { printf("BOUNDS_CHECK %s %d numNeighbors=%d\n", __FILE__, __LINE__, numNeighbors); exit(1); }
186  #endif  #endif
187      offsetInShared[numNeighbors]=lastn;      offsetInShared[numNeighbors]=lastn;
188      snd_shcomp=Paso_SharedComponents_alloc(numNeighbors,neighbor,shared,offsetInShared,1,0,dof_distribution->mpi_info);      snd_shcomp=Paso_SharedComponents_alloc(numNeighbors,neighbor,shared,offsetInShared,1,0,dof_distribution->mpi_info);
189    
190      if (Finley_noError()) this_coupler=Paso_Coupler_alloc(snd_shcomp,rcv_shcomp);      if (Finley_noError()) this_connector=Paso_Connector_alloc(snd_shcomp,rcv_shcomp);
191      /* assign new DOF labels to nodes */      /* assign new DOF labels to nodes */
192      Paso_SharedComponents_free(rcv_shcomp);      Paso_SharedComponents_free(rcv_shcomp);
193      Paso_SharedComponents_free(snd_shcomp);      Paso_SharedComponents_free(snd_shcomp);
# Line 200  void Mesh_createDOFMappingAndCoupling(Fi Line 200  void Mesh_createDOFMappingAndCoupling(Fi
200    if (Finley_noError()) {    if (Finley_noError()) {
201       if (use_reduced_elements) {       if (use_reduced_elements) {
202          in->Nodes->reducedDegreesOfFreedomMapping=this_mapping;          in->Nodes->reducedDegreesOfFreedomMapping=this_mapping;
203          in->Nodes->reducedDegreesOfFreedomCoupler=this_coupler;          in->Nodes->reducedDegreesOfFreedomConnector=this_connector;
204       } else {       } else {
205          in->Nodes->degreesOfFreedomMapping=this_mapping;          in->Nodes->degreesOfFreedomMapping=this_mapping;
206          in->Nodes->degreesOfFreedomCoupler=this_coupler;          in->Nodes->degreesOfFreedomConnector=this_connector;
207      }      }
208    } else {    } else {
209       Finley_NodeMapping_free(this_mapping);       Finley_NodeMapping_free(this_mapping);
210       Paso_Coupler_free(this_coupler);       Paso_Connector_free(this_connector);
211    
212    }    }
213  }  }
214    
215    void Finley_Mesh_createMappings(Finley_Mesh* mesh, index_t* distribution) {
216      int i;
217      index_t *maskReducedNodes=NULL, *indexReducedNodes=NULL;
218      dim_t numReducedNodes;
219    
220      maskReducedNodes=TMPMEMALLOC(mesh->Nodes->numNodes,index_t);
221      indexReducedNodes=TMPMEMALLOC(mesh->Nodes->numNodes,index_t);
222    
223      if (! ( Finley_checkPtr(maskReducedNodes) || Finley_checkPtr(indexReducedNodes) ) ) {
224        #pragma omp parallel for private(i) schedule(static)
225        for (i=0;i<mesh->Nodes->numNodes;++i) maskReducedNodes[i]=-1;
226        Finley_Mesh_markNodes(maskReducedNodes,0,mesh,TRUE);
227        numReducedNodes=Finley_Util_packMask(mesh->Nodes->numNodes,maskReducedNodes,indexReducedNodes);
228        if (Finley_noError()) Finley_Mesh_createNodeFileMappings(mesh,numReducedNodes,indexReducedNodes,distribution);
229      }
230    
231      TMPMEMFREE(maskReducedNodes);
232      TMPMEMFREE(indexReducedNodes);
233    }
234    
235  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) {
236    
237    
# Line 324  void Finley_Mesh_createNodeFileMappings( Line 345  void Finley_Mesh_createNodeFileMappings(
345    
346    }    }
347    TMPMEMFREE(nodeMask);    TMPMEMFREE(nodeMask);
348    /* ==== mapping between nodes and DOFs + DOF coupler ========== */    /* ==== mapping between nodes and DOFs + DOF connector ========== */
349    if ( Finley_noError()) Mesh_createDOFMappingAndCoupling(in,FALSE);    if ( Finley_noError()) Mesh_createDOFMappingAndCoupling(in,FALSE);
350    /* ==== mapping between nodes and reduced DOFs + reduced DOF coupler ========== */    /* ==== mapping between nodes and reduced DOFs + reduced DOF connector ========== */
351    if ( Finley_noError()) Mesh_createDOFMappingAndCoupling(in,TRUE);    if ( Finley_noError()) Mesh_createDOFMappingAndCoupling(in,TRUE);
352    
353    /* get the Ids for DOFs and reduced nodes */    /* get the Ids for DOFs and reduced nodes */
# Line 349  void Finley_Mesh_createNodeFileMappings( Line 370  void Finley_Mesh_createNodeFileMappings(
370      Paso_Distribution_free(in->Nodes->reducedNodesDistribution);      Paso_Distribution_free(in->Nodes->reducedNodesDistribution);
371      Paso_Distribution_free(in->Nodes->degreesOfFreedomDistribution);      Paso_Distribution_free(in->Nodes->degreesOfFreedomDistribution);
372      Paso_Distribution_free(in->Nodes->reducedDegreesOfFreedomDistribution);      Paso_Distribution_free(in->Nodes->reducedDegreesOfFreedomDistribution);
373      Paso_Coupler_free(in->Nodes->degreesOfFreedomCoupler);      Paso_Connector_free(in->Nodes->degreesOfFreedomConnector);
374      Paso_Coupler_free(in->Nodes->reducedDegreesOfFreedomCoupler);      Paso_Connector_free(in->Nodes->reducedDegreesOfFreedomConnector);
375      in->Nodes->nodesMapping=NULL;      in->Nodes->nodesMapping=NULL;
376      in->Nodes->reducedNodesMapping=NULL;      in->Nodes->reducedNodesMapping=NULL;
377      in->Nodes->degreesOfFreedomMapping=NULL;      in->Nodes->degreesOfFreedomMapping=NULL;
# Line 359  void Finley_Mesh_createNodeFileMappings( Line 380  void Finley_Mesh_createNodeFileMappings(
380      in->Nodes->reducedNodesDistribution=NULL;      in->Nodes->reducedNodesDistribution=NULL;
381      in->Nodes->degreesOfFreedomDistribution=NULL;      in->Nodes->degreesOfFreedomDistribution=NULL;
382      in->Nodes->reducedDegreesOfFreedomDistribution=NULL;      in->Nodes->reducedDegreesOfFreedomDistribution=NULL;
383      in->Nodes->degreesOfFreedomCoupler=NULL;      in->Nodes->degreesOfFreedomConnector=NULL;
384      in->Nodes->reducedDegreesOfFreedomCoupler=NULL;      in->Nodes->reducedDegreesOfFreedomConnector=NULL;
385    }    }
386  }  }
387    

Legend:
Removed from v.1315  
changed lines
  Added in v.1552

  ViewVC Help
Powered by ViewVC 1.1.26