|
[Sponsors] |
Iterating through a field leads to not matching dimensions at some point of the loop |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 31, 2022, 11:17 |
Iterating through a field leads to not matching dimensions at some point of the loop
|
#1 |
Member
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4 |
Dear Foamers,
I cannot wrap my mind around this problem. I have initialised a dimensionedScalar(dimMass/dimTime, 0) and then I want to integrate over all cells if a condition is met. But everytime the loop starts or is running through all cells at some point a conflict with not matching dimensions occurs. The code looks like this: Code:
dimensionedScalar intPhiVap("intPhiVap", dimMass/dimTime, 0); forAll(mesh_.C(), celli) { if (alpha1()[celli] < alphaCutOff_) { intPhiVap.value() += (1.0-alpha1()[celli])*phi[celli]*mesh_.V(); } } Code:
dimensions [0 0 0 0 0 0 0] = [1 0 -1 0 0 0 0] From function bool Foam::dimensionSet::operator=(const Foam::dimensionSet&) const Code:
intPhiVap += (1.0-alpha1()[celli])*phi[celli]*mesh_.V(); Code:
Different dimensions for += dimensions : [1 0 -1 0 0 0 0] = [0 0 0 0 0 0 0] From function bool Foam::dimensionSet::operator+=(const Foam::dimensionSet&) const Code:
intPhiVap = (1.0-alpha1()[celli])*phi[celli]*mesh_.V() + intPhiVap; Code:
--> FOAM FATAL ERROR: LHS and RHS of + have different dimensions dimensions : [0 0 0 0 0 0 0] + [1 0 -1 0 0 0 0] From function Foam::dimensionSet Foam::operator+(const Foam::dimensionSet&, const Foam::dimensionSet&) Code:
intPhiVap = (1.0-alpha1()[celli])*phi[celli]*mesh_.V() + intPhiVap.value(); Code:
--> FOAM FATAL ERROR: Different dimensions for = dimensions : [1 0 -1 0 0 0 0] = [0 0 0 0 0 0 0] From function bool Foam::dimensionSet::operator=(const Foam::dimensionSet&) const Code:
intPhiVap.value() = (1.0-alpha1()[celli])*phi[celli]*mesh_.V() + intPhiVap.value(); Code:
--> FOAM FATAL ERROR: Different dimensions for = dimensions : [0 0 0 0 0 0 0] = [1 0 -1 0 0 0 0] From function bool Foam::dimensionSet::operator=(const Foam::dimensionSet&) const I really hope someone has an idea how tofix this. Thank you all in advance Last edited by überschwupper; September 1, 2022 at 02:34. |
|
September 1, 2022, 08:40 |
|
#2 |
Member
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4 |
I'm not sure if the upper problem is solved but it seems like I have found a work around specificly for my work.
The above code snippet was inside a function that should return a Pair<dimensionedScalar>, but asap the single values are written, dimension mismatch is occuring. Code:
Pair<dimensionedScalar> calcPhis() //Code return Pair<dimensionedScalar> ( intPhiLiq, intPhiVap ); Pair intPhis(calcPhis); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Access volume field in the boundary condition of a point field | peyman.havaej | OpenFOAM Programming & Development | 0 | July 31, 2020 12:10 |
[Gmsh] Problem with Gmsh | nishant_hull | OpenFOAM Meshing & Mesh Conversion | 23 | August 5, 2015 02:09 |
[Gmsh] Gmsh and samplesurface | touf | OpenFOAM Meshing & Mesh Conversion | 2 | December 10, 2007 02:27 |
CFX4.3 -build analysis form | Chie Min | CFX | 5 | July 12, 2001 23:19 |
Grid refinement with wall functions | Mark Render | Main CFD Forum | 8 | May 2, 2000 07:09 |