tBTU_Verification.cc - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
 (HTM) git clone git://src.adamsgaard.dk/pism
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       tBTU_Verification.cc (2737B)
       ---
            1 /* Copyright (C) 2016, 2017, 2019 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 "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 
           26 namespace pism {
           27 namespace energy {
           28 
           29 BTU_Verification::BTU_Verification(IceGrid::ConstPtr g,
           30                                    const BTUGrid &vertical_grid,
           31                                    int testname, bool bedrock_is_ice)
           32   : BTU_Full(g, vertical_grid) {
           33 
           34   m_testname       = testname;
           35   m_bedrock_is_ice = bedrock_is_ice;
           36 }
           37 
           38 BTU_Verification::~BTU_Verification() {
           39   // empty
           40 }
           41 
           42 void BTU_Verification::initialize_bottom_surface_flux() {
           43   // hard-wired value used in exact solutions (tests K and O)
           44   m_bottom_surface_flux.set(0.042);
           45 }
           46 
           47 void BTU_Verification::bootstrap(const IceModelVec2S &bedrock_top_temperature) {
           48   (void) bedrock_top_temperature;
           49 
           50   std::vector<double> Tbcol(m_Mbz),
           51     zlevels = m_temp->levels();
           52 
           53   double time = m_grid->ctx()->time()->current();
           54 
           55   // evaluate exact solution in a column; all columns are the same
           56   switch (m_testname) {
           57   default:
           58   case 'K':
           59     for (unsigned int k = 0; k < m_Mbz; k++) {
           60       TestKParameters P = exactK(time, zlevels[k], m_bedrock_is_ice);
           61       if (P.error_code != 0) {
           62         throw RuntimeError::formatted(PISM_ERROR_LOCATION,
           63                                       "exactK() reports that level %9.7f is below B0 = -1000.0 m",
           64                                       zlevels[k]);
           65       }
           66       Tbcol[k] = P.T;
           67     }
           68     break;
           69   case 'O':
           70     for (unsigned int k = 0; k < m_Mbz; k++) {
           71       Tbcol[k] = exactO(zlevels[k]).TT;
           72     }
           73     break;
           74   }
           75 
           76   // copy column values into 3D arrays
           77   IceModelVec::AccessList list(*m_temp);
           78 
           79   ParallelSection loop(m_grid->com);
           80   try {
           81     for (Points p(*m_grid); p; p.next()) {
           82       m_temp->set_column(p.i(), p.j(), &Tbcol[0]);
           83     }
           84   } catch (...) {
           85     loop.failed();
           86   }
           87   loop.check();
           88 }
           89 
           90 } // end of namespace energy
           91 } // end of namespace pism