Changeset 4435


Ignore:
Timestamp:
07/07/10 15:07:45 (15 years ago)
Author:
seroussi
Message:

fixed nodes counter (similar to dofs counter instead of using sid)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Container/Nodes.cpp

    r4387 r4435  
    243243
    244244        int i;
    245 
    246         int max_sid=0;
    247         int sid;
    248         int node_max_sid;
    249 
    250         for(i=0;i<this->Size();i++){
    251 
    252                 Node* node=(Node*)this->GetObjectByOffset(i);
    253                 sid=node->Sid();
    254                 if (sid>max_sid)max_sid=sid;
    255         }
    256 
    257         #ifdef _PARALLEL_
    258         MPI_Reduce (&max_sid,&node_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
    259         MPI_Bcast(&node_max_sid,1,MPI_INT,0,MPI_COMM_WORLD);
    260         max_sid=node_max_sid;
    261         #endif
    262 
    263         /*sid starts at 0*/
    264         if (max_sid) max_sid++;
    265 
    266         /*return*/
    267         return max_sid;
     245       
     246        int   numnodes=0;
     247        int   allnumnodes;
     248
     249        /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
     250        for(i=0;i<this->Size();i++){
     251                Node* node=(Node*)this->GetObjectByOffset(i);
     252
     253                /*Ok, this object is a node, ask it to plug values into partition: */
     254                if (!node->IsClone()) numnodes++;
     255        }
     256
     257        /*Gather from all cpus: */
     258        MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
     259
     260        return allnumnodes;
    268261}
    269262/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.