CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   modified CrossPowerLaw wmake error (http://www.cfd-online.com/Forums/openfoam-programming-development/75324-modified-crosspowerlaw-wmake-error.html)

andboje April 22, 2010 04:04

modified CrossPowerLaw wmake error
 
Solution no longer needed.
Thread can be deleted.

Hi

I have modified the crossPowerLaw viscosity model to include temperature, but when I run wmake I get some errors referring to operator*. It might just be some syntax error with the exp() function, but I am not familiar enough with neither C++ or OpenFoam to see exactly what the problem might be.

Problem area
Code:

return (nu0_)/(scalar(1) + pow(m_*strainRate(), n_))*exp(C_*T);

Message from running wmake
Code:

anders@Anders-laptop:~/OpenFOAM/OpenFOAM-1.6/src/transportModels/incompressible$ wmake
Making dependency list for source file /home/anders/svn/Simulering/Viscosity/CrossPowerLawTemp.C
SOURCE=/home/anders/svn/Simulering/Viscosity/CrossPowerLawTemp.C ;  g++ -m32 -Dlinux -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-40 -I.. -I/home/anders/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/home/anders/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linuxGccDPOpt/CrossPowerLawTemp.o
/home/anders/svn/Simulering/Viscosity/CrossPowerLawTemp.C: In member function ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::viscosityModels::CrossPowerLawTemp::calcNu() const’:
/home/anders/svn/Simulering/Viscosity/CrossPowerLawTemp.C:53: error: no match for ‘operator*’ in ‘((const Foam::viscosityModels::CrossPowerLawTemp*)this)->Foam::viscosityModels::CrossPowerLawTemp::C_ * Foam::T’
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/dimensionSet.H:266: note: candidates are: Foam::dimensionSet Foam::operator*(const Foam::dimensionSet&, const Foam::dimensionSet&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/dimensionedScalar.H:56: note:                Foam::dimensionedScalar Foam::operator*(const Foam::dimensionedScalar&, Foam::scalar)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/dimensionedSymmTensor.H:69: note:                Foam::dimensionedVector Foam::operator*(const Foam::dimensionedSymmTensor&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/dimensionedTensor.H:75: note:                Foam::dimensionedVector Foam::operator*(const Foam::dimensionedTensor&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/dimensionedTensor.H:78: note:                Foam::dimensionedTensor Foam::operator*(const Foam::dimensionedVector&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/scalarField.H:81: note:                Foam::tmp<Foam::Field<double> > Foam::operator*(const Foam::UList<double>&, const Foam::UList<double>&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/scalarField.H:81: note:                Foam::tmp<Foam::Field<double> > Foam::operator*(const Foam::UList<double>&, const Foam::tmp<Foam::Field<double> >&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/scalarField.H:81: note:                Foam::tmp<Foam::Field<double> > Foam::operator*(const Foam::tmp<Foam::Field<double> >&, const Foam::UList<double>&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/scalarField.H:81: note:                Foam::tmp<Foam::Field<double> > Foam::operator*(const Foam::tmp<Foam::Field<double> >&, const Foam::tmp<Foam::Field<double> >&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/symmTensorField.H:71: note:                Foam::tmp<Foam::Field<Foam::Vector<double> > > Foam::operator*(const Foam::UList<Foam::SymmTensor<double> >&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/symmTensorField.H:71: note:                Foam::tmp<Foam::Field<Foam::Vector<double> > > Foam::operator*(const Foam::tmp<Foam::Field<Foam::SymmTensor<double> > >&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/tensorField.H:76: note:                Foam::tmp<Foam::Field<Foam::Vector<double> > > Foam::operator*(const Foam::UList<Foam::Tensor<double> >&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/tensorField.H:76: note:                Foam::tmp<Foam::Field<Foam::Vector<double> > > Foam::operator*(const Foam::tmp<Foam::Field<Foam::Tensor<double> > >&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/tensorField.H:77: note:                Foam::tmp<Foam::Field<Foam::Tensor<double> > > Foam::operator*(const Foam::UList<Foam::Vector<double> >&)
/home/anders/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/tensorField.H:77: note:                Foam::tmp<Foam::Field<Foam::Tensor<double> > > Foam::operator*(const Foam::tmp<Foam::Field<Foam::Vector<double> > >&)
make: *** [Make/linuxGccDPOpt/CrossPowerLawTemp.o] Error 1

Modified CrossPowerLaw:
CrossPowerLawTemp.C
Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    |
    \\  /    A nd          | Copyright (C) 1991-2009 OpenCFD Ltd.
    \\/    M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM; if not, write to the Free Software Foundation,
    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

\*---------------------------------------------------------------------------*/

#include "CrossPowerLawTemp.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFields.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
namespace viscosityModels
{
    defineTypeNameAndDebug(CrossPowerLawTemp, 0);

    addToRunTimeSelectionTable
    (
        viscosityModel,
        CrossPowerLawTemp,
        dictionary
    );
}
}

// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::CrossPowerLawTemp::calcNu() const
{
//    return (nu0_ - nuInf_)/(scalar(1) + pow(m_*strainRate(), n_)) + nuInf_; //Original Cross model
      return (nu0_)/(scalar(1) + pow(m_*strainRate(), n_))*exp(C_*T); //Modified Viscosity model with temperature
}


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::viscosityModels::CrossPowerLawTemp::CrossPowerLawTemp
(
    const word& name,
    const dictionary& viscosityProperties,
    const volVectorField& U,
    const surfaceScalarField& phi
)
:
    viscosityModel(name, viscosityProperties, U, phi),
    CrossPowerLawTempCoeffs_(viscosityProperties.subDict(typeName + "Coeffs")),
    nu0_(CrossPowerLawTempCoeffs_.lookup("nu0")),
    nuInf_(CrossPowerLawTempCoeffs_.lookup("nuInf")),
    m_(CrossPowerLawTempCoeffs_.lookup("m")),
    n_(CrossPowerLawTempCoeffs_.lookup("n")),
    C_(CrossPowerLawTempCoeffs_.lookup("C")),//Cross time constant
    nu_
    (
        IOobject
        (
            name,
            U_.time().timeName(),
            U_.db(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        calcNu()
    )
{}


// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //

bool Foam::viscosityModels::CrossPowerLawTemp::read
(
    const dictionary& viscosityProperties
)
{
    viscosityModel::read(viscosityProperties);

    CrossPowerLawTempCoeffs_ = viscosityProperties.subDict(typeName + "Coeffs");

    CrossPowerLawTempCoeffs_.lookup("nu0") >> nu0_;
    CrossPowerLawTempCoeffs_.lookup("nuInf") >> nuInf_;
    CrossPowerLawTempCoeffs_.lookup("m") >> m_;
    CrossPowerLawTempCoeffs_.lookup("n") >> n_;
    CrossPowerLawTempCoeffs_.lookup("C") >> C_;//Cross time constant

    return true;
}


// ************************************************************************* //

If anyone can help out it is much appreciated.

Anders

T.D. September 24, 2010 10:47

Hi
 
Hi
I think the problem is in pe defining T
i have the same problem,

so did you defined T in your CrossPowerLawTemp file?

andboje September 24, 2010 11:11

Hi
You are absolutely right, it needs to be declared.

This work was done as part of a 4 month group project on my University and I am no longer working on it. However, the problem in this thread did get resolved.

Here is a small section of our report, which describes the issue, I hope it helps a bit.

Quote:

Declaration of Variables
At this point, PowerLawTemp is a true copy of PowerLaw. Therefore, the next step is to read the temperature field, in order to use it for the viscosity equation. This requires, that the temperature variable T, is declared as a volScalarField as it was done in the solver. For this to be done successfully, it is important to understand the way classes work in C++. Simply declaring T in the PowerLawTemp files is not enough. T must also be declared in the constructors of the super classes located inside ../viscosityModels/ViscosityModel. Otherwise there will not be access to the temperature. However, this causes a new issue, since all the other viscosity classes inherits from the super class as well. Either T must also be declared inside them, or they can be removed from the make file to avoid any errors from occurring. Once the temperature is inserted, the temperature dependency constant,C, must also be declared so that it reads from transportProperties. However, it is fairly simple and obvious how this is done. Now the viscosity equation itself can be changed, according to Equation 10.4 on page 78. Once the incompressible library is compiled with the command wmake libso and the solver with wmake, a case can be simulated. Generally, whenever a new line of code has been added in OpenFOAM, it is prudent to often compile and test-run a case, in order to verify that it is working properly. Otherwise, debugging may become a very difficult and time consuming task.

T.D. September 24, 2010 11:42

Hi
 
Hi
ok so i need only to define T like a volScalarField but where? in the viscositymodel.C file before
multiplying by C_ ?? or in the viscositymodel.H file?

i have a problem in wmake?
i got these error:
error: no matching function for call to 'Foam::GeometricField<double, Foam::fvPatcheField, Foam::volMesh>::GeometricField()'

Can you tell me how exactly to do the wmake for a new viscosityLaw in the viscosityModels folder?
what about the option file and InInclude folder?
knowing i copied all to the $WM_USER_DIR/OpenFoam/...etc

Thanks a lot


T.D.

andboje September 24, 2010 12:14

2 Attachment(s)
I cannot remember the specifics about this, much of it I did not work on personally. However, I do remember how frustrating it was working with this.

I have attached a folder, maybe you can make some sense out of this. The files in question should be in there I think. I had to split it in two because of the size limit on this forum. The transportModels just goes inside interTempFoamv1.3.

T.D. September 24, 2010 12:50

Thanks
 
Thanks yes indeed i found it inside

thank you so much


I have a last question concerning boundary conditions

If i need to apply a bc to the Field T et a certain patch, but this bc is a function of another term used in calculation which is different from T

For example:

if i have a flux J=shearRate*Q+etc.....

and i need to apply at a certain BC on the patch of T field which is J=0;
knowing that i don't know anything about T BC at that patch.

i hope you understood me?
help pease?

thank you so much

andboje September 24, 2010 16:01

I am going to have to dissapoint you, but I really do not know about the boundary conditions.
Hopefully someone else can help you out with that.

But good luck with your work, trying to figure out the inner workings of OpenFOAM is a big task. ;)

T.D. September 28, 2010 09:58

Problem is still
 
Hi andboje, how are you?

I made the same as your files, but always i still have this error

even if i took for example your CrossPowerLawTemp and then i do the wmake
i get this error:

error: 'T_' was not declared in this scope


help please


thanks a lot

andboje September 28, 2010 10:13

Hi again

When do you get this error, when typing wmake or when running a case?

Try this:
In the terminal you navigate to the incompressible folder and type
Code:

wmake libso
then navigate to interTempFoamv1.3 and type
Code:

wmake
In that order, then I think it should be compiled properly.

T.D. September 28, 2010 10:17

Problem is still
 
Hi

but already indeed i am doing from /incompressible folder

wmake libso

and always the same error:

'T_' was not declared in this scope

help please

T.D.

andboje September 28, 2010 10:27

What version of OpenFOAM are you using, I can see there is a version 1.7 on their website. We were working with 1.6 and I remember code not being easily adopted from previous versions to that one.

I don't know if this is the issue, but it might be.

T.D. September 28, 2010 10:30

problem is still
 
Hi
i am using 1.7.1

help me please

i think the problem is in defining T_

however even in the code it does not give any error for other fields, just only for T_, that says, T_ was not declared in this scope !!! ?

and i don't think there might be a huge difference between versions 1.6 and 1.7, i don't know, i am confused what to do

help me please
thanks alot


T.D.

mohsenkh599 October 12, 2010 08:32

compiling error
 
Hi every body,
I have a problem when I want to compile a model.
the error is:

************************************************** *********************
************************************************** *********************

viscoelasticLaws/mohsen/mohsen.C:159: error: no match for ‘operator==’ in ‘Foam::operator+(const Foam::tmp<Foam::fvMatrix<Type> >&, const Foam::tmp<Foam::fvMatrix<Type> >&) [with Type = Foam::SymmTensor<double>](((const Foam::tmp<Foam::fvMatrix<Foam::SymmTensor<double> > >&)((const Foam::tmp<Foam::fvMatrix<Foam::SymmTensor<double> > >*)(& Foam::fvm::div(const Foam::surfaceScalarField&, Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = Foam::SymmTensor<double>](((Foam::GeometricField<Foam::SymmTensor<double>, Foam::fvPatchField, Foam::volMesh>&)(&((Foam::mohsen*)this)->Foam::mohsen::a_))))))) == Foam::operator+(const Foam::tmp<Foam::GeometricField<TypeR, PatchField, GeoMesh> >&, const Foam::tmp<Foam::GeometricField<Type1, PatchField, GeoMesh> >&) [with Type1 = Foam::Tensor<double>, Type2 = Foam::SymmTensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >*)(& Foam::operator*(const Foam::dimensioned<double>&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::SymmTensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >*)(& Foam::operator&(const Foam::tmp<Foam::GeometricField<TypeR, PatchField, GeoMesh> >&, const Foam::tmp<Foam::GeometricField<Type1, PatchField, GeoMesh> >&) [with Type1 = Foam::SymmTensor<double>, Type2 = Foam::SymmTensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >*)(& Foam::operator-(const Foam::dimensioned<Type>&, const Foam::tmp<Foam::GeometricField<Type1, PatchField, GeoMesh> >&) [with Form = Foam::SymmTensor<double>, Type = Foam::SymmTensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<Foam::SymmTensor<do uble>, Foam::fvPatchField, Foam::volMesh> >*)(& Foam::operator*(const Foam::scalar&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::SymmTensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::GeometricField<Foam::SymmTensor<double>, Foam::fvPatchField, Foam::volMesh>&)((const Foam::GeometricField<Foam::SymmTensor<double>, Foam::fvPatchField, Foam::volMesh>*)(&((Foam::mohsen*)this)->Foam::mohsen::a_))))))))))))))))))))’

