Improved form of BlockCoeffTwoNorm
This commit is contained in:
parent
0e04d88628
commit
ed73abd931
4 changed files with 96 additions and 16 deletions
|
@ -61,8 +61,13 @@ Foam::scalar Foam::BlockCoeffTwoNorm<Type>::normalize
|
||||||
}
|
}
|
||||||
else if (a.activeType() == Foam::BlockCoeff<Type>::SQUARE)
|
else if (a.activeType() == Foam::BlockCoeff<Type>::SQUARE)
|
||||||
{
|
{
|
||||||
// Note: for two-norm, use mag
|
// Note: for two-norm, use mag of diag
|
||||||
return mag(a.asSquare());
|
typedef typename BlockCoeff<Type>::linearType linearType;
|
||||||
|
|
||||||
|
linearType diag;
|
||||||
|
contractLinear(diag, a.asSquare());
|
||||||
|
|
||||||
|
return mag(diag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -94,13 +99,18 @@ void Foam::BlockCoeffTwoNorm<Type>::normalize
|
||||||
}
|
}
|
||||||
else if (a.activeType() == Foam::BlockCoeff<Type>::LINEAR)
|
else if (a.activeType() == Foam::BlockCoeff<Type>::LINEAR)
|
||||||
{
|
{
|
||||||
// Note: for two-norm, use mag
|
// Note: for two-norm, use mag = sqrt(sum magSqr(cmpt))
|
||||||
b = mag(a.asLinear());
|
b = mag(a.asLinear());
|
||||||
}
|
}
|
||||||
else if (a.activeType() == Foam::BlockCoeff<Type>::SQUARE)
|
else if (a.activeType() == Foam::BlockCoeff<Type>::SQUARE)
|
||||||
{
|
{
|
||||||
// Note: for two-norm, use mag
|
// Note: for two-norm, use mag of diag
|
||||||
b = mag(a.asSquare());
|
typedef typename BlockCoeff<Type>::linearTypeField linearTypeField;
|
||||||
|
|
||||||
|
linearTypeField diag(a.size());
|
||||||
|
contractLinear(diag, a.asSquare());
|
||||||
|
|
||||||
|
b = mag(diag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,7 @@ SourceFiles
|
||||||
#ifndef blockCoeffTwoNorms_H
|
#ifndef blockCoeffTwoNorms_H
|
||||||
#define blockCoeffTwoNorms_H
|
#define blockCoeffTwoNorms_H
|
||||||
|
|
||||||
|
#include "scalarBlockCoeffTwoNorm.H"
|
||||||
#include "tensorBlockCoeffTwoNorm.H"
|
#include "tensorBlockCoeffTwoNorm.H"
|
||||||
#include "BlockCoeffTwoNorm.H"
|
#include "BlockCoeffTwoNorm.H"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | foam-extend: Open Source CFD
|
||||||
|
\\ / O peration | Version: 4.0
|
||||||
|
\\ / A nd | Web: http://www.foam-extend.org
|
||||||
|
\\/ M anipulation | For copyright notice see file Copyright
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of foam-extend.
|
||||||
|
|
||||||
|
foam-extend is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
foam-extend is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
BlockCoeffTwoNorm
|
||||||
|
|
||||||
|
Description
|
||||||
|
Class for two norm of block coeffs. Specilization for scalar. Implemented
|
||||||
|
to avoid issues with asScalar, asSquare etc.
|
||||||
|
|
||||||
|
Author
|
||||||
|
Hrvoje Jasak, Wikki Ltd. All rights reserved
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef scalarBlockCoeffTwoNorm_H
|
||||||
|
#define scalarBlockCoeffTwoNorm_H
|
||||||
|
|
||||||
|
#include "blockCoeffs.H"
|
||||||
|
#include "blockCoeffNorms.H"
|
||||||
|
#include "BlockCoeffNorm.H"
|
||||||
|
#include "BlockCoeffTwoNorm.H"
|
||||||
|
#include "runTimeSelectionTables.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline scalar BlockCoeffTwoNorm<scalar>::normalize
|
||||||
|
(
|
||||||
|
const BlockCoeff<scalar>& a
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Note: for two-norm, use mag
|
||||||
|
return mag(a.asScalar());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void BlockCoeffTwoNorm<scalar>::normalize
|
||||||
|
(
|
||||||
|
Field<scalar>& b,
|
||||||
|
const CoeffField<scalar>& a
|
||||||
|
)
|
||||||
|
{
|
||||||
|
b = mag(a.asScalar());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
|
@ -33,9 +33,6 @@ Description
|
||||||
Author
|
Author
|
||||||
Klas Jareteg, 2013-01-30
|
Klas Jareteg, 2013-01-30
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
BlockCoeffTwoNorm.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef tensorBlockCoeffTwoNorm_H
|
#ifndef tensorBlockCoeffTwoNorm_H
|
||||||
|
@ -52,11 +49,6 @@ SourceFiles
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class BlockCoeffTwoNorm Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline scalar BlockCoeffTwoNorm<tensor>::normalize
|
inline scalar BlockCoeffTwoNorm<tensor>::normalize
|
||||||
(
|
(
|
||||||
|
@ -116,9 +108,6 @@ inline void BlockCoeffTwoNorm<tensor>::normalize
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Reference in a new issue