libMesh
Loading...
Searching...
No Matches
system_norm.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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// C++ includes
27#include <vector>
28
29namespace libMesh
30{
31
32// Forward declarations
33enum FEMNormType : int;
34
50{
51public:
52
56 SystemNorm();
57
66 SystemNorm(const FEMNormType & t);
67
75 explicit
76 SystemNorm(std::vector<FEMNormType> norms);
77
85 SystemNorm(std::vector<FEMNormType> norms,
86 std::vector<Real> & weights);
87
95 SystemNorm(std::vector<FEMNormType> norms,
96 std::vector<std::vector<Real>> & weights);
97
102 SystemNorm (const SystemNorm &) = default;
103 SystemNorm (SystemNorm &&) = default;
104 SystemNorm & operator= (const SystemNorm &) = default;
106 virtual ~SystemNorm() = default;
107
111 bool is_discrete() const;
112
117 Real calculate_norm(const std::vector<Real> & v);
118
122 Real calculate_norm(const std::vector<Real> & v1,
123 const std::vector<Real> & v2);
124
128 bool is_identity();
129
137 FEMNormType type(unsigned int var) const;
138
143 void set_type(unsigned int var, const FEMNormType & t);
144
152 Real weight(unsigned int var) const;
153
158 void set_weight(unsigned int var, Real w);
159
163 void set_off_diagonal_weight(unsigned int i, unsigned int j, Real w);
164
169 Real weight_sq(unsigned int var) const;
170
171
172
173private:
174 std::vector<FEMNormType> _norms;
175
176 std::vector<Real> _weights;
177 std::vector<Real> _weights_sq;
178
183 std::vector<std::vector<Real>> _off_diagonal_weights;
184};
185
186} // namespace libMesh
187
188#endif // LIBMESH_SYSTEM_NORM_H
void ErrorVector unsigned int
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a ...
Definition system_norm.h:50
virtual ~SystemNorm()=default
SystemNorm(SystemNorm &&)=default
bool is_discrete() const
Definition system_norm.C:99
void set_type(unsigned int var, const FEMNormType &t)
Sets the type of the norm in variable var, as well as for any unset variables with index less than va...
std::vector< FEMNormType > _norms
void set_weight(unsigned int var, Real w)
Sets the weight corresponding to the norm in variable var, as well as for any unset variables with in...
std::vector< Real > _weights
void set_off_diagonal_weight(unsigned int i, unsigned int j, Real w)
Sets the weight corresponding to the norm from the variable pair v1(var1) coming from v2(var2).
FEMNormType type(unsigned int var) const
SystemNorm & operator=(const SystemNorm &)=default
SystemNorm()
Constructor, defaults to DISCRETE_L2 with weight of 1.0.
Definition system_norm.C:27
std::vector< std::vector< Real > > _off_diagonal_weights
One more data structure needed to store the off diagonal components for the generalize SystemNorm cas...
Real calculate_norm(const std::vector< Real > &v)
std::vector< Real > _weights_sq
Real weight(unsigned int var) const
Real weight_sq(unsigned int var) const
SystemNorm(const SystemNorm &)=default
Copy/move ctor, copy/move assignment operator, and destructor are all explicitly defaulted for this s...
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real