- **OpenFOAM Bugs**
(*https://www.cfd-online.com/Forums/openfoam-bugs/*)

- - **bug in OpenFOAM!!!**
(*https://www.cfd-online.com/Forums/openfoam-bugs/108476-bug-openfoam.html*)

bug in OpenFOAM!!!Hi FOAMERS
I am trying to simulate flow in an-isotropic porous medium. As you might know, I have to define the permeability as a tensor with zero non diagonal elements. The Darcy source term in the momentum equation becomes + ((PermInvTen) & (fvc::Sp(Visc,U))) where PermInvTen is a tensor with diagonal elements of 1/kxx, 1/kyy and 1/ kzz. When I am using fvc (explicit) it compiles successfully. However, using fvm (implicit) gives the following error ------------------------------------------------------------------ BR1IM003.C:84:40: error: no match for ‘operator&’ in ‘PermTen & Foam::fvm::Sp(const Foam::dimensionedScalar&, Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = Foam::Vector<double>, Foam::dimensionedScalar = Foam::dimensioned<double>](((Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)(& U)))’ /opt/openfoam171/src/OpenFOAM/lnInclude/wordI.H:167:19: note: candidates are: Foam::word Foam::operator&(const Foam::word&, const Foam::word&) /opt/openfoam171/src/OpenFOAM/lnInclude/dimensionSet.H:273:29: note: Foam::dimensionSet Foam::operator&(const Foam::dimensionSet&, const Foam::dimensionSet&) /opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:8:10: warning: unused variable ‘momentumPredictor’ /opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:11:10: warning: unused variable ‘transonic’ /opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:14:9: warning: unused variable ‘nOuterCorr’ make: *** [Make/linux64GccDPOpt/BR1IM003.o] Error 1 ------------------------------------------------------------------------- Does any one know whether OF can handle the dot product of a tensor and implicitly treated vector or not? Is this a bug in foam? Regards |

Greetings Mahdi,
You're still using OpenFOAM 1.7.1... I don't know for certain, but is very likely/possible that said bug has already been fixed in the current version of OpenFOAM 2.1. We (any one in this forum) can test with OpenFOAM 2.1.1 or 2.1.x, if you can provide a small test case or test utility verifying the math operation you want to achieve! Best regards, Bruno |

1 Attachment(s)
Hello,
the "bug" (I don't know if it is one really or if there is a good reason why it is not coded this way) is still there in 2.1.1 and even 2.2.1. For anyone who would like to contribute / try. As a very basic example without real physical meaning, I took icoFoam, named it to icoTensorFoam, added a volTensorField and an expression to the velocity equation as proposed in at least 2 posts in the forum for anisotropic permeability. Add to createFields.H: Code:
` // Permeability volTensorField` Code:
` PermInv=10.0*tensor(1,0,0,0,0,0,0,0,0)+5.0*tensor(0,0,0,1,0,0,1,0,0);` I added a tar.gz with the code as well. Every hint is appreciated, thanks in advance |

Greetings Anja,
The issue here is that the desired method "Sp()" is not implemented in the name space fvm. For more information about what fvm and fvc are exactly: http://openfoamwiki.net/index.php/Op...%28OpenFOAM%29As for existing "Sp()" methods for each one, we can look into the Doxygen generated code documentation: - Namespaces: http://foam.sourceforge.net/docs/cpp/namespaces.html
- "Foam::fvm": http://foam.sourceforge.net/docs/cpp/a09414.html
- "Foam::fvc":http://foam.sourceforge.net/docs/cpp/a09413.html
fvm:Code:
`template<class Type > tmp< fvMatrix< Type > > Sp (const DimensionedField< scalar, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &)` fvc:Code:
`template<class Type > tmp< GeometricField< Type, fvPatchField, volMesh > > Sp (const volScalarField &sp, const GeometricField< Type, fvPatchField, volMesh > &vf)` - "nu" is a dimensioned scalar.
- "U" is a volume field.
fvc and the 4th one on fvm. So, on the arguments side, the desired method exists.Now let's look at the returning value. fvc only returns geometric patch fields and fvm only returns matrices. Therefore, this should be the origin of the compiling problem.So, let's look at the evidences: - This compiles:
Code:`fvVectorMatrix UEqn` ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) + (PermInv & fvc::Sp(nu, U)) );
- This does not compile:
Code:`fvVectorMatrix UEqn` ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) + (PermInv & fvm::Sp(nu, U)) );
- So, this clearly indicates that the operator "&" is the one
*breaking things*. And the compiler does tell us this, in the middle of the confusing output, that "Foam:: operator&" has several overloads, but not the one we're looking for. - Therefore, looking for the "operator&" in the documentation... :eek: there are
*sooooo*many operators &... :confused:... good luck finding the one being used with**fvc**and the one missing for**fvm**:( - The idea is that you have to look for the following
*triplet*:- The "operator&" operates with
**fvc**as: Code:`fv matrix = operator&( volume tensor field, geometric patch field )`
- The "operator&" operates with
**fvm**should do: Code:`fv matrix = operator&( volume tensor field, fv matrix )`
- The "operator&" operates with
- If the desired method is missing, have a look at the other methods to see if there is one similar enough on
**fvm**that can be used as basis for implementing an "operator&" for it.
Bruno |

Hello Bruno,
thank you very much for your detailed explanation. Unfortunately, my coding skills are not of a level that I could take something "similar as a basis for implementation" here. Code:
`& fvm::Sp()` Code:
`& fvc::Sp()` Thanks again, Best regards, Anja |

Good day,
As a follow up, considering the resulting matrix under the assumption that fvm::Sp(something,U) would actually work and that the operation Code:
`tensor & fvm::Sp()` This would create implicit terms for all velocity components in e.g. the momentum equation for the first velocity component. This does not make sense in the context of a segregated approach on the solution of the pressure-velocity coupling, where all other velocity components than the i'th are considered know from the previous time step in the i'th momentum equation. Kind regards Niels |

All times are GMT -4. The time now is 05:37. |