CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   [Thank you for help] How comes this modified lapalacianFoam can not be 'wmake'? (https://www.cfd-online.com/Forums/openfoam/85734-thank-you-help-how-comes-modified-lapalacianfoam-can-not-wmake.html)

merlyn March 5, 2011 11:58

[Thank you for help] How comes this modified lapalacianFoam can not be 'wmake'?
 
Hi, guys
There is a case that I am trying to add a time dependent term in laplacianFoam solver, which is theoretically easy, but when I typed in "wmake" after modified create.H, write.H, and cureLaplacianFoam.C, error occurred w/o detail.

my code in cureLaplacianFoam.C, changing from the original laplacianFoam.C:

//add line here//
fvScalarMatrix alphadot
(
fvm::(a1*exp(-d1/R/T)+a2*exp(-d2/R/T)*alpha^m)*(1-alpha)^n
);
alphadot.solve();
//addition end//
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
solve
(
fvm::ddt(T) - fvm::laplacian(KRhoC, T)- HC*alphadot
);
//add line here//
solve
(
fvm::ddt(alpha) - alphadot
);
//addition end//
}


"alpha" is an added field, to be calculated by linear integration from "alphadot", which is a function of temperature and the last values of "alpha" as you see it.

and when I compiled it with wmake, error occurred as (you can just see the highlight sentence in the end of this bunch):

Making dependency list for source file cureLaplacianFoam.C
SOURCE=cureLaplacianFoam.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/opt/openfoam171/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/cureLaplacianFoam.o
cureLaplacianFoam.C: In function ‘int main(int, char**)’:
cureLaplacianFoam.C:58: error: expected unqualified-id before ‘(’ token
In file included from /opt/openfoam171/src/OpenFOAM/lnInclude/doubleFloat.H:30,
from /opt/openfoam171/src/OpenFOAM/lnInclude/floatScalar.H:38,
from /opt/openfoam171/src/OpenFOAM/lnInclude/scalar.H:39,
from /opt/openfoam171/src/OpenFOAM/lnInclude/IOstream.H:49,
from /opt/openfoam171/src/OpenFOAM/lnInclude/Ostream.H:39,
from /opt/openfoam171/src/OpenFOAM/lnInclude/OSstream.H:40,
from /opt/openfoam171/src/OpenFOAM/lnInclude/messageStream.H:219,
from /opt/openfoam171/src/OpenFOAM/lnInclude/error.H:51,
from /opt/openfoam171/src/OpenFOAM/lnInclude/UListI.H:26,
from /opt/openfoam171/src/OpenFOAM/lnInclude/UList.H:349,
from /opt/openfoam171/src/OpenFOAM/lnInclude/List.H:43,
from /opt/openfoam171/src/OpenFOAM/lnInclude/labelList.H:36,
from /opt/openfoam171/src/OpenFOAM/lnInclude/Pstream.H:43,
from /opt/openfoam171/src/OpenFOAM/lnInclude/OPstream.H:35,
from /opt/openfoam171/src/OpenFOAM/lnInclude/parRun.H:35,
from /opt/openfoam171/src/finiteVolume/lnInclude/fvCFD.H:4,
from cureLaplacianFoam.C:32:
/opt/openfoam171/src/OpenFOAM/lnInclude/products.H: At global scope:
/opt/openfoam171/src/OpenFOAM/lnInclude/products.H: In instantiation of ‘Foam::crossProduct<double, double>’:
cureLaplacianFoam.C:58: instantiated from here
/opt/openfoam171/src/OpenFOAM/lnInclude/products.H:85: error: no type named ‘type’ in ‘class Foam::typeOfRank<double, -0x00000000000000001>’
cureLaplacianFoam.C: In function ‘int main(int, char**)’:
cureLaplacianFoam.C:58: error: no match for ‘operator^’ in ‘Foam::operator+(const Foam::tmp<Foam::GeometricField<TypeR, PatchField, GeoMesh> >&, const Foam::tmp<Foam::GeometricField<Type1, PatchField, GeoMesh> >&) [with Type1 = double, Type2 = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >*)(& Foam::operator*(const Foam::tmp<Foam::GeometricField<double, PatchField, GeoMesh> >&, const Foam::GeometricField<double, PatchField, GeoMesh>&) [with PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&)((const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>*)(& alpha)))))))) ^ m’
/opt/openfoam171/src/OpenFOAM/lnInclude/dimensionSet.H:279: note: candidates are: Foam::dimensionSet Foam::operator^(const Foam::dimensionSet&, const Foam::dimensionSet&)
/usr/include/c++/4.4/bits/ios_base.h:170: note: std::_Ios_Iostate std::operator^(std::_Ios_Iostate, std::_Ios_Iostate)
/usr/include/c++/4.4/bits/ios_base.h:132: note: std::_Ios_Openmode std::operator^(std::_Ios_Openmode, std::_Ios_Openmode)
/usr/include/c++/4.4/bits/ios_base.h:92: note: std::_Ios_Fmtflags std::operator^(std::_Ios_Fmtflags, std::_Ios_Fmtflags)
cureLaplacianFoam.C:58: warning: suggest parentheses around arithmetic in operand of ‘^’
/opt/openfoam171/src/finiteVolume/lnInclude/readSIMPLEControls.H:6: warning: unused variable ‘momentumPredictor’
/opt/openfoam171/src/finiteVolume/lnInclude/readSIMPLEControls.H:9: warning: unused variable ‘transonic’
make: *** [Make/linuxGccDPOpt/cureLaplacianFoam.o] Error 1


