|
[Sponsors] |
Wrong Overloaded operator for tensor2D in foam-extend-4.1 |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 16, 2019, 13:09 |
Wrong Overloaded operator for tensor2D in foam-extend-4.1
|
#1 |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 16 |
Hi Guys I wonder whether someone has stumbled upon the following 'hiccup'>> I am performing the following operation:
Code:
H += ( (1.0 + (dGrad & HdGrad) / dXdGrad) * (dx * dx) / dXdGrad - ((dx * HdGrad) + (HdGrad * dx)) / dXdGrad ); Code:
vector2D HdGrad, dx; tensor2D H; Once I go to compile the code, gcc complains: Code:
/home/lopezsa/foam/foam-extend-4.1.1/src/foam/lnInclude/VectorSpaceI.H:201:13: note: no known conversion for argument 1 from ‘Foam::Tensor<double>’ to ‘const Foam::VectorSpace<Foam::Tensor2D<double>, double, 4>&’ In file included from /home/lopezsa/foam/foam-extend-4.1.1/src/foam/lnInclude/Tensor2DTemplate.H:175:0, from /home/lopezsa/foam/foam-extend-4.1.1/src/foam/lnInclude/tensor2D.H:38, from MomentOfFluid.C:40: /home/lopezsa/foam/foam-extend-4.1.1/src/foam/lnInclude/Tensor2DTemplateI.H: In instantiation of ‘typename Foam::outerProduct<Foam::Vector2D<Cmpt>, Foam::Vector2D<Cmpt> >::type Foam::operator*(const Foam::Vector2D<Cmpt>&, const Foam::Vector2D<Cmpt>&) [with Cmpt = double; typename Foam::outerProduct<Foam::Vector2D<Cmpt>, Foam::Vector2D<Cmpt> >::type = Foam::Tensor<double>]’: Code:
//- Outer-product between two vectors template<class Cmpt> inline typename outerProduct<Vector2D<Cmpt>, Vector2D<Cmpt> >::type operator*(const Vector2D<Cmpt>& v1, const Vector2D<Cmpt>& v2) { return Tensor2D<Cmpt> ( v1.x()*v2.x(), v1.x()*v2.y(), v1.y()*v2.x(), v1.y()*v2.y() ); } Code:
inline tensor2D mult2DVects ( const vector2D& v1, const vector2D& v2) { return tensor2D ( v1.x()*v2.x(), v1.x()*v2.y(), v1.y()*v2.x(), v1.y()*v2.y() ); } Code:
H += ( (1.0 + (dGrad & HdGrad) / dXdGrad) * mult2DVects(dx, dx) / dXdGrad - (mult2DVects(dx, HdGrad) + mult2DVects(HdGrad, dx)) / dXdGrad ); |
|
December 16, 2019, 13:17 |
One more interesting detail....
|
#2 |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 16 |
If I change the inline function to
Code:
inline Tensor2D<double> mult2DVects ( const Vector2D<double>& v1, const Vector2D<double>& v2) { return Tensor2D<double> ( v1.x()*v2.x(), v1.x()*v2.y(), v1.y()*v2.x(), v1.y()*v2.y() ); } |
|
December 17, 2019, 07:05 |
A small test proves said error
|
#3 |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 16 |
If I go and compile the following simple code:
Code:
#include "argList.H" #include "vector2D.H" #include "tensor2D.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main(int argc, char *argv[]) { vector2D a(0.1,0.2); vector2D b(1,2); tensor2D c; c = a * b; Info << c; } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using createPatch and cyclicAMI in FOAM Extend to create periodicbox | manuc | OpenFOAM Running, Solving & CFD | 1 | April 12, 2022 12:36 |
[mesh manipulation] RefineMesh Error and Foam warning | jiahui_93 | OpenFOAM Meshing & Mesh Conversion | 4 | March 3, 2018 12:32 |
udf error | srihari | FLUENT | 1 | October 31, 2016 15:18 |
[blockMesh] Axisymmetrical mesh | Rasmus Gjesing (Gjesing) | OpenFOAM Meshing & Mesh Conversion | 10 | April 2, 2007 15:00 |
[Gmsh] Import gmsh msh to Foam | adorean | OpenFOAM Meshing & Mesh Conversion | 24 | April 27, 2005 09:19 |