/[escript]/branches/domexper/dudley/src/NodeFile_gather.c
ViewVC logotype

Diff of /branches/domexper/dudley/src/NodeFile_gather.c

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

revision 3080 by jfenwick, Tue Aug 3 04:28:03 2010 UTC revision 3086 by jfenwick, Thu Aug 5 05:07:58 2010 UTC
# Line 14  Line 14 
14    
15  /**************************************************************  /**************************************************************
16   *   *
17   *   Finley: Mesh: NodeFile                                     *   Dudley: Mesh: NodeFile                                  
18   *   gathers the NodeFile out from the NodeFile in using the entries   *   gathers the NodeFile out from the NodeFile in using the entries
19   *   in index[0:out->numNodes-1] which are between min_index and max_index (exclusive)   *   in index[0:out->numNodes-1] which are between min_index and max_index (exclusive)
20   *   the node index[i]   *   the node index[i]
# Line 25  Line 25 
25    
26  /**************************************************************/  /**************************************************************/
27    
28  void Finley_NodeFile_gatherEntries(dim_t n, index_t* index, index_t min_index, index_t max_index,  void Dudley_NodeFile_gatherEntries(dim_t n, index_t* index, index_t min_index, index_t max_index,
29                                     index_t* Id_out, index_t* Id_in,                                     index_t* Id_out, index_t* Id_in,
30                                     index_t* Tag_out, index_t* Tag_in,                                     index_t* Tag_out, index_t* Tag_in,
31                                     index_t* globalDegreesOfFreedom_out, index_t* globalDegreesOfFreedom_in,                                     index_t* globalDegreesOfFreedom_out, index_t* globalDegreesOfFreedom_in,
# Line 47  void Finley_NodeFile_gatherEntries(dim_t Line 47  void Finley_NodeFile_gatherEntries(dim_t
47     }     }
48  }  }
49    
50  void Finley_NodeFile_gather(index_t* index, Finley_NodeFile* in, Finley_NodeFile* out)  void Dudley_NodeFile_gather(index_t* index, Dudley_NodeFile* in, Dudley_NodeFile* out)
51  {  {
52     index_t min_id, max_id;     index_t min_id, max_id;
53     Finley_NodeFile_setGlobalIdRange(&min_id,&max_id,in);     Dudley_NodeFile_setGlobalIdRange(&min_id,&max_id,in);
54     Finley_NodeFile_gatherEntries(out->numNodes, index, min_id, max_id,     Dudley_NodeFile_gatherEntries(out->numNodes, index, min_id, max_id,
55                                   out->Id, in->Id,                                   out->Id, in->Id,
56                                   out->Tag, in->Tag,                                   out->Tag, in->Tag,
57                                   out->globalDegreesOfFreedom, in->globalDegreesOfFreedom,                                   out->globalDegreesOfFreedom, in->globalDegreesOfFreedom,
58                                   out->numDim, out->Coordinates, in->Coordinates);                                   out->numDim, out->Coordinates, in->Coordinates);
59  }  }
60    
61  void Finley_NodeFile_gather_global(index_t* index, Finley_NodeFile* in, Finley_NodeFile* out)  void Dudley_NodeFile_gather_global(index_t* index, Dudley_NodeFile* in, Dudley_NodeFile* out)
62  {  {
63    index_t min_id, max_id, undefined_node;    index_t min_id, max_id, undefined_node;
64    Paso_MPI_rank buffer_rank, dest, source, *distribution=NULL;    Paso_MPI_rank buffer_rank, dest, source, *distribution=NULL;
# Line 71  void Finley_NodeFile_gather_global(index Line 71  void Finley_NodeFile_gather_global(index
71    #endif    #endif
72    
73    /* get the global range of node ids */    /* get the global range of node ids */
74    Finley_NodeFile_setGlobalIdRange(&min_id,&max_id,in);    Dudley_NodeFile_setGlobalIdRange(&min_id,&max_id,in);
75    undefined_node=min_id-1;    undefined_node=min_id-1;
76    
77    distribution=TMPMEMALLOC(in->MPIInfo->size+1, index_t);    distribution=TMPMEMALLOC(in->MPIInfo->size+1, index_t);
78    
79    if ( !Finley_checkPtr(distribution) ) {    if ( !Dudley_checkPtr(distribution) ) {
80        /* distribute the range of node ids */        /* distribute the range of node ids */
81        buffer_len=Paso_MPIInfo_setDistribution(in->MPIInfo,min_id,max_id,distribution);        buffer_len=Paso_MPIInfo_setDistribution(in->MPIInfo,min_id,max_id,distribution);
82        /* allocate buffers */        /* allocate buffers */
# Line 84  void Finley_NodeFile_gather_global(index Line 84  void Finley_NodeFile_gather_global(index
84        Tag_buffer=TMPMEMALLOC(buffer_len,index_t);        Tag_buffer=TMPMEMALLOC(buffer_len,index_t);
85        globalDegreesOfFreedom_buffer=TMPMEMALLOC(buffer_len,index_t);        globalDegreesOfFreedom_buffer=TMPMEMALLOC(buffer_len,index_t);
86        Coordinates_buffer=TMPMEMALLOC(buffer_len*out->numDim,double);        Coordinates_buffer=TMPMEMALLOC(buffer_len*out->numDim,double);
87        if (! (Finley_checkPtr(Id_buffer) || Finley_checkPtr(Tag_buffer) ||        if (! (Dudley_checkPtr(Id_buffer) || Dudley_checkPtr(Tag_buffer) ||
88                       Finley_checkPtr(globalDegreesOfFreedom_buffer) || Finley_checkPtr(Coordinates_buffer) ) ) {                       Dudley_checkPtr(globalDegreesOfFreedom_buffer) || Dudley_checkPtr(Coordinates_buffer) ) ) {
89              /* fill Id_buffer by the undefined_node marker to check if nodes are defined */              /* fill Id_buffer by the undefined_node marker to check if nodes are defined */
90              #pragma omp parallel for private(n) schedule(static)              #pragma omp parallel for private(n) schedule(static)
91              for (n=0;n<buffer_len;n++) Id_buffer[n]=undefined_node;              for (n=0;n<buffer_len;n++) Id_buffer[n]=undefined_node;
# Line 113  void Finley_NodeFile_gather_global(index Line 113  void Finley_NodeFile_gather_global(index
113                       in->MPIInfo->msg_tag_counter+=4;                       in->MPIInfo->msg_tag_counter+=4;
114                   }                   }
115                   buffer_rank=Paso_MPIInfo_mod(in->MPIInfo->size, buffer_rank-1);                   buffer_rank=Paso_MPIInfo_mod(in->MPIInfo->size, buffer_rank-1);
116                   Finley_NodeFile_scatterEntries(in->numNodes, in->Id,                   Dudley_NodeFile_scatterEntries(in->numNodes, in->Id,
117                                                  distribution[buffer_rank], distribution[buffer_rank+1],                                                  distribution[buffer_rank], distribution[buffer_rank+1],
118                                                  Id_buffer, in->Id,                                                  Id_buffer, in->Id,
119                                                  Tag_buffer, in->Tag,                                                  Tag_buffer, in->Tag,
# Line 125  void Finley_NodeFile_gather_global(index Line 125  void Finley_NodeFile_gather_global(index
125              source=Paso_MPIInfo_mod(in->MPIInfo->size, in->MPIInfo->rank - 1);              source=Paso_MPIInfo_mod(in->MPIInfo->size, in->MPIInfo->rank - 1);
126              buffer_rank=in->MPIInfo->rank;              buffer_rank=in->MPIInfo->rank;
127              for (p=0; p< in->MPIInfo->size; ++p) {              for (p=0; p< in->MPIInfo->size; ++p) {
128                   Finley_NodeFile_gatherEntries(out->numNodes, index,                   Dudley_NodeFile_gatherEntries(out->numNodes, index,
129                                                 distribution[buffer_rank], distribution[buffer_rank+1],                                                 distribution[buffer_rank], distribution[buffer_rank+1],
130                                                 out->Id, Id_buffer,                                                 out->Id, Id_buffer,
131                                                 out->Tag, Tag_buffer,                                                 out->Tag, Tag_buffer,
# Line 154  void Finley_NodeFile_gather_global(index Line 154  void Finley_NodeFile_gather_global(index
154              #pragma omp parallel for private(n) schedule(static)              #pragma omp parallel for private(n) schedule(static)
155              for (n=0; n< out->numNodes; ++n) {              for (n=0; n< out->numNodes; ++n) {
156                  if (out->Id[n] == undefined_node ) {                  if (out->Id[n] == undefined_node ) {
157                   sprintf(error_msg,"Finley_NodeFile_gather_global: Node id %d at position %d is referenced but is not defined.",out->Id[n],n);                   sprintf(error_msg,"Dudley_NodeFile_gather_global: Node id %d at position %d is referenced but is not defined.",out->Id[n],n);
158                   Finley_setError(VALUE_ERROR,error_msg);                   Dudley_setError(VALUE_ERROR,error_msg);
159                 }                 }
160               }               }
161    

Legend:
Removed from v.3080  
changed lines
  Added in v.3086

  ViewVC Help
Powered by ViewVC 1.1.26