CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   adding strainRate in a solver (https://www.cfd-online.com/Forums/openfoam-programming-development/146061-adding-strainrate-solver.html)

Mahyar Javidi December 17, 2014 17:54

adding strainRate in a solver
 
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

kmooney December 19, 2014 15:26

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 (Post 524415)
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 December 23, 2014 10:50

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

kmooney December 23, 2014 16:25

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

Mahyar Javidi January 8, 2015 16:28

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

kmooney January 8, 2015 16:30

try

Code:

foam::sqrt
instead

Mahyar Javidi January 8, 2015 16:37

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

kmooney January 8, 2015 16:39

you could always just use 1.41421356237!

Mahyar Javidi January 8, 2015 16:51

Thanks Kyle. The solver compiled now.

wyldckat January 8, 2015 16:52

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

Mahyar Javidi January 8, 2015 17:06

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 January 11, 2015 15:53

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


All times are GMT -4. The time now is 08:48.