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

adding strainRate in a solver

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 1 Post By kmooney
  • 1 Post By wyldckat
  • 2 Post By Mahyar Javidi
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 17, 2014, 17:54
Default adding strainRate in a solver
  #1
New Member
 
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 14
Mahyar Javidi is on a distinguished road
Hello everyone
I want to add strain rate in interFoam and I do not know how to do that. I need to define one more equation to interFoam similar to the temperature but for volume fraction and I wrote the code for solving the matrix but still have a problem with strain rate.

I defined viscosity like:
surfaceScalarField mu=fvc::interpolate(twoPhaseProperties.mu());

and I tried to define strain rate like:
surfaceScalarField strainRate=fvc::interpolate(viscosityProperties.st rainRate());

which it seems the definition of strain rate is not correct. Do I need to declare sth in creatFields.H for it?
Could anyone help me coding this part.

Regards
Mahyar
Mahyar Javidi is offline   Reply With Quote

Old   December 19, 2014, 15:26
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
Hi Mahyar,

You could always calculate the strain rate values with something like this in the top level solver:

Code:
volScalarField strainRate = sqrt(2.0)*mag(symm(fvc::grad(U)));
surfaceScalarField strainRatef = fvc::interpolate(strainRate);
On another look it seems that the incompressibleTwoPhaseMixture class has a public access function to the viscosityModel class.

Something like this might work as well (warning:untested):

Code:
surfaceScalarField strainratef = fvc::interpolate(twoPhaseProperties.nuModel1().strainRate());
I hope that helps!

Cheers,
Kyle

Quote:
Originally Posted by Mahyar Javidi View Post
Hello everyone
I want to add strain rate in interFoam and I do not know how to do that. I need to define one more equation to interFoam similar to the temperature but for volume fraction and I wrote the code for solving the matrix but still have a problem with strain rate.

I defined viscosity like:
surfaceScalarField mu=fvc::interpolate(twoPhaseProperties.mu());

and I tried to define strain rate like:
surfaceScalarField strainRate=fvc::interpolate(viscosityProperties.st rainRate());

which it seems the definition of strain rate is not correct. Do I need to declare sth in creatFields.H for it?
Could anyone help me coding this part.

Regards
Mahyar
alainislas likes this.
kmooney is offline   Reply With Quote

Old   December 23, 2014, 10:50
Default
  #3
New Member
 
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 14
Mahyar Javidi is on a distinguished road
HiKyle

Thanks for your reply. I tried the first part of the code that you mentioned beforein my code and I got an error about the type that strainRate returns (which is double).

I was wondering should I define an object for viscosityModel class and use strainRate function through that object. I think this is the case for twophaseProperties.


Best Regards
Mahyar
Mahyar Javidi is offline   Reply With Quote

Old   December 23, 2014, 16:25
Default
  #4
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
Hi Mahyar,

I'm confused by your statement. How can strainRate return a double if you're initializing the variable to be type volScalarField?

Kyle
kmooney is offline   Reply With Quote

Old   January 8, 2015, 16:28
Default
  #5
New Member
 
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 14
Mahyar Javidi is on a distinguished road
Dear Kyle

sorry for the late reply.
This is the exact error that I receive when I used the definition of strainRate in the code.

error: call of overloaded ‘sqrt(double)’ is ambiguous

regards
Mahyar
Mahyar Javidi is offline   Reply With Quote

Old   January 8, 2015, 16:30
Default
  #6
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
try

Code:
foam::sqrt
instead
kmooney is offline   Reply With Quote

Old   January 8, 2015, 16:37
Default
  #7
New Member
 
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 14
Mahyar Javidi is on a distinguished road
Hi

I used volScalarField strainRate = foam::sqrt(2.0)*mag(symm(fvc::grad(U)));
and I got this: error: ‘foam’ has not been declared

Regards
Mahyar
Mahyar Javidi is offline   Reply With Quote

Old   January 8, 2015, 16:39
Default
  #8
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
you could always just use 1.41421356237!
kmooney is offline   Reply With Quote

Old   January 8, 2015, 16:51
Default
  #9
New Member
 
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 14
Mahyar Javidi is on a distinguished road
Thanks Kyle. The solver compiled now.
Mahyar Javidi is offline   Reply With Quote

Old   January 8, 2015, 16:52
Default
  #10
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

This is one of those frequently asked questions... gotta make a note to add this to the FAQ...

Mahyar, please try the following:
Code:
::sqrt(2.0)
::sqrt(scalar(2.0))
sqrt(scalar(2.0))
scalar(::sqrt(2.0))
scalar(sqrt(2.0))
I don't have time to test any of them right now, but I do vaguely remember that said error message can be overcome with one or more of the above.

Best regards,
Bruno
kmooney likes this.
__________________
wyldckat is offline   Reply With Quote

Old   January 8, 2015, 17:06
Default
  #11
New Member
 
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 14
Mahyar Javidi is on a distinguished road
Hi Bruno

I checked them in my solver and the results are:

scalar(sqrt(2.0)) error: call of overloaded ‘sqrt(double)’ is ambiguous, note: Foam::doubleScalar Foam::sqrt(Foam::doubleScalar)

scalar(::sqrt(2.0)) It works

sqrt(scalar(2.0)) error: call of overloaded ‘sqrt(double)’ is ambiguous

::sqrt(scalar(2.0)) It works

::sqrt(2.0) It works

Regards
Mahyar
wyldckat and rudolf.hellmuth like this.
Mahyar Javidi is offline   Reply With Quote

Old   January 11, 2015, 15:53
Default
  #12
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Mahyar,

Many thanks for testing them all! I've added the working ones to the FAQ: http://openfoamwiki.net/index.php/FA...9_is_ambiguous

Best regards,
Bruno
rudolf.hellmuth likes this.
wyldckat 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
chtMultiRegionSimpleFoam samiam1000 OpenFOAM Running, Solving & CFD 39 March 31, 2016 09:43
thobois class engineTopoChangerMesh error Peter_600 OpenFOAM 4 August 2, 2014 10:52
Adding additional complex source term to BuoyantBoussinesqPisoFoam solver pajofego OpenFOAM Programming & Development 2 April 9, 2013 18:00
Working directory via command line Luiz CFX 4 March 6, 2011 21:02
why the solver reject it? Anyone with experience? bearcat CFX 6 April 28, 2008 15:08


All times are GMT -4. The time now is 01:39.