Changeset 27490
- Timestamp:
- 01/01/23 08:43:06 (2 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/IoModel.cpp
r27102 r27490 1124 1124 } 1125 1125 /*}}}*/ 1126 void IoModel::FetchData(bool** pmatrix,int* pM,int* pN,const char* data_name){/*{{{*/ 1127 1128 /*output: */ 1129 int M,N; 1130 IssmPDouble* matrix=NULL; 1131 bool* bool_matrix=NULL; 1132 int code=0; 1133 1134 /*recover my_rank:*/ 1135 int my_rank=IssmComm::GetRank(); 1136 1137 /*Set file pointer to beginning of the data: */ 1138 fid=this->SetFilePointerToData(&code,NULL,data_name); 1139 1140 if(code!=5 && code!=6 && code!=7)_error_("expecting a IssmDouble, integer or boolean matrix for \""<<data_name<<"\""<<" (Code is "<<code<<")"); 1141 1142 /*Now fetch: */ 1143 1144 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */ 1145 /*numberofelements: */ 1146 if(my_rank==0){ 1147 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 1148 } 1149 1150 ISSM_MPI_Bcast(&M,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 1151 1152 if(my_rank==0){ 1153 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 1154 } 1155 ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 1156 1157 /*Now allocate matrix: */ 1158 if(M*N){ 1159 matrix=xNew<IssmPDouble>(M*N); 1160 1161 /*Read matrix on node 0, then broadcast: */ 1162 if(my_rank==0){ 1163 if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 1164 } 1165 1166 ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 1167 } 1168 1169 /*Now cast to bool: */ 1170 if(M*N){ 1171 bool_matrix=xNew<bool>(M*N); 1172 for(int i=0;i<M;i++){ 1173 for(int j=0;j<N;j++){ 1174 bool_matrix[i*N+j]=(bool)matrix[i*N+j]; 1175 } 1176 } 1177 } 1178 else{ 1179 bool_matrix=NULL; 1180 } 1181 /*Free resources:*/ 1182 xDelete<IssmPDouble>(matrix); 1183 1184 /*Assign output pointers: */ 1185 *pmatrix=bool_matrix; 1186 if (pM)*pM=M; 1187 if (pN)*pN=N; 1188 1189 } 1190 /*}}}*/ 1126 1191 void IoModel::FetchData(int** pmatrix,int* pM,int* pN,const char* data_name){/*{{{*/ 1127 1192 int i,j; -
issm/trunk-jpl/src/c/classes/IoModel.h
r26073 r27490 136 136 void FetchData(char*** pstrings,int* pnumstrings,const char* data_name); 137 137 void FetchData(int** pmatrix,int* pM,int* pN,const char* data_name); 138 void FetchData(bool** pboolmatrix,int* pM,int* pN,const char* data_name); 138 139 void FetchData(IssmDouble** pscalarmatrix,int* pM,int* pN,const char* data_name); 139 140 #if _HAVE_AD_ && !defined(_WRAPPERS_) -
issm/trunk-jpl/src/c/classes/Materials/Matlitho.cpp
r27102 r27490 14 14 /*Matlitho constructors and destructor*/ 15 15 Matlitho::Matlitho(){/*{{{*/ 16 this->numlayers=0; 17 this->radius=NULL; 18 this->viscosity=NULL; 19 this->lame_lambda=NULL; 20 this->lame_mu=NULL; 21 this->burgers_viscosity=NULL; 22 this->burgers_mu=NULL; 23 this->ebm_alpha=NULL; 24 this->ebm_delta=NULL; 25 this->ebm_taul=NULL; 26 this->ebm_tauh=NULL; 27 this->density=NULL; 28 this->rheologymodel=NULL; 29 this->issolid=NULL; 30 return; 31 } 32 /*}}}*/ 33 Matlitho::Matlitho(int matlitho_mid, IoModel* iomodel){/*{{{*/ 34 35 IssmDouble* rheologymodeld=NULL; 36 IssmDouble* issolidd=NULL; 16 this->numlayers = 0; 17 this->radius = NULL; 18 this->viscosity = NULL; 19 this->lame_lambda = NULL; 20 this->lame_mu = NULL; 21 this->burgers_viscosity = NULL; 22 this->burgers_mu = NULL; 23 this->ebm_alpha = NULL; 24 this->ebm_delta = NULL; 25 this->ebm_taul = NULL; 26 this->ebm_tauh = NULL; 27 this->density = NULL; 28 this->rheologymodel = NULL; 29 this->issolid = NULL; 30 return; 31 } 32 /*}}}*/ 33 Matlitho::Matlitho(int matlitho_mid, IoModel* iomodel, bool* issolid_in, int* rheo_in){/*{{{*/ 37 34 38 35 this->mid=matlitho_mid; … … 72 69 xMemCpy<IssmDouble>(this->density, iomodel->Data("md.materials.density"),this->numlayers); 73 70 74 this->rheologymodel=xNew<IssmDouble>(this->numlayers); 75 xMemCpy<IssmDouble>(this->rheologymodel, iomodel->Data("md.materials.rheologymodel"),this->numlayers); 76 77 this->issolid=xNew<IssmDouble>(this->numlayers); 78 xMemCpy<IssmDouble>(this->issolid, iomodel->Data("md.materials.issolid"),this->numlayers); 79 80 /*rheologymodeld= xNew<IssmDouble>(this->numlayers); 81 this->rheologymodel=xNew<bool>(this->numlayers); 82 xMemCpy<IssmDouble>(rheologymodeld, iomodel->Data("md.materials.rheologymodel"),this->numlayers); 83 for (int i=0;i<this->numlayers;i++)this->rheologymodel[i]=reCast<bool,IssmDouble>(rheologymodeld[i]); 84 85 issolidd= xNew<IssmDouble>(this->numlayers); 71 this->rheologymodel=xNew<int>(this->numlayers); 72 xMemCpy<int>(this->rheologymodel, rheo_in, this->numlayers); 73 86 74 this->issolid=xNew<bool>(this->numlayers); 87 xMemCpy<IssmDouble>(issolidd, iomodel->Data("md.materials.issolid"),this->numlayers); 88 for (int i=0;i<this->numlayers;i++)this->issolid[i]=reCast<bool,IssmDouble>(issolidd[i]);*/ 89 90 /*Free resources: */ 91 xDelete<IssmDouble>(rheologymodeld); 92 xDelete<IssmDouble>(issolidd); 75 xMemCpy<bool>(this->issolid, issolid_in, this->numlayers); 93 76 } 94 77 /*}}}*/ … … 106 89 xDelete<IssmDouble>(ebm_tauh); 107 90 xDelete<IssmDouble>(density); 108 xDelete< IssmDouble>(rheologymodel);109 xDelete< IssmDouble>(issolid);91 xDelete<int>(rheologymodel); 92 xDelete<bool>(issolid); 110 93 111 94 return; … … 141 124 matlitho->ebm_tauh=xNew<IssmDouble>(this->numlayers); xMemCpy<IssmDouble>(matlitho->ebm_tauh, this->ebm_tauh,this->numlayers); 142 125 matlitho->density=xNew<IssmDouble>(this->numlayers); xMemCpy<IssmDouble>(matlitho->density, this->density,this->numlayers); 143 matlitho->rheologymodel=xNew<IssmDouble>(this->numlayers); xMemCpy<IssmDouble>(matlitho->rheologymodel, this->rheologymodel,this->numlayers); 144 matlitho->issolid=xNew<IssmDouble>(this->numlayers); xMemCpy<IssmDouble>(matlitho->issolid, this->issolid,this->numlayers); 145 /*matlitho->rheologymodel=xNew<bool>(this->numlayers); for(int i=0;i<this->numlayers;i++)matlitho->rheologymodel[i]=this->rheologymodel[i]; 146 matlitho->issolid=xNew<bool>(this->numlayers); for(int i=0;i<this->numlayers;i++)matlitho->issolid[i]=this->issolid[i];*/ 126 matlitho->rheologymodel=xNew<int>(this->numlayers); xMemCpy<int>(matlitho->rheologymodel, this->rheologymodel,this->numlayers); 127 matlitho->issolid=xNew<bool>(this->numlayers); xMemCpy<bool>(matlitho->issolid, this->issolid,this->numlayers); 147 128 } 148 129 -
issm/trunk-jpl/src/c/classes/Materials/Matlitho.h
r27031 r27490 28 28 IssmDouble* ebm_tauh; 29 29 IssmDouble* density; 30 IssmDouble*rheologymodel;31 IssmDouble*issolid;30 int* rheologymodel; 31 bool* issolid; 32 32 33 33 Matlitho(); 34 Matlitho(int matlitho_id, IoModel* iomodel );34 Matlitho(int matlitho_id, IoModel* iomodel, bool* issolid_in, int* rheo_in); 35 35 ~Matlitho(); 36 36 void SetMid(int matlitho_mid); -
issm/trunk-jpl/src/c/cores/love_core.cpp
r27477 r27490 589 589 int rheo=matlitho->rheologymodel[layer_index]; 590 590 591 if 591 if(vi!=0 && omega!=0.0){ //take into account viscosity in the rigidity if the material isn't a perfect fluid 592 592 doubletype ka=la0 + 2.0/3.0*mu0; //Bulk modulus 593 if 593 if(rheo==2){//EBM 594 594 mu=muEBM<doubletype>(layer_index, omega, matlitho, femmodel); 595 595 la=ka-2.0/3.0*mu; 596 596 } 597 else if 597 else if(rheo==1){//Burgers 598 598 doubletype vi2=matlitho->burgers_viscosity[layer_index]; 599 599 doubletype mu2=matlitho->burgers_mu[layer_index]; … … 674 674 doubletype frh,frhg0,fgr0,fgr,fn,rm0,rlm,flm; 675 675 doubletype xmin,xmax,x,dr; 676 doubletype g,ro, issolid; 676 doubletype g,ro; 677 bool issolid; 677 678 678 679 if (pomega) { //frequency and degree dependent terms /*{{{*/ … … 690 691 ro=matlitho->density[layer_index]; 691 692 issolid=matlitho->issolid[layer_index]; 692 if(issolid !=0){693 if(issolid){ 693 694 //GetEarthRheology<doubletype>(&la, &mu,layer_index,omega,matlitho); 694 695 mu=vars->mu[layer_index*vars->nfreq+vars->ifreq]; … … 769 770 g=GetGravity<doubletype>(x*ra,layer_index,femmodel,matlitho,vars); 770 771 771 if(issolid ==1){772 if(issolid){ 772 773 yi_prefactor[nindex+ 1*6+3]= fn/x; // in dy[1*6+3] 773 774 yi_prefactor[nindex+ 5*6+2]= -(fgr/g0*fn)/x; // in dy[5*6+2] … … 802 803 g=GetGravity<doubletype>(x*ra,layer_index,femmodel,matlitho,vars); 803 804 nindex=nsteps*36+n*36; 804 if(issolid ==1){805 if(issolid){ 805 806 yi_prefactor[nindex+ 1*6+5]= -frhg0; // in dy[1*6+5] 806 807 yi_prefactor[nindex+ 2*6+0]= -1.0/x; // in dy[2*6+0] … … 825 826 //computes yi derivatives at r=radius[layer_index]+ n/nstep*(radius[layer_index+1]-radius[layer_index]) 826 827 827 intissolid=matlitho->issolid[layer_index];828 bool issolid=matlitho->issolid[layer_index]; 828 829 int iy,id,ny, nindex, nstep, nsteps; 829 830 //femmodel->parameters->FindParam(&nstep,LoveIntStepsPerLayerEnum); … … 842 843 fn=(deg*(deg+1.0)); 843 844 844 if(issolid ==1){845 if(issolid){ 845 846 ny = 6; 846 847 … … 899 900 nindex=nsteps*36+n*36; 900 901 901 if(issolid ==1){902 if(issolid){ 902 903 ny = 6; 903 904 } else { … … 1235 1236 1236 1237 // Boundary Condition matrix - solid regions 1237 if 1238 if(matlitho->issolid[i]){ 1238 1239 one = -1.0; 1239 if (i>0) if(!matlitho->issolid[i-1]) one = 1.0;1240 if(i>0) if(!matlitho->issolid[i-1]) one = 1.0; 1240 1241 for (int j=0;j<6;j++){ 1241 1242 yi[(j+6*ici)+ nyi*(j+6*ici+3)] = one; -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
r27102 r27490 197 197 break; 198 198 case MatlithoEnum: { /*{{{*/ 199 iomodel->FetchData(13,"md.materials.radius","md.materials.viscosity","md.materials.lame_lambda","md.materials.lame_mu","md.materials.burgers_viscosity","md.materials.burgers_mu","md.materials.ebm_alpha","md.materials.ebm_delta","md.materials.ebm_taul","md.materials.ebm_tauh","md.materials.rheologymodel","md.materials.issolid","md.materials.density"); 200 materials->AddObject(new Matlitho(iomodel->numberofelements+1,iomodel)); 201 iomodel->DeleteData(13,"md.materials.radius","md.materials.viscosity","md.materials.lame_lambda","md.materials.lame_mu","md.materials.burgers_viscosity","md.materials.burgers_mu","md.materials.ebm_alpha","md.materials.ebm_delta","md.materials.ebm_taul","md.materials.ebm_tauh","md.materials.rheologymodel","md.materials.issolid","md.materials.density"); 199 bool* issolid = NULL; 200 int* rheologymodel = NULL; 201 iomodel->FetchData(&issolid, NULL, NULL, "md.materials.issolid"); 202 iomodel->FetchData(&rheologymodel, NULL, NULL, "md.materials.rheologymodel"); 203 iomodel->FetchData(11,"md.materials.radius","md.materials.viscosity","md.materials.lame_lambda","md.materials.lame_mu","md.materials.burgers_viscosity","md.materials.burgers_mu","md.materials.ebm_alpha","md.materials.ebm_delta","md.materials.ebm_taul","md.materials.ebm_tauh","md.materials.density"); 204 materials->AddObject(new Matlitho(iomodel->numberofelements+1, iomodel, issolid, rheologymodel)); 205 iomodel->DeleteData(11,"md.materials.radius","md.materials.viscosity","md.materials.lame_lambda","md.materials.lame_mu","md.materials.burgers_viscosity","md.materials.burgers_mu","md.materials.ebm_alpha","md.materials.ebm_delta","md.materials.ebm_taul","md.materials.ebm_tauh","md.materials.density"); 206 xDelete<bool>(issolid); 207 xDelete<int>(rheologymodel); 202 208 } 203 209 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.