A little confused about source code of ViscousMaterial

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
sugerbug
Posts: 1
Joined: Fri Sep 08, 2023 10:55 pm

A little confused about source code of ViscousMaterial

Post by sugerbug »

Hello everyone,
When I look through the source code of ViscousMaterial, I'm confused about some lines about it (line122~139):

Code: Select all

double 
ViscousMaterial::getStress(void)
{
    double stress = 0.0;
    double absRate = fabs(trialRate);

    if (absRate > minVel)
      stress = C*pow(absRate, Alpha);
    else
      stress = C*pow(minVel, Alpha);

    stress = C*pow(absRate, Alpha);    

    if (trialRate < 0.0)
        return -stress;
    else
        return  stress;
}
it seems like no matter absRate > minVel or not, the stress alwasys equals to C*pow(absRate, Alpha). ( Since expression "stress = C*pow(minVel, Alpha);" will be over writen by the expression after it anyway.)

I'm a rookie to C++ language and programming, hope someone can help me with it.
Thanks you.
mhscott
Posts: 880
Joined: Tue Jul 06, 2004 3:38 pm
Location: Corvallis, Oregon USA
Contact:

Re: A little confused about source code of ViscousMaterial

Post by mhscott »

Yes, you are correct. I don't recall why the if/else is overridden though.
Post Reply