URI: 
       tSSATestCase.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
       ---
       tSSATestCase.hh (3423B)
       ---
            1 // Copyright (C) 2009--2017 Ed Bueler, Constantine Khroulev and David Maxwell
            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 _SSATESTCASE_H_
           20 #define _SSATESTCASE_H_
           21 
           22 #include "SSA.hh"
           23 #include "pism/util/Context.hh"
           24 #include "pism/util/EnthalpyConverter.hh"
           25 #include "pism/basalstrength/basal_resistance.hh"
           26 #include "pism/util/Vars.hh"
           27 #include "pism/util/IceGrid.hh"
           28 #include "pism/util/IceModelVec2CellType.hh"
           29 #include "pism/geometry/Geometry.hh"
           30 
           31 namespace pism {
           32 namespace stressbalance {
           33 
           34 /*! An SSATestCase manages running an SSA instance against a particular
           35   test.  Subclasses must implement the following abstract methods to define
           36   the input to an SSA for a test case:
           37 
           38   1) initializeSSACoefficients (to initialize the ssa coefficients, e.g. ice thickness)
           39 
           40   Additionally, a subclass can implement `report` to handle
           41   printing statistics after a run.  The default report method relies
           42   on subclasses implementing the exactSolution method for comparison.
           43 
           44   A driver uses an SSATestCase by calling 1-3 below and 4,5 as desired:
           45 
           46   1) its constructor
           47   2) init (to set coefficients)
           48   3) run (to actually solve the ssa)
           49   4) report
           50   5) write (to save the results of the computation to a file)
           51 */
           52 class SSATestCase
           53 {
           54 public:
           55   SSATestCase(Context::Ptr ctx, int Mx, int My,
           56               double Lx, double Ly,
           57               GridRegistration registration,
           58               Periodicity periodicity);
           59 
           60   virtual ~SSATestCase();
           61 
           62   virtual void init();
           63 
           64   virtual void run();
           65 
           66   virtual void report(const std::string &testname);
           67 
           68   virtual void write(const std::string &filename);
           69 
           70 protected:
           71 
           72   //! Set up the coefficient variables as appropriate for the test case.
           73   virtual void initializeSSACoefficients() = 0;
           74 
           75   //! Return the value of the exact solution at grid index (i,j) or equivalently
           76   //! at coordinates (x,y).
           77   virtual void exactSolution(int i, int j,
           78                              double x, double y, double *u, double *v);
           79 
           80   void report_netcdf(const std::string &testname,
           81                      double max_vector,
           82                      double rel_vector,
           83                      double max_u,
           84                      double max_v,
           85                      double avg_u,
           86                      double avg_v);
           87 
           88   MPI_Comm m_com;
           89   const Context::Ptr m_ctx;
           90   const Config::Ptr m_config;
           91   IceGrid::Ptr m_grid;
           92   const units::System::Ptr m_sys;
           93 
           94   // SSA model variables.
           95   EnthalpyConverter::Ptr m_enthalpyconverter;
           96 
           97   // SSA coefficient variables.
           98   IceModelVec2S m_tauc, m_melange_back_pressure;
           99   IceModelVec3 m_ice_enthalpy;
          100 
          101   IceModelVec2V m_bc_values;
          102   IceModelVec2Int m_bc_mask;
          103 
          104   Geometry m_geometry;
          105 
          106   SSA *m_ssa;
          107 };
          108 
          109 } // end of namespace stressbalance
          110 } // end of namespace pism
          111 
          112 #endif /* _SSATESTCASE_H_ */