URI:
       ticeModelVec2V.cc - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
  HTML git clone git://src.adamsgaard.dk/pism
   DIR Log
   DIR Files
   DIR Refs
   DIR LICENSE
       ---
       ticeModelVec2V.cc (2717B)
       ---
            1 // Copyright (C) 2009--2017 Constantine Khroulev
            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 #include <memory>
           20 using std::dynamic_pointer_cast;
           21 
           22 #include "iceModelVec.hh"
           23 #include "pism_utilities.hh"
           24 #include "IceGrid.hh"
           25 
           26 #include "error_handling.hh"
           27 #include "iceModelVec_helpers.hh"
           28 #include "ConfigInterface.hh"
           29 
           30 namespace pism {
           31 
           32 IceModelVec2V::IceModelVec2V() : IceModelVec2() {
           33   m_dof = 2;
           34   m_begin_end_access_use_dof = false;
           35 }
           36 
           37 IceModelVec2V::IceModelVec2V(IceGrid::ConstPtr grid, const std::string &short_name,
           38                              IceModelVecKind ghostedp, unsigned int stencil_width)
           39   : IceModelVec2() {
           40   m_dof = 2;
           41   m_begin_end_access_use_dof = false;
           42 
           43   create(grid, short_name, ghostedp, stencil_width);
           44 }
           45 
           46 IceModelVec2V::Ptr IceModelVec2V::ToVector(IceModelVec::Ptr input) {
           47   IceModelVec2V::Ptr result = dynamic_pointer_cast<IceModelVec2V,IceModelVec>(input);
           48   if (not (bool)result) {
           49     throw RuntimeError(PISM_ERROR_LOCATION, "dynamic cast failure");
           50   }
           51   return result;
           52 }
           53 
           54 void IceModelVec2V::create(IceGrid::ConstPtr grid, const std::string &short_name,
           55                            IceModelVecKind ghostedp,
           56                            unsigned int stencil_width) {
           57 
           58   IceModelVec2::create(grid, short_name, ghostedp,
           59                        stencil_width, m_dof);
           60 
           61   units::System::Ptr sys = m_grid->ctx()->unit_system();
           62 
           63   m_metadata[0] = SpatialVariableMetadata(sys, "u" + short_name);
           64   m_metadata[1] = SpatialVariableMetadata(sys, "v" + short_name);
           65 
           66   m_name = "vel" + short_name;
           67 }
           68 
           69 Vector2** IceModelVec2V::get_array() {
           70   begin_access();
           71   return static_cast<Vector2**>(m_array);
           72 }
           73 
           74 void IceModelVec2V::add(double alpha, const IceModelVec &x) {
           75   return add_2d<IceModelVec2V>(this, alpha, &x, this);
           76 }
           77 
           78 void IceModelVec2V::add(double alpha, const IceModelVec &x, IceModelVec &result) const {
           79   return add_2d<IceModelVec2V>(this, alpha, &x, &result);
           80 }
           81 
           82 void IceModelVec2V::copy_from(const IceModelVec &source) {
           83   return copy_2d<IceModelVec2V>(&source, this);
           84 }
           85 
           86 } // end of namespace pism