Reference documentation for deal.II version GIT 77cf9aa859 2023-06-10 04:00:02+00:00
\(\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 - 2021 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 
258 
274  };
275 
280  "The given point is inside a cell of a "
281  "parallel::distributed::Triangulation that is not "
282  "locally owned by this processor.");
283 } // namespace VectorTools
284 
285 // Make sure we can use NormType with Patterns.
286 namespace Patterns
287 {
288  namespace Tools
289  {
290  template <>
291  struct Convert<VectorTools::NormType, void>
292  {
296  static std::unique_ptr<Patterns::PatternBase>
298  {
299  return std::make_unique<Patterns::Selection>(
300  "mean|L1_norm|L2_norm|Lp_norm|"
301  "Linfty_norm|H1_seminorm|Hdiv_seminorm|"
302  "H1_norm|W1p_seminorm|W1p_norm|"
303  "W1infty_seminorm|W1infty_norm");
304  }
305 
306 
307 
311  static std::string
313  const Patterns::PatternBase &p =
315  {
316  std::string str;
317  if (s == VectorTools::mean)
318  str = "mean";
319  else if (s == VectorTools::L1_norm)
320  str = "L1_norm";
321  else if (s == VectorTools::L2_norm)
322  str = "L2_norm";
323  else if (s == VectorTools::Lp_norm)
324  str = "Lp_norm";
325  else if (s == VectorTools::Linfty_norm)
326  str = "Linfty_norm";
327  else if (s == VectorTools::H1_seminorm)
328  str = "H1_seminorm";
329  else if (s == VectorTools::Hdiv_seminorm)
330  str = "Hdiv_seminorm";
331  else if (s == VectorTools::H1_norm)
332  str = "H1_norm";
333  else if (s == VectorTools::W1p_seminorm)
334  str = "W1p_seminorm";
335  else if (s == VectorTools::W1infty_seminorm)
336  str = "W1infty_seminorm";
337  else if (s == VectorTools::W1infty_norm)
338  str = "W1infty_norm";
339  else if (s == VectorTools::W1p_norm)
340  str = "W1p_norm";
341  else
342  {
343  AssertThrow(false, ExcMessage("Didn't recognize a norm type."));
344  }
345  AssertThrow(p.match(str), ExcInternalError());
346  return str;
347  }
348 
349 
353  static VectorTools::NormType
354  to_value(const std::string & str,
355  const Patterns::PatternBase &p =
357  {
359  AssertThrow(p.match(str),
360  ExcMessage(
361  "String " + str +
362  " cannot be converted to VectorTools::NormType"));
363 
364  if (str == "mean")
366  else if (str == "L1_norm")
368  else if (str == "L2_norm")
370  else if (str == "Lp_norm")
372  else if (str == "Linfty_norm")
374  else if (str == "H1_seminorm")
376  else if (str == "Hdiv_seminorm")
378  else if (str == "H1_norm")
380  else if (str == "W1p_seminorm")
382  else if (str == "W1infty_seminorm")
384  else if (str == "W1infty_norm")
386  else if (str == "W1p_norm")
388  else
389  {
390  AssertThrow(false, ExcMessage("Didn't recognize a norm type."));
391  }
392  return norm;
393  }
394  };
395  } // namespace Tools
396 } // namespace Patterns
397 
399 
400 #endif // dealii_vector_tools_common_h
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:475
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:476
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcPointNotAvailableHere()
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:488
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
Definition: exceptions.h:1703
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim >>> &Du)
Definition: divergence.h:472
static std::unique_ptr< Patterns::PatternBase > to_pattern()
static std::string to_string(const VectorTools::NormType &s, const Patterns::PatternBase &p= *Convert< VectorTools::NormType >::to_pattern())
static VectorTools::NormType to_value(const std::string &str, const Patterns::PatternBase &p= *Convert< VectorTools::NormType >::to_pattern())