PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
Vector.hh
Go to the documentation of this file.
1 /* Copyright (C) 2020, 2021, 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 #ifndef PISM_ARRAY_VECTOR_HH
20 #define PISM_ARRAY_VECTOR_HH
21 
22 #include "pism/util/array/Array2D.hh"
23 #include "pism/util/Vector2d.hh"
24 
25 namespace pism {
26 namespace array {
27 
28 class Scalar;
29 
30 /** Class for storing and accessing 2D vector fields
31 */
32 class Vector : public array::Array2D<pism::Vector2d> {
33 public:
34  Vector(std::shared_ptr<const Grid> grid, const std::string &short_name);
35 
36  virtual ~Vector() = default;
37 
38  std::shared_ptr<Vector> duplicate() const;
39 protected:
40  Vector(std::shared_ptr<const Grid> grid, const std::string &name,
41  unsigned int stencil_width);
42 };
43 
44 class Vector1 : public Vector {
45 public:
46  Vector1(std::shared_ptr<const Grid> grid, const std::string &name);
47 
50 protected:
51  Vector1(std::shared_ptr<const Grid> grid, const std::string &name,
52  unsigned int stencil_width);
53 };
54 
55 class Vector2 : public Vector1 {
56 public:
57  Vector2(std::shared_ptr<const Grid> grid, const std::string &name);
58 };
59 
60 void compute_magnitude(const array::Vector &input, array::Scalar &result);
61 
62 } // end of namespace array
63 } // end of namespace pism
64 
65 #endif /* PISM_ARRAY_VECTOR_HH */
A storage vector combining related fields in a struct.
Definition: Array2D.hh:32
std::shared_ptr< const Grid > grid() const
Definition: Array.cc:132
unsigned int stencil_width() const
Get the stencil width of the current Array. Returns 0 if ghosts are not available.
Definition: Array.cc:331
Vector1(std::shared_ptr< const Grid > grid, const std::string &name)
Definition: Vector.cc:59
Vector2(std::shared_ptr< const Grid > grid, const std::string &name)
Definition: Vector.cc:70
virtual ~Vector()=default
std::shared_ptr< Vector > duplicate() const
Definition: Vector.cc:50
Vector(std::shared_ptr< const Grid > grid, const std::string &short_name)
Definition: Vector.cc:29
void compute_magnitude(const array::Vector &input, array::Scalar &result)
Definition: Scalar.cc:66