|
[Sponsors] |
adding condition to own solver (error occurs) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 23, 2021, 07:16 |
adding condition to own solver (error occurs)
|
#1 |
New Member
John Kim
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
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? |
|
February 23, 2021, 08:00 |
|
#2 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
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
|
|
February 23, 2021, 08:34 |
thanks for the reply
|
#3 | |
New Member
John Kim
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
Quote:
forAll(alpha1Cells, cellI) { if (alpha1[cellI] < 0.9 && alpha1[cellI] > 0.01) Q_pc_ = 1; else Q_pc_[cellI] = 0; } |
||
February 23, 2021, 08:38 |
|
#4 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
Code:
forAll(alpha1_, cellI) { if (alpha1_[cellI] < 0.9 && alpha1_[cellI] > 0.01) { Q_pc_[cellI]= 1; } else { Q_pc_[cellI] = 0; { } |
|
February 23, 2021, 08:46 |
|
#5 | |
New Member
John Kim
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
Quote:
const volScalarField& alpha1 = alpha1(); scalarField& alpha1Cells = alpha1.internalField(); this doesn't work at openfoam 2.4.0 |
||
February 23, 2021, 09:39 |
|
#6 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
There were some changes regarding the name of the function which returns the reference to the internal field from 3.0 on. Just google
|
|
February 25, 2021, 11:34 |
|
#7 | |
New Member
John Kim
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
Quote:
The program thinks Q_pc_ as zero dimension. Can you help me to deal with the problem? |
||
February 25, 2021, 11:50 |
|
#8 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
Can you post the error
|
|
February 25, 2021, 11:52 |
|
#9 |
New Member
John Kim
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
error: cannot convert ‘Foam::dimensioned<double>’ to ‘double’ in assignment
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. |
|
February 25, 2021, 12:04 |
|
#10 | |
New Member
John Kim
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
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; } } } |
||
February 25, 2021, 12:15 |
|
#11 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
Look for the member function value()
|
|
Tags |
openfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Boundary condition for a baffle in the Laplacian mesh motion solver | tecmul | OpenFOAM Running, Solving & CFD | 0 | May 11, 2020 23:10 |
How can I use solution from one simulation as initial condition on a remote solver? | Dano62 | CFX | 0 | October 21, 2015 18:45 |
adding Porous media to lagrangian Solver | kalyan | OpenFOAM Programming & Development | 0 | September 19, 2014 08:41 |
Star cd es-ice solver error | ernarasimman | STAR-CD | 2 | September 12, 2014 01:01 |
Quarter Burner mesh with periosic condition | SamCanuck | FLUENT | 2 | August 31, 2011 12:34 |