PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
BTU_Verification.cc
Go to the documentation of this file.
1 /* Copyright (C) 2016, 2017, 2019, 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/verification/BTU_Verification.hh"
21 #include "pism/util/Time.hh"
22 #include "pism/verification/tests/exactTestK.h"
23 #include "pism/verification/tests/exactTestO.h"
24 #include "pism/util/error_handling.hh"
25 #include "pism/util/array/Array3D.hh"
26 
27 namespace pism {
28 namespace energy {
29 
30 BTU_Verification::BTU_Verification(std::shared_ptr<const Grid> g,
31  const BTUGrid &vertical_grid,
32  int testname, bool bedrock_is_ice)
33  : BTU_Full(g, vertical_grid) {
34 
35  m_testname = testname;
36  m_bedrock_is_ice = bedrock_is_ice;
37 }
38 
40  // hard-wired value used in exact solutions (tests K and O)
42 }
43 
44 void BTU_Verification::bootstrap(const array::Scalar &bedrock_top_temperature) {
45  (void) bedrock_top_temperature;
46 
47  std::vector<double> temperature(m_Mbz), zlevels = m_temp->levels();
48 
49  double time = this->time().current();
50 
51  // evaluate exact solution in a column; all columns are the same
52  switch (m_testname) {
53  default:
54  case 'K':
55  for (unsigned int k = 0; k < m_Mbz; k++) {
56  TestKParameters P = exactK(time, zlevels[k], m_bedrock_is_ice ? 1 : 0);
57  if (P.error_code != 0) {
59  "exactK() reports that level %9.7f is below B0 = -1000.0 m",
60  zlevels[k]);
61  }
62  temperature[k] = P.T;
63  }
64  break;
65  case 'O':
66  for (unsigned int k = 0; k < m_Mbz; k++) {
67  temperature[k] = exactO(zlevels[k]).TT;
68  }
69  break;
70  }
71 
72  // copy column values into the 3D array
74 
75  ParallelSection loop(m_grid->com);
76  try {
77  for (auto p = m_grid->points(); p; p.next()) {
78  m_temp->set_column(p.i(), p.j(), temperature.data());
79  }
80  } catch (...) {
81  loop.failed();
82  }
83  loop.check();
84 }
85 
86 } // end of namespace energy
87 } // end of namespace pism
const Time & time() const
Definition: Component.cc:109
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition: Component.hh:156
void failed()
Indicates a failure of a parallel section.
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
double current() const
Current time, in seconds.
Definition: Time.cc:465
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition: Array.hh:65
void set(double c)
Result: v[j] <- c for all j.
Definition: Array.cc:707
const array::Array3D & temperature() const
Bedrock thermal layer temperature field.
Definition: BTU_Full.cc:243
unsigned int m_Mbz
number of vertical levels within the bedrock
Definition: BTU_Full.hh:120
std::shared_ptr< array::Array3D > m_temp
Definition: BTU_Full.hh:112
Given the temperature of the top of the bedrock, for the duration of one time-step,...
Definition: BTU_Full.hh:84
BTU_Verification(std::shared_ptr< const Grid > g, const BTUGrid &vertical_grid, int test, bool bii)
virtual void initialize_bottom_surface_flux()
virtual void bootstrap(const array::Scalar &bedrock_top_temperature)
array::Scalar m_bottom_surface_flux
upward heat flux through the bottom surface of the bed thermal layer
#define PISM_ERROR_LOCATION
struct TestKParameters exactK(double t, double z, int bedrock_is_ice)
Definition: exactTestK.c:129
struct TestOParameters exactO(double z)
Definition: exactTestO.c:112
static const double g
Definition: exactTestP.cc:36
static const double k
Definition: exactTestP.cc:42