ENH: support zip/unzip rows of symmTensor (#2487)

- was previously only implemented for tensor
This commit is contained in:
Mark Olesen 2022-05-25 17:12:06 +02:00
parent 082a0e687a
commit 21234ae296
21 changed files with 1079 additions and 313 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,6 +28,7 @@ Application
\*---------------------------------------------------------------------------*/
#include "symmTensorField.H"
#include "tensorField.H"
#include "FieldFields.H"
#include "Random.H"
@ -189,11 +190,21 @@ int main(int argc, char *argv[])
Info<<" =>";
printFieldField(sf1);
Info<< nl;
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
{
unzipRow(sf1, cmpt, slice[0]);
Info<< "row " << label(cmpt) << ": ";
printFieldField(slice[0]);
}
unzipDiag(sf1, slice[0]);
Info<< nl
<< "diag: ";
printFieldField(cmpts[0]);
Info<< "diag: ";
printFieldField(slice[0]);
Info<< nl;
unzip
(
@ -215,8 +226,8 @@ int main(int argc, char *argv[])
cmpts[1]
);
Info<<"rezip (swapped diag): "
<<" => " << sf1 << nl;
Info<< "rezip (swapped diag): "
<< " => " << sf1 << nl;
}
// sphericalTensorField

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -168,12 +168,24 @@ int main(int argc, char *argv[])
Info<< sf1 << nl;
Info<<" => " << tf1 << nl;
sf1 = symmTensor(1, 2, 3, 4, 5, 6);
Info<< nl << "reset: " << sf1 << nl;
FixedList<scalarField, 6> cmpts(scalarField(sf1.size()));
Info<<" => " << sf1 << nl;
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
{
Info<< "col/row " << label(cmpt) << ": "
<< sf1[0].col(cmpt) << ' '
<< sf1[0].row(cmpt) << nl;
}
Info<< nl
<< "diag: " << unzipDiag(sf1) << nl;
<< "diag: " << unzipDiag(sf1) << nl
<< "row 0: " << unzipRow(sf1, vector::X) << nl
<< "row 1: " << unzipCol(sf1, vector::Y) << nl // same as row
<< "row 2: " << unzipRow(sf1, vector::Z) << nl;
unzip
(
@ -183,7 +195,7 @@ int main(int argc, char *argv[])
cmpts[5]
);
Info<<"unzip:" << nl
Info<< "unzip:" << nl
<< "xx : " << cmpts[0] << nl
<< "xy : " << cmpts[1] << nl
<< "xz : " << cmpts[2] << nl
@ -192,7 +204,7 @@ int main(int argc, char *argv[])
<< "zz : " << cmpts[5] << nl
<< nl;
// Transposed
// Transposed diagonal
zip
(
sf1,
@ -201,8 +213,8 @@ int main(int argc, char *argv[])
cmpts[1]
);
Info<<"rezip (swapped diag): "
<<" => " << sf1 << nl;
Info<< "rezip (swapped diag): "
<< " => " << sf1 << nl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -24,9 +24,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Specialisation of FieldField\<T\> for symmTensor.
\*---------------------------------------------------------------------------*/
#include "symmTensorFieldField.H"
@ -86,6 +83,100 @@ void Foam::unzip
}
template<template<class> class Field, class Cmpt>
void Foam::zipRows
(
FieldField<Field, SymmTensor<Cmpt>>& result,
const FieldField<Field, Vector<Cmpt>>& x,
const FieldField<Field, Vector<Cmpt>>& y,
const FieldField<Field, Vector<Cmpt>>& z
)
{
forAll(result, i)
{
Foam::zipRows(result[i], x[i], y[i], z[i]);
}
}
template<template<class> class Field, class Cmpt>
void Foam::zipCols
(
FieldField<Field, SymmTensor<Cmpt>>& result,
const FieldField<Field, Vector<Cmpt>>& x,
const FieldField<Field, Vector<Cmpt>>& y,
const FieldField<Field, Vector<Cmpt>>& z
)
{
forAll(result, i)
{
Foam::zipCols(result[i], x[i], y[i], z[i]);
}
}
template<template<class> class Field, class Cmpt>
void Foam::unzipRows
(
const FieldField<Field, SymmTensor<Cmpt>>& input,
FieldField<Field, Vector<Cmpt>>& x,
FieldField<Field, Vector<Cmpt>>& y,
FieldField<Field, Vector<Cmpt>>& z
)
{
forAll(input, i)
{
Foam::unzipRows(input[i], x[i], y[i], z[i]);
}
}
template<template<class> class Field, class Cmpt>
void Foam::unzipCols
(
const FieldField<Field, SymmTensor<Cmpt>>& input,
FieldField<Field, Vector<Cmpt>>& x,
FieldField<Field, Vector<Cmpt>>& y,
FieldField<Field, Vector<Cmpt>>& z
)
{
forAll(input, i)
{
Foam::unzipCols(input[i], x[i], y[i], z[i]);
}
}
template<template<class> class Field, class Cmpt>
void Foam::unzipRow
(
const FieldField<Field, SymmTensor<Cmpt>>& input,
const direction idx,
FieldField<Field, Vector<Cmpt>>& result
)
{
forAll(input, i)
{
Foam::unzipRow(input[i], idx, result[i]);
}
}
template<template<class> class Field, class Cmpt>
void Foam::unzipCol
(
const FieldField<Field, SymmTensor<Cmpt>>& input,
const direction idx,
FieldField<Field, Vector<Cmpt>>& result
)
{
forAll(input, i)
{
Foam::unzipCol(input[i], idx, result[i]);
}
}
template<template<class> class Field, class Cmpt>
void Foam::unzipDiag
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef symmTensorFieldField_H
#define symmTensorFieldField_H
#ifndef Foam_symmTensorFieldField_H
#define Foam_symmTensorFieldField_H
#include "FieldField.H"
#include "symmTensor.H"
@ -77,6 +77,66 @@ void unzip
FieldField<Field, Cmpt>& zz
);
//- Zip together symmTensor field field from row components
template<template<class> class Field, class Cmpt>
void zipRows
(
FieldField<Field, SymmTensor<Cmpt>>& result,
const FieldField<Field, Vector<Cmpt>>& x,
const FieldField<Field, Vector<Cmpt>>& y,
const FieldField<Field, Vector<Cmpt>>& z
);
//- Zip together symmTensor field from column components
template<template<class> class Field, class Cmpt>
void zipCols
(
FieldField<Field, SymmTensor<Cmpt>>& result,
const FieldField<Field, Vector<Cmpt>>& x,
const FieldField<Field, Vector<Cmpt>>& y,
const FieldField<Field, Vector<Cmpt>>& z
);
//- Extract symmTensor field field rows
template<template<class> class Field, class Cmpt>
void unzipRows
(
const FieldField<Field, SymmTensor<Cmpt>>& input,
FieldField<Field, Vector<Cmpt>>& x,
FieldField<Field, Vector<Cmpt>>& y,
FieldField<Field, Vector<Cmpt>>& z
);
//- Extract symmTensor field field columns
template<template<class> class Field, class Cmpt>
void unzipCols
(
const FieldField<Field, SymmTensor<Cmpt>>& input,
FieldField<Field, Vector<Cmpt>>& x,
FieldField<Field, Vector<Cmpt>>& y,
FieldField<Field, Vector<Cmpt>>& z
);
//- Extract a symmTensor field field row (x,y,z) == (0,1,2)
template<template<class> class Field, class Cmpt>
void unzipRow
(
const FieldField<Field, SymmTensor<Cmpt>>& input,
const direction idx, //!< vector::components
FieldField<Field, Vector<Cmpt>>& result
);
//- Extract a symmTensor field field column (x,y,z) == (0,1,2)
template<template<class> class Field, class Cmpt>
void unzipCol
(
const FieldField<Field, SymmTensor<Cmpt>>& input,
const direction idx, //!< vector::components
FieldField<Field, Vector<Cmpt>>& result
);
//- Extract a symmTensor field field diagonal
template<template<class> class Field, class Cmpt>
void unzipDiag

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -24,9 +24,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Specialisation of FieldField\<T\> for tensor.
\*---------------------------------------------------------------------------*/
#include "tensorFieldField.H"
@ -160,13 +157,13 @@ template<template<class> class Field, class Cmpt>
void Foam::unzipRow
(
const FieldField<Field, Tensor<Cmpt>>& input,
const vector::components cmpt,
const direction idx,
FieldField<Field, Vector<Cmpt>>& result
)
{
forAll(input, i)
{
Foam::unzipRow(input[i], cmpt, result[i]);
Foam::unzipRow(input[i], idx, result[i]);
}
}
@ -175,13 +172,13 @@ template<template<class> class Field, class Cmpt>
void Foam::unzipCol
(
const FieldField<Field, Tensor<Cmpt>>& input,
const vector::components cmpt,
const direction idx,
FieldField<Field, Vector<Cmpt>>& result
)
{
forAll(input, i)
{
Foam::unzipCol(input[i], cmpt, result[i]);
Foam::unzipCol(input[i], idx, result[i]);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef tensorFieldField_H
#define tensorFieldField_H
#ifndef Foam_tensorFieldField_H
#define Foam_tensorFieldField_H
#include "sphericalTensorFieldField.H"
#include "symmTensorFieldField.H"
@ -132,7 +132,7 @@ template<template<class> class Field, class Cmpt>
void unzipRow
(
const FieldField<Field, Tensor<Cmpt>>& input,
const vector::components cmpt,
const direction idx, //!< vector::components
FieldField<Field, Vector<Cmpt>>& result
);
@ -141,7 +141,7 @@ template<template<class> class Field, class Cmpt>
void unzipCol
(
const FieldField<Field, Tensor<Cmpt>>& input,
const vector::components cmpt,
const direction idx, //!< vector::components
FieldField<Field, Vector<Cmpt>>& result
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef symmTensorField_H
#define symmTensorField_H
#ifndef Foam_symmTensorField_H
#define Foam_symmTensorField_H
#include "scalarField.H"
#include "vectorField.H"
@ -86,6 +86,76 @@ tmp<Field<SymmTensor<Cmpt>>> zip
);
//- Zip together symmTensor field from row components
template<class Cmpt>
void zipRows
(
Field<SymmTensor<Cmpt>>& result,
const UList<Vector<Cmpt>>& x,
const UList<Vector<Cmpt>>& y,
const UList<Vector<Cmpt>>& z
);
//- Zip together symmTensor field from column components
template<class Cmpt>
void zipCols
(
Field<SymmTensor<Cmpt>>& result,
const UList<Vector<Cmpt>>& x,
const UList<Vector<Cmpt>>& y,
const UList<Vector<Cmpt>>& z
)
{
zipRows(result, x, y, z);
}
//- Extract symmTensor field rows
template<class Cmpt>
void unzipRows
(
const UList<SymmTensor<Cmpt>>& input,
Field<Vector<Cmpt>>& x,
Field<Vector<Cmpt>>& y,
Field<Vector<Cmpt>>& z
);
//- Extract symmTensor field columns
template<class Cmpt>
void unzipCols
(
const UList<SymmTensor<Cmpt>>& input,
Field<Vector<Cmpt>>& x,
Field<Vector<Cmpt>>& y,
Field<Vector<Cmpt>>& z
)
{
unzipRows(input, x, y, z);
}
//- Extract a symmTensor field row (x,y,z) == (0,1,2)
template<class Cmpt>
void unzipRow
(
const UList<SymmTensor<Cmpt>>& input,
const direction idx, //!< vector::components
Field<Vector<Cmpt>>& result
);
//- Extract a symmTensor field column (x,y,z) == (0,1,2)
template<class Cmpt>
void unzipCol
(
const UList<SymmTensor<Cmpt>>& input,
const direction idx, //!< vector::components
Field<Vector<Cmpt>>& result
)
{
unzipRow(input, idx, result);
}
//- Extract a symmTensor field diagonal
template<class Cmpt>
void unzipDiag
@ -94,7 +164,26 @@ void unzipDiag
Field<Vector<Cmpt>>& result
);
//- Extract a symmTensor field diagonal
//- Extract a symmTensor field row (x,y,z) == (0,1,2)
template<class Cmpt>
tmp<Field<Vector<Cmpt>>> unzipRow
(
const Field<SymmTensor<Cmpt>>& input,
const direction idx //!< vector::components
);
//- Extract a symmTensor field column (x,y,z) == (0,1,2)
template<class Cmpt>
tmp<Field<Vector<Cmpt>>> unzipCol
(
const Field<SymmTensor<Cmpt>>& input,
const direction idx //!< vector::components
)
{
return unzipRow(input, idx);
}
//- Extract a symmTensor field diagonal
template<class Cmpt>
tmp<Field<Vector<Cmpt>>> unzipDiag
(

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -125,6 +125,128 @@ Foam::zip
}
template<class Cmpt>
void Foam::zipRows
(
Field<SymmTensor<Cmpt>>& result,
const UList<Vector<Cmpt>>& x,
const UList<Vector<Cmpt>>& y,
const UList<Vector<Cmpt>>& z
)
{
const label len = result.size();
#ifdef FULLDEBUG
if (len != x.size() || len != y.size() || len != z.size())
{
FatalErrorInFunction
<< "Components sizes do not match: " << len << " ("
<< x.size() << ' ' << y.size() << ' ' << z.size() << ')'
<< nl
<< abort(FatalError);
}
#endif
for (label i=0; i < len; ++i)
{
// Like symmTensor::rows() but removed redundancy
result[i].xx() = x[i].x();
result[i].xy() = x[i].y();
result[i].xz() = x[i].z();
result[i].yy() = y[i].y();
result[i].yz() = y[i].z();
result[i].zz() = z[i].z();
}
}
template<class Cmpt>
void Foam::unzipRows
(
const UList<SymmTensor<Cmpt>>& input,
Field<Vector<Cmpt>>& x,
Field<Vector<Cmpt>>& y,
Field<Vector<Cmpt>>& z
)
{
const label len = input.size();
#ifdef FULLDEBUG
if (len != x.size() || len != y.size() || len != z.size())
{
FatalErrorInFunction
<< "Components sizes do not match: " << len << " ("
<< x.size() << ' ' << y.size() << ' ' << z.size() << ')'
<< nl
<< abort(FatalError);
}
#endif
for (label i=0; i < len; ++i)
{
x[i] = input[i].x();
y[i] = input[i].y();
z[i] = input[i].z();
}
}
template<class Cmpt>
void Foam::unzipRow
(
const UList<SymmTensor<Cmpt>>& input,
const direction idx,
Field<Vector<Cmpt>>& result
)
{
const label len = input.size();
#ifdef FULLDEBUG
if (len != result.size())
{
FatalErrorInFunction
<< "Components sizes do not match: " << len << " ("
<< result.size() << ')'
<< nl
<< abort(FatalError);
}
#endif
switch (idx)
{
case vector::components::X :
{
for (label i=0; i < len; ++i)
{
result[i] = input[i].x();
}
}
break;
case vector::components::Y :
{
for (label i=0; i < len; ++i)
{
result[i] = input[i].y();
}
}
break;
case vector::components::Z :
{
for (label i=0; i < len; ++i)
{
result[i] = input[i].z();
}
}
break;
}
}
template<class Cmpt>
void Foam::unzipDiag
(
@ -152,6 +274,22 @@ void Foam::unzipDiag
}
template<class Cmpt>
Foam::tmp<Foam::Field<Foam::Vector<Cmpt>>>
Foam::unzipRow
(
const Field<SymmTensor<Cmpt>>& input,
const direction idx
)
{
auto tresult = tmp<Field<Vector<Cmpt>>>::New(input.size());
Foam::unzipRow(input, idx, tresult.ref());
return tresult;
}
template<class Cmpt>
Foam::tmp<Foam::Field<Foam::Vector<Cmpt>>>
Foam::unzipDiag

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef tensorField_H
#define tensorField_H
#ifndef Foam_tensorField_H
#define Foam_tensorField_H
#include "scalarField.H"
#include "vectorField.H"
@ -133,7 +133,7 @@ template<class Cmpt>
void unzipRow
(
const UList<Tensor<Cmpt>>& input,
const vector::components cmpt,
const direction idx, //!< vector::components
Field<Vector<Cmpt>>& result
);
@ -142,7 +142,7 @@ template<class Cmpt>
void unzipCol
(
const UList<Tensor<Cmpt>>& input,
const vector::components cmpt,
const direction idx, //!< vector::components
Field<Vector<Cmpt>>& result
);
@ -159,7 +159,7 @@ template<class Cmpt>
tmp<Field<Vector<Cmpt>>> unzipRow
(
const Field<Tensor<Cmpt>>& input,
const vector::components cmpt
const direction idx //!< vector::components
);
//- Extract a tensor field column (x,y,z) == (0,1,2)
@ -167,7 +167,7 @@ template<class Cmpt>
tmp<Field<Vector<Cmpt>>> unzipCol
(
const Field<Tensor<Cmpt>>& input,
const vector::components cmpt
const direction idx //!< vector::components
);
//- Extract a tensor field diagonal

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -249,7 +249,7 @@ template<class Cmpt>
void Foam::unzipRow
(
const UList<Tensor<Cmpt>>& input,
const vector::components cmpt,
const direction idx,
Field<Vector<Cmpt>>& result
)
{
@ -266,7 +266,7 @@ void Foam::unzipRow
}
#endif
switch (cmpt)
switch (idx)
{
case vector::components::X :
{
@ -302,7 +302,7 @@ template<class Cmpt>
void Foam::unzipCol
(
const UList<Tensor<Cmpt>>& input,
const vector::components cmpt,
const direction idx,
Field<Vector<Cmpt>>& result
)
{
@ -319,7 +319,7 @@ void Foam::unzipCol
}
#endif
switch (cmpt)
switch (idx)
{
case vector::components::X :
{
@ -383,12 +383,12 @@ Foam::tmp<Foam::Field<Foam::Vector<Cmpt>>>
Foam::unzipRow
(
const Field<Tensor<Cmpt>>& input,
const vector::components cmpt
const direction idx
)
{
auto tresult = tmp<Field<Vector<Cmpt>>>::New(input.size());
Foam::unzipRow(input, cmpt, tresult.ref());
Foam::unzipRow(input, idx, tresult.ref());
return tresult;
}
@ -399,12 +399,12 @@ Foam::tmp<Foam::Field<Foam::Vector<Cmpt>>>
Foam::unzipCol
(
const Field<Tensor<Cmpt>>& input,
const vector::components cmpt
const direction idx
)
{
auto tresult = tmp<Field<Vector<Cmpt>>>::New(input.size());
Foam::unzipCol(input, cmpt, tresult.ref());
Foam::unzipCol(input, idx, tresult.ref());
return tresult;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -94,6 +94,142 @@ void Foam::unzip
}
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void Foam::zipRows
(
GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& result,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& x,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& y,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
)
{
Foam::zipRows
(
result.primitiveFieldRef(),
x.primitiveField(),
y.primitiveField(),
z.primitiveField()
);
Foam::zipRows
(
result.boundaryFieldRef(),
x.boundaryField(),
y.boundaryField(),
z.boundaryField()
);
}
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void Foam::zipCols
(
GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& result,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& x,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& y,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
)
{
Foam::zipCols
(
result.primitiveFieldRef(),
x.primitiveField(),
y.primitiveField(),
z.primitiveField()
);
Foam::zipCols
(
result.boundaryFieldRef(),
x.boundaryField(),
y.boundaryField(),
z.boundaryField()
);
}
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void Foam::unzipRows
(
const GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& input,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& x,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& y,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
)
{
Foam::unzipRows
(
input.primitiveField(),
x.primitiveFieldRef(),
y.primitiveFieldRef(),
z.primitiveFieldRef()
);
Foam::unzipRows
(
input.boundaryField(),
x.boundaryFieldRef(),
y.boundaryFieldRef(),
z.boundaryFieldRef()
);
}
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void Foam::unzipCols
(
const GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& input,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& x,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& y,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
)
{
Foam::unzipCols
(
input.primitiveField(),
x.primitiveFieldRef(),
y.primitiveFieldRef(),
z.primitiveFieldRef()
);
Foam::unzipCols
(
input.boundaryField(),
x.boundaryFieldRef(),
y.boundaryFieldRef(),
z.boundaryFieldRef()
);
}
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void Foam::unzipRow
(
const GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& input,
const direction idx,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& result
)
{
Foam::unzipRow(input.primitiveField(), idx, result.primitiveFieldRef());
Foam::unzipRow(input.boundaryField(), idx, result.boundaryFieldRef());
}
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void Foam::unzipCol
(
const GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& input,
const direction idx,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& result
)
{
Foam::unzipCol(input.primitiveField(), idx, result.primitiveFieldRef());
Foam::unzipCol(input.boundaryField(), idx, result.boundaryFieldRef());
}
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void Foam::unzipDiag
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef GeometricSymmTensorField_H
#define GeometricSymmTensorField_H
#ifndef Foam_GeometricSymmTensorField_H
#define Foam_GeometricSymmTensorField_H
#include "GeometricField.H"
#include "DimensionedSymmTensorField.H"
@ -77,6 +77,67 @@ void unzip
GeometricField<Cmpt, PatchField, GeoMesh>& zz
);
//- Zip together symmTensor field from row components
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void zipRows
(
GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& result,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& x,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& y,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
);
//- Zip together symmTensor field from column components
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void zipCols
(
GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& result,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& x,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& y,
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
);
//- Extract symmTensor field rows
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void unzipRows
(
const GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& input,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& x,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& y,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
);
//- Extract symmTensor field columns
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void unzipCols
(
const GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& input,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& x,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& y,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
);
//- Extract a symmTensor field row (x,y,z) == (0,1,2)
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void unzipRow
(
const GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& input,
const direction idx, //!< vector::components
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& result
);
//- Extract a symmTensor field column (x,y,z) == (0,1,2)
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void unzipCol
(
const GeometricField<SymmTensor<Cmpt>, PatchField, GeoMesh>& input,
const direction idx, //!< vector::components
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& result
);
//- Extract a symmTensor field diagonal
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void unzipDiag

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -212,13 +212,13 @@ template<class Cmpt, template<class> class PatchField, class GeoMesh>
void Foam::unzipRow
(
const GeometricField<Tensor<Cmpt>, PatchField, GeoMesh>& input,
const vector::components cmpt,
const direction idx,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& result
)
{
Foam::unzipRow(input.primitiveField(), cmpt, result.primitiveFieldRef());
Foam::unzipRow(input.primitiveField(), idx, result.primitiveFieldRef());
Foam::unzipRow(input.boundaryField(), cmpt, result.boundaryFieldRef());
Foam::unzipRow(input.boundaryField(), idx, result.boundaryFieldRef());
}
@ -226,13 +226,13 @@ template<class Cmpt, template<class> class PatchField, class GeoMesh>
void Foam::unzipCol
(
const GeometricField<Tensor<Cmpt>, PatchField, GeoMesh>& input,
const vector::components cmpt,
const direction idx,
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& result
)
{
Foam::unzipCol(input.primitiveField(), cmpt, result.primitiveFieldRef());
Foam::unzipCol(input.primitiveField(), idx, result.primitiveFieldRef());
Foam::unzipCol(input.boundaryField(), cmpt, result.boundaryFieldRef());
Foam::unzipCol(input.boundaryField(), idx, result.boundaryFieldRef());
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef GeometricTensorField_H
#define GeometricTensorField_H
#ifndef Foam_GeometricTensorField_H
#define Foam_GeometricTensorField_H
#include "GeometricSphericalTensorField.H"
#include "GeometricSymmTensorField.H"
@ -85,8 +85,7 @@ void unzip
);
//- Zip together tensor field field from row components
//- Zip together tensor field from row components
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void zipRows
(
@ -106,7 +105,7 @@ void zipCols
const GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
);
//- Extract tensor field field rows
//- Extract tensor field rows
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void unzipRows
(
@ -116,7 +115,7 @@ void unzipRows
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& z
);
//- Extract tensor field field columns
//- Extract tensor field columns
template<class Cmpt, template<class> class PatchField, class GeoMesh>
void unzipCols
(
@ -132,7 +131,7 @@ template<class Cmpt, template<class> class PatchField, class GeoMesh>
void unzipRow
(
const GeometricField<Tensor<Cmpt>, PatchField, GeoMesh>& input,
const vector::components cmpt,
const direction idx, //!< vector::components
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& result
);
@ -141,7 +140,7 @@ template<class Cmpt, template<class> class PatchField, class GeoMesh>
void unzipCol
(
const GeometricField<Tensor<Cmpt>, PatchField, GeoMesh>& input,
const vector::components cmpt,
const direction idx, //!< vector::components
GeometricField<Vector<Cmpt>, PatchField, GeoMesh>& result
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,16 +31,13 @@ Description
A templated (3 x 3) symmetric tensor of objects of \<T\>, effectively
containing 6 elements, derived from VectorSpace.
See also
Test-SymmTensor.C
SourceFiles
SymmTensorI.H
\*---------------------------------------------------------------------------*/
#ifndef SymmTensor_H
#define SymmTensor_H
#ifndef Foam_SymmTensor_H
#define Foam_SymmTensor_H
#include "contiguous.H"
#include "Vector.H"
@ -107,6 +104,15 @@ public:
//- Construct given SphericalTensor
inline SymmTensor(const SphericalTensor<Cmpt>&);
//- Construct given the three row (or column) vectors
inline SymmTensor
(
const Vector<Cmpt>& x,
const Vector<Cmpt>& y,
const Vector<Cmpt>& z,
const bool transposed = false /* ignored */
);
//- Construct given the six components
inline SymmTensor
(
@ -121,36 +127,103 @@ public:
// Member Functions
// Component access
// Component Access
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& xz() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
inline const Cmpt& yz() const;
inline const Cmpt& zx() const;
inline const Cmpt& zy() const;
inline const Cmpt& zz() const;
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& xz() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
inline const Cmpt& yz() const;
inline const Cmpt& zx() const;
inline const Cmpt& zy() const;
inline const Cmpt& zz() const;
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& xz();
inline Cmpt& yx();
inline Cmpt& yy();
inline Cmpt& yz();
inline Cmpt& zx();
inline Cmpt& zy();
inline Cmpt& zz();
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& xz();
inline Cmpt& yx();
inline Cmpt& yy();
inline Cmpt& yz();
inline Cmpt& zx();
inline Cmpt& zy();
inline Cmpt& zz();
// Diagonal access and manipulation
// Column-vector access
//- Extract the diagonal as a vector
inline Vector<Cmpt> diag() const;
//- Extract vector for column 0
Vector<Cmpt> cx() const { return this->x(); }
//- Set values of the diagonal
inline void diag(const Vector<Cmpt>& v);
//- Extract vector for column 1
Vector<Cmpt> cy() const { return this->y(); }
//- Extract vector for column 2
Vector<Cmpt> cz() const { return this->z(); }
//- Extract vector for given column: compile-time check of index
template<direction Idx>
Vector<Cmpt> col() const { return this->row<Idx>(); }
//- Extract vector for given column (0,1,2): runtime check of index
Vector<Cmpt> col(const direction c) const { return this->row(c); }
//- Set values of given column (0,1,2): runtime check of index
void col(const direction c, const Vector<Cmpt>& v) { this->row(c, v); }
//- Set column values
void cols
(
const Vector<Cmpt>& x,
const Vector<Cmpt>& y,
const Vector<Cmpt>& z
)
{
this->rows(x, y, z);
}
// Row-vector access
//- Extract vector for row 0
inline Vector<Cmpt> x() const;
//- Extract vector for row 1
inline Vector<Cmpt> y() const;
//- Extract vector for row 2
inline Vector<Cmpt> z() const;
//- Extract vector for given row: compile-time check of index
template<direction Row>
inline Vector<Cmpt> row() const;
//- Extract vector for given row (0,1,2): runtime check of index
inline Vector<Cmpt> row(const direction r) const;
//- Set values of given row: compile-time check of index
template<direction Idx>
inline void row(const Vector<Cmpt>& v);
//- Set values of given row (0,1,2): runtime check of row
inline void row(const direction r, const Vector<Cmpt>& v);
//- Set row values
inline void rows
(
const Vector<Cmpt>& x,
const Vector<Cmpt>& y,
const Vector<Cmpt>& z
);
// Diagonal access and manipulation
//- Extract the diagonal as a vector
inline Vector<Cmpt> diag() const;
//- Set values of the diagonal
inline void diag(const Vector<Cmpt>& v);
// Tensor Operations

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,6 +57,19 @@ inline Foam::SymmTensor<Cmpt>::SymmTensor(const SphericalTensor<Cmpt>& st)
}
template<class Cmpt>
inline Foam::SymmTensor<Cmpt>::SymmTensor
(
const Vector<Cmpt>& x,
const Vector<Cmpt>& y,
const Vector<Cmpt>& z,
const bool transposed /* ignored */
)
{
this->rows(x, y, z);
}
template<class Cmpt>
inline Foam::SymmTensor<Cmpt>::SymmTensor
(
@ -190,6 +203,111 @@ inline Cmpt& Foam::SymmTensor<Cmpt>::zz()
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::x() const
{
return Vector<Cmpt>(this->v_[XX], this->v_[XY], this->v_[XZ]);
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::y() const
{
return Vector<Cmpt>(this->v_[XY], this->v_[YY], this->v_[YZ]);
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::z() const
{
return Vector<Cmpt>(this->v_[XZ], this->v_[YZ], this->v_[ZZ]);
}
template<class Cmpt>
template<Foam::direction Idx>
inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::row() const
{
if (Idx == 0) return x();
else if (Idx == 1) return y();
else if (Idx == 2) return z();
static_assert(Idx < 3, "Invalid row access");
return Zero;
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::row(const direction r) const
{
switch (r)
{
case 0: return x(); break;
case 1: return y(); break;
case 2: return z(); break;
default:
FatalErrorInFunction
<< "Invalid row access " << r << abort(FatalError);
}
return Zero;
}
template<class Cmpt>
template<Foam::direction Idx>
inline void Foam::SymmTensor<Cmpt>::row(const Vector<Cmpt>& v)
{
if (Idx == 0)
{
this->v_[XX] = v.x(); this->v_[XY] = v.y(); this->v_[XZ] = v.z();
}
else if (Idx == 1)
{
this->v_[XY] = v.x(); this->v_[YY] = v.y(); this->v_[YZ] = v.z();
}
else if (Idx == 2)
{
this->v_[XZ] = v.x(); this->v_[YZ] = v.y(); this->v_[ZZ] = v.z();
}
static_assert(Idx < 3, "Invalid row access");
}
template<class Cmpt>
inline void Foam::SymmTensor<Cmpt>::rows
(
const Vector<Cmpt>& x,
const Vector<Cmpt>& y,
const Vector<Cmpt>& z
)
{
this->v_[XX] = x.x(); this->v_[XY] = x.y(); this->v_[XZ] = x.z();
this->v_[YY] = y.y(); this->v_[YZ] = y.z();
this->v_[ZZ] = z.z();
}
template<class Cmpt>
inline void Foam::SymmTensor<Cmpt>::row
(
const direction r,
const Vector<Cmpt>& v
)
{
switch (r)
{
case 0: row<0>(v); break;
case 1: row<1>(v); break;
case 2: row<2>(v); break;
default:
FatalErrorInFunction
<< "Invalid row access " << r << abort(FatalError);
}
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::diag() const
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,9 +30,6 @@ Class
Description
A templated (3 x 3) tensor of objects of \<T\> derived from MatrixSpace.
See also
Test-Tensor.C
SourceFiles
TensorI.H
@ -42,8 +39,8 @@ See also
\*---------------------------------------------------------------------------*/
#ifndef Tensor_H
#define Tensor_H
#ifndef Foam_Tensor_H
#define Foam_Tensor_H
#include "MatrixSpace.H"
#include "Vector.H"
@ -57,7 +54,6 @@ namespace Foam
// Forward Declarations
template<class Cmpt> class SymmTensor;
/*---------------------------------------------------------------------------*\
Class Tensor Declaration
\*---------------------------------------------------------------------------*/
@ -165,112 +161,104 @@ public:
// Member Functions
// Component access
// Component access
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& xz() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
inline const Cmpt& yz() const;
inline const Cmpt& zx() const;
inline const Cmpt& zy() const;
inline const Cmpt& zz() const;
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& xz() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
inline const Cmpt& yz() const;
inline const Cmpt& zx() const;
inline const Cmpt& zy() const;
inline const Cmpt& zz() const;
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& xz();
inline Cmpt& yx();
inline Cmpt& yy();
inline Cmpt& yz();
inline Cmpt& zx();
inline Cmpt& zy();
inline Cmpt& zz();
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& xz();
inline Cmpt& yx();
inline Cmpt& yy();
inline Cmpt& yz();
inline Cmpt& zx();
inline Cmpt& zy();
inline Cmpt& zz();
// Column-vector access.
// Column-vector access
//- Extract vector for column 0
inline Vector<Cmpt> cx() const;
//- Extract vector for column 0
inline Vector<Cmpt> cx() const;
//- Extract vector for column 1
inline Vector<Cmpt> cy() const;
//- Extract vector for column 1
inline Vector<Cmpt> cy() const;
//- Extract vector for column 2
inline Vector<Cmpt> cz() const;
//- Extract vector for column 2
inline Vector<Cmpt> cz() const;
//- Extract vector for given column.
// Compile-time check of column index.
template<direction Col>
inline Vector<Cmpt> col() const;
//- Extract vector for given column: compile-time check of index
template<direction Idx>
inline Vector<Cmpt> col() const;
//- Extract vector for given column (0,1,2).
// Runtime check of column index.
inline Vector<Cmpt> col(const direction c) const;
//- Extract vector for given column (0,1,2): runtime check of index
inline Vector<Cmpt> col(const direction c) const;
//- Set values of given column
// Compile-time check of column index.
template<direction Col>
inline void col(const Vector<Cmpt>& v);
//- Set values of given column: compile-time check of index
template<direction Idx>
inline void col(const Vector<Cmpt>& v);
//- Set values of given column (0,1,2)
// Runtime check of column index.
inline void col(const direction c, const Vector<Cmpt>& v);
//- Set values of given column (0,1,2): runtime check of index
inline void col(const direction c, const Vector<Cmpt>& v);
//- Set column values
inline void cols
(
const Vector<Cmpt>& x,
const Vector<Cmpt>& y,
const Vector<Cmpt>& z
);
//- Set column values
inline void cols
(
const Vector<Cmpt>& x,
const Vector<Cmpt>& y,
const Vector<Cmpt>& z
);
// Row-vector access.
// Row-vector access
//- Extract vector for row 0
inline Vector<Cmpt> x() const;
//- Extract vector for row 0
inline Vector<Cmpt> x() const;
//- Extract vector for row 1
inline Vector<Cmpt> y() const;
//- Extract vector for row 1
inline Vector<Cmpt> y() const;
//- Extract vector for row 2
inline Vector<Cmpt> z() const;
//- Extract vector for row 2
inline Vector<Cmpt> z() const;
//- Extract vector for given row.
// Compile-time check of row index.
template<direction Row>
inline Vector<Cmpt> row() const;
//- Extract vector for given row: compile-time check of index
template<direction Idx>
inline Vector<Cmpt> row() const;
//- Extract vector for given row (0,1,2)
// Runtime check of row index.
inline Vector<Cmpt> row(const direction r) const;
//- Extract vector for given row (0,1,2): runtime check of index
inline Vector<Cmpt> row(const direction r) const;
//- Set values of given row
// Compile-time check of row index.
template<direction Row>
inline void row(const Vector<Cmpt>& v);
//- Set values of given row: compile-time check of index
template<direction Idx>
inline void row(const Vector<Cmpt>& v);
//- Set values of given row (0,1,2)
// Runtime check of row index.
inline void row(const direction r, const Vector<Cmpt>& v);
//- Set values of given row (0,1,2): runtime check of row
inline void row(const direction r, const Vector<Cmpt>& v);
//- Set row values
inline void rows
(
const Vector<Cmpt>& x,
const Vector<Cmpt>& y,
const Vector<Cmpt>& z
);
//- Set row values
inline void rows
(
const Vector<Cmpt>& x,
const Vector<Cmpt>& y,
const Vector<Cmpt>& z
);
// Diagonal access and manipulation
// Diagonal access and manipulation
//- Extract the diagonal as a vector
inline Vector<Cmpt> diag() const;
//- Extract the diagonal as a vector
inline Vector<Cmpt> diag() const;
//- Set values of the diagonal
inline void diag(const Vector<Cmpt>& v);
//- Set values of the diagonal
inline void diag(const Vector<Cmpt>& v);
// Tensor Operations

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -317,14 +317,14 @@ inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::cz() const
template<class Cmpt>
template<Foam::direction Col>
template<Foam::direction Idx>
inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::col() const
{
if (Col == 0) return cx();
else if (Col == 1) return cy();
else if (Col == 2) return cz();
if (Idx == 0) return cx();
else if (Idx == 1) return cy();
else if (Idx == 2) return cz();
static_assert(Col < 3, "Invalid column access");
static_assert(Idx < 3, "Invalid column access");
return Zero;
}
@ -337,24 +337,24 @@ inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::col(const direction c) const
case 0: return cx(); break;
case 1: return cy(); break;
case 2: return cz(); break;
default:
FatalErrorInFunction
<< "Invalid column access " << c << abort(FatalError);
}
FatalErrorInFunction
<< "Invalid column access " << c << abort(FatalError);
return Zero;
}
template<class Cmpt>
template<Foam::direction Row>
template<Foam::direction Idx>
inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::row() const
{
if (Row == 0) return x();
else if (Row == 1) return y();
else if (Row == 2) return z();
if (Idx == 0) return x();
else if (Idx == 1) return y();
else if (Idx == 2) return z();
static_assert(Row < 3, "Invalid row access");
static_assert(Idx < 3, "Invalid row access");
return Zero;
}
@ -367,60 +367,60 @@ inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::row(const direction r) const
case 0: return x(); break;
case 1: return y(); break;
case 2: return z(); break;
default:
FatalErrorInFunction
<< "Invalid row access " << r << abort(FatalError);
}
FatalErrorInFunction
<< "Invalid row access " << r << abort(FatalError);
return Zero;
}
template<class Cmpt>
template<Foam::direction Col>
template<Foam::direction Idx>
inline void Foam::Tensor<Cmpt>::col(const Vector<Cmpt>& v)
{
if (Col == 0)
if (Idx == 0)
{
this->v_[XX] = v.x();
this->v_[YX] = v.y();
this->v_[ZX] = v.z();
}
else if (Col == 1)
else if (Idx == 1)
{
this->v_[XY] = v.x();
this->v_[YY] = v.y();
this->v_[ZY] = v.z();
}
else if (Col == 2)
else if (Idx == 2)
{
this->v_[XZ] = v.x();
this->v_[YZ] = v.y();
this->v_[ZZ] = v.z();
}
static_assert(Col < 3, "Invalid column access");
static_assert(Idx < 3, "Invalid column access");
}
template<class Cmpt>
template<Foam::direction Row>
template<Foam::direction Idx>
inline void Foam::Tensor<Cmpt>::row(const Vector<Cmpt>& v)
{
if (Row == 0)
if (Idx == 0)
{
this->v_[XX] = v.x(); this->v_[XY] = v.y(); this->v_[XZ] = v.z();
}
else if (Row == 1)
else if (Idx == 1)
{
this->v_[YX] = v.x(); this->v_[YY] = v.y(); this->v_[YZ] = v.z();
}
else if (Row == 2)
else if (Idx == 2)
{
this->v_[ZX] = v.x(); this->v_[ZY] = v.y(); this->v_[ZZ] = v.z();
}
static_assert(Row < 3, "Invalid row access");
static_assert(Idx < 3, "Invalid row access");
}
@ -453,7 +453,11 @@ inline void Foam::Tensor<Cmpt>::rows
template<class Cmpt>
inline void Foam::Tensor<Cmpt>::col(const direction c, const Vector<Cmpt>& v)
inline void Foam::Tensor<Cmpt>::col
(
const direction c,
const Vector<Cmpt>& v
)
{
switch (c)
{
@ -463,13 +467,16 @@ inline void Foam::Tensor<Cmpt>::col(const direction c, const Vector<Cmpt>& v)
default:
FatalErrorInFunction
<< "Invalid column access " << c << abort(FatalError);
break;
}
}
template<class Cmpt>
inline void Foam::Tensor<Cmpt>::row(const direction r, const Vector<Cmpt>& v)
inline void Foam::Tensor<Cmpt>::row
(
const direction r,
const Vector<Cmpt>& v
)
{
switch (r)
{
@ -479,7 +486,6 @@ inline void Foam::Tensor<Cmpt>::row(const direction r, const Vector<Cmpt>& v)
default:
FatalErrorInFunction
<< "Invalid row access " << r << abort(FatalError);
break;
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,16 +30,13 @@ Class
Description
A templated (2 x 2) tensor of objects of \<T\> derived from VectorSpace.
See also
Test-Tensor2D.C
SourceFiles
Tensor2DI.H
\*---------------------------------------------------------------------------*/
#ifndef Tensor2D_H
#define Tensor2D_H
#ifndef Foam_Tensor2D_H
#define Foam_Tensor2D_H
#include "Vector2D.H"
#include "SphericalTensor2D.H"
@ -130,86 +127,78 @@ public:
// Member Functions
// Component access
// Component access
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& yx();
inline Cmpt& yy();
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& yx();
inline Cmpt& yy();
// Column-vector access.
// Column-vector access
//- Extract vector for column 0
inline Vector2D<Cmpt> cx() const;
//- Extract vector for column 0
inline Vector2D<Cmpt> cx() const;
//- Extract vector for column 1
inline Vector2D<Cmpt> cy() const;
//- Extract vector for column 1
inline Vector2D<Cmpt> cy() const;
//- Extract vector for given column.
// Compile-time check of column index.
template<direction Col>
inline Vector2D<Cmpt> col() const;
//- Extract vector for given column: compile-time check of index
template<direction Idx>
inline Vector2D<Cmpt> col() const;
//- Extract vector for given column (0,1).
// Runtime check of column index.
inline Vector2D<Cmpt> col(const direction c) const;
//- Extract vector for given column (0,1): runtime check of index
inline Vector2D<Cmpt> col(const direction c) const;
//- Set values of given column
// Compile-time check of column index.
template<direction Col>
inline void col(const Vector2D<Cmpt>& v);
//- Set values of given column: compile-time check of index
template<direction Idx>
inline void col(const Vector2D<Cmpt>& v);
//- Set values of given column (0,1)
// Runtime check of column index.
inline void col(const direction c, const Vector2D<Cmpt>& v);
//- Set values of given column (0,1): runtime check of index
inline void col(const direction c, const Vector2D<Cmpt>& v);
//- Set column values
inline void cols(const Vector2D<Cmpt>& x, const Vector2D<Cmpt>& y);
//- Set column values
inline void cols(const Vector2D<Cmpt>& x, const Vector2D<Cmpt>& y);
// Row-vector access.
// Row-vector access
//- Extract vector for row 0
inline Vector2D<Cmpt> x() const;
//- Extract vector for row 0
inline Vector2D<Cmpt> x() const;
//- Extract vector for row 1
inline Vector2D<Cmpt> y() const;
//- Extract vector for row 1
inline Vector2D<Cmpt> y() const;
//- Extract vector for given row.
// Compile-time check of row index.
template<direction Row>
inline Vector2D<Cmpt> row() const;
//- Extract vector for given row: compile-time check of index
template<direction Idx>
inline Vector2D<Cmpt> row() const;
//- Extract vector for given row (0,1)
// Runtime check of row index.
inline Vector2D<Cmpt> row(const direction r) const;
//- Extract vector for given row (0,1): runtime check of index
inline Vector2D<Cmpt> row(const direction r) const;
//- Set values of given row
// Compile-time check of row index.
template<direction Row>
inline void row(const Vector2D<Cmpt>& v);
//- Set values of given row: compile-time check of index
template<direction Idx>
inline void row(const Vector2D<Cmpt>& v);
//- Set values of given row (0,1)
// Runtime check of row index.
inline void row(const direction r, const Vector2D<Cmpt>& v);
//- Set values of given row (0,1): compile-time check of index
inline void row(const direction r, const Vector2D<Cmpt>& v);
//- Set row values
inline void rows(const Vector2D<Cmpt>& x, const Vector2D<Cmpt>& y);
//- Set row values
inline void rows(const Vector2D<Cmpt>& x, const Vector2D<Cmpt>& y);
// Diagonal access and manipulation
// Diagonal access and manipulation
//- Extract the diagonal as a vector
inline Vector2D<Cmpt> diag() const;
//- Extract the diagonal as a vector
inline Vector2D<Cmpt> diag() const;
//- Set values of the diagonal
inline void diag(const Vector2D<Cmpt>& v);
//- Set values of the diagonal
inline void diag(const Vector2D<Cmpt>& v);
// Tensor Operations

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -171,13 +171,13 @@ inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::cy() const
template<class Cmpt>
template<Foam::direction Col>
template<Foam::direction Idx>
inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::col() const
{
if (Col == 0) return cx();
else if (Col == 1) return cy();
if (Idx == 0) return cx();
else if (Idx == 1) return cy();
static_assert(Col < 2, "Invalid column access");
static_assert(Idx < 2, "Invalid column access");
return Zero;
}
@ -189,23 +189,23 @@ inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::col(const direction c) const
{
case 0: return cx(); break;
case 1: return cy(); break;
default:
FatalErrorInFunction
<< "Invalid column access " << c << abort(FatalError);
}
FatalErrorInFunction
<< "Invalid column access " << c << abort(FatalError);
return Zero;
}
template<class Cmpt>
template<Foam::direction Row>
template<Foam::direction Idx>
inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::row() const
{
if (Row == 0) return x();
else if (Row == 1) return y();
if (Idx == 0) return x();
else if (Idx == 1) return y();
static_assert(Row < 2, "Invalid row access");
static_assert(Idx < 2, "Invalid row access");
return Zero;
}
@ -217,48 +217,48 @@ inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::row(const direction r) const
{
case 0: return x(); break;
case 1: return y(); break;
default:
FatalErrorInFunction
<< "Invalid row access " << r << abort(FatalError);
}
FatalErrorInFunction
<< "Invalid row access " << r << abort(FatalError);
return Zero;
}
template<class Cmpt>
template<Foam::direction Col>
template<Foam::direction Idx>
inline void Foam::Tensor2D<Cmpt>::col(const Vector2D<Cmpt>& v)
{
if (Col == 0)
if (Idx == 0)
{
this->v_[XX] = v.x();
this->v_[YX] = v.y();
}
else if (Col == 1)
else if (Idx == 1)
{
this->v_[XY] = v.x();
this->v_[YY] = v.y();
}
static_assert(Col < 2, "Invalid column access");
static_assert(Idx < 2, "Invalid column access");
}
template<class Cmpt>
template<Foam::direction Row>
template<Foam::direction Idx>
inline void Foam::Tensor2D<Cmpt>::row(const Vector2D<Cmpt>& v)
{
if (Row == 0)
if (Idx == 0)
{
this->v_[XX] = v.x(); this->v_[XY] = v.y();
}
else if (Row == 1)
else if (Idx == 1)
{
this->v_[YX] = v.x(); this->v_[YY] = v.y();
}
static_assert(Row < 2, "Invalid row access");
static_assert(Idx < 2, "Invalid row access");
}
@ -300,7 +300,6 @@ inline void Foam::Tensor2D<Cmpt>::col
default:
FatalErrorInFunction
<< "Invalid column access " << c << abort(FatalError);
break;
}
}
@ -319,7 +318,6 @@ inline void Foam::Tensor2D<Cmpt>::row
default:
FatalErrorInFunction
<< "Invalid row access " << r << abort(FatalError);
break;
}
}

View File

@ -98,7 +98,7 @@ void Foam::functionObjects::volRegion::calculateCache()
if (regionIDs_.size() > 1)
{
cellIds_ =
volMesh_.cellZones().selected(regionIDs_).sortedToc();
volMesh_.cellZones().selection(regionIDs_).sortedToc();
}
break;
}
@ -114,7 +114,7 @@ void Foam::functionObjects::volRegion::calculateCache()
V_ += volMesh_.V()[celli];
}
nCells_ = returnReduce(selected.size(), sumOp<label>();
nCells_ = returnReduce(selected.size(), sumOp<label>());
reduce(V_, sumOp<scalar>());
if (!nCells_)
@ -167,7 +167,7 @@ Foam::functionObjects::volRegion::volRegion
regionTypes::vrtAll
)
),
regionName_(volMesh_.name());
regionName_(volMesh_.name())
{
read(dict);
}