Reference documentation for deal.II version 9.6.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\}}\)
Loading...
Searching...
No Matches
vector_tools_common.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2020 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_vector_tools_common_h
16#define dealii_vector_tools_common_h
17
18
19#include <deal.II/base/config.h>
20
22
24
25namespace VectorTools
26{
274
279 "The given point is inside a cell of a "
280 "parallel::distributed::Triangulation that is not "
281 "locally owned by this processor.");
282} // namespace VectorTools
283
284// Make sure we can use NormType with Patterns.
285namespace Patterns
286{
287 namespace Tools
288 {
289 template <>
290 struct Convert<VectorTools::NormType, void>
291 {
295 static std::unique_ptr<Patterns::PatternBase>
297 {
298 return std::make_unique<Patterns::Selection>(
299 "mean|L1_norm|L2_norm|Lp_norm|"
300 "Linfty_norm|H1_seminorm|Hdiv_seminorm|"
301 "H1_norm|W1p_seminorm|W1p_norm|"
302 "W1infty_seminorm|W1infty_norm");
303 }
304
305
306
310 static std::string
312 const Patterns::PatternBase &p =
314 {
315 std::string str;
316 if (s == VectorTools::mean)
317 str = "mean";
318 else if (s == VectorTools::L1_norm)
319 str = "L1_norm";
320 else if (s == VectorTools::L2_norm)
321 str = "L2_norm";
322 else if (s == VectorTools::Lp_norm)
323 str = "Lp_norm";
324 else if (s == VectorTools::Linfty_norm)
325 str = "Linfty_norm";
326 else if (s == VectorTools::H1_seminorm)
327 str = "H1_seminorm";
328 else if (s == VectorTools::Hdiv_seminorm)
329 str = "Hdiv_seminorm";
330 else if (s == VectorTools::H1_norm)
331 str = "H1_norm";
332 else if (s == VectorTools::W1p_seminorm)
333 str = "W1p_seminorm";
334 else if (s == VectorTools::W1infty_seminorm)
335 str = "W1infty_seminorm";
336 else if (s == VectorTools::W1infty_norm)
337 str = "W1infty_norm";
338 else if (s == VectorTools::W1p_norm)
339 str = "W1p_norm";
340 else
341 {
342 AssertThrow(false, ExcMessage("Didn't recognize a norm type."));
343 }
344 AssertThrow(p.match(str), ExcInternalError());
345 return str;
346 }
347
348
353 to_value(const std::string &str,
354 const Patterns::PatternBase &p =
356 {
358 AssertThrow(p.match(str),
360 "String " + str +
361 " cannot be converted to VectorTools::NormType"));
362
363 if (str == "mean")
364 norm = VectorTools::mean;
365 else if (str == "L1_norm")
367 else if (str == "L2_norm")
369 else if (str == "Lp_norm")
371 else if (str == "Linfty_norm")
373 else if (str == "H1_seminorm")
375 else if (str == "Hdiv_seminorm")
377 else if (str == "H1_norm")
379 else if (str == "W1p_seminorm")
381 else if (str == "W1infty_seminorm")
383 else if (str == "W1infty_norm")
385 else if (str == "W1p_norm")
387 else
388 {
389 AssertThrow(false, ExcMessage("Didn't recognize a norm type."));
390 }
391 return norm;
392 }
393 };
394 } // namespace Tools
395} // namespace Patterns
396
398
399#endif // dealii_vector_tools_common_h
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
#define DeclExceptionMsg(Exception, defaulttext)
Definition exceptions.h:494
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcPointNotAvailableHere()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
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())