def _initSSACoefficients(self): """Reads SSA coefficients from the input file. Called from :meth:`PISM.ssa.SSARun.setup`.""" self._allocStdSSACoefficients() # Read PISM SSA related state variables # # Hmmm. A lot of code duplication with SSAFromInputFile._initSSACoefficients. vecs = self.modeldata.vecs thickness = vecs.land_ice_thickness bed = vecs.bedrock_altitude enthalpy = vecs.enthalpy mask = vecs.mask surface = vecs.surface_altitude sea_level = vecs.sea_level sea_level.set(0.0) # Read in the PISM state variables that are used directly in the SSA solver for v in [thickness, bed, enthalpy]: v.regrid(self.input_filename, True) # variables mask and surface are computed from the geometry previously read gc = PISM.GeometryCalculator(self.config) gc.compute(sea_level, bed, thickness, mask, surface) grid = self.grid config = self.modeldata.config # Compute yield stress from PISM state variables # (basal melt rate, tillphi, and basal water height) if they are available file_has_inputs = (PISM.util.fileHasVariable(self.input_filename, 'bmelt') and PISM.util.fileHasVariable(self.input_filename, 'tillwat') and PISM.util.fileHasVariable(self.input_filename, 'tillphi')) if file_has_inputs: bmr = PISM.model.createBasalMeltRateVec(grid) tillphi = PISM.model.createTillPhiVec(grid) tillwat = PISM.model.createBasalWaterVec(grid) for v in [bmr, tillphi, tillwat]: v.regrid(self.input_filename, True) vecs.add(v) # The SIA model might need the age field. if self.config.get_flag("age.enabled"): vecs.age.regrid(self.input_filename, True) hydrology_model = config.get_string("hydrology.model") if hydrology_model == "null": subglacial_hydrology = PISM.NullTransportHydrology(grid) elif hydrology_model == "routing": subglacial_hydrology = PISM.RoutingHydrology(grid) elif hydrology_model == "distributed": subglacial_hydrology = PISM.DistributedHydrology(grid) if self.is_regional: yieldstress = PISM.RegionalDefaultYieldStress(self.modeldata.grid, subglacial_hydrology) else: yieldstress = PISM.MohrCoulombYieldStress(self.modeldata.grid, subglacial_hydrology) # make sure vecs is locked! subglacial_hydrology.init() yieldstress.init() yieldstress.basal_material_yield_stress(vecs.tauc) elif PISM.util.fileHasVariable(self.input_filename, 'tauc'): vecs.tauc.regrid(self.input_filename, critical=True) if PISM.util.fileHasVariable(self.input_filename, 'ssa_driving_stress_x'): vecs.add(PISM.model.createDrivingStressXVec(self.grid)) vecs.ssa_driving_stress_x.regrid(self.input_filename, critical=True) if PISM.util.fileHasVariable(self.input_filename, 'ssa_driving_stress_y'): vecs.add(PISM.model.createDrivingStressYVec(self.grid)) vecs.ssa_driving_stress_y.regrid(self.input_filename, critical=True) # read in the fractional floatation mask vecs.add(PISM.model.createGroundingLineMask(self.grid)) vecs.gl_mask.regrid(self.input_filename, critical=False, default_value=0.0) # set to zero if not found if self.is_regional: vecs.add(PISM.model.createNoModelMaskVec(self.grid), 'no_model_mask') vecs.no_model_mask.regrid(self.input_filename, True) vecs.add(vecs.surface_altitude, 'usurfstore') if self.config.get_flag('stress_balance.ssa.dirichlet_bc'): vecs.add(PISM.model.create2dVelocityVec(self.grid, name='_ssa_bc', desc='SSA velocity boundary condition', intent='intent'), "vel_ssa_bc") has_u_ssa_bc = PISM.util.fileHasVariable(self.input_filename, 'u_ssa_bc') has_v_ssa_bc = PISM.util.fileHasVariable(self.input_filename, 'v_ssa_bc') if (not has_u_ssa_bc) or (not has_v_ssa_bc): PISM.verbPrintf(2, self.grid.com, "Input file '%s' missing Dirichlet boundary data u/v_ssa_bc; using zero default instead." % self.input_filename) vecs.vel_ssa_bc.set(0.) else: vecs.vel_ssa_bc.regrid(self.input_filename, True) if self.is_regional: vecs.add(vecs.no_model_mask, 'bc_mask') else: vecs.add(PISM.model.createBCMaskVec(self.grid), 'bc_mask') bc_mask_name = vecs.bc_mask.metadata().get_string("short_name") if PISM.util.fileHasVariable(self.input_filename, bc_mask_name): vecs.bc_mask.regrid(self.input_filename, True) else: PISM.verbPrintf(2, self.grid.com, "Input file '%s' missing Dirichlet location mask '%s'. Default to no Dirichlet locations." % (self.input_filename, bc_mask_name)) vecs.bc_mask.set(0) if PISM.util.fileHasVariable(self.inv_data_filename, 'vel_misfit_weight'): vecs.add(PISM.model.createVelocityMisfitWeightVec(self.grid)) vecs.vel_misfit_weight.regrid(self.inv_data_filename, True)