************************************************** ************
************************************************** ************

and the model is :

// Velocity gradient tensor
volTensorField L = fvc::grad( U() );

// Convected derivate term
// volTensorField C = tau_ & L;

// vorticity term
volTensorField Vor = L - L.T();

// Twice the rate of deformation tensor
volSymmTensorField twoD = twoSymm( L );


// fc
scalar fc = 0.5; //1 - 27 * det( a_ );

//double dot term

// volSymmTensorField mk = -( (2 / 35) * ( 1 - fc ) * twoD - (2 / 7) * ( a_ & twoD + twoD & a_ + (1 / 2) * tr( twoD & a_ ) * I_ ) - fc * tr( twoD & a_ ) * a_ );

// Stress transport equation
tmp<fvSymmTensorMatrix> aEqn
(
fvm::ddt(a_)
+ fvm::div(phi(), a_)
==
( 1 / 2 ) * ( Vor & a_ - a_ & Vor ) + ( 1 / 2 ) * keisi_ * ( twoD & a_ + a_ & twoD + 2 * ( ( (2 / 35) * ( 1 - fc ) * twoD - (2 / 7) * ( 1 - fc ) * ( a_ & twoD + twoD & a_ + (1 / 2) * tr( twoD & a_ ) * I_ ) - fc * tr( twoD & a_ ) * a_ ) ) + 2 * ci_ * twoD & ( I_ - 3 * a_ )
//+ twoSymm( C )
//- zeta_ / 2 * ( (tau_ & twoD) + (twoD & tau_) )
//- fvm::Sp( epsilon_ / etaP_ * tr(tau_) + 1/lambda_, tau_ )
);

aEqn().relax();
solve(aEqn);
// Viscoelastic stress
tau_ = (etaP_ / keisi_) * (a_ - I_);
}

************************************************** ****************
************************************************** ****************

where "a" , "tau" and "I" are symmetric tensors and "Vor" is asymmetric tensor. and the others are constant parameters.

best

T.D. October 12, 2010 13:07

HI
 
Hi
How did you compiled your new Law in the viscosityModels ?


All times are GMT -4. The time now is 23:34.