View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000348 | OpenFOAM | Bug | public | 2011-11-30 10:40 | 2013-07-02 19:00 |
Reporter | Assigned To | henry | |||
Priority | high | Severity | major | Reproducibility | N/A |
Status | resolved | Resolution | fixed | ||
Summary | 0000348: The dot-product operator for two SymmTensor's returns a SymmTensor instead of a Tensor | ||||
Description | The author assumed that the dot product of two symmetric tensors is again symmetric, which in general is not the case. | ||||
Tags | No tags attached. | ||||
2011-11-30 10:41
|
0001-FIX-Dot-product-of-SymmTensor-s-is-not-symmetric.patch (4,121 bytes)
From 458d07a1469dc50f9fb157f695711873d1b00885 Mon Sep 17 00:00:00 2001 From: Michael Wild <themiwi@users.sourceforge.net> Date: Tue, 29 Nov 2011 21:55:57 +0100 Subject: [PATCH] FIX: Dot product of SymmTensor's is not symmetric The result of the dot product of two symmetric tensors is not symmetric in general, as the original author assumed. This patch also adds two lines to applications/test/tensor/Test-tensor.C to verify the fixed implementation. Fixes http://www.openfoam.com/mantisbt/view.php?id=348. Signed-off-by: Michael Wild <themiwi@users.sourceforge.net> --- applications/test/tensor/Test-tensor.C | 4 ++++ src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H | 8 ++++++-- src/OpenFOAM/primitives/Tensor/Tensor.H | 4 +++- src/OpenFOAM/primitives/Tensor/TensorI.H | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/applications/test/tensor/Test-tensor.C b/applications/test/tensor/Test-tensor.C index efc7824..6da37d3 100644 --- a/applications/test/tensor/Test-tensor.C +++ b/applications/test/tensor/Test-tensor.C @@ -50,10 +50,14 @@ int main() << (t1 & t7 & t1.T()) << " " << transform(t1, t7) << endl; symmTensor st1(1, 2, 3, 4, 5, 6); + symmTensor st2(7, 8, 9, 10, 11, 12); Info<< "Check symmetric transformation " << transform(t1, st1) << endl; + Info<< "Check for dot product of symmetric tensors " + << (st1 & st2) << endl; + vector v1(1, 2, 3); Info<< sqr(v1) << endl; diff --git a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H index 5f9fbe9..4566cc7 100644 --- a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H +++ b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Vector.H" +#include "Tensor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -184,18 +185,21 @@ inline Vector<Cmpt> operator*(const SymmTensor<Cmpt>& st) //- Inner-product between two symmetric tensors template <class Cmpt> -inline SymmTensor<Cmpt> +inline Tensor<Cmpt> operator&(const SymmTensor<Cmpt>& st1, const SymmTensor<Cmpt>& st2) { - return SymmTensor<Cmpt> + return Tensor<Cmpt> ( st1.xx()*st2.xx() + st1.xy()*st2.xy() + st1.xz()*st2.xz(), st1.xx()*st2.xy() + st1.xy()*st2.yy() + st1.xz()*st2.yz(), st1.xx()*st2.xz() + st1.xy()*st2.yz() + st1.xz()*st2.zz(), + st1.xy()*st2.xx() + st1.yy()*st2.xy() + st1.yz()*st2.xz(), st1.xy()*st2.xy() + st1.yy()*st2.yy() + st1.yz()*st2.yz(), st1.xy()*st2.xz() + st1.yy()*st2.yz() + st1.yz()*st2.zz(), + st1.xz()*st2.xx() + st1.yz()*st2.xy() + st1.zz()*st2.xz(), + st1.xz()*st2.xy() + st1.yz()*st2.yy() + st1.zz()*st2.yz(), st1.xz()*st2.xz() + st1.yz()*st2.yz() + st1.zz()*st2.zz() ); } diff --git a/src/OpenFOAM/primitives/Tensor/Tensor.H b/src/OpenFOAM/primitives/Tensor/Tensor.H index c3dd522..a1554dc 100644 --- a/src/OpenFOAM/primitives/Tensor/Tensor.H +++ b/src/OpenFOAM/primitives/Tensor/Tensor.H @@ -40,13 +40,15 @@ SourceFiles #include "Vector.H" #include "SphericalTensor.H" -#include "SymmTensor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +template<class Cmpt> +class SymmTensor; + /*---------------------------------------------------------------------------*\ Class Tensor Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/primitives/Tensor/TensorI.H b/src/OpenFOAM/primitives/Tensor/TensorI.H index cbfe677..237bb6c 100644 --- a/src/OpenFOAM/primitives/Tensor/TensorI.H +++ b/src/OpenFOAM/primitives/Tensor/TensorI.H @@ -23,6 +23,8 @@ License \*---------------------------------------------------------------------------*/ +#include "SymmTensor.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam -- 1.7.5.4 |
|
Just wanted to ask whether this will be fixed now hat 2.1.0 is released? |
|
Yes we will fix this along with other pending issues. |
|
What strikes me as really odd, is that nobody stumbled across this gross bug before. One would assume that the dot product of two symmetric tensors isn't such a rarely used functionality... |
|
Thanks for your bug-report and the carefully crafted patch. I have applied the patch and propagated the changes through the field algebra layers and run the test loop on the resulting code. Resolved by commit 913f0ed8b63b2a46cad4bf3979bca7a92fa65f5b |
|
This bug is still not fully resolved (sorry, I just stumbled across it now). The partial specialization of the innerProduct meta-function for two SymmTensor arguments is still returning SymmTensor instead of Tensor. This bug is then e.g. exposed in Foam::dot(SymmTensor<Cmpt> const&, SymmTensor<Cmpt> const&). Attached patch 0001-FIX-innerProduct-type-of-SymmTensor-s-should-be-Tens.patch fixes this and adds a regression test. |
2013-07-02 16:36
|
0001-FIX-innerProduct-type-of-SymmTensor-s-should-be-Tens.patch (1,687 bytes)
From 9a0c4190e44788944f6af6d68fd76096337561ef Mon Sep 17 00:00:00 2001 From: Michael Wild <themiwi@users.sourceforge.net> Date: Tue, 2 Jul 2013 17:31:52 +0200 Subject: [PATCH] FIX: innerProduct::type of SymmTensor's should be Tensor, not SymmTensor As already partially fixed in issue #348, the dot (inner) product of two symmetric tensors is not symmetric in general. Here, the partial specialization of the innerProduct meta-function for two SymmTensor arguments was still returning a SymmTensor, which resulted in Foam::dot() failing to compile. Fixes http://www.openfoam.com/mantisbt/view.php?id=348. Signed-off-by: Michael Wild <themiwi@users.sourceforge.net> --- applications/test/tensor/Test-tensor.C | 1 + src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/test/tensor/Test-tensor.C b/applications/test/tensor/Test-tensor.C index 6da37d3..b0c1b65 100644 --- a/applications/test/tensor/Test-tensor.C +++ b/applications/test/tensor/Test-tensor.C @@ -57,6 +57,7 @@ int main() Info<< "Check for dot product of symmetric tensors " << (st1 & st2) << endl; + Info<< dot(st1, st2) << endl; vector v1(1, 2, 3); diff --git a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H index dce7984..19bcfb3 100644 --- a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H +++ b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H @@ -529,7 +529,7 @@ class innerProduct<SymmTensor<Cmpt>, SymmTensor<Cmpt> > { public: - typedef SymmTensor<Cmpt> type; + typedef Tensor<Cmpt> type; }; template<class Cmpt> -- 1.8.1.2 |
|
Resolved by commit c4a742b4ea323e5001fb1ed7f64203d237bb4e92 |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-11-30 10:40 |
|
New Issue | |
2011-11-30 10:41 |
|
File Added: 0001-FIX-Dot-product-of-SymmTensor-s-is-not-symmetric.patch | |
2011-12-21 05:41 |
|
Note Added: 0000855 | |
2011-12-21 07:56 | henry | Note Added: 0000857 | |
2011-12-21 08:17 |
|
Note Added: 0000858 | |
2011-12-28 15:54 | henry | Note Added: 0000873 | |
2011-12-28 15:54 | henry | Status | new => resolved |
2011-12-28 15:54 | henry | Resolution | open => fixed |
2011-12-28 15:54 | henry | Assigned To | => henry |
2013-07-02 16:35 |
|
Note Added: 0002298 | |
2013-07-02 16:35 |
|
Status | resolved => feedback |
2013-07-02 16:35 |
|
Resolution | fixed => reopened |
2013-07-02 16:36 |
|
File Added: 0001-FIX-innerProduct-type-of-SymmTensor-s-should-be-Tens.patch | |
2013-07-02 19:00 | henry | Note Added: 0002299 | |
2013-07-02 19:00 | henry | Status | feedback => resolved |
2013-07-02 19:00 | henry | Resolution | reopened => fixed |