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

Whats wrong with this volScalarField?

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes
  • 2 Post By alexeym
  • 1 Post By sharonyue
  • 1 Post By alexeym
  • 2 Post By alexeym
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 9, 2014, 04:09
Default Whats wrong with this volScalarField?
  #1
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Hi guys,

In my code I have this We definition:
Code:
volScalarField We(2*rho2*pow(epsilon,0.6667)*pow(d,1.6667));
Then I define:
Code:
volScalarField Web(-1.5*(1/We));
It compiles okay, and actually I only define this Web, I even dont use it in function. But when I run a case it said:
Code:
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2   in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::divide(Foam::Field<double>&, double const&, Foam::UList<double> const&) at ??:?
#4  void Foam::divide<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::dimensioned<double> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#5  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#6  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(double const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#7  
 at ??:?
#8  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#9  
 at ??:?
Floating point exception (core dumped)
I tried another definition:
Code:
volScalarField Web(-1.5*(pow(We,-1));
It compiles okay too, but when I run it said:
Code:
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2   in "/lib/x86_64-linux-gnu/libc.so.6"
#3   in "/lib/x86_64-linux-gnu/libm.so.6"
#4  pow in "/lib/x86_64-linux-gnu/libm.so.6"
#5  Foam::pow(Foam::Field<double>&, Foam::UList<double> const&, double const&) at ??:?
#6  void Foam::pow<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensioned<double> const&) at ??:?
#7  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::pow<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensioned<double> const&) at ??:?
#8  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::pow<Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, double const&) at ??:?
#9  
 at ??:?
#10  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
So I think this core dumped is caused by this definition. How should I do? Thanks.


PS. If I define it like this:
Code:
volScalarField Web(-1.5*(pow(We,1));
It runs with out error.
sharonyue is offline   Reply With Quote

Old   April 9, 2014, 04:27
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

as the error is in division, it seems that We is zero somewhere.
sharonyue and venturi123 like this.
alexeym is offline   Reply With Quote

Old   April 9, 2014, 04:36
Default
  #3
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

as the error is in division, it seems that We is zero somewhere.
Solved! You do pretty good in OpenFOAM, everytime you know the solution.!
sharonyue is offline   Reply With Quote

Old   April 9, 2014, 04:38
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
This time it's just common sense
alexeym is offline   Reply With Quote

Old   April 18, 2014, 16:16
Default
  #5
New Member
 
Amjad
Join Date: May 2012
Posts: 21
Rep Power: 13
Amjad Asad is on a distinguished road
hallo
how did u solve this problem plz
Amjad Asad is offline   Reply With Quote

Old   April 18, 2014, 21:12
Default
  #6
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Quote:
Originally Posted by Amjad Asad View Post
hallo
how did u solve this problem plz
Just like Alexey have said,

when you are using pow() function. Watch out your denominator, it can not be zero. So if you wanna use this function as this: pow(e,-1). You'd better define a small number like SMALL=1e-6, and write it as pow(e+SMALL,-1). This worked for my problem.

Regards,
Amjad Asad likes this.
sharonyue is offline   Reply With Quote

Old   April 19, 2014, 00:52
Default
  #7
New Member
 
Amjad
Join Date: May 2012
Posts: 21
Rep Power: 13
Amjad Asad is on a distinguished road
I am trying to write a code to estimate the turbulence intensity in openfoam. the code does not work, when mag (U) is equal to zero.
volScalarField Intensity
(
IOobject
(
"Intensity",
runTime.timeName(),
mesh,
IOobject::NO_READ

),


sqrt((2.0/3.0)*k)/mag(UMean)



);
Amjad Asad is offline   Reply With Quote

Old   April 19, 2014, 01:45
Default
  #8
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

instead of

Quote:
Originally Posted by Amjad Asad View Post
sqrt((2.0/3.0)*k)/mag(UMean)
you can use

Code:
sqrt((2.0/3.0)*k)/max(SMALL, mag(UMean))
Amjad Asad likes this.
alexeym is offline   Reply With Quote

Old   April 19, 2014, 02:02
Default
  #9
New Member
 
Amjad
Join Date: May 2012
Posts: 21
Rep Power: 13
Amjad Asad is on a distinguished road
thanks for ur reply but i have a new problem now, I get

--> FOAM FATAL ERROR:
Arguments of max have different dimensions
dimensions : [0 0 0 0 0 0 0] and [0 1 -1 0 0 0 0]

thanks
Amjad Asad is offline   Reply With Quote

Old   April 19, 2014, 02:06
Default
  #10
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Oh, forgot about dimensions. Then it should be something like:

Code:
sqrt((2.0/3.0)*k)/max(dimensionedScalar("uSMALL", dimVelocity, SMALL), mag(UMean))
Amjad Asad and sharonyue like this.
alexeym is offline   Reply With Quote

Old   April 19, 2014, 02:09
Default
  #11
New Member
 
Amjad
Join Date: May 2012
Posts: 21
Rep Power: 13
Amjad Asad is on a distinguished road
thanks it is working very good now
Amjad Asad is offline   Reply With Quote

Old   April 19, 2014, 04:02
Default
  #12
New Member
 
Amjad
Join Date: May 2012
Posts: 21
Rep Power: 13
Amjad Asad is on a distinguished road
hi again,
but i still get strange values at the wall where the velocity zero
Amjad Asad is offline   Reply With Quote

Old   April 19, 2014, 04:09
Default
  #13
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
And by strange values you mean? What BCs did you use for k on this wall with non-slip BC for velocity?
alexeym is offline   Reply With Quote

Old   April 19, 2014, 04:20
Default
  #14
New Member
 
Amjad
Join Date: May 2012
Posts: 21
Rep Power: 13
Amjad Asad is on a distinguished road
i meant with strang values that they are too hight 1e+13. and the BCs is fixed wall and i used wall function here for K
Amjad Asad is offline   Reply With Quote

Old   April 19, 2014, 07:23
Default
  #15
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
OK.

Let's forget for a moment about volume fields. If you have expression y/x in your model, rewriting it as y/(x + small) will help you to resolve a problem with 0/0. But it will give you very high values if y is non-zero.

Now returning to OpenFOAM. You've got non-slip BC for velocity at the wall and you've got non-zero value of k at the same wall. Why? If there's no motion why there is turbulence? If you're using kqRWallFunction for k, it's actually simple zero-gradient boundary condition and you have to use appropriate mesh so k go to 0 at the wall. Or maybe your solution is not converged. Or maybe your initial conditions do not make sense. Or ...

First fix your model, then fix code.
Amjad Asad likes this.

Last edited by alexeym; April 19, 2014 at 07:40. Reason: typo
alexeym is offline   Reply With Quote

Old   April 19, 2014, 08:21
Default
  #16
New Member
 
Amjad
Join Date: May 2012
Posts: 21
Rep Power: 13
Amjad Asad is on a distinguished road
thanks for ur help, I think there is no proplem with K. the problem is mag(U) because it too small
at the wall, them K/mag(u) will be too high.
my code is attached.
Attached Files
File Type: gz intensity.tar.gz (74.6 KB, 9 views)
Amjad Asad 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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 09:21
udf error srihari FLUENT 1 October 31, 2016 14:18
make a dimensionedScalar to be volScalarField sharonyue OpenFOAM Programming & Development 4 April 2, 2014 05:44
multiplicate all elements of volScalarField with scalar to get new volScalarField maybee OpenFOAM Programming & Development 2 February 18, 2014 15:43
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16


All times are GMT -4. The time now is 21:57.