source:
issm/oecreview/Archive/22819-23185/ISSM-23065-23066.diff
Last change on this file was 23186, checked in by , 7 years ago | |
---|---|
File size: 181.5 KB |
-
../trunk-jpl/src/c/modules/SetActiveNodesLSMx/SetActiveNodesLSMx.cpp
91 91 92 92 /* Intermediaries */ 93 93 int numvertices = element->GetNumberOfVertices(); 94 94 95 95 if(element->IsIceInElement()){ 96 96 for(int i = 0;i<numvertices;i++){ 97 97 vec_mask_ice->SetValue(element->vertices[i]->Sid(),1.,INS_VAL); -
../trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp
21 21 22 22 /*This is the object that we have been chasing for. compute the response and return: */ 23 23 IssmDouble return_value=definition->Response(femmodel); 24 24 25 25 /*cleanup: */ 26 26 xDelete<char>(name); 27 27 … … 30 30 } 31 31 xDelete<char>(name); 32 32 } 33 33 34 34 /*If we are here, did not find the definition for this response, not good!: */ 35 35 _error_("Could not find the response for output definition " << output_string << " because could not find the definition itself!"); 36 36 … … 43 43 44 44 /*Now, go through the output definitions, and retrieve the object which corresponds to our requested response, output_enum: */ 45 45 for(int i=0;i<output_definitions->Size();i++){ 46 46 47 47 //Definition* definition=xDynamicCast<Definition*>(output_definitions->GetObjectByOffset(i)); 48 48 Definition* definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i)); 49 49 … … 52 52 53 53 /*This is the object that we have been chasing for. compute the response and return: */ 54 54 IssmDouble return_value=definition->Response(femmodel); 55 55 56 56 /*return:*/ 57 57 return return_value; 58 58 } 59 59 } 60 60 61 61 /*If we are here, did not find the definition for this response, not good!: */ 62 62 _error_("Could not find the response for output definition " << EnumToStringx(output_enum) 63 63 <<" ("<<output_enum<<")" -
../trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
14 14 IssmDouble *phi_ungrounding = NULL; 15 15 Element *element = NULL; 16 16 17 18 17 /*retrieve parameters: */ 19 18 parameters->FindParam(&migration_style,GroundinglineMigrationEnum); 20 19 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 21 20 22 21 if(migration_style==NoneEnum) return; 23 22 24 23 if(VerboseModule()) _printf0_(" Migrating grounding line\n"); 25 24 26 25 /*Set toolkit to default*/ -
../trunk-jpl/src/c/modules/AllocateSystemMatricesx/AllocateSystemMatricesx.cpp
77 77 if(pdf) df =new Vector<IssmDouble>(flocalsize,fsize); 78 78 if(ppf) pf =new Vector<IssmDouble>(flocalsize,fsize); 79 79 } 80 80 81 81 /*Free ressources: */ 82 82 xDelete<char>(toolkittype); 83 83 -
../trunk-jpl/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
27 27 int size = 0; 28 28 for(int i=0;i<num_controls;i++) size+=M[i]*N[i]; 29 29 30 31 30 /*2. Allocate vector*/ 32 31 vector=new Vector<IssmDouble>(size); 33 32 … … 59 58 parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 60 59 parameters->FindParam(&control_type,NULL,InversionControlParametersEnum); 61 60 62 63 61 /*2. Allocate vector*/ 64 62 vector=new Vector<IssmDouble>(num_controls*vertices->NumberOfVertices()); 65 63 -
../trunk-jpl/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
165 165 edge3=SegmentIntersect(&gamma1,&gamma2, xel,yel,xsegment,ysegment); 166 166 167 167 /*edge can be either IntersectEnum (one and only one intersection between the edge and the segment), ColinearEnum (edge and segment are collinear) and SeparateEnum (no intersection): */ 168 168 169 169 /*if (el==318 && contouri==9){ 170 170 _printf_(edge1 << " " << edge2 << " " << edge3 << " " << alpha1 << " " << alpha2 << " " << beta1 << " " << beta2 << " " << gamma1 << " " << gamma2 << " " << xsegment[0] << " " << xsegment[1] << " " << ysegment[0] << " " << ysegment[1] << " " << xnodes[0] << " " << xnodes[1] << " " << xnodes[2] << " " << ynodes[0] << " " << ynodes[1] << " " << ynodes[2]); 171 171 172 172 _printf_("Bool" << (edge1==IntersectEnum) || (edge2==IntersectEnum) || (edge3==IntersectEnum)); 173 173 }*/ 174 174 … … 198 198 } 199 199 segments_dataset->AddObject(new Segment<double>(el+1,xfinal[0],yfinal[0],xfinal[1],yfinal[1])); 200 200 201 202 201 /*This case is impossible: not quite! */ 203 202 //_printf_(alpha1 << " " << alpha2 << " " << beta1 << " " << beta2 << " " << gamma1 << " " << gamma2 << " " << xsegment[0] << " " << xsegment[1] << " " << ysegment[0] << " " << ysegment[1] << " " << xnodes[0] << " " << xnodes[1] << " " << xnodes[2] << " " << ynodes[0] << " " << ynodes[1] << " " << ynodes[2]); 204 203 /* _error_("error: a line cannot go through 3 different vertices!");*/ … … 225 224 } 226 225 } 227 226 else if( (edge1==IntersectEnum) || (edge2==IntersectEnum) || (edge3==IntersectEnum) ){ 228 227 229 228 /*if (el==318 && contouri==9){ 230 229 _printf_("hello" << " NodeInElement 0 " << (NodeInElement(xnodes,ynodes,xsegment[0],ysegment[0])) << " NodeInElement 1 " << (NodeInElement(xnodes,ynodes,xsegment[1],ysegment[1]))); 231 230 }*/ … … 250 249 if (IsIdenticalNode(xnodes[0],ynodes[0],xsegment[0],ysegment[0],tolerance) || 251 250 IsIdenticalNode(xnodes[1],ynodes[1],xsegment[0],ysegment[0],tolerance) || 252 251 IsIdenticalNode(xnodes[2],ynodes[2],xsegment[0],ysegment[0],tolerance)){ 253 252 254 253 /*ok, segments[0] is common to one of our vertices: */ 255 254 coord1=0; 256 255 if(edge1==IntersectEnum){coord2=alpha1;} -
../trunk-jpl/src/c/modules/DistanceToMaskBoundaryx/DistanceToMaskBoundaryxt.cpp
38 38 39 39 IssmDouble d0=1.e+10; 40 40 IssmDouble xi,yi; 41 41 42 42 //recover vertex position: 43 43 xi=x[i]; yi=y[i]; 44 44 -
../trunk-jpl/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
83 83 int interpolation_type; 84 84 /*this one is special: we don't specify the type, but let the nature of the inputs dictace. 85 85 * P0 -> ElementSIdEnum, P1 ->VertexSIdEnum: */ 86 86 87 87 /*We go find the input of the first element, and query its interpolation type: */ 88 88 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(0)); 89 89 Input* input=element->GetInput(name); -
../trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp
20 20 *element, figure out if they hold the vertex, and the data. If so, return it: */ 21 21 cpu_found=-1; 22 22 found=0; 23 23 24 24 for(int i=0;i<elements->Size();i++){ 25 25 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 26 26 found=element->NodalValue(&value,index,natureofdataenum); -
../trunk-jpl/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
8 8 #include "../../MeshPartitionx/MeshPartitionx.h" 9 9 #include "../ModelProcessorx.h" 10 10 11 12 11 #if !defined(_HAVE_ADOLC_) 13 12 void UpdateElementsAndMaterialsControl(Elements* elements,Parameters* parameters,Materials* materials, IoModel* iomodel){ 14 13 /*Intermediary*/ … … 21 20 char **controls = NULL; 22 21 char **cost_functions = NULL; 23 22 24 25 23 /*Fetch parameters: */ 26 24 iomodel->FindConstant(&control_analysis,"md.inversion.iscontrol"); 27 25 if(control_analysis) iomodel->FindConstant(&num_controls,"md.inversion.num_control_parameters"); … … 28 26 29 27 /*Now, return if no control*/ 30 28 if(!control_analysis) return; 31 29 32 30 /*Process controls and convert from string to enums*/ 33 31 iomodel->FindConstant(&controls,&num_controls,"md.inversion.control_parameters"); 34 32 if(num_controls<1) _error_("no controls found"); … … 47 45 } 48 46 49 47 iomodel->FetchData(3,"md.inversion.cost_functions_coefficients","md.inversion.min_parameters","md.inversion.max_parameters"); 50 48 51 49 /*Fetch Observations */ 52 50 iomodel->FindConstant(&domaintype,"md.mesh.domain_type"); 53 51 for(int i=0;i<num_cost_functions;i++){ … … 153 151 _assert_(M==num_independent_objects); 154 152 iomodel->FetchData(&types,NULL,NULL,"md.autodiff.independent_object_types"); 155 153 156 157 154 M_all = xNew<int>(num_independent_objects); 158 155 159 156 /*create independent objects, and at the same time, fetch the corresponding independent variables, … … 161 158 iomodel->FetchData(&independents_fullmin,&M_par,&N_par,"md.autodiff.independent_min_parameters"); 162 159 iomodel->FetchData(&independents_fullmax,&M_par,&N_par,"md.autodiff.independent_max_parameters"); 163 160 iomodel->FetchData(&control_sizes,NULL,NULL,"md.autodiff.independent_control_sizes"); 164 161 165 162 int* start_point = NULL; 166 163 start_point = xNew<int>(num_independent_objects); 167 164 int counter = 0; … … 179 176 int input_enum; 180 177 IssmDouble* independents_min = NULL; 181 178 IssmDouble* independents_max = NULL; 182 179 183 180 FieldAndEnumFromCode(&input_enum,&iofieldname,names[i]); 184 181 185 182 /*Fetch required data*/ … … 186 183 iomodel->FetchData(&independent,&M,&N,iofieldname); 187 184 _assert_(independent); 188 185 _assert_(N==control_sizes[i]); 189 186 190 187 independents_min = NULL; independents_min = xNew<IssmDouble>(M*N); 191 188 independents_max = NULL; independents_max = xNew<IssmDouble>(M*N); 192 189 for(int m=0;m<M;m++){ … … 205 202 xDelete<IssmDouble>(independent); 206 203 xDelete<IssmDouble>(independents_min); 207 204 xDelete<IssmDouble>(independents_max); 208 205 209 206 } 210 207 else{ 211 208 _error_("Independent cannot be of size " << types[i]); -
../trunk-jpl/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
68 68 /*Intermediaries*/ 69 69 int num_independent_objects,M; 70 70 char** names = NULL; 71 71 72 72 /*this is done somewhere else*/ 73 73 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.num_independent_objects",InversionNumControlParametersEnum)); 74 74 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.num_dependent_objects",InversionNumCostFunctionsEnum)); 75 75 76 76 /*Step1: create controls (independents)*/ 77 77 iomodel->FetchData(&num_independent_objects,"md.autodiff.num_independent_objects"); 78 78 _assert_(num_independent_objects>0); … … 95 95 } 96 96 xDelete<char*>(cm_responses); 97 97 parameters->AddObject(new IntVecParam(InversionCostFunctionsEnum,costfunc_enums,num_costfunc)); 98 98 99 99 iomodel->FetchData(&control_scaling_factors,NULL,NULL,"md.autodiff.independent_scaling_factors"); 100 100 parameters->AddObject(new DoubleVecParam(InversionControlScalingFactorsEnum,control_scaling_factors,num_independent_objects)); 101 101 102 102 /*cleanup*/ 103 103 for(int i=0;i<num_independent_objects;i++){ 104 104 xDelete<char>(names[i]); -
../trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp
10 10 void CreateOutputDefinitions(Elements* elements, Parameters* parameters,IoModel* iomodel){ 11 11 12 12 int i,j; 13 13 14 14 DataSet* output_definitions = NULL; 15 15 int* output_definition_enums = NULL; 16 16 int num_output_definitions; … … 64 64 } 65 65 else if (output_definition_enums[i]==MisfitEnum){ 66 66 /*Deal with misfits: {{{*/ 67 67 68 68 /*misfit variables: */ 69 69 int nummisfits; 70 70 char** misfit_name_s = NULL; … … 114 114 else 115 115 _error_("misfit weight size not supported yet"); 116 116 117 118 117 /*First create a misfit object for that specific string (misfit_model_string_s[j]):*/ 119 118 output_definitions->AddObject(new Misfit(misfit_name_s[j],StringToEnumx(misfit_definitionstring_s[j]),StringToEnumx(misfit_model_string_s[j]),StringToEnumx(misfit_observation_string_s[j]),misfit_timeinterpolation_s[j],misfit_local_s[j],StringToEnumx(misfit_weights_string_s[j]))); 120 119 … … 158 157 } 159 158 else if (output_definition_enums[i]==CfsurfacesquareEnum){ 160 159 /*Deal with cfsurfacesquare: {{{*/ 161 160 162 161 /*cfsurfacesquare variables: */ 163 162 int num_cfsurfacesquares; 164 163 char** cfsurfacesquare_name_s = NULL; … … 213 212 for(int k=0;k<elements->Size();k++){ 214 213 215 214 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(k)); 216 215 217 216 element->DatasetInputAdd(StringToEnumx(cfsurfacesquare_definitionstring_s[j]),cfsurfacesquare_observation_s[j], iomodel,cfsurfacesquare_observation_M_s[j],cfsurfacesquare_observation_N_s[j],obs_vector_type,StringToEnumx(cfsurfacesquare_observation_string_s[j]),7,SurfaceObservationEnum); 218 217 element->DatasetInputAdd(StringToEnumx(cfsurfacesquare_definitionstring_s[j]),cfsurfacesquare_weights_s[j], iomodel,cfsurfacesquare_weights_M_s[j],cfsurfacesquare_weights_N_s[j],weight_vector_type,StringToEnumx(cfsurfacesquare_weights_string_s[j]),7,WeightsSurfaceObservationEnum); 219 218 … … 250 249 } 251 250 else if (output_definition_enums[i]==CfdragcoeffabsgradEnum){ 252 251 /*Deal with cfdragcoeffabsgrad: {{{*/ 253 252 254 253 /*cfdragcoeffabsgrad variables: */ 255 254 int num_cfdragcoeffabsgrads; 256 255 char** cfdragcoeffabsgrad_name_s = NULL; … … 285 284 for(int k=0;k<elements->Size();k++){ 286 285 287 286 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(k)); 288 287 289 288 element->DatasetInputAdd(StringToEnumx(cfdragcoeffabsgrad_definitionstring_s[j]),cfdragcoeffabsgrad_weights_s[j], iomodel,cfdragcoeffabsgrad_weights_M_s[j],cfdragcoeffabsgrad_weights_N_s[j],weight_vector_type,StringToEnumx(cfdragcoeffabsgrad_weights_string_s[j]),7,WeightsSurfaceObservationEnum); 290 289 291 290 } … … 312 311 } 313 312 else if (output_definition_enums[i]==CfsurfacelogvelEnum){ 314 313 /*Deal with cfsurfacelogvel: {{{*/ 315 314 316 315 /*cfsurfacelogvel variables: */ 317 316 int num_cfsurfacelogvels; 318 317 char** cfsurfacelogvel_name = NULL; … … 368 367 for(int k=0;k<elements->Size();k++){ 369 368 370 369 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(k)); 371 370 372 371 element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_vxobs[j], iomodel,cfsurfacelogvel_observation_M[j],cfsurfacelogvel_observation_N[j],obs_vector_type,StringToEnumx(cfsurfacelogvel_vxobs_string[j]),7,VxObsEnum); 373 372 element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_vyobs[j], iomodel,cfsurfacelogvel_observation_M[j],cfsurfacelogvel_observation_N[j],obs_vector_type,StringToEnumx(cfsurfacelogvel_vyobs_string[j]),7,VyObsEnum); 374 373 element->DatasetInputAdd(StringToEnumx(cfsurfacelogvel_definitionstring[j]),cfsurfacelogvel_weights[j], iomodel,cfsurfacelogvel_weights_M[j],cfsurfacelogvel_weights_N[j],weight_vector_type,StringToEnumx(cfsurfacelogvel_weightstring[j]),7,WeightsSurfaceObservationEnum); … … 408 407 } 409 408 else if (output_definition_enums[i]==NodalvalueEnum){ 410 409 /*Deal with nodal values: {{{*/ 411 410 412 411 /*nodal value variables: */ 413 412 int numnodalvalues; 414 413 char** nodalvalue_name_s = NULL; … … 427 426 /*First create a nodalvalue object for that specific enum (nodalvalue_model_enum_s[j]):*/ 428 427 output_definitions->AddObject(new Nodalvalue(nodalvalue_name_s[j],StringToEnumx(nodalvalue_definitionstrings[j]),StringToEnumx(nodalvalue_modelstrings[j]),nodalvalue_node_s[j]-1)); //-1 because matlab to c indexing. 429 428 } 430 429 431 430 /*Free ressources:*/ 432 431 for(j=0;j<numnodalvalues;j++){ 433 432 char* string=NULL; … … 481 480 } 482 481 else if (output_definition_enums[i]==MassconaxpbyEnum){ 483 482 /*Deal with masscon combinations: {{{*/ 484 483 485 484 /*masscon variables: */ 486 485 char** masscon_name_s = NULL; 487 486 char** masscon_definitionstring_s = NULL; … … 616 615 } 617 616 output_definitions->AddObject(new Numberedcostfunction(ncf_name_s[j],StringToEnumx(ncf_definitionstring_s[j]),num_cost_functions,cost_function_enums)); 618 617 } 619 618 620 619 /*Free data: */ 621 620 iomodel->DeleteData(2,"md.numberedcostfunction.name","md.numberedcostfunction.definitionstring"); 622 621 xDelete<int>(cost_function_enums); -
../trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp
22 22 char** requestedoutputs = NULL; 23 23 char* fieldname = NULL; 24 24 IssmDouble time; 25 25 26 26 /*parameters for mass flux:*/ 27 27 int mass_flux_num_profiles = 0; 28 28 bool qmu_mass_flux_present = false; … … 61 61 parameters->AddObject(iomodel->CopyConstantObject("md.inversion.type",InversionTypeEnum)); 62 62 parameters->AddObject(iomodel->CopyConstantObject("md.calving.law",CalvingLawEnum)); 63 63 parameters->AddObject(new IntParam(SealevelriseRunCountEnum,1)); 64 65 64 66 65 {/*This is specific to ice...*/ 67 66 parameters->AddObject(iomodel->CopyConstantObject("md.mesh.elementtype",MeshElementtypeEnum)); -
../trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
54 54 analysis->UpdateElements(elements,iomodel,i,analysis_enum); 55 55 delete analysis; 56 56 57 58 57 /* Update counters, because we have created more nodes, loads and 59 58 * constraints, and ids for objects created in next call to CreateDataSets 60 59 * will need to start at the end of the updated counters: */ -
../trunk-jpl/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
34 34 35 35 /*Create elements*/ 36 36 if(control_analysis && !adolc_analysis)iomodel->FetchData(2,"md.inversion.min_parameters","md.inversion.max_parameters"); 37 37 38 38 switch(iomodel->meshelementtype){ 39 39 case TriaEnum: 40 40 for(i=0;i<iomodel->numberofelements;i++){ … … 122 122 } 123 123 break; 124 124 case MaterialsEnum: 125 125 126 126 //we have several types of materials. Retrieve this info first: 127 127 iomodel->FetchData(&nature,&nnat,&dummy,"md.materials.nature"); 128 128 … … 234 234 if (iomodel->domaintype == Domain3DsurfaceEnum) iomodel->FetchData(3,"md.mesh.lat","md.mesh.long","md.mesh.r"); 235 235 else iomodel->FetchDataToInput(elements,"md.mesh.scale_factor",MeshScaleFactorEnum,1.); 236 236 if (isoceancoupling) iomodel->FetchData(2,"md.mesh.lat","md.mesh.long"); 237 237 238 238 CreateNumberNodeToElementConnectivity(iomodel,solution_type); 239 239 240 240 int lid = 0; -
../trunk-jpl/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
31 31 offset += M[i]*N[i]; 32 32 } 33 33 34 35 34 xDelete<int>(control_type); 36 35 } 37 36 else{ -
../trunk-jpl/src/c/modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.cpp
66 66 } 67 67 } 68 68 /*}}}*/ 69 -
../trunk-jpl/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.cpp
6 6 #include "../../shared/shared.h" 7 7 #include "../../toolkits/toolkits.h" 8 8 9 10 9 void SmbGradientsx(FemModel* femmodel){/*{{{*/ 11 10 12 11 // void SurfaceMassBalancex(hd,agd,ni){ … … 317 316 correct for number of seconds in a year [s/yr]*/ 318 317 smb = smb/yts + anomaly; 319 318 320 321 319 /*Update array accordingly*/ 322 320 smblist[v] = smb; 323 321 -
../trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp
106 106 /*Free ressouces:*/ 107 107 xDelete(dzT); 108 108 xDelete(dzB); 109 109 110 110 //---------NEED TO IMPLEMENT A PROPER GRID STRECHING ALGORITHM------------ 111 111 112 112 /*assign ouput pointers: */ … … 201 201 re=*pre; 202 202 gdn=*pgdn; 203 203 gsp=*pgsp; 204 204 205 205 /*only when aIdx = 1 or 2 do we run grainGrowth: */ 206 206 if(aIdx!=1 & aIdx!=2){ 207 207 /*come out as we came in: */ … … 220 220 //set maximum water content by mass to 9 percent (Brun, 1980) 221 221 for(int i=0;i<m;i++)if(lwc[i]>9.0-Wtol) lwc[i]=9.0; 222 222 223 224 223 /* Calculate temperature gradiant across grid cells 225 224 * Returns the avereage gradient across the upper and lower grid cell */ 226 225 … … 243 242 244 243 // take absolute value of temperature gradient 245 244 for(int i=0;i<m;i++)dT[i]=fabs(dT[i]); 246 245 247 246 /*Snow metamorphism. Depends on value of snow dendricity and wetness of the snowpack: */ 248 247 for(int i=0;i<m;i++){ 249 248 if (gdn[i]>0.0+Gdntol){ … … 323 322 //convert grain size back to effective grain radius: 324 323 re[i]=gsz[i]/2.0; 325 324 } 326 325 327 326 /*Free ressources:*/ 328 327 xDelete<IssmDouble>(gsz); 329 328 xDelete<IssmDouble>(dT); … … 347 346 348 347 //// Inputs 349 348 // aIdx = albedo method to use 350 349 351 350 // Method 0 352 351 // aValue = direct input value for albedo, override all changes to albedo 353 352 … … 396 395 397 396 /*Recover pointers: */ 398 397 a=*pa; 399 398 400 399 //some constants: 401 400 const IssmDouble dSnow = 300; // density of fresh snow [kg m-3] 402 401 … … 512 511 void thermo(IssmDouble* pEC, IssmDouble** pT, IssmDouble* dz, IssmDouble* d, IssmDouble* swf, IssmDouble dlwrf, IssmDouble Ta, IssmDouble V, IssmDouble eAir, IssmDouble pAir, IssmDouble teValue, IssmDouble Ws, IssmDouble dt0, int m, IssmDouble Vz, IssmDouble Tz, IssmDouble thermo_scaling, IssmDouble dIce, int sid) { /*{{{*/ 513 512 514 513 /* ENGLACIAL THERMODYNAMICS*/ 515 514 516 515 /* Description: 517 516 computes new temperature profile accounting for energy absorption and 518 517 thermal diffusion.*/ … … 536 535 // OUTPUTS 537 536 // T: grid cell temperature [k] 538 537 // EC: evaporation/condensation [kg] 539 538 540 539 /*intermediary: */ 541 540 IssmDouble* K = NULL; 542 541 IssmDouble* KU = NULL; … … 579 578 IssmDouble dT_ulw=0.0; 580 579 IssmDouble dlw=0.0; 581 580 IssmDouble dT_dlw=0.0; 582 581 583 582 /*outputs:*/ 584 583 IssmDouble EC=0.0; 585 584 IssmDouble* T=*pT; … … 596 595 597 596 //initialize Evaporation - Condenstation 598 597 EC = 0.0; 599 598 600 599 // check if all SW applied to surface or distributed throught subsurface 601 600 // swIdx = length(swf) > 1 602 601 … … 608 607 609 608 // if V = 0 goes to infinity therfore if V = 0 change 610 609 if(V<0.01-Dtol)V=0.01; 611 610 612 611 // Bulk-transfer coefficient for turbulent fluxes 613 612 An = pow(0.4,2) / pow(log(Tz/z0),2); // Bulk-transfer coefficient 614 613 C = An * dAir * V; // shf & lhf common coefficient … … 626 625 for(int i=0;i<m;i++) if(d[i]>=dIce-Dtol) K[i] = 9.828 * exp(-5.7E-3*T[i]); 627 626 628 627 // THERMAL DIFFUSION COEFFICIENTS 629 628 630 629 // A discretization scheme which truncates the Taylor-Series expansion 631 630 // after the 3rd term is used. See Patankar 1980, Ch. 3&4 632 631 633 632 // discretized heat equation: 634 633 635 634 // Tp = (Au*Tu° + Ad*Td° + (Ap-Au-Ad)Tp° + S) / Ap 636 635 637 636 // where neighbor coefficients Au, Ap, & Ad are 638 637 639 638 // Au = [dz_u/2KP + dz_p/2KE]^-1 640 639 // Ad = [dz_d/2KP + dz_d/2KD]^-1 641 640 // Ap = d*CI*dz/Dt … … 648 647 KU = xNew<IssmDouble>(m); 649 648 KD = xNew<IssmDouble>(m); 650 649 KP = xNew<IssmDouble>(m); 651 650 652 651 KU[0] = UNDEF; 653 652 KD[m-1] = UNDEF; 654 653 for(int i=1;i<m;i++) KU[i]= K[i-1]; … … 660 659 dzD = xNew<IssmDouble>(m); 661 660 dzU[0]=UNDEF; 662 661 dzD[m-1]=UNDEF; 663 662 664 663 for(int i=1;i<m;i++) dzU[i]= dz[i-1]; 665 664 for(int i=0;i<m-1;i++) dzD[i] = dz[i+1]; 666 665 … … 692 691 Ad[i] = pow((dzD[i]/2.0/KP[i] + dz[i]/2.0/KD[i]),-1.0); 693 692 Ap[i] = (d[i]*dz[i]*CI)/dt; 694 693 } 695 694 696 695 // create "neighbor" coefficient matrix 697 696 Nu = xNew<IssmDouble>(m); 698 697 Nd = xNew<IssmDouble>(m); … … 702 701 Nd[i] = Ad[i] / Ap[i]; 703 702 Np[i]= 1.0 - Nu[i] - Nd[i]; 704 703 } 705 704 706 705 // specify boundary conditions: constant flux at bottom 707 706 Nu[m-1] = 0.0; 708 707 Np[m-1] = 1.0; 709 708 710 709 // zero flux at surface 711 710 Np[0] = 1.0 - Nd[0]; 712 711 713 712 // Create neighbor arrays for diffusion calculations instead of a tridiagonal matrix 714 713 Nu[0] = 0.0; 715 714 Nd[m-1] = 0.0; 716 715 717 716 /* RADIATIVE FLUXES*/ 718 717 719 718 // energy supplied by shortwave radiation [J] 720 719 sw = xNew<IssmDouble>(m); 721 720 for(int i=0;i<m;i++) sw[i]= swf[i] * dt; 722 721 723 722 // temperature change due to SW 724 723 dT_sw = xNew<IssmDouble>(m); 725 724 for(int i=0;i<m;i++) dT_sw[i]= sw[i] / (CI * d[i] * dz[i]); … … 745 744 // PART OF ENERGY CONSERVATION CHECK 746 745 // store initial temperature 747 746 //T_init = T; 748 747 749 748 // calculate temperature of snow surface (Ts) 750 749 // when incoming SW radition is allowed to penetrate the surface, 751 750 // the modeled energy balance becomes very sensitive to how Ts is … … 753 752 // less when Ts is taken as the mean of the x top grid cells. 754 753 Ts = (T[0] + T[1])/2.0; 755 754 Ts = fmin(CtoK,Ts); // don't allow Ts to exceed 273.15 K (0 degC) 756 755 757 756 //TURBULENT HEAT FLUX 758 757 759 758 // Monin-Obukhov Stability Correction 760 759 // Reference: 761 760 // Ohmura, A., 1982: Climate and Energy-Balance on the Arctic Tundra. … … 763 762 764 763 // calculate the Bulk Richardson Number (Ri) 765 764 Ri = (2.0*9.81* (Vz - z0) * (Ta - Ts)) / ((Ta + Ts)* pow(V,2.0)); 766 765 767 766 // calculate Monin-Obukhov stability factors 'coefM' and 'coefH' 768 767 769 768 // do not allow Ri to exceed 0.19 770 769 Ri = fmin(Ri, 0.19); 771 770 … … 777 776 else { 778 777 coefM =pow (1.0-18*Ri,-0.25); 779 778 } 780 779 781 780 // calculate heat/wind 'coef_H' stability factor 782 781 if (Ri <= -0.03+Ttol) coefH = coefM/1.3; 783 782 else coefH = coefM; 784 783 785 784 //// Sensible Heat 786 785 // calculate the sensible heat flux [W m-2](Patterson, 1998) 787 786 shf = C * CA * (Ta - Ts); … … 800 799 } 801 800 else{ 802 801 L = LS; // latent heat of sublimation 803 802 804 803 // for an ice surface Murphy and Koop, 2005 [Equation 7] 805 804 eS = exp(9.550426 - 5723.265/Ts + 3.53068 * log(Ts) - 0.00728332 * Ts); 806 805 } … … 822 821 // upward longwave contribution 823 822 ulw = - (SB * pow(Ts,4.0)* teValue) * dt ; 824 823 dT_ulw = ulw / TCs; 825 824 826 825 // new grid point temperature 827 826 828 827 //SW penetrates surface 829 828 for(int j=0;j<m;j++) T[j] = T[j] + dT_sw[j]; 830 829 T[0] = T[0] + dT_dlw + dT_ulw + dT_turb; 831 830 832 831 // temperature diffusion 833 832 for(int j=0;j<m;j++) T0[1+j]=T[j]; 834 833 for(int j=0;j<m;j++) Tu[j] = T0[j]; 835 834 for(int j=0;j<m;j++) Td[j] = T0[2+j]; 836 835 for(int j=0;j<m;j++) T[j] = (Np[j] * T[j]) + (Nu[j] * Tu[j]) + (Nd[j] * Td[j]); 837 836 838 837 // calculate cumulative evaporation (+)/condensation(-) 839 838 EC = EC + (EC_day/dts)*dt; 840 839 … … 872 871 xDelete<IssmDouble>(Tu); 873 872 xDelete<IssmDouble>(Td); 874 873 875 876 874 /*Assign output pointers:*/ 877 875 *pEC=EC; 878 876 *pT=T; … … 900 898 // Outputs 901 899 // swf = absorbed shortwave radiation [W m-2] 902 900 // 903 901 904 902 /*outputs: */ 905 903 IssmDouble* swf=NULL; 906 904 … … 909 907 /*Initialize and allocate: */ 910 908 swf=xNewZeroInit<IssmDouble>(m); 911 909 912 913 910 // SHORTWAVE FUNCTION 914 911 if (swIdx == 0) {// all sw radation is absorbed in by the top grid cell 915 912 916 913 // calculate surface shortwave radiation fluxes [W m-2] 917 914 swf[0] = (1.0 - as) * dsw; 918 915 } … … 947 944 B2_cum[i]=1.0; 948 945 } 949 946 950 951 947 // spectral albedos: 952 948 // 0.3 - 0.8um 953 949 IssmDouble a0 = fmin(0.98, 1.0 - 1.58 *pow(gsz[0],0.5)); … … 988 984 B2_cum[i+1]=cum2; 989 985 } 990 986 991 992 987 // flux across grid cell boundaries 993 988 Qs1 = xNew<IssmDouble>(m+1); 994 989 Qs2 = xNew<IssmDouble>(m+1); … … 1014 1009 xDelete<IssmDouble>(exp2); 1015 1010 xDelete<IssmDouble>(Qs1); 1016 1011 xDelete<IssmDouble>(Qs2); 1017 1018 1012 1019 1013 } 1020 1014 else{ //function of grid cell density 1021 1015 … … 1143 1137 for(int i=0;i<m;i++)massinit+=mInit[i]; 1144 1138 1145 1139 if (P > 0.0+Dtol){ 1146 1147 1140 1148 1141 if (T_air <= CtoK+Ttol){ // if snow 1149 1142 … … 1209 1202 mass=0; for(int i=0;i<m;i++)mass+=d[i]*dz[i]; 1210 1203 1211 1204 mass_diff = mass - massinit - P; 1212 1205 1213 1206 #ifndef _HAVE_ADOLC_ //avoid round operation. only check in forward mode. 1214 1207 mass_diff = round(mass_diff * 100.0)/100.0; 1215 1208 if (mass_diff > 0) _error_("mass not conserved in accumulation function"); … … 1252 1245 IssmDouble* EW=NULL; 1253 1246 IssmDouble* M=NULL; 1254 1247 int* D=NULL; 1255 1248 1256 1249 IssmDouble sumM=0.0; 1257 1250 IssmDouble sumER=0.0; 1258 1251 IssmDouble addE=0.0; … … 1264 1257 IssmDouble dm=0.0; 1265 1258 IssmDouble X=0.0; 1266 1259 IssmDouble Wi=0.0; 1267 1260 1268 1261 IssmDouble Ztot=0.0; 1269 1262 IssmDouble T_bot=0.0; 1270 1263 IssmDouble m_bot=0.0; … … 1278 1271 IssmDouble EI_bot=0.0; 1279 1272 IssmDouble EW_bot=0.0; 1280 1273 bool top=false; 1281 1274 1282 1275 IssmDouble* Zcum=NULL; 1283 1276 IssmDouble* dzMin2=NULL; 1284 1277 IssmDouble zY2=1.025; … … 1285 1278 bool lastCellFlag = false; 1286 1279 int X1=0; 1287 1280 int X2=0; 1288 1281 1289 1282 int D_size = 0; 1290 1283 1291 1284 /*outputs:*/ … … 1302 1295 IssmDouble* gsp=*pgsp; 1303 1296 int n=*pn; 1304 1297 IssmDouble* R=NULL; 1305 1298 1306 1299 if(VerboseSmb() && sid==0 && IssmComm::GetRank()==0)_printf0_(" melt module\n"); 1307 1300 1308 1301 //// INITIALIZATION … … 1334 1327 // new grid point center temperature, T [K] 1335 1328 // for(int i=0;i<n;i++) T[i]-=exsT[i]; 1336 1329 for(int i=0;i<n;i++) T[i]=fmin(T[i],CtoK); 1337 1330 1338 1331 // specify irreducible water content saturation [fraction] 1339 1332 const IssmDouble Swi = 0.07; // assumed constant after Colbeck, 1974 1340 1333 … … 1492 1485 flxDn[i+1] = inM - F1 - dW[i]; // meltwater out 1493 1486 T[i] = T[i] + ((F1+F2)*(LF+(CtoK - T[i])*CI)/(m[i]*CI));// change in temperature 1494 1487 1495 1496 1488 // check if an ice layer forms 1497 1489 if (fabs(d[i] - dIce) < Dtol){ 1498 1490 // _printf_("ICE LAYER FORMS"); … … 1504 1496 } 1505 1497 } 1506 1498 1507 1508 1499 //// GRID CELL SPACING AND MODEL DEPTH 1509 1500 for(int i=0;i<n;i++)if (W[i] < 0.0 - Wtol) _error_("negative pore water generated in melt equations"); 1510 1501 1511 1502 // delete all cells with zero mass 1512 1503 // adjust pore water 1513 1504 for(int i=0;i<n;i++)W[i] += dW[i]; … … 1532 1523 celldelete(&EW,n,D,D_size); 1533 1524 n=D_size; 1534 1525 xDelete<int>(D); 1535 1526 1536 1527 // calculate new grid lengths 1537 1528 for(int i=0;i<n;i++)dz[i] = m[i] / d[i]; 1538 1529 … … 1544 1535 //Merging of cells as they are burried under snow. 1545 1536 Zcum=xNew<IssmDouble>(n); 1546 1537 dzMin2=xNew<IssmDouble>(n); 1547 1538 1548 1539 Zcum[0]=dz[0]; // Compute a cumulative depth vector 1549 1540 1550 1541 for (int i=1;i<n;i++){ 1551 1542 Zcum[i]=Zcum[i-1]+dz[i]; 1552 1543 } 1553 1544 1554 1545 for (int i=0;i<n;i++){ 1555 1546 if (Zcum[i]<=zTop+Dtol){ 1556 1547 dzMin2[i]=dzMin; … … 1568 1559 break; 1569 1560 } 1570 1561 } 1571 1562 1572 1563 //Last cell has to be treated separately if has to be merged (no underlying cell so need to merge with overlying cell) 1573 1564 if(X==n-1){ 1574 1565 lastCellFlag = true; … … 1588 1579 re[i+1] = (re[i]*m[i] + re[i+1]*m[i+1]) / m_new; 1589 1580 gdn[i+1] = (gdn[i]*m[i] + gdn[i+1]*m[i+1]) / m_new; 1590 1581 gsp[i+1] = (gsp[i]*m[i] + gsp[i+1]*m[i+1]) / m_new; 1591 1582 1592 1583 // merge with underlying grid cell and delete old cell 1593 1584 dz[i+1] = dz[i] + dz[i+1]; // combine cell depths 1594 1585 d[i+1] = m_new / dz[i+1]; // combine top densities 1595 1586 W[i+1] = W[i+1] + W[i]; // combine liquid water 1596 1587 m[i+1] = m_new; // combine top masses 1597 1588 1598 1589 // set cell to 99999 for deletion 1599 1590 m[i] = -99999; 1600 1591 } … … 1610 1601 break; 1611 1602 } 1612 1603 } 1613 1604 1614 1605 // adjust variables as a linearly weighted function of mass 1615 1606 IssmDouble m_new = m[X2] + m[X1]; 1616 1607 T[X1] = (T[X2]*m[X2] + T[X1]*m[X1]) / m_new; … … 1618 1609 re[X1] = (re[X2]*m[X2] + re[X1]*m[X1]) / m_new; 1619 1610 gdn[X1] = (gdn[X2]*m[X2] + gdn[X1]*m[X1]) / m_new; 1620 1611 gsp[X1] = (gsp[X2]*m[X2] + gsp[X1]*m[X1]) / m_new; 1621 1612 1622 1613 // merge with underlying grid cell and delete old cell 1623 1614 dz[X1] = dz[X2] + dz[X1]; // combine cell depths 1624 1615 d[X1] = m_new / dz[X1]; // combine top densities 1625 1616 W[X1] = W[X1] + W[X2]; // combine liquid water 1626 1617 m[X1] = m_new; // combine top masses 1627 1618 1628 1619 // set cell to 99999 for deletion 1629 1620 m[X2] = -99999; 1630 1621 } … … 1647 1638 celldelete(&EW,n,D,D_size); 1648 1639 n=D_size; 1649 1640 xDelete<int>(D); 1650 1641 1651 1642 // check if any of the top 10 cell depths are too large 1652 1643 X=0; 1653 1644 for(int i=9;i>=0;i--){ … … 1656 1647 break; 1657 1648 } 1658 1649 } 1659 1650 1660 1651 int j=0; 1661 1652 while(j<=X){ 1662 1653 if (dz[j] > dzMin*2.0+Dtol){ … … 1685 1676 // INTERPRETATION 1686 1677 // calculate total model depth 1687 1678 Ztot = cellsum(dz,n); 1688 1679 1689 1680 if (Ztot < zMin-Dtol){ 1690 1681 // printf("Total depth < zMin %f \n", Ztot); 1691 1682 // mass and energy to be added 1692 1683 mAdd = m[n-1]+W[n-1]; 1693 1684 addE = T[n-1]*m[n-1]*CI + W[n-1]*(LF+CtoK*CI); 1694 1685 1695 1686 // add a grid cell of the same size and temperature to the bottom 1696 1687 dz_bot=dz[n-1]; 1697 1688 T_bot=T[n-1]; … … 1704 1695 gsp_bot=gsp[n-1]; 1705 1696 EI_bot=EI[n-1]; 1706 1697 EW_bot=EW[n-1]; 1707 1698 1708 1699 dz_add=dz_bot; 1709 1700 1710 1701 newcell(&dz,dz_bot,top,n); 1711 1702 newcell(&T,T_bot,top,n); 1712 1703 newcell(&W,W_bot,top,n); … … 1726 1717 mAdd = -(m[n-1]+W[n-1]); 1727 1718 addE = -(T[n-1]*m[n-1]*CI) - (W[n-1]*(LF+CtoK*CI)); 1728 1719 dz_add=-(dz[n-1]); 1729 1720 1730 1721 // remove a grid cell from the bottom 1731 1722 D_size=n-1; 1732 1723 D=xNew<int>(D_size); 1733 1724 1734 1725 for(int i=0;i<n-1;i++) D[i]=i; 1735 1726 celldelete(&dz,n,D,D_size); 1736 1727 celldelete(&T,n,D,D_size); … … 1767 1758 if (dm !=0 || dE !=0) _error_("mass or energy are not conserved in melt equations\n" 1768 1759 << "dm: " << dm << " dE: " << dE << "\n"); 1769 1760 #endif 1770 1761 1771 1762 /*Free ressources:*/ 1772 1763 if(m)xDelete<IssmDouble>(m); 1773 1764 if(EI)xDelete<IssmDouble>(EI); … … 1783 1774 if(M)xDelete<IssmDouble>(M); 1784 1775 xDelete<IssmDouble>(Zcum); 1785 1776 xDelete<IssmDouble>(dzMin2); 1786 1777 1787 1778 /*Assign output pointers:*/ 1788 1779 *pM=sumM; 1789 1780 *pR=Rsum; … … 1861 1852 /*output: */ 1862 1853 IssmDouble* dz=NULL; 1863 1854 IssmDouble* d=NULL; 1864 1855 1865 1856 if(VerboseSmb() && sid==0 && IssmComm::GetRank()==0)_printf0_(" densification module\n"); 1866 1857 1867 1858 /*Recover pointers: */ … … 1870 1861 1871 1862 // initial mass 1872 1863 IssmDouble* mass_init = xNew<IssmDouble>(m);for(int i=0;i<m;i++) mass_init[i]=d[i] * dz[i]; 1873 1864 1874 1865 /*allocations and initialization of overburden pressure and factor H: */ 1875 1866 IssmDouble* cumdz = xNew<IssmDouble>(m-1); 1876 1867 cumdz[0]=dz[0]; … … 1879 1870 IssmDouble* obp = xNew<IssmDouble>(m); 1880 1871 obp[0]=0.0; 1881 1872 for(int i=1;i<m;i++)obp[i]=cumdz[i-1]*d[i-1]; 1882 1873 1883 1874 // calculate new snow/firn density for: 1884 1875 // snow with densities <= 550 [kg m-3] 1885 1876 // snow with densities > 550 [kg m-3] 1886 1887 1877 1888 1878 for(int i=0;i<m;i++){ 1889 1879 switch (denIdx){ 1890 1880 case 1: // Herron and Langway (1980) … … 2003 1993 IssmDouble shf=0.0; 2004 1994 IssmDouble lhf=0.0; 2005 1995 IssmDouble EC=0.0; 2006 1996 2007 1997 if(VerboseSmb() && sid==0 && IssmComm::GetRank()==0)_printf0_(" turbulentFlux module\n"); 2008 1998 2009 1999 // calculated air density [kg/m3] … … 2028 2018 Ri = (2.0*9.81* (Vz - z0) * (Ta - Ts)) / ((Ta + Ts)* pow(V,2)); 2029 2019 2030 2020 // calculate Monin-Obukhov stability factors 'coef_M' and 'coef_H' 2031 2021 2032 2022 // do not allow Ri to exceed 0.19 2033 2023 Ri = fmin(Ri, 0.19); 2034 2024 … … 2072 2062 eS = exp(9.550426 - 5723.265/Ts + 3.53068 * log(Ts) - 0.00728332 * Ts); 2073 2063 } 2074 2064 2075 2076 2065 // Latent heat flux [W m-2] 2077 2066 lhf = C * L * (eAir - eS) * 0.622 / pAir; 2078 2067 -
../trunk-jpl/src/c/modules/FloatingiceMeltingRatePicox/FloatingiceMeltingRatePicox.cpp
106 106 107 107 femmodel->parameters->FindParam(&num_basins,BasalforcingsPicoNumBasinsEnum); 108 108 femmodel->parameters->FindParam(&maxbox,BasalforcingsPicoMaxboxcountEnum); 109 109 110 110 IssmDouble* boxareas=xNewZeroInit<IssmDouble>(num_basins*maxbox); 111 111 112 112 for(int i=0;i<femmodel->elements->Size();i++){ … … 121 121 IssmDouble* sumareas =xNew<IssmDouble>(num_basins*maxbox); 122 122 ISSM_MPI_Allreduce(boxareas,sumareas,num_basins*maxbox,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 123 123 //if(sumareas[0]==0){_error_("No elements in box 0, basal meltrates will be 0. Consider decreasing md.basalforcings.maxboxcount or refining your mesh!");} 124 124 125 125 /*Update parameters to keep track of the new areas in future calculations*/ 126 126 femmodel->parameters->AddObject(new DoubleVecParam(BasalforcingsPicoBoxAreaEnum,sumareas,maxbox*num_basins)); 127 127 -
../trunk-jpl/src/c/modules/ExpToLevelSetx/ExpToLevelSetxt.cpp
51 51 double x1,y1; 52 52 double x2,y2; 53 53 double mind; 54 54 55 55 for(int i=i0;i<i1;i++){ 56 56 57 57 /*Get current point*/ … … 92 92 /*Beyond the 'w' end of the segment*/ 93 93 return sqrt(pow(x2-x0,2)+pow(y2-y0,2)); 94 94 } 95 95 96 96 /*Projection falls on segment*/ 97 97 double projx= x1 + t* (x2-x1); 98 98 double projy= y1 + t* (y2-y1); -
../trunk-jpl/src/c/solutionsequences/solutionsequence_linear.cpp
19 19 Vector<IssmDouble>* ys = NULL; 20 20 int configuration_type; 21 21 IssmDouble solver_residue_threshold; 22 22 23 23 /*solver convergence test: */ 24 24 IssmDouble nKUF; 25 25 IssmDouble nF; … … 38 38 femmodel->profiler->Start(SOLVER); 39 39 Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); 40 40 femmodel->profiler->Stop(SOLVER); 41 41 42 42 /*Check that the solver converged nicely: */ 43 43 44 44 //compute KUF = KU - F = K*U - F 45 45 KU=uf->Duplicate(); Kff->MatMult(uf,KU); 46 46 KUF=KU->Duplicate(); KU->Copy(KUF); KUF->AYPX(pf,-1.0); … … 52 52 53 53 if(!xIsNan(solver_residue_threshold) && solver_residue>solver_residue_threshold)_error_(" solver residue too high!: norm(KU-F)/norm(F)=" << solver_residue << "\n"); 54 54 55 56 55 //clean up 57 56 delete KU; delete KUF; 58 57 delete Kff; delete pf; delete df; … … 62 61 // ADOLC_DUMP_MACRO(uf->svector->vector[i]); 63 62 // } 64 63 //#endif 65 64 66 65 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);delete uf; delete ys; 67 66 InputUpdateFromSolutionx(femmodel,ug); 68 67 delete ug; -
../trunk-jpl/src/c/solutionsequences/solutionsequence_fct.cpp
184 184 185 185 /*Initial guess*/ 186 186 VecZeroEntries(udot); 187 187 188 188 /*Richardson's iterations*/ 189 189 for(int i=0;i<5;i++){ 190 190 MatMult(Mc,udot,temp1); … … 401 401 /*Create RHS: [ML + (1 â theta) deltaT L^n] u^n */ 402 402 CreateRHS(&RHS,K_petsc,D_petsc,Ml_petsc,uf->pvector->vector,theta,deltat,dmax,femmodel,configuration_type); 403 403 delete uf; 404 404 405 405 /*Go solve lower order solution*/ 406 406 femmodel->profiler->Start(SOLVER); 407 407 SolverxPetsc(&u,LHS,RHS,NULL,NULL, femmodel->parameters); -
../trunk-jpl/src/c/solutionsequences/solutionsequence_thermal_nonlinear.cpp
60 60 } 61 61 62 62 count=1; 63 63 64 64 for(;;){ 65 65 delete tf_old;tf_old=tf; 66 66 -
../trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp
177 177 rhs=xNew<IssmDouble>(pf_M); 178 178 #endif 179 179 180 181 180 recvcounts=xNew<int>(num_procs); 182 181 displs=xNew<int>(num_procs); 183 182 … … 262 261 rhs=xNew<IssmDouble>(pf_M); 263 262 #endif 264 263 265 266 264 recvcounts=xNew<int>(num_procs); 267 265 displs=xNew<int>(num_procs); 268 266 -
../trunk-jpl/src/c/cores/controlad_core.cpp
104 104 case 7: _printf0_(" <g,d> > 0 or <y,s> <0\n"); break; 105 105 default: _printf0_(" Unknown end condition\n"); 106 106 } 107 107 108 108 /*Save results:*/ 109 109 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,G,n,1,0,0.0)); 110 110 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffXpEnum,X,intn,1,0,0.0)); … … 129 129 int intn; 130 130 IssmPDouble* X=NULL; 131 131 int i; 132 132 133 133 /*Now things get complicated. The femmodel we recovered did not initialize an AD trace, so we can't compute gradients with it. We are going to recreate 134 134 *a new femmodel, identical in all aspects to the first one, with trace on though, which will allow us to run the forward mode and get the gradient 135 135 in one run of the solution core. So first recover the filenames required for the FemModel constructor, then call a new ad tailored constructor:*/ … … 142 142 143 143 femmodel=new FemModel(rootpath, inputfilename, outputfilename, toolkitsfilename, lockfilename, restartfilename,IssmComm::GetComm(), femmodel->solution_type,NULL); 144 144 145 146 145 /*Get initial guess:*/ 147 146 femmodel->parameters->FindParam(&Xd,&intn,AutodiffXpEnum); 148 147 X=xNew<IssmPDouble>(intn); for(i=0;i<intn;i++) X[i]=reCast<IssmPDouble>(Xd[i]); … … 174 173 FemModel *femmodel = NULL; 175 174 IssmDouble pfd; 176 175 int i; 177 176 178 177 /*Recover Femmodel*/ 179 178 femmodel = (FemModel*)dzs; 180 179 … … 194 193 IssmDouble* Jlist = NULL; 195 194 femmodel->CostFunctionx(&pfd,&Jlist,NULL); *pf=reCast<IssmPDouble>(pfd); 196 195 _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<" | "); 197 196 198 197 /*Compute gradient using AD. Gradient is in the results after the ad_core is called*/ 199 198 adgradient_core(femmodel); 200 199 … … 210 209 211 210 /*MPI broadcast results:*/ 212 211 ISSM_MPI_Bcast(G2,*n,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 213 212 214 213 /*Send gradient to m1qn3 core: */ 215 214 for(long i=0;i<*n;i++) G[i] = G2[i]; 216 215 217 216 /*Constrain X and G*/ 218 217 IssmDouble Gnorm = 0.; 219 218 for(long i=0;i<*n;i++) Gnorm += G[i]*G[i]; … … 227 226 /*Clean-up and return*/ 228 227 xDelete<IssmDouble>(Jlist); 229 228 xDelete<IssmPDouble>(G2); 230 229 231 230 xDelete<char>(rootpath); 232 231 xDelete<char>(inputfilename); 233 232 xDelete<char>(outputfilename); … … 250 249 FemModel *femmodelad = NULL; 251 250 IssmDouble pfd; 252 251 int i; 253 252 254 253 /*Recover Femmodel*/ 255 254 femmodel = (FemModel*)dzs; 256 255 … … 270 269 271 270 femmodelad=new FemModel(rootpath, inputfilename, outputfilename, toolkitsfilename, lockfilename, restartfilename,IssmComm::GetComm(), femmodel->solution_type,X); 272 271 femmodel=femmodelad; //We can do this, because femmodel is being called from outside, not by reference, so we won't erase it 273 272 274 273 /*Recover some parameters*/ 275 274 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 276 275 … … 283 282 IssmDouble* Jlist = NULL; 284 283 femmodel->CostFunctionx(&pfd,&Jlist,NULL); *pf=reCast<IssmPDouble>(pfd); 285 284 _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<" | "); 286 285 287 286 /*Compute gradient using AD. Gradient is in the results after the ad_core is called*/ 288 287 adgradient_core(femmodel); 289 288 … … 299 298 300 299 /*MPI broadcast results:*/ 301 300 ISSM_MPI_Bcast(G2,*n,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 302 301 303 302 /*Send gradient to m1qn3 core: */ 304 303 for(long i=0;i<*n;i++) G[i] = G2[i]; 305 304 306 305 /*Recover Gnorm: */ 307 306 IssmDouble Gnorm = 0.; 308 307 for(int i=0;i<*n;i++) Gnorm += G[i]*G[i]; … … 316 315 /*Clean-up and return*/ 317 316 xDelete<IssmDouble>(Jlist); 318 317 xDelete<IssmPDouble>(G2); 319 320 318 xDelete<char>(rootpath); 321 319 xDelete<char>(inputfilename); 322 320 xDelete<char>(outputfilename); -
../trunk-jpl/src/c/cores/gia_core.cpp
52 52 int outputs[2] = {GiaWEnum,GiadWdtEnum}; 53 53 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],2); 54 54 } 55 55 56 56 xDelete<IssmDouble>(x); 57 57 xDelete<IssmDouble>(y); 58 58 } -
../trunk-jpl/src/c/cores/bmb_core.cpp
11 11 12 12 void bmb_core(FemModel* femmodel){ 13 13 14 15 14 /*First, get BMB model from parameters*/ 16 15 int basalforcing_model; 17 16 bool isplume = false; -
../trunk-jpl/src/c/cores/dakota_core.cpp
234 234 /*}}}*/ 235 235 void dakota_core(FemModel* femmodel){ /*{{{*/ 236 236 237 238 237 int my_rank; 239 238 char *dakota_input_file = NULL; 240 239 char *dakota_output_file = NULL; -
../trunk-jpl/src/c/cores/esa_core.cpp
22 22 int solution_type; 23 23 int numoutputs = 0; 24 24 char **requested_outputs = NULL; 25 25 26 26 /*additional parameters: */ 27 27 int gsize; 28 28 bool spherical=true; … … 79 79 U_east = new Vector<IssmDouble>(gsize); 80 80 U_x = new Vector<IssmDouble>(gsize); 81 81 U_y = new Vector<IssmDouble>(gsize); 82 82 83 83 /*call the geodetic main modlule:*/ 84 84 if(domaintype==Domain3DsurfaceEnum){ 85 85 femmodel->EsaGeodetic3D(U_radial,U_north,U_east,latitude,longitude,radius,xx,yy,zz); … … 94 94 InputUpdateFromVectorx(femmodel,U_radial,EsaUmotionEnum,VertexSIdEnum); // radial displacement 95 95 InputUpdateFromVectorx(femmodel,U_north,EsaNmotionEnum,VertexSIdEnum); // north motion 96 96 InputUpdateFromVectorx(femmodel,U_east,EsaEmotionEnum,VertexSIdEnum); // east motion 97 97 98 98 if(save_results){ 99 99 if(VerboseSolution()) _printf0_(" saving results\n"); 100 100 femmodel->parameters->FindParam(&requested_outputs,&numoutputs,EsaRequestedOutputsEnum); 101 101 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 102 102 } 103 103 104 104 if(solution_type==EsaSolutionEnum)femmodel->RequestedDependentsx(); 105 105 106 106 /*Free ressources:*/ … … 114 114 115 115 } 116 116 /*}}}*/ 117 -
../trunk-jpl/src/c/cores/masstransport_core.cpp
30 30 femmodel->parameters->FindParam(&numoutputs,MasstransportNumRequestedOutputsEnum); 31 31 femmodel->parameters->FindParam(&stabilization,MasstransportStabilizationEnum); 32 32 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,MasstransportRequestedOutputsEnum); 33 33 34 34 if(VerboseSolution()) _printf0_(" computing mass transport\n"); 35 35 36 36 /*Transport mass or free surface*/ -
../trunk-jpl/src/c/cores/sealevelrise_core.cpp
12 12 /*cores:*/ 13 13 void sealevelrise_core(FemModel* femmodel){ /*{{{*/ 14 14 15 16 15 /*Parameters, variables:*/ 17 16 bool save_results; 18 17 bool isslr=0; 19 18 int solution_type; 20 19 21 20 /*Retrieve parameters:*/ 22 21 femmodel->parameters->FindParam(&isslr,TransientIsslrEnum); 23 22 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 24 23 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 25 24 26 25 /*in case we are running SealevelriseSolutionEnum, then bypass transient settings:*/ 27 26 if(solution_type==SealevelriseSolutionEnum)isslr=1; 28 27 … … 40 39 41 40 /*Run steric core for sure:*/ 42 41 steric_core(femmodel); 43 42 44 43 /*Save results: */ 45 44 if(save_results){ 46 45 int numoutputs = 0; … … 58 57 /*}}}*/ 59 58 void geodetic_core(FemModel* femmodel){ /*{{{*/ 60 59 61 62 60 /*variables:*/ 63 61 Vector<IssmDouble> *RSLg = NULL; 64 62 Vector<IssmDouble> *RSLg_rate = NULL; … … 87 85 88 86 /*Should we even be here?:*/ 89 87 femmodel->parameters->FindParam(&geodetic,SealevelriseGeodeticEnum); if(!geodetic)return; 90 88 91 89 /*Verbose: */ 92 90 if(VerboseSolution()) _printf0_(" computing geodetic sea level rise\n"); 93 91 … … 154 152 155 153 /*recover N_esa = U_esa + RSLg:*/ 156 154 N_esa=U_esa->Duplicate(); U_esa->Copy(N_esa); N_esa->AXPY(RSLg,1); 157 155 158 156 /*transform these values into rates (as we only run this once each frequency turn:*/ 159 157 N_esa_rate=N_esa->Duplicate(); N_esa->Copy(N_esa_rate); N_esa_rate->Scale(1/(dt*frequency)); 160 158 U_esa_rate=U_esa->Duplicate(); U_esa->Copy(U_esa_rate); U_esa_rate->Scale(1/(dt*frequency)); … … 161 159 N_gia_rate=N_gia->Duplicate(); N_gia->Copy(N_gia_rate); N_gia_rate->Scale(1/(dt*frequency)); 162 160 U_gia_rate=U_gia->Duplicate(); U_gia->Copy(U_gia_rate); U_gia_rate->Scale(1/(dt*frequency)); 163 161 RSLg_rate=RSLg->Duplicate(); RSLg->Copy(RSLg_rate); RSLg_rate->Scale(1/(dt*frequency)); 164 162 165 163 /*get some results into elements:{{{*/ 166 164 InputUpdateFromVectorx(femmodel,U_esa_rate,SealevelUEsaRateEnum,VertexSIdEnum); 167 165 InputUpdateFromVectorx(femmodel,N_esa_rate,SealevelNEsaRateEnum,VertexSIdEnum); … … 181 179 } /*}}}*/ 182 180 } 183 181 184 185 182 if(iscoupler){ 186 183 /*transfer sea level back to ice caps:*/ 187 184 TransferSealevel(femmodel,SealevelNEsaRateEnum); … … 227 224 Vector<IssmDouble> *N_esa_rate= NULL; 228 225 Vector<IssmDouble> *U_gia_rate= NULL; 229 226 Vector<IssmDouble> *N_gia_rate= NULL; 230 227 231 228 /*parameters: */ 232 229 bool isslr=0; 233 230 int solution_type; … … 242 239 243 240 /*in case we are running SealevelriseSolutionEnum, then bypass transient settings:*/ 244 241 if(solution_type==SealevelriseSolutionEnum)isslr=1; 245 242 246 243 /*Should we be here?:*/ 247 244 if(!isslr)return; 248 245 … … 290 287 } 291 288 /*}}}*/ 292 289 Vector<IssmDouble>* sealevelrise_core_eustatic(FemModel* femmodel){ /*{{{*/ 293 290 294 291 /*Eustatic core of the SLR solution (terms that are constant with respect to sea-level)*/ 295 292 296 293 Vector<IssmDouble> *RSLgi = NULL; … … 317 314 318 315 /*Figure out size of g-set deflection vector and allocate solution vector: */ 319 316 gsize = femmodel->nodes->NumberOfDofs(configuration_type,GsetEnum); 320 317 321 318 /*Initialize:*/ 322 319 RSLgi = new Vector<IssmDouble>(gsize); 323 320 … … 330 327 /*RSLg is the sum of the pure eustatic component (term 3) and the contribution from the perturbation to the graviation potential due to the 331 328 * presence of ice (terms 1 and 4 in Eq.4 of Farrel and Clarke):*/ 332 329 RSLgi->Shift(-eustatic-RSLgi_oceanaverage); 333 330 334 331 /*save eustatic value for results: */ 335 332 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelRSLEustaticEnum,-eustatic)); 336 333 337 338 334 /*clean up and return:*/ 339 335 xDelete<IssmDouble>(latitude); 340 336 xDelete<IssmDouble>(longitude); … … 346 342 /*sealevelrise_core_noneustatic.cpp //this computes the contributions from Eq.4 of Farrel and Clarke, rhs terms 2 and 5. 347 343 non eustatic core of the SLR solution */ 348 344 349 350 345 Vector<IssmDouble> *RSLg = NULL; 351 346 Vector<IssmDouble> *RSLg_old = NULL; 352 347 … … 379 374 femmodel->parameters->FindParam(&eps_abs,SealevelriseAbstolEnum); 380 375 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 381 376 femmodel->parameters->FindParam(&loop,SealevelriseLoopIncrementEnum); 382 377 383 378 /*computational flag: */ 384 379 femmodel->parameters->FindParam(&rotation,SealevelriseRotationEnum); 385 380 … … 388 383 389 384 /*Figure out size of g-set deflection vector and allocate solution vector: */ 390 385 gsize = femmodel->nodes->NumberOfDofs(configuration_type,GsetEnum); 391 386 392 387 /*Initialize:*/ 393 388 RSLg = new Vector<IssmDouble>(gsize); 394 389 RSLg->Assemble(); … … 399 394 400 395 count=1; 401 396 converged=false; 402 397 403 398 /*Start loop: */ 404 399 for(;;){ 405 400 … … 412 407 413 408 /*call the non eustatic module: */ 414 409 femmodel->SealevelriseNonEustatic(RSLgo, RSLg_old, latitude, longitude, radius,verboseconvolution,loop); 415 410 416 411 /*assemble solution vector: */ 417 412 RSLgo->Assemble(); 418 413 … … 422 417 RSLgo_rot = new Vector<IssmDouble>(gsize); RSLgo_rot->Assemble(); 423 418 femmodel->SealevelriseRotationalFeedback(RSLgo_rot,RSLg_old,&Ixz,&Iyz,&Izz,latitude,longitude,radius); 424 419 RSLgo_rot->Assemble(); 425 420 426 421 /*save changes in inertia tensor as results: */ 427 422 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelInertiaTensorXZEnum,Ixz)); 428 423 femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelInertiaTensorYZEnum,Iyz)); … … 430 425 431 426 RSLgo->AXPY(RSLgo_rot,1); 432 427 } 433 428 434 429 /*we need to average RSLgo over the ocean: RHS term 5 in Eq.4 of Farrel and clarke. Only the elements can do that: */ 435 430 RSLgo_oceanaverage=femmodel->SealevelriseOceanAverage(RSLgo); 436 431 437 432 /*RSLg is the sum of the eustatic term, and the ocean terms: */ 438 433 RSLg_eustatic->Copy(RSLg); RSLg->AXPY(RSLgo,1); 439 434 RSLg->Shift(-RSLgo_oceanaverage); … … 454 449 converged=true; 455 450 break; 456 451 } 457 452 458 453 /*some minor verbosing adjustment:*/ 459 454 if(count>1)verboseconvolution=false; 460 455 461 456 } 462 457 if(VerboseConvergence()) _printf0_("\n total number of iterations: " << count-1 << "\n"); 463 458 … … 473 468 Vector<IssmDouble> *U_esa = NULL; 474 469 Vector<IssmDouble> *U_north_esa = NULL; 475 470 Vector<IssmDouble> *U_east_esa = NULL; 476 471 477 472 /*parameters: */ 478 473 int configuration_type; 479 474 int gsize; … … 506 501 /*retrieve geometric information: */ 507 502 VertexCoordinatesx(&latitude,&longitude,&radius,femmodel->vertices,spherical); 508 503 VertexCoordinatesx(&xx,&yy,&zz,femmodel->vertices); 509 504 510 505 /*call the elastic main modlule:*/ 511 506 femmodel->SealevelriseElastic(U_esa,U_north_esa,U_east_esa,RSLg,latitude,longitude,radius,xx,yy,zz,loop,horiz); 512 507 … … 531 526 /*variables:*/ 532 527 Vector<IssmDouble> *U_gia = NULL; 533 528 Vector<IssmDouble> *N_gia = NULL; 534 529 535 530 /*parameters:*/ 536 531 int frequency; 537 532 IssmDouble dt; … … 569 564 IssmDouble* forcing=NULL; 570 565 Vector<IssmDouble>* forcingglobal=NULL; 571 566 int* nvs=NULL; 572 567 573 568 /*transition vectors:*/ 574 569 IssmDouble** transitions=NULL; 575 570 int ntransitions; … … 576 571 int* transitions_m=NULL; 577 572 int* transitions_n=NULL; 578 573 int nv; 579 574 580 575 /*communicators:*/ 581 576 ISSM_MPI_Comm tocomm; 582 577 ISSM_MPI_Comm* fromcomms=NULL; … … 590 585 femmodel->parameters->FindParam(&earthid,EarthIdEnum); 591 586 femmodel->parameters->FindParam(&nummodels,NumModelsEnum); 592 587 my_rank=IssmComm::GetRank(); 593 588 594 589 /*retrieve the inter communicators that will be used to send data from each ice cap to the earth: */ 595 590 if(modelid==earthid){ 596 591 GenericParam<ISSM_MPI_Comm*>* parcoms = dynamic_cast<GenericParam<ISSM_MPI_Comm*>*>(femmodel->parameters->FindParamObject(IcecapToEarthCommEnum)); … … 619 614 forcings[i]=xNew<IssmDouble>(nvs[i]); 620 615 ISSM_MPI_Recv(forcings[i], nvs[i], ISSM_MPI_DOUBLE, 0,i, fromcomms[i], &status); 621 616 } 622 617 623 618 } 624 619 else{ 625 620 ISSM_MPI_Send(&nv, 1, ISSM_MPI_INT, 0, modelid, tocomm); … … 630 625 631 626 /*On the earth model, consolidate all the forcings into one, and update the elements dataset accordingly: {{{*/ 632 627 if(modelid==earthid){ 633 628 634 629 /*Out of all the delta thicknesses, build one delta thickness vector made of all the ice cap contributions. 635 630 *First, build the global delta thickness vector in the earth model: */ 636 631 nv=femmodel->vertices->NumberOfVertices(); … … 652 647 /*build index to plug values: */ 653 648 int* index=xNew<int>(M); for(int i=0;i<M;i++)index[i]=reCast<int>(transition[i])-1; //matlab indexing! 654 649 655 656 650 /*We are going to plug this vector into the earth model, at the right vertices corresponding to this particular 657 651 * ice cap: */ 658 652 forcingglobal->SetValues(M,index,forcingfromcap,ADD_VAL); … … 662 656 663 657 /*Assemble vector:*/ 664 658 forcingglobal->Assemble(); 665 659 666 660 /*Plug into elements:*/ 667 661 InputUpdateFromVectorx(femmodel,forcingglobal,forcingenum,VertexSIdEnum); 668 662 } … … 695 689 /*forcing being transferred from earth to ice caps: */ 696 690 IssmDouble* forcing=NULL; 697 691 IssmDouble* forcingglobal=NULL; 698 692 699 693 /*transition vectors:*/ 700 694 IssmDouble** transitions=NULL; 701 695 int ntransitions; … … 702 696 int* transitions_m=NULL; 703 697 int* transitions_n=NULL; 704 698 int nv; 705 699 706 700 /*communicators:*/ 707 701 ISSM_MPI_Comm fromcomm; 708 702 ISSM_MPI_Comm* tocomms=NULL; … … 717 711 femmodel->parameters->FindParam(&earthid,EarthIdEnum); 718 712 femmodel->parameters->FindParam(&nummodels,NumModelsEnum); 719 713 my_rank=IssmComm::GetRank(); 720 714 721 715 /*retrieve the inter communicators that will be used to send data from earth to ice caps:*/ 722 716 if(modelid==earthid){ 723 717 GenericParam<ISSM_MPI_Comm*>* parcoms = dynamic_cast<GenericParam<ISSM_MPI_Comm*>*>(femmodel->parameters->FindParamObject(IcecapToEarthCommEnum)); … … 732 726 //femmodel->parameters->FindParam((int*)(&fromcomm), IcecapToEarthCommEnum); 733 727 } 734 728 735 736 729 /*Retrieve sea-level on earth model: */ 737 730 if(modelid==earthid){ 738 731 nv=femmodel->vertices->NumberOfVertices(); … … 741 734 742 735 /*Send the forcing to the ice caps:{{{*/ 743 736 if(my_rank==0){ 744 737 745 738 if(modelid==earthid){ 746 739 747 740 /*Retrieve transition vectors, used to figure out global forcing contribution to each ice cap's own elements: */ 748 741 femmodel->parameters->FindParam(&transitions,&ntransitions,&transitions_m,&transitions_n,SealevelriseTransitionsEnum); 749 742 750 743 if(ntransitions!=earthid)_error_("TransferSeaLevel error message: number of transition vectors is not equal to the number of icecaps!"); 751 744 752 745 for(int i=0;i<earthid;i++){ … … 803 796 Vector<IssmDouble> *deltathickness = NULL; 804 797 Vector<IssmDouble> *cumdeltathickness = NULL; 805 798 int nv; 806 799 807 800 if(VerboseSolution()) _printf0_(" computing earth mass transport\n"); 808 801 809 802 /*This mass transport module for the Earth is because we might have thickness variations as spcs … … 839 832 840 833 } /*}}}*/ 841 834 void slrconvergence(bool* pconverged, Vector<IssmDouble>* RSLg,Vector<IssmDouble>* RSLg_old,IssmDouble eps_rel,IssmDouble eps_abs){ /*{{{*/ 842 835 843 836 bool converged=true; 844 837 IssmDouble ndS,nS; 845 838 Vector<IssmDouble> *dRSLg = NULL; … … 847 840 //compute norm(du) and norm(u) if requested 848 841 dRSLg=RSLg_old->Duplicate(); RSLg_old->Copy(dRSLg); dRSLg->AYPX(RSLg,-1.0); 849 842 ndS=dRSLg->Norm(NORM_TWO); 850 843 851 844 if (xIsNan<IssmDouble>(ndS)) _error_("convergence criterion is NaN!"); 852 845 853 846 if(!xIsNan<IssmDouble>(eps_rel)){ 854 847 nS=RSLg_old->Norm(NORM_TWO); 855 848 if (xIsNan<IssmDouble>(nS)) _error_("convergence criterion is NaN!"); 856 849 } 857 850 858 859 851 //clean up 860 852 delete dRSLg; 861 853 -
../trunk-jpl/src/c/cores/stressbalance_core.cpp
21 21 int numoutputs = 0; 22 22 char **requested_outputs = NULL; 23 23 Analysis *analysis = NULL; 24 25 24 26 25 /* recover parameters:*/ 27 26 femmodel->parameters->FindParam(&domaintype,DomainTypeEnum); … … 35 34 femmodel->parameters->FindParam(&numoutputs,StressbalanceNumRequestedOutputsEnum); 36 35 femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum); 37 36 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,StressbalanceRequestedOutputsEnum); 38 37 39 38 if(VerboseSolution()) _printf0_(" computing new velocity\n"); 40 39 41 40 /*Compute slopes if necessary */ … … 78 77 delete analysis; 79 78 } 80 79 81 82 80 if(save_results){ 83 81 if(VerboseSolution()) _printf0_(" saving results\n"); 84 82 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 85 83 } 86 84 87 85 if(solution_type==StressbalanceSolutionEnum && !control_analysis)femmodel->RequestedDependentsx(); 88 86 89 87 /*Free ressources:*/ -
../trunk-jpl/src/c/cores/adgradient_core.cpp
38 38 /*intermediary: */ 39 39 IssmPDouble *aWeightVector=NULL; 40 40 IssmPDouble *weightVectorTimesJac=NULL; 41 41 42 42 /*output: */ 43 43 IssmPDouble *totalgradient=NULL; 44 44 … … 52 52 53 53 /*First, stop tracing: */ 54 54 trace_off(); 55 55 56 56 if(VerboseAutodiff()){ /*{{{*/ 57 57 size_t tape_stats[15]; 58 58 tapestats(my_rank,tape_stats); //reading of tape statistics … … 95 95 } 96 96 delete [] sstats; 97 97 } /*}}}*/ 98 98 99 99 /*retrieve parameters: */ 100 100 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 101 101 femmodel->parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum); 102 102 103 103 /*if no dependents, no point in running a driver: */ 104 104 if(!(num_dependents*num_independents)) return; 105 105 … … 108 108 if (my_rank!=0){ 109 109 num_dependents=0; num_independents=0; 110 110 } 111 111 112 112 /*retrieve state variable: */ 113 113 femmodel->parameters->FindParam(&axp,&dummy,AutodiffXpEnum); 114 114 115 115 /* driver argument */ 116 116 xp=xNew<double>(num_independents); 117 117 for(i=0;i<num_independents;i++){ … … 130 130 131 131 /*Initialize outputs: */ 132 132 totalgradient=xNewZeroInit<IssmPDouble>(num_independents); 133 133 134 134 for(aDepIndex=0;aDepIndex<num_dependents_old;aDepIndex++){ 135 135 136 136 /*initialize direction index in the weights vector: */ 137 137 aWeightVector=xNewZeroInit<IssmPDouble>(num_dependents); 138 138 if (my_rank==0) aWeightVector[aDepIndex]=1.0; 139 139 140 140 /*initialize output gradient: */ 141 141 weightVectorTimesJac=xNew<IssmPDouble>(num_independents); 142 142 … … 161 161 xDelete(weightVectorTimesJac); 162 162 xDelete(aWeightVector); 163 163 } 164 164 165 165 /*add totalgradient to results*/ 166 166 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,totalgradient,num_independents,1,1,0.0)); 167 167 168 168 if(VerboseAutodiff())_printf0_(" end ad core\n"); 169 169 170 170 /* delete the allocated space for the parameters and free ressources:{{{*/ 171 171 xDelete(anEDF_for_solverx_p->dp_x); 172 172 xDelete(anEDF_for_solverx_p->dp_X); -
../trunk-jpl/src/c/cores/controladm1qn3_core.cpp
125 125 ISSM_MPI_Bcast(aX,intn,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 126 126 SetControlInputsFromVectorx(femmodel,aX); 127 127 xDelete<IssmDouble>(aX); 128 128 129 129 /*Compute solution (forward)*/ 130 130 void (*solutioncore)(FemModel*)=NULL; 131 131 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); … … 391 391 /*Optimization criterions*/ 392 392 long niter = long(maxsteps); /*Maximum number of iterations*/ 393 393 long nsim = long(maxiter);/*Maximum number of function calls*/ 394 394 395 395 /*Get initial guess*/ 396 396 Vector<double> *Xpetsc = NULL; 397 397 … … 400 400 Xpetsc->GetSize(&intn); 401 401 delete Xpetsc; 402 402 //_assert_(intn==numberofvertices*num_controls); 403 403 404 404 /*Get problem dimension and initialize gradient and initial guess*/ 405 405 long n = long(intn); 406 406 G = xNew<double>(n); … … 414 414 } 415 415 N_add+=N[c]; 416 416 } 417 417 418 418 /*Allocate m1qn3 working arrays (see documentation)*/ 419 419 long m = 100; 420 420 long ndz = 4*n+m*(2*n+1); … … 470 470 } 471 471 N_add +=N[c]; 472 472 } 473 473 474 474 /*Set X as our new control*/ 475 475 IssmDouble* aX=xNew<IssmDouble>(intn); 476 476 IssmDouble* aG=xNew<IssmDouble>(intn); … … 482 482 483 483 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,aG); 484 484 SetControlInputsFromVectorx(femmodel,aX); 485 485 486 486 xDelete(aX); 487 487 488 489 488 if (solution_type == TransientSolutionEnum){ 490 489 int step = 1; 491 490 femmodel->parameters->SetParam(step,StepEnum); … … 505 504 /*Add to results*/ 506 505 femmodel->results->AddObject(G_output); 507 506 femmodel->results->AddObject(X_output); 508 507 509 508 offset += N[i]*numberofvertices; 510 509 } 511 510 } -
../trunk-jpl/src/c/cores/love_core.cpp
27 27 28 28 /*parameters: */ 29 29 bool save_results; 30 30 31 31 if(VerboseSolution()) _printf0_(" computing LOVE numbers\n"); 32 32 33 33 /*Recover some parameters: */ 34 34 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 35 35 36 36 /*recover love number parameters: */ 37 37 femmodel->parameters->FindParam(&nfreq,LoveNfreqEnum); 38 38 femmodel->parameters->FindParam(&frequencies,&dummy,LoveFrequenciesEnum); _assert_(nfreq==dummy); … … 44 44 femmodel->parameters->FindParam(&allow_layer_deletion,LoveAllowLayerDeletionEnum); 45 45 femmodel->parameters->FindParam(&love_kernels,LoveKernelsEnum); 46 46 femmodel->parameters->FindParam(&forcing_type,LoveForcingTypeEnum); 47 47 48 48 /*recover materials parameters: there is only one Matlitho, chase it down the hard way:*/ 49 49 Matlitho* matlitho=NULL; 50 50 for (int i=femmodel->materials->Size()-1;i>=0;i--){ -
../trunk-jpl/src/c/cores/damage_core.cpp
18 18 int numoutputs = 0; 19 19 char **requested_outputs = NULL; 20 20 21 22 21 //first recover parameters common to all solutions 23 22 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 24 23 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); -
../trunk-jpl/src/c/cores/smb_core.cpp
28 28 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 29 29 femmodel->parameters->FindParam(&numoutputs,SmbNumRequestedOutputsEnum); 30 30 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,SmbRequestedOutputsEnum); 31 31 32 32 if(VerboseSolution()) _printf0_(" computing smb \n"); 33 33 34 34 analysis = new SmbAnalysis(); 35 35 analysis->Core(femmodel); 36 36 delete analysis; -
../trunk-jpl/src/c/cores/ad_core.cpp
45 45 46 46 /*First, stop tracing: */ 47 47 trace_off(); 48 48 49 49 /*Print tape statistics so that user can kill this run if something is off already:*/ 50 50 if(VerboseAutodiff()){ /*{{{*/ 51 51 tapestats(my_rank,tape_stats); //reading of tape statistics … … 92 92 /*retrieve parameters: */ 93 93 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 94 94 femmodel->parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum); 95 95 96 96 /*if no dependents, no point in running a driver: */ 97 97 if(!(num_dependents*num_independents)) return; 98 98 … … 100 100 if (my_rank!=0){ 101 101 num_dependents=0; num_independents=0; 102 102 } 103 103 104 104 /*retrieve state variable: */ 105 105 femmodel->parameters->FindParam(&axp,&dummy,AutodiffXpEnum); 106 106 … … 116 116 /*Branch according to AD driver: */ 117 117 femmodel->parameters->FindParam(&driver,AutodiffDriverEnum); 118 118 119 120 119 if (strcmp(driver,"fos_forward")==0){ /*{{{*/ 121 120 122 121 int anIndepIndex; … … 140 139 anEDF_for_solverx_p->fos_forward=EDF_fos_forward_for_solverx; 141 140 #endif 142 141 143 144 142 /*call driver: */ 145 143 fos_forward(my_rank,num_dependents,num_independents, 0, xp, tangentDir, theOutput, jacTimesTangentDir ); 146 144 … … 184 182 #endif 185 183 // anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx; 186 184 187 188 185 /*seed matrix: */ 189 186 seed=xNewZeroInit<double>(num_independents,tangentDirNum); 190 187 … … 243 240 anEDF_for_solverx_p->fos_reverse_iArr=fos_reverse_mumpsSolveEDF; 244 241 #endif 245 242 246 247 243 /*call driver: */ 248 244 fos_reverse(my_rank,num_dependents,num_independents, aWeightVector, weightVectorTimesJac ); 249 245 … … 284 280 anEDF_for_solverx_p->fov_reverse=EDF_fov_reverse_for_solverx; 285 281 #endif 286 282 287 288 283 /*seed matrix: */ 289 284 weights=xNewZeroInit<double>(weightNum,num_dependents); 290 285 … … 316 311 } /*}}}*/ 317 312 else _error_("driver: " << driver << " not yet supported!"); 318 313 319 320 314 if(VerboseAutodiff())_printf0_(" end AD core\n"); 321 315 322 316 /*Free resources: */ -
../trunk-jpl/src/c/classes/Materials/Matestar.cpp
108 108 void Matestar::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 109 109 110 110 if(marshall_direction==MARSHALLING_BACKWARD)helement=new Hook(); 111 111 112 112 MARSHALLING_ENUM(MatestarEnum); 113 113 MARSHALLING(mid); 114 114 this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); -
../trunk-jpl/src/c/classes/Materials/Matlitho.cpp
36 36 37 37 this->radius=xNew<IssmDouble>(this->numlayers+1); 38 38 xMemCpy<IssmDouble>(this->radius, iomodel->Data("md.materials.radius"),this->numlayers+1); 39 39 40 40 this->viscosity=xNew<IssmDouble>(this->numlayers); 41 41 xMemCpy<IssmDouble>(this->viscosity, iomodel->Data("md.materials.viscosity"),this->numlayers); 42 42 43 43 this->lame_lambda=xNew<IssmDouble>(this->numlayers); 44 44 xMemCpy<IssmDouble>(this->lame_lambda, iomodel->Data("md.materials.lame_lambda"),this->numlayers); 45 45 46 46 this->lame_mu=xNew<IssmDouble>(this->numlayers); 47 47 xMemCpy<IssmDouble>(this->lame_mu, iomodel->Data("md.materials.lame_mu"),this->numlayers); 48 48 … … 60 60 61 61 this->issolid=xNew<IssmDouble>(this->numlayers); 62 62 xMemCpy<IssmDouble>(this->issolid, iomodel->Data("md.materials.issolid"),this->numlayers); 63 63 64 64 /*isburgersd= xNew<IssmDouble>(this->numlayers); 65 65 this->isburgers=xNew<bool>(this->numlayers); 66 66 xMemCpy<IssmDouble>(isburgersd, iomodel->Data("md.materials.isburgers"),this->numlayers); 67 67 for (int i=0;i<this->numlayers;i++)this->isburgers[i]=reCast<bool,IssmDouble>(isburgersd[i]); 68 68 69 69 issolidd= xNew<IssmDouble>(this->numlayers); 70 70 this->issolid=xNew<bool>(this->numlayers); 71 71 xMemCpy<IssmDouble>(issolidd, iomodel->Data("md.materials.issolid"),this->numlayers); 72 72 for (int i=0;i<this->numlayers;i++)this->issolid[i]=reCast<bool,IssmDouble>(issolidd[i]);*/ 73 73 74 74 /*free ressources: */ 75 75 xDelete<IssmDouble>(isburgersd); 76 76 xDelete<IssmDouble>(issolidd); … … 77 77 } 78 78 /*}}}*/ 79 79 Matlitho::~Matlitho(){/*{{{*/ 80 80 81 81 xDelete<IssmDouble>(radius); 82 82 xDelete<IssmDouble>(viscosity); 83 83 xDelete<IssmDouble>(lame_lambda); -
../trunk-jpl/src/c/classes/Materials/Matice.cpp
134 134 _printf_(" note: helement not printed to avoid recursion.\n"); 135 135 //if(helement) helement->DeepEcho(); 136 136 //else _printf_(" helement = NULL\n"); 137 137 138 138 _printf_(" element:\n"); 139 139 _printf_(" note: element not printed to avoid recursion.\n"); 140 140 //if(element) element->DeepEcho(); … … 142 142 } 143 143 /*}}}*/ 144 144 void Matice::Echo(void){/*{{{*/ 145 145 146 146 _printf_("Matice:\n"); 147 147 _printf_(" mid: " << mid << "\n"); 148 148 _printf_(" isdamaged: " << isdamaged << "\n"); 149 149 _printf_(" isenhanced: " << isenhanced << "\n"); 150 150 151 151 /*helement and element Echo were commented to avoid recursion.*/ 152 152 /*Example: element->Echo calls matice->Echo which calls element->Echo etc*/ 153 153 _printf_(" helement:\n"); … … 154 154 _printf_(" note: helement not printed to avoid recursion.\n"); 155 155 //if(helement) helement->Echo(); 156 156 //else _printf_(" helement = NULL\n"); 157 157 158 158 _printf_(" element:\n"); 159 159 _printf_(" note: element not printed to avoid recursion.\n"); 160 160 //if(element) element->Echo(); … … 166 166 void Matice::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 167 167 168 168 if(marshall_direction==MARSHALLING_BACKWARD)helement=new Hook(); 169 169 170 170 MARSHALLING_ENUM(MaticeEnum); 171 171 MARSHALLING(mid); 172 172 MARSHALLING(isdamaged); … … 540 540 /*input strain rate: */ 541 541 IssmDouble exx,eyy,exy,exz,eyz; 542 542 543 544 543 if((epsilon[0]==0) && (epsilon[1]==0) && (epsilon[2]==0) && 545 544 (epsilon[3]==0) && (epsilon[4]==0)){ 546 545 mu_prime=0.5*pow(10.,14); -
../trunk-jpl/src/c/classes/Numberedcostfunction.cpp
8 8 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 9 9 #endif 10 10 11 12 11 /*Headers:*/ 13 12 //#include "./Definition.h" 14 13 //#include "../datastructures/datastructures.h" … … 29 28 #include "../modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.h" 30 29 31 30 /*}}}*/ 32 31 33 32 /*Numberedcostfunction constructors, destructors :*/ 34 33 Numberedcostfunction::Numberedcostfunction(){/*{{{*/ 35 34 … … 109 108 } 110 109 /*}}}*/ 111 110 IssmDouble Numberedcostfunction::Response(FemModel* femmodel){/*{{{*/ 112 111 113 112 _assert_(number_cost_functions>0 && number_cost_functions<1e3); 114 113 115 114 /*output:*/ … … 156 155 return value_sum; 157 156 } 158 157 /*}}}*/ 159 -
../trunk-jpl/src/c/classes/Params/BoolParam.cpp
62 62 63 63 } 64 64 /*}}}*/ 65 -
../trunk-jpl/src/c/classes/Params/StringParam.cpp
54 54 int size = 0; 55 55 56 56 if(marshall_direction==MARSHALLING_FORWARD || marshall_direction == MARSHALLING_SIZE)size=strlen(value)+1; 57 57 58 58 MARSHALLING_ENUM(StringParamEnum); 59 59 MARSHALLING(enum_type); 60 60 MARSHALLING(size); -
../trunk-jpl/src/c/classes/Params/DoubleVecParam.cpp
115 115 116 116 /*DoubleVecParam specific routines:*/ 117 117 void DoubleVecParam::GetParameterValueByPointer(IssmDouble** pIssmDoublearray,int* pM){/*{{{*/ 118 118 119 119 /*Assign output pointers:*/ 120 120 if(pM) *pM=M; 121 121 *pIssmDoublearray=values; -
../trunk-jpl/src/c/classes/Params/DoubleMatParam.cpp
115 115 116 116 /*DoubleMatParam specific routines:*/ 117 117 void DoubleMatParam::GetParameterValueByPointer(IssmDouble** pIssmDoublearray,int* pM,int* pN){/*{{{*/ 118 118 119 119 /*Assign output pointers:*/ 120 120 if(pM) *pM=M; 121 121 if(pN) *pN=N; -
../trunk-jpl/src/c/classes/Params/DataSetParam.cpp
54 54 void DataSetParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 55 55 56 56 if(marshall_direction==MARSHALLING_BACKWARD)value=new DataSet(); 57 57 58 58 MARSHALLING_ENUM(DataSetParamEnum); 59 59 MARSHALLING(enum_type); 60 60 value->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); -
../trunk-jpl/src/c/classes/Params/IntParam.cpp
63 63 64 64 } 65 65 /*}}}*/ 66 -
../trunk-jpl/src/c/classes/Params/StringArrayParam.cpp
82 82 } 83 83 84 84 MARSHALLING_ENUM(StringArrayParamEnum); 85 85 86 86 MARSHALLING(enum_type); 87 87 MARSHALLING(numstrings); 88 88 -
../trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.cpp
232 232 233 233 } 234 234 /*}}}*/ 235 -
../trunk-jpl/src/c/classes/AmrBamg.cpp
33 33 this->deviatoricerror_threshold = -1; 34 34 this->deviatoricerror_groupthreshold = -1; 35 35 this->deviatoricerror_maximum = -1; 36 36 37 37 /*Geometry and mesh as NULL*/ 38 38 this->geometry = NULL; 39 39 this->fathermesh = NULL; … … 136 136 this->options->hmaxVertices = NULL; 137 137 this->options->hmaxVerticesSize[0] = 0; 138 138 this->options->hmaxVerticesSize[1] = 0; 139 139 140 140 /*verify if the metric will be reseted or not*/ 141 141 if(this->keepmetric==0){ 142 142 if(this->options->metric) xDelete<IssmDouble>(this->options->metric); … … 154 154 int *datalist = xNew<int>(2); 155 155 IssmDouble *xylist= xNew<IssmDouble>(nbv*2); 156 156 int* elementslist = xNew<int>(nbt*3); 157 157 158 158 datalist[0] = nbv; 159 159 datalist[1] = nbt; 160 160 161 161 for(int i=0;i<nbv;i++){ 162 162 xylist[2*i] = meshout->Vertices[i*3+0]; 163 163 xylist[2*i+1] = meshout->Vertices[i*3+1]; 164 164 } 165 165 166 166 for(int i=0;i<nbt;i++){ 167 167 elementslist[3*i+0] = reCast<int>(meshout->Triangles[4*i+0]); 168 168 elementslist[3*i+1] = reCast<int>(meshout->Triangles[4*i+1]); … … 173 173 *pdatalist = datalist; 174 174 *pxylist = xylist; 175 175 *pelementslist = elementslist; 176 176 177 177 /*Cleanup and return*/ 178 178 delete geomout; 179 179 }/*}}}*/ … … 180 180 void AmrBamg::SetBamgOpts(IssmDouble hmin_in,IssmDouble hmax_in,IssmDouble err_in,IssmDouble gradation_in){/*{{{*/ 181 181 182 182 if(!this->options) _error_("AmrBamg->options is NULL!"); 183 183 184 184 this->options->hmin = hmin_in; 185 185 this->options->hmax = hmax_in; 186 186 this->options->err[0] = err_in; -
../trunk-jpl/src/c/classes/kriging/Observations.cpp
740 740 /*Assign output pointer*/ 741 741 xDelete<IssmPDouble>(counter); 742 742 }/*}}}*/ 743 -
../trunk-jpl/src/c/classes/Cfsurfacelogvel.cpp
22 22 #include "../classes/Inputs/Input.h" 23 23 #include "../classes/gauss/Gauss.h" 24 24 /*}}}*/ 25 25 26 26 /*Cfsurfacelogvel constructors, destructors :*/ 27 27 Cfsurfacelogvel::Cfsurfacelogvel(){/*{{{*/ 28 28 … … 39 39 Cfsurfacelogvel::Cfsurfacelogvel(char* in_name, int in_definitionenum, IssmDouble in_datatime, bool in_timepassedflag){/*{{{*/ 40 40 41 41 this->definitionenum=in_definitionenum; 42 42 43 43 this->name = xNew<char>(strlen(in_name)+1); 44 44 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 45 45 46 46 this->datatime=in_datatime; 47 47 this->timepassedflag=in_timepassedflag; 48 48 49 49 this->misfit=0; 50 50 this->lock=0; 51 51 } … … 99 99 } 100 100 /*}}}*/ 101 101 IssmDouble Cfsurfacelogvel::Response(FemModel* femmodel){/*{{{*/ 102 102 103 103 /*diverse: */ 104 104 IssmDouble time; 105 105 106 106 /*recover time parameters: */ 107 107 femmodel->parameters->FindParam(&time,TimeEnum); 108 108 if(time < last_time) timepassedflag = false; … … 111 111 int i; 112 112 IssmDouble J=0.; 113 113 IssmDouble J_sum=0.; 114 114 115 115 if(datatime<=time && !timepassedflag){ 116 116 for(i=0;i<femmodel->elements->Size();i++){ 117 117 Element* element=(Element*)femmodel->elements->GetObjectByOffset(i); … … 121 121 ISSM_MPI_Allreduce ( (void*)&J,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 122 122 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 123 123 J=J_sum; 124 124 125 125 timepassedflag = true; 126 126 return J; 127 127 } … … 138 138 IssmDouble misfit,Jdet; 139 139 IssmDouble vx,vy,vxobs,vyobs,weight; 140 140 IssmDouble* xyz_list = NULL; 141 141 142 142 /*Get basal element*/ 143 143 if(!element->IsOnSurface()) return 0.; 144 144 … … 159 159 160 160 /* Get node coordinates*/ 161 161 topelement->GetVerticesCoordinates(&xyz_list); 162 162 163 163 /*Get model values*/ 164 164 Input* vx_input =topelement->GetInput(VxEnum); _assert_(vx_input); 165 165 Input* vy_input =NULL; … … 174 174 if(tempinput->ObjectEnum()!=DatasetInputEnum) _error_("don't know what to do"); 175 175 datasetinput = (DatasetInput*)tempinput; 176 176 177 178 177 /* Start looping on the number of gaussian points: */ 179 178 Gauss* gauss=topelement->NewGauss(2); 180 179 for(int ig=gauss->begin();ig<gauss->end();ig++){ … … 221 220 delete gauss; 222 221 return Jelem; 223 222 }/*}}}*/ 224 -
../trunk-jpl/src/c/classes/Cfdragcoeffabsgrad.cpp
22 22 #include "../classes/Inputs/Input.h" 23 23 #include "../classes/gauss/Gauss.h" 24 24 /*}}}*/ 25 25 26 26 /*Cfdragcoeffabsgrad constructors, destructors :*/ 27 27 Cfdragcoeffabsgrad::Cfdragcoeffabsgrad(){/*{{{*/ 28 28 … … 39 39 Cfdragcoeffabsgrad::Cfdragcoeffabsgrad(char* in_name, int in_definitionenum, int in_weights_enum, bool in_timepassedflag){/*{{{*/ 40 40 41 41 this->definitionenum=in_definitionenum; 42 42 43 43 this->name = xNew<char>(strlen(in_name)+1); 44 44 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 45 45 46 46 this->weights_enum=in_weights_enum; 47 47 this->timepassedflag=in_timepassedflag; 48 48 49 49 this->misfit=0; 50 50 this->lock=0; 51 51 } … … 101 101 IssmDouble Cfdragcoeffabsgrad::Response(FemModel* femmodel){/*{{{*/ 102 102 /*diverse: */ 103 103 IssmDouble time; 104 104 105 105 /*recover time parameters: */ 106 106 int i; 107 107 IssmDouble J=0.; … … 115 115 ISSM_MPI_Allreduce ( (void*)&J,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 116 116 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 117 117 J=J_sum; 118 118 119 119 timepassedflag = true; 120 120 return J; 121 121 } … … 182 182 delete gauss; 183 183 return Jelem; 184 184 }/*}}}*/ 185 -
../trunk-jpl/src/c/classes/Loads/Neumannflux.cpp
30 30 /*}}}*/ 31 31 Neumannflux::Neumannflux(int neumannflux_id,int i,IoModel* iomodel,int* segments,int in_analysis_type){/*{{{*/ 32 32 33 34 33 /*Some sanity checks*/ 35 34 _assert_(segments); 36 35 -
../trunk-jpl/src/c/classes/Loads/Moulin.cpp
177 177 this->parameters->FindParam(&analysis_type,AnalysisTypeEnum); 178 178 179 179 switch(analysis_type){ 180 180 181 181 case HydrologyShaktiAnalysisEnum: 182 182 pe = this->CreatePVectorHydrologyShakti(); 183 183 break; … … 394 394 if(!this->node->IsActive()) return NULL; 395 395 IssmDouble moulin_load,dt; 396 396 ElementVector* pe=new ElementVector(&node,1,this->parameters); 397 397 398 398 this->element->GetInputValue(&moulin_load,node,HydrologydcBasalMoulinInputEnum); 399 399 parameters->FindParam(&dt,TimesteppingTimeStepEnum); 400 400 401 401 pe->values[0]=moulin_load*dt; 402 402 /*Clean up and return*/ 403 403 return pe; -
../trunk-jpl/src/c/classes/Cfsurfacesquare.cpp
22 22 #include "../classes/Inputs/Input.h" 23 23 #include "../classes/gauss/Gauss.h" 24 24 /*}}}*/ 25 25 26 26 /*Cfsurfacesquare constructors, destructors :*/ 27 27 Cfsurfacesquare::Cfsurfacesquare(){/*{{{*/ 28 28 … … 42 42 Cfsurfacesquare::Cfsurfacesquare(char* in_name, int in_definitionenum, int in_model_enum, int in_observation_enum, int in_weights_enum, IssmDouble in_datatime, bool in_timepassedflag){/*{{{*/ 43 43 44 44 this->definitionenum=in_definitionenum; 45 45 46 46 this->name = xNew<char>(strlen(in_name)+1); 47 47 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 48 48 … … 51 51 this->weights_enum=in_weights_enum; 52 52 this->datatime=in_datatime; 53 53 this->timepassedflag=in_timepassedflag; 54 54 55 55 this->misfit=0; 56 56 this->lock=0; 57 57 } … … 110 110 IssmDouble Cfsurfacesquare::Response(FemModel* femmodel){/*{{{*/ 111 111 /*diverse: */ 112 112 IssmDouble time; 113 113 114 114 /*recover time parameters: */ 115 115 femmodel->parameters->FindParam(&time,TimeEnum); 116 116 if(time < last_time) timepassedflag = false; … … 129 129 ISSM_MPI_Allreduce ( (void*)&J,(void*)&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 130 130 ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 131 131 J=J_sum; 132 132 133 133 timepassedflag = true; 134 134 return J; 135 135 } … … 171 171 172 172 /*Get input if it already exists*/ 173 173 Input* tempinput = topelement->GetInput(definitionenum); 174 174 175 175 /*Cast it to a Datasetinput*/ 176 176 if(tempinput->ObjectEnum()!=DatasetInputEnum) _error_("don't know what to do"); 177 177 datasetinput = (DatasetInput*)tempinput; … … 213 213 delete gauss; 214 214 return Jelem; 215 215 }/*}}}*/ 216 -
../trunk-jpl/src/c/classes/Profiler.cpp
99 99 _assert_(tag<MAXIMUMSIZE); 100 100 if(this->running[tag]) _error_("Tag "<<tag<<" has not been stopped"); 101 101 102 103 102 #ifdef _HAVE_MPI_ 104 103 return this->time[tag]; 105 104 #else … … 143 142 _assert_(tag<MAXIMUMSIZE); 144 143 if(this->running[tag]) _error_("Tag "<<tag<<" is already running"); 145 144 146 147 145 /*If mpisync requested, make sure all the cpus are at the same point in the execution: */ 148 146 if(!dontmpisync){ 149 147 ISSM_MPI_Barrier(IssmComm::GetComm()); … … 183 181 _assert_(tag<MAXIMUMSIZE); 184 182 if(!this->running[tag]) _error_("Tag "<<tag<<" is not running"); 185 183 186 187 184 /*If mpisync requested, make sure all the cpus are at the same point in the execution: */ 188 185 if(!dontmpisync){ 189 186 ISSM_MPI_Barrier(IssmComm::GetComm()); -
../trunk-jpl/src/c/classes/AdaptiveMeshRefinement.cpp
100 100 101 101 /*Mesh refinement methods*/ 102 102 void AdaptiveMeshRefinement::ExecuteRefinement(double* gl_distance,double* if_distance,double* deviatoricerror,double* thicknesserror,int** pdatalist,double** pxylist,int** pelementslist){/*{{{*/ 103 103 104 104 /*IMPORTANT! pelementslist are in Matlab indexing*/ 105 105 /*NEOPZ works only in C indexing*/ 106 106 if(!this->fathermesh || !this->previousmesh) _error_("Impossible to execute refinement: fathermesh or previousmesh is NULL!\n"); … … 117 117 118 118 /*Intermediaries*/ 119 119 bool verbose=VerboseSolution(); 120 120 121 121 /*Execute refinement*/ 122 122 this->RefineMeshOneLevel(verbose,gl_distance,if_distance,deviatoricerror,thicknesserror); 123 123 124 124 /*Get new geometric mesh in ISSM data structure*/ 125 125 this->GetMesh(this->previousmesh,pdatalist,pxylist,pelementslist); 126 126 … … 129 129 } 130 130 /*}}}*/ 131 131 void AdaptiveMeshRefinement::RefineMeshOneLevel(bool &verbose,double* gl_distance,double* if_distance,double* deviatoricerror,double* thicknesserror){/*{{{*/ 132 132 133 133 /*Intermediaries*/ 134 134 int nelem =-1; 135 135 int side2D = 6; … … 203 203 if(criteria) index.push_back(gmesh->Element(this->specialelementsindex[i])->FatherIndex()); 204 204 } 205 205 /*}}}*/ 206 206 207 207 /*Now, detele the special elements{{{*/ 208 208 if(this->refinement_type==1) this->DeleteSpecialElements(verbose,gmesh); 209 209 else this->specialelementsindex.clear(); … … 215 215 gmesh=this->fathermesh; 216 216 } 217 217 /*}}}*/ 218 218 219 219 /*Unrefinement process: loop over level of refinements{{{*/ 220 220 if(verbose) _printf_("\tunrefinement process...\n"); 221 221 if(verbose) _printf_("\ttotal: "); 222 222 count=0; 223 223 224 224 nelem=gmesh->NElements();//must keep here 225 225 for(int i=0;i<nelem;i++){ 226 226 if(!gmesh->Element(i)) continue; … … 265 265 /*Adjust the connectivities before continue*/ 266 266 gmesh->BuildConnectivity(); 267 267 /*}}}*/ 268 268 269 269 /*Refinement process: loop over level of refinements{{{*/ 270 270 if(verbose) _printf_("\trefinement process (level max = "<<this->level_max<<")\n"); 271 271 if(verbose) _printf_("\ttotal: "); … … 319 319 * 2 : uniform refinment 320 320 * */ 321 321 if(!geoel) _error_("geoel is NULL!\n"); 322 322 323 323 /*Output*/ 324 324 int type=0; 325 325 int count=0; 326 326 327 327 /*Intermediaries*/ 328 328 TPZVec<TPZGeoEl*> sons; 329 329 330 330 /*Loop over neighboors (sides 3, 4 and 5)*/ 331 331 for(int j=3;j<6;j++){ 332 332 sons.clear(); … … 334 334 if(sons.size()) count++; //if neighbour was refined 335 335 if(sons.size()>4) count++; //if neighbour's level is > element level+1 336 336 } 337 337 338 338 /*Verify and return*/ 339 339 if(count>1) type=2; 340 340 else type=count; 341 341 342 342 return type; 343 343 } 344 344 /*}}}*/ … … 390 390 } 391 391 /*}}}*/ 392 392 void AdaptiveMeshRefinement::RefineMeshToAvoidHangingNodes(bool &verbose,TPZGeoMesh* gmesh){/*{{{*/ 393 393 394 394 /*Now, insert special elements to avoid hanging nodes*/ 395 395 if(verbose) _printf_("\trefining to avoid hanging nodes (total: "); 396 396 397 397 /*Intermediaries*/ 398 398 int nelem=-1; 399 399 int count= 1; 400 400 401 401 while(count>0){ 402 402 nelem=gmesh->NElements();//must keep here 403 403 count=0; … … 467 467 long* vertex_index2sid = xNew<long>(ntotalvertices); 468 468 this->index2sid.clear(); this->index2sid.resize(gmesh->NElements()); 469 469 this->sid2index.clear(); 470 470 471 471 /*Fill in the vertex_index2sid vector with non usual index value*/ 472 472 for(int i=0;i<gmesh->NNodes();i++) vertex_index2sid[i]=-1; 473 473 474 474 /*Fill in the this->index2sid vector with non usual index value*/ 475 475 for(int i=0;i<gmesh->NElements();i++) this->index2sid[i]=-1; 476 476 477 477 /*Get elements without sons and fill in the vertex_index2sid with used vertices (indexes) */ 478 478 sid=0; 479 479 for(int i=0;i<gmesh->NElements();i++){//over gmesh elements index … … 510 510 newmeshXY[2*sid] = coords[0]; // X 511 511 newmeshXY[2*sid+1] = coords[1]; // Y 512 512 } 513 513 514 514 for(int i=0;i<this->sid2index.size();i++){//over the sid (fill the ISSM elements) 515 515 for(int j=0;j<this->GetNumberOfNodes();j++) { 516 516 geoel = gmesh->ElementVec()[this->sid2index[i]]; … … 532 532 xc=newmeshXY[2*c]; yc=newmeshXY[2*c+1]; 533 533 534 534 detJ=(xb-xa)*(yc-ya)-(xc-xa)*(yb-ya); 535 535 536 536 /*verify and swap, if necessary*/ 537 537 if(detJ<0) { 538 538 newelements[i*this->GetNumberOfNodes()+0]=b+1;//a->b … … 544 544 *pdata = newdata; 545 545 *pxy = newmeshXY; 546 546 *pelements = newelements; 547 547 548 548 /*Cleanup*/ 549 549 xDelete<long>(vertex_index2sid); 550 550 } … … 553 553 554 554 /* IMPORTANT! elements come in Matlab indexing 555 555 NEOPZ works only in C indexing*/ 556 556 557 557 if(nvertices<=0) _error_("Impossible to create initial mesh: nvertices is <= 0!\n"); 558 558 if(nelements<=0) _error_("Impossible to create initial mesh: nelements is <= 0!\n"); 559 559 if(this->refinement_type!=0 && this->refinement_type!=1) _error_("Impossible to create initial mesh: refinement type is not defined!\n"); … … 560 560 561 561 /*Verify and creating initial mesh*/ 562 562 if(this->fathermesh || this->previousmesh) _error_("Initial mesh already exists!"); 563 563 564 564 this->fathermesh = new TPZGeoMesh(); 565 565 this->fathermesh->NodeVec().Resize(nvertices); 566 566 … … 575 575 this->fathermesh->NodeVec()[i].SetCoord(coord); 576 576 this->fathermesh->NodeVec()[i].SetNodeId(i); 577 577 } 578 578 579 579 /*Generate the elements*/ 580 580 long index; 581 581 const int mat = this->GetElemMaterialID(); … … 603 603 } 604 604 /*}}}*/ 605 605 TPZGeoMesh* AdaptiveMeshRefinement::CreateRefPatternMesh(TPZGeoMesh* gmesh){/*{{{*/ 606 606 607 607 TPZGeoMesh *newgmesh = new TPZGeoMesh(); 608 608 newgmesh->CleanUp(); 609 609 610 610 int nnodes = gmesh->NNodes(); 611 611 int nelem = gmesh->NElements(); 612 612 int mat = this->GetElemMaterialID();; … … 616 616 //nodes 617 617 newgmesh->NodeVec().Resize(nnodes); 618 618 for(int i=0;i<nnodes;i++) newgmesh->NodeVec()[i] = gmesh->NodeVec()[i]; 619 619 620 620 //elements 621 621 for(int i=0;i<nelem;i++){ 622 622 TPZGeoEl * geoel = gmesh->Element(i); 623 623 624 624 if(!geoel){ 625 625 index=newgmesh->ElementVec().AllocateNewElement(); 626 626 newgmesh->ElementVec()[index] = NULL; 627 627 continue; 628 628 } 629 629 630 630 TPZManVector<long> elem(3,0); 631 631 for(int j=0;j<3;j++) elem[j] = geoel->NodeIndex(j); 632 632 633 633 newgmesh->CreateGeoElement(ETriangle,elem,mat,index,reftype); 634 634 newgmesh->ElementVec()[index]->SetId(geoel->Id()); 635 635 636 636 TPZGeoElRefPattern<TPZGeoTriangle>* newgeoel = dynamic_cast<TPZGeoElRefPattern<TPZGeoTriangle>*>(newgmesh->ElementVec()[index]); 637 637 638 638 //old neighbourhood 639 639 const int nsides = TPZGeoTriangle::NSides; 640 640 TPZVec< std::vector<TPZGeoElSide> > neighbourhood(nsides); … … 653 653 neighS = neighS.Neighbour(); 654 654 } 655 655 } 656 656 657 657 //inserting in new element 658 658 for(int s = 0; s < nsides; s++){ 659 659 TPZGeoEl * tempEl = newgeoel; … … 667 667 } 668 668 tempEl->SetNeighbour(byside, tempSide); 669 669 } 670 670 671 671 long fatherindex = geoel->FatherIndex(); 672 672 if(fatherindex>-1) newgeoel->SetFather(fatherindex); 673 673 674 674 if(!geoel->HasSubElement()) continue; 675 675 676 676 int nsons = geoel->NSubElements(); 677 677 678 678 TPZAutoPointer<TPZRefPattern> ref = gRefDBase.GetUniformRefPattern(ETriangle); 679 679 newgeoel->SetRefPattern(ref); 680 680 681 681 for(int j=0;j<nsons;j++){ 682 682 TPZGeoEl* son = geoel->SubElement(j); 683 683 if(!son){ … … 689 689 690 690 /*Now, build connectivities*/ 691 691 newgmesh->BuildConnectivity(); 692 692 693 693 return newgmesh; 694 694 } 695 695 /*}}}*/ … … 704 704 } 705 705 /*}}}*/ 706 706 void AdaptiveMeshRefinement::PrintGMeshVTK(TPZGeoMesh* gmesh,std::ofstream &file,bool matColor){/*{{{*/ 707 707 708 708 file.clear(); 709 709 long nelements = gmesh->NElements(); 710 710 TPZGeoEl *gel; … … 730 730 } 731 731 MElementType elt = gel->Type(); 732 732 int elNnodes = MElementType_NNodes(elt); 733 733 734 734 size += (1+elNnodes); 735 735 connectivity << elNnodes; 736 736 737 737 for(int t = 0; t < elNnodes; t++) 738 738 { 739 739 for(int c = 0; c < 3; c++) … … 742 742 node << coord << " "; 743 743 } 744 744 node << std::endl; 745 745 746 746 actualNode++; 747 747 connectivity << " " << actualNode; 748 748 } 749 749 connectivity << std::endl; 750 750 751 751 int elType = this->GetVTK_ElType(gel); 752 752 type << elType << std::endl; 753 753 754 754 if(matColor == true) 755 755 { 756 756 material << gel->MaterialId() << std::endl; … … 759 759 { 760 760 material << gel->Index() << std::endl; 761 761 } 762 762 763 763 nVALIDelements++; 764 764 } 765 765 node << std::endl; … … 789 789 } 790 790 /*}}}*/ 791 791 int AdaptiveMeshRefinement::GetVTK_ElType(TPZGeoEl * gel){/*{{{*/ 792 792 793 793 MElementType pzElType = gel->Type(); 794 794 795 795 int elType = -1; 796 796 switch (pzElType) 797 797 { … … 848 848 std::cout << "MIGHT BE CURVED ELEMENT (quadratic or quarter point)" << std::endl; 849 849 DebugStop(); 850 850 } 851 851 852 852 return elType; 853 853 } 854 854 /*}}}*/ 855 -
../trunk-jpl/src/c/classes/Elements/Tria.cpp
105 105 for(i=0;i<num_nodes;i++) if(this->nodes[i]) tria->nodes[i]=this->nodes[i]; else tria->nodes[i] = NULL; 106 106 } 107 107 else tria->nodes = NULL; 108 108 109 109 tria->vertices = (Vertex**)this->hvertices->deliverp(); 110 110 tria->material = (Material*)this->hmaterial->delivers(); 111 111 tria->matpar = (Matpar*)this->hmatpar->delivers(); … … 114 114 } 115 115 /*}}}*/ 116 116 void Tria::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 117 117 118 118 MARSHALLING_ENUM(TriaEnum); 119 119 120 120 /*Call parent classes: */ 121 121 ElementHook::Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 122 122 Element::MarshallElement(pmarshalled_data,pmarshalled_data_size,marshall_direction,this->numanalyses); … … 134 134 135 135 /*Call inputs method*/ 136 136 _assert_(this->inputs); 137 137 138 138 int domaintype; 139 139 parameters->FindParam(&domaintype,DomainTypeEnum); 140 140 switch(domaintype){ … … 184 184 if(N!=num_inputs) _error_("sizes are not consistent"); 185 185 186 186 int tria_vertex_ids[3]; 187 187 188 188 for(int k=0;k<3;k++){ 189 189 tria_vertex_ids[k]=reCast<int>(iomodel->elements[3*this->Sid()+k]); //ids for vertices are in the elements array from Matlab 190 190 } … … 327 327 } 328 328 /*}}}*/ 329 329 void Tria::CalvingCrevasseDepth(){/*{{{*/ 330 330 331 331 IssmDouble xyz_list[NUMVERTICES][3]; 332 332 IssmDouble calvingrate[NUMVERTICES]; 333 333 IssmDouble vx,vy,vel; … … 339 339 340 340 /* Get node coordinates and dof list: */ 341 341 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 342 342 343 343 /*Get the critical fraction of thickness surface and basal crevasses penetrate for calving onset*/ 344 344 this->parameters->FindParam(&critical_fraction,CalvingCrevasseDepthEnum); 345 345 346 346 IssmDouble rho_ice = this->GetMaterialParameter(MaterialsRhoIceEnum); 347 347 IssmDouble rho_seawater = this->GetMaterialParameter(MaterialsRhoSeawaterEnum); 348 348 IssmDouble rho_freshwater = this->GetMaterialParameter(MaterialsRhoFreshwaterEnum); … … 360 360 Input* s_xx_input = inputs->GetInput(DeviatoricStressxxEnum); _assert_(s_xx_input); 361 361 Input* s_xy_input = inputs->GetInput(DeviatoricStressxyEnum); _assert_(s_xy_input); 362 362 Input* s_yy_input = inputs->GetInput(DeviatoricStressyyEnum); _assert_(s_yy_input); 363 363 364 364 /*Loop over all elements of this partition*/ 365 365 GaussTria* gauss=new GaussTria(); 366 366 for (int iv=0;iv<NUMVERTICES;iv++){ 367 367 gauss->GaussVertex(iv); 368 368 369 369 H_input->GetInputValue(&thickness,gauss); 370 370 bed_input->GetInputValue(&bed,gauss); 371 371 surface_input->GetInputValue(&float_depth,gauss); … … 377 377 s_xx_input->GetInputValue(&s_xx,gauss); 378 378 s_xy_input->GetInputValue(&s_xy,gauss); 379 379 s_yy_input->GetInputValue(&s_yy,gauss); 380 380 381 381 vel=sqrt(vx*vx+vy*vy)+1.e-14; 382 382 383 383 s1=(s_xx+s_yy)/2.+sqrt(pow((s_xx-s_yy)/2.,2)+pow(s_xy,2)); 384 384 s2=(s_xx+s_yy)/2.-sqrt(pow((s_xx-s_yy)/2.,2)+pow(s_xy,2)); 385 385 if(fabs(s2)>fabs(s1)){stmp=s2; s2=s1; s1=stmp;} 386 386 387 387 Ho = thickness - (rho_seawater/rho_ice) * (-bed); 388 388 if(Ho<0.) Ho=0.; 389 389 … … 398 398 //if (surface_crevasse[iv]<water_height){ 399 399 // water_height = surface_crevasse[iv]; 400 400 //} 401 401 402 402 /*basal crevasse*/ 403 403 //basal_crevasse[iv] = (rho_ice/(rho_seawater-rho_ice)) * (rheology_B * strainparallel * pow(straineffective,((1/rheology_n)-1)) / (rho_ice*constant_g) - Ho); 404 404 basal_crevasse[iv] = (rho_ice/(rho_seawater-rho_ice))* (s1/ (rho_ice*constant_g)-Ho); 405 405 if (basal_crevasse[iv]<0.) basal_crevasse[iv]=0.; 406 406 if (bed>0.) basal_crevasse[iv] = 0.; 407 407 408 408 H_surf = surface_crevasse[iv] + (rho_freshwater/rho_ice)*water_height - critical_fraction*float_depth; 409 409 H_surfbasal = (surface_crevasse[iv] + (rho_freshwater/rho_ice)*water_height + basal_crevasse[iv])-(critical_fraction*thickness); 410 410 411 411 crevasse_depth[iv] = max(H_surf,H_surfbasal); 412 412 } 413 413 414 414 this->inputs->AddInput(new TriaInput(SurfaceCrevasseEnum,&surface_crevasse[0],P1Enum)); 415 415 this->inputs->AddInput(new TriaInput(BasalCrevasseEnum,&basal_crevasse[0],P1Enum)); 416 416 this->inputs->AddInput(new TriaInput(CrevasseDepthEnum,&crevasse_depth[0],P1Enum)); … … 460 460 } 461 461 else 462 462 calvingrate[iv]=0.; 463 463 464 464 calvingratex[iv]=calvingrate[iv]*vx/(sqrt(vel)+1.e-14); 465 465 calvingratey[iv]=calvingrate[iv]*vy/(sqrt(vel)+1.e-14); 466 466 } … … 561 561 IssmDouble strain_xy[NUMVERTICES]; 562 562 IssmDouble vorticity_xy[NUMVERTICES]; 563 563 GaussTria* gauss=NULL; 564 564 565 565 /* Get node coordinates and dof list: */ 566 566 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 567 567 … … 568 568 /*Retrieve all inputs we will be needing: */ 569 569 Input* vx_input=this->GetInput(EsaXmotionEnum); _assert_(vx_input); 570 570 Input* vy_input=this->GetInput(EsaYmotionEnum); _assert_(vy_input); 571 571 572 572 /* Start looping on the number of vertices: */ 573 573 gauss=new GaussTria(); 574 574 for (int iv=0;iv<NUMVERTICES;iv++){ … … 772 772 } 773 773 } 774 774 775 776 775 }/*}}}*/ 777 776 void Tria::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){/*{{{*/ 778 777 … … 1399 1398 } 1400 1399 /*}}}*/ 1401 1400 void Tria::GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 1402 1401 1403 1402 /* Intermediaries */ 1404 1403 int i, dir,nrfrontnodes; 1405 1404 IssmDouble levelset[NUMVERTICES]; … … 1488 1487 1489 1488 }/*}}}*/ 1490 1489 void Tria::GetLevelsetIntersection(int** pindices, int* pnumiceverts, IssmDouble* fraction, int levelset_enum, IssmDouble level){/*{{{*/ 1491 1490 1492 1491 /* GetLevelsetIntersection computes: 1493 1492 * 1. indices of element, sorted in [iceverts, noiceverts] in counterclockwise fashion, 1494 1493 * 2. fraction of intersected triangle edges intersected by levelset, lying below level*/ … … 1564 1563 } 1565 1564 /*}}}*/ 1566 1565 void Tria::GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* gl){/*{{{*/ 1567 1566 1568 1567 /*Computeportion of the element that has a positive levelset*/ 1569 1568 1570 1569 bool negative=true; … … 1678 1677 Input* input=(Input*)this->inputs->GetInput(control_enum); _assert_(input); 1679 1678 1680 1679 parameters->FindParam(&M,NULL,ControlInputSizeMEnum); 1681 1680 1682 1681 /*Cast to Controlinput*/ 1683 1682 if(input->ObjectEnum()!=ControlInputEnum) _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput"); 1684 1683 ControlInput* controlinput = xDynamicCast<ControlInput*>(input); 1685 1684 1686 1685 if(strcmp(data,"value")==0){ 1687 1686 input = controlinput->values; 1688 1687 } … … 1699 1698 _error_("Data " << data << " not supported yet"); 1700 1699 } 1701 1700 /*Check what input we are dealing with*/ 1702 1701 1703 1702 switch(input->ObjectEnum()){ 1704 1703 case TriaInputEnum: 1705 1704 { … … 1716 1715 vector->SetValues(NUMVERTICES,idlist,values,INS_VAL); 1717 1716 break; 1718 1717 } 1719 1718 1720 1719 case TransientInputEnum: 1721 1720 { 1722 1721 TransientInput* transientinput = xDynamicCast<TransientInput*>(input); … … 1981 1980 surface_input->GetInputAverage(&surface); 1982 1981 base_input->GetInputAverage(&bed); 1983 1982 bed_input->GetInputAverage(&bathymetry); 1984 1983 1985 1984 /*Return: */ 1986 1985 return base*(surface-bed+min(rho_water/rho_ice*bathymetry,0.)); 1987 1986 } … … 2026 2025 if(control_analysis && ad_analysis) iomodel->FindConstant(&num_control_type,"md.autodiff.num_independent_objects"); 2027 2026 if(control_analysis && ad_analysis) iomodel->FindConstant(&num_responses,"md.autodiff.num_dependent_objects"); 2028 2027 2029 2030 2031 2028 /*Recover vertices ids needed to initialize inputs*/ 2032 2029 for(i=0;i<3;i++){ 2033 2030 tria_vertex_ids[i]=reCast<int>(iomodel->elements[3*index+i]); //ids for vertices are in the elements array from Matlab … … 2393 2390 /*}}}*/ 2394 2391 IssmDouble Tria::Masscon(IssmDouble* levelset){ /*{{{*/ 2395 2392 2396 2397 2393 /*intermediary: */ 2398 2394 IssmDouble* values=NULL; 2399 2395 Input* thickness_input=NULL; … … 2406 2402 int point1; 2407 2403 IssmDouble fraction1,fraction2; 2408 2404 bool mainlynegative=true; 2409 2405 2410 2406 /*Output:*/ 2411 2407 volume=0; 2412 2408 … … 2415 2411 2416 2412 /*Retrieve inputs required:*/ 2417 2413 thickness_input=this->GetInput(ThicknessEnum); _assert_(thickness_input); 2418 2414 2419 2415 /*Retrieve material parameters: */ 2420 2416 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2421 2417 … … 2424 2420 for(int i=0;i<NUMVERTICES;i++){ 2425 2421 values[i]=levelset[this->vertices[i]->Sid()]; 2426 2422 } 2427 2423 2428 2424 /*Ok, use the level set values to figure out where we put our gaussian points:*/ 2429 2425 this->GetLevelsetPositivePart(&point1,&fraction1,&fraction2,&mainlynegative,values); 2430 2426 Gauss* gauss = this->NewGauss(point1,fraction1,fraction2,mainlynegative,4); … … 2876 2872 dist_gl_input->GetInputValue(&dist_gl,gauss); 2877 2873 dist_cf_input->GetInputValue(&dist_cf,gauss); 2878 2874 delete gauss; 2879 2875 2880 2876 /*Ensure values are positive for floating ice*/ 2881 2877 dist_gl = fabs(dist_gl); 2882 2878 dist_cf = fabs(dist_cf); … … 3196 3192 } 3197 3193 } 3198 3194 3199 3200 3195 } 3201 3196 /*}}}*/ 3202 3197 void Tria::ResetFSBasalBoundaryCondition(void){/*{{{*/ … … 3277 3272 IssmDouble values[NUMVERTICES]; 3278 3273 int idlist[NUMVERTICES],control_init; 3279 3274 3280 3281 3275 /*Get Domain type*/ 3282 3276 int domaintype; 3283 3277 parameters->FindParam(&domaintype,DomainTypeEnum); … … 3297 3291 3298 3292 /*Get out if this is not an element input*/ 3299 3293 if(!IsInputEnum(control_enum)) return; 3300 3294 3301 3295 Input* input = (Input*)this->inputs->GetInput(control_enum); _assert_(input); 3302 3296 if(input->ObjectEnum()!=ControlInputEnum){ 3303 3297 _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput"); … … 3330 3324 IssmDouble values[NUMVERTICES]; 3331 3325 int vertexpidlist[NUMVERTICES],control_init; 3332 3326 3333 3334 3327 /*Get Domain type*/ 3335 3328 int domaintype; 3336 3329 parameters->FindParam(&domaintype,DomainTypeEnum); … … 4166 4159 IssmDouble* U_elastic_precomputed = NULL; 4167 4160 IssmDouble* H_elastic_precomputed = NULL; 4168 4161 int M, hemi; 4169 4162 4170 4163 /*computation of Green functions:*/ 4171 4164 IssmDouble* U_elastic= NULL; 4172 4165 IssmDouble* N_elastic= NULL; … … 4173 4166 IssmDouble* E_elastic= NULL; 4174 4167 IssmDouble* X_elastic= NULL; 4175 4168 IssmDouble* Y_elastic= NULL; 4176 4169 4177 4170 /*optimization:*/ 4178 4171 bool store_green_functions=false; 4179 4172 … … 4181 4174 Input* deltathickness_input=inputs->GetInput(EsaDeltathicknessEnum); 4182 4175 if (!deltathickness_input)_error_("delta thickness input needed to compute elastic adjustment!"); 4183 4176 deltathickness_input->GetInputAverage(&I); 4184 4177 4185 4178 /*early return if we are not on the (ice) loading point: */ 4186 4179 if(I==0) return; 4187 4180 … … 4194 4187 4195 4188 /*which hemisphere? for north-south, east-west components*/ 4196 4189 this->parameters->FindParam(&hemi,EsaHemisphereEnum); 4197 4190 4198 4191 /*compute area of element:*/ 4199 4192 area=GetArea(); 4200 4193 … … 4253 4246 U_values[i]+=3*rho_ice/rho_earth*area/(4*PI*pow(earth_radius,2))*I*U_elastic[i]; 4254 4247 Y_values[i]+=3*rho_ice/rho_earth*area/(4*PI*pow(earth_radius,2))*I*Y_elastic[i]; 4255 4248 X_values[i]+=3*rho_ice/rho_earth*area/(4*PI*pow(earth_radius,2))*I*X_elastic[i]; 4256 4249 4257 4250 /*North-south, East-west components */ 4258 4251 if (hemi == -1) { 4259 4252 ang2 = PI/2 - atan2(yy[i],xx[i]); … … 4276 4269 pEast->SetValues(gsize,indices,E_values,ADD_VAL); 4277 4270 pX->SetValues(gsize,indices,X_values,ADD_VAL); 4278 4271 pY->SetValues(gsize,indices,Y_values,ADD_VAL); 4279 4272 4280 4273 /*free ressources:*/ 4281 4274 xDelete<int>(indices); 4282 4275 xDelete<IssmDouble>(U_values); xDelete<IssmDouble>(N_values); xDelete<IssmDouble>(E_values); … … 4306 4299 IssmDouble* U_elastic_precomputed = NULL; 4307 4300 IssmDouble* H_elastic_precomputed = NULL; 4308 4301 int M; 4309 4302 4310 4303 /*computation of Green functions:*/ 4311 4304 IssmDouble* U_elastic= NULL; 4312 4305 IssmDouble* N_elastic= NULL; 4313 4306 IssmDouble* E_elastic= NULL; 4314 4307 4315 4308 /*optimization:*/ 4316 4309 bool store_green_functions=false; 4317 4310 … … 4319 4312 Input* deltathickness_input=inputs->GetInput(EsaDeltathicknessEnum); 4320 4313 if (!deltathickness_input)_error_("delta thickness input needed to compute elastic adjustment!"); 4321 4314 deltathickness_input->GetInputAverage(&I); 4322 4315 4323 4316 /*early return if we are not on the (ice) loading point: */ 4324 4317 if(I==0) return; 4325 4318 … … 4418 4411 dx = x_element-x; dy = y_element-y; dz = z_element-z; 4419 4412 N_azim = (-z*x*dx-z*y*dy+(pow(x,2)+pow(y,2))*dz) /pow((pow(x,2)+pow(y,2))*(pow(x,2)+pow(y,2)+pow(z,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); 4420 4413 E_azim = (-y*dx+x*dy) /pow((pow(x,2)+pow(y,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); 4421 4414 4422 4415 /*Elastic component (from Eq 17 in Adhikari et al, GMD 2015): */ 4423 4416 int index=reCast<int,IssmDouble>(alpha/PI*(M-1)); 4424 4417 U_elastic[i] += U_elastic_precomputed[index]; … … 4433 4426 pUp->SetValues(gsize,indices,U_values,ADD_VAL); 4434 4427 pNorth->SetValues(gsize,indices,N_values,ADD_VAL); 4435 4428 pEast->SetValues(gsize,indices,E_values,ADD_VAL); 4436 4429 4437 4430 /*free ressources:*/ 4438 4431 xDelete<int>(indices); 4439 4432 xDelete<IssmDouble>(U_values); xDelete<IssmDouble>(N_values); xDelete<IssmDouble>(E_values); … … 4454 4447 IssmDouble Tria::OceanAverage(IssmDouble* Sg){ /*{{{*/ 4455 4448 4456 4449 if(IsWaterInElement()){ 4457 4450 4458 4451 IssmDouble area; 4459 4452 4460 4453 /*Compute area of element:*/ … … 4527 4520 4528 4521 if(IsWaterInElement()){ 4529 4522 IssmDouble rho_water, S; 4530 4523 4531 4524 /*recover material parameters: */ 4532 4525 rho_water=matpar->GetMaterialParameter(MaterialsRhoFreshwaterEnum); 4533 4526 4534 4527 /*From Sg_old, recover water sea level rise:*/ 4535 4528 S=0; for(int i=0;i<NUMVERTICES;i++) S+=Sg_old[this->vertices[i]->Sid()]/NUMVERTICES; 4536 4529 4537 4530 /* Perturbation terms for moment of inertia (moi_list): 4538 4531 * computed analytically (see Wu & Peltier, eqs 10 & 32) 4539 4532 * also consistent with my GMD formulation! … … 4545 4538 } 4546 4539 else if(this->inputs->Max(MaskIceLevelsetEnum)<0){ 4547 4540 IssmDouble rho_ice, I; 4548 4541 4549 4542 /*recover material parameters: */ 4550 4543 rho_ice=matpar->GetMaterialParameter(MaterialsRhoIceEnum); 4551 4544 4552 4545 /*Compute ice thickness change: */ 4553 4546 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 4554 4547 if (!deltathickness_input)_error_("delta thickness input needed to compute sea level rise!"); 4555 4548 deltathickness_input->GetInputAverage(&I); 4556 4549 4557 4550 dI_list[0] = -4*PI*(rho_ice*I*area)*pow(re,4)*(sin(late)*cos(late)*cos(longe))/eartharea; 4558 4551 dI_list[1] = -4*PI*(rho_ice*I*area)*pow(re,4)*(sin(late)*cos(late)*sin(longe))/eartharea; 4559 4552 dI_list[2] = +4*PI*(rho_ice*I*area)*pow(re,4)*(1-pow(sin(late),2))/eartharea; 4560 4553 } 4561 4554 4562 4555 return; 4563 4556 }/*}}}*/ 4564 4557 void Tria::SealevelriseEustatic(Vector<IssmDouble>* pSgi,IssmDouble* peustatic,IssmDouble* latitude,IssmDouble* longitude,IssmDouble* radius,IssmDouble oceanarea,IssmDouble eartharea){ /*{{{*/ … … 4591 4584 bool computerigid = true; 4592 4585 bool computeelastic= true; 4593 4586 bool scaleoceanarea= false; 4594 4587 4595 4588 /*early return if we are not on an ice cap:*/ 4596 4589 if(!(this->inputs->Max(MaskIceLevelsetEnum)<=0)){ 4597 4590 constant=0; this->inputs->AddInput(new TriaInput(SealevelEustaticMaskEnum,&constant,P0Enum)); … … 4605 4598 *peustatic=0; //do not forget to assign this pointer, otherwise, global eustatic will be garbage! 4606 4599 return; 4607 4600 } 4608 4601 4609 4602 /*If we are here, we are on ice that is fully grounded or half-way to floating: */ 4610 4603 if ((this->inputs->Min(MaskGroundediceLevelsetEnum))<0){ 4611 4604 notfullygrounded=true; //used later on. 4612 4605 } 4613 4606 4614 4607 /*Inform mask: */ 4615 4608 constant=1; this->inputs->AddInput(new TriaInput(SealevelEustaticMaskEnum,&constant,P0Enum)); 4616 4609 … … 4635 4628 this->parameters->FindParam(&gsize,MeshNumberofverticesEnum); 4636 4629 4637 4630 /* Where is the centroid of this element?:{{{*/ 4638 4631 4639 4632 /*retrieve coordinates: */ 4640 4633 ::GetVerticesCoordinates(&llr_list[0][0],this->vertices,NUMVERTICES,spherical); 4641 4634 4642 4635 IssmDouble minlong=400; 4643 4636 IssmDouble maxlong=-20; 4644 4637 for (int i=0;i<NUMVERTICES;i++){ … … 4652 4645 if (llr_list[1][1]==0)llr_list[1][1]=360; 4653 4646 if (llr_list[2][1]==0)llr_list[2][1]=360; 4654 4647 } 4655 4648 4656 4649 // correction at the north pole 4657 4650 if(llr_list[0][0]==0)llr_list[0][1]=(llr_list[1][1]+llr_list[2][1])/2.0; 4658 4651 if(llr_list[1][0]==0)llr_list[1][1]=(llr_list[0][1]+llr_list[2][1])/2.0; 4659 4652 if(llr_list[2][0]==0)llr_list[2][1]=(llr_list[0][1]+llr_list[1][1])/2.0; 4660 4653 4661 4654 //correction at the south pole 4662 4655 if(llr_list[0][0]==180)llr_list[0][1]=(llr_list[1][1]+llr_list[2][1])/2.0; 4663 4656 if(llr_list[1][0]==180)llr_list[1][1]=(llr_list[0][1]+llr_list[2][1])/2.0; … … 4683 4676 phi=this->GetGroundedPortion(&xyz_list[0][0]); //watch out, this only works because of the Thales theorem! We are in 3D, but this routine is inherently for 2D trias 4684 4677 area*=phi; 4685 4678 } 4686 4679 4687 4680 /*Compute ice thickness change: */ 4688 4681 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 4689 4682 if (!deltathickness_input)_error_("delta thickness input needed to compute sea level rise!"); … … 4695 4688 bool mainlyfloating = true; 4696 4689 int point1; 4697 4690 IssmDouble fraction1,fraction2; 4698 4691 4699 4692 /*Recover portion of element that is grounded*/ 4700 4693 this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating); 4701 4694 Gauss* gauss = this->NewGauss(point1,fraction1,fraction2,mainlyfloating,2); … … 4749 4742 values[i]=3*rho_ice/rho_earth*area/eartharea*I*(G_rigid+G_elastic); 4750 4743 } 4751 4744 pSgi->SetValues(gsize,indices,values,ADD_VAL); 4752 4745 4753 4746 /*free ressources:*/ 4754 4747 xDelete<IssmDouble>(values); 4755 4748 xDelete<int>(indices); 4756 4749 } 4757 4750 4758 4751 /*Assign output pointer:*/ 4759 4752 _assert_(!xIsNan<IssmDouble>(eustatic)); 4760 4753 _assert_(!xIsInf<IssmDouble>(eustatic)); … … 4779 4772 /*precomputed elastic green functions:*/ 4780 4773 IssmDouble* G_elastic_precomputed = NULL; 4781 4774 int M; 4782 4775 4783 4776 /*computation of Green functions:*/ 4784 4777 IssmDouble* G_elastic= NULL; 4785 4778 IssmDouble* G_rigid= NULL; … … 4856 4849 late=late/180*PI; 4857 4850 longe=longe/180*PI; 4858 4851 /*}}}*/ 4859 4852 4860 4853 if(computeelastic){ 4861 4854 4862 4855 /*recover elastic green function:*/ 4863 4856 DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGElasticEnum)); _assert_(parameter); 4864 4857 parameter->GetParameterValueByPointer(&G_elastic_precomputed,&M); … … 4896 4889 values[i]+=3*rho_water/rho_earth*area/eartharea*S*G_elastic[i]; 4897 4890 } 4898 4891 } 4899 4892 4900 4893 pSgo->SetValues(gsize,indices,values,ADD_VAL); 4901 4894 4902 4895 /*free ressources:*/ … … 4929 4922 IssmDouble* U_elastic_precomputed = NULL; 4930 4923 IssmDouble* H_elastic_precomputed = NULL; 4931 4924 int M; 4932 4925 4933 4926 /*computation of Green functions:*/ 4934 4927 IssmDouble* U_elastic= NULL; 4935 4928 IssmDouble* N_elastic= NULL; … … 4956 4949 /*recover computational flags: */ 4957 4950 this->parameters->FindParam(&computerigid,SealevelriseRigidEnum); 4958 4951 this->parameters->FindParam(&computeelastic,SealevelriseElasticEnum); 4959 4952 4960 4953 /*early return if elastic not requested:*/ 4961 4954 if(!computeelastic) return; 4962 4955 … … 5025 5018 5026 5019 /*From Sg, recover water sea level rise:*/ 5027 5020 S=0; for(int i=0;i<NUMVERTICES;i++) S+=Sg[this->vertices[i]->Sid()]/NUMVERTICES; 5028 5021 5029 5022 /*Compute ice thickness change: */ 5030 5023 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 5031 5024 if (!deltathickness_input)_error_("delta thickness input needed to compute sea level rise!"); 5032 5025 deltathickness_input->GetInputAverage(&I); 5033 5026 5034 5027 /*initialize: */ 5035 5028 U_elastic=xNewZeroInit<IssmDouble>(gsize); 5036 5029 if(horiz){ … … 5072 5065 N_azim = (-z*x*dx-z*y*dy+(pow(x,2)+pow(y,2))*dz) /pow((pow(x,2)+pow(y,2))*(pow(x,2)+pow(y,2)+pow(z,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); 5073 5066 E_azim = (-y*dx+x*dy) /pow((pow(x,2)+pow(y,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); 5074 5067 } 5075 5068 5076 5069 /*Elastic component (from Eq 17 in Adhikari et al, GMD 2015): */ 5077 5070 int index=reCast<int,IssmDouble>(alpha/PI*(M-1)); 5078 5071 U_elastic[i] += U_elastic_precomputed[index]; -
../trunk-jpl/src/c/classes/Elements/Penta.cpp
286 286 IssmDouble calvingratey[NUMVERTICES]; 287 287 IssmDouble calvingrate[NUMVERTICES]; 288 288 289 290 289 /* Get node coordinates and dof list: */ 291 290 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 292 291 … … 1047 1046 } 1048 1047 /*}}}*/ 1049 1048 void Penta::GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 1050 1049 1051 1050 /* Intermediaries */ 1052 1051 const int dim=3; 1053 1052 int i, dir,nrfrontnodes; … … 1181 1180 if(!IsInputEnum(control_enum)) _error_("Enum "<<EnumToStringx(control_enum)<<" is not in IsInput"); 1182 1181 Input* input=(Input*)this->inputs->GetInput(control_enum); _assert_(input); 1183 1182 1184 1185 1183 /*Cast to Controlinput*/ 1186 1184 if(input->ObjectEnum()!=ControlInputEnum) _error_("input " << EnumToStringx(control_enum) << " is not a ControlInput"); 1187 1185 ControlInput* controlinput = xDynamicCast<ControlInput*>(input); … … 2594 2592 2595 2593 Penta* penta=this; 2596 2594 for(;;){ 2597 2595 2598 2596 IssmDouble xyz_list[NUMVERTICES][3]; 2599 2597 /* Get node coordinates and dof list: */ 2600 2598 ::GetVerticesCoordinates(&xyz_list[0][0],penta->vertices,NUMVERTICES); … … 2603 2601 Jdet[0]=(xyz_list[3][2]-xyz_list[0][2])*0.5; 2604 2602 Jdet[1]=(xyz_list[4][2]-xyz_list[1][2])*0.5; 2605 2603 Jdet[2]=(xyz_list[5][2]-xyz_list[2][2])*0.5; 2606 2604 2607 2605 /*Retrieve all inputs we will need*/ 2608 2606 Input* vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2609 2607 Input* vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); … … 2614 2612 Input* deviayy_input=inputs->GetInput(DeviatoricStressyyEnum); _assert_(deviayy_input); 2615 2613 Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input); 2616 2614 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 2617 2615 2618 2616 /* Start looping on the number of 2D vertices: */ 2619 2617 for(int ig=0;ig<3;ig++){ 2620 2618 GaussPenta* gauss=new GaussPenta(ig,3+ig,11); … … 2643 2641 } 2644 2642 delete gauss; 2645 2643 } 2646 2644 2647 2645 /*Stop if we have reached the surface/base*/ 2648 2646 if(penta->IsOnSurface()) break; 2649 2647 2650 2648 /*get upper Penta*/ 2651 2649 penta=penta->GetUpperPenta(); 2652 2650 _assert_(penta->Id()!=this->id); -
../trunk-jpl/src/c/classes/Elements/ElementHook.cpp
103 103 MARSHALLING_DYNAMIC(hnodesi_null,bool,numanalyses); 104 104 105 105 if(marshall_direction==MARSHALLING_BACKWARD){ 106 106 107 107 if (!hnodes_null)this->hnodes = new Hook*[numanalyses]; 108 108 else this->hnodes=NULL; 109 109 this->hvertices = new Hook(); … … 139 139 140 140 _printf_(" ElementHook DeepEcho:\n"); 141 141 _printf_(" numanalyses : "<< this->numanalyses <<"\n"); 142 142 143 143 _printf_(" hnodes:\n"); 144 144 if(hnodes){ 145 145 for(int i=0;i<this->numanalyses;i++) { … … 148 148 } 149 149 } 150 150 else _printf_(" hnodes = NULL\n"); 151 151 152 152 _printf_(" hvertices:\n"); 153 153 if(hvertices) hvertices->DeepEcho(); 154 154 else _printf_(" hvertices = NULL\n"); 155 155 156 156 _printf_(" hmaterial:\n"); 157 157 if(hmaterial) hmaterial->DeepEcho(); 158 158 else _printf_(" hmaterial = NULL\n"); … … 169 169 } 170 170 /*}}}*/ 171 171 void ElementHook::Echo(){/*{{{*/ 172 172 173 173 _printf_(" ElementHook Echo:\n"); 174 174 _printf_(" numanalyses : "<< this->numanalyses <<"\n"); 175 175 176 176 _printf_(" hnodes:\n"); 177 177 if(hnodes){ 178 178 for(int i=0;i<this->numanalyses;i++) { … … 180 180 } 181 181 } 182 182 else _printf_(" hnodes = NULL\n"); 183 183 184 184 _printf_(" hvertices:\n"); 185 185 if(hvertices) hvertices->Echo(); 186 186 else _printf_(" hvertices = NULL\n"); 187 187 188 188 _printf_(" hmaterial:\n"); 189 189 if(hmaterial) hmaterial->Echo(); 190 190 else _printf_(" hmaterial = NULL\n"); -
../trunk-jpl/src/c/classes/Elements/Seg.cpp
103 103 104 104 return seg; 105 105 106 107 106 } 108 107 /*}}}*/ 109 108 void Seg::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 140 139 } 141 140 /*}}}*/ 142 141 void Seg::GetIcefrontCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum){/*{{{*/ 143 142 144 143 /* Intermediaries */ 145 144 int nrfrontnodes,index; 146 145 IssmDouble levelset[NUMVERTICES]; -
../trunk-jpl/src/c/classes/Elements/Element.cpp
1104 1104 /*}}}*/ 1105 1105 void Element::GetInputLocalMinMaxOnNodes(IssmDouble* min,IssmDouble* max,IssmDouble* ug){/*{{{*/ 1106 1106 1107 1108 1107 /*Get number of nodes for this element*/ 1109 1108 int numnodes = this->GetNumberOfNodes(); 1110 1109 … … 1121 1120 if(ug[nodes[i]->GetDof(0,GsetEnum)] > input_max) input_max = ug[nodes[i]->GetDof(0,GsetEnum)]; 1122 1121 } 1123 1122 1124 1125 1123 /*Second loop to reassign min and max with local extrema*/ 1126 1124 for(int i=0;i<numnodes;i++){ 1127 1125 if(min[nodes[i]->GetDof(0,GsetEnum)]>input_min) min[nodes[i]->GetDof(0,GsetEnum)] = input_min; … … 1388 1386 default: 1389 1387 _error_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet"); 1390 1388 } 1391 1389 1392 1390 /*Clean up*/ 1393 1391 xDelete<int>(doflist); 1394 1392 xDelete<IssmDouble>(values); … … 1476 1474 parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 1477 1475 parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum); 1478 1476 1479 1480 1477 /*Get number of vertices*/ 1481 1478 int numvertices = this->GetNumberOfVertices(); 1482 1479 if(isautodiff){ … … 1807 1804 this->inputs->AddInput(datasetinput); 1808 1805 } 1809 1806 1810 1811 1807 /*Branch on type of vector: nodal or elementary: */ 1812 1808 if(vector_type==1){ //nodal vector 1813 1809 … … 2066 2062 this->GetInputListOnVertices(deepwatermelt,BasalforcingsDeepwaterMeltingRateEnum); 2067 2063 this->GetInputListOnVertices(deepwaterel,BasalforcingsDeepwaterElevationEnum); 2068 2064 this->GetInputListOnVertices(upperwaterel,BasalforcingsUpperwaterElevationEnum); 2069 2065 2070 2066 for(int i=0;i<numvertices;i++){ 2071 2067 if(base[i]>upperwaterel[i]) values[i]=0; 2072 2068 else if (base[i]<deepwaterel[i]) values[i]=deepwatermelt[i]; … … 2869 2865 /*only compute SMB at the surface: */ 2870 2866 if (!IsOnSurface()) return; 2871 2867 2872 2873 2868 /*Retrieve material properties and parameters:{{{ */ 2874 2869 rho_ice = matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2875 2870 rho_water = matpar->GetMaterialParameter(MaterialsRhoFreshwaterEnum); … … 3071 3066 /*Snow, firn and ice albedo:*/ 3072 3067 if(isalbedo)albedo(&a,aIdx,re,d,cldFrac,aIce,aSnow,aValue,adThresh,T,W,P,EC,t0wet,t0dry,K,smb_dt,rho_ice,m,this->Sid()); 3073 3068 3074 3075 3069 /*Distribution of absorbed short wave radation with depth:*/ 3076 3070 if(isshortwave)shortwave(&swf, swIdx, aIdx, dsw, a[0], d, dz, re,rho_ice,m,this->Sid()); 3077 3071 -
../trunk-jpl/src/c/classes/gauss/GaussSeg.cpp
30 30 /*Get gauss points*/ 31 31 this->numgauss = order; 32 32 GaussLegendreLinear(&pcoords1,&pweights,order); 33 33 34 34 this->coords1=xNew<IssmDouble>(numgauss); 35 35 this->weights=xNew<IssmDouble>(numgauss); 36 36 -
../trunk-jpl/src/c/classes/Regionaloutput.cpp
154 154 return val_t; 155 155 } 156 156 /*}}}*/ 157 -
../trunk-jpl/src/c/classes/Dakota/IssmParallelDirectApplicInterface.cpp
19 19 20 20 int world_rank; 21 21 ISSM_MPI_Comm_rank(ISSM_MPI_COMM_WORLD,&world_rank); 22 22 23 23 /*Build an femmodel if you are a slave, using the corresponding communicator:*/ 24 24 if(world_rank!=0){ 25 25 femmodel_init= new FemModel(argc,argv,evaluation_comm); … … 32 32 33 33 int world_rank; 34 34 ISSM_MPI_Comm_rank(ISSM_MPI_COMM_WORLD,&world_rank); 35 35 36 36 if(world_rank!=0){ 37 37 38 38 /*Wrap up: */ -
../trunk-jpl/src/c/classes/Node.cpp
497 497 } 498 498 /*}}}*/ 499 499 void Node::SetApproximation(int in_approximation){/*{{{*/ 500 500 501 501 this->approximation = in_approximation; 502 502 } 503 503 /*}}}*/ -
../trunk-jpl/src/c/classes/Constraints/SpcStatic.cpp
36 36 37 37 /*Object virtual functions definitions:*/ 38 38 Object* SpcStatic::copy() {/*{{{*/ 39 39 40 40 SpcStatic* spcstat = new SpcStatic(*this); 41 41 42 42 spcstat->id=this->id; -
../trunk-jpl/src/c/classes/IoModel.cpp
156 156 157 157 bool autodiff=false; 158 158 bool iscontrol=false; 159 159 160 160 /*First, keep track of the file handle: */ 161 161 this->fid=iomodel_handle; 162 162 … … 421 421 /*Initialize array detecting whether data[i] is an independent AD mode variable: */ 422 422 this->FetchData(&autodiff,"md.autodiff.isautodiff"); 423 423 this->FetchData(&iscontrol,"md.inversion.iscontrol"); 424 424 425 425 if(trace || (autodiff && !iscontrol)){ 426 426 427 427 #ifdef _HAVE_ADOLC_ … … 505 505 void IoModel::DeleteData(char*** pstringarray, int numstrings,const char* data_name){/*{{{*/ 506 506 507 507 char** stringarray=*pstringarray; 508 508 509 509 if(numstrings){ 510 510 for(int i=0;i<numstrings;i++){ 511 511 char* string=stringarray[i]; … … 596 596 case 2: 597 597 /*Read the integer and broadcast it to other cpus:*/ 598 598 if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_("could not read integer "); 599 599 600 600 /*Convert codes to Enums if needed*/ 601 601 if(strcmp(record_name,"md.smb.model")==0) integer = IoCodeToEnumSMB(integer); 602 602 if(strcmp(record_name,"md.basalforcings.model")==0) integer = IoCodeToEnumBasal(integer); … … 962 962 963 963 /*recover my_rank:*/ 964 964 int my_rank=IssmComm::GetRank(); 965 965 966 966 /*Set file pointer to beginning of the data: */ 967 967 fid=this->SetFilePointerToData(&code,NULL,data_name); 968 968 … … 1133 1133 return; 1134 1134 } 1135 1135 } 1136 1136 1137 1137 /*output: */ 1138 1138 int M,N; 1139 1139 IssmPDouble *matrix = NULL; … … 1824 1824 if(my_rank==0){ 1825 1825 /*check we are indeed finding a string, not something else: */ 1826 1826 if(codes[i]!=4)_error_("expecting a string for \""<<data_name<<"\""); 1827 1827 1828 1828 /*We have to read a string from disk. First read the dimensions of the string, then the string: */ 1829 1829 fsetpos(fid,file_positions+i); 1830 1830 if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string "); … … 1853 1853 /*Free ressources:*/ 1854 1854 xDelete<int>(codes); 1855 1855 xDelete<fpos_t>(file_positions); 1856 1856 1857 1857 /*Assign output pointers: */ 1858 1858 *pstrings=strings; 1859 1859 *pnumstrings=num_instances; … … 1874 1874 1875 1875 /*recover my_rank:*/ 1876 1876 int my_rank=IssmComm::GetRank(); 1877 1877 1878 1878 /*Get file pointers to beginning of the data (multiple instances of it): */ 1879 1879 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_name); 1880 1880 … … 1889 1889 code=codes[i]; 1890 1890 1891 1891 if(code!=2)_error_("expecting an integer for \""<<data_name<<"\""); 1892 1892 1893 1893 /*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */ 1894 1894 fsetpos(fid,file_positions+i); 1895 1895 if(my_rank==0){ … … 1902 1902 vector[i]=integer; 1903 1903 } 1904 1904 } 1905 1905 1906 1906 /*Free ressources:*/ 1907 1907 xDelete<fpos_t>(file_positions); 1908 1908 xDelete<int>(codes); … … 1927 1927 1928 1928 /*recover my_rank:*/ 1929 1929 int my_rank=IssmComm::GetRank(); 1930 1930 1931 1931 /*Get file pointers to beginning of the data (multiple instances of it): */ 1932 1932 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_name); 1933 1933 … … 1942 1942 code=codes[i]; 1943 1943 1944 1944 if(code!=3)_error_("expecting a double for \""<<data_name<<"\""); 1945 1945 1946 1946 /*We have to read a double from disk: */ 1947 1947 fsetpos(fid,file_positions+i); 1948 1948 if(my_rank==0){ … … 1955 1955 vector[i]=scalar; 1956 1956 } 1957 1957 } 1958 1958 1959 1959 /*Free ressources:*/ 1960 1960 xDelete<fpos_t>(file_positions); 1961 1961 xDelete<int>(codes); … … 1984 1984 1985 1985 /*recover my_rank:*/ 1986 1986 int my_rank=IssmComm::GetRank(); 1987 1987 1988 1988 /*Get file pointers to beginning of the data (multiple instances of it): */ 1989 1989 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_name); 1990 1990 … … 2014 2014 } 2015 2015 ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 2016 2016 2017 2018 2017 /*Now allocate matrix: */ 2019 2018 if(M*N){ 2020 2019 pmatrix=xNew<IssmPDouble>(M*N); … … 2038 2037 } 2039 2038 else 2040 2039 matrix=NULL; 2041 2042 2040 2043 2041 /*Assign: */ 2044 2042 mdims[i]=M; 2045 2043 matrices[i]=matrix; … … 2046 2044 ndims[i]=N; 2047 2045 } 2048 2046 } 2049 2047 2050 2048 /*Free ressources:*/ 2051 2049 xDelete<fpos_t>(file_positions); 2052 2050 xDelete<int>(codes); … … 2088 2086 2089 2087 /*recover my_rank:*/ 2090 2088 int my_rank=IssmComm::GetRank(); 2091 2089 2092 2090 /*Get file pointers to beginning of the data (multiple instances of it): */ 2093 2091 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_name); 2094 2092 … … 2118 2116 } 2119 2117 ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 2120 2118 2121 2122 2119 /*Now allocate matrix: */ 2123 2120 if(M*N){ 2124 2121 pmatrix=xNew<IssmPDouble>(M*N); … … 2143 2140 } 2144 2141 else 2145 2142 integer_matrix=NULL; 2146 2147 2143 2148 2144 /*Assign: */ 2149 2145 mdims[i]=M; 2150 2146 matrices[i]=integer_matrix; … … 2151 2147 ndims[i]=N; 2152 2148 } 2153 2149 } 2154 2150 2155 2151 /*Free ressources:*/ 2156 2152 xDelete<fpos_t>(file_positions); 2157 2153 xDelete<int>(codes); … … 2375 2371 codes = xNew<int>(num_instances); 2376 2372 vector_types = xNew<int>(num_instances); 2377 2373 } 2378 2374 2379 2375 /*Reset FILE* position to the beginning of the file, and start again, this time saving the data information 2380 2376 * as we find it: */ 2381 2377 counter=0; … … 2418 2414 codes[counter] = record_code; 2419 2415 vector_types[counter] = vector_type; 2420 2416 fgetpos(fid,file_positions+counter); 2421 2417 2422 2418 /*backup and skip over the record, as we have more work to do: */ 2423 2419 if(5<=record_code && record_code<=7) fseek(fid,-sizeof(int),SEEK_CUR); 2424 2420 fseek(fid,-sizeof(int),SEEK_CUR); 2425 2421 fseek(fid,-sizeof(int),SEEK_CUR); 2426 2422 2427 2423 /*increment counter: */ 2428 2424 counter++; 2429 2425 } -
../trunk-jpl/src/c/classes/Nodalvalue.cpp
86 86 } 87 87 /*}}}*/ 88 88 IssmDouble Nodalvalue::Response(FemModel* femmodel){/*{{{*/ 89 89 90 90 /*output:*/ 91 91 IssmDouble value; 92 92 -
../trunk-jpl/src/c/classes/Misfit.cpp
22 22 #include "../classes/Inputs/Input.h" 23 23 #include "../classes/gauss/Gauss.h" 24 24 /*}}}*/ 25 25 26 26 /*Misfit constructors, destructors :*/ 27 27 Misfit::Misfit(){/*{{{*/ 28 28 … … 41 41 Misfit::Misfit(char* in_name, int in_definitionenum, int in_model_enum, int in_observation_enum, char* in_timeinterpolation, int in_local, int in_weights_enum){/*{{{*/ 42 42 43 43 this->definitionenum=in_definitionenum; 44 44 45 45 this->name = xNew<char>(strlen(in_name)+1); 46 46 xMemCpy<char>(this->name,in_name,strlen(in_name)+1); 47 47 48 48 this->timeinterpolation = xNew<char>(strlen(in_timeinterpolation)+1); 49 49 xMemCpy<char>(this->timeinterpolation,in_timeinterpolation,strlen(in_timeinterpolation)+1); 50 50 51 51 this->model_enum=in_model_enum; 52 52 this->observation_enum=in_observation_enum; 53 53 this->weights_enum=in_weights_enum; 54 54 this->local=in_local; 55 55 56 56 this->misfit=0; 57 57 this->lock=0; 58 58 } … … 110 110 } 111 111 /*}}}*/ 112 112 IssmDouble Misfit::Response(FemModel* femmodel){/*{{{*/ 113 113 114 114 /*diverse: */ 115 115 IssmDouble time,starttime,finaltime; 116 116 IssmDouble dt; 117 117 118 118 /*recover time parameters: */ 119 119 femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum); 120 120 femmodel->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum); … … 129 129 IssmDouble area_t=0.; 130 130 IssmDouble all_area_t; 131 131 132 133 132 /*If we are locked, return time average: */ 134 133 if(this->lock)return misfit/(time-starttime); 135 134 … … 143 142 ISSM_MPI_Allreduce ( (void*)&area_t,(void*)&all_area_t,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 144 143 area_t=all_area_t; 145 144 misfit_t=all_misfit_t; 146 145 147 146 /*Divide by surface area if not nill!: */ 148 147 if (area_t!=0) misfit_t=misfit_t/area_t; 149 148 … … 163 162 IssmDouble* observation= NULL; 164 163 IssmDouble* weights= NULL; 165 164 int msize,osize,wsize; 166 165 167 166 /*Are we transient?:*/ 168 167 if (time==0){ 169 168 IssmDouble misfit_t=0.; 170 169 171 170 /*get global vectors: */ 172 171 GetVectorFromInputsx(&model,&msize,femmodel,model_enum); 173 172 GetVectorFromInputsx(&observation,&osize,femmodel,observation_enum);_assert_(msize==osize); … … 189 188 return misfit; 190 189 } 191 190 else{ 192 191 193 192 IssmDouble misfit_t=0.; 194 193 IssmDouble all_misfit_t=0.; 195 194 … … 200 199 GetVectorFromInputsx(&model,&msize,femmodel,model_enum); 201 200 GetVectorFromInputsx(&observation,&osize,femmodel,observation_enum);_assert_(msize==osize); 202 201 GetVectorFromInputsx(&weights,&wsize,femmodel,weights_enum); _assert_(wsize==msize); 203 202 204 203 int count=0; 205 204 for (int i=0;i<msize;i++){ 206 205 misfit_t += pow(model[i]-observation[i],2)*weights[i]; … … 214 213 215 214 /*Do we lock? i.e. are we at final_time? :*/ 216 215 if(time==finaltime)this->lock=1; 217 216 218 217 /*Free ressources:*/ 219 218 xDelete<IssmDouble>(model); 220 219 xDelete<IssmDouble>(observation); … … 226 225 227 226 } /*}}}*/ 228 227 else{ /*global computation: {{{ */ 229 228 230 229 IssmDouble model, observation; 231 230 232 231 /*If we are locked, return time average: */ 233 232 if(this->lock)return misfit/(time-starttime); 234 233 … … 238 237 Element* element=(Element*)femmodel->elements->GetObjectByOffset(0); _assert_(element); 239 238 Input* input = element->GetInput(observation_enum); _assert_(input); 240 239 input->GetInputAverage(&observation); 241 240 242 241 /*Add this time's contribution to curent misfit: */ 243 242 misfit+=dt*(model-observation); 244 243 245 244 /*Do we lock? i.e. are we at final_time? :*/ 246 245 if(time==finaltime)this->lock=1; 247 246 248 247 /*What we return is the value of misfit / time: */ 249 248 return misfit/(time-starttime); 250 249 } /*}}}*/ -
../trunk-jpl/src/c/datastructures/DataSet.cpp
91 91 92 92 /*Specific methods*/ 93 93 void DataSet::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 94 94 95 95 vector<Object*>::iterator obj; 96 96 int obj_size=0; 97 97 int obj_enum=0; -
../trunk-jpl/src/c/analyses/BalancethicknessAnalysis.cpp
593 593 xDelete<int>(responses); 594 594 delete gauss; 595 595 596 597 596 }/*}}}*/ 598 597 void BalancethicknessAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 599 598 -
../trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.cpp
260 260 basis,1,numnodes,0, 261 261 &Ke->values[0],1); 262 262 263 264 263 /*Transfer EPL part*/ 265 264 transfer=GetHydrologyKMatrixTransfer(basalelement); 266 265 D_scalar=dt*transfer*gauss->weight*Jdet; -
../trunk-jpl/src/c/analyses/AdjointHorizAnalysis.cpp
1152 1152 1153 1153 /*Clean up and return*/ 1154 1154 xDelete<int>(responses); 1155 1155 1156 1156 }/*}}}*/ 1157 1157 void AdjointHorizAnalysis::GradientJBbarFS(Element* element,Vector<IssmDouble>* gradient,int control_index){/*{{{*/ 1158 1158 /*WARNING: We use SSA as an estimate for now*/ … … 2111 2111 IssmDouble vx,vy,lambda,mu; 2112 2112 IssmDouble *xyz_list= NULL; 2113 2113 2114 2115 2114 /*Fetch number of vertices for this finite element*/ 2116 2115 int numvertices = basalelement->GetNumberOfVertices(); 2117 2116 … … 2131 2130 Input* adjointx_input = basalelement->GetInput(AdjointxEnum); _assert_(adjointx_input); 2132 2131 Input* adjointy_input = basalelement->GetInput(AdjointyEnum); _assert_(adjointy_input); 2133 2132 2134 2135 2136 2133 IssmDouble q_exp; 2137 2134 IssmDouble C_param; 2138 2135 IssmDouble As; … … 2181 2178 vmag = sqrt(vx*vx + vy*vy); 2182 2179 Chi = vmag/(pow(C_param,n)*pow(Neff,n)*As); 2183 2180 Gamma = (Chi/(1.+alpha*pow(Chi,q_exp))); 2184 2181 2185 2182 Uder =Neff*C_param/(vmag*vmag*n) * 2186 2183 (Gamma-alpha*q_exp*pow(Chi,q_exp-1.)*Gamma*Gamma* pow(Gamma,(1.-n)/n) - 2187 2184 n* pow(Gamma,1./n)); 2188 2185 2189 2186 /*Build gradient vector (actually -dJ/dD): */ 2190 2187 for(int i=0;i<numvertices;i++){ 2191 2188 ge[i]+=-dalpha2dk*((lambda*vx+mu*vy))*Jdet*gauss->weight*basis[i]; … … 2318 2315 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 2319 2316 } 2320 2317 2321 2322 2318 /*Fetch number of nodes and dof for this finite element*/ 2323 2319 int vnumnodes = element->NumberofNodesVelocity(); 2324 2320 int pnumnodes = element->NumberofNodesPressure(); -
../trunk-jpl/src/c/analyses/LevelsetAnalysis.cpp
42 42 counter++; 43 43 } 44 44 } 45 45 46 46 iomodel->FetchDataToInput(elements,"md.mask.ice_levelset",MaskIceLevelsetEnum); 47 47 iomodel->FetchDataToInput(elements,"md.initialization.vx",VxEnum); 48 48 iomodel->FetchDataToInput(elements,"md.initialization.vy",VyEnum); … … 176 176 } 177 177 178 178 /*Calving threshold*/ 179 179 180 180 /*Fetch number of nodes and dof for this finite element*/ 181 181 int numnodes = basalelement->GetNumberOfNodes(); 182 182 … … 325 325 c[i]=0.; m[i]=0.; 326 326 } 327 327 break; 328 328 329 329 case CalvingLevermannEnum: 330 330 calvingratex_input->GetInputValue(&c[0],gauss); 331 331 if(dim==2) calvingratey_input->GetInputValue(&c[1],gauss); … … 356 356 m[i]=0.; 357 357 } 358 358 break; 359 359 360 360 case CalvingHabEnum: 361 361 lsf_slopex_input->GetInputValue(&dlsf[0],gauss); 362 362 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],gauss); … … 377 377 m[i]=0.; 378 378 } 379 379 break; 380 380 381 381 case CalvingCrevasseDepthEnum: 382 382 lsf_slopex_input->GetInputValue(&dlsf[0],gauss); 383 383 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],gauss); … … 384 384 meltingrate_input->GetInputValue(&meltingrate,gauss); 385 385 386 386 if(groundedice<0) meltingrate = 0.; 387 387 388 388 norm_dlsf=0.; 389 389 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2); 390 390 norm_dlsf=sqrt(norm_dlsf); … … 515 515 return Ke; 516 516 }/*}}}*/ 517 517 ElementVector* LevelsetAnalysis::CreatePVector(Element* element){/*{{{*/ 518 518 519 519 if(!element->IsOnBase()) return NULL; 520 520 Element* basalelement = element->SpawnBasalElement(); 521 521 … … 524 524 IssmDouble Jdet,dt; 525 525 IssmDouble lsf; 526 526 IssmDouble* xyz_list = NULL; 527 527 528 528 /*Fetch number of nodes and dof for this finite element*/ 529 529 int numnodes = basalelement->GetNumberOfNodes(); 530 530 … … 531 531 /*Initialize Element vector*/ 532 532 ElementVector* pe = basalelement->NewElementVector(); 533 533 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 534 534 535 535 if(dt!=0.){ 536 536 /*Initialize basis vector*/ 537 537 IssmDouble* basis = xNew<IssmDouble>(numnodes); … … 622 622 // returns distance d of point q to straight going through points s0, s1 623 623 // d=|a x b|/|b| 624 624 // with a=q-s0, b=s1-s0 625 625 626 626 /* Intermediaries */ 627 627 const int dim=2; 628 628 int i; … … 633 633 a[i]=q[i]-s0[i]; 634 634 b[i]=s1[i]-s0[i]; 635 635 } 636 636 637 637 norm_b=0.; 638 638 for(i=0;i<dim;i++) 639 639 norm_b+=b[i]*b[i]; … … 670 670 IssmDouble rho_ice,rho_water; 671 671 IssmDouble bed,water_depth; 672 672 IssmDouble levelset; 673 673 674 674 femmodel->parameters->FindParam(&calvinglaw,CalvingLawEnum); 675 675 676 676 if(calvinglaw==CalvingMinthicknessEnum){ … … 702 702 delete gauss; 703 703 } 704 704 } 705 705 706 706 if(calvinglaw==CalvingHabEnum){ 707 707 708 708 /*Get the fraction of the flotation thickness at the terminus*/ 709 709 femmodel->elements->InputDuplicate(MaskIceLevelsetEnum, DistanceToCalvingfrontEnum); 710 710 femmodel->DistanceToFieldValue(MaskIceLevelsetEnum,0,DistanceToCalvingfrontEnum); 711 711 712 712 /*Loop over all elements of this partition*/ 713 713 for(int i=0;i<femmodel->elements->Size();i++){ 714 714 Element* element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 715 715 716 716 rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 717 717 rho_water = element->GetMaterialParameter(MaterialsRhoSeawaterEnum); 718 718 … … 743 743 delete gauss; 744 744 } 745 745 } 746 746 747 747 if(calvinglaw==CalvingCrevasseDepthEnum){ 748 748 749 749 int nflipped,local_nflipped; 750 750 Vector<IssmDouble>* vec_constraint_nodes = NULL; 751 751 IssmDouble* constraint_nodes = NULL; 752 752 753 753 /*Get the DistanceToCalvingfront*/ 754 754 femmodel->elements->InputDuplicate(MaskIceLevelsetEnum,DistanceToCalvingfrontEnum); 755 755 femmodel->DistanceToFieldValue(MaskIceLevelsetEnum,0,DistanceToCalvingfrontEnum); … … 841 841 for(int in=0;in<numnodes;in++){ 842 842 gauss->GaussNode(element->GetElementType(),in); 843 843 Node* node=element->GetNode(in); 844 844 845 845 if(constraint_nodes[node->Sid()]>0.){ 846 846 node->ApplyConstraint(0,+1.); 847 847 } -
../trunk-jpl/src/c/analyses/StressbalanceVerticalAnalysis.cpp
29 29 else 30 30 iscoupling = false; 31 31 32 33 32 /*If no coupling, call Regular IoModelToConstraintsx, else, use P1 elements only*/ 34 33 if(!iscoupling){ 35 34 IoModelToConstraintsx(constraints,iomodel,"md.stressbalance.spcvz",StressbalanceVerticalAnalysisEnum,P1Enum,0); … … 158 157 }/*}}}*/ 159 158 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrixBase(Element* element){/*{{{*/ 160 159 161 162 160 if(!element->IsOnBase()) return NULL; 163 161 164 162 /*Intermediaries*/ … … 199 197 }/*}}}*/ 200 198 ElementMatrix* StressbalanceVerticalAnalysis::CreateKMatrixSurface(Element* element){/*{{{*/ 201 199 202 203 200 if(!element->IsOnSurface()) return NULL; 204 201 205 202 /*Intermediaries*/ -
../trunk-jpl/src/c/analyses/HydrologyShaktiAnalysis.cpp
294 294 B_input->GetInputValue(&B,gauss); 295 295 n_input->GetInputValue(&n,gauss); 296 296 A=pow(B,-n); 297 297 298 298 /*Compute beta term*/ 299 299 if(gap<br) 300 300 beta = (br-gap)/lr; … … 323 323 324 324 meltrate = 1/latentheat*(G+frictionheat+rho_water*g*conductivity*(dh[0]*dh[0]+dh[1]*dh[1])-PMPheat); 325 325 _assert_(meltrate>0.); 326 326 327 327 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight* 328 328 ( 329 329 meltrate*(1/rho_water-1/rho_ice) … … 397 397 398 398 /*Calculate effective pressure*/ 399 399 eff_pressure[i] = rho_ice*g*thickness[i] - rho_water*g*(values[i]-bed[i]); 400 400 401 401 if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector"); 402 402 if(xIsInf<IssmDouble>(values[i])) _error_("Inf found in solution vector"); 403 403 } … … 443 443 Input* gap_input = element->GetInput(HydrologyGapHeightEnum); _assert_(gap_input); 444 444 reynolds_input->GetInputAverage(&reynolds); 445 445 gap_input->GetInputAverage(&gap); 446 446 447 447 /*Compute conductivity*/ 448 448 IssmDouble conductivity = pow(gap,3)*g/(12.*NU*(1+OMEGA*reynolds)); 449 449 _assert_(conductivity>0); … … 453 453 }/*}}}*/ 454 454 void HydrologyShaktiAnalysis::UpdateGapHeight(FemModel* femmodel){/*{{{*/ 455 455 456 457 456 for(int j=0;j<femmodel->elements->Size();j++){ 458 457 Element* element=(Element*)femmodel->elements->GetObjectByOffset(j); 459 458 UpdateGapHeight(element); … … 546 545 IssmDouble pressure_ice = rho_ice*g*thickness; _assert_(pressure_ice>0.); 547 546 IssmDouble pressure_water = rho_water*g*(head-bed); 548 547 if(pressure_water>pressure_ice) pressure_water = pressure_ice; 549 548 550 549 /* Compute change in sensible heat due to changes in pressure melting point*/ 551 550 dpressure_water[0] = rho_water*g*(dh[0] - dbed[0]); 552 551 dpressure_water[1] = rho_water*g*(dh[1] - dbed[1]); … … 580 579 581 580 /*Add new gap as an input*/ 582 581 element->AddInput(HydrologyGapHeightEnum,&newgap,P0Enum); 583 582 584 583 /*Divide by connectivity, add basal flux as an input*/ 585 584 q = q/totalweights; 586 585 element->AddInput(HydrologyBasalFluxEnum,&q,P0Enum); -
../trunk-jpl/src/c/analyses/EsaAnalysis.cpp
39 39 int nl; 40 40 IssmDouble* love_h=NULL; 41 41 IssmDouble* love_l=NULL; 42 42 43 43 IssmDouble* U_elastic = NULL; 44 44 IssmDouble* U_elastic_local = NULL; 45 45 IssmDouble* H_elastic = NULL; … … 68 68 M=reCast<int,IssmDouble>(180./degacc+1.); 69 69 U_elastic=xNew<IssmDouble>(M); 70 70 H_elastic=xNew<IssmDouble>(M); 71 71 72 72 /*compute combined legendre + love number (elastic green function:*/ 73 73 m=DetermineLocalSize(M,IssmComm::GetComm()); 74 74 GetOwnershipBoundariesFromRange(&lower_row,&upper_row,m,IssmComm::GetComm()); … … 95 95 IssmDouble deltalove_U; 96 96 97 97 deltalove_U = (love_h[n]-love_h[nl-1]); 98 98 99 99 /*compute legendre polynomials: P_n(cos\theta) & d P_n(cos\theta)/ d\theta: */ 100 100 if(n==0){ 101 101 Pn=1; … … 198 198 void EsaAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 199 199 /*Default, do nothing*/ 200 200 return; 201 201 202 202 }/*}}}*/ 203 203 void EsaAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 204 204 /*Default, do nothing*/ -
../trunk-jpl/src/c/analyses/SmoothAnalysis.cpp
152 152 default: input = element->GetInput(input_enum); 153 153 } 154 154 155 156 155 /* Start looping on the number of gaussian points: */ 157 156 Gauss* gauss=element->NewGauss(2); 158 157 for(int ig=gauss->begin();ig<gauss->end();ig++){ … … 161 160 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 162 161 element->NodalFunctions(basis,gauss); 163 162 164 165 163 switch(input_enum){ 166 164 case DrivingStressXEnum: 167 165 case DrivingStressYEnum:{ -
../trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp
164 164 } 165 165 iomodel->FetchDataToInput(elements,"md.initialization.vx",VxEnum); 166 166 iomodel->FetchDataToInput(elements,"md.initialization.vy",VyEnum); 167 167 168 168 /*Initialize cumdeltalthickness input*/ 169 169 InputUpdateFromConstantx(elements,0.,SealevelriseCumDeltathicknessEnum); 170 170 … … 202 202 iomodel->FetchDataToInput(elements,"md.mesh.vertexonbase",MeshVertexonbaseEnum); 203 203 iomodel->FetchDataToInput(elements,"md.mesh.vertexonsurface",MeshVertexonsurfaceEnum); 204 204 } 205 205 206 206 }/*}}}*/ 207 207 void MasstransportAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 208 208 … … 220 220 parameters->AddObject(new IntParam(MasstransportNumRequestedOutputsEnum,numoutputs)); 221 221 if(numoutputs)parameters->AddObject(new StringArrayParam(MasstransportRequestedOutputsEnum,requestedoutputs,numoutputs)); 222 222 iomodel->DeleteData(&requestedoutputs,numoutputs,"md.masstransport.requested_outputs"); 223 224 225 223 226 224 }/*}}}*/ 227 225 … … 804 802 xDelete<IssmDouble>(phi); 805 803 xDelete<IssmDouble>(sealevel); 806 804 xDelete<IssmDouble>(bed); 807 805 808 806 xDelete<int>(doflist); 809 807 if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;}; 810 808 }/*}}}*/ -
../trunk-jpl/src/c/analyses/SealevelriseAnalysis.cpp
68 68 IssmDouble* love_h=NULL; 69 69 IssmDouble* love_k=NULL; 70 70 IssmDouble* love_l=NULL; 71 71 72 72 bool elastic=false; 73 73 IssmDouble* G_elastic = NULL; 74 74 IssmDouble* G_elastic_local = NULL; … … 131 131 H_elastic=xNew<IssmDouble>(M); 132 132 #endif 133 133 134 135 134 /*compute combined legendre + love number (elastic green function:*/ 136 135 m=DetermineLocalSize(M,IssmComm::GetComm()); 137 136 GetOwnershipBoundariesFromRange(&lower_row,&upper_row,m,IssmComm::GetComm()); … … 167 166 168 167 deltalove_G = (love_k[n]-love_k[nl-1]-love_h[n]+love_h[nl-1]); 169 168 deltalove_U = (love_h[n]-love_h[nl-1]); 170 169 171 170 /*compute legendre polynomials: P_n(cos\theta) & d P_n(cos\theta)/ d\theta: */ 172 171 if(n==0){ 173 172 Pn=1; … … 229 228 xDelete<IssmDouble>(H_elastic); 230 229 xDelete<IssmDouble>(H_elastic_local); 231 230 } 232 231 233 232 /*Transitions: */ 234 233 iomodel->FetchData(&transitions,&transitions_M,&transitions_N,&ntransitions,"md.slr.transitions"); 235 234 if(transitions){ … … 249 248 if(numoutputs)parameters->AddObject(new StringArrayParam(SealevelriseRequestedOutputsEnum,requestedoutputs,numoutputs)); 250 249 iomodel->DeleteData(&requestedoutputs,numoutputs,"md.slr.requested_outputs"); 251 250 252 253 251 }/*}}}*/ 254 252 255 253 /*Finite Element Analysis*/ -
../trunk-jpl/src/c/analyses/GLheightadvectionAnalysis.cpp
198 198 xDelete<IssmDouble>(lset); 199 199 } 200 200 201 202 203 201 return; 204 202 }/*}}}*/ 205 203 -
../trunk-jpl/src/c/analyses/HydrologyShreveAnalysis.cpp
378 378 return; 379 379 }/*}}}*/ 380 380 381 382 381 /*Needed changes to switch to the Johnson formulation*//*{{{*/ 383 382 /*All the changes are to be done in the velocity computation. 384 383 The new velocity needs some new parameter that should be introduce in the hydrologyshreve class: -
../trunk-jpl/src/c/analyses/BalancevelocityAnalysis.cpp
199 199 Ny[i] = -H[i]*Ny[i]/norm; 200 200 } 201 201 202 203 202 /* Start looping on the number of gaussian points: */ 204 203 Gauss* gauss=basalelement->NewGauss(2); 205 204 for(int ig=gauss->begin();ig<gauss->end();ig++){ -
../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp
213 213 return NULL; 214 214 } 215 215 216 217 216 /*Intermediaries */ 218 217 bool active_element,isefficientlayer; 219 218 IssmDouble D_scalar,Jdet,dt; … … 503 502 default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet"); 504 503 } 505 504 506 507 505 /*Fetch number of nodes for this finite element*/ 508 506 int numnodes = basalelement->GetNumberOfNodes(); 509 507 -
../trunk-jpl/src/c/analyses/SmbAnalysis.cpp
18 18 return 1; 19 19 }/*}}}*/ 20 20 void SmbAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 21 21 22 22 int smb_model; 23 23 bool isdelta18o,ismungsm,isd18opd,issetpddfac,isprecipscaled,istemperaturescaled; 24 24 25 25 /*Update elements: */ 26 26 int counter=0; 27 27 for(int i=0;i<iomodel->numberofelements;i++){ … … 31 31 counter++; 32 32 } 33 33 } 34 34 35 35 /*Figure out smb model: */ 36 36 iomodel->FindConstant(&smb_model,"md.smb.model"); 37 37 38 38 switch(smb_model){ 39 39 case SMBforcingEnum: 40 40 iomodel->FetchDataToInput(elements,"md.smb.mass_balance",SmbMassBalanceEnum,0.); … … 141 141 default: 142 142 _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet"); 143 143 } 144 145 146 144 147 145 }/*}}}*/ 148 146 void SmbAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ … … 153 151 int smb_model; 154 152 IssmDouble *temp = NULL; 155 153 int N,M; 156 154 157 155 parameters->AddObject(iomodel->CopyConstantObject("md.smb.model",SmbEnum)); 158 156 159 157 iomodel->FindConstant(&smb_model,"md.smb.model"); 160 158 iomodel->FindConstant(&interp,"md.timestepping.interp_forcings"); 161 159 162 160 switch(smb_model){ 163 161 case SMBforcingEnum: 164 162 /*Nothing to add to parameters*/ … … 197 195 iomodel->FetchData(&temp,&N,&M,"md.smb.Pfac"); _assert_(N==2); 198 196 parameters->AddObject(new TransientParam(SmbPfacEnum,&temp[0],&temp[M],interp,M)); 199 197 iomodel->DeleteData(temp,"md.smb.Pfac"); 200 198 201 199 iomodel->FetchData(&temp,&N,&M,"md.smb.Tdiff"); _assert_(N==2); 202 200 parameters->AddObject(new TransientParam(SmbTdiffEnum,&temp[0],&temp[M],interp,M)); 203 201 iomodel->DeleteData(temp,"md.smb.Tdiff"); … … 265 263 266 264 /*Figure out smb model: */ 267 265 femmodel->parameters->FindParam(&smb_model,SmbEnum); 268 266 269 267 /*branch to correct module*/ 270 268 switch(smb_model){ 271 269 case SMBforcingEnum: -
../trunk-jpl/src/c/analyses/DamageEvolutionAnalysis.cpp
125 125 126 126 /*Add input*/ 127 127 element->AddInput(DamageFEnum,f,element->GetElementType()); 128 128 129 129 /*Clean up and return*/ 130 130 xDelete<IssmDouble>(f); 131 131 }/*}}}*/ … … 169 169 Gauss* gauss=element->NewGauss(); 170 170 for (int i=0;i<numnodes;i++){ 171 171 gauss->GaussNode(element->GetElementType(),i); 172 172 173 173 eps_xx_input->GetInputValue(&eps_xx,gauss); 174 174 eps_xy_input->GetInputValue(&eps_xy,gauss); 175 175 eps_yy_input->GetInputValue(&eps_yy,gauss); … … 176 176 B_input->GetInputValue(&B,gauss); 177 177 n_input->GetInputValue(&n,gauss); 178 178 damage_input->GetInputValue(&damage,gauss); 179 179 180 180 /*Calculate principal effective strain rates*/ 181 181 eps1=(eps_xx+eps_yy)/2.+sqrt(pow((eps_xx-eps_yy)/2.,2)+pow(eps_xy,2)); 182 182 eps2=(eps_xx+eps_yy)/2.-sqrt(pow((eps_xx-eps_yy)/2.,2)+pow(eps_xy,2)); … … 194 194 195 195 /*Add input*/ 196 196 element->AddInput(DamageFEnum,f,element->GetElementType()); 197 197 198 198 /*Clean up and return*/ 199 199 xDelete<IssmDouble>(f); 200 200 delete gauss; … … 261 261 Gauss* gauss=element->NewGauss(); 262 262 for (int i=0;i<numnodes;i++){ 263 263 gauss->GaussNode(element->GetElementType(),i); 264 264 265 265 damage_input->GetInputValue(&damage,gauss); 266 266 tau_xx_input->GetInputValue(&tau_xx,gauss); 267 267 tau_xy_input->GetInputValue(&tau_xy,gauss); … … 313 313 } 314 314 /*Add input*/ 315 315 element->AddInput(DamageFEnum,f,element->GetElementType()); 316 316 317 317 /*Clean up and return*/ 318 318 xDelete<IssmDouble>(f); 319 319 delete gauss; … … 374 374 375 375 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 376 376 element->NodalFunctions(basis,gauss); 377 377 378 378 vx_input->GetInputValue(&vx,gauss); 379 379 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 380 380 vy_input->GetInputValue(&vy,gauss); … … 537 537 damaged_input = element->GetInput(DamageDEnum); _assert_(damaged_input); 538 538 } 539 539 540 541 540 /* Start looping on the number of gaussian points: */ 542 541 Gauss* gauss=element->NewGauss(2); 543 542 for(int ig=gauss->begin();ig<gauss->end();ig++){ -
../trunk-jpl/src/c/analyses/Balancethickness2Analysis.cpp
7 7 /*Model processing*/ 8 8 void Balancethickness2Analysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 9 9 10 11 10 int finiteelement = P1Enum; 12 11 IoModelToConstraintsx(constraints,iomodel,"md.balancethickness.spcthickness",Balancethickness2AnalysisEnum,finiteelement); 13 12 -
../trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp
102 102 bool dakota_analysis,ismovingfront,isenthalpy; 103 103 int frictionlaw,basalforcing_model,materialstype; 104 104 int FrictionCoupling; 105 105 106 106 /*Now, is the model 3d? otherwise, do nothing: */ 107 107 if(iomodel->domaintype==Domain2DhorizontalEnum)return; 108 108 … … 188 188 default: 189 189 _error_("not supported"); 190 190 } 191 191 192 192 /*Friction law variables*/ 193 193 switch(frictionlaw){ 194 194 case 1: … … 804 804 805 805 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 806 806 element->NodalFunctions(basis,gauss); 807 807 808 808 /*viscous dissipation*/ 809 809 element->ViscousHeating(&phi,xyz_list,gauss,vx_input,vy_input,vz_input); 810 810 … … 822 822 enthalpypicard_input->GetInputDerivativeValue(&d1enthalpypicard[0],xyz_list,gauss); 823 823 pressure_input->GetInputDerivativeValue(&d1pressure[0],xyz_list,gauss); 824 824 d2pressure=0.; // for linear elements, 2nd derivative is zero 825 825 826 826 d1H_d1P=0.; 827 827 for(i=0;i<3;i++) d1H_d1P+=d1enthalpypicard[i]*d1pressure[i]; 828 828 d1P2=0.; … … 1055 1055 IssmDouble dt; 1056 1056 int* basalnodeindices=NULL; 1057 1057 Element* element= NULL; 1058 1058 1059 1059 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 1060 1060 1061 1061 /*depth-integrate the drained water fraction */ … … 1387 1387 for(int i=0;i<numindices;i++){ 1388 1388 gauss->GaussNode(element->GetElementType(),indices[i]); 1389 1389 gaussup->GaussNode(element->GetElementType(),indicesup[i]); 1390 1390 1391 1391 enthalpy_input->GetInputValue(&enthalpy,gauss); 1392 1392 enthalpy_input->GetInputValue(&enthalpyup,gaussup); 1393 1393 pressure_input->GetInputValue(&pressure,gauss); -
../trunk-jpl/src/c/analyses/ExtrapolationAnalysis.cpp
144 144 workelement->JacobianDeterminant(&Jdet,xyz_list,gauss); 145 145 GetB(B,workelement,xyz_list,gauss,dim); 146 146 GetBprime(Bprime,workelement,xyz_list,gauss,dim); 147 147 148 148 D_scalar=gauss->weight*Jdet; 149 149 150 150 if(extrapolatebydiffusion){ … … 173 173 for(i=0;i<dim;i++) normal[i]=dlsf[i]/norm_dlsf; 174 174 else 175 175 for(i=0;i<dim;i++) normal[i]=0.; 176 176 177 177 for(row=0;row<dim;row++) 178 178 for(col=0;col<dim;col++) 179 179 if(row==col) … … 336 336 337 337 /* Get parameters */ 338 338 element->FindParam(&extvar_enum, ExtrapolationVariableEnum); 339 339 340 340 Input* active_input=element->GetInput(IceMaskNodeActivationEnum); _assert_(active_input); 341 341 Input* extvar_input=element->GetInput(extvar_enum); _assert_(extvar_input); 342 342 -
../trunk-jpl/src/c/main/issm_slr.cpp
27 27 28 28 /*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/ 29 29 worldcomm=EnvironmentInit(argc,argv); 30 30 31 31 /*What is my rank?:*/ 32 32 ISSM_MPI_Comm_rank(worldcomm,&my_rank); 33 33 … … 39 39 rankzeros=xNew<int>(nummodels); 40 40 for(int i=0;i<nummodels;i++){ 41 41 char* string=NULL; 42 42 43 43 string=xNew<char>(strlen(argv[5+3*i])+1); 44 44 xMemCpy<char>(string,argv[5+3*i],strlen(argv[5+3*i])+1); 45 45 dirnames[i]=string; 46 46 47 47 string=xNew<char>(strlen(argv[5+3*i+1])+1); 48 48 xMemCpy<char>(string,argv[5+3*i+1],strlen(argv[5+3*i+1])+1); 49 49 modelnames[i]=string; … … 93 93 94 94 /*Initialize femmodel from arguments provided command line: */ 95 95 FemModel *femmodel = new FemModel(4,arguments,modelcomm); 96 96 97 97 /*Now that the models are initialized, keep communicator information in the parameters datasets of each model: */ 98 98 femmodel->parameters->AddObject(new GenericParam<ISSM_MPI_Comm>(worldcomm,WorldCommEnum)); 99 99 femmodel->parameters->AddObject(new IntParam(NumModelsEnum,nummodels)); -
../trunk-jpl/src/c/main/issm_dakota.cpp
15 15 16 16 int main(int argc,char **argv){ 17 17 18 19 18 #if defined(_HAVE_DAKOTA_) && _DAKOTA_MAJOR_ >= 6 20 19 21 20 bool parallel=true; … … 28 27 29 28 /*Initialize MPI: */ 30 29 ISSM_MPI_Init(&argc, &argv); // initialize MPI 31 30 32 31 /*Recover file name for dakota input file:*/ 33 32 dakota_input_file=xNew<char>((strlen(argv[2])+strlen(argv[3])+strlen(".qmu.in")+2)); 34 33 sprintf(dakota_input_file,"%s/%s%s",argv[2],argv[3],".qmu.in"); 35 34 36 35 dakota_output_file=xNew<char>((strlen(argv[2])+strlen(argv[3])+strlen(".qmu.out")+2)); 37 36 sprintf(dakota_output_file,"%s/%s%s",argv[2],argv[3],".qmu.out"); 38 37 … … 56 55 << std::endl; 57 56 Dakota::abort_handler(-1); 58 57 } 59 58 60 59 Dakota::ProblemDescDB& problem_db = env.problem_description_db(); 61 60 Dakota::ModelLIter ml_iter; 62 61 size_t model_index = problem_db.get_db_model_node(); // for restoration -
../trunk-jpl/src/c/main/issm_ocean.cpp
21 21 22 22 /*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/ 23 23 worldcomm=EnvironmentInit(argc,argv); 24 24 25 25 /*What is my rank?:*/ 26 26 ISSM_MPI_Comm_rank(worldcomm,&my_rank); 27 27 ISSM_MPI_Comm_size(worldcomm,&my_size); … … 38 38 ISSM_MPI_Intercomm_create( modelcomm, 0, worldcomm, my_local_size, 0, &tomitgcmcomm); 39 39 40 40 FemModel *femmodel = new FemModel(argc,argv,modelcomm); 41 41 42 42 /*Now that the models are initialized, keep communicator information in the parameters datasets of each model: */ 43 43 femmodel->parameters->AddObject(new GenericParam<ISSM_MPI_Comm>(worldcomm,WorldCommEnum)); 44 44 femmodel->parameters->AddObject(new GenericParam<ISSM_MPI_Comm>(tomitgcmcomm,ToMITgcmCommEnum)); -
../trunk-jpl/src/c/main/esmfbinders.cpp
2 2 * \brief: ESMF binders for ISSM. Binders developed initially for the GEOS-5 framework. 3 3 */ 4 4 5 6 5 #include "./issm.h" 7 6 8 7 /*GCM specific declarations:*/ … … 35 34 36 35 /*Some specific code here for the binding: */ 37 36 femmodel->parameters->SetParam(SMBgcmEnum,SmbEnum); //bypass SMB model, will be provided by GCM! 38 37 39 38 /*Restart file: */ 40 39 femmodel->Restart(); 41 40 … … 112 111 { 113 112 114 113 IssmDouble surface; 115 114 116 115 /*Recover surface from the ISSM element: */ 117 116 Input* surface_input = element->GetInput(SurfaceEnum); _assert_(surface_input); 118 117 surface_input->GetInputAverage(&surface); 119 118 120 119 *(issmoutputs+f*numberofelements+i) = surface; 121 120 122 121 } … … 146 145 147 146 /*Output results: */ 148 147 OutputResultsx(femmodel); 149 148 150 149 /*Check point: */ 151 150 femmodel->CheckPoint(); 152 151 -
../trunk-jpl/src/c/bamg/BamgQuadtree.cpp
284 284 int xiv = b->v[k]->i.x; 285 285 int yiv = b->v[k]->i.y; 286 286 287 288 287 int h0 = Norm(xi2,xiv,yi2,yiv); 289 288 290 289 /*is it smaller than previous value*/ -
../trunk-jpl/src/c/bamg/Mesh.cpp
500 500 int* connectivitysize_1=NULL; 501 501 int connectivitymax_1=0; 502 502 int verbose=0; 503 503 504 504 /*Check needed pointer*/ 505 505 _assert_(bamgmesh); 506 506 … … 1033 1033 // ---------------- ! 1034 1034 // s0 tt2 s1 1035 1035 //------------------------------- 1036 1036 1037 1037 /*Intermediaries*/ 1038 1038 Triangle* tt[3]; //the three triangles 1039 1039 long long det3local[3]; //three determinants (integer) … … 1157 1157 1158 1158 int verbose=0; 1159 1159 double lminaniso = 1./ (Max(hminaniso*hminaniso,1e-100)); 1160 1160 1161 1161 //Get options 1162 1162 if(bamgopts) verbose=bamgopts->verbose; 1163 1163 1164 1164 //display info 1165 1165 if (verbose > 1) _printf_(" BoundAnisotropy by " << anisomax << "\n"); 1166 1166 … … 1853 1853 1854 1854 /*Check pointer*/ 1855 1855 _assert_(bamgopts); 1856 1856 1857 1857 /*Recover options*/ 1858 1858 verbose=bamgopts->verbose; 1859 1859 NbJacobi=bamgopts->nbjacobi; … … 2727 2727 long k0=this->RandomNumber(nbv); 2728 2728 if (verbose>4) _printf_(" Prime Number = "<<PrimeNumber<<"\n"); 2729 2729 if (verbose>4) _printf_(" k0 = "<<k0<<"\n"); 2730 2730 2731 2731 //Build orderedvertices 2732 2732 for (i=0; i<nbv; i++){ 2733 2733 orderedvertices[i]=&vertices[k0=(k0+PrimeNumber)%nbv]; … … 2952 2952 /*}}}*/ 2953 2953 void Mesh::MaxSubDivision(BamgOpts* bamgopts,double maxsubdiv) {/*{{{*/ 2954 2954 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/MaxSubDivision)*/ 2955 2955 2956 2956 /*Intermediaries*/ 2957 2957 int verbose=0; 2958 2958 … … 3739 3739 /*}}}*/ 3740 3740 void Mesh::SmoothingVertex(BamgOpts* bamgopts,int nbiter,double omega ) { /*{{{*/ 3741 3741 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/SmoothingVertex)*/ 3742 3742 3743 3743 /*Intermediaries*/ 3744 3744 int verbose=0; 3745 3745 3746 3746 /*Get options*/ 3747 3747 if(bamgopts) verbose=bamgopts->verbose; 3748 3748 … … 3784 3784 /*}}}*/ 3785 3785 void Mesh::SmoothMetric(BamgOpts* bamgopts,double raisonmax) { /*{{{*/ 3786 3786 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Metric.cpp/SmoothMetric)*/ 3787 3787 3788 3788 /*Intermediaries*/ 3789 3789 int verbose=0; 3790 3790 … … 4086 4086 int verbose=0; 4087 4087 int i; 4088 4088 Metric M1(1); 4089 4089 4090 4090 /*Get options*/ 4091 4091 if(bamgopts) verbose=bamgopts->verbose; 4092 4092 -
../trunk-jpl/src/c/shared/Elements/Paterson.cpp
15 15 /*Switch to celsius from Kelvin: */ 16 16 T=temperature-273.15; 17 17 18 19 18 if(T<=-45.0){ 20 19 B=1.e+8*(-0.000292866376675*pow(T+50.,3)+ 0.011672640664130*pow(T+50.,2) -0.325004442485481*(T+50.)+ 6.524779401948101); 21 20 } -
../trunk-jpl/src/c/shared/Elements/ComputeMungsmTemperaturePrecipitation.cpp
15 15 IssmDouble monthlytemperaturestmp[12],monthlyprectmp[12]; 16 16 IssmDouble tdiffh; 17 17 18 19 18 for (int imonth = 0; imonth<12; imonth++){ 20 19 tdiffh = TdiffTime*( TemperaturesLgm[imonth] - TemperaturesPresentday[imonth] ); 21 20 monthlytemperaturestmp[imonth] = tdiffh + TemperaturesPresentday[imonth] ; … … 28 27 } 29 28 // printf(" tempera %f\n",monthlytemperaturestmp[1]); 30 29 } 31 -
../trunk-jpl/src/c/shared/Elements/EstarComponents.cpp
65 65 66 66 /*Get norm of epsprime*/ 67 67 epsprime_norm = sqrt(epsprime[0]*epsprime[0] + epsprime[1]*epsprime[1] + epsprime[2]*epsprime[2]); 68 68 69 69 /*Assign output pointers*/ 70 70 *pepsprime_norm=epsprime_norm; 71 71 }/*}}}*/ -
../trunk-jpl/src/c/shared/Elements/ComputeD18OTemperaturePrecipitationFromPD.cpp
10 10 bool isPrecipScaled, IssmDouble f, IssmDouble* PrecipitationPresentday,IssmDouble* TemperaturePresentday, 11 11 IssmDouble* PrecipitationReconstructed,IssmDouble* TemperatureReconstructed, IssmDouble* monthlytemperaturesout, 12 12 IssmDouble* monthlyprecout){ 13 13 14 14 IssmDouble monthlytemperaturestmp[12],monthlyprectmp[12]; 15 15 IssmDouble deltaTemp; 16 16 17 17 /* Constants */ 18 18 // dpermil = 2.4;/*degrees C per mil*/ 19 19 20 20 /*Create Delta Temp to be applied to monthly temps and used in precip scaling*/ 21 21 deltaTemp = dpermil * (d018+34.83); 22 22 23 23 for (int imonth = 0; imonth<12; imonth++){ 24 24 25 25 if (isTemperatureScaled)monthlytemperaturestmp[imonth] = TemperaturePresentday[imonth] + deltaTemp; 26 26 else{ 27 27 monthlytemperaturestmp[imonth] = TemperatureReconstructed[imonth]; … … 30 30 31 31 if (isPrecipScaled)monthlyprectmp[imonth] = PrecipitationPresentday[imonth]*exp((f/dpermil)*deltaTemp); 32 32 else monthlyprectmp[imonth] = PrecipitationReconstructed[imonth]; 33 33 34 34 /*Assign output pointer*/ 35 35 *(monthlytemperaturesout+imonth) = monthlytemperaturestmp[imonth]; 36 36 *(monthlyprecout+imonth) = monthlyprectmp[imonth]; -
../trunk-jpl/src/c/shared/Elements/DrainageFunctionWaterfraction.cpp
18 18 /*get drainage function value*/ 19 19 if((w0==w1)||(w1==w2)||(w0==w2)) 20 20 _error_("Error: equal ordinates in DrainageFunctionWaterfraction -> division by zero. Abort"); 21 21 22 22 if(waterfraction<=w0) 23 23 Dret=D0; 24 24 else if((waterfraction>w0) && (waterfraction<=w1)) -
../trunk-jpl/src/c/shared/Elements/PddSurfaceMassBalance.cpp
82 82 // seasonal loop 83 83 for (iqj = 0; iqj < 12; iqj++){ 84 84 imonth = ismon[iqj]; 85 85 86 86 /*********compute lapse rate ****************/ 87 87 st=(s-s0t)/1000.; 88 88 rtlaps=TdiffTime*rlapslgm + (1.-TdiffTime)*rlaps; // lapse rate 89 89 90 90 /*********compute Surface temperature *******/ 91 91 monthlytemperatures[imonth]=monthlytemperatures[imonth] - rtlaps *max(st,sealevTime*0.001); 92 92 tstar = monthlytemperatures[imonth]; … … 98 98 if (tstar >= -siglimc){ pd = pds[reCast<int,IssmDouble>(tstar/DT + siglim0c)];}} 99 99 else { 100 100 pd = 0.;} 101 101 102 102 /******exp des/elev precip reduction*******/ 103 103 sp=(s-s0p)/1000.-deselcut; // deselev effect is wrt chng in topo 104 104 if (sp>0.0){q = exp(-desfac*sp);} 105 105 else {q = 1.0;} 106 106 107 107 qmt= qmt + monthlyprec[imonth]*sconv; //*sconv to convert in m of ice equivalent per month 108 108 qmpt= q*monthlyprec[imonth]*sconv; 109 109 qmp= qmp + qmpt; … … 113 113 // ndd(month)=-(tstar-pdd(month)) since ndd+pdd gives expectation of 114 114 // gaussian=T_m, so ndd=-(Tsurf-pdd) 115 115 if (iqj>5 && iqj<9){ Tsum=Tsum+tstar;} 116 116 117 117 if (tstar >= siglim) {pdd = pdd + tstar*deltm;} 118 118 else if (tstar> -siglim){ 119 119 pddsig=pdds[reCast<int,IssmDouble>(tstar/DT + siglim0)]; … … 120 120 pdd = pdd + pddsig*deltm; 121 121 frzndd = frzndd - (tstar-pddsig)*deltm;} 122 122 else{frzndd = frzndd - tstar*deltm; } 123 123 124 124 /*Assign output pointer*/ 125 125 *(monthlytemperatures+imonth) = monthlytemperatures[imonth]; 126 126 *(monthlyprec+imonth) = monthlyprec[imonth]; … … 149 149 icefac=pddicefac; 150 150 } 151 151 } 152 152 153 153 /***** determine PDD factors *****/ 154 154 if(Tsum< -1.) { 155 155 snwmf=(2.65+snowfac-pddsnowfac0)*0.001; // ablation factor for snow per positive degree day.*0.001 to go from mm to m/ppd … … 165 165 } 166 166 snwmf=0.95*snwmf; 167 167 smf=0.95*smf; 168 168 169 169 /***** compute PDD ablation and refreezing *****/ 170 170 pddt = pdd *365; 171 171 snwm = snwmf*pddt; // snow that could have been melted in a year 172 172 hmx2 = min(h,dfrz); // refreeze active layer max depth: dfrz 173 173 174 174 if(snwm < saccu) { 175 175 water=prect-saccu + snwm; //water=rain + snowmelt 176 176 // l 2.2= capillary factor -
../trunk-jpl/src/c/shared/Numerics/legendre.cpp
120 120 v(1:m,2) = x; 121 121 122 122 for i = 2 : n 123 123 124 124 v(:,i+1) = ( ( 2 * i - 1 ) * x .* v(:,i) ... 125 125 - ( i - 1 ) * v(:,i-1) ) ... 126 126 / ( i ); 127 127 128 128 end 129 129 }}} */ 130 130 … … 239 239 Output, double P_POLYNOMIAL_VALUE[M*(N+1)], the values of the Legendre 240 240 polynomials of order 0 through N. 241 241 }}}*/ 242 242 243 243 int i,j; 244 244 245 245 if(n<0) return NULL; … … 253 253 254 254 for ( i = 0; i < m; i++ ) { 255 255 for ( j = 2; j <= n; j++ ) { 256 256 257 257 v[j+i*(n+1)] = ( ( IssmDouble ) ( 2 * j - 1 ) * x[i] * v[(j-1)+i*(n+1)] 258 258 - ( IssmDouble ) ( j - 1 ) * v[(j-2)+i*(n+1)] ) 259 259 / ( IssmDouble ) ( j ); -
../trunk-jpl/src/c/shared/Numerics/BrentSearch.cpp
67 67 /*Get current Gradient at xmin=0*/ 68 68 _printf0_(" x = "<<setw(9)<<xmin<<" | "); 69 69 fxmin = (*g)(&G,X0,usr); if(xIsNan<IssmDouble>(fxmin)) _error_("Function evaluation returned NaN"); 70 70 71 71 /*Get f(xmax)*/ 72 72 _printf0_(" x = "<<setw(9)<<xmax<<" | "); 73 73 for(int i=0;i<nsize;i++) X[i]=X0[i]+xmax*G[i]; … … 243 243 xDelete<IssmDouble>(G); 244 244 J[n]=fxbest; 245 245 } 246 246 247 247 /*return*/ 248 248 xDelete<IssmDouble>(X); 249 249 *pJ=J; -
../trunk-jpl/src/c/shared/Matrix/MatrixUtils.cpp
62 62 else{ 63 63 dtemp = &dtemp_static[0]; 64 64 } 65 65 66 66 /* perform the matrix triple product in the order that minimizes the 67 67 number of multiplies and the temporary space used, noting that 68 68 (a*b)*c requires ac(b+d) multiplies and ac IssmDoubles, and a*(b*c) … … 334 334 /*Compute determinant*/ 335 335 Matrix2x2Determinant(&det,A); 336 336 if (fabs(det) < DBL_EPSILON) _error_("Determinant smaller than machine epsilon"); 337 337 338 338 /*Multiplication is faster than divsion, so we multiply by the reciprocal*/ 339 339 det_reciprocal = 1./det; 340 340 … … 426 426 *pvx = vx; 427 427 *pvy = vy; 428 428 429 430 429 }/*}}}*/ 431 430 432 431 void Matrix3x3Determinant(IssmDouble* Adet,IssmDouble* A){/*{{{*/ … … 576 575 }/*}}}*/ 577 576 578 577 void newcell(IssmDouble** pcell, IssmDouble newvalue, bool top, int m){ /*{{{*/ 579 578 580 579 IssmDouble* cell=NULL; 581 580 IssmDouble* dummy=NULL; 582 581 583 582 /*recover pointer: */ 584 583 cell=*pcell; 585 584 586 585 /*reallocate:*/ 587 586 dummy=xNew<IssmDouble>(m+1); 588 587 589 588 /*copy data:*/ 590 589 if(top){ 591 590 dummy[0]=newvalue; … … 595 594 dummy[m]=newvalue; 596 595 for(int i=0;i<m;i++)dummy[i]=cell[i]; 597 596 } 598 597 599 598 /*delete and reassign: */ 600 599 xDelete<IssmDouble>(cell); cell=dummy; 601 600 602 601 /*assign output pointer:*/ 603 602 *pcell=cell; 604 603 } /*}}}*/ … … 614 613 615 614 /*input: */ 616 615 IssmDouble* cell=*pcell; 617 616 618 617 /*output: */ 619 618 IssmDouble* newcell=xNew<IssmDouble>(nind); 620 619 … … 621 620 for(int i=0;i<nind;i++){ 622 621 newcell[i]=cell[indices[i]]; 623 622 } 624 623 625 624 /*free allocation:*/ 626 625 xDelete<IssmDouble>(cell); 627 626 … … 632 631 633 632 /*input: */ 634 633 IssmDouble* cell=*pcell; 635 634 636 635 /*output: */ 637 636 IssmDouble* newcell=xNew<IssmDouble>(m+1); 638 637 … … 640 639 newcell[i]=scale*cell[i]; 641 640 newcell[i+1]=scale* cell[i]; 642 641 for(int j=i+2;j<m+1;j++)newcell[j]=cell[j-1]; 643 642 644 643 /*free allocation:*/ 645 644 xDelete<IssmDouble>(cell); 646 645 … … 661 660 celllist[x]= va_arg ( arguments, IssmDouble*); 662 661 } 663 662 va_end ( arguments ); 664 663 665 664 _printf_("Echo of cell: \n"); 666 665 for(int i=0;i<m;i++){ 667 666 _printf_(i << ": "); -
../trunk-jpl/src/c/classes/Materials/Matpar.cpp
58 58 lithosphere_density = 0; 59 59 mantle_shear_modulus = 0; 60 60 mantle_density = 0; 61 61 62 62 earth_density = 0; 63 63 64 64 int nnat,dummy; … … 337 337 matpar->lithosphere_density=this->lithosphere_density; 338 338 matpar->mantle_shear_modulus=this->mantle_shear_modulus; 339 339 matpar->mantle_density=this->mantle_density; 340 340 341 341 matpar->earth_density=this->earth_density; 342 342 343 343 return matpar; … … 438 438 MARSHALLING(lithosphere_density); 439 439 MARSHALLING(mantle_shear_modulus); 440 440 MARSHALLING(mantle_density); 441 441 442 442 //slr: 443 443 MARSHALLING(earth_density); 444 444 } -
../trunk-jpl/src/c/classes/Loads/Friction.cpp
195 195 /*Check to prevent dividing by zero if vmag==0*/ 196 196 if(vmag==0. && (s-1.)<0.) alpha_complement=0.; 197 197 else alpha_complement=pow(Neff,r)*pow(vmag,(s-1)); 198 198 199 199 _assert_(!xIsNan<IssmDouble>(alpha_complement)); 200 200 _assert_(!xIsInf<IssmDouble>(alpha_complement)); 201 201 … … 270 270 r=drag_q/drag_p; 271 271 s=1./drag_p; 272 272 273 274 273 /*Get effective pressure*/ 275 274 IssmDouble Neff = EffectivePressure(gauss); 276 275 -
../trunk-jpl/src/c/classes/FemModel.cpp
242 242 char *lockfilename = NULL; 243 243 bool waitonlock = false; 244 244 245 246 245 /*Write lock file if requested: */ 247 246 this->parameters->FindParam(&waitonlock,SettingsWaitonlockEnum); 248 247 this->parameters->FindParam(&lockfilename,LockFileNameEnum); … … 4392 4391 /*Free ressources:*/ 4393 4392 xDelete<IssmDouble>(RSLg_old); 4394 4393 4395 4396 4394 } 4397 4395 /*}}}*/ 4398 4396 void FemModel::SealevelriseElastic(Vector<IssmDouble>* pUp, Vector<IssmDouble>* pNorth, Vector<IssmDouble>* pEast, Vector<IssmDouble>* pRSLg, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius, IssmDouble* xx, IssmDouble* yy, IssmDouble* zz,int loop,int horiz){/*{{{*/ … … 4806 4804 char** poutputbuffer; 4807 4805 size_t* poutputbuffersize; 4808 4806 4809 4810 4807 /*Before we delete the profiler, report statistics for this run: */ 4811 4808 profiler->Stop(TOTAL); //final tagging 4812 4809 _printf0_("\n"); … … 4868 4865 }/*}}}*/ 4869 4866 #endif 4870 4867 4871 4872 4868 #if defined(_HAVE_BAMG_) && !defined(_HAVE_ADOLC_) 4873 4869 void FemModel::ReMeshBamg(int* pnewnumberofvertices,int* pnewnumberofelements,IssmDouble** pnewx,IssmDouble** pnewy,IssmDouble** pnewz,int** pnewelementslist){/*{{{*/ 4874 4870 … … 5245 5241 newx[i] = newxylist[2*i]; 5246 5242 newy[i] = newxylist[2*i+1]; 5247 5243 } 5248 5244 5249 5245 /*Assign the pointers*/ 5250 5246 (*pnewelementslist) = newelementslist; //Matlab indexing 5251 5247 (*pnewx) = newx; -
../trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp
2735 2735 } 2736 2736 } 2737 2737 2738 2739 2738 /*Clean-up*/ 2740 2739 xDelete<IssmDouble>(dbasis); 2741 2740 }/*}}}*/
Note:
See TracBrowser
for help on using the repository browser.