CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   compiling error(s) in a modified twoPhaseEulerFoam solver (https://www.cfd-online.com/Forums/openfoam/97976-compiling-error-s-modified-twophaseeulerfoam-solver.html)

foamer February 29, 2012 15:39

compiling error(s) in a modified twoPhaseEulerFoam solver
 
Hi

I am trying to compile a modified version of the solver twoPhaseEulerFoam. The errors that arise are the following:


Making dependency list for source file twoPhaseEulerFoam.C
SOURCE=twoPhaseEulerFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I../bubbleFoam -I/opt/openfoam171/src/finiteVolume/lnInclude -I/opt/openfoam171/src/transportModels/incompressible/lnInclude -IphaseModel/lnInclude -Iaveraging -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/twoPhaseEulerFoam.o
In file included from twoPhaseEulerFoam.C:77:
UEqns.H: In function ‘int main(int, char**)’:
UEqns.H:8: error: conversion from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<doubl e>, Foam::fvPatchField, Foam::volMesh> >’ to non-scalar type ‘Foam::volScalarField’ requested
UEqns.H:9: error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘Foam::scalar’ in initialization
UEqns.H:10: error: cannot convert ‘Foam::dimensionedScalar’ to ‘Foam::scalar’ in initialization
UEqns.H:19: error: no matching function for call to ‘interpolate(Foam::scalar&)’
UEqns.H:31: error: no matching function for call to ‘laplacian(Foam::scalar&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)’
UEqns.H:51: error: ‘nutb’ was not declared in this scope
UEqns.H:59: error: no matching function for call to ‘interpolate(Foam::scalar&)’
UEqns.H:71: error: no matching function for call to ‘laplacian(Foam::scalar&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:8: warning: unused variable ‘momentumPredictor’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:11: warning: unused variable ‘transonic’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:14: warning: unused variable ‘nOuterCorr’
readPPProperties.H:15: warning: unused variable ‘preAlphaExp’
readPPProperties.H:20: warning: unused variable ‘alphaMax’
readPPProperties.H:25: warning: unused variable ‘expMax’
make: *** [Make/linux64GccDPOpt/twoPhaseEulerFoam.o] Error 1


I am especially interested if someone could tell me how to go around the error i get in UEqns on line 8. In the UEqns.H file on line 8, the following is written:

volScalarField Umix = (rhoa*alpha*Ua + rhob * beta * Ub) / (rhoa * alpha + rhob * beta);

By inspection of the UEqns.H file, Umix is included in more places downwards in the code. I hence have a sense of that this is the reason for the rest of the errors in the UEqns.H file.


Could someone please help me with these compiling problems ?

Any help is deeply appreciated

Alex

Cyp February 29, 2012 15:48

Try volVectorField instead of volScalarField, it should works !

Regards,
Cyp

foamer February 29, 2012 16:07

Thanks very much Cyp!

That actually did work.

However, after i recompiled the solver, i still have som errors:


Making dependency list for source file twoPhaseEulerFoam.C
SOURCE=twoPhaseEulerFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I../bubbleFoam -I/opt/openfoam171/src/finiteVolume/lnInclude -I/opt/openfoam171/src/transportModels/incompressible/lnInclude -IphaseModel/lnInclude -Iaveraging -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/twoPhaseEulerFoam.o
In file included from twoPhaseEulerFoam.C:77:
UEqns.H: In function ‘int main(int, char**)’:
UEqns.H:10: error: cannot convert ‘Foam::tmp<Foam::GeometricField<Foam::Vector<doubl e>, Foam::fvPatchField, Foam::volMesh> >’ to ‘Foam::scalar’ in initialization
UEqns.H:11: error: cannot convert ‘Foam::dimensionedScalar’ to ‘Foam::scalar’ in initialization
UEqns.H:20: error: no matching function for call to ‘interpolate(Foam::scalar&)’
UEqns.H:32: error: no matching function for call to ‘laplacian(Foam::scalar&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)’
UEqns.H:52: error: ‘nutb’ was not declared in this scope
UEqns.H:60: error: no matching function for call to ‘interpolate(Foam::scalar&)’
UEqns.H:72: error: no matching function for call to ‘laplacian(Foam::scalar&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:8: warning: unused variable ‘momentumPredictor’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:11: warning: unused variable ‘transonic’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:14: warning: unused variable ‘nOuterCorr’
readPPProperties.H:15: warning: unused variable ‘preAlphaExp’
readPPProperties.H:20: warning: unused variable ‘alphaMax’
readPPProperties.H:25: warning: unused variable ‘expMax’
make: *** [Make/linux64GccDPOpt/twoPhaseEulerFoam.o] Error 1


Do you know how to go around any of these ?


Alex

Cyp February 29, 2012 16:13

What is it on UEqn.H line 10 ??

foamer February 29, 2012 16:15

It is:

scalar nutb = ct * Umix * pipeDia;


Alex

Cyp March 1, 2012 03:09

You have to keep in mind that in OpenFOAM, the variable are a specific object :

when you declare a scalar field, for example nut as volScalarField, this means that nut is :
- a table defined over the mesh,
- with boundary conditions,
- a name ("nut"),
- a dimensionSet

When you perform mathematical operation (+, - ,*, / ...) with such variables, you add (in the case of the addition) the table value (internalField), the boundary value, the dimensions..

In the line you present me, you try to define a scalar (just a number) from a volVectorField (a table of vector defined all over the mesh), and two other terms... it is absolutly not coherent !!!

just think of what you want to do !

I may found many informations in this doc : powerlab.fsb.hr/ped/kturbo/openfoam/docs/foam.pdf

Regards,
Cyp

laurensvd March 1, 2012 03:32

Cyp is correct, in the last formula you try to compute a scalar by using other scalars (ct, pipeDia) and a vector (Umix). Think of what is actually meant in the formula. Do you need the longitudonal velocity (extract the component of U in that direction), do you need the magnutide of the velocity (use mag(Umix) instead of Umix) or do you need something else?

On top of that, as Cyp mentioned, your vector Umix is defined in every cell whereas you want to compute a global value. Think if it really is a global value or if it is a value that is different throughout the field. If it is the latter initialise nutb as a volScalarField instead of a scalar.

foamer March 1, 2012 05:57

Quote:

Originally Posted by Cyp (Post 347024)
You have to keep in mind that in OpenFOAM, the variable are a specific object :

when you declare a scalar field, for example nut as volScalarField, this means that nut is :
- a table defined over the mesh,
- with boundary conditions,
- a name ("nut"),
- a dimensionSet

When you perform mathematical operation (+, - ,*, / ...) with such variables, you add (in the case of the addition) the table value (internalField), the boundary value, the dimensions..

In the line you present me, you try to define a scalar (just a number) from a volVectorField (a table of vector defined all over the mesh), and two other terms... it is absolutly not coherent !!!

just think of what you want to do !

I may found many informations in this doc : powerlab.fsb.hr/ped/kturbo/openfoam/docs/foam.pdf

Regards,
Cyp


Yes you are right. Actually, in the expression on line 10: scalar nutb = Ct * Umix * pipeDia, i put the scalar in front since without it, i got teh error message :

UEqns.H:10: error: ‘nutb’ was not declared in this scope

So i am not sure how to deal with it. But thanks for the link, i will definetely have a look into it.

Alex

foamer March 1, 2012 06:22

Quote:

Originally Posted by laurensvd (Post 347028)
Cyp is correct, in the last formula you try to compute a scalar by using other scalars (ct, pipeDia) and a vector (Umix). Think of what is actually meant in the formula. Do you need the longitudonal velocity (extract the component of U in that direction), do you need the magnutide of the velocity (use mag(Umix) instead of Umix) or do you need something else?

On top of that, as Cyp mentioned, your vector Umix is defined in every cell whereas you want to compute a global value. Think if it really is a global value or if it is a value that is different throughout the field. If it is the latter initialise nutb as a volScalarField instead of a scalar.

Thank you for your reply.

I think that the velocity Umix is supposed to be a constant value through the whole pipe. So i guess that it should be constant in each cell then...

If i use mag(Umix) i get the error message that Umix was not declared in this scope..

If i initialise nutb as a volScalarField instead of a scalar i get the error mesage:

UEqns.H:10: error: conversion from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<doubl e>, Foam::fvPatchField, Foam::volMesh> >’ to non-scalar type ‘Foam::volScalarField’ requested


Alex

foamer March 1, 2012 06:34

Btw, my whole UEqns.H file look like the following:


fvVectorMatrix UaEqn(Ua, Ua.dimensions()*dimVol/dimTime);
fvVectorMatrix UbEqn(Ub, Ub.dimensions()*dimVol/dimTime);
// scalar nutb = 1.0 ; // Use new var. name : NOS
// scalar nuEffa, nuEffb ; // Use new var. name : NOS
{
{
volTensorField gradUaT = fvc::grad(Ua)().T();
//volScalarField Umix = (rhoa * alpha * Ua + rhob * beta * Ub) / (rhoa *alpha + rhob * beta);
volVectorField Umix = (rhoa * alpha * Ua + rhob * beta * Ub) / (rhoa * alpha + rhob * beta);
volScalarField nutb = Ct * Umix * pipeDia; // Mixing length
scalar nuEffa = nutb + nua;

volTensorField Rca
(
"Rca",
((2.0/3.0)*I)*(nuEffa*tr(gradUaT)) - nuEffa*gradUaT // Turbulent kinetic energy combined with pressure
);

surfaceScalarField phiRa =
-fvc::interpolate(nuEffa)*mesh.magSf()*fvc::snGrad( alpha)
/fvc::interpolate(alpha + scalar(0.001));

UaEqn =
(
scalar(1)*
(
fvm::ddt(Ua)
+ fvm::div(phia, Ua, "div(phia,Ua)")
- fvm::Sp(fvc::div(phia), Ua)
)

- fvm::laplacian(nuEffa, Ua)
+ fvc::div(Rca)

+ fvm::div(phiRa, Ua, "div(phia,Ua)")
- fvm::Sp(fvc::div(phiRa), Ua)
+ (fvc::grad(alpha)/(fvc::average(alpha) + scalar(0.001)) & Rca)
==

// g // Buoyancy term transfered to p-equation
- fvm::Sp(KWalla, Ua) // Wall friction
- fvm::Sp(KInta, Ua) // Interface drag
//+ KIa*Ub/rhoa // Explicit interface drag transfered to p-equation

);

UaEqn.relax();
}

{
volTensorField gradUbT = fvc::grad(Ub)().T();
scalar nuEffb = nutb + nub;
volTensorField Rcb
(
"Rcb",
((2.0/3.0)*I)*(nuEffb*tr(gradUbT)) - nuEffb*gradUbT
);

surfaceScalarField phiRb =
-fvc::interpolate(nuEffb)*mesh.magSf()*fvc::snGrad( beta)
/fvc::interpolate(beta + scalar(0.001));

UbEqn =
(
scalar(1)*
(
fvm::ddt(Ub)
+ fvm::div(phib, Ub, "div(phib,Ub)")
- fvm::Sp(fvc::div(phib), Ub)
)

- fvm::laplacian(nuEffb, Ub)
+ fvc::div(Rcb)

+ fvm::div(phiRb, Ub, "div(phib,Ub)")
- fvm::Sp(fvc::div(phiRb), Ub)

+ (fvc::grad(beta)/(fvc::average(beta) + scalar(0.001)) & Rcb)
==

// g // Buoyancy term transfered to p-equation
- fvm::Sp(KWallb, Ub) // Wall friction phaseb
- fvm::Sp(KIntb, Ub) // Interfacial drag
//+ KIa*Ua/rhob // Explicit interface drag transfered to p-equation
);

UbEqn.relax();
}
}


I get the following compiling error message :


SOURCE=twoPhaseEulerFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/opt/openfoam171/applications/solvers/multiphase/bubbleFoam -I/opt/openfoam171/src/finiteVolume/lnInclude -I/opt/openfoam171/src/transportModels/incompressible/lnInclude -IphaseModel/lnInclude -Iaveraging -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/twoPhaseEulerFoam.o
In file included from twoPhaseEulerFoam.C:77:
UEqns.H: In function ‘int main(int, char**)’:
UEqns.H:10: error: conversion from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<doubl e>, Foam::fvPatchField, Foam::volMesh> >’ to non-scalar type ‘Foam::volScalarField’ requested
UEqns.H:11: error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘Foam::scalar’ in initialization
UEqns.H:20: error: no matching function for call to ‘interpolate(Foam::scalar&)’
UEqns.H:32: error: no matching function for call to ‘laplacian(Foam::scalar&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)’
UEqns.H:52: error: ‘nutb’ was not declared in this scope
UEqns.H:60: error: no matching function for call to ‘interpolate(Foam::scalar&)’
UEqns.H:72: error: no matching function for call to ‘laplacian(Foam::scalar&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:8: warning: unused variable ‘momentumPredictor’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:11: warning: unused variable ‘transonic’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:14: warning: unused variable ‘nOuterCorr’
readPPProperties.H:15: warning: unused variable ‘preAlphaExp’
readPPProperties.H:20: warning: unused variable ‘alphaMax’
readPPProperties.H:25: warning: unused variable ‘expMax’
make: *** [Make/linux64GccDPOpt/twoPhaseEulerFoam.o] Error 1


Alex

Cyp March 1, 2012 06:37

And btw have you read what we explain to you ?

Code:

volScalarField nutb = Ct * mag(Umix) * pipeDia;
should works (If Umix is a volVectorField, then mag(Umix) is a volScalarField defined on every cells of your mesh, it is not a constant !). But once again, it depends on the way you declare Ct and pipeDia...

foamer March 9, 2012 10:14

Quote:

Originally Posted by Cyp (Post 347062)
And btw have you read what we explain to you ?

Code:

volScalarField nutb = Ct * mag(Umix) * pipeDia;
should works (If Umix is a volVectorField, then mag(Umix) is a volScalarField defined on every cells of your mesh, it is not a constant !). But once again, it depends on the way you declare Ct and pipeDia...


You are right.

I was a little tired of not getting it to work.

However, now it compiled fine :)

Thank you very much for your help.

Cyp March 9, 2012 10:32

Quote:

Originally Posted by foamer (Post 348573)
You are right.

I was a little tired of not getting it to work.

However, now it compiled fine :)

Thank you very much for your help.


you're welcome ;)

Pirlu June 20, 2014 00:33

Hi Cyp,

your answers also help me. May i ask one more simple question?

How can i convert volScalarField to a scalar, or just get the 'value' from the volScalarField variable?

I tried scalar vf (voidfraction); but the complier complains that it is not allowed in initialisation.

Thanks in advance,
Jing

Pirlu June 20, 2014 08:51

Quote:

Originally Posted by Pirlu (Post 497881)
Hi Cyp,

your answers also help me. May i ask one more simple question?

How can i convert volScalarField to a scalar, or just get the 'value' from the volScalarField variable?

I tried scalar vf (voidfraction); but the complier complains that it is not allowed in initialisation.

Thanks in advance,
Jing

Thank to this link: http://www.cfd-online.com/Forums/ope...dimension.html

I think i found the simple solution.


All times are GMT -4. The time now is 03:45.