From e066235ba1b5ab66af07dcf5a7ad9487120e6d6e Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 8 Feb 2012 15:13:40 +0000 Subject: [PATCH] Add l1_norm and linfty_norm for Tensor<2,dim>. git-svn-id: https://svn.dealii.org/trunk@25014 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 4 ++ deal.II/include/deal.II/base/tensor.h | 59 ++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 059568060c..27efd234fa 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -87,6 +87,10 @@ enabled due to a missing include file in file

Specific improvements

    +
  1. New: There are now global functions l1_norm() and linfty_norm() that compute +the respective norms of a rank-2 tensor. +
    +(Wolfgang Bangerth, 2012/02/08)
  2. New: VectorTools::interpolation_to_different_mesh implemented which interpolates between DoFHandlers with different triangulations based on a common coarse grid. diff --git a/deal.II/include/deal.II/base/tensor.h b/deal.II/include/deal.II/base/tensor.h index a0280769c1..132bebbea1 100644 --- a/deal.II/include/deal.II/base/tensor.h +++ b/deal.II/include/deal.II/base/tensor.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2011 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -1798,6 +1798,63 @@ transpose (const Tensor<2,3,Number> &t) #endif // DOXYGEN +/** + * Return the $l_1$ norm of the given rank-2 tensor, where + * $||t||_1 = \max_j \sum_i |t_{ij}|$ (maximum of + * the sums over columns). + * + * @relates Tensor + * @author Wolfgang Bangerth, 2012 + */ +template +inline +double +l1_norm (const Tensor<2,dim,Number> &t) +{ + double max = 0; + for (unsigned int j=0; j max) + max = sum; + } + + return max; +} + + + +/** + * Return the $l_\infty$ norm of the given rank-2 tensor, where + * $||t||_\infty = \max_i \sum_j |t_{ij}|$ (maximum of + * the sums over rows). + * + * @relates Tensor + * @author Wolfgang Bangerth, 2012 + */ +template +inline +double +linfty_norm (const Tensor<2,dim,Number> &t) +{ + double max = 0; + for (unsigned int i=0; i max) + max = sum; + } + + return max; +} + + /** * Multiplication of a tensor of general rank with a scalar Number -- 2.39.5