PISM, A Parallel Ice Sheet Model stable 0.4.1779

src/base/stressbalance/SSAFD.hh

Go to the documentation of this file.
00001 // Copyright (C) 2004--2011 Jed Brown, Ed Bueler and Constantine Khroulev
00002 //
00003 // This file is part of PISM.
00004 //
00005 // PISM is free software; you can redistribute it and/or modify it under the
00006 // terms of the GNU General Public License as published by the Free Software
00007 // Foundation; either version 2 of the License, or (at your option) any later
00008 // version.
00009 //
00010 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
00011 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013 // details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with PISM; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef _SSAFD_H_
00020 #define _SSAFD_H_
00021 
00022 #include "SSA.hh"
00023 #include <petscksp.h>
00024 
00025 
00027 class SSAFD : public SSA
00028 {
00029 public:
00030   SSAFD(IceGrid &g, IceBasalResistancePlasticLaw &b, IceFlowLaw &i, EnthalpyConverter &e,
00031         const NCConfigVariable &c) :
00032     SSA(g,b,i,e,c)
00033   {
00034     PetscErrorCode ierr = allocate_fd();
00035     if (ierr != 0) {
00036       PetscPrintf(grid.com, "FATAL ERROR: SSAFD allocation failed.\n");
00037       PISMEnd();
00038     }
00039   }
00040 
00041   virtual ~SSAFD()
00042   {
00043     PetscErrorCode ierr = deallocate_fd();
00044     if (ierr != 0) {
00045       PetscPrintf(grid.com, "FATAL ERROR: SSAFD de-allocation failed.\n");
00046       PISMEnd();
00047     }
00048   }
00049 
00050   virtual PetscErrorCode init(PISMVars &vars);
00051 
00052 protected:
00053   virtual PetscErrorCode allocate_fd();
00054 
00055   virtual PetscErrorCode deallocate_fd();
00056 
00057   virtual PetscErrorCode solve();
00058 
00059   virtual PetscErrorCode compute_hardav_staggered(IceModelVec2Stag &result);
00060 
00061   virtual PetscErrorCode compute_nuH_staggered(IceModelVec2Stag &result,
00062                                                PetscReal epsilon);
00063 
00064   virtual PetscErrorCode compute_nuH_norm(PetscReal &norm,
00065                                           PetscReal &norm_change);
00066 
00067   virtual PetscErrorCode assemble_matrix(bool include_basal_shear, Mat A);
00068 
00069   virtual PetscErrorCode assemble_rhs(Vec rhs);
00070 
00071   virtual PetscErrorCode writeSSAsystemMatlab();
00072 
00073   virtual PetscErrorCode update_nuH_viewers();
00074 
00075   virtual PetscErrorCode set_diagonal_matrix_entry(Mat A, int i, int j,
00076                                                    PetscScalar value);
00077 
00078   virtual bool is_marginal(int i, int j);
00079 
00080   // objects used internally
00081   IceModelVec2Stag hardness, nuH, nuH_old;
00082   KSP SSAKSP;
00083   Mat SSAStiffnessMatrix;
00084   Vec SSARHS;
00085   PetscScalar scaling;
00086 
00087   bool view_nuh;
00088   PetscViewer nuh_viewer;
00089   PetscInt nuh_viewer_size;
00090 };
00091 
00093 SSA * SSAFDFactory(IceGrid &, IceBasalResistancePlasticLaw &, 
00094                   IceFlowLaw &, EnthalpyConverter &, const NCConfigVariable &);
00095 
00096 #endif /* _SSAFD_H_ */
00097 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines