CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

logarithm of a volScalarField

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Santiago

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 15, 2019, 12:02
Default logarithm of a volScalarField
  #1
New Member
 
Join Date: Mar 2019
Posts: 7
Rep Power: 7
Flopi is on a distinguished road
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 !
Flopi is offline   Reply With Quote

Old   April 16, 2019, 03:13
Default
  #2
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15
Santiago is on a distinguished road
... or maybe its because b is not positive?
vivek05 likes this.
Santiago is offline   Reply With Quote

Old   April 16, 2019, 03:32
Default
  #3
New Member
 
Join Date: Mar 2019
Posts: 7
Rep Power: 7
Flopi is on a distinguished road
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 ?
Flopi is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message Bruno_Jorge Main CFD Forum 1 February 5, 2019 11:12
namespace Foam Argen OpenFOAM 4 February 5, 2019 08:55
Logarithm for volScalarField pakanatiakash OpenFOAM Running, Solving & CFD 6 April 2, 2016 16:38
execFlowFunctionObjects - unknown field problem Toorop OpenFOAM Post-Processing 16 March 14, 2016 03:25
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16


All times are GMT -4. The time now is 23:51.