Changeset 3463


Ignore:
Timestamp:
04/08/10 09:48:24 (15 years ago)
Author:
Eric.Larour
Message:

Added DofObject virtual abstract class. Redid all DistributeDofs,
so that it works for Node, Vertex, and anything that has dofs.

Location:
issm/trunk/src/c
Files:
1 added
43 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/DataSet/DataSet.cpp

    r3454 r3463  
    947947/*}}}*/
    948948/*FUNCTION DataSet::DistributeDofs{{{1*/
    949 void  DataSet::DistributeDofs(int numberofnodes,int numdofspernode){
    950 
    951         int  dofcount=0;
    952         int  dofcount1=0;
    953         int* alldofcount=NULL;
    954         int* alldofcount1=NULL;
    955         int* borderdofs=NULL;
    956         int* borderdofs1=NULL;
    957         int* allborderdofs=NULL;
    958         int* allborderdofs1=NULL;
    959         int  i;
    960         vector<Object*>::iterator object;
    961         Node* node=NULL;
     949void  DataSet::DistributeDofs(int numberofobjects,int numberofdofsperobject){
    962950
    963951        extern int num_procs;
    964952        extern int my_rank;
    965953
    966         dofcount=0;
    967         for ( object=objects.begin() ; object < objects.end(); object++ ){
    968 
    969                 /*Check this is a node: */
    970                 if((*object)->Enum()==NodeEnum()){
    971 
    972                         node=(Node*)(*object);
    973 
    974                         /*Ok, this object is a node, ask it to distribute dofs, and update the dofcount: */
    975                         node->DistributeDofs(&dofcount,&dofcount1);
    976 
    977                 }
    978         }
    979 
    980         /*Ok, now every node has distributed dofs, but locally, and with a dof count starting from
     954        int  i;
     955       
     956        int  dofcount=0;
     957        int* alldofcount=NULL;
     958        int* truedofs=NULL;
     959        int* alltruedofs=NULL;
     960        vector<Object*>::iterator object;
     961        DofObject* dofobject=NULL;
     962
     963        /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject: */
     964        for ( object=objects.begin() ; object < objects.end(); object++ ){
     965
     966                dofobject=(DofObject*)(*object);
     967                dofobject->DistributeDofs(&dofcount);
     968
     969       
     970        }
     971
     972        /*Ok, now every object has distributed dofs, but locally, and with a dof count starting from
    981973         *0. This means the dofs between all the cpus are not synchronized! We need to synchronize all
    982          *dof on all cpus, and use those to update the dofs of every node: */
     974         *dof on all cpus, and use those to update the dofs of every object: */
    983975
    984976        alldofcount=(int*)xmalloc(num_procs*sizeof(int));
     
    986978        MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
    987979
    988         alldofcount1=(int*)xmalloc(num_procs*sizeof(int));
    989         MPI_Gather(&dofcount1,1,MPI_INT,alldofcount1,1,MPI_INT,0,MPI_COMM_WORLD);
    990         MPI_Bcast(alldofcount1,num_procs,MPI_INT,0,MPI_COMM_WORLD);
    991 
    992980        /*Ok, now every cpu should start its own dof count at the end of the dofcount
    993981         * from cpu-1. : */
    994982        dofcount=0;
    995         dofcount1=0;
    996983        if(my_rank==0){
    997984                dofcount=0;
    998                 dofcount1=0;
    999985        }
    1000986        else{
    1001987                for(i=0;i<my_rank;i++){
    1002988                        dofcount+=alldofcount[i];
    1003                         dofcount1+=alldofcount1[i];
    1004989                }
    1005990        }
     
    1009994        for ( object=objects.begin() ; object < objects.end(); object++ ){
    1010995
    1011                 /*Check this is a node: */
    1012                 if((*object)->Enum()==NodeEnum()){
    1013 
    1014                         node=(Node*)(*object);
    1015 
    1016                         /*Ok, this object is a node, ask it to update his dofs: */
    1017                         node->UpdateDofs(dofcount,dofcount1);
    1018 
    1019                 }
    1020         }
    1021 
    1022         /*Finally, remember that cpus may have skipped some nodes, when these nodes were
    1023          * clones: */
    1024         borderdofs=(int*)xcalloc(numberofnodes*numdofspernode,sizeof(int));
    1025         allborderdofs=(int*)xcalloc(numberofnodes*numdofspernode,sizeof(int));
    1026         borderdofs1=(int*)xcalloc(numberofnodes*3,sizeof(int));
    1027         allborderdofs1=(int*)xcalloc(numberofnodes*3,sizeof(int));
    1028 
    1029         for ( object=objects.begin() ; object < objects.end(); object++ ){
    1030 
    1031                 /*Check this is a node: */
    1032                 if((*object)->Enum()==NodeEnum()){
    1033 
    1034                         node=(Node*)(*object);
    1035 
    1036                         /*Ok, let this object show its border dofs, if is is a border dof: */
    1037                         node->ShowBorderDofs(borderdofs,borderdofs1);
    1038 
    1039                 }
    1040         }
    1041         MPI_Allreduce ( (void*)borderdofs,(void*)allborderdofs,numberofnodes*numdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
    1042         MPI_Allreduce ( (void*)borderdofs1,(void*)allborderdofs1,numberofnodes*3,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
    1043 
    1044         /*Ok, now every cpu knows everyone else's border node dofs, update the border dofs accordingly: */
    1045         for ( object=objects.begin() ; object < objects.end(); object++ ){
    1046 
    1047                 /*Check this is a node: */
    1048                 if((*object)->Enum()==NodeEnum()){
    1049 
    1050                         node=(Node*)(*object);
    1051 
    1052                         /*Ok, this object is a node, ask it to update his dofs: */
    1053                         node->UpdateBorderDofs(allborderdofs,allborderdofs1);
    1054 
    1055                 }
    1056         }
    1057 
     996                dofobject=(DofObject*)(*object);
     997                dofobject->OffsetDofs(dofcount);
     998       
     999        }
     1000
     1001        /*Finally, remember that cpus may have skipped some objects, because they were clones. For every
     1002         * object that is not a clone, tell them to show their dofs, so that later on, they can get picked
     1003         * up by their clones: */
     1004        truedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
     1005        alltruedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
     1006
     1007        for ( object=objects.begin() ; object < objects.end(); object++ ){
     1008                       
     1009                /*Ok, let this object show its true dofs, if is is a true dof: */
     1010                dofobject=(DofObject*)(*object);
     1011                dofobject->ShowTrueDofs(truedofs);
     1012        }
     1013       
     1014        MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
     1015
     1016        /*Ok, now every cpu knows the true dofs of everyone else that is not a clone. Let the clones recover those true dofs: */
     1017        for ( object=objects.begin() ; object < objects.end(); object++ ){
     1018
     1019                dofobject=(DofObject*)(*object);
     1020                dofobject->UpdateCloneDofs(alltruedofs);
     1021
     1022        }
    10581023
    10591024        /* Free ressources: */
    10601025        xfree((void**)&alldofcount);
    1061         xfree((void**)&borderdofs);
    1062         xfree((void**)&allborderdofs);
    1063         xfree((void**)&alldofcount1);
    1064         xfree((void**)&borderdofs1);
    1065         xfree((void**)&allborderdofs1);
    1066 
    1067         return;
     1026        xfree((void**)&truedofs);
     1027        xfree((void**)&alltruedofs);
    10681028
    10691029}
     
    11571117
    11581118        vector<Object*>::iterator object;
     1119        DofObject* dofobject=NULL;
    11591120
    11601121        /*Allocate ranks: */
     
    11881149        for ( object=objects.begin() ; object < objects.end(); object++ ){
    11891150
    1190                 /*Check this is a vertex: */
    1191                 if((*object)->Enum()==NodeEnum()){
    1192                        
    1193                         /*For this object, decide whether it is a clone: */
    1194                         (*object)->SetClone(minranks);
    1195 
    1196                 }
     1151                /*For this object, decide whether it is a clone: */
     1152                dofobject=(DofObject*)(*object);
     1153                dofobject->SetClone(minranks);
    11971154        }
    11981155
  • issm/trunk/src/c/Dofx/Dofx.cpp

    r3417 r3463  
    4848        nodes->FlagClones(numberofnodes);
    4949
    50         /*Go through all nodes, and build degree of freedom lists. Each node gets a fixed number of dofs. When
    51          *a  node has already been distributed dofs on one cpu, all other cpus with the same node cannot distribute it
     50        /*Go through all vertices and nodes, and build degree of freedom lists. Each vertex/node gets a fixed number of dofs. When
     51         *a  vertex/node has already been distributed dofs on one cpu, all other cpus with the same vertex/node cannot distribute it
    5252         *anymore. Use clone field to be sure of that: */
     53        vertices->DistributeDofs(numberofvertices,1); //only 1 dof per vertex.
    5354        nodes->DistributeDofs(numberofnodes,numberofdofspernode);
    5455
  • issm/trunk/src/c/objects/DofIndexing.cpp

    r3420 r3463  
    2424        int i;
    2525        this->numberofdofs=UNDEF;
    26         this->partitionborder=UNDEF;
    27         this->clone=UNDEF;
     26        this->clone=0;
    2827
    2928        for (i=0;i<MAXDOFSPERNODE;i++){
     
    3837/*}}}*/
    3938/*FUNCTION DofIndexing constructor {{{1*/
    40 DofIndexing::DofIndexing(int in_numberofdofs, int in_partitionborder){
    41 
    42         this->Init(in_numberofdofs,in_partitionborder);
     39DofIndexing::DofIndexing(int in_numberofdofs){
     40        this->Init(in_numberofdofs);
    4341}
    4442/*}}}*/
    4543/*FUNCTION DofIndexing Init: used by constructor {{{1*/
    46 void DofIndexing::Init(int in_numberofdofs, int in_partitionborder){
     44void DofIndexing::Init(int in_numberofdofs){
    4745
    4846        int i;
    4947        this->numberofdofs=in_numberofdofs;
    50         this->partitionborder=in_partitionborder;
    51         this->clone=UNDEF;
     48        this->clone=0;
    5249
    5350        for (i=0;i<MAXDOFSPERNODE;i++){
     
    6663        int i;
    6764        this->numberofdofs=in->numberofdofs;
    68         this->partitionborder=in->partitionborder;
    6965        this->clone=in->clone;
    7066
     
    10197        /*marshall DofIndexing data: */
    10298        memcpy(marshalled_dataset,&numberofdofs,sizeof(numberofdofs));marshalled_dataset+=sizeof(numberofdofs);
    103         memcpy(marshalled_dataset,&partitionborder,sizeof(partitionborder));marshalled_dataset+=sizeof(partitionborder);
    10499        memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone);
    105100        memcpy(marshalled_dataset,&m_set,sizeof(m_set));marshalled_dataset+=sizeof(m_set);
     
    117112
    118113        return sizeof(numberofdofs)+
    119                 sizeof(partitionborder)+
    120114                sizeof(clone)+
    121115                sizeof(m_set)+
     
    139133
    140134        memcpy(&numberofdofs,marshalled_dataset,sizeof(numberofdofs));marshalled_dataset+=sizeof(numberofdofs);
    141         memcpy(&partitionborder,marshalled_dataset,sizeof(partitionborder));marshalled_dataset+=sizeof(partitionborder);
    142135        memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone);
    143136        memcpy(&m_set,marshalled_dataset,sizeof(m_set));marshalled_dataset+=sizeof(m_set);
     
    159152        printf("DofIndexing:\n");
    160153        printf("   numberofdofs: %i\n",numberofdofs);
    161         printf("   partitionborder: %i\n",partitionborder);
    162154        printf("   clone: %i\n",clone);
    163155}
     
    170162        printf("DofIndexing:\n");
    171163        printf("   numberofdofs: %i\n",numberofdofs);
    172         printf("   partitionborder: %i\n",partitionborder);
    173164        printf("   clone: %i\n",clone);
    174165       
  • issm/trunk/src/c/objects/DofIndexing.h

    r3420 r3463  
    1515
    1616                /*partitioning: */
    17                 int     partitionborder; /*! during parallel partitioning, does this grid belong to a partition border?*/
    18                 int     clone;  /*!this nodes is one the partition border, and is cloned*/
     17                int     clone;   //this node is replicated from another one
    1918
    2019                /*boundary conditions sets: */
     
    2827
    2928                DofIndexing();
    30                 DofIndexing(int numberofdofs, int partitionborder);
    31                 void Init(int numberofdofs, int partitionborder);
     29                DofIndexing(int numberofdofs);
     30                void Init(int numberofdofs);
    3231                DofIndexing(DofIndexing* properties);
    3332                ~DofIndexing();
  • issm/trunk/src/c/objects/DofVec.cpp

    r3454 r3463  
    418418        return vector;
    419419}
    420 /*FUNCTION DofVec::SetClone {{{1*/
    421 void  DofVec::SetClone(int* minranks){
    422 
    423         ISSMERROR("not implemented yet");
    424 }
    425 /*}}}1*/
  • issm/trunk/src/c/objects/DofVec.h

    r3454 r3463  
    4545                int   MyRank();
    4646                int   Size();
    47                 void  SetClone(int* minranks);
    4847       
    4948
  • issm/trunk/src/c/objects/Element.h

    r3454 r3463  
    2121                virtual int    MyRank()=0;
    2222                virtual void   Marshall(char** pmarshalled_dataset)=0;
    23                 virtual void   SetClone(int* minranks)=0;
    2423                virtual int    MarshallSize()=0;
    2524                virtual char*  GetName()=0;
  • issm/trunk/src/c/objects/FemModel.cpp

    r3454 r3463  
    225225Mat                 FemModel::get_Gmn(void){return Gmn;}
    226226/*}}}*/
    227 /*FUNCTION FemModel::FemModel {{{1*/
    228 void  FemModel::SetClone(int* minranks){
    229 
    230         ISSMERROR("not implemented yet");
    231 }
    232 /*}}}1*/
  • issm/trunk/src/c/objects/FemModel.h

    r3454 r3463  
    5555                int   Enum();
    5656                Object* copy();
    57                 void  SetClone(int* minranks);
    5857               
    5958                int FindParam(double* pscalar,char* name);
  • issm/trunk/src/c/objects/Icefront.cpp

    r3454 r3463  
    14781478}
    14791479/*}}}*/
    1480 /*FUNCTION Icefront::SetClone {{{1*/
    1481 void  Icefront::SetClone(int* minranks){
    1482 
    1483         ISSMERROR("not implemented yet");
    1484 }
    1485 /*}}}1*/
    14861480/*FUNCTION Icefront UpdateFromInputs {{{1*/
    14871481void  Icefront::UpdateFromInputs(void* vinputs){
  • issm/trunk/src/c/objects/Icefront.h

    r3454 r3463  
    6969                int   MarshallSize();
    7070                int   MyRank();
    71                 void   SetClone(int* minranks);
    7271
    7372                /*}}}*/
  • issm/trunk/src/c/objects/Input.cpp

    r3454 r3463  
    301301}
    302302/*}}}*/
    303 /*FUNCTION Input::SetClone {{{1*/
    304 void  Input::SetClone(int* minranks){
    305 
    306         ISSMERROR("not implemented yet");
    307 }
    308 /*}}}1*/
  • issm/trunk/src/c/objects/Input.h

    r3454 r3463  
    3939               
    4040                Object* copy();
    41                 void  SetClone(int* minranks);
    4241
    4342                /*fill virtual routines: */
  • issm/trunk/src/c/objects/Load.h

    r3454 r3463  
    3232                virtual void  PenaltyCreateKMatrix(Mat Kgg,void* inputs,double kmax,int analysis_type,int sub_analysis_type)=0;
    3333                virtual void  PenaltyCreatePVector(Vec pg,void* inputs,double kmax,int analysis_type,int sub_analysis_type)=0;
    34                 virtual void  SetClone(int* minranks)=0;
    3534
    3635                int           Enum();
  • issm/trunk/src/c/objects/Material.h

    r3454 r3463  
    2121                virtual int   MyRank()=0;
    2222                virtual void  Marshall(char** pmarshalled_dataset)=0;
    23                 virtual void  SetClone(int* minranks)=0;
    2423                virtual int   MarshallSize()=0;
    2524                virtual char* GetName()=0;
  • issm/trunk/src/c/objects/Matice.cpp

    r3454 r3463  
    441441}
    442442/*}}}*/
    443 //*FUNCTION Matice::SetClone {{{1*/
    444 void  Matice::SetClone(int* minranks){
    445 
    446         ISSMERROR("not implemented yet");
    447 }
    448 /*}}}1*/
    449 
  • issm/trunk/src/c/objects/Matice.h

    r3454 r3463  
    4444                double GetB();
    4545                double GetN();
    46                 void   SetClone(int* minranks);
    4746
    4847};
  • issm/trunk/src/c/objects/Matpar.cpp

    r3454 r3463  
    289289}
    290290/*}}}1*/
    291 /*FUNCTION Matpar::SetClone {{{1*/
    292 void  Matpar::SetClone(int* minranks){
    293 
    294         ISSMERROR("not implemented yet");
    295 }
    296 /*}}}1*/
  • issm/trunk/src/c/objects/Matpar.h

    r3454 r3463  
    5757                double GetMeltingPoint();
    5858                Object* copy();
    59                 void   SetClone(int* minranks);
    6059
    6160};
  • issm/trunk/src/c/objects/Node.cpp

    r3451 r3463  
    2929/*}}}*/
    3030/*FUNCTION Node constructor {{{2*/
    31 Node::Node(int node_id,int node_vertex_id, int node_upper_node_id, int node_partitionborder,int node_numdofs, NodeProperties* node_properties):
    32         indexing(node_numdofs,node_partitionborder),
     31Node::Node(int node_id,int node_vertex_id, int node_upper_node_id, int node_numdofs, NodeProperties* node_properties):
     32        indexing(node_numdofs),
    3333        properties(node_properties),
    3434    hvertex(&node_vertex_id,1),
     
    5858       
    5959        int numdofs;
    60         int partitionborder;
    6160        int vertex_id;
    6261        int upper_node_id;
     
    6766        /*indexing:*/
    6867        DistributeNumDofs(&numdofs,iomodel->analysis_type,iomodel->sub_analysis_type); //number of dofs per node
    69         if(iomodel->my_bordervertices[i]) partitionborder=1; else partitionborder=0;//is this node on a partition border?
    70 
    71         this->indexing.Init(numdofs,partitionborder);
     68
     69        this->indexing.Init(numdofs);
    7270
    7371        /*properties: */
     
    163161
    164162        int numdofs;
    165         int partitionborder;
    166163        int vertex_id;
    167164        int upper_node_id;
     
    172169        /*indexing:*/
    173170        DistributeNumDofs(&numdofs,iomodel->analysis_type,iomodel->sub_analysis_type); //number of dofs per node
    174         if(iomodel->my_bordervertices[i])partitionborder=1; else partitionborder=0;//is this node on a partition border?
    175 
    176         this->indexing.Init(numdofs,partitionborder);
     171
     172        this->indexing.Init(numdofs);
    177173
    178174        /*properties (come from vertex number i): */
     
    459455
    460456
    461 }
    462 /*}}}*/
    463 /*FUNCTION Node DistributeDofs{{{2*/
    464 void  Node::DistributeDofs(int* pdofcount,int* pdofcount1){
    465 
    466         int i;
    467         extern int my_rank;
    468         int dofcount;
    469         int dofcount1;
    470 
    471         dofcount=*pdofcount;
    472         dofcount1=*pdofcount1;
    473        
    474         if(indexing.clone){
    475                 /*This node is a clone! Don't distribute dofs, it will get them from another cpu!*/
    476                 return;
    477         }
    478 
    479         /*This node should distribute dofs, go ahead: */
    480         for(i=0;i<this->indexing.numberofdofs;i++){
    481                 indexing.doflist[i]=dofcount+i;
    482         }
    483         dofcount+=this->indexing.numberofdofs;
    484 
    485         SetVertexDof(dofcount1);
    486         dofcount1+=1;
    487 
    488         /*Assign output pointers: */
    489         *pdofcount=dofcount;
    490         *pdofcount1=dofcount1;
    491 
    492         return;
    493457}
    494458/*}}}*/
     
    851815}
    852816/*}}}*/
     817/*FUNCTION Node UpdateFromInputs {{{2*/
     818void  Node::UpdateFromInputs(void* vinputs){
     819
     820        ISSMERROR("not used yet!");
     821       
     822}
     823/*}}}*/
     824/*}}}*/
     825/* DofObject routines: {{{1*
     826/*FUNCTION Node DistributeDofs{{{2*/
     827void  Node::DistributeDofs(int* pdofcount){
     828
     829        int i;
     830        extern int my_rank;
     831        int dofcount;
     832
     833        dofcount=*pdofcount;
     834       
     835        if(indexing.clone){
     836                /*This node is a clone! Don't distribute dofs, it will get them from another cpu!*/
     837                return;
     838        }
     839
     840        /*This node should distribute dofs, go ahead: */
     841        for(i=0;i<this->indexing.numberofdofs;i++){
     842                indexing.doflist[i]=dofcount+i;
     843        }
     844        dofcount+=this->indexing.numberofdofs;
     845
     846        /*Assign output pointers: */
     847        *pdofcount=dofcount;
     848
     849}
     850/*}}}*/
     851/*FUNCTION Node OffsetDofs{{{2*/
     852void  Node::OffsetDofs(int dofcount){
     853       
     854        int i;
     855        extern int my_rank;
     856       
     857        if(indexing.clone){
     858                /*This node is a clone, don't offset the dofs!: */
     859                return;
     860        }
     861
     862        /*This node should offset the dofs, go ahead: */
     863        for(i=0;i<this->indexing.numberofdofs;i++){
     864                indexing.doflist[i]+=dofcount;
     865        }
     866}
     867/*}}}*/
     868/*FUNCTION Node ShowTrueDofs{{{2*/
     869void  Node::ShowTrueDofs(int* truedofs){
     870
     871        int j;
     872        extern int my_rank;
     873       
     874        /*Are we a clone? : */
     875        if(indexing.clone)return;
     876
     877        /*Ok, we are not a clone, just plug our dofs into truedofs: */
     878        for(j=0;j<this->indexing.numberofdofs;j++){
     879                *(truedofs+this->indexing.numberofdofs*(id-1)+j)=indexing.doflist[j];
     880        }
     881
     882}
     883/*}}}*/
     884/*FUNCTION Node UpdateCloneDofs{{{2*/
     885void  Node::UpdateCloneDofs(int* alltruedofs){
     886
     887        int j;
     888        extern int my_rank;
     889       
     890        /*If we are not a clone, don't update, we already have dofs!: */
     891        if(indexing.clone==0)return;
     892
     893        /*Ok, we are a clone node, but we did not create the dofs for this node.
     894         * Therefore, our doflist is garbage right now. Go pick it up in the alltruedofs: */
     895        for(j=0;j<this->indexing.numberofdofs;j++){
     896                indexing.doflist[j]=*(alltruedofs+this->indexing.numberofdofs*(id-1)+j);
     897        }
     898}
     899/*}}}*/
    853900/*FUNCTION Node SetClone {{{2*/
    854901void  Node::SetClone(int* minranks){
     
    867914}
    868915/*}}}*/
    869 /*FUNCTION Node ShowBorderDofs{{{2*/
    870 void  Node::ShowBorderDofs(int* borderdofs,int* borderdofs1){
    871 
    872         int j;
    873         extern int my_rank;
    874        
    875         /*Is this node on the partition border? */
    876         if(!indexing.partitionborder)return;
    877 
    878         /*Are we the cpu that created this node's dof list? */
    879         if(indexing.clone)return;
    880 
    881         /*Ok, we are on the partition border, and we did create the
    882          * dofs for this node, plug the doflist into borderdofs: */
    883         for(j=0;j<this->indexing.numberofdofs;j++){
    884                 *(borderdofs+this->indexing.numberofdofs*(id-1)+j)=indexing.doflist[j];
    885         }
    886         *(borderdofs1+(id-1)+0)=this->GetVertexDof();
    887 
    888         return;
    889 }
    890 /*}}}*/
    891 /*FUNCTION Node UpdateBorderDofs{{{2*/
    892 void  Node::UpdateBorderDofs(int* allborderdofs,int* allborderdofs1){
    893 
    894         int j;
    895         extern int my_rank;
    896        
    897         /*Is this node on the partition border? */
    898         if(!indexing.partitionborder)return;
    899        
    900         /*Are we the cpu that created this node's dof list? */
    901         if(indexing.clone==0)return;
    902 
    903         /*Ok, we are on the partition border, but we did not create
    904          * the dofs for this node. Therefore, our doflist is garbage right
    905          * now. Go pick it up in the allborderdofs: */
    906         for(j=0;j<this->indexing.numberofdofs;j++){
    907                 indexing.doflist[j]=*(allborderdofs+this->indexing.numberofdofs*(id-1)+j);
    908         }
    909         this->SetVertexDof(*(allborderdofs1+(id-1)+0));
    910         return;
    911 }
    912 /*}}}*/
    913 /*FUNCTION Node UpdateDofs{{{2*/
    914 void  Node::UpdateDofs(int dofcount,int dofcount1){
    915        
    916         int i;
    917         extern int my_rank;
    918        
    919         if(indexing.clone){
    920                 /*This node is a clone, don't update the dofs!: */
    921                 return;
    922         }
    923 
    924         /*This node should update the dofs, go ahead: */
    925         for(i=0;i<this->indexing.numberofdofs;i++){
    926                 indexing.doflist[i]+=dofcount;
    927         }
    928         this->SetVertexDof(this->GetVertexDof()+dofcount1);
    929 
    930         return;
    931 }
    932 /*}}}*/
    933 /*FUNCTION Node UpdateFromInputs {{{2*/
    934 void  Node::UpdateFromInputs(void* vinputs){
    935 
    936         ISSMERROR("not used yet!");
    937        
    938 }
    939 /*}}}*/
    940 /*}}}*/
     916/*}}}*/
  • issm/trunk/src/c/objects/Node.h

    r3451 r3463  
    1414class NodeProperties;
    1515class Node;
     16class DofObject;
    1617
    1718#include "./Object.h"
     19#include "./DofObject.h"
    1820#include "../DataSet/DataSet.h"
    1921#include "./Hook.h"
     
    2426#include "../ModelProcessorx/IoModel.h"
    2527
    26 class Node: public Object{
     28class Node: public Object,public DofObject{
    2729
    2830        private:
     
    4042                /*FUNCTION constructors, destructors {{{1*/
    4143                Node();
    42                 Node(int id,int vertex_id, int upper_node_id, int partitionborder,int numberofdofs, NodeProperties* node_properties);
     44                Node(int id,int vertex_id, int upper_node_id, int numberofdofs, NodeProperties* node_properties);
    4345                Node(int id,DofIndexing* indexing, NodeProperties* properties, Hook* vertex, Hook* upper_node);
    4446                Node(int i, IoModel* iomodel);
     
    6163                /*}}}*/
    6264                /*FUNCTION numerical routines {{{1*/
    63                 void  DistributeDofs(int* pdofcount,int* pdofcount1);
    64                 void  UpdateDofs(int dofcount,int dofcount1);
    65                 void  ShowBorderDofs(int* borderdofs,int* borderdofs1);
    66                 void  UpdateBorderDofs(int* allborderdofs,int* allborderdofs1);
    6765                void  CreatePartition(Vec partition);
    68                 void  SetClone(int* minranks);
    6966                int   GetNumberOfDofs();
    7067                int   IsClone();
     
    9390                void  FieldExtrude(Vec field,double* field_serial,char* field_name);
    9491                /*}}}*/
     92                /*FUNCTION DofObject routines {{{1*/
     93                void  DistributeDofs(int* pdofcount);
     94                void  OffsetDofs(int dofcount);
     95                void  ShowTrueDofs(int* borderdofs);
     96                void  UpdateCloneDofs(int* allborderdofs);
     97                void  SetClone(int* minranks);
     98                /*}}}*/
    9599};
    96100
  • issm/trunk/src/c/objects/Numericalflux.cpp

    r3454 r3463  
    751751}
    752752/*}}}*/
    753 /*FUNCTION Numericalflux::SetClone {{{1*/
    754 void  Numericalflux::SetClone(int* minranks){
    755 
    756         ISSMERROR("not implemented yet");
    757 }
    758 /*}}}1*/
  • issm/trunk/src/c/objects/Numericalflux.h

    r3454 r3463  
    4848                int   Enum();
    4949                int   GetId();
    50                 void   SetClone(int* minranks);
    5150                void  GetJacobianDeterminant(double* pJdet,double xyz_list[4][3], double gauss_coord);
    5251                void  GetNodalFunctions(double* l1l4, double gauss_coord);
  • issm/trunk/src/c/objects/Numpar.cpp

    r3454 r3463  
    245245}
    246246/*}}}*/
    247 /*FUNCTION Numpar::SetClone {{{1*/
    248 void  Numpar::SetClone(int* minranks){
    249 
    250         ISSMERROR("not implemented yet");
    251 }
    252 /*}}}1*/
  • issm/trunk/src/c/objects/Numpar.h

    r3454 r3463  
    4343                int   Enum();
    4444                Object* copy();
    45                 void  SetClone(int* minranks);
    4645
    4746                void  Configure(void* pparametersin);
  • issm/trunk/src/c/objects/Object.h

    r3454 r3463  
    2525                virtual void  Demarshall(char** pmarshalled_dataset)=0;
    2626                virtual int   Enum()=0;
    27                 virtual void  SetClone(int* minranks)=0;
    2827                virtual Object* copy()=0;
    29 
     28               
     29       
    3030};
    3131#endif
  • issm/trunk/src/c/objects/Param.cpp

    r3454 r3463  
    724724}
    725725/*}}}*/
    726 /*FUNCTION Param::SetClone {{{1*/
    727 void  Param::SetClone(int* minranks){
    728 
    729         ISSMERROR("not implemented yet");
    730 }
    731 /*}}}1*/
  • issm/trunk/src/c/objects/Param.h

    r3454 r3463  
    4545                void  Demarshall(char** pmarshalled_dataset);
    4646                int   Enum();
    47                 void  SetClone(int* minranks);
    4847               
    4948                void  SetDouble(double value);
  • issm/trunk/src/c/objects/Pengrid.cpp

    r3454 r3463  
    636636}
    637637/*}}}1*/
    638 /*FUNCTION Pengrid::SetClone {{{1*/
    639 void  Pengrid::SetClone(int* minranks){
    640 
    641         ISSMERROR("not implemented yet");
    642 }
    643 /*}}}1*/
    644638/*FUNCTION Pengrid::UpdateFromInputs {{{1*/
    645639void  Pengrid::UpdateFromInputs(void* inputs){
  • issm/trunk/src/c/objects/Pengrid.h

    r3454 r3463  
    6565                void  PenaltyConstrain(int* punstable,void* inputs,int analysis_type,int sub_analysis_type);
    6666                void  PenaltyConstrainThermal(int* punstable,void* inputs,int analysis_type,int sub_analysis_type);
    67                 void   SetClone(int* minranks);
    6867
    6968};
  • issm/trunk/src/c/objects/Penpair.cpp

    r3454 r3463  
    234234}
    235235/*}}}1*/
    236 /*FUNCTION Penpair::SetClone {{{1*/
    237 void  Penpair::SetClone(int* minranks){
    238 
    239         ISSMERROR("not implemented yet");
    240 }
    241 /*}}}1*/
  • issm/trunk/src/c/objects/Penpair.h

    r3454 r3463  
    4848                void  PenaltyCreatePVector(Vec pg,void* inputs,double kmax,int analysis_type,int sub_analysis_type);
    4949                Object* copy();
    50                 void   SetClone(int* minranks);
    5150
    5251};
  • issm/trunk/src/c/objects/Result.cpp

    r3454 r3463  
    291291}
    292292/*}}}1*/
    293 /*FUNCTION Result::SetClone {{{1*/
    294 void  Result::SetClone(int* minranks){
    295 
    296         ISSMERROR("not implemented yet");
    297 }
    298 /*}}}1*/
  • issm/trunk/src/c/objects/Result.h

    r3454 r3463  
    4141                int   Enum();
    4242                Object* copy();
    43                 void  SetClone(int* minranks);
    4443
    4544                double GetTime();
  • issm/trunk/src/c/objects/Rgb.cpp

    r3454 r3463  
    165165}
    166166/*}}}1*/
    167 /*FUNCTION Rgb::SetClone {{{1*/
    168 void  Rgb::SetClone(int* minranks){
    169 
    170         ISSMERROR("not implemented yet");
    171 }
    172 /*}}}1*/
  • issm/trunk/src/c/objects/Rgb.h

    r3454 r3463  
    3232                int    GetId();
    3333                int    MyRank();
    34                 void  SetClone(int* minranks);
    3534
    3635                /*non virtual: */
  • issm/trunk/src/c/objects/Riftfront.cpp

    r3454 r3463  
    909909}
    910910/*}}}1*/
    911 /*FUNCTION Riftfront::SetClone {{{1*/
    912 void  Riftfront::SetClone(int* minranks){
    913 
    914         ISSMERROR("not implemented yet");
    915 }
    916 /*}}}1*/
    917911/*FUNCTION Riftfront::UpdateFromInputs {{{1*/
    918912void  Riftfront::UpdateFromInputs(void* vinputs){
  • issm/trunk/src/c/objects/Riftfront.h

    r3454 r3463  
    7777                int   MarshallSize();
    7878                int   MyRank();
    79                 void   SetClone(int* minranks);
    8079
    8180                /*}}}*/
  • issm/trunk/src/c/objects/SolPar.h

    r3454 r3463  
    3737                int   Enum();
    3838                Object* copy();
    39                 void  SetClone(int* minranks);
    4039
    4140                /*functionality: */
  • issm/trunk/src/c/objects/Spc.cpp

    r3454 r3463  
    164164}
    165165/*}}}1*/
    166 /*FUNCTION Spc::SetClone {{{1*/
    167 void  Spc::SetClone(int* minranks){
    168 
    169         ISSMERROR("not implemented yet");
    170 }
    171 /*}}}1*/
  • issm/trunk/src/c/objects/Spc.h

    r3454 r3463  
    3737                double GetValue();
    3838                Object* copy();
    39                 void  SetClone(int* minranks);
    4039
    4140};
  • issm/trunk/src/c/objects/Vertex.cpp

    r3454 r3463  
    2020/*}}}*/
    2121
    22 /*Object constructors and destructor*/
    23 /*FUNCTION Vertex default constructor {{{1*/
     22/*Object constructors and destructor{{{1*/
     23/*FUNCTION Vertex default constructor {{{2*/
    2424Vertex::Vertex(){
    2525        return;
    2626}
    2727/*}}}*/
    28 /*FUNCTION Vertex constructor {{{1*/
    29 Vertex::Vertex(int tria_id, double tria_x, double tria_y, double tria_z, double tria_sigma, int partitionborder){
    30         this->Init(tria_id, tria_x, tria_y, tria_z, tria_sigma, partitionborder);
    31 }
    32 /*}}}*/
    33 /*FUNCTION Vertex init, used by constructor {{{1*/
    34 void Vertex::Init(int tria_id, double tria_x, double tria_y, double tria_z, double tria_sigma, int partitionborder){
     28/*FUNCTION Vertex constructor {{{2*/
     29Vertex::Vertex(int tria_id, double tria_x, double tria_y, double tria_z, double tria_sigma){
     30        this->Init(tria_id, tria_x, tria_y, tria_z, tria_sigma);
     31}
     32/*}}}*/
     33/*FUNCTION Vertex init, used by constructor {{{2*/
     34void Vertex::Init(int tria_id, double tria_x, double tria_y, double tria_z, double tria_sigma){
    3535
    3636        /*all the initialization has been done by the initializer, just fill in the id: */
     
    4545}
    4646/*}}}*/
    47 /*FUNCTION Vertex constructor  from iomodel{{{1*/
     47/*FUNCTION Vertex constructor  from iomodel{{{2*/
    4848Vertex::Vertex(int i, IoModel* iomodel){
    4949
    50         int partitionborder;
    51 
    52         /*is this vertex on a partition border? */
    53         if(iomodel->my_bordervertices[i])partitionborder=1;
    54         else partitionborder=0;
    55 
    56         this->Init(i+1, iomodel->x[i],iomodel->y[i],iomodel->z[i],(iomodel->z[i]-iomodel->bed[i])/(iomodel->thickness[i]),partitionborder);
    57 
    58 }
    59 /*}}}*/
    60 /*FUNCTION Vertex destructor {{{1*/
     50        this->Init(i+1, iomodel->x[i],iomodel->y[i],iomodel->z[i],(iomodel->z[i]-iomodel->bed[i])/(iomodel->thickness[i]));
     51
     52}
     53/*}}}*/
     54/*FUNCTION Vertex destructor {{{2*/
    6155Vertex::~Vertex(){
    6256        return;
    6357}
    6458/*}}}*/
    65 
    66 /*Object management*/
    67 /*FUNCTION copy {{{1*/
     59/*}}}*/
     60/*Object management {{{1*/
     61/*FUNCTION copy {{{2*/
    6862Object* Vertex::copy() {
    6963
     
    7266}
    7367/*}}}*/
    74 /*FUNCTION DeepEcho{{{1*/
     68/*FUNCTION DeepEcho{{{2*/
    7569
    7670void Vertex::DeepEcho(void){
     
    7872}
    7973/*}}}*/
    80 /*FUNCTION Demarshall {{{1*/
     74/*FUNCTION Demarshall {{{2*/
    8175void  Vertex::Demarshall(char** pmarshalled_dataset){
    8276
     
    9690        memcpy(&sigma,marshalled_dataset,sizeof(sigma));marshalled_dataset+=sizeof(sigma);
    9791        memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);
    98         memcpy(&partitionborder,marshalled_dataset,sizeof(partitionborder));marshalled_dataset+=sizeof(partitionborder);
    9992        memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone);
    10093
     
    10497}
    10598/*}}}*/
    106 /*FUNCTION Echo{{{1*/
     99/*FUNCTION Echo{{{2*/
    107100
    108101void Vertex::Echo(void){
     
    115108        printf("   sigma: %g\n",sigma);
    116109        printf("   dof: %g\n",dof);
    117         printf("   partitionborder: %g\n",partitionborder);
    118110        printf("   clone: %g\n",clone);
    119111
     
    121113}
    122114/*}}}*/
    123 /*FUNCTION Enum {{{1*/
     115/*FUNCTION Enum {{{2*/
    124116int Vertex::Enum(void){
    125117
     
    128120}
    129121/*}}}*/
    130 /*FUNCTION GetId{{{1*/
     122/*FUNCTION GetId{{{2*/
    131123int    Vertex::GetId(void){ return id; }
    132124/*}}}*/
    133 /*FUNCTION GetName{{{1*/
     125/*FUNCTION GetName{{{2*/
    134126char* Vertex::GetName(void){
    135127        return "node";
    136128}
    137129/*}}}*/
    138 /*FUNCTION Marshall {{{1*/
     130/*FUNCTION Marshall {{{2*/
    139131void  Vertex::Marshall(char** pmarshalled_dataset){
    140132
     
    158150        memcpy(marshalled_dataset,&sigma,sizeof(sigma));marshalled_dataset+=sizeof(sigma);
    159151        memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);
    160         memcpy(marshalled_dataset,&partitionborder,sizeof(partitionborder));marshalled_dataset+=sizeof(partitionborder);
    161152        memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone);
    162153
     
    165156}
    166157/*}}}*/
    167 /*FUNCTION MarshallSize {{{1*/
     158/*FUNCTION MarshallSize {{{2*/
    168159int   Vertex::MarshallSize(){
    169160       
     
    174165                sizeof(sigma)+
    175166                sizeof(dof)+
    176                 sizeof(partitionborder)+
    177167                sizeof(clone)+
    178168                +sizeof(int); //sizeof(int) for enum type
    179169}
    180170/*}}}*/
    181 /*FUNCTION MyRank {{{1*/
     171/*FUNCTION MyRank {{{2*/
    182172int    Vertex::MyRank(void){
    183173        extern int my_rank;
     
    185175}
    186176/*}}}*/
    187 /*FUNCTION SetClone {{{1*/
     177/*FUNCTION UpdateFromDakota {{{2*/
     178void  Vertex::UpdateFromDakota(void* vinputs){
     179
     180        ISSMERROR("not supported yet!");
     181       
     182}
     183/*}}}*/
     184/*FUNCTION UpdateFromInputs {{{2*/
     185void  Vertex::UpdateFromInputs(void* vinputs){
     186       
     187        ParameterInputs* inputs=NULL;
     188        Vertex* vertex=NULL;
     189        int dof[1]={0};
     190        double coord[3];
     191
     192        vertex=this;
     193
     194        coord[0]=this->x; coord[1]=this->y; coord[2]=this->z;
     195
     196        /*Recover parameter inputs: */
     197        inputs=(ParameterInputs*)vinputs;
     198
     199        /*Update internal data if inputs holds new values: */
     200        inputs->Recover("x",&coord[0],1,dof,1,(void**)&vertex);
     201        inputs->Recover("y",&coord[1],1,dof,1,(void**)&vertex);
     202        inputs->Recover("z",&coord[2],1,dof,1,(void**)&vertex);
     203       
     204        ISSMERROR("not supported yet!");
     205       
     206}
     207/*}}}*/
     208/*FUNCTION UpdateVertexPosition {{{2*/
     209void  Vertex::UpdatePosition(double* thickness,double* bed){
     210
     211        /*sigma remains constant. z=bed+sigma*thickness*/
     212        this->z=bed[dof]+sigma*thickness[this->dof];
     213
     214}
     215/*}}}*/
     216/*}}}*/
     217/* DofObject routines: {{{1*
     218/*FUNCTION Vertex DistributeDofs{{{2*/
     219void  Vertex::DistributeDofs(int* pdofcount){
     220
     221        int i;
     222        extern int my_rank;
     223        int dofcount;
     224
     225        dofcount=*pdofcount;
     226       
     227        if(this->clone){
     228                /*This vertex is a clone! Don't distribute dofs, it will get them from another cpu!*/
     229                return;
     230        }
     231
     232        /*This vertex should distribute his dof, go ahead: */
     233        this->dof=dofcount;
     234        dofcount++;
     235
     236        /*Assign output pointers: */
     237        *pdofcount=dofcount;
     238
     239}
     240/*}}}*/
     241/*FUNCTION Vertex OffsetDofs{{{2*/
     242void  Vertex::OffsetDofs(int dofcount){
     243       
     244        int i;
     245        extern int my_rank;
     246       
     247        if(this->clone){
     248                /*This vertex is a clone, don't offset the dofs!: */
     249                return;
     250        }
     251
     252        /*This vertex should offset his dof, go ahead: */
     253        this->dof+=dofcount;
     254}
     255/*}}}*/
     256/*FUNCTION Vertex ShowTrueDofs{{{2*/
     257void  Vertex::ShowTrueDofs(int* truedofs){
     258
     259        int j;
     260        extern int my_rank;
     261       
     262        /*Are we a clone? : */
     263        if(this->clone)return;
     264
     265        /*Ok, we are not a clone, just plug our dof into truedofs: */
     266        truedofs[this->id-1]=this->dof;
     267
     268}
     269/*}}}*/
     270/*FUNCTION Vertex UpdateCloneDofs{{{2*/
     271void  Vertex::UpdateCloneDofs(int* alltruedofs){
     272
     273        int j;
     274        extern int my_rank;
     275       
     276        /*If we are not a clone, don't update, we already have dofs!: */
     277        if(this->clone==0)return;
     278
     279        /*Ok, we are a clone node, but we did not create the dof for this vertex
     280         * Therefore, our dof is garbage right now. Go pick it up in the alltruedofs: */
     281        this->dof=alltruedofs[id-1];
     282}
     283/*}}}*/
     284/*FUNCTION Vertex SetClone {{{2*/
    188285void  Vertex::SetClone(int* minranks){
    189286
     
    194291        }
    195292        else{
    196                 /*!there is a cpu with lower rank that has the same node,
     293                /*!there is a cpu with lower rank that has the same vertex,
    197294                therefore, I am a clone*/
    198295                this->clone=1; 
     
    201298}
    202299/*}}}*/
    203 /*FUNCTION UpdateFromDakota {{{1*/
    204 void  Vertex::UpdateFromDakota(void* vinputs){
    205 
    206         ISSMERROR("not supported yet!");
    207        
    208 }
    209 /*}}}*/
    210 /*FUNCTION UpdateFromInputs {{{1*/
    211 void  Vertex::UpdateFromInputs(void* vinputs){
    212        
    213         ParameterInputs* inputs=NULL;
    214         Vertex* vertex=NULL;
    215         int dof[1]={0};
    216         double coord[3];
    217 
    218         vertex=this;
    219 
    220         coord[0]=this->x; coord[1]=this->y; coord[2]=this->z;
    221 
    222         /*Recover parameter inputs: */
    223         inputs=(ParameterInputs*)vinputs;
    224 
    225         /*Update internal data if inputs holds new values: */
    226         inputs->Recover("x",&coord[0],1,dof,1,(void**)&vertex);
    227         inputs->Recover("y",&coord[1],1,dof,1,(void**)&vertex);
    228         inputs->Recover("z",&coord[2],1,dof,1,(void**)&vertex);
    229        
    230         ISSMERROR("not supported yet!");
    231        
    232 }
    233 /*}}}*/
    234 /*FUNCTION UpdateVertexPosition {{{1*/
    235 void  Vertex::UpdatePosition(double* thickness,double* bed){
    236 
    237         /*sigma remains constant. z=bed+sigma*thickness*/
    238         this->z=bed[dof]+sigma*thickness[this->dof];
    239 
    240 }
    241 /*}}}*/
     300/*}}}*/
  • issm/trunk/src/c/objects/Vertex.h

    r3454 r3463  
    66#define _VERTEX_H_
    77
     8class Object;
     9class DofObject;
     10
    811#include "../ModelProcessorx/IoModel.h"
    912#include "./Object.h"
     13#include "./DofObject.h"
    1014
    11 class Vertex: public Object{
     15class Vertex: public Object,public DofObject{
    1216
    1317        public:
     
    2024
    2125                /*dof management: */
    22                 int    partitionborder;
    2326                int    clone;
    2427                int    dof; //dof to recover values in a vertex indexed vector
     
    2629                /*FUNCTION constructors, destructors {{{1*/
    2730                Vertex();
    28                 Vertex(int id, double x, double y, double z, double sigma,int partitionborder);
    29                 void Init(int id, double x, double y, double z, double sigma,int partitionborder);
     31                Vertex(int id, double x, double y, double z, double sigma);
     32                void Init(int id, double x, double y, double z, double sigma);
    3033                Vertex(int i, IoModel* iomodel);
    3134                ~Vertex();
     
    4245                int   MarshallSize();
    4346                int   MyRank();
    44                 void  SetClone(int* minranks);
    4547                void  UpdateFromDakota(void* vinputs);
    4648                void  UpdateFromInputs(void* vinputs);
     
    4951
    5052                /*}}}*/
     53                /*FUNCTION DofObject routines {{{1*/
     54                void  DistributeDofs(int* pdofcount);
     55                void  OffsetDofs(int dofcount);
     56                void  ShowTrueDofs(int* borderdofs);
     57                void  UpdateCloneDofs(int* allborderdofs);
     58                void  SetClone(int* minranks);
     59                /*}}}*/
    5160
    5261};
Note: See TracChangeset for help on using the changeset viewer.