PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
BlatterTestXY.cc
Go to the documentation of this file.
1 /* Copyright (C) 2020, 2022, 2023 PISM Authors
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 
20 #include "pism/stressbalance/blatter/verification/BlatterTestXY.hh"
21 
22 #include "pism/rheology/IsothermalGlen.hh"
23 
24 #include "pism/stressbalance/blatter/verification/manufactured_solutions.hh"
25 
26 namespace pism {
27 namespace stressbalance {
28 
29 BlatterTestXY::BlatterTestXY(std::shared_ptr<const Grid> grid, int Mz, int coarsening_factor)
30  : Blatter(grid, Mz, coarsening_factor) {
31 
32  // use the isothermal Glen flow law
33  m_flow_law.reset(new rheology::IsothermalGlen("stress_balance.blatter.", *m_config, m_EC));
34 
35  // make sure we use the same Glen exponent
36  assert(m_flow_law->exponent() == 3.0);
37 
38  // store constant hardness (enthalpy and pressure values are irrelevant)
39  m_B = m_flow_law->hardness(1e5, 0);
40 }
41 
43  const int *node_type,
44  const double *ice_bottom,
45  const double *sea_level) {
46  (void) face;
47  (void) node_type;
48  (void) ice_bottom;
49  (void) sea_level;
50 
51  return false;
52 }
53 
54 bool BlatterTestXY::dirichlet_node(const DMDALocalInfo &info, const fem::Element3::GlobalIndex& I) {
55  // use Dirichlet BC on the whole map-plane boundary
56  return (I.i == 0 or I.i == info.mx - 1 or
57  I.j == 0 or I.j == info.my - 1);
58 }
59 
60 Vector2d BlatterTestXY::u_bc(double x, double y, double z) const {
61  (void) z;
62 
63  return blatter_xy_exact(x, y);
64 }
65 
67  const double *surface,
68  const double *bed,
69  Vector2d *residual) {
70  (void) surface;
71  (void) bed;
72 
73  // compute x and y coordinates of quadrature points
74  double
75  *x = m_work[0],
76  *y = m_work[1];
77  {
78  double
79  *x_nodal = m_work[2],
80  *y_nodal = m_work[3];
81 
82  for (int n = 0; n < element.n_chi(); ++n) {
83  x_nodal[n] = element.x(n);
84  y_nodal[n] = element.y(n);
85  }
86 
87  element.evaluate(x_nodal, x);
88  element.evaluate(y_nodal, y);
89  }
90 
91  // loop over all quadrature points
92  for (int q = 0; q < element.n_pts(); ++q) {
93  auto W = element.weight(q) / m_scaling;
94 
95  // loop over all test functions
96  for (int t = 0; t < element.n_chi(); ++t) {
97  const auto &psi = element.chi(q, t);
98 
99  residual[t] += W * psi.val * blatter_xy_source(x[q], y[q], m_B);
100  }
101  }
102 }
103 
104 } // end of namespace stressbalance
105 } // end of namespace pism
const Config::ConstPtr m_config
configuration database used by this component
Definition: Component.hh:158
This class represents a 2D vector field (such as ice velocity) at a certain grid point.
Definition: Vector2d.hh:29
void evaluate(const T *x, T *vals, T *dx, T *dy, T *dz) const
Given nodal values, compute the values and partial derivatives at the quadrature points.
Definition: Element.hh:278
const Germ & chi(unsigned int q, unsigned int k) const
Definition: Element.hh:73
int n_pts() const
Number of quadrature points.
Definition: Element.hh:80
int n_chi() const
Definition: Element.hh:65
double weight(unsigned int q) const
Weight of the quadrature point q
Definition: Element.hh:85
double y(int n) const
Definition: Element.hh:369
double x(int n) const
Definition: Element.hh:364
3D Q1 element
Definition: Element.hh:351
Isothermal Glen ice allowing extra customization.
double m_B
constant ice hardness
void residual_source_term(const fem::Q1Element3 &element, const double *surface, const double *bed, Vector2d *residual)
bool marine_boundary(int face, const int *node_type, const double *ice_bottom, const double *sea_level)
Vector2d u_bc(double x, double y, double z) const
BlatterTestXY(std::shared_ptr< const Grid > grid, int Mz, int coarsening_factor)
bool dirichlet_node(const DMDALocalInfo &info, const fem::Element3::GlobalIndex &I)
double m_work[m_n_work][m_Nq]
Definition: Blatter.hh:108
std::shared_ptr< rheology::FlowLaw > m_flow_law
#define n
Definition: exactTestM.c:37
Vector2d blatter_xy_source(double x, double y, double B)
Vector2d blatter_xy_exact(double x, double y)
const int I[]
Definition: ssafd_code.cc:24