tSSB_Modifier.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
       ---
       tSSB_Modifier.cc (4194B)
       ---
            1 // Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Constantine Khroulev and Ed Bueler
            2 //
            3 // This file is part of PISM.
            4 //
            5 // PISM is free software; you can redistribute it and/or modify it under the
            6 // terms of the GNU General Public License as published by the Free Software
            7 // Foundation; either version 3 of the License, or (at your option) any later
            8 // version.
            9 //
           10 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
           11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
           12 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
           13 // details.
           14 //
           15 // You should have received a copy of the GNU General Public License
           16 // along with PISM; if not, write to the Free Software
           17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
           18 
           19 #include "SSB_Modifier.hh"
           20 #include "pism/rheology/FlowLawFactory.hh"
           21 #include "pism/rheology/FlowLaw.hh"
           22 #include "pism/util/IceGrid.hh"
           23 #include "pism/util/ConfigInterface.hh"
           24 #include "pism/util/Vars.hh"
           25 #include "pism/stressbalance/StressBalance.hh"
           26 
           27 namespace pism {
           28 namespace stressbalance {
           29 
           30 SSB_Modifier::SSB_Modifier(IceGrid::ConstPtr g)
           31   : Component(g),
           32     m_EC(g->ctx()->enthalpy_converter()),
           33     m_diffusive_flux(m_grid, "diffusive_flux", WITH_GHOSTS, 1),
           34     m_u(m_grid, "uvel", WITH_GHOSTS),
           35     m_v(m_grid, "vvel", WITH_GHOSTS),
           36     m_strain_heating(m_grid, "strainheat", WITHOUT_GHOSTS) {
           37   m_D_max = 0.0;
           38 
           39   m_u.set_attrs("diagnostic", "horizontal velocity of ice in the X direction",
           40                 "m s-1", "m year-1", "land_ice_x_velocity", 0);
           41 
           42   m_v.set_attrs("diagnostic", "horizontal velocity of ice in the Y direction",
           43                 "m s-1", "m year-1", "land_ice_y_velocity", 0);
           44 
           45    // never diff'ed in hor dirs
           46   m_strain_heating.set_attrs("internal",
           47                              "rate of strain heating in ice (dissipation heating)",
           48                              "W m-3", "mW m-3", "", 0);
           49 
           50 
           51   m_diffusive_flux.set_attrs("internal",
           52                              "diffusive (SIA) flux components on the staggered grid",
           53                              "", "", "", 0);
           54 
           55 }
           56 
           57 SSB_Modifier::~SSB_Modifier() {
           58   // empty
           59 }
           60 
           61 void SSB_Modifier::init() {
           62 }
           63 
           64 const IceModelVec2Stag& SSB_Modifier::diffusive_flux() {
           65   return m_diffusive_flux;
           66 }
           67 
           68 //! \brief Get the max diffusivity (for the adaptive time-stepping).
           69 double SSB_Modifier::max_diffusivity() const {
           70   return m_D_max;
           71 }
           72 
           73 const IceModelVec3& SSB_Modifier::velocity_u() const {
           74   return m_u;
           75 }
           76 
           77 const IceModelVec3& SSB_Modifier::velocity_v() const {
           78   return m_v;
           79 }
           80 
           81 const IceModelVec3& SSB_Modifier::volumetric_strain_heating() const {
           82   return m_strain_heating;
           83 }
           84 
           85 std::string SSB_Modifier::stdout_report() const {
           86   return "";
           87 }
           88 
           89 std::shared_ptr<const rheology::FlowLaw> SSB_Modifier::flow_law() const {
           90   return m_flow_law;
           91 }
           92 
           93 void ConstantInColumn::init() {
           94   SSB_Modifier::init();
           95 }
           96 
           97 ConstantInColumn::ConstantInColumn(IceGrid::ConstPtr g)
           98   : SSB_Modifier(g) {
           99   rheology::FlowLawFactory ice_factory("stress_balance.sia.", m_config, m_EC);
          100 
          101   m_flow_law = ice_factory.create();
          102 }
          103 
          104 ConstantInColumn::~ConstantInColumn() {
          105   // empty
          106 }
          107 
          108 
          109 //! \brief Distribute the input velocity throughout the column.
          110 /*!
          111  * Things to update:
          112  * - 3D-distributed horizontal velocity
          113  * - maximum horizontal velocity
          114  * - diffusive ice flux
          115  * - maximum diffusivity
          116  * - strain heating (strain_heating)
          117  */
          118 void ConstantInColumn::update(const IceModelVec2V &sliding_velocity,
          119                               const Inputs &inputs,
          120                               bool full_update) {
          121 
          122   (void) inputs;
          123 
          124   if (not full_update) {
          125     return;
          126   }
          127 
          128   // horizontal velocity and its maximum:
          129   IceModelVec::AccessList list{&m_u, &m_v, &sliding_velocity};
          130 
          131   for (Points p(*m_grid); p; p.next()) {
          132     const int i = p.i(), j = p.j();
          133 
          134     m_u.set_column(i,j, sliding_velocity(i,j).u);
          135     m_v.set_column(i,j, sliding_velocity(i,j).v);
          136   }
          137 
          138   // Communicate to get ghosts (needed to compute w):
          139   m_u.update_ghosts();
          140   m_v.update_ghosts();
          141 
          142   // diffusive flux and maximum diffusivity
          143   m_diffusive_flux.set(0.0);
          144   m_D_max = 0.0;
          145 }
          146 
          147 } // end of namespace stressbalance
          148 } // end of namespace pism