adding condition to own solver (error occurs)
hello openfoamers.
I am trying to add condition const dimensionedScalar& rhol = twoPhaseProperties_.rho1(); const dimensionedScalar& rhov = twoPhaseProperties_.rho2(); if (alpha1_<0.9 && alpha1_>0.01) { Q_pc_ = 1; } else { Q_pc_ = 0; } } to my solver. But error no match for ‘operator<’ (operand types are ‘const volScalarField {aka const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘double’) occurs during allwmake. Is there a way to solve this problem? |
alpha1_ is a volScalarField and you want to compare it with a scalar. This does not work since no operator is defined for this. You have to loop over the whole field and compere each entry
|
thanks for the reply
Quote:
forAll(alpha1Cells, cellI) { if (alpha1[cellI] < 0.9 && alpha1[cellI] > 0.01) Q_pc_ = 1; else Q_pc_[cellI] = 0; } |
Code:
forAll(alpha1_, cellI) |
Quote:
const volScalarField& alpha1 = alpha1(); scalarField& alpha1Cells = alpha1.internalField(); this doesn't work at openfoam 2.4.0 |
There were some changes regarding the name of the function which returns the reference to the internal field from 3.0 on. Just google
|
Quote:
The program thinks Q_pc_ as zero dimension. Can you help me to deal with the problem? |
Can you post the error
|
Quote:
Q_pc_[cellI] = pos(T_[cellI] - T_sat_)*h_lv_*rl*alpha1_[cellI]*rhol*((T_[cellI] - T_sat_)/T_sat_) + neg(T_[cellI] -T_sat_)*h_lv_*rv*(1.0 - alpha1_[cellI])*rhov*((T_[cellI] - T_sat_)/T_sat_); ^ This is the error! i think Q_pc_[cellI] = 0; is working well but the equation format does not work. |
Quote:
const word& name, const dictionary& thermalPhaseChangeProperties, const twoPhaseThermalMixture& twoPhaseProperties, const volScalarField& T, const volScalarField& alpha1 ) : thermalPhaseChangeModel ( name, thermalPhaseChangeProperties, twoPhaseProperties, T, alpha1 ), Q_pc_ ( IOobject ( "PhaseChangeHeat", T_.time().timeName(), T.mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), T.mesh(), dimensionedScalar( "dummy", dimensionSet(1,-1,-3,0,0,0,0), 0 ) ) { // reading rl and rv thermalPhaseChangeProperties_.lookup("rl") >> rl; thermalPhaseChangeProperties_.lookup("rv") >> rv; correct(); } // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // void Foam::thermalPhaseChangeModels::EmpiricalRateParam eter::calcQ_pc() { const dimensionedScalar& rhol = twoPhaseProperties_.rho1(); const dimensionedScalar& rhov = twoPhaseProperties_.rho2(); forAll(alpha1_, cellI) { if (alpha1_[cellI] < 0.9 && alpha1_[cellI] > 0.01) { Q_pc_[cellI] = pos(T_[cellI] - T_sat_)*h_lv_*rl*alpha1_[cellI]*rhol*((T_[cellI] - T_sat_)/T_sat_) + neg(T_[cellI] -T_sat_)*h_lv_*rv*(1.0 - alpha1_[cellI])*rhov*((T_[cellI] - T_sat_)/T_sat_); } else { Q_pc_[cellI] = 0; } } } |
Look for the member function value()
|
All times are GMT -4. The time now is 19:37. |