Ignore:
Timestamp:
09/07/20 03:12:14 (5 years ago)
Author:
bdef
Message:

CHG:Modifying loop on elements towards for on iterator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Nodes.cpp

    r25508 r25539  
    6363        output->id_offsets=NULL;
    6464        output->sorted_ids=NULL;
    65         if(this->sorted && objsize>0 && this->id_offsets){     
     65        if(this->sorted && objsize>0 && this->id_offsets){
    6666                output->id_offsets=xNew<int>(objsize);
    6767                xMemCpy<int>(output->id_offsets,this->id_offsets,objsize);
     
    148148
    149149        /*First, allocate dof lists based on fset and sset*/
    150         for(int i=0;i<this->Size();i++){
    151                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     150        for(Object* & object : this->objects){
     151      Node* node = xDynamicCast<Node*>(object);
    152152                node->AllocateDofLists(setenum);
    153153        }
     
    155155        /*Now, Build local dofs for masters first*/
    156156        int  dofcount=0;
    157         for(int i=0;i<this->Size();i++){
    158                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     157        for(Object* & object : this->objects){
     158      Node* node = xDynamicCast<Node*>(object);
    159159                if(!node->IsClone()) node->DistributeLocalDofs(&dofcount,setenum);
    160160        }
    161161        /*Build local dofs for clones, they always will be at the end*/
    162162        int dofcount_local = dofcount;
    163         for(int i=0;i<this->Size();i++){
    164                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     163        for(Object* & object : this->objects){
     164                Node* node = xDynamicCast<Node*>(object);
    165165                if(node->IsClone()) node->DistributeLocalDofs(&dofcount_local,setenum);
    166166        }
    167167
    168         /* Now every object has distributed dofs, but locally, and with a dof count starting from 
     168        /* Now every object has distributed dofs, but locally, and with a dof count starting from
    169169         * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of each
    170170         * cpus by the total last (master) dofs of the previus cpu, starting from 0.
     
    179179        xDelete<int>(alldofcount);
    180180
    181         for(int i=0;i<this->Size();i++){
    182                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     181        for(Object* & object : this->objects){
     182                Node* node = xDynamicCast<Node*>(object);
    183183                node->DistributeGlobalDofsMasters(offset,setenum);
    184184        }
    185185
    186         /* Finally, remember that cpus may have skipped some objects, because they were clones. For every 
    187          * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 
     186        /* Finally, remember that cpus may have skipped some objects, because they were clones. For every
     187         * object that is not a clone, tell them to show their dofs, so that later on, they can get picked
    188188         * up by their clones: */
    189189        int  maxdofspernode = this->MaxNumDofs(setenum);
     
    212212
    213213        /*Update indexingupdateflag*/
    214         for(int i=0;i<this->Size();i++){
    215                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     214        for(Object* & object : this->objects){
     215                Node* node = xDynamicCast<Node*>(object);
    216216                node->ReindexingDone();
    217217        }
     
    236236        this->numberofnodes_local=this->Size();
    237237        this->numberofmasters_local=0;
    238         for(int i=0;i<this->Size();i++){
    239                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     238        for(Object* & object : this->objects){
     239                Node* node = xDynamicCast<Node*>(object);
    240240                if(!node->clone) this->numberofmasters_local++;
    241241        }
     
    244244        /*2. Distribute lids (First: masters, then clones)*/
    245245        int lid = 0;
    246         for(int i=0;i<this->Size();i++){
    247                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     246        for(Object* & object : this->objects){
     247                Node* node = xDynamicCast<Node*>(object);
    248248                if(!node->clone) node->lid=lid++;
    249249        }
    250         for(int i=0;i<this->Size();i++){
    251                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     250        for(Object* & object : this->objects){
     251                Node* node = xDynamicCast<Node*>(object);
    252252                if(node->clone) node->lid=lid++;
    253253        }
     
    261261        xDelete<int>(all_num_masters);
    262262
    263         for(int i=0;i<this->Size();i++){
    264                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     263        for(Object* & object : this->objects){
     264                Node* node = xDynamicCast<Node*>(object);
    265265                node->pid = node->lid+offset;
    266266        }
     
    301301
    302302        /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
    303         for(int i=0;i<this->Size();i++){
    304                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     303        for(Object* & object : this->objects){
     304                Node* node = xDynamicCast<Node*>(object);
    305305
    306306                int numdofs=node->GetNumberOfDofs(NoneApproximationEnum,setenum);
     
    332332
    333333        /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
    334         for(int i=0;i<this->Size();i++){
    335                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     334        for(Object* & object : this->objects){
     335                Node* node = xDynamicCast<Node*>(object);
    336336
    337337                /*Ok, this object is a node, ask it to plug values into partition: */
     
    348348        /*go through all nodes, and get how many dofs they own, unless they are clone nodes: */
    349349        int numdofs=0;
    350         for(int i=0;i<this->Size();i++){
    351                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     350        for(Object* & object : this->objects){
     351                Node* node = xDynamicCast<Node*>(object);
    352352                numdofs+=node->GetNumberOfDofs(NoneApproximationEnum,setenum);
    353353        }
     
    376376
    377377        /*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
    378         for(int i=0;i<this->Size();i++){
    379                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     378        for(Object* & object : this->objects){
     379                Node* node = xDynamicCast<Node*>(object);
    380380                if(node->RequiresDofReindexing()){
    381381                        flag = 1;
     
    408408
    409409        /*First, go over all nodes, and masters can write their f dof and -1 for s-set*/
    410         for(int i=0;i<this->Size();i++){
    411                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     410        for(Object* & object : this->objects){
     411                Node* node = xDynamicCast<Node*>(object);
    412412
    413413                /*Skip if clone (will check later)*/
     
    436436
    437437        /*Second, go over all nodes, and check that we still have what's expected...*/
    438         for(int i=0;i<this->Size();i++){
    439                 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
     438        for(Object* & object : this->objects){
     439                Node* node = xDynamicCast<Node*>(object);
    440440
    441441                /*Write degree of freedom if active*/
Note: See TracChangeset for help on using the changeset viewer.