PISM, A Parallel Ice Sheet Model stable 0.4.1779

src/base/stressbalance/SSAFEM.hh

Go to the documentation of this file.
00001 // Copyright (C) 2009--2011 Jed Brown and Ed Bueler and Constantine Khroulev and David Maxwell
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 _SSAFEM_H_
00020 #define _SSAFEM_H_
00021 
00022 #include "SSA.hh"
00023 #include "FETools.hh"
00024 #include <petscsnes.h>
00025 
00026 
00028 struct FEStoreNode {
00029   PetscReal H,tauc,hx,hy,b,B;
00030   PetscInt mask;
00031 };
00032 
00033 
00034 class SSAFEM;
00035 
00037 /* The callbacks from SNES are mediated via SNESDAFormFunction, which has the
00038  convention that its context argument is a pointer to a struct 
00039  having a DA as its first entry.  The SSAFEM_SNESCallbackData fulfills 
00040  this requirement, and allows for passing the callback on to an honest 
00041  SSAFEM object. */
00042 struct SSAFEM_SNESCallbackData {
00043   DA           da;
00044   SSAFEM      *ssa;
00045 };
00046 
00048 
00049 PetscErrorCode SSAFEFunction(DALocalInfo *, const PISMVector2 **, 
00050                                                       PISMVector2 **, SSAFEM_SNESCallbackData *);
00051 PetscErrorCode SSAFEJacobian(DALocalInfo *, const PISMVector2 **, Mat, SSAFEM_SNESCallbackData *);
00052 
00054 SSA * SSAFEMFactory(IceGrid &, IceBasalResistancePlasticLaw &, 
00055                   IceFlowLaw &, EnthalpyConverter &, const NCConfigVariable &);
00056 
00058 
00062 class SSAFEM : public SSA
00063 {
00064   friend PetscErrorCode SSAFEFunction(DALocalInfo *, const PISMVector2 **, PISMVector2 **, SSAFEM_SNESCallbackData *);
00065   friend PetscErrorCode SSAFEJacobian(DALocalInfo *, const PISMVector2 **, Mat, SSAFEM_SNESCallbackData *);
00066 public:
00067   SSAFEM(IceGrid &g, IceBasalResistancePlasticLaw &b, IceFlowLaw &i, EnthalpyConverter &e,
00068          const NCConfigVariable &c) :
00069     SSA(g,b,i,e,c), element_index(g)
00070   {
00071     quadrature.init(grid);
00072     PetscErrorCode ierr = allocate_fem();
00073     if (ierr != 0) {
00074       PetscPrintf(grid.com, "FATAL ERROR: SSAFEM allocation failed.\n");
00075       PISMEnd();
00076     }
00077   }
00078 
00079   virtual ~SSAFEM()
00080   {
00081     deallocate_fem();
00082   }
00083 
00084   virtual PetscErrorCode init(PISMVars &vars);
00085 
00086 protected:
00087   PetscErrorCode setup();
00088 
00089   virtual PetscErrorCode PointwiseNuHAndBeta(const FEStoreNode *,
00090                                              const PISMVector2 *,const PetscReal[],
00091                                              PetscReal *,PetscReal *,PetscReal *,PetscReal *);
00092 
00093   void FixDirichletValues(PetscReal local_bc_mask[],PISMVector2 **BC_vel,
00094                           PISMVector2 x[], FEDOFMap &my_dofmap);
00095 
00096   virtual PetscErrorCode allocate_fem();
00097 
00098   virtual PetscErrorCode deallocate_fem();
00099 
00100   virtual PetscErrorCode compute_local_function(DALocalInfo *info, const PISMVector2 **xg, PISMVector2 **yg);
00101 
00102   virtual PetscErrorCode compute_local_jacobian(DALocalInfo *info, const PISMVector2 **xg, Mat J);
00103 
00104   virtual PetscErrorCode solve();
00105   
00106   virtual PetscErrorCode setFromOptions();
00107 
00108   // objects used internally
00109   IceModelVec2S hardav;         // vertically-averaged ice hardness
00110   SSAFEM_SNESCallbackData callback_data;
00111   Mat J;
00112   Vec r;
00113 
00114   SNES         snes;
00115   FEStoreNode *feStore;
00116   PetscReal    dirichletScale;
00117   PetscReal    ocean_rho;
00118   PetscReal    earth_grav;
00119   PetscReal    m_beta_ice_free_bedrock;
00120   PetscReal    m_epsilon_ssa;
00121 
00122   FEElementMap element_index;
00123   FEQuadrature quadrature;
00124   FEDOFMap dofmap;
00125 };
00126 
00127 
00128 #endif /* _SSAFEM_H_ */
00129 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines