CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Bugs

bug in OpenFOAM!!!

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By wyldckat
  • 1 Post By ngj

Reply
 
LinkBack Thread Tools Display Modes
Old   October 24, 2012, 12:41
Default bug in OpenFOAM!!!
  #1
Member
 
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 5
hawkeye321 is an unknown quantity at this point
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:perator&(const Foam::word&, const Foam::word&)
/opt/openfoam171/src/OpenFOAM/lnInclude/dimensionSet.H:273:29: note: Foam::dimensionSet Foam:perator&(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
hawkeye321 is offline   Reply With Quote

Old   October 24, 2012, 14:42
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,488
Blog Entries: 34
Rep Power: 86
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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
wyldckat is offline   Reply With Quote

Old   September 17, 2013, 07:49
Default
  #3
Member
 
Anja Miehe
Join Date: Dec 2009
Location: Freiberg / Germany
Posts: 48
Rep Power: 7
AnjaMiehe is on a distinguished road
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
   volTensorField PermInv
   (
     IOobject
     (
       "PermInv",
       runTime.timeName(),
       mesh,
       IOobject::NO_READ,
       IOobject::AUTO_WRITE
     ),
     mesh,
     dimensionedTensor("PermInv",dimless/sqr(dimLength), tensor::zero)
   );
For the icoTensorFoam.C add / modify:
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);
        
        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
        //  + (PermInv & fvm::Sp(nu, U))
          + (PermInv & fvc::Sp(nu, U))
        );

        solve(UEqn == -fvc::grad(p));
PermInv is a tensor with 10 at XX, 5 at YY and ZZ position and 0 off-diagonal. The non-commented line compiles, the commented one does not.

I added a tar.gz with the code as well.
Every hint is appreciated, thanks in advance
Attached Files
File Type: gz icoTensorFoam.tar.gz (2.0 KB, 3 views)
AnjaMiehe is offline   Reply With Quote

Old   September 28, 2013, 09:14
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,488
Blog Entries: 34
Rep Power: 86
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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%29

As for existing "Sp()" methods for each one, we can look into the Doxygen generated code documentation:
On fvm:
Code:
template<class Type > tmp< fvMatrix< Type > >     Sp (const DimensionedField< scalar, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &)

template<class Type > tmp< fvMatrix< Type > >     Sp (const tmp< DimensionedField< scalar, volMesh > > &, const GeometricField< Type, fvPatchField, volMesh > &)

template<class Type > tmp< fvMatrix< Type > >     Sp (const tmp< volScalarField > &, const GeometricField< Type, fvPatchField, volMesh > &)

template<class Type > tmp< fvMatrix< Type > >     Sp (const dimensionedScalar &, const GeometricField< Type, fvPatchField, volMesh > &)

template<class Type > zeroField     Sp (const zero &, const GeometricField< Type, fvPatchField, volMesh > &)
On fvc:
Code:
template<class Type > tmp< GeometricField< Type, fvPatchField, volMesh > >     Sp (const volScalarField &sp, const GeometricField< Type, fvPatchField, volMesh > &vf)

template<class Type > tmp< GeometricField< Type, fvPatchField, volMesh > >     Sp (const tmp< volScalarField > &tsp, const GeometricField< Type, fvPatchField, volMesh > &vf)

template<class Type > tmp< GeometricField< Type, fvPatchField, volMesh > >     Sp (const dimensionedScalar &sp, const GeometricField< Type, fvPatchField, volMesh > &vf)
Now, on your source code, you are using "Sp(nu, U)", where:
  • "nu" is a dimensioned scalar.
  • "U" is a volume field.
If we look at the possibilities above... it's the 3rd method on 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:
  1. This compiles:
    Code:
            fvVectorMatrix UEqn
            (
                fvm::ddt(U)
              + fvm::div(phi, U)
              - fvm::laplacian(nu, U)
              + (PermInv & fvc::Sp(nu, U))
            );
  2. This does not compile:
    Code:
            fvVectorMatrix UEqn
            (
                fvm::ddt(U)
              + fvm::div(phi, U)
              - fvm::laplacian(nu, U)
              + (PermInv & fvm::Sp(nu, U))
            );
  3. 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.
  4. Therefore, looking for the "operator&" in the documentation... there are sooooo many operators &... ... good luck finding the one being used with fvc and the one missing for fvm
  5. 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 )
  6. 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.
Best regards,
Bruno
snak likes this.
wyldckat is offline   Reply With Quote

Old   September 30, 2013, 02:27
Default
  #5
Member
 
Anja Miehe
Join Date: Dec 2009
Location: Freiberg / Germany
Posts: 48
Rep Power: 7
AnjaMiehe is on a distinguished road
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()
would be nice to have, but luckily
Code:
& fvc::Sp()
works for me although it is but the explicit implementation. So I will stick with it for the moment.

Thanks again,
Best regards,
Anja
AnjaMiehe is offline   Reply With Quote

Old   October 5, 2013, 07:51
Default
  #6
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,619
Rep Power: 25
ngj will become famous soon enoughngj will become famous soon enough
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()
would create an implicit contribution to the left hand side of the matrix system, as is what is wanted.

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
wyldckat likes this.
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
bug in "average" function of OpenFOAM jms OpenFOAM 0 March 22, 2011 05:04
Cross-compiling OpenFOAM 1.6 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 7 January 19, 2010 16:39
Adventure of fisrst openfoam installation on Ubuntu 710 jussi OpenFOAM Installation 0 April 24, 2008 14:25
Cumulative patch for OpenFOAM 141 January 3rd 2007 msrinath80 OpenFOAM Bugs 6 January 4, 2008 11:12


All times are GMT -4. The time now is 04:32.