Changeset 23630
- Timestamp:
- 01/14/19 09:18:35 (6 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Node.cpp
r23629 r23630 866 866 } 867 867 /*}}}*/ 868 void Node::VecReduce(Vector<IssmDouble>* vector, IssmDouble* ug_serial,int setenum){/*{{{*/ 869 870 IssmDouble* values=NULL; 871 int count=0; 872 int i; 873 874 if(setenum==FsetEnum){ 875 if(this->fsize){ 876 values=xNew<IssmDouble>(this->fsize); 877 878 for(i=0;i<this->gsize;i++){ 879 if(this->f_set[i]){ 880 _assert_(ug_serial); 881 values[count]=ug_serial[this->gdoflist[i]]; 882 count++; 883 } 884 } 885 886 /*Add values into ug: */ 887 vector->SetValues(this->fsize,this->fdoflist,values,INS_VAL); 888 } 889 } 890 else if(setenum==SsetEnum){ 891 if(this->ssize){ 892 values=xNew<IssmDouble>(this->ssize); 893 894 for(i=0;i<this->gsize;i++){ 895 if(this->s_set[i]){ 896 _assert_(ug_serial); 897 values[count]=ug_serial[this->gdoflist[i]]; 898 count++; 899 } 900 } 901 902 /*Add values into ug: */ 903 vector->SetValues(this->ssize,this->sdoflist,values,INS_VAL); 904 } 905 } 906 else _error_("VecReduce can only merge from the s or f-set onto the g-set!"); 907 908 /*Free ressources:*/ 909 xDelete<IssmDouble>(values); 868 void Node::VecReduce(Vector<IssmDouble>* uf, IssmDouble* local_ug,int* indices_ug){/*{{{*/ 869 870 871 /*Only perform operation if not clone*/ 872 if(this->IsClone()) return; 873 874 if(this->fsize){ 875 int* indices = xNew<int>(this->fsize); 876 IssmDouble* values = xNew<IssmDouble>(this->fsize); 877 878 int count = 0; 879 for(int i=0;i<this->gsize;i++){ 880 if(this->f_set[i]){ 881 _assert_(local_ug); 882 _assert_(this->gdoflist[i]==indices_ug[this->gdoflist_local[i]]); 883 884 values[count] =local_ug[this->gdoflist_local[i]]; 885 indices[count]=this->fdoflist[count]; 886 count++; 887 } 888 } 889 uf->SetValues(this->fsize,indices,values,INS_VAL); 890 891 xDelete<IssmDouble>(values); 892 xDelete<int>(indices); 893 } 910 894 } 911 895 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Node.h
r23629 r23630 107 107 void UpdateCloneDofs(int* alltruerows,int setenum); 108 108 void VecMerge(Vector<IssmDouble>* ug,IssmDouble* local_uf,int* indices_uf,IssmDouble* local_ys,int* indices_ys); 109 void VecReduce(Vector<IssmDouble>* vector, IssmDouble* ug_serial,int setnum);109 void VecReduce(Vector<IssmDouble>* uf, IssmDouble* local_ug,int* indices_ug); 110 110 void SetApproximation(int in_approximation); 111 111 }; -
issm/trunk-jpl/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp
r23629 r23630 41 41 ug->Assemble(); 42 42 43 /*Cleanup and ass ounfoutput pointer*/43 /*Cleanup and assign output pointer*/ 44 44 xDelete<int>(indices_uf); 45 45 xDelete<int>(indices_ys); -
issm/trunk-jpl/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp
r23587 r23630 8 8 void Reducevectorgtofx(Vector<IssmDouble>** puf, Vector<IssmDouble>* ug, Nodes* nodes,Parameters* parameters){ 9 9 10 /*output: */11 Vector<IssmDouble>* uf=NULL;12 13 /*variables: */14 IssmDouble *ug_serial = NULL;15 bool oldalloc = false;16 17 10 if(VerboseModule()) _printf0_(" Reduce vector from g to f set\n"); 18 11 … … 21 14 int flocalsize = nodes->NumberOfDofsLocal(FsetEnum); 22 15 16 /*If fsize is 0, return NULL vector*/ 23 17 if(fsize==0){ 24 uf=NULL; 25 } 26 else{ 27 /*allocate: */ 28 if(oldalloc) 29 uf=new Vector<IssmDouble>(fsize); 30 else 31 uf=new Vector<IssmDouble>(flocalsize,fsize); 32 33 if(nodes->NumberOfNodes()){ 34 35 /*serialize ug, so nodes can index into it: */ 36 ug_serial=ug->ToMPISerial(); 37 38 /*Go through all nodes, and ask them to retrieve values from ug, and plug them into uf: */ 39 for(int i=0;i<nodes->Size();i++){ 40 Node* node=(Node*)nodes->GetObjectByOffset(i); 41 42 /*For this object, reduce values for enum set Fset: */ 43 node->VecReduce(uf,ug_serial,FsetEnum); 44 } 45 } 46 /*Assemble vector: */ 47 uf->Assemble(); 18 *puf=NULL; 19 return; 48 20 } 49 21 50 /*Free ressources:*/ 51 xDelete<IssmDouble>(ug_serial); 22 /*Get local vectors ug*/ 23 int *indices_ug = NULL; 24 IssmDouble *local_ug = NULL; 25 ug->GetLocalVector(&local_ug,&indices_ug); 52 26 53 /*Assign output pointers:*/ 27 /*Allocate output*/ 28 Vector<IssmDouble>* uf=new Vector<IssmDouble>(flocalsize,fsize); 29 30 /*Let nodes figure it out*/ 31 for(int i=0;i<nodes->Size();i++){ 32 Node* node=(Node*)nodes->GetObjectByOffset(i); 33 node->VecReduce(uf,local_ug,indices_ug); 34 } 35 36 /*Assemble vector: */ 37 uf->Assemble(); 38 39 /*Cleanup and assing output pointer*/ 40 xDelete<int>(indices_ug); 41 xDelete<IssmDouble>(local_ug); 54 42 *puf=uf; 55 43 }
Note:
See TracChangeset
for help on using the changeset viewer.