if-loop, volScalarField comparison
Hi all,
I have a problem with a task, which seemed to be straight-forward to solve at first. I need to program an if-loop in order to compare one volScalarField (P1) to another one (P2), and for each grid point, where P1 >= P2, a certain value (d) has to be written to another volScalarField (N) at exactly the same grid point. I wrote something like: (a, b, c, d are placeholder for arbitrary volScalarFields) Code:
volScalarField P1 = a; It's more that it just compares just one (the first?!) point of P1 with P2. Right now, I don't have any idea how to get rid of that problem, though it seems to be a very silly one. Thanks for any idea. greets, volker |
Hi,
you have to loop over your cells to compare information in each point: Code:
forAll(P1, cellI) |
hi alberto,
so many thanks for your help!!! It worked great. I wasn't aware of that class 'cell'. Do you know if there is a way to loop over the boundary patches as well? best volker |
Quote:
Quote:
Code:
forAll(p.boundaryField(), patchi) |
perfect, big thanks to you!
:) |
You're welcome :D
|
2 Attachment(s)
I am tyring to change a viscoisty model. I need to campare strain rate with a constant parameter (gama)
if strainrate is greater than the gama then do.... so I write : ************************************************** ******************* Foam::viscosityModels::MyHerschelBulkley::calcNu() const { dimensionedScalar tone("tone", dimTime, 1.0); dimensionedScalar rtone("rtone", dimless/dimTime, 1.0); tmp<volScalarField> sr(strainRate()); forAll(calcNu.internalField(), cellI) { if (sr[cellI]< gama_.value()) { ...... It shows me the error: error : calcNu’ does not have class type forAll(calcNu.internalField(), cellI) could you please help me? Attachment 75170 Attachment 75171 |
Can any one help me?
|
All times are GMT -4. The time now is 14:52. |