Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
vector_tools_common.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2020 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_vector_tools_common_h
17 #define dealii_vector_tools_common_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/patterns.h>
23 
25 
26 namespace VectorTools
27 {
53  enum NormType
54  {
80 
96 
114 
132 
149 
166 
187 
205 
222 
241 
259 
275  };
276 
281  "The given point is inside a cell of a "
282  "parallel::distributed::Triangulation that is not "
283  "locally owned by this processor.");
284 } // namespace VectorTools
285 
286 // Make sure we can use NormType with Patterns.
287 namespace Patterns
288 {
289  namespace Tools
290  {
291  template <>
292  struct Convert<VectorTools::NormType, void>
293  {
297  static std::unique_ptr<Patterns::PatternBase>
299  {
300  return std_cxx14::make_unique<Patterns::Selection>(
301  "mean|L1_norm|L2_norm|Lp_norm|"
302  "Linfty_norm|H1_seminorm|Hdiv_seminorm|"
303  "H1_norm|W1p_seminorm|W1p_norm|"
304  "W1infty_seminorm|W1infty_norm");
305  }
306 
307 
308 
312  static std::string
314  const std::unique_ptr<Patterns::PatternBase> &p =
316  {
317  std::string str;
318  if (s == VectorTools::mean)
319  str = "mean";
320  else if (s == VectorTools::L1_norm)
321  str = "L1_norm";
322  else if (s == VectorTools::L2_norm)
323  str = "L2_norm";
324  else if (s == VectorTools::Lp_norm)
325  str = "Lp_norm";
326  else if (s == VectorTools::Linfty_norm)
327  str = "Linfty_norm";
328  else if (s == VectorTools::H1_seminorm)
329  str = "H1_seminorm";
330  else if (s == VectorTools::Hdiv_seminorm)
331  str = "Hdiv_seminorm";
332  else if (s == VectorTools::H1_norm)
333  str = "H1_norm";
334  else if (s == VectorTools::W1p_seminorm)
335  str = "W1p_seminorm";
336  else if (s == VectorTools::W1infty_seminorm)
337  str = "W1infty_seminorm";
338  else if (s == VectorTools::W1infty_norm)
339  str = "W1infty_norm";
340  else if (s == VectorTools::W1p_norm)
341  str = "W1p_norm";
342  else
343  {
344  AssertThrow(false, ExcMessage("Didn't recognize a norm type."));
345  }
346  AssertThrow(p->match(str), ExcInternalError());
347  return str;
348  }
349 
350 
354  static VectorTools::NormType
355  to_value(const std::string & str,
356  const std::unique_ptr<Patterns::PatternBase> &p =
358  {
360  AssertThrow(p->match(str),
361  ExcMessage(
362  "String " + str +
363  " cannot be converted to VectorTools::NormType"));
364 
365  if (str == "mean")
367  else if (str == "L1_norm")
369  else if (str == "L2_norm")
371  else if (str == "Lp_norm")
373  else if (str == "Linfty_norm")
375  else if (str == "H1_seminorm")
377  else if (str == "Hdiv_seminorm")
379  else if (str == "H1_norm")
381  else if (str == "W1p_seminorm")
383  else if (str == "W1infty_seminorm")
385  else if (str == "W1infty_norm")
387  else if (str == "W1p_norm")
389  else
390  {
391  AssertThrow(false, ExcMessage("Didn't recognize a norm type."));
392  }
393  return norm;
394  }
395  };
396  } // namespace Tools
397 } // namespace Patterns
398 
400 
401 #endif // dealii_vector_tools_common_h
DeclExceptionMsg
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:496
VectorTools::L2_norm
@ L2_norm
Definition: vector_tools_common.h:113
Patterns
Definition: patterns.h:72
Patterns::Tools::Convert< VectorTools::NormType, void >::to_pattern
static std::unique_ptr< Patterns::PatternBase > to_pattern()
Definition: vector_tools_common.h:298
VectorTools::W1infty_seminorm
@ W1infty_seminorm
Definition: vector_tools_common.h:258
VectorTools::H1_norm
@ H1_norm
Definition: vector_tools_common.h:204
VectorTools::NormType
NormType
Definition: vector_tools_common.h:53
VectorTools::W1infty_norm
@ W1infty_norm
Definition: vector_tools_common.h:274
Patterns::Tools::Convert< VectorTools::NormType, void >::to_string
static std::string to_string(const VectorTools::NormType &s, const std::unique_ptr< Patterns::PatternBase > &p=Convert< VectorTools::NormType >::to_pattern())
Definition: vector_tools_common.h:313
Patterns::Tools::Convert
Definition: patterns.h:1305
VectorTools
Definition: vector_tools.h:303
VectorTools::L1_norm
@ L1_norm
Definition: vector_tools_common.h:95
StandardExceptions::ExcMessage
static ::ExceptionBase & ExcMessage(std::string arg1)
VectorTools::ExcPointNotAvailableHere
static ::ExceptionBase & ExcPointNotAvailableHere()
LocalIntegrators::Divergence::norm
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim >>> &Du)
Definition: divergence.h:548
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
VectorTools::mean
@ mean
Definition: vector_tools_common.h:79
VectorTools::Lp_norm
@ Lp_norm
Definition: vector_tools_common.h:131
VectorTools::W1p_seminorm
@ W1p_seminorm
Definition: vector_tools_common.h:221
StandardExceptions::ExcInternalError
static ::ExceptionBase & ExcInternalError()
VectorTools::H1_seminorm
@ H1_seminorm
Definition: vector_tools_common.h:165
Patterns::Tools::Convert< VectorTools::NormType, void >::to_value
static VectorTools::NormType to_value(const std::string &str, const std::unique_ptr< Patterns::PatternBase > &p=Convert< VectorTools::NormType >::to_pattern())
Definition: vector_tools_common.h:355
VectorTools::Linfty_norm
@ Linfty_norm
Definition: vector_tools_common.h:148
config.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
patterns.h
AssertThrow
#define AssertThrow(cond, exc)
Definition: exceptions.h:1531
VectorTools::Hdiv_seminorm
@ Hdiv_seminorm
Definition: vector_tools_common.h:186
VectorTools::W1p_norm
@ W1p_norm
Definition: vector_tools_common.h:240