Skip to content

Commit

Permalink
squash! Added: Tangent matrix for monolithic coupling of elasticity a…
Browse files Browse the repository at this point in the history
…nd phasefield. Added: Option to return derivatives of the stress degradation function. Added: Parsing and printing of the stabilization parameter alpha, this is the same quantity as stabk in the CahnHilliard integrand.

The monolithic coupling matrix was incorrect
  • Loading branch information
kmokstad committed Nov 5, 2016
1 parent 222759e commit 45d1ff3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
58 changes: 30 additions & 28 deletions FractureElasticityVoigt.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@

bool FractureElasticityVoigt::evalStress (double lambda, double mu, double Gc,
const SymmTensor& epsil, double* Phi,
SymmTensor* sigma, Matrix* dSdE,
bool postProc, bool printElm) const
SymmTensor* sigma, SymmTensor* sigP,
Matrix* dSdE, bool postProc,
bool printElm) const
{
PROFILE3("FractureEl::evalStress");

Expand Down Expand Up @@ -90,6 +91,12 @@ bool FractureElasticityVoigt::evalStress (double lambda, double mu, double Gc,
*sigma = C0*trEps;
*sigma += 2.0*mu*(Gc*ePos + eNeg);
}
if (sigP)
{
// Evaluate the non-degraded tensile stress tensor
*sigP = lambda*trEps;
*sigP += 2.0*mu*ePos;
}

// Evaluate the tensile energy
Phi[0] = mu*(ePos*ePos).trace();
Expand All @@ -113,6 +120,7 @@ bool FractureElasticityVoigt::evalStress (double lambda, double mu, double Gc,
std::cout <<"M("<< 1+a <<") =\n"<< M[a];
std::cout <<"ePos =\n"<< ePos <<"eNeg =\n"<< eNeg;
if (sigma) std::cout <<"sigma =\n"<< *sigma;
if (sigP) std::cout <<"sigP =\n"<< *sigP;
std::cout <<"Phi = "<< Phi[0];
if (postProc) std::cout <<" "<< Phi[1] <<" "<< Phi[2] <<" "<< Phi[3];
std::cout << std::endl;
Expand Down Expand Up @@ -242,7 +250,7 @@ bool FractureElasticityVoigt::evalInt (LocalIntegral& elmInt,

size_t nstrc = (nsd+1)*nsd/2;
Matrix Bmat, dSdE(nstrc,nstrc);
SymmTensor eps(nsd), sigma(nsd);
SymmTensor eps(nsd), sigma(nsd), sigP(nsd);
bool lHaveStrains = false;

if (eKm || eKg || iS || m_mode == SIM::RECOVERY)
Expand All @@ -269,12 +277,12 @@ bool FractureElasticityVoigt::evalInt (LocalIntegral& elmInt,
if (noSplit)
{
// Evaluate the constitutive matrix and the stress tensor at this point
if (!material->evaluate(dSdE,sigma,myPhi[fe.iGP],fe,X,eps,eps))
if (!material->evaluate(dSdE,sigP,myPhi[fe.iGP],fe,X,eps,eps))
return false;

// Degrade the stresses and strain energy isotropically
myPhi[fe.iGP] *= Gc;
sigma *= Gc;
sigma = Gc*sigP;
}
else
{
Expand All @@ -290,7 +298,7 @@ bool FractureElasticityVoigt::evalInt (LocalIntegral& elmInt,

// Evaluate the stress state at this point, with degraded tensile part
if (!this->evalStress(lambda,mu,Gc,eps,&myPhi[fe.iGP],&sigma,
eKm ? &dSdE : nullptr))
eKc ? &sigP : nullptr, eKm ? &dSdE : nullptr))
return false;
}
}
Expand All @@ -312,6 +320,14 @@ bool FractureElasticityVoigt::evalInt (LocalIntegral& elmInt,
if (eM) // Integrate the mass matrix
this->formMassMatrix(elMat.A[eM-1],fe.N,X,fe.detJxW);

if (iS && lHaveStrains)
{
// Integrate the internal forces
sigma *= -fe.detJxW;
if (!Bmat.multiply(sigma,elMat.b[iS-1],true,true)) // ES -= B^T*sigma
return false;
}

if (eS)
{
// Integrate the load vector due to gravitation and other body forces
Expand All @@ -320,28 +336,14 @@ bool FractureElasticityVoigt::evalInt (LocalIntegral& elmInt,
this->formCrackForce(elMat.b[eS-1],elMat.vec,fe,X);
}

if (!lHaveStrains)
return true;

Vector BtSig;
sigma *= -fe.detJxW;
if (eKc && !Bmat.multiply(sigma,BtSig,true)) // BtSig = -B^T*sigma
return false;

if (iS)
{
// Integrate the internal forces
if (eKc)
elMat.b[iS-1].add(BtSig); // ES += BtSig
else if (!Bmat.multiply(sigma,elMat.b[iS-1],true,true)) // ES -= B^T*sigma
return false;
}

if (eKc)
if (eKc && lHaveStrains)
{
// Integrate the coupling matrix between displacement and phase-field DOFs
BtSig *= -this->getStressDegradation(fe.N,elmInt.vec,1); // g'(c)
if (!elMat.A[eKc-1].outer_product(BtSig,fe.N,true)) // Kc += B^T*sigma*N*dGc
Vector BtSig;
sigP *= this->getStressDegradation(fe.N,elmInt.vec,1)*fe.detJxW; // *= g'(c)
if (!Bmat.multiply(sigP,BtSig,true)) // BtSig = B^T*g'(c)*sigP
return false;
if (!elMat.A[eKc-1].outer_product(BtSig,fe.N,true)) // Kc += BtSig*N
return false;
}

Expand All @@ -353,7 +355,7 @@ bool FractureElasticityVoigt::evalStress (double lambda, double mu, double Gc,
const SymmTensor& epsilon,
double* Phi, SymmTensor& sigma) const
{
return this->evalStress(lambda,mu,Gc,epsilon,Phi,&sigma,nullptr,true);
return this->evalStress(lambda,mu,Gc,epsilon,Phi,&sigma,nullptr,nullptr,true);
}


Expand Down Expand Up @@ -445,7 +447,7 @@ bool FractureElasticNorm::evalInt (LocalIntegral& elmInt,
// Evaluate the tensile-degraded strain energy
if (!p.evalStress(lambda,mu,Gc,eps,Phi,
dirDer ? &sigma : nullptr,
nullptr,true,printElm))
nullptr,nullptr,true,printElm))
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion FractureElasticityVoigt.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class FractureElasticityVoigt : public FractureElasticity
//! \brief Evaluates the stress tensor and its derivative w.r.t. the strains.
bool evalStress(double lambda, double mu, double Gc,
const SymmTensor& epsilon, double* Phi,
SymmTensor* sigma, Matrix* dSdE,
SymmTensor* sigma, SymmTensor* sigP, Matrix* dSdE,
bool postProc = false, bool printElm = false) const;

unsigned short int eKc; //!< Zero-based index to element coupling matrix
Expand Down
2 changes: 1 addition & 1 deletion Test/TestFractureElasticity.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public:
virtual ~FracEl() {}
bool calcStress(double lambda, double mu, double Gc, const SymmTensor& eps,
double& Phi, SymmTensor& sigma, Matrix& dSdE) const
{ return evalStress(lambda,mu,Gc,eps,&Phi,&sigma,&dSdE); }
{ return evalStress(lambda,mu,Gc,eps,&Phi,&sigma,nullptr,&dSdE); }
bool calcStress(double lambda, double mu, double Gc, const SymmTensor& eps,
double& Phi, SymmTensor& sigma, Tensor4& dSdE) const
{ return FractureElasticity::evalStress(lambda,mu,Gc,eps,&Phi,sigma,&dSdE); }
Expand Down

0 comments on commit 45d1ff3

Please sign in to comment.