|
[Sponsors] |
September 19, 2008, 12:08 |
Hi,
I need an operator that
|
#1 |
Senior Member
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17 |
Hi,
I need an operator that behaves like Matlab .* which is an element-wise multiplication of two vectors. I would like it to be able to handle volVectorField. For example (a,b,c) .* (A,B,C) = (aA,bB,cC) I have written this: volVectorField operator || (volVectorField a,volVectorField b) { volVectorField p; p.component(vector::x)=a.component(vector::x)+b.co mponent(vector::x); p.component(vector::y)=a.component(vector::y)+b.co mponent(vector::y); p.component(vector::z)=a.component(vector::z)+b.co mponent(vector::z); return p }; but I got this error message: SOURCE=myStatFoam.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/flurec/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -I/home/flurec/OpenFOAM/OpenFOAM-1.5/src/sampling/lnInclude -I/home/flurec/OpenFOAM/OpenFOAM-1.5/src/meshTools/lnInclude -IlnInclude -I. -I/home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/flurec/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGccDPOpt/myStatFoam.o In file included from myStatFoam.C:42: myOperator.H: In function 'Foam::volVectorField operator||(Foam::volVectorField, Foam::volVectorField)': myOperator.H:3: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField()' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:611: note: candidates are: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<type,>&, const Foam::wordList&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:576: note: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<type,>&, const Foam::word&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:545: note: Foam::GeometricField<type,>::GeometricField(const Foam::word&, const Foam::tmp<foam::geometricfield<type,> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:512: note: Foam::GeometricField<type,>::GeometricField(const Foam::word&, const Foam::GeometricField<type,>&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:480: note: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<type,>&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:448: note: Foam::GeometricField<type,>::GeometricField(const Foam::tmp<foam::geometricfield<type,> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:416: note: Foam::GeometricField<type,>::GeometricField(const Foam::GeometricField<type,>&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:378: note: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, Foam::Istream&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:337: note: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:313: note: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::Field<type>&, const Foam::PtrList<patchfield<type> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:283: note: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensioned<type>&, const Foam::wordList&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:254: note: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensioned<type>&, const Foam::word&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:227: note: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::wordList&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:197: note: Foam::GeometricField<type,>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::word&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:4: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::component(<unresolved>)' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:943: note: candidates are: Foam::tmp<foam::geometricfield<typename>::cmptType , PatchField, GeoMesh> > Foam::GeometricField<type,>::component(Foam::direc tion) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:4: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::component(<unresolved>)' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:943: note: candidates are: Foam::tmp<foam::geometricfield<typename>::cmptType , PatchField, GeoMesh> > Foam::GeometricField<type,>::component(Foam::direc tion) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:4: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::component(<unresolved>)' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:943: note: candidates are: Foam::tmp<foam::geometricfield<typename>::cmptType , PatchField, GeoMesh> > Foam::GeometricField<type,>::component(Foam::direc tion) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:5: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::component(<unresolved>)' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:943: note: candidates are: Foam::tmp<foam::geometricfield<typename>::cmptType , PatchField, GeoMesh> > Foam::GeometricField<type,>::component(Foam::direc tion) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:5: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::component(<unresolved>)' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:943: note: candidates are: Foam::tmp<foam::geometricfield<typename>::cmptType , PatchField, GeoMesh> > Foam::GeometricField<type,>::component(Foam::direc tion) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:5: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::component(<unresolved>)' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:943: note: candidates are: Foam::tmp<foam::geometricfield<typename>::cmptType , PatchField, GeoMesh> > Foam::GeometricField<type,>::component(Foam::direc tion) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:6: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::component(<unresolved>)' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:943: note: candidates are: Foam::tmp<foam::geometricfield<typename>::cmptType , PatchField, GeoMesh> > Foam::GeometricField<type,>::component(Foam::direc tion) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:6: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::component(<unresolved>)' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:943: note: candidates are: Foam::tmp<foam::geometricfield<typename>::cmptType , PatchField, GeoMesh> > Foam::GeometricField<type,>::component(Foam::direc tion) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:6: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::component(<unresolved>)' /home/flurec/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:943: note: candidates are: Foam::tmp<foam::geometricfield<typename>::cmptType , PatchField, GeoMesh> > Foam::GeometricField<type,>::component(Foam::direc tion) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] myOperator.H:8: error: expected ';' before '}' token createAverages.H: In function 'int main(int, char**)': createAverages.H:312: warning: unused variable 'Umean' createAverages.H:313: warning: unused variable 'R' make: *** [Make/linuxGccDPOpt/myStatFoam.o] Error 1 Could you help me, as I am going to need it extensively. JD |
|
September 19, 2008, 12:45 |
> myOperator.H:8: error: expec
|
#2 |
Senior Member
Gavin Tabor
Join Date: Mar 2009
Posts: 181
Rep Power: 17 |
> myOperator.H:8: error: expected ';' before '}' token
You missed a semicolon after "return p"! > myOperator.H:3: error: no matching function for call to 'Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField()' Also (and more significantly) volVectorField doesnt have a null constructor. I assume you wanted multiplications rather than additions on lines 4,5,6? There also seems to be something wrong with the way you are accessing the components, but I'm not quite sure what Gavin |
|
May 14, 2012, 10:45 |
|
#3 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34 |
Hi JD,
Were you successful in implementing a element-wise multiplication operator? I would like a tensor element-wise multiplication with another tensor. Actually one of the tensors is the identity - I essentially want to set the off-diagonals of a tensor to zero. I am open to any suggestions other people might have? At the moment I use a forAll loop through all the cells of the volTensorField. Best regards, Philip |
|
March 9, 2019, 14:03 |
|
#4 |
New Member
Luofeng
Join Date: May 2016
Posts: 5
Rep Power: 10 |
solution found?
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Ouput Variable Operator | selim | CFX | 1 | October 24, 2007 12:15 |
Operator Splitting. | Maria. | Main CFD Forum | 5 | September 17, 2005 23:10 |
Operator precedence | hemph | OpenFOAM | 1 | September 13, 2005 13:40 |
Vector multiplication and scaling in CFD-ACE/VIEW | MK | Main CFD Forum | 0 | August 29, 2005 19:11 |
a math operator in UDF | lichun Dong | FLUENT | 7 | June 18, 2005 23:04 |