Strains in zerolength

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

Moderators: silvia, selimgunay, Moderators

Post Reply
eroz
Posts: 49
Joined: Wed Sep 14, 2005 7:47 am
Location: San Francisco

Strains in zerolength

Post by eroz »

Two questions about the ZeroLength.cpp :

1) There is a "dispDiff(i)" function used in the "computeCurrentStrain1d" method. Where is "dispDiff(i)" defined?

2) What is the difference between (a) "diff" and (b) "dispDiff", where :

(a) the "diff" in the "upDate" function is given as:

const Vector& disp1 = theNodes[0]->getTrialDisp();
const Vector& disp2 = theNodes[1]->getTrialDisp();
Vector diff = disp2-disp1;

AND

(b) "dispDiff" is used as :

double MyElement::computeCurrentStrain1d( int mat, const Vector& dispDiff ) const
{
double strain = 0.0;

for (int i=0; i<numDOF/2; i++)
{
strain += -dispDiff(i) * (*t1d)(mat,i);
}

return strain;

}

Thanks
aneeman
Posts: 90
Joined: Thu Jan 12, 2006 1:13 pm
Contact:

Post by aneeman »

Let's take these one at a time. You're actually asking a general C++ question.

dispDiff is what's called a formal parameter. It's part of a method declaration:
double computeCurrentStrain1d( int mat, const Vector& dispDiff ) const;


diff is a local paramater, declared inside the method named update:
int ZeroLength::update(void)
{

Vector diff = disp2-disp1;

//diff can be used as an actual parameter and we can
// pass it in and call the method, as below

this->computeCurrentStrain1d(mat,diff ); // here diff gets used as if
//it was dispDiff
}

Hope this helps.

alisa

<<
Two questions about the ZeroLength.cpp :

1) There is a "dispDiff(i)" function used in the "computeCurrentStrain1d" method. Where is "dispDiff(i)" defined?

2) What is the difference between (a) "diff" and (b) "dispDiff", where :

(a) the "diff" in the "upDate" function is given as:

const Vector& disp1 = theNodes[0]->getTrialDisp();
const Vector& disp2 = theNodes[1]->getTrialDisp();
Vector diff = disp2-disp1;
>>
eroz
Posts: 49
Joined: Wed Sep 14, 2005 7:47 am
Location: San Francisco

Post by eroz »

Yes, this helps; thank you.
Post Reply