|
[Sponsors] |
December 1, 2014, 22:49 |
error when applying myCavitatingFoam
|
#1 |
Member
BO WANG
Join Date: Sep 2014
Posts: 37
Rep Power: 11 |
Hi everyone, I tried to do some adaptations to the cavitatingFoam. And the compile went well. However, when I tried to apply it to the throttle/ras/cavitatingFoam case, following error appears. I compared it with my succeed log file with cavitatingFoam, and found out the problem might be with the compressibility model. But I can't really find which part of the code leads to this. Can anyone offer any clue?
Create time Create mesh for time = 0 Reading thermodynamicProperties Reading field p Reading field U Reading/calculating face flux field phiv Reading/calculating face flux field phi Reading transportProperties Selecting incompressible transport model Newtonian Selecting incompressible transport model Newtonian #0 Foam::error:rintStack(Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 in "/lib/x86_64-linux-gnu/libc.so.6" #3 std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) in "/usr/lib/x86_64-linux-gnu/libstdc++.so.6" #4 Foam::regIOobject::regIOobject(Foam::regIOobject const&) at ??:? #5 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::GeometricFiel d<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:? #6 at ??:? #7 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #8 at ??:? Segmentation fault (core dumped) |
|
December 2, 2014, 01:34 |
|
#2 |
Senior Member
|
Hi,
Maybe I missed something but are you proposing people to guess your code modifications? |
|
December 2, 2014, 04:02 |
|
#3 | |
Member
BO WANG
Join Date: Sep 2014
Posts: 37
Rep Power: 11 |
Quote:
It seems to me that the error happened in the creatField.H. But I only added few lines there as following without other modifications. volScalarField rhov(twoPhaseProperties.rho1()); volScalarField rhol(twoPhaseProperties.rho2()); volScalarField B=rhol/psil; double N=11; double r=1.4; Regards |
||
December 2, 2014, 04:40 |
|
#4 |
Senior Member
|
Well,
Don't know what OF version/compiler you're using but this Code:
volScalarField rhov(twoPhaseProperties.rho1()); volScalarField rhol(twoPhaseProperties.rho2()); These lines should be something like: Code:
rhol ( IOobject ( "rhol", mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, twoPhaseProperties.rho1() ) |
|
December 2, 2014, 07:33 |
|
#5 | |
Member
BO WANG
Join Date: Sep 2014
Posts: 37
Rep Power: 11 |
Quote:
And I need the rhol and rhov as volScalarField beacuse there is a function in 0Equn.H: { volScalarField pgl=(rhov*rhol*(rhov-rhol))/(magSqr(rhov)*psil-magSqr(rhol)*psiv); if ( rho>rhol) p=pSat+(B/N)*(pow((rho/rhol),N)-1.0); else if (rho<rhov) p=pSat*pow((rho/rhov),r); else p=pSat+pgl*log10(rhov*psil*(rhol+alphav*(rhov-rhol))/(rhol*(rhov*psil-alphav*(rhov*psil-rhol*psiv)))); } Or is there other method I can do this? |
||
December 2, 2014, 08:10 |
|
#6 |
Senior Member
|
Hi,
I can't answer your question as I don't see your redefinition. Maybe it's OK, maybe it is the reason for the runtime error. As I don't know what else you've redefined (and think that one should guess it), I will assume variables in you expression have types as in original cavitatingFoam. This Code:
{ volScalarField pgl=(rhov*rhol*(rhov-rhol))/(magSqr(rhov)*psil-magSqr(rhol)*psiv); if ( rho>rhol) p=pSat+(B/N)*(pow((rho/rhol),N)-1.0); else if (rho<rhov) p=pSat*pow((rho/rhov),r); else p=pSat+pgl*log10(rhov*psil*(rhol+alphav*(rhov-rhol))/(rhol*(rhov*psil-alphav*(rhov*psil-rhol*psiv)))); } 1. Iterate over volume field and check your condition is every cell. Code:
dimensionedScalar pgl=(rhov*rhol*(rhov-rhol))/(magSqr(rhov)*psil-magSqr(rhol)*psiv); forAll(rho, cellI) { if ( rho[cellI] > rhol.value()) p[cellI] = pSat + (B/N)*(pow((rho/rhol),N)-1.0); else if (rho[cellI]<rhov.value()) p[cellI] = pSat*pow((rho/rhov),r); else p[cellI] = pSat + pgl*log10(rhov*psil*(rhol+alphav[cellI]*(rhov-rhol))/(rhol*(rhov*psil-alphav[cellI]*(rhov*psil-rhol*psiv)))); } p.correctBoundaryConditions(); 2. These is sign function which return -1 if expression is below zero, 0 is expression is 0, and 1 if expression is above zero. You need 3 conditions: rho - rhol, rho - rhov, everything else. Expr1 is value of p for rhol < rho, expr2 is value of p for rho < rhov, expr3 is everything else. Also assuming rhov < rhol: Code:
const volScalarField s1(sign(rho - rhol)); const volScalarField s2(sign(rho - rhov)); // if rho < rhov: s1 == -1 and s2 == -1 -> expr2 // if rhov < rho < rhol: s1 == 1 and s2 == -1 -> expr3 // if rhol < rho: s1 == 1 and s2 == 1 -> exp1 p = 0.25*(1 - s1)*(1 - s2)*expr2 + 0.25*(1 + s1)*(1 - s2)*exp3 + 0.5*(1 + s2)*exp1 |
|
December 2, 2014, 21:55 |
|
#7 |
Member
BO WANG
Join Date: Sep 2014
Posts: 37
Rep Power: 11 |
Hi, thanks for the brilliant suggestion, I have been stuck on the expression for a long time. I have learnt a lesson from here. Now I am able to wmake the solver without error.
However, following error appears again when I am trying to apply it to the throttle case. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 Reading thermodynamicProperties Reading field p Reading field U Reading/calculating face flux field phiv Reading/calculating face flux field phi Reading transportProperties Selecting incompressible transport model Newtonian Selecting incompressible transport model Newtonian #0 Foam::error:rintStack(Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 in "/lib/x86_64-linux-gnu/libc.so.6" #3 std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) in "/usr/lib/x86_64-linux-gnu/libstdc++.so.6" #4 Foam::regIOobject::regIOobject(Foam::regIOobject const&) at ??:? #5 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::GeometricFiel d<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:? #6 at ??:? #7 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #8 at ??:? Segmentation fault (core dumped) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // And this is how my relevant creatField.H looks like now. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "createPhiv.H" #include "compressibleCreatePhi.H" Info<< "Reading transportProperties\n" << endl; incompressibleTwoPhaseMixture twoPhaseProperties(U, phiv); volScalarField& alphav(twoPhaseProperties.alpha1()); alphav.oldTime(); volScalarField& alphal(twoPhaseProperties.alpha2()); dimensionedScalar rhov(twoPhaseProperties.rho1()); dimensionedScalar rhol(twoPhaseProperties.rho2()); volScalarField B=rhol/psil; double N=11; double r=1.4; Info<< "Creating compressibilityModel\n" << endl; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // |
|
December 2, 2014, 22:06 |
|
#8 |
Member
BO WANG
Join Date: Sep 2014
Posts: 37
Rep Power: 11 |
Thanks for being so patient.
For the convenient, I have attached all the modified code in the attachment. For the pEqn.H, it is a immature version now. I planned to add more to it, such as nonorthogonal correction when I am able to run the case. |
|
December 3, 2014, 01:47 |
|
#9 |
Senior Member
|
Hm, you've changed rhol and rhov into dimensioned scalars and again trying to initialize volScalarField B from ratio of these scalars using = operator. It is OK but you have to create B properly first (via copy constructor from other volume field or via constructor from components). Will B be location dependent or it's another constant like rhol and rhov?
|
|
December 3, 2014, 03:07 |
|
#10 | |
New Member
BO
Join Date: Dec 2014
Posts: 21
Rep Power: 11 |
Quote:
Code:
Info<< "Reading transportProperties\n" << endl; incompressibleTwoPhaseMixture twoPhaseProperties(U, phiv); volScalarField& alphav(twoPhaseProperties.alpha1()); alphav.oldTime(); volScalarField& alphal(twoPhaseProperties.alpha2()); dimensionedScalar rhov(twoPhaseProperties.rho1()); dimensionedScalar rhol(twoPhaseProperties.rho2()); dimensionedScalar B=rhol/psil; double N=11; double r=1.4; Info<< "Creating compressibilityModel\n" << endl; Code:
forAll(rho,cellI) { if (rho[cellI]>rhol.value()) p[cellI]=pSat.value()+(B/N)*(pow((rho/rhol),N)-1.0); else if (rho[cellI]<rhov.value()) p[cellI]=pSat.value()*pow((rho/rhov),r); else p[cellI]=pSat.value()+pgl*log10(rhov*psil*(rhol+alphav*(rhov-rhol))/(rhol*(rhov*psil-alphav*(rhov*psil-rhol*psiv)))); } p.correctBoundaryConditions(); Code:
p[cellI]=pSat+pgl*log10(rhov*psil*(rhol+alphav[cellI]*(rhov-rhol))/(rhol*(rhov*psil-alphav[cellI]*(rhov*psil-rhol*psiv)))); |
||
December 3, 2014, 03:14 |
|
#11 |
New Member
BO
Join Date: Dec 2014
Posts: 21
Rep Power: 11 |
Thanks again for being so patient. Or could you please tell me is there any place I can learn how to deal with these?
|
|
December 3, 2014, 03:40 |
|
#12 |
Senior Member
|
Well,
Basically you've got 3 different types here: 1. scalar 2. dimensionedScalar 3. volScalarField let's assume variables: S is scalar, DS is dimensioned scalar, VSF is volScalarField. 1. DS.value() is scalar. 2. VSF[cellI] (or VSF.internalField()[cellI]) is scalar. There are certain assignments that are valid, for example, you can assign VSF = DS. For the assignment to be valid, VSF should be correctly constructed. Either as a copy of another volScalarField, or from components. Returning to your code: Code:
p[cellI]=pSat.value()+(B/N)*(pow((rho/rhol),N)-1.0) Code:
0pEqn.H:23:18: erreur: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ in assignment Code:
In file included from mycavitatingFoam.C:51:0: createFields.H:56:53: erreur: no matching function for call to ‘Foam::dimensioned<double>::dimensioned(const volScalarField&)’ dimensionedScalar rhol(twoPhaseProperties.rho2()); If you'd like to learn about iterating over volScalarField (or volVectorField): Code:
$ cd $FOAM_APP/solvers $ grep -r forAll * |
|
December 3, 2014, 08:51 |
|
#13 |
New Member
BO
Join Date: Dec 2014
Posts: 21
Rep Power: 11 |
Hi, thanks for the advise. I have looked through the example files, redefined my rhov and rhol as scalar and managed to write my 0pEqn like this, no more no match error this time :
Code:
dimensionedScalar rhov00(twoPhaseProperties.rho1()); dimensionedScalar rhol00(twoPhaseProperties.rho2()); scalar rhov=rhov00.value(); scalar rhol=rhol00.value(); scalar B=rhol/psil.value(); scalar N=11; scalar r=1.4; Code:
forAll(rho,cellI) { if (rho[cellI]>rhol) p[cellI]=pSat.vlaue()+(B/N)*(pow((rho[cellI]/rhol),N)-scalar(1)); else if (rho[cellI]<rhov) p[cellI]=pSat.value()*pow((rho[cellI]/rhov),r); else p[cellI]=pSat.value()+pgl.value()*log10(rhov*psil.value()*(rhol+alphav[cellI]*(rhov-rhol))/(rhol*(rhov*psil.value()-alphav[cellI]*(rhov*psil.value()-rhol*psiv.value())))); } Code:
0pEqn.H:27:55: error: call of overloaded ‘pow(double, Foam::scalar&)’ is ambiguous p[cellI]=pSat.value()*pow((rho[cellI]/rhov),r); Code:
0pEqn.H:31:179: error: call of overloaded ‘log10(Foam::scalar)’ is ambiguous p[cellI]=pSat.value()+pgl.value()*log10(rhov*psil.value()*(rhol+alphav[cellI]*(rhov-rhol))/(rhol*(rhov*psil.value()-alphav[cellI]*(rhov*psil.value()-rhol*psiv.value())))); Code:
{ volScalarField Ta(pair_.Ta()); return neg(Ta - scalar(1))*scalar(1) + pos(Ta - scalar(1))*neg(Ta - scalar(39.8)) *pow3(0.81 + 0.206*tanh(1.6 - 2*log10(max(Ta, scalar(1))))) + pos(Ta - scalar(39.8))*0.24; } |
|
December 3, 2014, 09:08 |
|
#14 |
Senior Member
|
There are lots of fancy errors like
Code:
In file included from pEqn.H:37:0, from mycavitatingFoam.C:82: 0pEqn.H:23:24: erreur: ‘Foam::dimensionedScalar’ has no member named ‘vlaue’ p[cellI]=pSat.vlaue()+(B/N)*(std::pow((rho[cellI]/rhol),N)-1.0); Code:
pow -> std::pow log10 -> std::log10 |
|
December 3, 2014, 22:18 |
|
#15 |
New Member
BO
Join Date: Dec 2014
Posts: 21
Rep Power: 11 |
Hi, I have been able to solve the fancy problem by predefine a scalar pSat
Code:
scalar pSat00=pSat.value(); Now I am able to run the case, although it will explode at last. I think I am going to fix the equations now. Thanks for all the advise and patience all the way. Best. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Applying Temprature Gradient | mujeeb | Structural Mechanics | 0 | May 17, 2014 07:48 |
Applying Loads to Part of a Surface/spliting a part in ANSYS | 123catty456 | Main CFD Forum | 1 | July 29, 2013 12:52 |
Problem in applying Gamma-Retheta transition model | mb.pejvak | Main CFD Forum | 2 | November 13, 2012 10:27 |
Problem in applying SST k-omega | mb.pejvak | Main CFD Forum | 2 | May 17, 2012 19:50 |
applying boundary condition on rotating wall | Haris Maharana | Siemens | 2 | January 16, 2001 12:03 |