Changeset 25256 for issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
- Timestamp:
- 07/10/20 17:03:33 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
r25239 r25256 4707 4707 4708 4708 #ifdef _HAVE_DAKOTA_ 4709 void Penta::InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name){/*{{{*/ 4710 4711 int interp; 4712 int type; 4713 4714 /*Branch according to whether we have a transient or not input: */ 4715 type=this->inputs2->GetInputObjectEnum(name); 4716 if(type==PentaInput2Enum){ 4717 /*Figure out if we are P0 or P1 interpolation: */ 4718 PentaInput2* pentainput = this->inputs2->GetPentaInput(name); 4719 PentaInput2* pentainput2 = this->inputs2->GetPentaInput(DummyEnum); 4720 interp=pentainput->GetInterpolation(); 4721 4722 if (interp==P0Enum){ 4723 /*Update the value if this element belongs to the partition: */ 4724 if(partition[this->Sid()]!=-1){ 4725 int lid=this->lid; pentainput->Serve(1,&lid); 4726 /*scale P0 value for this element, corresponding to the partition:*/ 4727 IssmDouble value = pentainput->element_values[0]; 4728 value*=distributed_values[(int)partition[this->Sid()]]; 4729 pentainput2->SetInput(P0Enum,this->lid,value); 4730 } 4731 } 4732 else if (interp==P1Enum){ 4733 IssmDouble values[NUMVERTICES]; 4734 int lidlist[NUMVERTICES]; 4735 this->GetVerticesLidList(&lidlist[0]); 4736 pentainput->Serve(NUMVERTICES,&lidlist[0]); 4737 for (int i=0;i<NUMVERTICES;i++){ 4738 values[i]=pentainput->element_values[i]; 4739 if(partition[this->vertices[i]->Sid()]!=-1) values[i]*=distributed_values[(int)partition[this->vertices[i]->Sid()]]; 4740 } 4741 pentainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]); 4742 } 4743 else _error_("Penta::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!"); 4744 } 4745 else if(type==TransientInput2Enum){ 4746 4747 4748 IssmDouble* steps=NULL; 4749 int nsteps; 4750 TransientInput2* transientinput = NULL; 4751 TransientInput2* transientinput2 = NULL; 4752 4753 /*retrieve transient input:*/ 4754 transientinput= this->inputs2->GetTransientInput(name); 4755 transientinput2= this->inputs2->GetTransientInput(DummyEnum); 4756 4757 /*retrieve time steps: */ 4758 transientinput->GetAllTimes(&steps,&nsteps); 4759 4760 /*double check:*/ 4761 if (nsteps!=nt && nt!=1) _error_("Penta:InputScaleFromDakota error message: transient input " << EnumToStringx(name) << 4762 " should have the same number of time steps as the number of time values distributed by Dakota: " << nt << "\n"); 4763 4764 /*needed to update inputs:*/ 4765 int lidlist[NUMVERTICES]; 4766 this->GetVerticesLidList(&lidlist[0]); 4767 4768 /*go through the transient inputs, and update:*/ 4769 for (int i=0;i<nsteps;i++){ 4770 PentaInput2* pentainput=transientinput->GetPentaInput(i); 4771 PentaInput2* pentainput2=transientinput2->GetPentaInput(i); 4772 interp=pentainput->GetInterpolation(); 4773 4774 if (interp==P0Enum){ 4775 /*Update the value if this element belongs to the partition: */ 4776 if(partition[this->Sid()]!=-1){ 4777 int lid=this->lid; pentainput->Serve(1,&lid); 4778 /*scale P0 value for this element, corresponding to the partition:*/ 4779 IssmDouble value = pentainput->element_values[0]; 4780 if(nt==1) value*=distributed_values[(int)partition[this->Sid()]]; //we scale all the time steps with the same distributed_value 4781 else value*=distributed_values[(int)partition[this->Sid()]*nsteps+i]; //we scale all the time steps with distributed value for each step 4782 4783 pentainput2->SetInput(P0Enum,this->lid,value); 4784 } 4785 } 4786 else if (interp==P1Enum){ 4787 IssmDouble values[NUMVERTICES]; 4788 pentainput->Serve(NUMVERTICES,&lidlist[0]); 4789 for (int j=0;j<NUMVERTICES;j++){ 4790 values[j]=pentainput->element_values[j]; 4791 if(partition[this->vertices[i]->Sid()]!=-1){ 4792 if(nt==1) values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]];//we scale all the time steps with the same distributed_value 4793 else values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]*nsteps+i];//we scale all the time steps with distributed value for each step 4794 } 4795 } 4796 pentainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]); 4797 } 4798 else _error_("Penta::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!"); 4799 } 4800 } 4801 else _error_("Penta::InputScaleFromDakota error message: input type " << EnumToStringx(name) << " not supported yet!"); 4802 } 4803 /*}}}*/ 4709 4804 void Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*{{{*/ 4710 4805
Note:
See TracChangeset
for help on using the changeset viewer.