
[Sponsors] 
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); Something like this might work as well (warning:untested): Code:
surfaceScalarField strainratef = fvc::interpolate(twoPhaseProperties.nuModel1().strainRate()); Cheers, Kyle Quote:


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 

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)) Best regards, Bruno
__________________


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 

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 

Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
chtMultiRegionSimpleFoam  samiam1000  OpenFOAM Running, Solving & CFD  39  March 31, 2016 08:43 
thobois class engineTopoChangerMesh error  Peter_600  OpenFOAM  4  August 2, 2014 09:52 
Adding additional complex source term to BuoyantBoussinesqPisoFoam solver  pajofego  OpenFOAM Programming & Development  2  April 9, 2013 17:00 
Working directory via command line  Luiz  CFX  4  March 6, 2011 20:02 
why the solver reject it? Anyone with experience?  bearcat  CFX  6  April 28, 2008 14:08 