|
[Sponsors] |
April 15, 2019, 13:02 |
logarithm of a volScalarField
|
#1 |
New Member
Join Date: Mar 2019
Posts: 7
Rep Power: 7 |
Dear all,
I have an issue with my code, and I can't seem to find a way around. I am trying to calculated explicitly a volScalarField as the logarithm of another field: volScalarField a ( IOobject ( "a", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); volScalarField b ( IOobject ( "b", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); a = log(b); The code compiles properly, but when I try to use the value of a, in another explicit equation: c = a; then the program fails and 'generates stack trace...'. I guess it's because there is a problem of variable type, but when I try a ForAll loop to give each cell the value, I got a problem with incompatible type during compilation. So basically my question is: how to easily take the logarithm of a volScalarField such that the result is a volScalarField whose values are the log of the previous field ? Thank you for your help ! |
|
April 16, 2019, 04:13 |
|
#2 |
Senior Member
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 16 |
... or maybe its because b is not positive?
|
|
April 16, 2019, 04:32 |
|
#3 |
New Member
Join Date: Mar 2019
Posts: 7
Rep Power: 7 |
There are indeed some zero values in b (nothing negative though).
As I tried to make the calculation with a ForAll loop and failed because of some type mismatch, I decided to remove the -inf values after the a = log(b) calculation by looping on a and removing the -inf values using an auxilliary Field (calculated somewhere else on my model) which knows where the zero values of b were (not sure if that's clear). It seemed to work as when I print the new cleaned a, I don't have any -inf values in the list (nor the boundary conditions). But I guess something must have remained and makes the calculation fail ? |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error message | Bruno_Jorge | Main CFD Forum | 1 | February 5, 2019 12:12 |
namespace Foam | Argen | OpenFOAM | 4 | February 5, 2019 09:55 |
Logarithm for volScalarField | pakanatiakash | OpenFOAM Running, Solving & CFD | 6 | April 2, 2016 17:38 |
execFlowFunctionObjects - unknown field problem | Toorop | OpenFOAM Post-Processing | 16 | March 14, 2016 04:25 |
writing execFlowFunctionObjects | immortality | OpenFOAM Post-Processing | 30 | September 15, 2013 07:16 |