Exemplo n.º 1
0
    def initSSACoefficients(self):
        # Read PISM SSA related state variables
        solver = self.solver

        thickness = solver.thickness
        bed = solver.bed
        enthalpy = solver.enthalpy
        mask = solver.ice_mask
        surface = solver.surface

        # Read in the PISM state variables that are used directly in the SSA solver
        for v in [thickness, bed, enthalpy]:
            v.regrid(self.boot_file, True)

        # variables mask and surface are computed from the geometry previously read
        sea_level = 0  # FIXME setFromOption?
        gc = PISM.GeometryCalculator(sea_level, self.ice, self.config)
        with PISM.util.Access(nocomm=[thickness, bed], comm=[mask, surface]):
            GHOSTS = self.grid.max_stencil_width
            for (i, j) in self.grid.points_with_ghosts(nGhosts=GHOSTS):
                (mask[i, j], surface[i,
                                     j]) = gc.compute(bed[i, j], thickness[i,
                                                                           j])

        # Compute yield stress from PISM state variables
        # (basal melt rate, tillphi, and basal water height)
        grid = self.grid
        bmr = PISM.util.standardBasalMeltRateVec(grid)
        tillphi = PISM.util.standardTillPhiVec(grid)
        Hmelt = PISM.util.standardBasalWaterVec(grid)
        for v in [bmr, tillphi, Hmelt]:
            v.regrid(self.boot_file, True)

        standard_gravity = self.config.get("standard_gravity")
        ice_rho = self.ice.rho
        basal_till = BasalTillStrength(self.grid, ice_rho, standard_gravity)
        basal_till.updateYieldStress(mask, thickness, Hmelt, bmr, tillphi,
                                     solver.tauc)
Exemplo n.º 2
0
    vecs.enthalpy.set(enth0)

    # Build the continent
    bed = vecs.bedrock_altitude
    thickness = vecs.land_ice_thickness

    with PISM.vec.Access(comm=[bed, thickness]):
        for (i, j) in grid.points():
            x = grid.x(i)
            y = grid.y(j)
            (b, t) = geometry(x, y)
            bed[i, j] = b
            thickness[i, j] = t

    # Compute mask and surface elevation from geometry variables.
    gc = PISM.GeometryCalculator(sea_level, grid.ctx().config())
    gc.compute(bed, thickness, vecs.mask, vecs.surface_altitude)

    tauc = vecs.tauc
    mask = vecs.mask
    tauc_free_bedrock = config.get_double('high_tauc')
    with PISM.vec.Access(comm=tauc, nocomm=mask):
        for (i, j) in grid.points():
            tauc[i, j] = stream_tauc(grid.x(i), grid.y(j))

    vecs.vel_ssa_bc.set(0.0)
    no_model_mask = vecs.no_model_mask
    no_model_mask.set(0)
    with PISM.vec.Access(comm=[no_model_mask]):
        for (i, j) in grid.points():
            if (i == 0) or (i == grid.Mx() -
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    # Build the continent
    bed = vecs.bedrock_altitude
    thickness = vecs.land_ice_thickness
    sea_level = vecs.sea_level

    with PISM.vec.Access(comm=[bed, thickness, sea_level]):
        for (i, j) in grid.points():
            x = grid.x(i)
            y = grid.y(j)
            (b, t) = geometry(x, y)
            bed[i, j] = b
            thickness[i, j] = t
            sea_level[i, j] = 0.0

    # Compute mask and surface elevation from geometry variables.
    gc = PISM.GeometryCalculator(grid.ctx().config())
    gc.compute(sea_level, bed, thickness, vecs.mask, vecs.surface_altitude)

    tauc = vecs.tauc
    with PISM.vec.Access(comm=tauc):
        for (i, j) in grid.points():
            tauc[i, j] = stream_tauc(grid.x(i), grid.y(j))

    vecs.vel_ssa_bc.set(0.0)
    no_model_mask = vecs.no_model_mask
    no_model_mask.set(0)
    with PISM.vec.Access(comm=[no_model_mask]):
        for (i, j) in grid.points():
            if (i == 0) or (i == grid.Mx() -
                            1) or (j == 0) or (j == grid.My() - 1):
                no_model_mask[i, j] = 1
Exemplo n.º 5
0
    def _initSSACoefficients(self):
        """Override of :meth:`SSARun._initSSACoefficients` that initializes variables from the
        contents of the input file."""
        # Build the standard thickness, bed, etc
        self._allocStdSSACoefficients()
        self._allocExtraSSACoefficients()

        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.boot_file, True)

        # The SIA model might need the age field.
        if self.config.get_boolean("age.enabled"):
            vecs.age.regrid(self.boot_file, 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)

        if util.fileHasVariable(self.boot_file, 'ssa_driving_stress_x'):
            vecs.ssa_driving_stress_x.regrid(self.boot_file, critical=True)

        if util.fileHasVariable(self.boot_file, 'ssa_driving_stress_y'):
            vecs.ssa_driving_stress_y.regrid(self.boot_file, critical=True)

        # For a regional run we'll need no_model_mask, usurfstore, thkstore
        if self.is_regional:
            vecs.no_model_mask.regrid(self.boot_file, True)

            if util.fileHasVariable(self.boot_file, 'usurfstore'):
                vecs.usurfstore.regrid(self.boot_file, True)
            else:
                vecs.usurfstore.copy_from(vecs.surface_altitude)

            if util.fileHasVariable(self.boot_file, 'thkstore'):
                vecs.thkstore.regrid(self.boot_file, True)
            else:
                vecs.thkstore.copy_from(vecs.land_ice_thickness)

        # Compute yield stress from PISM state variables
        # (basal melt rate, tillphi, and basal water height)
        grid = self.grid

        if self.phi_to_tauc:
            for v in [vecs.bmr, vecs.tillphi, vecs.bwat]:
                v.regrid(self.boot_file, True)
                vecs.add(v)

            if self.is_regional:
                yieldstress = PISM.RegionalDefaultYieldStress(
                    self.modeldata.grid)
            else:
                yieldstress = PISM.MohrCoulombYieldStress(self.modeldata.grid)

            # make sure vecs is locked!
            yieldstress.init()
            yieldstress.set_till_friction_angle(vecs.tillphi)
            yieldstress.update(0, 1)
            vecs.tauc.copy_from(yieldstress.basal_material_yield_stress())
        else:
            vecs.tauc.regrid(self.boot_file, True)

        if self.config.get_boolean('stress_balance.ssa.dirichlet_bc'):
            has_u_ssa_bc = util.fileHasVariable(self.boot_file, 'u_ssa_bc')
            has_v_ssa_bc = util.fileHasVariable(self.boot_file, 'v_ssa_bc')

            if (not has_u_ssa_bc) or (not has_v_ssa_bc):
                PISM.verbPrintf(
                    2, grid.com,
                    "Input file '%s' missing Dirichlet boundary data u/v_ssa_bc;"
                    " using zero default instead." % self.boot_file)
                vecs.vel_ssa_bc.set(0.0)
            else:
                vecs.vel_ssa_bc.regrid(self.boot_file, True)

            if not self.is_regional:
                bc_mask_name = vecs.bc_mask.metadata().get_string("short_name")
                if util.fileHasVariable(self.boot_file, bc_mask_name):
                    vecs.bc_mask.regrid(self.boot_file, True)
                else:
                    PISM.verbPrintf(
                        2, grid.com,
                        "Input file '%s' missing Dirichlet location mask '%s'."
                        "  Default to no Dirichlet locations." %
                        (self.boot_file, bc_mask_name))
                    vecs.bc_mask.set(0)
