URI: 
       ticeModelVec2T.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
       ---
       ticeModelVec2T.hh (3966B)
       ---
            1 // Copyright (C) 2009--2019 Constantine Khroulev
            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 #ifndef __IceModelVec2T_hh
           20 #define __IceModelVec2T_hh
           21 
           22 #include "iceModelVec.hh"
           23 #include "MaxTimestep.hh"
           24 
           25 namespace pism {
           26 
           27 //! A class for storing and accessing 2D time-series (for climate forcing)
           28 /*! This class was created to read time-dependent and spatially-varying climate
           29   forcing data, in particular snow temperatures and precipitation.
           30 
           31   If requests (calls to update()) go in sequence, every records should be read
           32   only once.
           33 
           34   Note that this class is optimized for use with a PDD scheme -- it stores
           35   records so that data corresponding to a grid point are stored in adjacent
           36   memory locations.
           37 
           38   IceModelVec2T is always global (%i.e. has no ghosts).
           39 
           40   Both versions of interp() use piecewise-constant interpolation and
           41   extrapolate (by a constant) outside the available range.
           42 */
           43 class IceModelVec2T : public IceModelVec2S {
           44 public:
           45   typedef std::shared_ptr<IceModelVec2T> Ptr;
           46 
           47   static Ptr ForcingField(IceGrid::ConstPtr grid,
           48                           const File &file,
           49                           const std::string &short_name,
           50                           const std::string &standard_name,
           51                           int max_buffer_size,
           52                           int evaluations_per_year,
           53                           bool periodic,
           54                           InterpolationType interpolation_type = PIECEWISE_CONSTANT);
           55 
           56   IceModelVec2T(IceGrid::ConstPtr grid, const std::string &short_name, unsigned int n_records,
           57                 unsigned int n_evaluations_per_year,
           58                 InterpolationType interpolation_type = PIECEWISE_CONSTANT);
           59   virtual ~IceModelVec2T();
           60 
           61   unsigned int n_records();
           62 
           63   void init(const std::string &filename, unsigned int period, double reference_time);
           64   void init_constant(double value);
           65 
           66   void update(double t, double dt);
           67   MaxTimestep max_timestep(double t) const;
           68 
           69   void interp(double t);
           70 
           71   void interp(int i, int j, std::vector<double> &results);
           72 
           73   void average(double t, double dt);
           74 
           75   void begin_access() const;
           76   void end_access() const;
           77   void init_interpolation(const std::vector<double> &ts);
           78 
           79 private:
           80   std::vector<double> m_time,             //!< all the times available in filename
           81     m_time_bounds;                //!< time bounds
           82   std::string m_filename;         //!< file to read (regrid) from
           83   petsc::DM::Ptr m_da3;
           84   petsc::Vec m_v3;                       //!< a 3D Vec used to store records
           85   mutable void ***m_array3;
           86 
           87   //! maximum number of records to store in memory
           88   unsigned int m_n_records;
           89 
           90   //! number of records kept in memory
           91   unsigned int m_N;
           92 
           93   //! number of evaluations per year used to compute temporal averages
           94   unsigned int m_n_evaluations_per_year;
           95 
           96   //! in-file index of the first record stored in memory ("int" to allow first==-1 as an
           97   //! "invalid" first value)
           98   int m_first;
           99 
          100   InterpolationType m_interp_type;
          101   std::shared_ptr<Interpolation> m_interp;
          102   unsigned int m_period;        // in years
          103   double m_reference_time;      // in seconds
          104 
          105   double*** get_array3();
          106   void update(unsigned int start);
          107   void discard(int N);
          108   double average(int i, int j);
          109   void set_record(int n);
          110   void get_record(int n);
          111 };
          112 
          113 
          114 } // end of namespace pism
          115 
          116 #endif // __IceModelVec2T_hh