Changeset 26114
- Timestamp:
- 03/18/21 20:40:04 (4 years ago)
- Location:
- issm/trunk-jpl/src/c/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/FemModel.cpp
r26110 r26114 4749 4749 #endif 4750 4750 #ifdef _HAVE_SEALEVELCHANGE_ 4751 void FemModel::SealevelchangeBarystatic(Vector<IssmDouble>* pRSLgi, IssmDouble* poceanarea, IssmDouble* pbslc,IssmDouble* pbslcice, IssmDouble* pbslchydro, IssmDouble** pbslcice_partition,IssmDouble** pbslchydro_partition,SealevelMasks* masks) { /*{{{*/ 4752 4753 /*serialized vectors:*/ 4754 IssmDouble bslcice = 0.; 4755 IssmDouble bslcice_cpu = 0.; 4756 IssmDouble bslchydro = 0.; 4757 IssmDouble bslchydro_cpu = 0.; 4758 IssmDouble area = 0.; 4759 IssmDouble oceanarea = 0.; 4760 IssmDouble oceanarea_cpu = 0.; 4761 int bp_compute_fingerprints= 0; 4762 bool isoceantransport=false; 4763 4764 Vector<IssmDouble>* bslcice_partition=NULL; 4765 IssmDouble* bslcice_partition_serial=NULL; 4766 IssmDouble* partitionice=NULL; 4767 int npartice,nel; 4768 4769 Vector<IssmDouble>* bslchydro_partition=NULL; 4770 IssmDouble* bslchydro_partition_serial=NULL; 4771 IssmDouble* partitionhydro=NULL; 4772 bool istws=0; 4773 int nparthydro; 4774 4775 int npartocean; 4776 Vector<IssmDouble>* bslcocean_partition=NULL; 4777 IssmDouble* bslcocean_partition_serial=NULL; 4778 IssmDouble* partitionocean=NULL; 4779 4780 /*Initialize temporary vector that will be used to sum barystatic components 4781 * on all local elements, prior to assembly:*/ 4782 int gsize = this->nodes->NumberOfDofs(GsetEnum); 4783 IssmDouble* RSLgi=xNewZeroInit<IssmDouble>(gsize); 4784 int* indices=xNew<int>(gsize); 4785 for(int i=0;i<gsize;i++) indices[i]=i; 4786 4787 /*First, figure out the area of the ocean, which is needed to compute the barystatic component: */ 4788 int i = -1; 4789 for(Object* & object : this->elements->objects){ 4790 i +=1; 4791 Element* element = xDynamicCast<Element*>(object); 4792 element->GetInputValue(&area,AreaEnum); 4793 if (masks->isoceanin[i]) oceanarea_cpu += area; 4794 } 4795 ISSM_MPI_Reduce (&oceanarea_cpu,&oceanarea,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 4796 ISSM_MPI_Bcast(&oceanarea,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 4797 _assert_(oceanarea>0.); 4798 4799 /*Initialize partition vectors to retrieve barystatic contributions: */ 4800 this->parameters->FindParam(&npartice,SolidearthNpartIceEnum); 4801 if(npartice){ 4802 this->parameters->FindParam(&partitionice,&nel,NULL,SolidearthPartitionIceEnum); 4803 bslcice_partition= new Vector<IssmDouble>(npartice); 4804 } 4805 4806 this->parameters->FindParam(&nparthydro,SolidearthNpartHydroEnum); 4807 if(nparthydro){ 4808 this->parameters->FindParam(&partitionhydro,&nel,NULL,SolidearthPartitionHydroEnum); 4809 bslchydro_partition= new Vector<IssmDouble>(nparthydro); 4810 } 4811 4812 this->parameters->FindParam(&npartocean,SolidearthNpartOceanEnum); 4813 if(npartocean){ 4814 this->parameters->FindParam(&partitionocean,&nel,NULL,SolidearthPartitionOceanEnum); 4815 bslchydro_partition= new Vector<IssmDouble>(npartocean); 4816 } 4817 /*For later: 4818 npartbarystatic=npartice; 4819 if(nparthydro>npartbarystatic)npartbarystatic=nparthydro; 4820 if(npartocean>npartbarystatic)npartbarystatic=npartocean; 4821 bslc_partition=new Matrix(IssmDouble>(npartbarystatic,3); 4822 4823 bslc_cpu[0]=0; bslc_cpu[1]=0; bslc_cpu[2]=0; 4824 for(Object* & object : this->elements->objects){ 4825 Element* element = xDynamicCast<Element*>(object); 4826 element->SealevelchangeBarystaticLoads(&bslc_cpu[0], localloads,masks, bslcice_partition,partitionice,oceanarea); 4827 } 4828 MPI Bcast localloads -> loads 4829 4830 for(Object* & object : this->elements->objects){ 4831 Element* element = xDynamicCast<Element*>(object); 4832 element->SealevelchangeConvolution(loads); 4833 } 4834 */ 4835 4836 4837 4838 4839 4840 /*Call the barystatic sea level change core for ice : */ 4841 bslcice_cpu=0; 4842 for(Object* & object : this->elements->objects){ 4843 Element* element = xDynamicCast<Element*>(object); 4844 bslcice_cpu+=element->SealevelchangeBarystaticIce(RSLgi,masks, bslcice_partition,partitionice,oceanarea); 4845 } 4846 4847 /*Call the barystatic sea level change core for hydro: */ 4848 bslchydro_cpu=0; //make sure to initialize this, so we have a total barystatic contribution computed at 0. 4849 this->parameters->FindParam(&istws,TransientIshydrologyEnum); 4850 if(istws){ 4851 for(int i=0;i<elements->Size();i++){ 4852 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 4853 bslchydro_cpu+=element->SealevelchangeBarystaticHydro(RSLgi,masks, bslchydro_partition,partitionhydro,oceanarea); 4854 } 4855 } 4856 4857 /*Call the barystatic sea level change core for bottom pressures: */ 4858 this->parameters->FindParam(&bp_compute_fingerprints,SolidearthSettingsComputeBpGrdEnum); 4859 this->parameters->FindParam(&isoceantransport,TransientIsoceantransportEnum); 4860 if(bp_compute_fingerprints && isoceantransport){ 4861 for(int i=0;i<elements->Size();i++){ 4862 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 4863 element->SealevelchangeBarystaticBottomPressure(RSLgi,masks); 4864 } 4865 } 4866 4867 /*Plug values once and assemble: */ 4868 pRSLgi->SetValues(gsize,indices,RSLgi,ADD_VAL); 4869 pRSLgi->Assemble(); 4870 4871 /*Sum all barystatic components from all cpus:*/ 4872 ISSM_MPI_Reduce (&bslcice_cpu,&bslcice,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 4873 ISSM_MPI_Bcast(&bslcice,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 4874 _assert_(!xIsNan<IssmDouble>(bslcice)); 4875 4876 ISSM_MPI_Reduce (&bslchydro_cpu,&bslchydro,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 4877 ISSM_MPI_Bcast(&bslchydro,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 4878 _assert_(!xIsNan<IssmDouble>(bslchydro)); 4879 4880 /*Take care of partition vectors:*/ 4881 if(bslcice_partition){ 4882 bslcice_partition->Assemble(); 4883 bslcice_partition_serial=bslcice_partition->ToMPISerial(); 4884 } 4885 if(bslchydro_partition){ 4886 bslchydro_partition->Assemble(); 4887 bslchydro_partition_serial=bslchydro_partition->ToMPISerial(); 4888 } 4889 4890 4891 /*Free ressources:*/ 4892 xDelete<int>(indices); 4893 xDelete<IssmDouble>(RSLgi); 4894 if(bslchydro_partition)delete bslchydro_partition; 4895 if(bslcice_partition)delete bslcice_partition; 4896 if(partitionhydro)xDelete<IssmDouble>(partitionhydro); 4897 if(partitionice)xDelete<IssmDouble>(partitionice); 4898 4899 /*Assign output pointers:*/ 4900 *poceanarea = oceanarea; 4901 *pbslcice = bslcice; 4902 *pbslchydro = bslchydro; 4903 *pbslc=bslchydro+bslcice; 4904 *pbslcice_partition=bslcice_partition_serial; 4905 *pbslchydro_partition=bslchydro_partition_serial; 4906 4907 } 4908 /*}}}*/ 4751 4909 void FemModel::SealevelchangeSal(Vector<IssmDouble>* pRSLgo, Vector<IssmDouble>* pRSLg_old, SealevelMasks* masks, bool verboseconvolution){/*{{{*/ 4752 4910 -
issm/trunk-jpl/src/c/classes/FemModel.h
r26113 r26114 164 164 #endif 165 165 #ifdef _HAVE_SEALEVELCHANGE_ 166 void SealevelchangeBarystatic(Vector<IssmDouble>* pRSLgi, IssmDouble* poceanarea, IssmDouble* pbslc,IssmDouble* pbslcice, IssmDouble* pbslchydro, IssmDouble** pbslcice_partition,IssmDouble** pbslchydro_partition, SealevelMasks* masks); 166 167 void SealevelchangeSal(Vector<IssmDouble>* pSgo, Vector<IssmDouble>* pSg_old, SealevelMasks* masks,bool verboseconvolution); 167 168 void SealevelchangeRotationalFeedback(Vector<IssmDouble>* pRSLgo_rot, Vector<IssmDouble>* pRSLg_old, IssmDouble* pIxz, IssmDouble* pIyz, IssmDouble* pIzz, SealevelMasks* masks);
Note:
See TracChangeset
for help on using the changeset viewer.