URI:
       tSSAFD.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
       ---
       tSSAFD.hh (3796B)
       ---
            1 // Copyright (C) 2004--2019 Jed Brown, Ed Bueler and 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 _SSAFD_H_
           20 #define _SSAFD_H_
           21 
           22 #include "SSA.hh"
           23 
           24 #include "pism/util/error_handling.hh"
           25 #include "pism/util/petscwrappers/Viewer.hh"
           26 #include "pism/util/petscwrappers/KSP.hh"
           27 #include "pism/util/petscwrappers/Mat.hh"
           28 
           29 namespace pism {
           30 namespace stressbalance {
           31 
           32 //! PISM's SSA solver: the finite difference implementation.
           33 class SSAFD : public SSA
           34 {
           35 public:
           36   SSAFD(IceGrid::ConstPtr g);
           37   virtual ~SSAFD();
           38 
           39   const IceModelVec2Stag & integrated_viscosity() const;
           40 protected:
           41   virtual void init_impl();
           42 
           43   virtual DiagnosticList diagnostics_impl() const;
           44 
           45   virtual void pc_setup_bjacobi();
           46 
           47   virtual void pc_setup_asm();
           48   
           49   virtual void solve(const Inputs &inputs);
           50 
           51   virtual void picard_iteration(const Inputs &inputs,
           52                                 double nuH_regularization,
           53                                 double nuH_iter_failure_underrelax);
           54 
           55   virtual void picard_manager(const Inputs &inputs,
           56                               double nuH_regularization,
           57                               double nuH_iter_failure_underrelax);
           58 
           59   virtual void picard_strategy_regularization(const Inputs &inputs);
           60 
           61   virtual void compute_hardav_staggered(const Inputs &inputs);
           62 
           63   virtual void compute_nuH_staggered(const Geometry &geometry,
           64                                      double nuH_regularization,
           65                                      IceModelVec2Stag &result);
           66 
           67   virtual void compute_nuH_staggered_cfbc(const Geometry &geometry,
           68                                           double nuH_regularization,
           69                                           IceModelVec2Stag &result);
           70 
           71   virtual void compute_nuH_norm(double &norm,
           72                                 double &norm_change);
           73 
           74   virtual void assemble_matrix(const Inputs &inputs,
           75                                bool include_basal_shear, Mat A);
           76 
           77   virtual void assemble_rhs(const Inputs &inputs);
           78 
           79   virtual void write_system_petsc(const std::string &namepart);
           80 
           81   virtual void update_nuH_viewers();
           82 
           83   void set_diagonal_matrix_entry(Mat A, int i, int j, int component,
           84                                          double value);
           85 
           86   virtual bool is_marginal(int i, int j, bool ssa_dirichlet_bc);
           87 
           88   virtual void fracture_induced_softening(const IceModelVec2S *fracture_density);
           89 
           90   // objects used internally
           91   IceModelVec2Stag m_hardness, m_nuH, m_nuH_old;
           92   IceModelVec2 m_work;
           93   petsc::KSP m_KSP;
           94   petsc::Mat m_A;
           95   IceModelVec2V m_b;            // right hand side
           96   double m_scaling;
           97 
           98   IceModelVec2V m_velocity_old;
           99 
          100   unsigned int m_default_pc_failure_count,
          101     m_default_pc_failure_max_count;
          102   
          103   bool m_view_nuh;
          104   petsc::Viewer::Ptr m_nuh_viewer;
          105   int m_nuh_viewer_size;
          106 
          107   class KSPFailure : public RuntimeError {
          108   public:
          109     KSPFailure(const char* reason);
          110   };
          111 
          112   class PicardFailure : public RuntimeError {
          113   public:
          114     PicardFailure(const std::string &message);
          115   };
          116 };
          117 
          118 //! Constructs a new SSAFD
          119 SSA * SSAFDFactory(IceGrid::ConstPtr grid);
          120 
          121 } // end of namespace stressbalance
          122 } // end of namespace pism
          123 
          124 #endif /* _SSAFD_H_ */