system_norm.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_SYSTEM_NORM_H
21 #define LIBMESH_SYSTEM_NORM_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h" // for Real
25 
26 #ifdef LIBMESH_FORWARD_DECLARE_ENUMS
27 namespace libMesh
28 {
29 enum FEMNormType : int;
30 }
31 #else
32 #include "libmesh/enum_norm_type.h"
33 #endif
34 
35 // C++ includes
36 #include <vector>
37 
38 namespace libMesh
39 {
40 
52 {
53 public:
54 
58  SystemNorm();
59 
68  SystemNorm(const FEMNormType & t);
69 
77  explicit
78  SystemNorm(const std::vector<FEMNormType> & norms);
79 
87  SystemNorm(const std::vector<FEMNormType> & norms,
88  std::vector<Real> & weights);
89 
97  SystemNorm(const std::vector<FEMNormType> & norms,
98  std::vector<std::vector<Real>> & weights);
99 
104  SystemNorm (const SystemNorm &) = default;
105  SystemNorm (SystemNorm &&) = default;
106  SystemNorm & operator= (const SystemNorm &) = default;
107  SystemNorm & operator= (SystemNorm &&) = default;
108  virtual ~SystemNorm() = default;
109 
113  bool is_discrete() const;
114 
119  Real calculate_norm(const std::vector<Real> & v);
120 
124  Real calculate_norm(const std::vector<Real> & v1,
125  const std::vector<Real> & v2);
126 
130  bool is_identity();
131 
135  FEMNormType type(unsigned int var) const;
136 
140  void set_type(unsigned int var, const FEMNormType & t);
141 
145  Real weight(unsigned int var) const;
146 
150  void set_weight(unsigned int var, Real w);
151 
155  void set_off_diagonal_weight(unsigned int i, unsigned int j, Real w);
156 
161  Real weight_sq(unsigned int var) const;
162 
163 
164 
165 private:
166  std::vector<FEMNormType> _norms;
167 
168  std::vector<Real> _weights;
169  std::vector<Real> _weights_sq;
170 
175  std::vector<std::vector<Real>> _off_diagonal_weights;
176 };
177 
178 } // namespace libMesh
179 
180 #endif // LIBMESH_SYSTEM_NORM_H
std::vector< FEMNormType > _norms
Definition: system_norm.h:166
std::vector< Real > _weights_sq
Definition: system_norm.h:169
virtual ~SystemNorm()=default
bool is_discrete() const
Definition: system_norm.C:97
void set_off_diagonal_weight(unsigned int i, unsigned int j, Real w)
Definition: system_norm.C:154
void set_weight(unsigned int var, Real w)
Definition: system_norm.C:140
FEMNormType type(unsigned int var) const
Definition: system_norm.C:110
SystemNorm & operator=(const SystemNorm &)=default
Real weight_sq(unsigned int var) const
Definition: system_norm.C:175
Real weight(unsigned int var) const
Definition: system_norm.C:132
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real calculate_norm(const std::vector< Real > &v)
Definition: system_norm.C:230
std::vector< std::vector< Real > > _off_diagonal_weights
Definition: system_norm.h:175
std::vector< Real > _weights
Definition: system_norm.h:168
void set_type(unsigned int var, const FEMNormType &t)
Definition: system_norm.C:121