CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Division of a dimensionedScalar by a volScalar Field - Arithmetic Exception

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 25, 2018, 15:22
Default Division of a dimensionedScalar by a volScalar Field - Arithmetic Exception
  #1
Member
 
Join Date: Feb 2018
Posts: 91
Rep Power: 8
charles4allme is on a distinguished road
Hello,
I would appreciate any input to this problem am facing. Here is the piece of the code.
Code:
const volVectorField Uduct = U.db().lookupObject<volVectorField>("U");
const volScalarField Uduct1 = mag(U);
dimensionedScalar Length
(
   "Length",
   dimensionSet(0, 1, 0, 0, 0, 0, 0),
   0.75
);

dimensionedScalar mu
(
   "mu",
   dimensionSet(0, 2, -1, 0, 0, 0, 0),
   1.81e-05
);

const volScalarField Reynold = (Uduct1*Length)/mu;

const scalar first = (3.0/0.4572)/3.7; 

 
const scalar second = Foam::pow(first,1.11);

dimensionedScalar t1
(
   "t1",
   dimensionSet(0, 0, 0, 0, 0, 0, 0),
   6.9
);

const volScalarField third = t1/Reynold;

const volScalarField fourth = 4.518/Reynold;

const volScalarField fifth = fourth*log10(second+third);
const volScalarField frict = -2*log10(first - fifth);
const volScalarField frictfact = pow(1/frict,2);

The error comes from the line of the code
Code:
const volScalarField third = t1/Reynold;
I get a
Code:
Program received signal SIGFPE, Arithmetic exception.
It seems that the Reynold value is zero. Playing around with the code if I do this
Code:
const volScalarField third = Reynold/t1;
, the code runs. What is going on with error cos I assume am making a school boy error in my code or violating the format in OpenFOAM code. Any input will be appreciated.


Thanks.
charles4allme is offline   Reply With Quote

Old   June 25, 2018, 15:51
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Can you guarantee your velocity to be non-zero everywhere? Otherwise this is plain division by zero.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   June 26, 2018, 06:04
Default
  #3
Member
 
Join Date: Feb 2018
Posts: 91
Rep Power: 8
charles4allme is on a distinguished road
Hi,

Yeah you are right. I cannot guarantee that. What do you recommend. Do I make use of the velocity at the initial condition to calculate the reynolds number, or do I use an if loop to avoid non-zero velocities.

P.S. I still can't explain why I get a value when I reverse the division I get a value.
Code:
const volScalarField third = Reynold/t1;
THanks a lot.
charles4allme is offline   Reply With Quote

Old   June 26, 2018, 06:57
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Quote:
Originally Posted by charles4allme View Post
Hi,
P.S. I still can't explain why I get a value when I reverse the division I get a value.
Code:
const volScalarField third = Reynold/t1;
THanks a lot.
These are really very simple basics. t1 is a non-zero constant, so there is no reason why a division would not give a value. What is unclear?
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   June 27, 2018, 09:57
Default
  #5
Member
 
Join Date: Feb 2018
Posts: 91
Rep Power: 8
charles4allme is on a distinguished road
Yeah i was just a bit confused. STill figuring basic details of OpenFOAM.

Thanks a lot
charles4allme 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
problems after decomposing for running alessio.nz OpenFOAM 7 March 5, 2021 04:49
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Modifying boundaryfield of a volscalar field hawkeye321 OpenFOAM 5 February 15, 2013 05:01
Is good initial guess field is neccessary ? mmkr825 OpenFOAM 5 October 17, 2012 12:58
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51


All times are GMT -4. The time now is 16:02.