|
[Sponsors] |
February 25, 2021, 11:27 |
assigning dimension scalar
|
#1 |
New Member
John Kim
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
Hello openfoamers. I have a problem dealing with the dimension
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; } } } This is my code. The wmake works but when i run this solver, openfoam 2.4.0 thinks Q_pc_ as zero dimension. But as you can see, I made Q_pc_ to be (1,-1,-3,0,0,0,0). How can i solve this problem? p.s error occurs like this 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 error come when i run the program. --> FOAM FATAL ERROR: Different dimensions for = dimensions : [1 -1 -3 0 0 0 0] = [0 0 0 0 0 0 0] |
|
February 25, 2021, 14:37 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
If you use something like Q_pc[index], you are already bypassing dimension checks. Your dimensions are coming from somewhere else like rhol. Might want to use the .value() method there.
|
|
February 25, 2021, 15:06 |
|
#3 | |
New Member
John Kim
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
Quote:
Then I have to make a code something like (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_)).value() ?? |
||
February 25, 2021, 18:22 |
|
#4 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Quote:
It looks like your Q_pc is a volScalarField - when thinking of the rest, it would pay to take a look at some of the tutorial files (the various 0/ fields) to see what how they are structured. The volScalarField has the same things: dimensions, an internal field and the boundary patches. Within OpenFOAM, you usually work on the highest level, for example adding or multiplying these volume fields. The dimension checks are done once at the top level. At the lower-level of looping, you just have an "internal" field of values, eg a scalar for each cell. These don't have any dimensions, and you wouldn't really want to have dimension checking in the inner loop. So when you are referencing an internal value like Q_pc[cellId] you are just getting the scalar value. If you start to multiply these with things that _are_ dimensioned, such as a dimensionedScalar, things get a bit weird since the plain scalar doesn't have dimension. At that stage you would normally use the .value() on the dimensionedScalar to get its plain value. Have a play around, and you'll get the idea. Not really easy to explain at a distance. |
||
February 26, 2021, 03:27 |
|
#5 | |
New Member
John Kim
Join Date: Jan 2021
Posts: 22
Rep Power: 5 |
Quote:
Sincerely John |
||
Tags |
openfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' | muth | OpenFOAM Running, Solving & CFD | 3 | August 27, 2018 05:18 |
Division by zero exception - loop over scalarField | Pat84 | OpenFOAM Programming & Development | 6 | February 18, 2017 06:57 |
Issue symmetryPlane 2.5d extruded airfoil simulation | 281419 | OpenFOAM Running, Solving & CFD | 5 | November 28, 2015 14:09 |
Diverging solution in transonicMRFDyMFoam | tsalter | OpenFOAM Running, Solving & CFD | 30 | July 7, 2014 07:20 |
compressible flow in turbocharger | riesotto | OpenFOAM | 50 | May 26, 2014 02:47 |