I dont know what happened to .o file, wondering if there is any problem in the solver, cureLaplacianFoam.C .

Thank you for help, I really appreciate your time!

-Merlin-

Cyp March 5, 2011 14:17

Hi Merlin!

Your code can't compile. Indeed, your first declaration is a non-sense: alphadot is not a matrix. In fact it is just a field that depends on the other variables.

Code:

volScalarField alphadot = (a1*exp(-d1/R/T)+a2*exp(-d2/R/T)*alpha^m)*(1-alpha)^n;

        for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
        {
            solve
            (
                fvm::ddt(T) - fvm::laplacian(KRhoC, T)- HC*alphadot
            );

//add line here//           
            solve
            (
                fvm::ddt(alpha) - alphadot
            );
//addition end//
        }

This snippet should work..

You can even optimise the resolution using fvm::Sp() to deal with the source term of your last equation...

@++
Cyp

merlyn March 6, 2011 13:45

Quote:

Originally Posted by Cyp (Post 298055)
Hi Merlin!

Your code can't compile. Indeed, your first declaration is a non-sense: alphadot is not a matrix. In fact it is just a field that depends on the other variables.

Code:

volScalarField alphadot = (a1*exp(-d1/R/T)+a2*exp(-d2/R/T)*alpha^m)*(1-alpha)^n;

        for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
        {
            solve
            (
                fvm::ddt(T) - fvm::laplacian(KRhoC, T)- HC*alphadot
            );

//add line here//           
            solve
            (
                fvm::ddt(alpha) - alphadot
            );
//addition end//
        }

This snippet should work..

You can even optimise the resolution using fvm::Sp() to deal with the source term of your last equation...

@++
Cyp

Hi Cyp,
Appreciate your help pretty much. I think it makes a lot of sense to me.
But...
After changing my code to those you provide, the same error occurred.
I think I should paste createFields.H here:

Info<< "Reading field T\n" << endl;

volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

Info<< "Reading field alpha\n" << endl;

volScalarField alpha
(
IOobject
(
"alpha",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);


Info<< "Reading transportProperties\n" << endl;

IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);


Info<< "Reading KRhoC\n" << endl;

dimensionedScalar KRhoC
(
transportProperties.lookup("KRhoC")
);

Info<< "Reading HC\n" << endl;

dimensionedScalar HC
(
transportProperties.lookup("HC")
);

Info<< "Reading cureProperties\n" << endl;

IOdictionary cureProperties
(
IOobject
(
"cureProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);

Info<< "Reading a1\n" << endl;

dimensionedScalar a1
(
cureProperties.lookup("a1")
);

Info<< "Reading a2\n" << endl;

dimensionedScalar a2
(
cureProperties.lookup("a2")
);

Info<< "Reading d1\n" << endl;

dimensionedScalar d1
(
cureProperties.lookup("d1")
);

Info<< "Reading d2\n" << endl;

dimensionedScalar d2
(
cureProperties.lookup("d2")
);

Info<< "Reading R\n" << endl;

dimensionedScalar R
(
cureProperties.lookup("R")
);
Info<< "Reading m\n" << endl;

dimensionedScalar m
(
cureProperties.lookup("m")
);
Info<< "Reading n\n" << endl;

dimensionedScalar n
(
cureProperties.lookup("n")
);


actually, I cant find anything special here....I stored KRhoC and HC in transportproperties, and other parameters in cureProperties.
Sorry for bothering you and other guys again.

Cyp March 6, 2011 14:06

Hi!

Your last error comes from the power in your alphadot expression : in c++ a^b is pow(a,b).

Now, your code should compile perfectly.

Best,
Cyp

merlyn March 6, 2011 15:17

Quote:

Originally Posted by Cyp (Post 298116)
Hi!

Your last error comes from the power in your alphadot expression : in c++ a^b is pow(a,b).

Now, your code should compile perfectly.

Best,
Cyp

Hi, Cyp
You are the MAN !! :):):) It has been complied smoothly.

Grateful for your instruction and learnt a lot from your suggestion!

Merlin-
Truly


All times are GMT -4. The time now is 01:58.