# adding strainRate in a solver

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 LinkBack Thread Tools Search this Thread Display Modes
 December 17, 2014, 16:54 adding strainRate in a solver #1 New Member   anonymous Join Date: Jan 2012 Location: Canada Posts: 24 Rep Power: 11 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

December 19, 2014, 14:26
#2
Senior Member

Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 15
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 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

 December 23, 2014, 09:50 #3 New Member   anonymous Join Date: Jan 2012 Location: Canada Posts: 24 Rep Power: 11 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

 December 23, 2014, 15:25 #4 Senior Member     Kyle Mooney Join Date: Jul 2009 Location: San Francisco, CA USA Posts: 323 Rep Power: 15 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

 January 8, 2015, 15:28 #5 New Member   anonymous Join Date: Jan 2012 Location: Canada Posts: 24 Rep Power: 11 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

 January 8, 2015, 15:30 #6 Senior Member     Kyle Mooney Join Date: Jul 2009 Location: San Francisco, CA USA Posts: 323 Rep Power: 15 try Code: `foam::sqrt` instead

 January 8, 2015, 15:37 #7 New Member   anonymous Join Date: Jan 2012 Location: Canada Posts: 24 Rep Power: 11 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

 January 8, 2015, 15:39 #8 Senior Member     Kyle Mooney Join Date: Jul 2009 Location: San Francisco, CA USA Posts: 323 Rep Power: 15 you could always just use 1.41421356237!

 January 8, 2015, 15:51 #9 New Member   anonymous Join Date: Jan 2012 Location: Canada Posts: 24 Rep Power: 11 Thanks Kyle. The solver compiled now.

 January 8, 2015, 15:52 #10 Retired Super Moderator   Bruno Santos Join Date: Mar 2009 Location: Lisbon, Portugal Posts: 10,962 Blog Entries: 45 Rep Power: 125 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. __________________ OpenFOAM: FAQ | Getting started Forum: How to get help, to post code/output and forum guide Read this before sending me PM

 January 8, 2015, 16:06 #11 New Member   anonymous Join Date: Jan 2012 Location: Canada Posts: 24 Rep Power: 11 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.

 January 11, 2015, 14:53 #12 Retired Super Moderator   Bruno Santos Join Date: Mar 2009 Location: Lisbon, Portugal Posts: 10,962 Blog Entries: 45 Rep Power: 125 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.

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 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 OffTrackbacks are Off Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post samiam1000 OpenFOAM Running, Solving & CFD 39 March 31, 2016 08:43 Peter_600 OpenFOAM 4 August 2, 2014 09:52 pajofego OpenFOAM Programming & Development 2 April 9, 2013 17:00 Luiz CFX 4 March 6, 2011 20:02 bearcat CFX 6 April 28, 2008 14:08

All times are GMT -4. The time now is 22:56.

 Contact Us - CFD Online - Privacy Statement - Top