URI: 
       tinit_step.hh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
  HTML git clone git://src.adamsgaard.dk/pism
   DIR Log
   DIR Files
   DIR Refs
   DIR LICENSE
       ---
       tinit_step.hh (1682B)
       ---
            1 /* Copyright (C) 2017, 2018 PISM Authors
            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 
           20 #include "pism/util/Time.hh"
           21 #include "pism/util/MaxTimestep.hh"
           22 
           23 namespace pism {
           24 
           25 /*!
           26  * Update a `model` by asking it to perform time-stepping from the current time to one year in the
           27  * future (or as far as the time step restriction allows).
           28  *
           29  * This is sometimes necessary during initialization, but should be avoided if possible.
           30  */
           31 template<class M>
           32 void init_step(M *model, const Geometry &geometry, const Time& time) {
           33   const double
           34     now               = time.current(),
           35     one_year_from_now = time.increment_date(now, 1.0);
           36 
           37   // Take a one year long step if we can.
           38   MaxTimestep max_dt(one_year_from_now - now);
           39 
           40   max_dt = std::min(max_dt, model->max_timestep(now));
           41 
           42   // Do not take time-steps shorter than 1 second
           43   if (max_dt.value() < 1.0) {
           44     max_dt = MaxTimestep(1.0);
           45   }
           46 
           47   assert(max_dt.finite());
           48 
           49   model->update(geometry, now, max_dt.value());
           50 }
           51 
           52 } // end of namespace pism