Exemplo n.º 6
0
vecs = modeldata.vecs

vecs.add(PISM.model.createIceSurfaceVec(grid))
vecs.add(PISM.model.createIceThicknessVec(grid))
vecs.add(PISM.model.createBedrockElevationVec(grid))
vecs.add(PISM.model.createEnthalpyVec(grid))
vecs.add(PISM.model.createIceMaskVec(grid))

# Read in the PISM state variables that are used directly in the SSA solver
for v in [vecs.thk, vecs.topg, vecs.enthalpy]:
    v.regrid(input_file, critical=True)

# variables mask and surface are computed from the geometry previously read
sea_level = 0  # FIXME setFromOption?
gc = PISM.GeometryCalculator(config)
gc.compute(sea_level, vecs.topg, vecs.thk, vecs.mask, vecs.surface_altitude)

# If running in regional mode, load in regional variables
if is_regional:
    vecs.add(PISM.model.createNoModelMask(grid))
    vecs.no_model_mask.regrid(input_file, critical=True)

    if PISM.util.fileHasVariable(input_file, 'usurfstore'):
        vecs.add(PISM.model.createIceSurfaceStoreVec(grid))
        vecs.usurfstore.regrid(input_file, critical=True)
    else:
        vecs.add(vecs.surface, 'usurfstore')

    solver = PISM.SIAFD_Regional
else:
Exemplo n.º 7
0
def compute_mask(sea_level, bed_topography, ice_thickness, mask, surface):
    gc = PISM.GeometryCalculator(ctx.config)
    gc.compute(sea_level, bed_topography, ice_thickness, mask, surface)
Exemplo n.º 8
0
vecs = modeldata.vecs

vecs.add(PISM.model.createIceSurfaceVec(grid))
vecs.add(PISM.model.createIceThicknessVec(grid))
vecs.add(PISM.model.createBedrockElevationVec(grid))
vecs.add(PISM.model.createEnthalpyVec(grid))
vecs.add(PISM.model.createIceMaskVec(grid))

# Read in the PISM state variables that are used directly in the SSA solver
for v in [vecs.thk, vecs.topg, vecs.enthalpy]:
    v.regrid(input_file, critical=True)

# variables mask and surface are computed from the geometry previously read
sea_level = 0  # FIXME setFromOption?
gc = PISM.GeometryCalculator(sea_level, config)
gc.compute(vecs.topg, vecs.thk, vecs.mask, vecs.surface_altitude)

# If running in regional mode, load in regional variables
if is_regional:
    vecs.add(PISM.model.createNoModelMask(grid))
    vecs.no_model_mask.regrid(input_file, critical=True)

    if PISM.util.fileHasVariable(input_file, 'usurfstore'):
        vecs.add(PISM.model.createIceSurfaceStoreVec(grid))
        vecs.usurfstore.regrid(input_file, critical=True)
    else:
        vecs.add(vecs.surface, 'usurfstore')

    solver = PISM.SIAFD_Regional
else: