PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
BlatterTestXZ.cc
Go to the documentation of this file.
1/* Copyright (C) 2020, 2022, 2023, 2025 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/BlatterTestXZ.hh"
21
22#include "pism/rheology/IsothermalGlen.hh"
23
24#include "pism/stressbalance/blatter/verification/manufactured_solutions.hh"
25
26namespace pism {
27namespace stressbalance {
28
29BlatterTestXZ::BlatterTestXZ(std::shared_ptr<const Grid> grid,
30 int Mz, int coarsening_factor)
31 : Blatter(grid, Mz, coarsening_factor) {
32
33 // use the isothermal Glen flow law
34 double n = m_config->get_number("stress_balance.blatter.Glen_exponent");
36
37 // make sure we use the same Glen exponent
38 assert(m_flow_law->exponent() == 3.0);
39
40 // make sure the grid is periodic in the Y direction
41 assert(m_grid->periodicity() == grid::Y_PERIODIC);
42
43 // store constant ice softness (enthalpy and pressure values are irrelevant)
44 m_A = m_flow_law->softness(1e5, 0);
45
46 // surface elevation parameter (1/m)
47 m_alpha = 4e-8;
48
49 // surface elevation parameter (m)
50 m_s0 = 2000.0;
51
52 // ice thickness (m)
53 m_H0 = 1000.0;
54
55 // sliding parameter
56 m_beta = convert(m_sys, 1.0, "kPa year m-1", "Pa s m-1");
57
58 m_rho = m_config->get_number("constants.ice.density");
59 m_g = m_config->get_number("constants.standard_gravity");
60}
61
63 const int *node_type,
64 const double *ice_bottom,
65 const double *sea_level) {
66 (void) face;
67 (void) node_type;
68 (void) ice_bottom;
69 (void) sea_level;
70
71 return false;
72}
73
74bool BlatterTestXZ::dirichlet_node(const DMDALocalInfo &info,
76 // use Dirichlet BC at x == -Lx and x == Lx
77 return (I.i == 0 or I.i == info.mx - 1);
78}
79
80Vector2d BlatterTestXZ::u_bc(double x, double y, double z) const {
81 (void) y;
82
83 return blatter_xz_exact(x, z, m_A, m_rho, m_g, m_s0, m_alpha, m_H0, m_beta);
84}
85
87 const double *surface,
88 const double *bed,
89 Vector2d *residual) {
90 (void) surface;
91 (void) bed;
92
93 // compute x and z coordinates of quadrature points
94 double
95 *x = m_work[0],
96 *z = m_work[1];
97 {
98 double
99 *x_nodal = m_work[2],
100 *z_nodal = m_work[3];
101
102 for (int n = 0; n < fem::q13d::n_chi; ++n) {
103 x_nodal[n] = element.x(n);
104 z_nodal[n] = element.z(n);
105 }
106
107 element.evaluate(x_nodal, x);
108 element.evaluate(z_nodal, z);
109 }
110
111 // loop over all quadrature points
112 for (unsigned int q = 0; q < element.n_pts(); ++q) {
113 auto W = element.weight(q) / m_scaling;
114
115 // loop over all test functions
116 for (int t = 0; t < element.n_chi(); ++t) {
117 const auto &psi = element.chi(q, t);
118
119 residual[t] += W * psi.val * blatter_xz_source(x[q], z[q], m_A, m_rho, m_g,
121 }
122 }
123}
124
125/*!
126 * Basal contribution to the residual.
127 */
129 const fem::Q1Element3Face &face,
130 const double *tauc_nodal,
131 const double *f_nodal,
132 const Vector2d *u_nodal,
133 Vector2d *residual) {
134
135 // The basal sliding BC contribution:
136 Blatter::residual_basal(element, face, tauc_nodal, f_nodal, u_nodal, residual);
137
138 // Additional contribution needed to satisfy the manufactured solution:
139 {
140 // compute x and z coordinates of quadrature points
141 double
142 *x = m_work[0],
143 *z = m_work[1];
144 {
145 double
146 *x_nodal = m_work[2],
147 *z_nodal = m_work[3];
148
149 for (int n = 0; n < fem::q13d::n_chi; ++n) {
150 x_nodal[n] = element.x(n);
151 z_nodal[n] = element.z(n);
152 }
153
154 face.evaluate(x_nodal, x);
155 face.evaluate(z_nodal, z);
156 }
157
158 for (unsigned int q = 0; q < face.n_pts(); ++q) {
159 auto W = face.weight(q) / m_scaling;
160
161 // loop over all test functions
162 for (int t = 0; t < element.n_chi(); ++t) {
163 auto psi = face.chi(q, t);
164
165 residual[t] += - W * psi * blatter_xz_source_bed(x[q], z[q], m_A, m_rho, m_g,
167 }
168 }
169 }
170}
171
172/*!
173 * Top surface contribution to the residual.
174 */
176 const fem::Q1Element3Face &face,
177 Vector2d *residual) {
178
179 // compute x and z coordinates of quadrature points
180 double
181 *x = m_work[0],
182 *z = m_work[1];
183 {
184 double
185 *x_nodal = m_work[2],
186 *z_nodal = m_work[3];
187
188 for (int n = 0; n < fem::q13d::n_chi; ++n) {
189 x_nodal[n] = element.x(n);
190 z_nodal[n] = element.z(n);
191 }
192
193 face.evaluate(x_nodal, x);
194 face.evaluate(z_nodal, z);
195 }
196
197 for (unsigned int q = 0; q < face.n_pts(); ++q) {
198 auto W = face.weight(q) / m_scaling;
199
200 auto F = blatter_xz_source_surface(x[q], z[q], m_A, m_rho, m_g,
202
203 // loop over all test functions
204 for (int t = 0; t < element.n_chi(); ++t) {
205 auto psi = face.chi(q, t);
206
207 residual[t] += - W * psi * F;
208 }
209 }
210}
211
212} // end of namespace stressbalance
213} // end of namespace pism
const units::System::Ptr m_sys
unit system used by this component
Definition Component.hh:162
std::shared_ptr< const Config > m_config
configuration database used by this component
Definition Component.hh:160
const std::shared_ptr< const Grid > m_grid
grid 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:285
int n_chi() const
Definition Element.hh:65
double weight(unsigned int q) const
Weight of the quadrature point q
Definition Element.hh:85
const Germ & chi(unsigned int q, unsigned int k) const
Definition Element.hh:73
unsigned int n_pts() const
Number of quadrature points.
Definition Element.hh:80
double weight(unsigned int q) const
Definition Element.hh:414
unsigned int n_pts() const
Number of quadrature points.
Definition Element.hh:411
const double & chi(unsigned int q, unsigned int k) const
Definition Element.hh:419
void evaluate(const T *x, T *result) const
Definition Element.hh:434
double z(int n) const
Definition Element.hh:381
double x(int n) const
Definition Element.hh:371
3D Q1 element
Definition Element.hh:358
Isothermal Glen ice allowing extra customization.
BlatterTestXZ(std::shared_ptr< const Grid > grid, int Mz, int coarsening_factor)
void residual_basal(const fem::Q1Element3 &element, const fem::Q1Element3Face &face, const double *tauc_nodal, const double *f_nodal, const Vector2d *u_nodal, Vector2d *residual)
Vector2d u_bc(double x, double y, double z) const
bool marine_boundary(int face, const int *node_type, const double *ice_bottom, const double *sea_level)
void residual_source_term(const fem::Q1Element3 &element, const double *surface, const double *bed, Vector2d *residual)
void residual_surface(const fem::Q1Element3 &element, const fem::Q1Element3Face &face, Vector2d *residual)
double m_A
constant ice hardness
bool dirichlet_node(const DMDALocalInfo &info, const fem::Element3::GlobalIndex &I)
virtual void residual_basal(const fem::Q1Element3 &element, const fem::Q1Element3Face &face, const double *tauc_nodal, const double *f_nodal, const Vector2d *u_nodal, Vector2d *residual)
Definition residual.cc:164
double m_work[m_n_work][m_Nq]
Definition Blatter.hh:109
std::shared_ptr< rheology::FlowLaw > m_flow_law
std::shared_ptr< EnthalpyConverter > m_EC
#define n
Definition exactTestM.c:37
const int n_chi
Number of shape functions on a Q1 element.
Definition FEM.hh:213
static double F(double SL, double B, double H, double alpha)
Vector2d blatter_xz_source_surface(double x, double z, double A, double rho, double g, double s_0, double alpha, double H, double beta)
Vector2d blatter_xz_source(double x, double z, double A, double rho, double g, double s_0, double alpha, double H, double beta)
Vector2d blatter_xz_exact(double x, double z, double A, double rho, double g, double s_0, double alpha, double H, double beta)
Vector2d blatter_xz_source_bed(double x, double z, double A, double rho, double g, double s_0, double alpha, double H, double beta)