tExample.cc - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
 (HTM) git clone git://src.adamsgaard.dk/pism
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       tExample.cc (2262B)
       ---
            1 #include "Example.hh"
            2 
            3 #include "base/util/PISMConfigInterface.hh"
            4 #include "base/util/IceGrid.hh"
            5 #include "base/util/pism_options.hh"
            6 #include "base/util/MaxTimestep.hh"
            7 
            8 namespace pism {
            9 namespace ocean {
           10 
           11 Example::Example(IceGrid::ConstPtr g)
           12   : OceanModel(g) {
           13 
           14   // assume that input.forcing.buffer_size is big enough
           15   m_shelf_melt_rate.create(m_grid, "shelf_base_melt_rate",
           16                            m_config->get_number("input.forcing.buffer_size"));
           17   m_shelf_melt_rate.set_attrs("internal", "shelf base melt rate", "m / second", "");
           18 }
           19 
           20 Example::~Example() {
           21   // empty
           22 }
           23 
           24 void Example::update_impl(double t, double dt) {
           25   m_t  = t;
           26   m_dt = dt;
           27 
           28   m_shelf_melt_rate.update(t, dt);
           29 
           30   // Use mid-point of the interval. (We restricted the time step, so
           31   // the choice of the point within the time step does not matter.)
           32   m_shelf_melt_rate.interp(t + 0.5 * dt);
           33 
           34   // Alternatively one could call. This does not require a time step restriction.
           35   // m_shelf_melt_rate.average(t, dt);
           36 }
           37 
           38 void Example::init_impl() {
           39   m_log->message(2, "* Initializing the example ocean model...\n");
           40 
           41   options::String input_file("-ocean_example_file", "Shelf melt rate input file.");
           42 
           43   if (input_file.is_set()) {
           44     m_log->message(2, "  Reading shelf base melt rate from %s...\n",
           45                    input_file->c_str());
           46 
           47     m_shelf_melt_rate.init(input_file, 0.0, 0.0);
           48   } else {
           49     m_shelf_melt_rate.init_constant(0.0);
           50   }
           51 }
           52 
           53 MaxTimestep Example::max_timestep_impl(double t) const {
           54   // Assume that temporal variations in the melt rate have to be resolved.
           55   return m_shelf_melt_rate.max_timestep(t);
           56 
           57   // Use this to disable the time step restriction
           58   return MaxTimestep("example ocean model");
           59 }
           60 
           61 void Example::shelf_base_temperature_impl(IceModelVec2S &result) const {
           62   // PISM uses MKS. This is obviously wrong, but this just an example.
           63   result.set(273.15);
           64 }
           65 
           66 void Example::sea_level_elevation_impl(double &result) const {
           67   // Also wrong.
           68   result = 0.0;
           69 }
           70 
           71 //! @brief Computes mass flux in [kg m-2 s-1], from assumption that
           72 //! basal heat flux rate converts to mass flux.
           73 void Example::shelf_base_mass_flux_impl(IceModelVec2S &result) const {
           74   result.copy_from(m_shelf_melt_rate);
           75 }
           76 
           77 } // end of namespape ocean
           78 } // end of namespace pism