keyword stringclasses 7 values | repo_name stringlengths 8 98 | file_path stringlengths 4 244 | file_extension stringclasses 29 values | file_size int64 0 84.1M | line_count int64 0 1.6M | content stringlengths 1 84.1M ⌀ | language stringclasses 14 values |
|---|---|---|---|---|---|---|---|
3D | febiosoftware/FEBio | FEBioMech/FEOrthotropicCLE.h | .h | 2,373 | 60 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
//-----------------------------------------------------------------------------
//! This class implements an orthotropic conewise linear elastic (CLE) material (Curnier et al. 1995 J Elasticity).
class FEOrthotropicCLE : public FEElasticMaterial
{
public:
double lp11, lp22, lp33; // diagonal first lamé constants (tension)
double lm11, lm22, lm33; // diagonal first lamé constants (compression)
double l12, l23, l31; // off-diagonal first lamé constants
double mu1, mu2, mu3; // shear moduli
public:
FEOrthotropicCLE(FEModel* pfem) : FEElasticMaterial(pfem) {}
//! calculate stress at material point
mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! data initialization
bool Validate() override;
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEMortarContactSurface.cpp | .cpp | 2,196 | 66 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEMortarContactSurface.h"
//-----------------------------------------------------------------------------
FEMortarContactSurface::FEMortarContactSurface(FEModel* pfem) : FEContactSurface(pfem)
{
}
//-----------------------------------------------------------------------------
bool FEMortarContactSurface::Init()
{
if (FEContactSurface::Init() == false) return false;
int NN = Nodes();
m_gap.resize(NN, vec3d(0,0,0));
return true;
}
//-----------------------------------------------------------------------------
void FEMortarContactSurface::UpdateNodalAreas()
{
int NN = Nodes();
int NF = Elements();
m_A.resize(NN, 0.0);
for (int i=0; i<NF; ++i)
{
FESurfaceElement& el = Element(i);
double a = FaceArea(el);
int nn = el.Nodes();
double fa = a / (double) nn;
for (int j=0; j<nn; ++j) m_A[el.m_lnode[j]] += fa;
}
for (int i=0; i<NN; ++i) m_A[i] = 1.0/m_A[i];
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPeriodicSurfaceConstraint.h | .h | 3,814 | 118 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEContactInterface.h"
#include "FEContactSurface.h"
//-----------------------------------------------------------------------------
class FEBIOMECH_API FEPeriodicSurfaceConstraintSurface : public FEContactSurface
{
public:
//! constructor
FEPeriodicSurfaceConstraintSurface(FEModel* pfem) : FEContactSurface(pfem) { m_nref = -1; }
//! initializes data
bool Init();
//! calculates the center of mass of the surface
vec3d CenterOfMass();
void Serialize(DumpStream& ar);
public:
vector<vec3d> m_gap; //!< gap function at nodes
vector<FESurfaceElement*> m_pme; //!< secondary surface element a node penetrates
vector<vec2d> m_rs; //!< natural coordinates of projection on secondary surface element
vector<vec3d> m_Lm; //!< Lagrange multipliers
int m_nref; //!< reference node
};
//-----------------------------------------------------------------------------
class FEBIOMECH_API FEPeriodicSurfaceConstraint : public FEContactInterface
{
public:
//! constructor
FEPeriodicSurfaceConstraint(FEModel* pfem);
//! destructor
virtual ~FEPeriodicSurfaceConstraint(void) {}
//! initialization
bool Init() override;
//! interface activation
void Activate() override;
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! return the primary and secondary surface
FESurface* GetPrimarySurface() override { return &m_ss; }
FESurface* GetSecondarySurface() override { return &m_ms; }
//! return integration rule class
bool UseNodalIntegration() override { return true; }
//! build the matrix profile for use in the stiffness matrix
void BuildMatrixProfile(FEGlobalMatrix& K) override;
public:
//! calculate contact forces
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
//! calculate contact stiffness
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
//! calculate Lagrangian augmentations
bool Augment(int naug, const FETimeInfo& tp) override;
//! update
void Update() override;
protected:
void ProjectSurface(FEPeriodicSurfaceConstraintSurface& ss, FEPeriodicSurfaceConstraintSurface& ms, bool bmove);
public:
FEPeriodicSurfaceConstraintSurface m_ss; //!< primary surface
FEPeriodicSurfaceConstraintSurface m_ms; //!< secondary surface
double m_atol; //!< augmentation tolerance
double m_eps; //!< penalty scale factor
double m_stol; //!< search tolerance
double m_srad; //!< search radius (%)
bool m_btwo_pass; //!< nr of passes
FEDofList m_dofU;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEDamageNeoHookean.cpp | .cpp | 5,861 | 186 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEDamageNeoHookean.h"
// define the material parameters
BEGIN_FECORE_CLASS(FEDamageNeoHookean, FEElasticMaterial)
ADD_PARAMETER(m_E, FE_RANGE_GREATER(0.0), "E")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_v, FE_RANGE_RIGHT_OPEN(-1.0, 0.5), "v");
ADD_PARAMETER(m_alpha, FE_RANGE_GREATER_OR_EQUAL(0.0), "a");
ADD_PARAMETER(m_beta , FE_RANGE_CLOSED(0.0, 1.0), "b");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
// Constructor
FEDamageNeoHookean::FEDamageNeoHookean(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_E = 0;
m_v = 0;
m_alpha = 0.014;
m_beta = 0.34;
}
//-----------------------------------------------------------------------------
// returns a pointer to a new material point object
FEMaterialPointData* FEDamageNeoHookean::CreateMaterialPointData()
{
return new FEDamageMaterialPoint(new FEElasticMaterialPoint);
}
//-----------------------------------------------------------------------------
// Initialization routine and parameter checking
bool FEDamageNeoHookean::Init()
{
if (FEElasticMaterial::Init() == false) return false;
// calculate Lame parameters
m_lam = m_v*m_E/((1+m_v)*(1-2*m_v));
m_mu = 0.5*m_E/(1+m_v);
return true;
}
//-----------------------------------------------------------------------------
//! Calculate the stress. This happens in two phases. First, we calculate
//! the stress for the undamaged material. Second, we update the damage
//! parameter and correct the stress accordingly.
mat3ds FEDamageNeoHookean::Stress(FEMaterialPoint& mp)
{
// --- A. Calculate neo-Hookean stress ----
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double detF = pt.m_J;
double detFi = 1.0/detF;
double lndetF = log(detF);
// calculate left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
// Identity
mat3dd I(1);
// calculate stress
mat3ds s = (b - I)*(m_mu*detFi) + I*(m_lam*lndetF*detFi);
// --- B. Calculate the damage reduction factor ---
double g = Damage(mp);
return s*g;
}
//-----------------------------------------------------------------------------
// Calculate damage reduction factor
double FEDamageNeoHookean::Damage(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate right Cauchy-Green tensor
mat3ds C = pt.RightCauchyGreen();
// Invariants
double I1 = C.tr();
double J = pt.m_J;
// strain-energy value
double lnJ = log(J);
double SEF = 0.5*m_mu*(I1 - 3) - m_mu*lnJ + 0.5*m_lam*(lnJ*lnJ);
// get the damage material point data
FEDamageMaterialPoint& dp = *mp.ExtractData<FEDamageMaterialPoint>();
// calculate trial-damage parameter
dp.m_Etrial = sqrt(2.0*fabs(SEF));
// calculate damage parameter
double Es = max(dp.m_Etrial, dp.m_Emax);
// calculate reduction parameter
double g = 1.0;
if (fabs(Es) > 1e-12) g = m_beta + (1.0 - m_beta)*(1.0 - exp(-Es/m_alpha))/(Es/m_alpha);
else g = 1.0 - 0.5*(1.0 - m_beta)/m_alpha*Es;
dp.m_D = 1-g;
return g;
}
//-----------------------------------------------------------------------------
// Calculate tangent. I'm not sure if the tangent needs to be modified for the
// damage model For now, I don't modify it.
tens4ds FEDamageNeoHookean::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
double detF = pt.m_J;
// lame parameters
double lam = m_v*m_E/((1+m_v)*(1-2*m_v));
double mu = 0.5*m_E/(1+m_v);
double lam1 = lam / detF;
double mu1 = (mu - lam*log(detF)) / detF;
double D[6][6] = {0};
D[0][0] = lam1+2.*mu1; D[0][1] = lam1 ; D[0][2] = lam1 ;
D[1][0] = lam1 ; D[1][1] = lam1+2.*mu1; D[1][2] = lam1 ;
D[2][0] = lam1 ; D[2][1] = lam1 ; D[2][2] = lam1+2.*mu1;
D[3][3] = mu1;
D[4][4] = mu1;
D[5][5] = mu1;
double g = Damage(mp);
return tens4ds(D)*g;
}
//-----------------------------------------------------------------------------
//! calculate strain energy density at material point
double FEDamageNeoHookean::StrainEnergyDensity(FEMaterialPoint& mp)
{
// --- A. Calculate neo-Hookean strain energy density ----
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
double lnJ = log(J);
// calculate left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
double I1 = b.tr();
double sed = m_mu*(0.5*(I1-3) - lnJ) + 0.5*m_lam*lnJ*lnJ;
// --- B. Calculate the damage reduction factor ---
double g = Damage(mp);
return sed*g;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEBioMech.cpp | .cpp | 2,184 | 49 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEBioMech.h"
#include <assert.h>
//-----------------------------------------------------------------------------
const char* FEBioMech::GetVariableName(FEBioMech::MECH_VARIABLE var)
{
switch (var)
{
case DISPLACEMENT : return "displacement" ; break;
case ROTATION : return "rotation" ; break;
case RIGID_ROTATION : return "rigid rotation" ; break;
case SHELL_DISPLACEMENT : return "shell displacement" ; break;
case VELOCITY : return "velocity" ; break;
case SHELL_VELOCITY : return "shell velocity" ; break;
case SHELL_ACCELERATION : return "shell acceleration" ; break;
case BEAM_ANGULAR_VELOCITY : return "vorticity" ; break;
case BEAM_ANGULAR_ACCELERATION: return "angular acceleration"; break;
}
assert(false);
return nullptr;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEGenericHyperelastic.h | .h | 2,450 | 73 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
#include <FECore/MathObject.h>
//! Hyperelastic material, defined by strain energy function.
//! This case only considers the strain energy function to be a function of
//! the invariants: I1, I2, J. Furthermore, it assumes that the
//! strain energy function is defined by W(C) = W1(I1,I2) + WJ(J), where
//! W1 only depends on I1 and I2, and WJ only depends on J.
class FEGenericHyperelastic : public FEElasticMaterial
{
public:
FEGenericHyperelastic(FEModel* fem);
bool Init() override;
// serialization
void Serialize(DumpStream& ar) override;
mat3ds Stress(FEMaterialPoint& mp) override;
tens4ds Tangent(FEMaterialPoint& mp) override;
double StrainEnergyDensity(FEMaterialPoint& mp) override;
private:
bool BuildMathExpressions();
private:
std::string m_exp;
private:
MSimpleExpression m_W; // strain-energy function
vector<double*> m_param; // user parameters
// strain energy derivatives
MSimpleExpression m_W1;
MSimpleExpression m_W2;
MSimpleExpression m_WJ;
MSimpleExpression m_W11;
MSimpleExpression m_W12;
MSimpleExpression m_W22;
MSimpleExpression m_WJJ;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidSpring.cpp | .cpp | 8,918 | 309 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FERigidSpring.h"
#include "FERigidBody.h"
#include "FECore/log.h"
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidSpring, FERigidConnector);
ADD_PARAMETER(m_k , "k" );
ADD_PARAMETER(m_a0 , "insertion_a");
ADD_PARAMETER(m_b0 , "insertion_b");
ADD_PARAMETER(m_L0 , "free_length");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidSpring::FERigidSpring(FEModel* pfem) : FERigidConnector(pfem)
{
m_nID = m_ncount++;
m_L0 = 0;
m_k = 1.0;
}
//-----------------------------------------------------------------------------
//! TODO: This function is called twice: once in the Init and once in the Solve
//! phase. Is that necessary?
bool FERigidSpring::Init()
{
// base class first
if (FERigidConnector::Init() == false) return false;
// reset force
m_F = vec3d(0,0,0);
// if not specified by use, get free length of spring
if (m_L0 == 0) m_L0 = (m_b0 - m_a0).norm();
// set spring insertions relative to rigid body center of mass
m_qa0 = m_a0 - m_rbA->m_r0;
m_qb0 = m_b0 - m_rbB->m_r0;
m_at = m_a0;
m_bt = m_b0;
return true;
}
//-----------------------------------------------------------------------------
void FERigidSpring::Serialize(DumpStream& ar)
{
FERigidConnector::Serialize(ar);
ar & m_qa0 & m_qb0;
ar & m_L0 & m_k;
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidSpring::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
vector<double> fa(6);
vector<double> fb(6);
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
double alpha = tp.alphaf;
// body A
quatd Qat = RBa.GetRotation();
quatd Qap = RBa.m_qp;
vec3d ra = RBa.m_rt*alpha + RBa.m_rp*(1-alpha);
vec3d zat = Qat*m_qa0;
vec3d zap = Qap*m_qa0;
vec3d za = zat*alpha + zap*(1-alpha);
// body b
quatd Qbt = RBb.GetRotation();
quatd Qbp = RBb.m_qp;
vec3d rb = RBb.m_rt*alpha + RBb.m_rp*(1-alpha);
vec3d zbt = Qbt*m_qb0;
vec3d zbp = Qbp*m_qb0;
vec3d zb = zbt*alpha + zbp*(1-alpha);
vec3d c = rb + zb - ra - za;
double L = c.norm();
m_F = (L > 0) ? c*((1 - m_L0/L)*m_k) : c*m_k;
fa[0] = m_F.x;
fa[1] = m_F.y;
fa[2] = m_F.z;
fa[3] = za.y*m_F.z-za.z*m_F.y;
fa[4] = za.z*m_F.x-za.x*m_F.z;
fa[5] = za.x*m_F.y-za.y*m_F.x;
fb[0] = -m_F.x;
fb[1] = -m_F.y;
fb[2] = -m_F.z;
fb[3] = -zb.y*m_F.z+zb.z*m_F.y;
fb[4] = -zb.z*m_F.x+zb.x*m_F.z;
fb[5] = -zb.x*m_F.y+zb.y*m_F.x;
for (int i=0; i<6; ++i) if (RBa.m_LM[i] >= 0) R[RBa.m_LM[i]] += fa[i];
for (int i=0; i<6; ++i) if (RBb.m_LM[i] >= 0) R[RBb.m_LM[i]] += fb[i];
RBa.m_Fr -= vec3d(fa[0],fa[1],fa[2]);
RBa.m_Mr -= vec3d(fa[3],fa[4],fa[5]);
RBb.m_Fr -= vec3d(fb[0],fb[1],fb[2]);
RBb.m_Mr -= vec3d(fb[3],fb[4],fb[5]);
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidSpring::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
double alpha = tp.alphaf;
vector<int> LM(12);
FEElementMatrix ke(12,12);
ke.zero();
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// body A
quatd Qat = RBa.GetRotation();
quatd Qap = RBa.m_qp;
vec3d rat = RBa.m_rt;
vec3d rap = RBa.m_rp;
vec3d ra = RBa.m_rt*alpha + RBa.m_rp*(1-alpha);
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
vec3d za = zat*alpha + zap*(1-alpha);
mat3d zahat; zahat.skew(za);
mat3d zathat; zathat.skew(zat);
// body b
quatd Qbt = RBb.GetRotation();
quatd Qbp = RBb.m_qp;
vec3d rbt = RBb.m_rt;
vec3d rbp = RBb.m_rp;
vec3d rb = RBb.m_rt*alpha + RBb.m_rp*(1-alpha);
vec3d zbt = m_qb0; RBb.GetRotation().RotateVector(zbt);
vec3d zbp = m_qb0; RBb.m_qp.RotateVector(zbp);
vec3d zb = zbt*alpha + zbp*(1-alpha);
mat3d zbhat; zbhat.skew(zb);
mat3d zbthat; zbthat.skew(zbt);
vec3d c = rb + zb - ra - za;
double L = c.norm();
vec3d n = c/L;
m_F = (L > 0) ? c*((1 - m_L0/L)*m_k) : c*m_k;
mat3ds P;
mat3dd I(1);
P = (L > 0) ? I*(1 - m_L0/L) + dyad(n)*(m_L0/L) : I;
mat3da Fhat(m_F);
mat3d K;
// row 0
ke.set(0, 0, P * (m_k));
ke.set(0, 3, P * zathat * (-m_k));
ke.set(0, 6, P * (-m_k));
ke.set(0, 9, P * zbthat * (m_k));
// row 1
ke.set(3, 0, (zahat * P) * (m_k));
ke.set(3, 3, (zahat * P * zathat) * (-m_k) + (Fhat * zathat) * (-1.0));
ke.set(3, 6, (zahat * P) * (- m_k));
ke.set(3, 9, (zahat * P * zbthat) * (m_k));
// row 2
ke.set(6, 0, P * (-m_k));
ke.set(6, 3, P * zathat * (m_k));
ke.set(6, 6, P * (m_k));
ke.set(6, 9, P * zbthat * (-m_k));
// row 3
ke.set(9, 0, (zbhat * P)* (-m_k));
ke.set(9, 3, (zbhat * P * zathat) * (m_k));
ke.set(9, 6, (zbhat * P)* (m_k));
ke.set(9, 9, (zbhat * P * zbthat) * (-m_k) + (Fhat * zbthat));
if (alpha != 1) ke *= alpha;
for (int j=0; j<6; ++j)
{
LM[j ] = RBa.m_LM[j];
LM[j+6] = RBb.m_LM[j];
}
ke.SetIndices(LM);
LS.Assemble(ke);
}
//-----------------------------------------------------------------------------
bool FERigidSpring::Augment(int naug, const FETimeInfo& tp)
{
return true;
}
//-----------------------------------------------------------------------------
void FERigidSpring::Update()
{
vec3d ra, rb, c;
vec3d za, zb;
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
const FETimeInfo& tp = GetTimeInfo();
double alpha = tp.alphaf;
ra = RBa.m_rt*alpha + RBa.m_rp*(1-alpha);
rb = RBb.m_rt*alpha + RBb.m_rp*(1-alpha);
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
za = zat*alpha + zap*(1-alpha);
vec3d zbt = m_qb0; RBb.GetRotation().RotateVector(zbt);
vec3d zbp = m_qb0; RBb.m_qp.RotateVector(zbp);
zb = zbt*alpha + zbp*(1-alpha);
m_at = RBa.m_rt + zat;
m_bt = RBb.m_rt + zbt;
c = rb + zb - ra - za;
double L = c.norm();
m_F = (L > 0) ? c*((1 - m_L0/L)*m_k) : c*m_k;
}
//-----------------------------------------------------------------------------
void FERigidSpring::Reset()
{
m_F = vec3d(0,0,0);
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
m_qa0 = m_a0 - RBa.m_r0;
m_qb0 = m_b0 - RBb.m_r0;
}
//-----------------------------------------------------------------------------
vec3d FERigidSpring::RelativeTranslation(const bool global)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// body A
vec3d ra = RBa.m_rt;
vec3d za = m_qa0; RBa.GetRotation().RotateVector(za);
// body B
vec3d rb = RBb.m_rt;
vec3d zb = m_qb0; RBb.GetRotation().RotateVector(zb);
// relative translation in global coordinate system
vec3d x = rb + zb - ra - za;
if (global) return x;
vec3d y = vec3d(1,0,0)*x.norm();
return y;
}
//-----------------------------------------------------------------------------
vec3d FERigidSpring::RelativeRotation(const bool global)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// get relative rotation
quatd Q = RBb.GetRotation()*RBa.GetRotation().Inverse(); Q.MakeUnit();
// relative rotation vector
vec3d q = Q.GetRotationVector();
return q;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberEntropyChain.cpp | .cpp | 13,876 | 293 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2019 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEFiberEntropyChain.h"
#include <iostream>
#include "triangle_sphere.h"
#include <limits>
#include <FECore/log.h>
//-----------------------------------------------------------------------------
// FEFiberEntropyChain
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberEntropyChain, FEFiberMaterial)
ADD_PARAMETER(m_N , FE_RANGE_GREATER_OR_EQUAL(0.0), "N");
ADD_PARAMETER(m_ksi, FE_RANGE_GREATER_OR_EQUAL(0.0), "ksi")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_mu , FE_RANGE_GREATER_OR_EQUAL(0.0), "mu" )->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_term, FE_RANGE_CLOSED(3,30), "n_term");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFiberEntropyChain::FEFiberEntropyChain(FEModel* pfem) : FEFiberMaterial(pfem)
{
m_mu = 0;
m_term = 30;
m_epsf = 1.0;
}
//-----------------------------------------------------------------------------
bool FEFiberEntropyChain::Validate()
{
return FEFiberMaterial::Validate();
}
//-----------------------------------------------------------------------------
mat3ds FEFiberEntropyChain::FiberStress(FEMaterialPoint& mp, const vec3d& n0)
{
double ksi = m_ksi(mp);
double mu = m_mu(mp);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
mat3ds s;
const double f_a[] = { 3.0, 9.0 / 5.0, 297.0 / 175.0, 1539.0 / 875.0, 126117.0 / 67373.0, 43733439.0 / 21896875.0, \
231321177.0 / 109484375.0, 20495009043.0 / 9306171875.0, 1073585186448381.0 / 476522530859375.0, 4387445039583.0 / 1944989921875.0, \
1000263375846831627.0 / 453346207767578125.0, 280865021365240713.0 / 133337119931640625.0, 148014872740758343473.0 / 75350125192138671875.0, 137372931237386537808993.0 / 76480377070020751953125.0, \
41722474198742657618857192737.0 / 25674386102028896409912109375.0, 12348948373636682700768301125723.0 / 8344175483159391333221435546875.0, 5001286000741585238340074032091091.0 / 3590449627018291035442047119140625.0, \
185364329915163811141785118512534489.0 / 132846636199676768311355743408203125.0, 6292216384025878939310787532157558451.0 / 4160197291516193533960877227783203125.0, 299869254759556271677902570230858640837.0 / 170568088952163934892395966339111328125.0, \
316689568216860631885141475537178451746044283.0 / 148810301691076651811854156590061187744140625.0, 670194310437429598283653289122392937145371137.0 / 258140319260030926612400067554187774658203125.0, 19697015384373759058671314622426656486031717197919.0 / 6332687088594936951180328352888571262359619140625.0, \
178793788985653424246012689916144867915861856840849.0 / 49756827124674504616416865629838774204254150390625.0, 323844166067349737493036492206152479344269351967043143667.0 / 82039106319990447886052744467343800746748447418212890625.0, 200808116689754604893460969866238617668631975356485302537199.0 / 49409916306357883385918130190559334540655314922332763671875.0, \
27506481209689719715275759452624078040221544551995885750037973.0 / 7164437864421893090958128877631103508395020663738250732421875.0, 16356939619211770477227805130221533318985185730316048281126247721.0 / 5122573073061653560035062147506239008502439774572849273681640625.0, 30976199222209837888906735596203249520053107250807132769871859115868101.0 / 14801698741072505317694781203956860833766632412399612367153167724609375.0, \
519588001407316958447129785511020819131555326399179970047767492196701159.0 / 902903623205422824379381653441368510859764577156376354396343231201171875.0 };
// fiber direction in global coordinate system
//vec3d n0 = GetFiberVector(mp);
// Calculate In = n0*C*n0
double In = n0*(C*n0);
// only take fibers in tension into consideration
const double eps = m_epsf * std::numeric_limits<double>::epsilon();
if ((In - 1.0) > eps)
{
// define the distribution
double R, Ra = 0.0;
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
// calculate strain energy derivative
//double alpha = sqrt(In) / sqrt(m_N);
double alpha = sqrt(In) / sqrt(m_N);
double alpha0 = 1 / sqrt(m_N);
double alphaI = 1 / sqrt(In) / (2.0 * sqrt(m_N));
///////////////////////////////////////////////////////////////////////////////////////
double beta = 0, beta0 = 0, alpha2 = alpha * alpha, alpha02 = alpha0 * alpha0;
int num_fa = sizeof(f_a) / sizeof(f_a[0]);
if (m_term > num_fa) {
m_term = num_fa;
}
beta = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha2;
beta0 = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha02;
for (int i = 2; i < m_term; i++) {
beta = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha2 * beta;
beta0 = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha02 * beta0;
//cout << num_fa - i << endl;
};
beta = f_a[0] * alpha * beta;
beta0 = f_a[0] * alpha0 * beta0;
////////////////////////////////////////////////////////////////////////////////////////////
double Wl = ksi * m_N * alphaI * beta - ksi*sqrt(m_N) / 2 * beta0;
// calculate the fiber stress
s = N*(2.0*Wl / J);
//cout << n0.x << " " << n0.y << " " << n0.z << endl;
// add the contribution from shear
if (mu != 0.0)
{
mat3ds BmI = pt.LeftCauchyGreen() - mat3dd(1);
s += (N*BmI).sym()*(mu / J);
}
}
else
{
s.zero();
}
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEFiberEntropyChain::FiberTangent(FEMaterialPoint& mp, const vec3d& n0)
{
double ksi = m_ksi(mp);
double mu = m_mu(mp);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
mat3ds C = pt.RightCauchyGreen();
tens4ds c;
// fiber direction in global coordinate system
//vec3d n0 = GetFiberVector(mp);
// Calculate In = n0*C*n0
double In = n0*(C*n0);
// only take fibers in tension into consideration
const double eps = m_epsf * std::numeric_limits<double>::epsilon();
if ((In - 1.0) > eps)
{
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
tens4ds NxN = dyad1s(N);
// calculate strain energy 2nd derivative
const double f_a[] = { 3.0, 9.0 / 5.0, 297.0 / 175.0, 1539.0 / 875.0, 126117.0 / 67373.0, 43733439.0 / 21896875.0, \
231321177.0 / 109484375.0, 20495009043.0 / 9306171875.0, 1073585186448381.0 / 476522530859375.0, 4387445039583.0 / 1944989921875.0, \
1000263375846831627.0 / 453346207767578125.0, 280865021365240713.0 / 133337119931640625.0, 148014872740758343473.0 / 75350125192138671875.0, 137372931237386537808993.0 / 76480377070020751953125.0, \
41722474198742657618857192737.0 / 25674386102028896409912109375.0, 12348948373636682700768301125723.0 / 8344175483159391333221435546875.0, 5001286000741585238340074032091091.0 / 3590449627018291035442047119140625.0, \
185364329915163811141785118512534489.0 / 132846636199676768311355743408203125.0, 6292216384025878939310787532157558451.0 / 4160197291516193533960877227783203125.0, 299869254759556271677902570230858640837.0 / 170568088952163934892395966339111328125.0, \
316689568216860631885141475537178451746044283.0 / 148810301691076651811854156590061187744140625.0, 670194310437429598283653289122392937145371137.0 / 258140319260030926612400067554187774658203125.0, 19697015384373759058671314622426656486031717197919.0 / 6332687088594936951180328352888571262359619140625.0, \
178793788985653424246012689916144867915861856840849.0 / 49756827124674504616416865629838774204254150390625.0, 323844166067349737493036492206152479344269351967043143667.0 / 82039106319990447886052744467343800746748447418212890625.0, 200808116689754604893460969866238617668631975356485302537199.0 / 49409916306357883385918130190559334540655314922332763671875.0, \
27506481209689719715275759452624078040221544551995885750037973.0 / 7164437864421893090958128877631103508395020663738250732421875.0, 16356939619211770477227805130221533318985185730316048281126247721.0 / 5122573073061653560035062147506239008502439774572849273681640625.0, 30976199222209837888906735596203249520053107250807132769871859115868101.0 / 14801698741072505317694781203956860833766632412399612367153167724609375.0, \
519588001407316958447129785511020819131555326399179970047767492196701159.0 / 902903623205422824379381653441368510859764577156376354396343231201171875.0 };
double alpha = sqrt(In) / sqrt(m_N);
double alpha0 = 1 / sqrt(m_N);
double alphaI = 1.0 / sqrt(In) / (2.0 * sqrt(m_N));
double alphaII = -pow(In, (-3.0 / 2.0)) / (4.0 * sqrt(m_N));
/////////////////////////////////////////////////////////////////////////////////
double beta = 0, beta0 = 0, beta_alpha = 0, alpha2 = alpha * alpha, alpha02 = alpha0 * alpha0;
int num_fa = sizeof(f_a) / sizeof(f_a[0]);
if (m_term > num_fa) {
m_term = num_fa;
}
beta = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha2;
beta0 = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha02;
beta_alpha = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha2 * (2 * m_term - 1) / (2 * m_term - 3);
for (int i = 2; i < m_term; i++) {
beta = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha2 * beta;
beta0 = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha02 * beta0;
beta_alpha = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha2 * beta_alpha * (2 * m_term - 2 * i + 1) / (2 * m_term - 2 * i - 1);
};
beta = f_a[0] * alpha * beta;
beta0 = f_a[0] * alpha0 * beta0;
beta_alpha = f_a[0] * beta_alpha;
//////////////////////////////////////////////////////////////////////////////////////
double Wll = ksi * m_N * (beta_alpha*alphaI*alphaI + beta*alphaII);;
// calculate the fiber tangent
c = NxN*(4.0*Wll / J);
// add the contribution from shear
if (mu != 0.0)
{
mat3ds B = pt.LeftCauchyGreen();
c += dyad4s(N,B)*(mu/J);
}
}
else
{
c.zero();
}
return c;
}
//-----------------------------------------------------------------------------
//! Strain energy density
double FEFiberEntropyChain::FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0)
{
double ksi = m_ksi(mp);
double mu = m_mu(mp);
double sed = 0.0;
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
mat3ds C2 = C.sqr();
// fiber direction in global coordinate system
//vec3d n0 = GetFiberVector(mp);
// Calculate In = n0*C*n0
double In = n0*(C*n0);
// only take fibers in tension into consideration
const double eps = m_epsf * std::numeric_limits<double>::epsilon();
if ((In - 1.0) > eps)
{
// calculate strain energy density
double alpha = sqrt(In) / sqrt(m_N);
double beta = alpha * (3.0 - alpha * alpha) / (1.0 - alpha * alpha) - 0.5 * pow(alpha, (10.0 / 3.0)) + 3.0 * pow(alpha, 5.0)*(alpha - 0.76)*(alpha - 1.0);
double alpha0 = 1 / sqrt(m_N);
double beta0 = alpha0 * (3.0 - alpha0 * alpha0) / (1.0 - alpha0 * alpha0) - 0.5 * pow(alpha0, (10.0 / 3.0)) + 3.0 * pow(alpha0, 5.0)*(alpha0 - 0.76)*(alpha0 - 1.0);
double alpha00 = ksi* sqrt(m_N) / 2 * beta0 + ksi*m_N*log(beta0 / sinh(beta0));
sed = ksi*m_N * (alpha*beta + log(beta / (sinh(beta)))) - ksi*sqrt(m_N)/2 * beta0 * In - alpha00;
// add the contribution from shear
sed += mu*(n0*(C2*n0)-2.0*(In-1.0)-1.0)/4.0;
}
else
{
sed = 0;
}
return sed;
}
//-----------------------------------------------------------------------------
// FEElasticFiberEntropyChain
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEElasticFiberEntropyChain, FEElasticFiberMaterial)
ADD_PARAMETER(m_fib.m_N , FE_RANGE_GREATER_OR_EQUAL(0.0), "N");
ADD_PARAMETER(m_fib.m_ksi, FE_RANGE_GREATER_OR_EQUAL(0.0), "ksi")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_fib.m_mu , FE_RANGE_GREATER_OR_EQUAL(0.0), "mu" )->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_fib.m_term, FE_RANGE_GREATER_OR_EQUAL(3), "n_term");
END_FECORE_CLASS();
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationGaussKronrod.cpp | .cpp | 7,109 | 281 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include <limits>
#include "FEFiberIntegrationGaussKronrod.h"
#include "gausskronrod.h"
#include <FECore/log.h>
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
class FEFiberIntegrationGaussKronrod::Iterator : public FEFiberIntegrationSchemeIterator
{
public:
Iterator(FEMaterialPoint* mp, FEFiberIntegrationGaussKronrod::GKRULE& rule)
{
m_ncase = -1;
m_nth = rule.m_nth;
m_nph = rule.m_nph;
m_gp = rule.m_gp;
m_gw = rule.m_gw;
const double eps = std::numeric_limits<double>::epsilon();
if (mp)
{
FEElasticMaterialPoint& pt = *mp->ExtractData<FEElasticMaterialPoint>();
// right Cauchy-Green tensor and its eigenvalues & eigenvectors
// TODO: for uncoupled formulations we need to use the deviatoric strain-energy
mat3ds C = (pt.m_buncoupled? pt.DevRightCauchyGreen() : pt.RightCauchyGreen());
mat3ds E = (C - mat3dd(1)) * 0.5;
E.eigen2(lE, vE);//lE[2]>lE[1]>lE[0]
// check if there is no tension
if (lE[2] <= 0) return;
// check the other case
if (lE[0] >= 0) m_ncase = 0;
else if (lE[1] <= eps) m_ncase = 1;
else m_ncase = 2;
}
else
{
m_ncase = 0;
vE[0] = vec3d(1,0,0);
vE[1] = vec3d(0,1,0);
vE[2] = vec3d(0,0,1);
}
// initialize theta increment
double pi = 4 * atan(1.0);
dth = 2 * pi / m_nth;
// tension along all three eigenvectors (all directions)
if (m_ncase == 0)
{
ksia = 0;
ksib = 1;
dksi = (ksib - ksia) / 2;
sksi = (ksib + ksia) / 2;
}
// tension along one eigenvector and compression along other two// TC case
else if (m_ncase == 1)
{
// nothing to do
// ksia, ksib are calculated in FiberVector
}
// tension along two eigenvectors and compression along third
else
{
// swap first and last eigenvalues/eigenvectors to maintain consistency in formulas
double ltmp = lE[2]; vec3d vtmp = vE[2];
lE[2] = lE[0]; vE[2] = vE[0];
lE[0] = ltmp; vE[0] = vtmp;
}
i = 0; j = -1;
i_old = -1;
cth = 1.0; sth = 0.0;
Next();
}
bool IsValid()
{
return (m_ncase != -1);
}
// move to the next integration point
bool Next()
{
// check if the iterator is valid
if (m_ncase == -1) return false;
// update loop counters
j++;
if (j>=m_nph)
{
j = 0;
i++;
if (i >= m_nth)
{
// all done
m_ncase = -1;
return false;
}
}
// update vector
if (i_old != i)
{
double theta = i*dth;
cth = cos(theta);
sth = sin(theta);
if (m_ncase == 1)
{
double nu = -lE[0] * SQR(cth) - lE[1] * SQR(sth);
if (nu<0) nu = 0;
double de = lE[2] - lE[0] * SQR(cth) - lE[1] * SQR(sth);
if (de <= 0) ksia = 1;
else ksia = sqrt(nu) / sqrt(de);
ksib = 1;
dksi = (ksib - ksia) / 2;
sksi = (ksib + ksia) / 2;
}
else if (m_ncase == 2)
{
ksia = 0;
double nu = lE[0] * SQR(cth) + lE[1] * SQR(sth);
if (nu<0) nu = 0;
double de = lE[0] * SQR(cth) + lE[1] * SQR(sth) - lE[2];
if (de <= 0) ksib = 0;
else ksib = sqrt(nu) / sqrt(de);
dksi = (ksib - ksia) / 2;
sksi = (ksib + ksia) / 2;
}
}
double ksi = sksi + dksi*m_gp[j];
double sph = sqrt(1.0 - ksi*ksi); // = sin(acos(ksi));
m_fiber = vE[0] * (cth*sph) + vE[1] * (sth*sph) + vE[2] * ksi;
// we multiply by two to add contribution from other half-sphere
m_weight = (m_gw[j] * dth*dksi)*2.0;
i_old = i;
return true;
}
public:
int m_ncase;
int m_nth, m_nph;
double lE[3];
vec3d vE[3];
int i, j, i_old; // loop iterators
double dth;
double cth, sth;
double ksia, ksib, dksi, sksi;
const double* m_gp;
const double* m_gw;
};
//-----------------------------------------------------------------------------
// FEFiberIntegrationGaussKronrod
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberIntegrationGaussKronrod, FEFiberIntegrationScheme)
ADD_PARAMETER(m_rule.m_nph, "nph");
ADD_PARAMETER(m_rule.m_nth, "nth");
END_FECORE_CLASS();
FEFiberIntegrationGaussKronrod::FEFiberIntegrationGaussKronrod(FEModel* pfem) : FEFiberIntegrationScheme(pfem)
{
m_rule.m_nph = 7;
m_rule.m_nth = 31;
}
//-----------------------------------------------------------------------------
FEFiberIntegrationGaussKronrod::~FEFiberIntegrationGaussKronrod()
{
}
//-----------------------------------------------------------------------------
void FEFiberIntegrationGaussKronrod::Serialize(DumpStream& ar)
{
FEFiberIntegrationScheme::Serialize(ar);
if ((ar.IsShallow() == false) && (ar.IsSaving() == false))
{
InitRule();
}
}
//-----------------------------------------------------------------------------
bool FEFiberIntegrationGaussKronrod::Init()
{
if (m_rule.m_nth < 1) {
feLogError("nth must be strictly greater than zero."); return false;
}
// initialize the rule
if (InitRule() == false) {
feLogError("nph must be 7, 11, 15, 19, 23, or 27."); return false;
}
// also initialize the parent class
return FEFiberIntegrationScheme::Init();
}
//-----------------------------------------------------------------------------
bool FEFiberIntegrationGaussKronrod::InitRule()
{
switch (m_rule.m_nph) {
case 7:
m_rule.m_gp = gp7;
m_rule.m_gw = gw7;
break;
case 11:
m_rule.m_gp = gp11;
m_rule.m_gw = gw11;
break;
case 15:
m_rule.m_gp = gp15;
m_rule.m_gw = gw15;
break;
case 19:
m_rule.m_gp = gp19;
m_rule.m_gw = gw19;
break;
case 23:
m_rule.m_gp = gp23;
m_rule.m_gw = gw23;
break;
case 27:
m_rule.m_gp = gp27;
m_rule.m_gw = gw27;
break;
default:
return false;
break;
}
return true;
}
//-----------------------------------------------------------------------------
FEFiberIntegrationSchemeIterator* FEFiberIntegrationGaussKronrod::GetIterator(FEMaterialPoint* mp)
{
// create a new iterator
return new Iterator(mp, m_rule);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledMaterial.cpp | .cpp | 6,075 | 161 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEUncoupledMaterial.h"
#include <FECore/log.h>
//-----------------------------------------------------------------------------
// Material parameters for FEUncoupledMaterial
BEGIN_FECORE_CLASS(FEUncoupledMaterial, FEElasticMaterial)
ADD_PARAMETER(m_K , FE_RANGE_GREATER_OR_EQUAL(0.0), "k")->setUnits(UNIT_PRESSURE)->MakeTopLevel(true)->setLongName("bulk modulus");
ADD_PARAMETER(m_npmodel, "pressure_model")->setEnums("default\0NIKE3D\0Abaqus\0Abaqus (GOH)\0")->MakeTopLevel(true);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! constructor
FEUncoupledMaterial::FEUncoupledMaterial(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_K = 0; // invalid value!
m_npmodel = 0;
}
//-----------------------------------------------------------------------------
bool FEUncoupledMaterial::Init()
{
// K has to be non-zero if this is a top-level material, otherwise
// it should be zero.
FECoreBase* parent = GetParent();
FEUncoupledMaterial* parentMat = dynamic_cast<FEUncoupledMaterial*>(GetParent());
if (parentMat)
{
if (m_K != 0.0)
{
feLogWarning("K should only be defined at the top-level.\nValue will be ignored.");
// NOTE: This should not be neccessary, but just to be safe.
m_K = 0.0;
}
}
else
{
if (m_K <= 0.0)
{
feLogError("K must be a positive number.");
return false;
}
}
return FEElasticMaterial::Init();
}
//-----------------------------------------------------------------------------
//! The stress function calculates the total Cauchy stress as a sum of
//! two terms, namely the deviatoric stress and the pressure.
mat3ds FEUncoupledMaterial::Stress(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate the stress as a sum of deviatoric stress and pressure
pt.m_p = UJ(pt.m_J);
return mat3dd(pt.m_p) + DevStress(mp);
}
//------------------------------------------------------------------------------
//! The tangent function calculates the total spatial tangent, that is it calculates
//! the push-forward of the derivative of the 2ndPK stress with respect to C. However,
//! for an uncoupled material, the 2ndPK stress decouples in a deviatoric and a
//! dilatational component. The deviatoric tangent is provided by the particular
//! material and the dilatational component is added here.
//!
tens4ds FEUncoupledMaterial::Tangent(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// 2nd-order identity tensor
mat3dd I(1);
// 4th-order identity tensors
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
// pressure
pt.m_p = UJ(pt.m_J);
// tangent is sum of three terms
// C = c_tilde + c_pressure + c_k
//
// + c_tilde is the derivative of the deviatoric stress with respect to C
// + c_pressure is p*d(JC)/dC
// + c_k comes from the derivative of p with respect to C
//
// Note that the c_k term is not necessary in the 3F formulation (since p is independant variable)
// but we do need to add it here.
//
// c_tilde c_pressure c_k
return DevTangent(mp) + (IxI - I4*2)*pt.m_p + IxI*(UJJ(pt.m_J)*pt.m_J);
}
//-----------------------------------------------------------------------------
//! The strain energy density function calculates the total sed as a sum of
//! two terms, namely the deviatoric sed and U(J).
double FEUncoupledMaterial::StrainEnergyDensity(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate the stress as a sum of deviatoric stress and pressure
return U(pt.m_J) + DevStrainEnergyDensity(mp);
}
//-----------------------------------------------------------------------------
//! The strain energy density function calculates the total sed as a sum of
//! two terms, namely the deviatoric sed and U(J).
double FEUncoupledMaterial::StrongBondSED(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate the stress as a sum of deviatoric stress and pressure
return U(pt.m_J) + StrongBondDevSED(mp);
}
//-----------------------------------------------------------------------------
//! The strain energy density function calculates the total sed as a sum of
//! two terms, namely the deviatoric sed and U(J).
double FEUncoupledMaterial::WeakBondSED(FEMaterialPoint &mp)
{
// calculate the stress as a sum of deviatoric stress and pressure
return WeakBondDevSED(mp);
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEUncoupledMaterial::CreateMaterialPointData()
{
FEElasticMaterialPoint* mp = new FEElasticMaterialPoint;
mp->m_buncoupled = true;
return mp;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FENodeToNodeConstraint.cpp | .cpp | 4,391 | 162 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FENodeToNodeConstraint.h"
#include <FECore/FEMesh.h>
#include <FECore/FELinearSystem.h>
#include <FECore/FEGlobalMatrix.h>
BEGIN_FECORE_CLASS(FENodeToNodeConstraint, FENLConstraint)
ADD_PARAMETER(m_a, FE_RANGE_GREATER(0), "a");
ADD_PARAMETER(m_b, FE_RANGE_GREATER(0), "b");
END_FECORE_CLASS();
FENodeToNodeConstraint::FENodeToNodeConstraint(FEModel* fem) : FENLConstraint(fem)
{
m_a = m_b = -1;
m_Lm = vec3d(0, 0, 0);
m_Lp = vec3d(0, 0, 0);
}
void FENodeToNodeConstraint::Serialize(DumpStream& ar)
{
FENLConstraint::Serialize(ar);
ar & m_a & m_b & m_Lm & m_Lp;
}
// allocate equations
int FENodeToNodeConstraint::InitEquations(int neq)
{
// we allocate three equations
m_LM.resize(3);
m_LM[0] = neq;
m_LM[1] = neq+1;
m_LM[2] = neq+2;
return 3;
}
void FENodeToNodeConstraint::UnpackLM(vector<int>& lm)
{
// get the displacement dofs
int dofX = GetDOFIndex("x");
int dofY = GetDOFIndex("y");
int dofZ = GetDOFIndex("z");
// we need to couple the dofs of node A, B, and the LMs
FEMesh& mesh = GetMesh();
// add the dofs of node A
FENode& node_a = mesh.Node(m_a - 1);
lm.push_back(node_a.m_ID[dofX]);
lm.push_back(node_a.m_ID[dofY]);
lm.push_back(node_a.m_ID[dofZ]);
// add the dofs of node B
FENode& node_b = mesh.Node(m_b - 1);
lm.push_back(node_b.m_ID[dofX]);
lm.push_back(node_b.m_ID[dofY]);
lm.push_back(node_b.m_ID[dofZ]);
// add the LM equations
lm.push_back(m_LM[0]);
lm.push_back(m_LM[1]);
lm.push_back(m_LM[2]);
}
void FENodeToNodeConstraint::PrepStep()
{
m_Lp = m_Lm;
}
void FENodeToNodeConstraint::Update(const std::vector<double>& Ui, const std::vector<double>& ui)
{
m_Lm.x = m_Lp.x + Ui[m_LM[0]] + ui[m_LM[0]];
m_Lm.y = m_Lp.x + Ui[m_LM[1]] + ui[m_LM[1]];
m_Lm.z = m_Lp.x + Ui[m_LM[2]] + ui[m_LM[2]];
}
void FENodeToNodeConstraint::UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui)
{
Ui[m_LM[0]] += ui[m_LM[0]];
Ui[m_LM[1]] += ui[m_LM[1]];
Ui[m_LM[2]] += ui[m_LM[2]];
}
// The LoadVector function evaluates the "forces" that contribute to the residual of the system
void FENodeToNodeConstraint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
FEMesh& mesh = GetMesh();
vec3d ra = mesh.Node(m_a - 1).m_rt;
vec3d rb = mesh.Node(m_b - 1).m_rt;
vec3d c = ra - rb;
vector<double> fe(9, 0.0);
fe[0] = -m_Lm.x;
fe[1] = -m_Lm.y;
fe[2] = -m_Lm.z;
fe[3] = m_Lm.x;
fe[4] = m_Lm.y;
fe[5] = m_Lm.z;
fe[6] = -c.x;
fe[7] = -c.y;
fe[8] = -c.z;
vector<int> lm;
UnpackLM(lm);
R.Assemble(lm, fe);
}
// Evaluates the contriubtion to the stiffness matrix
void FENodeToNodeConstraint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
FEElementMatrix ke(9, 9);
ke.zero();
ke[0][6] = ke[6][0] = 1;
ke[1][7] = ke[7][1] = 1;
ke[2][8] = ke[8][2] = 1;
ke[3][6] = ke[6][3] = -1;
ke[4][7] = ke[7][4] = -1;
ke[5][8] = ke[8][5] = -1;
vector<int> lm;
UnpackLM(lm);
ke.SetIndices(lm);
LS.Assemble(ke);
}
// Build the matrix profile
void FENodeToNodeConstraint::BuildMatrixProfile(FEGlobalMatrix& M)
{
vector<int> lm;
UnpackLM(lm);
// add it to the pile
M.build_add(lm);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationTrapezoidal.h | .h | 2,024 | 55 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEFiberIntegrationScheme.h"
//----------------------------------------------------------------------------------
// Trapezoidal integration scheme for 2D continuous fiber distributions
//
class FEFiberIntegrationTrapezoidal : public FEFiberIntegrationScheme
{
class Iterator;
public:
FEFiberIntegrationTrapezoidal(FEModel* pfem);
~FEFiberIntegrationTrapezoidal();
// get iterator
FEFiberIntegrationSchemeIterator* GetIterator(FEMaterialPoint* mp) override;
// get number of integration points
int IntegrationPoints() const override { return -1; };
private:
int m_nth; // number of trapezoidal integration points along theta
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEEFDUncoupled.cpp | .cpp | 8,966 | 305 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEEFDUncoupled.h"
// The following file contains the integration points and weights
// for the integration over a unit sphere in spherical coordinates
#include "geodesic.h"
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
//-----------------------------------------------------------------------------
// FEEFDUncoupled
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEEFDUncoupled, FEUncoupledMaterial)
ADD_PARAMETER(m_beta, 3, FE_RANGE_GREATER_OR_EQUAL(2.0), "beta");
ADD_PARAMETER(m_ksi , 3, FE_RANGE_GREATER_OR_EQUAL(0.0), "ksi" )->setUnits(UNIT_PRESSURE);
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEEFDUncoupled::FEEFDUncoupled(FEModel* pfem) : FEUncoupledMaterial(pfem) {}
//-----------------------------------------------------------------------------
mat3ds FEEFDUncoupled::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// deviatoric deformation gradient
mat3d F = pt.m_F*pow(J,-1.0/3.0);
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// loop over all integration points
vec3d n0e, n0a, n0q, nt;
double In, Wl;
const double eps = 0;
mat3ds s;
s.zero();
const int li[4][3] = {
{ 1, 1, 1},
{-1, 1, 1},
{-1,-1, 1},
{ 1,-1, 1}
};
double ksi[3] = { m_ksi[0](mp), m_ksi[1](mp), m_ksi[2](mp) };
double beta[3] = { m_beta[0](mp), m_beta[1](mp), m_beta[2](mp) };
const int nint = 45;
for (int n=0; n<nint; ++n)
{
// set the global fiber direction in material coordinate system
n0a.x = XYZ2[n][0];
n0a.y = XYZ2[n][1];
n0a.z = XYZ2[n][2];
double wn = XYZ2[n][3];
// calculate material coefficients
// TODO: There is an obvious optimization opportunity here, since the values of ksi
// and beta can be precalculated and reused. I have not done this yet since I
// need to figure out how to initialize the material parameters for each time
// step (instead of once at the start) in case the values depend on load curves.
double ksi_n = 1.0 / sqrt(SQR(n0a.x / ksi [0]) + SQR(n0a.y / ksi [1]) + SQR(n0a.z / ksi [2]));
double beta_n = 1.0 / sqrt(SQR(n0a.x / beta[0]) + SQR(n0a.y / beta[1]) + SQR(n0a.z / beta[2]));
// loop over the four quadrants
for (int l=0; l<4; ++l)
{
n0q = vec3d(li[l][0]*n0a.x, li[l][1]*n0a.y, li[l][2]*n0a.z);
// rotate to reference configuration
n0e = Q*n0q;
// get the global spatial fiber direction in current configuration
nt = F*n0e;
// Calculate In = n0e*C*n0e
In = nt*nt;
// only take fibers in tension into consideration
if (In > 1. + eps)
{
// calculate the outer product of nt
mat3ds N = dyad(nt);
// calculate strain energy derivative
Wl = beta_n *ksi_n *pow(In - 1.0, beta_n -1.0);
// calculate the stress
s += N*(Wl*wn);
}
}
}
// don't forget to multiply by two to include the other half-sphere
return s.dev()*(4.0/J);
}
//-----------------------------------------------------------------------------
tens4ds FEEFDUncoupled::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// deviatoric deformation gradient
mat3d F = pt.m_F*pow(J,-1.0/3.0);
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// loop over all integration points
vec3d n0e, n0a, nt;
double In, Wl, Wll;
const double eps = 0;
mat3ds s;
tens4ds cf, cfw; cf.zero();
mat3ds N2;
mat3dd I(1);
tens4ds N4;
tens4ds c;
s.zero();
c.zero();
const int li[4][3] = {
{ 1, 1, 1},
{-1, 1, 1},
{-1,-1, 1},
{ 1,-1, 1}
};
double ksi[3] = { m_ksi[0](mp), m_ksi[1](mp), m_ksi[2](mp) };
double beta[3] = { m_beta[0](mp), m_beta[1](mp), m_beta[2](mp) };
const int nint = 45;
for (int n=0; n<nint; ++n)
{
// set the global fiber direction in material coordinate system
n0a.x = XYZ2[n][0];
n0a.y = XYZ2[n][1];
n0a.z = XYZ2[n][2];
double wn = XYZ2[n][3];
// calculate material coefficients
double ksi_n = 1.0 / sqrt(SQR(n0a.x / ksi [0]) + SQR(n0a.y / ksi [1]) + SQR(n0a.z / ksi [2]));
double beta_n = 1.0 / sqrt(SQR(n0a.x / beta[0]) + SQR(n0a.y / beta[1]) + SQR(n0a.z / beta[2]));
for (int l=0; l<4; ++l)
{
vec3d n0q = vec3d(li[l][0]*n0a.x, li[l][1]*n0a.y, li[l][2]*n0a.z);
// rotate to reference configuration
n0e = Q*n0q;
// get the global spatial fiber direction in current configuration
nt = F*n0e;
// Calculate In = n0e*C*n0e
In = nt*nt;
// only take fibers in tension into consideration
if (In > 1. + eps)
{
// calculate strain energy derivative
Wl = beta_n *ksi_n *pow(In - 1.0, beta_n -1.0);
Wll = beta_n *(beta_n -1.0)*ksi_n *pow(In - 1.0, beta_n -2.0);
// calculate the outer product of nt
N2 = dyad(nt);
N4 = dyad1s(N2);
// calculate the stress
s += N2*(2.0/J*Wl*wn);
// calculate tangent
c += N4*(4.0/J*Wll*wn);
}
}
}
// don't forget to multiply by two to include the other half-sphere
s *= 2.0;
c *= 2.0;
// This is the final value of the elasticity tensor
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
c += ((I4+IxI/3.0)*s.tr() - dyad1s(I,s))*(2./3.)
- (ddots(IxI, c)-IxI*(c.tr()/3.))/3.;
return c;
}
//-----------------------------------------------------------------------------
//! calculate deviatoric strain energy density
double FEEFDUncoupled::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
double sed = 0.0;
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// deviatoric deformation gradient
mat3d F = pt.m_F*pow(J,-1.0/3.0);
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// loop over all integration points
vec3d n0e, n0a, n0q, nt;
double In, W;
const double eps = 0;
const int li[4][3] = {
{ 1, 1, 1},
{-1, 1, 1},
{-1,-1, 1},
{ 1,-1, 1}
};
double ksi[3] = { m_ksi[0](mp), m_ksi[1](mp), m_ksi[2](mp) };
double beta[3] = { m_beta[0](mp), m_beta[1](mp), m_beta[2](mp) };
const int nint = 45;
for (int n=0; n<nint; ++n)
{
// set the global fiber direction in material coordinate system
n0a.x = XYZ2[n][0];
n0a.y = XYZ2[n][1];
n0a.z = XYZ2[n][2];
double wn = XYZ2[n][3];
// calculate material coefficients
// TODO: There is an obvious optimization opportunity here, since the values of ksi
// and beta can be precalculated and reused. I have not done this yet since I
// need to figure out how to initialize the material parameters for each time
// step (instead of once at the start) in case the values depend on load curves.
double ksi_n = 1.0 / sqrt(SQR(n0a.x / ksi [0]) + SQR(n0a.y / ksi [1]) + SQR(n0a.z / ksi [2]));
double beta_n = 1.0 / sqrt(SQR(n0a.x / beta[0]) + SQR(n0a.y / beta[1]) + SQR(n0a.z / beta[2]));
// loop over the four quadrants
for (int l=0; l<4; ++l)
{
n0q = vec3d(li[l][0]*n0a.x, li[l][1]*n0a.y, li[l][2]*n0a.z);
// rotate to reference configuration
n0e = Q*n0q;
// get the global spatial fiber direction in current configuration
nt = F*n0e;
// Calculate In = n0e*C*n0e
In = nt*nt;
// only take fibers in tension into consideration
if (In > 1. + eps)
{
// calculate strain energy density
W = ksi_n *pow(In - 1.0, beta_n);
sed += W*wn;
}
}
}
// don't forget to multiply by two to include the other half-sphere
return sed*2.0;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPolynomalHyperElastic.cpp | .cpp | 7,169 | 227 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEPolynomialHyperElastic.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEPolynomialHyperElastic, FEElasticMaterial)
// ADD_PARAMETER(m_c[0][0], "c00"); // should always be zero
ADD_PARAMETER(m_c[0][1], "c01");
ADD_PARAMETER(m_c[0][2], "c02");
ADD_PARAMETER(m_c[1][0], "c10");
ADD_PARAMETER(m_c[1][1], "c11");
ADD_PARAMETER(m_c[1][2], "c12");
ADD_PARAMETER(m_c[2][0], "c20");
ADD_PARAMETER(m_c[2][1], "c21");
ADD_PARAMETER(m_c[2][2], "c22");
ADD_PARAMETER(m_D1, "D1");
ADD_PARAMETER(m_D2, "D2");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPolynomialHyperElastic::FEPolynomialHyperElastic(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_D1 = m_D2 = 0.0;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j) m_c[i][j] = 0.0;
}
//-----------------------------------------------------------------------------
//! Calculate the deviatoric stress
mat3ds FEPolynomialHyperElastic::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// determinant of deformation gradient
double J = pt.m_J;
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
double I1 = B.tr();
double I2 = 0.5 * (I1 * I1 - B2.tr());
// get material parameters
double c[3][3] = { 0 };
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
c[i][j] = m_c[i][j](mp);
c[0][0] = 0.0;
// --- put strain energy derivatives here ---
// Wi = dW/dIi
double I1p1 = I1 - 3.0;
double I1p2 = I1p1 * I1p1;
double I2p1 = I2 - 3.0;
double I2p2 = I2p1 * I2p1;
double W1 = c[1][0] + c[1][1] * I2p1 + c[1][2] * I2p2 + 2.0 * I1p1 * (c[2][0] + c[2][1] * I2p1 + c[2][2] * I2p2);
double W2 = c[0][1] + c[1][1] * I1p1 + c[2][1] * I1p2 + 2.0 * I2p1 * (c[0][2] + c[1][2] * I1p1 + c[2][2] * I1p2);
// ---
// calculate T = F*dW/dC*Ft
// T = F*dW/dC*Ft
mat3ds T = B * (W1 + W2 * I1) - B2 * W2;
mat3ds devs = T.dev() * (2.0 / J);
pt.m_p = UJ(pt.m_J);
return mat3dd(pt.m_p) + devs;
}
//-----------------------------------------------------------------------------
//! Calculate the deviatoric tangent
tens4ds FEPolynomialHyperElastic::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// determinant of deformation gradient
double J = pt.m_J;
double Ji = 1.0 / J;
// calculate deviatoric left Cauchy-Green tensor: B = F*Ft
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
double I1 = B.tr();
double I2 = 0.5 * (I1 * I1 - B2.tr());
// get material parameters
double c[3][3] = { 0 };
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
c[i][j] = m_c[i][j](mp);
c[0][0] = 0.0;
// --- TODO: put strain energy derivatives here ---
// Wi = dW/dIi
double I1p1 = I1 - 3.0;
double I1p2 = I1p1 * I1p1;
double I2p1 = I2 - 3.0;
double I2p2 = I2p1 * I2p1;
double W1 = c[1][0] + c[1][1] * I2p1 + c[1][2] * I2p2 + 2.0 * I1p1 * (c[2][0] + c[2][1] * I2p1 + c[2][2] * I2p2);
double W2 = c[0][1] + c[1][1] * I1p1 + c[2][1] * I1p2 + 2.0 * I2p1 * (c[0][2] + c[1][2] * I1p1 + c[2][2] * I1p2);
double W11 = 2.0 * (c[2][0] + c[2][1] * I2p1 + c[2][2] * I2p2);
double W22 = 2.0 * (c[0][2] + c[1][2] * I1p1 + c[2][2] * I1p2);
double W12 = c[1][1] + 2.0 * c[1][2] * I2p1 + 2.0 * c[2][1] * I1p1 + 4.0 * c[2][2]*I1p1 * I2p1;
double W21 = W12;
// ---
// define some helper constants
double g1 = W11 + 2.0 * W12 * I1 + W22 * I1 * I1 + W2;
double g2 = W12 + I1 * W22;
double I2b = B2.tr();
// calculate dWdC:C
double WC = W1 * I1 + 2 * W2 * I2;
// deviatoric cauchy-stress
mat3ds T = B * (W1 + W2 * I1) - B2 * W2;
mat3ds devs = T.dev() * (2.0 / J);
// Identity tensor
mat3ds I(1, 1, 1, 0, 0, 0);
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxB = dyad1s(B);
tens4ds B2xB2 = dyad1s(B2);
tens4ds B4 = dyad4s(B);
// calculate chat
tens4ds ch = BxB * g1 - dyad1s(B, B2) * g2 + B2xB2 * W22 - B4 * W2;
// calculate I:ch:I
double IchI = W11*I1*I1 + 2.0*W12*I1*I2 + 2.0*W21*I1*I2 + 4.0*W22*I2*I2 + 2.0*W2*I2;
// 1:ch
mat3ds Ich = B * (g1*I1-g2*I2b) + B2 * (W22*I2b - g2*I1 - W2);
tens4ds cw = ch - dyad1s(Ich, I) * (1.0 / 3.0) + IxI * (1.0 / 9.0 * IchI);
tens4ds cs = dyad1s(devs, I)* (-2.0 / 3.0) + (I4 - IxI / 3.0) * (4.0 / 3.0 * Ji * WC);
tens4ds ce = cs + cw*(4.0 * Ji);
return ce + (IxI - I4 * 2) * pt.m_p + IxI * (UJJ(pt.m_J) * pt.m_J);
}
//-----------------------------------------------------------------------------
//! calculate deviatoric strain energy density
double FEPolynomialHyperElastic::StrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get material parameters
double c[3][3] = { 0 };
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
c[i][j] = m_c[i][j](mp);
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
double I1 = B.tr();
double I2 = 0.5 * (I1 * I1 - B2.tr());
double W = 0.0;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
W += c[i][j] * pow(I1 - 3, i) * pow(I2 - 3, j);
return U(pt.m_J) + W;
}
double FEPolynomialHyperElastic::U(double J)
{
return m_D1 * pow(J - 1.0, 2.0) + m_D2 * pow(J - 1.0, 4.0);
}
double FEPolynomialHyperElastic::UJ(double J)
{
return 2.0*m_D1 * (J - 1.0) + 4.0*m_D2 * pow(J - 1.0, 3.0);
}
double FEPolynomialHyperElastic::UJJ(double J)
{
return 2.0*m_D1 + 12.0*m_D2 * pow(J - 1.0, 2.0);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEGentMaterial.h | .h | 2,486 | 75 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FEBioMech/FEElasticMaterial.h>
#include <FEBioMech/FEUncoupledMaterial.h>
//-----------------------------------------------------------------------------
// uncoupled Gent material
class FEGentMaterial : public FEUncoupledMaterial
{
public:
//! constructor
FEGentMaterial(FEModel* pfem);
//! deviatoric Cauchy stress
mat3ds DevStress(FEMaterialPoint& mp) override;
//! Deviatoric spatial Tangent
tens4ds DevTangent(FEMaterialPoint& mp) override;
private: // material parameters
double m_G; //!< shear modulus
double m_Jm; //!< Jm = Im - 3, where Im is max first invariant
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// compressible Gent material
class FECompressibleGentMaterial : public FEElasticMaterial
{
public:
// constructor
FECompressibleGentMaterial(FEModel* pfem);
// Cauchy stress
mat3ds Stress(FEMaterialPoint& mp) override;
// spatial elasticity tangent
tens4ds Tangent(FEMaterialPoint& mp) override;
public: // material parameter
double m_G; //!< shear modulus
double m_K; //!< bulk modulus
double m_Jm; //!< Jm = Im - 3, where Im is max first invariant
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEInitialPreStrain.cpp | .cpp | 3,316 | 114 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEInitialPreStrain.h"
#include <FECore/FEDomain.h>
#include <FECore/FEMesh.h>
#include "FEConstPrestrain.h"
BEGIN_FECORE_CLASS(FEInitialPreStrain, FEInitialCondition)
ADD_PARAMETER(m_binit , "init" );
ADD_PARAMETER(m_breset, "reset");
END_FECORE_CLASS();
FEInitialPreStrain::FEInitialPreStrain(FEModel* pfem) : FEInitialCondition(pfem)
{
m_binit = true;
m_breset = true;
}
void FEInitialPreStrain::Activate()
{
FEInitialCondition::Activate();
FEMesh& mesh = GetMesh();
// loop over all the domains
int ND = mesh.Domains();
for (int i=0; i<ND; ++i)
{
FEDomain& dom = mesh.Domain(i);
// see if this material is the right type
FEPrestrainMaterial* pmat = dynamic_cast<FEPrestrainMaterial*>(dom.GetMaterial());
if (pmat)
{
// get the prestrain gradient
FEPrestrainGradient* Fp = pmat->PrestrainGradientProperty();
if (Fp)
{
// loop over the elements
int NE = dom.Elements();
for (int i=0; i<NE; ++i)
{
FEElement& el = dom.ElementRef(i);
// loop over the integration points
const int nint = el.GaussPoints();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint* pt = mp.ExtractData<FEElasticMaterialPoint>();
FEPrestrainMaterialPoint& pp = *mp.ExtractData<FEPrestrainMaterialPoint>();
// get the deformation gradient
mat3d& F = pt->m_F;
// initialize prestrain material point data
if (m_binit) Fp->Initialize(F, mp);
else
{
mat3d Fc = F*pp.PrestrainCorrection();
pp.setPrestrainCorrection(Fc);
}
// reset deformation gradient
F.unit();
}
}
}
}
}
// reset the nodal coordinates
if (m_breset)
{
int dofX = GetDOFIndex("x");
int dofY = GetDOFIndex("y");
int dofZ = GetDOFIndex("z");
int NN = mesh.Nodes();
for (int i=0; i<NN; ++i)
{
FENode& node = mesh.Node(i);
node.m_r0 = node.m_rt;
node.set(dofX, 0.0);
node.set(dofY, 0.0);
node.set(dofZ, 0.0);
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEMortarInterface.h | .h | 1,967 | 55 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEContactInterface.h"
#include "FEMortarContactSurface.h"
//-----------------------------------------------------------------------------
// Base class for mortar-type contact formulations
class FEMortarInterface : public FEContactInterface
{
public:
//! constructor
FEMortarInterface(FEModel* pfem);
//! update the mortar weights
void UpdateMortarWeights(FESurface& ss, FESurface& ms);
//! update the nodal gaps
void UpdateNodalGaps(FEMortarContactSurface& ss, FEMortarContactSurface& ms);
protected:
matrix m_n1; //!< integration weights n1_AB
matrix m_n2; //!< integration weights n2_AB
private:
// integration rule
FESurfaceElementTraits* m_pT;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FE3FieldElasticShellDomain.h | .h | 3,356 | 99 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticShellDomain.h"
//-----------------------------------------------------------------------------
//! The following domain implements the finite element formulation for a three-field
//! shell element. Results indicate that using this class produces poorer convergence
//! with shells than the standard FEElasticShellDomain. This class is included
//! only for development purposes.
class FEBIOMECH_API FE3FieldElasticShellDomain : public FEElasticShellDomain
{
protected:
struct ELEM_DATA
{
double eJ; // average element jacobian
double ep; // average pressure
double Lk; // Lagrangian multiplier
void Serialize(DumpStream& ar);
};
public:
//! constructor
FE3FieldElasticShellDomain(FEModel* pfem);
//! \todo Is this really used?
FE3FieldElasticShellDomain& operator = (FE3FieldElasticShellDomain& d);
//! initialize class
bool Init() override;
//! Reset data
void Reset() override;
//! augmentation
bool Augment(int naug) override;
//! serialize data to archive
void Serialize(DumpStream& ar) override;
public: // overridden from FEElasticDomain
// update stresses
void Update(const FETimeInfo& tp) override;
// calculate stiffness matrix
void StiffnessMatrix(FELinearSystem& LS) override;
protected:
//! Dilatational stiffness component for nearly-incompressible materials
void ElementDilatationalStiffness(FEModel& fem, int iel, matrix& ke);
//! material and geometrical stiffness components
void ElementStiffness(int iel, matrix& ke);
//! update the stress of an element
void UpdateElementStress(int iel);
public:
bool DoAugmentations() const;
protected:
vector<ELEM_DATA> m_Data;
bool m_blaugon; //!< augmented lagrangian flag
double m_augtol; //!< augmented lagrangian tolerance
int m_naugmin; //!< minimum number of augmentations
int m_naugmax; //!< max number of augmentations
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledFiberExpLinear.cpp | .cpp | 6,324 | 226 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEUncoupledFiberExpLinear.h"
#include <stdlib.h>
#include <limits>
#include <FECore/expint_Ei.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEFiberExpLinearUC, FEFiberMaterialUncoupled);
ADD_PARAMETER(m_c3, FE_RANGE_GREATER_OR_EQUAL(0.0), "c3");
ADD_PARAMETER(m_c4, FE_RANGE_GREATER_OR_EQUAL(0.0), "c4");
ADD_PARAMETER(m_c5, FE_RANGE_GREATER_OR_EQUAL(0.0), "c5");
ADD_PARAMETER(m_lam1, FE_RANGE_GREATER_OR_EQUAL(1.0), "lambda");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFiberExpLinearUC::FEFiberExpLinearUC(FEModel* pfem) : FEFiberMaterialUncoupled(pfem)
{
m_c3 = 0;
m_c4 = 0;
m_c5 = 0;
m_lam1 = 1;
}
//-----------------------------------------------------------------------------
//! Fiber material stress
mat3ds FEFiberExpLinearUC::DevFiberStress(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the deformation gradient
mat3d F = pt.m_F;
double J = pt.m_J;
double Ji = 1.0 / J;
double Jm13 = pow(J, -1.0 / 3.0);
double twoJi = 2.0 * Ji;
// calculate the current material axis lam*a = F*a0;
vec3d a = F * a0;
// normalize material axis and store fiber stretch
double lam = a.unit();
double lamd = lam * Jm13; // i.e. lambda tilde
// invariant I4
double I4 = lamd * lamd;
// calculate stress:
mat3ds s; s.zero();
if (lamd >= 1)
{
double c3 = m_c3(mp);
double c4 = m_c4(mp);
double c5 = m_c5(mp);
double lam1 = m_lam1(mp);
// calculate dyad of a: AxA = (a x a)
mat3ds AxA = dyad(a);
if (c3 == 0) {
c3 = c5 / c4 * exp(-c4 * (lam1 - 1));
}
// calculate fiber stress
double sn = 0.0;
if (lamd < lam1)
{
sn = c3 * (exp(c4 * (lamd - 1.0)) - 1.0);
}
else
{
double c6 = c3 * (exp(c4 * (lam1 - 1)) - 1) - c5 * lam1;
sn = c5 * lamd + c6;
}
mat3ds T = AxA * (sn / J);
s = T.dev();
}
return s;
}
//-----------------------------------------------------------------------------
//! Fiber material tangent
tens4ds FEFiberExpLinearUC::DevFiberTangent(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the deformation gradient
mat3d F = pt.m_F;
double J = pt.m_J;
double Jm13 = pow(J, -1.0 / 3.0);
double Ji = 1.0 / J;
// calculate current local material axis
vec3d a = F * a0;
double lam = a.unit();
// deviatoric stretch
double lamd = lam * Jm13;
double I4 = lamd * lamd;
const double eps = 0;// std::numeric_limits<double>::epsilon();
tens4ds c; c.zero();
if (lamd >= 1 + eps)
{
double c3 = m_c3(mp);
double c4 = m_c4(mp);
double c5 = m_c5(mp);
double lam1 = m_lam1(mp);
mat3dd I(1); // Identity
tens4ds IxI = dyad1s(I);
tens4ds Id4 = dyad4s(I);
mat3ds AxA = dyad(a);
tens4ds AxAxAxA = dyad1s(AxA);
if (c3 == 0) {
c3 = c5 / c4 * exp(-c4 * (lam1 - 1));
}
double sn = 0;
double cn = 0;
if (lamd < lam1) {
sn = c3 * (exp(c4 * (lamd - 1.0)) - 1.0);
cn = c3 * (2 + exp(c4 * (lamd - 1)) * (c4 * lamd - 2));
}
else {
double c6 = c3 * (exp(c4 * (lam1 - 1)) - 1) - c5 * lam1;
sn = c5 * lamd + c6;
cn = -c5 * lamd - 2 * c6;
}
mat3ds T = AxA * (sn / J);
c = AxAxAxA * (cn / J);
c += -1. / 3. * (ddots(c, IxI) - IxI * (c.tr() / 3.))
+ 2. / 3. * ((Id4 - IxI / 3.) * T.tr() - dyad1s(T.dev(), I));
}
return c;
}
//-----------------------------------------------------------------------------
//! Fiber material strain energy density
double FEFiberExpLinearUC::DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the deformation gradient
mat3d F = pt.m_F;
double J = pt.m_J;
double Jm13 = pow(J, -1.0 / 3.0);
// calculate the current material axis lam*a = F*a0;
vec3d a = F * a0;
// normalize material axis and store fiber stretch
double lam, lamd;
lam = a.unit();
lamd = lam * Jm13; // i.e. lambda tilde
// strain energy density
double sed = 0.0;
if (lamd >= 1)
{
double c3 = m_c3(mp);
double c4 = m_c4(mp);
double c5 = m_c5(mp);
double lam1 = m_lam1(mp);
if (c3 == 0) c3 = c5 / c4 * exp(-c4 * (lam1 - 1));
if (lamd < lam1)
{
sed = c3 * exp(-c4) * (expint_Ei(c4 * lamd) - expint_Ei(c4)) - c3 * log(lamd);
}
else
{
double c6 = c3 * (exp(c4 * (lam1 - 1)) - 1) - c5 * lam1;
sed = c5 * (lamd - lam1) + c6 * log(lamd / lam1)
+ c3 * exp(-c4) * (expint_Ei(c4 * lam1) - expint_Ei(c4)) - c3 * log(lam1);
}
}
return sed;
}
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEUncoupledFiberExpLinear, FEElasticFiberMaterialUC);
ADD_PARAMETER(m_fib.m_c3, FE_RANGE_GREATER_OR_EQUAL(0.0), "c3");
ADD_PARAMETER(m_fib.m_c4, FE_RANGE_GREATER_OR_EQUAL(0.0), "c4");
ADD_PARAMETER(m_fib.m_c5, FE_RANGE_GREATER_OR_EQUAL(0.0), "c5");
ADD_PARAMETER(m_fib.m_lam1, FE_RANGE_GREATER_OR_EQUAL(1.0), "lambda");
END_FECORE_CLASS();
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPreStrainElastic.h | .h | 4,669 | 136 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
//-----------------------------------------------------------------------------
//! Class for stroing pre-strain gradient data
//! This material point class stores the initial pre-strain "guess" and
//! the correction term. The total prestrain gradient is the product of these two.
class FEPrestrainMaterialPoint : public FEMaterialPointData
{
public:
//! constructor
FEPrestrainMaterialPoint(FEMaterialPointData* mp);
//! copy
FEMaterialPointData* Copy();
//! initialization
void Init(bool bflag);
//! Serialization
void Serialize(DumpStream& dmp);
public:
//! get the initial prestrain gradient
const mat3d& initialPrestrain() const { return F0; }
//! set the prestrain gradient
void setInitialPrestrain(const mat3d& F) { F0 = F; }
//! get the prestrain correction
const mat3d& PrestrainCorrection() const { return Fc; }
//! set the prestrain correction
void setPrestrainCorrection(const mat3d& F) { Fc = F; }
//! get the total prestrain
mat3d prestrain() const { return Fc*F0; }
protected:
mat3d F0; //!< initial guess of pre-strain value
mat3d Fc; //!< "correction" used to premultiply the prestrain gradient
};
//-----------------------------------------------------------------------------
//! Base class for algorithms that will be used to calculate a pre-strain gradient.
//! This is used by the FEPrestrainElastic class to calculate the initial pre-strain
//! gradient.
class FEBIOMECH_API FEPrestrainGradient : public FEMaterialProperty
{
public:
FEPrestrainGradient(FEModel* pfem) : FEMaterialProperty(pfem) {}
virtual ~FEPrestrainGradient(){}
// evaluate the pre-strain deformation gradient
virtual mat3d Prestrain(FEMaterialPoint& mp) = 0;
// initialize the pre-strain gradient based on a deformation gradient
// This is used by the pre-strain initial condition
virtual void Initialize(const mat3d& F, FEMaterialPoint& mp) = 0;
FECORE_BASE_CLASS(FEPrestrainGradient)
};
//-----------------------------------------------------------------------------
class FEPrestrainMaterial
{
public:
virtual FEPrestrainGradient* PrestrainGradientProperty() = 0;
virtual FEElasticMaterial* GetElasticMaterial() = 0;
};
//-----------------------------------------------------------------------------
//! This material applies a user-defined prestrain deformation gradient
//! before evaluating the stress and tangents.
class FEPrestrainElastic : public FEElasticMaterial, public FEPrestrainMaterial
{
public:
//! constructor
FEPrestrainElastic(FEModel* pfem);
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
//! return the pre-strain gradient property
FEPrestrainGradient* PrestrainGradientProperty() override { return m_Fp; }
//! return the elastic material
FEElasticMaterial* GetElasticMaterial() override { return m_mat; }
// evaluate density in (pre-strained) reference configuration
double Density(FEMaterialPoint& mp) override;
public:
//! Cauchy stress
mat3ds Stress(FEMaterialPoint& mp) override;
//! spatial tangent
tens4ds Tangent(FEMaterialPoint& mp) override;
protected:
//! calculate prestrain deformation gradient
mat3d PrestrainGradient(FEMaterialPoint& mp);
private:
FEElasticMaterial* m_mat; //!< elastic base material
FEPrestrainGradient* m_Fp; //!< pre-strain gradient
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEReactivePlasticDamage.cpp | .cpp | 18,803 | 515 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2019 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEReactivePlasticDamage.h"
#include "FEDamageCriterion.h"
#include "FEElasticMaterial.h"
#include "FEDamageCDF.h"
#include "FEUncoupledMaterial.h"
#include "FECore/FECoreKernel.h"
#include <FECore/FEMesh.h>
#include <FECore/log.h>
#include <FECore/matrix.h>
#ifndef max
#define max(a, b) ((a)>(b)?(a):(b))
#endif
//////////////////////// PLASTIC DAMAGE MATERIAL /////////////////////////////////
// define the material parameters
BEGIN_FECORE_CLASS(FEReactivePlasticDamage, FEElasticMaterial)
// set material properties
ADD_PROPERTY(m_pBase, "elastic");
ADD_PROPERTY(m_pCrit, "yield_criterion");
ADD_PROPERTY(m_pFlow, "flow_curve");
ADD_PROPERTY(m_pYDamg, "plastic_damage" , FEProperty::Optional);
ADD_PROPERTY(m_pYDCrit, "plastic_damage_criterion", FEProperty::Optional);
ADD_PROPERTY(m_pIDamg, "elastic_damage" , FEProperty::Optional);
ADD_PROPERTY(m_pIDCrit, "elastic_damage_criterion", FEProperty::Optional);
ADD_PARAMETER(m_isochrc, "isochoric");
ADD_PARAMETER(m_rtol , FE_RANGE_GREATER_OR_EQUAL(0.0), "rtol");
ADD_PARAMETER(m_secant_tangent, "secant_tangent");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEReactivePlasticDamage::FEReactivePlasticDamage(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_isochrc = true;
m_rtol = 1e-4;
m_pBase = nullptr;
m_pCrit = nullptr;
m_pFlow = nullptr;
m_pYDamg = nullptr;
m_pYDCrit = nullptr;
m_pIDamg = nullptr;
m_pIDCrit = nullptr;
m_secant_tangent = true;
}
//-----------------------------------------------------------------------------
//! Initialization.
bool FEReactivePlasticDamage::Init()
{
if (m_pFlow->Init() == false) return false;
return FEElasticMaterial::Init();
}
//-----------------------------------------------------------------------------
void FEReactivePlasticDamage::Serialize(DumpStream& ar)
{
FEElasticMaterial::Serialize(ar);
ar & m_isochrc & m_rtol;
}
//-----------------------------------------------------------------------------
//! Create material point data for this material
FEMaterialPointData* FEReactivePlasticDamage::CreateMaterialPointData()
{
FEMaterialPointData* ep = m_pBase->CreateMaterialPointData();
FEMaterialPointData* fp = m_pFlow->CreateMaterialPointData();
fp->SetNext(ep);
return new FEReactivePlasticDamageMaterialPoint(fp, this);
}
//-----------------------------------------------------------------------------
//! evaluate elastic deformation gradient
void FEReactivePlasticDamage::ElasticDeformationGradient(FEMaterialPoint& pt)
{
// initialize flow curve (if not done yet)
if (m_pFlow->InitFlowCurve(pt)) {
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
pp.Init();
}
int n = (int)m_pFlow->BondFamilies(pt);
// extract total deformation gradient
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract inverse of plastic deformation gradient and evaluate elastic deformation gradient
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
FEPlasticFlowCurveMaterialPoint& fp = *pt.ExtractData<FEPlasticFlowCurveMaterialPoint>();
FEShellElementNew* sel = dynamic_cast<FEShellElementNew*>(pt.m_elem);
for (int i=0; i<n; ++i) {
mat3d Fs = pe.m_F;
mat3d R = pe.m_F*pe.RightStretchInverse();
// for EAS and ANS shells, adjust calculation of Fs using enhanced strain Es
if (sel) {
mat3ds Cs = mat3dd(1) + sel->m_E[pt.m_index]*2;
double eval[3];
vec3d evec[3];
Cs.eigen2(eval,evec);
mat3ds Us = dyad(evec[0])*sqrt(eval[0]) + dyad(evec[1])*sqrt(eval[1]) + dyad(evec[2])*sqrt(eval[2]);
Fs = R*Us;
}
mat3d Fe = Fs*pp.m_Fusi[i];
// store safe copy of total deformation gradient
mat3d Ftmp = pe.m_F;
double Jtmp = pe.m_J;
pe.m_F = Fe; pe.m_J = Fe.det();
mat3ds Ue = pe.RightStretch();
// evaluate yield measure
pp.m_Kv[i] = m_pCrit->DamageCriterion(pt);
// restore total deformation gradient
pe.m_F = Ftmp; pe.m_J = Jtmp;
// if there is no yielding, we're done
double phi = pp.m_Kv[i] - fp.m_Ky[i];
if (phi <= m_rtol*fp.m_Ky[i]) {
pp.m_Fvsi[i] = pp.m_Fusi[i];
continue;
}
// check if i-th bond family is yielding
if ((pp.m_Kv[i] > pp.m_Ku[i]) && (pp.m_Ku[i] < fp.m_Ky[i]*(1+m_rtol))) {
if (pp.m_byldt[i] == false) {
pp.m_byldt[i] = true;
pp.m_wy[i] = (1.0-pp.m_di[i])*fp.m_w[i];
}
}
// if not, and if this bond family has not yielded at previous times,
// reset the mass fraction of yielded bonds to zero (in case m_wy[i] was
// set to non-zero during a prior iteration at current time)
else if (pp.m_byld[i] == false) {
pp.m_byldt[i] = false;
pp.m_wy[i] = 0;
}
// find Fv
bool conv = false;
int iter = 0;
double lam = 0;
mat3d Fv = Fe;
Ftmp = pe.m_F; // store safe copy
Jtmp = pe.m_J;
pe.m_F = Fv; pe.m_J = Fv.det();
mat3ds Uv = pe.RightStretch();
mat3ds Nv = YieldSurfaceNormal(pt);
double Nvmag = Nv.norm();
mat3dd I(1);
double beta = 1;
mat3ds ImN = I;
double phi0=0, phi1=0, phi2=0, lam1=0, lam2=0, a, b, c=0, d;
while (!conv) {
++iter;
pe.m_F = Fv; pe.m_J = Fv.det();
pp.m_Kv[i] = m_pCrit->DamageCriterion(pt);
phi = pp.m_Kv[i] - fp.m_Ky[i]; // phi = 0 => stay on yield surface
if (iter == 1) {
phi0 = phi;
c = phi0;
}
else if (iter == 2) {
phi1 = phi;
lam1 = lam;
}
else if (iter == 3) {
phi2 = phi;
lam2 = lam;
}
mat3d dUvdlam = -Ue*Nv*(beta/Nvmag);
if (m_isochrc)
dUvdlam += Ue*ImN*((ImN.inverse()*Nv/Nvmag).trace()*beta/3.);
double dlam = -phi/(Nv*dUvdlam.transpose()).trace();
lam += dlam;
if (iter == 3) {
d = lam1*lam2*(lam1-lam2);
if (d == 0) {
lam = (lam1*lam2 == 0) ? 0 : lam2;
}
else {
a = (lam2*(phi1-phi0)-lam1*(phi2-phi0))/d;
b = ((phi2-phi0)*lam1*lam1-(phi1-phi0)*lam2*lam2)/d;
d = b*b - 4*a*c;
if (d >= 0) {
if (a != 0) {
lam1 = (-b+sqrt(d))/(2*a);
lam2 = (-b-sqrt(d))/(2*a);
lam = (fabs(lam1) < fabs(lam2)) ? lam1 : lam2;
}
else if (b != 0) lam = -c/b;
else lam = 0;
}
else if (a != 0) {
lam = -b/(2*a);
}
else
lam = 0;
}
conv = true;
}
ImN = I - Nv*(lam/Nvmag);
if (m_isochrc) beta = pow((pp.m_Fusi[i]*ImN).det(), -1./3.);
Uv = (Ue*ImN).sym()*beta;
Fv = R*Uv;
if (fabs(dlam) <= m_rtol*fabs(lam)) conv = true;
if (fabs(lam) <= m_rtol*m_rtol) conv = true;
}
pe.m_F = Fv; pe.m_J = Fv.det();
pp.m_Kv[i] = m_pCrit->DamageCriterion(pt);
pe.m_F = Ftmp; pe.m_J = Jtmp;
pp.m_Fvsi[i] = Fs.inverse()*Fv;
}
// evaluate octahedral plastic strain
OctahedralPlasticStrain(pt);
ReactiveHeatSupplyDensity(pt);
return;
}
//-----------------------------------------------------------------------------
// update plastic damage material point at each iteration
void FEReactivePlasticDamage::UpdateSpecializedMaterialPoints(FEMaterialPoint& pt, const FETimeInfo& tp)
{
// initialize flow curve (if not done yet)
if (m_pFlow->InitFlowCurve(pt)) {
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
pp.Init();
}
ElasticDeformationGradient(pt);
int n = (int)m_pFlow->BondFamilies(pt);
// extract total deformation gradient
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract plastic damage material point
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
FEPlasticFlowCurveMaterialPoint& fp = *pt.ExtractData<FEPlasticFlowCurveMaterialPoint>();
// zero the total damage variable
pp.m_D = 0.0;
// get intact damage criterion
if (m_pIDCrit) pp.m_Etrial = m_pIDCrit->DamageCriterion(pt);
double Es = max(pp.m_Etrial, pp.m_Emax);
for (int i=0; i<n; ++i) {
if (pp.m_byldt[i] == false)
{
pp.m_di[i] = m_pIDamg ? m_pIDamg->cdf(pt,Es) : 0;
pp.m_d[i] = pp.m_di[i]*fp.m_w[i];
// what if we iterate here, update damage, then the next iteration decides we actually are yielding?
// no mechanism to undo the extra damage we've added
// do i need to save the final Eim for each family?
}
else
{
mat3d Fp = pp.m_Fvsi[i].inverse();
// store safe copy of total deformation gradient
mat3d Ftmp = pe.m_F;
pe.m_F = Fp;
// calculate damage
if (m_pYDCrit) pp.m_Eyt[i] = m_pYDCrit->DamageCriterion(pt);
double Ey = max(pp.m_Eyt[i], pp.m_Eym[i]);
pp.m_dy[i] = m_pYDamg ? m_pYDamg->cdf(pt,Ey) : 0;
// restore total deformation gradient
pe.m_F = Ftmp;
// calculate bond fractions
pp.m_wy[i] = (1.0-pp.m_dy[i])*(1.0-pp.m_di[i])*fp.m_w[i];
// calculate damage
pp.m_d[i] = (pp.m_di[i]+pp.m_dy[i]*(1.0-pp.m_di[i]))*fp.m_w[i];
}
// sum the damage over all bond families
pp.m_D += pp.m_d[i];
}
// add damage to persistent elastic bonds
pp.m_di[n] = m_pIDamg ? m_pIDamg->cdf(pt,Es) : 0;
pp.m_d[n] = pp.m_di[n]*fp.m_w[n];
pp.m_D += pp.m_d[n];
}
//-----------------------------------------------------------------------------
//! calculate stress at material point
mat3ds FEReactivePlasticDamage::Stress(FEMaterialPoint& pt)
{
ElasticDeformationGradient(pt);
int n = (int)m_pFlow->BondFamilies(pt);
// extract elastic material point
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract plastic damage material point
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
mat3ds s = m_pBase->Stress(pt)*pp.IntactBonds();
for (int i=0; i<n; ++i) {
// get the elastic deformation gradient
mat3d Fv = pe.m_F*pp.m_Fvsi[i];
// store safe copy of total deformation gradient
mat3d Fs = pe.m_F; double Js = pe.m_J;
pe.m_F = Fv; pe.m_J = Fv.det();
// evaluate the damaged plastic stress using the elastic deformation gradient
s += m_pBase->Stress(pt)*pp.m_wy[i];
// restore the original deformation gradient
pe.m_F = Fs; pe.m_J = Js;
}
// return the stress
return s;
}
//-----------------------------------------------------------------------------
//! calculate tangent stiffness at material point
tens4ds FEReactivePlasticDamage::Tangent(FEMaterialPoint& pt)
{
ElasticDeformationGradient(pt);
int n = (int)m_pFlow->BondFamilies(pt);
// extract elastic material point
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract plastic material point
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
tens4ds c = m_pBase->Tangent(pt)*pp.IntactBonds();
for (int i=0; i<n; ++i) {
// get the elastic deformation gradient
mat3d Fv = pe.m_F*pp.m_Fvsi[i];
// store safe copy of total deformation gradient
mat3d Fs = pe.m_F; double Js = pe.m_J;
pe.m_F = Fv; pe.m_J = Fv.det();
// evaluate the tangent using the elastic deformation gradient
c += m_pBase->Tangent(pt)*pp.m_wy[i];
// restore the original deformation gradient
pe.m_F = Fs; pe.m_J = Js;
}
// return the tangent
return c;
}
//-----------------------------------------------------------------------------
//! calculate strain energy density at material point
double FEReactivePlasticDamage::StrainEnergyDensity(FEMaterialPoint& pt)
{
ElasticDeformationGradient(pt);
int n = (int)m_pFlow->BondFamilies(pt);
// extract elastic material point
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract plastic material point
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
double sed = m_pBase->StrainEnergyDensity(pt)*pp.IntactBonds();
for (int i=0; i<n; ++i) {
// get the elastic deformation gradient
mat3d Fv = pe.m_F*pp.m_Fvsi[i];
double Jvsi = m_isochrc ? 1 : pp.m_Fvsi[i].det();
// store safe copy of total deformation gradient
mat3d Fs = pe.m_F; double Js = pe.m_J;
pe.m_F = Fv; pe.m_J = Fv.det();
// evaluate the tangent using the elastic deformation gradient
sed += m_pBase->StrainEnergyDensity(pt)*pp.m_wy[i]/Jvsi;
// restore the original deformation gradient
pe.m_F = Fs; pe.m_J = Js;
}
// return the sed
return sed;
}
//-----------------------------------------------------------------------------
//! calculate damage at material point
double FEReactivePlasticDamage::Damage(FEMaterialPoint& pt, int k)
{
//get plastic damage material point data
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
return pp.m_d[k];
}
//-----------------------------------------------------------------------------
// get the yield surface normal
mat3ds FEReactivePlasticDamage::YieldSurfaceNormal(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pe = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds s = m_pBase->Stress(mp);
tens4ds c = m_pBase->Tangent(mp);
mat3ds dPhi = m_pCrit->CriterionStressTangent(mp);
mat3d M = dPhi*s*2 - mat3dd((dPhi*s).trace()) + c.dot(dPhi);
mat3ds Ui = pe.RightStretchInverse();
mat3d R = pe.m_F*Ui;
mat3ds N = (R.transpose()*M*R*Ui).sym();
return N;
}
//-----------------------------------------------------------------------------
//! calculate octahedral plastic strain at material point
void FEReactivePlasticDamage::OctahedralPlasticStrain(FEMaterialPoint& pt)
{
int n = (int)m_pFlow->BondFamilies(pt);
// extract plastic material point
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
double ev[3];
for (int i=0; i<n; ++i) {
mat3ds Cvsi = (pp.m_Fvsi[i].transpose()*pp.m_Fvsi[i]).sym();
Cvsi.eigen2(ev);
for (int j=0; j<3; ++j) ev[j] = 1./sqrt(ev[j]);
pp.m_gp[i] = sqrt(2.)/3.*sqrt(pow(ev[0] - ev[1],2) + pow(ev[1] - ev[2],2) + pow(ev[2] - ev[0],2));
}
}
//-----------------------------------------------------------------------------
//! evaluate reactive heat supply at material point
void FEReactivePlasticDamage::ReactiveHeatSupplyDensity(FEMaterialPoint& pt)
{
double Rhat = 0;
double dt = CurrentTimeIncrement();
// extract elastic material point
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract plastic material point
FEReactivePlasticDamageMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
if (dt == 0) {
pp.m_Rhat = 0;
return;
}
// store safe copy of total deformation gradient
mat3d Fs = pe.m_F; double Js = pe.m_J;
int n = (int)m_pFlow->BondFamilies(pt);
for (int i=0; i<n; ++i) {
// get the elastic deformation gradients
mat3d Fu = Fs*pp.m_Fusi[i];
// evaluate strain energy density in the absence of yielding
pe.m_F = Fu; pe.m_J = Fu.det();
// evaluate the tangent using the elastic deformation gradient
Rhat += m_pBase->StrainEnergyDensity(pt)*pp.m_wy[i];
mat3d Fv = Fs*pp.m_Fvsi[i];
// evaluate strain energy density in the absence of yielding
pe.m_F = Fv; pe.m_J = Fv.det();
// evaluate the tangent using the elastic deformation gradient
Rhat -= m_pBase->StrainEnergyDensity(pt)*pp.m_wy[i];
}
// get rate
Rhat /= dt;
// restore the original deformation gradient
pe.m_F = Fs; pe.m_J = Js;
// return the reactive heat supply
pp.m_Rhat = Rhat;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEScaledElasticMaterial.h | .h | 2,242 | 58 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
#include <FECore/FEFunction1D.h>
//-----------------------------------------------------------------------------
//! This class implements a scaled elastic material with user-specified scale
//
class FEScaledElasticMaterial : public FEElasticMaterial
{
public:
//! default constructor
FEScaledElasticMaterial(FEModel* pfem) : m_pBase(nullptr), FEElasticMaterial(pfem) {}
public:
//! stress function
mat3ds Stress(FEMaterialPoint& pt) override;
//! tangent function
tens4ds Tangent(FEMaterialPoint& pt) override;
//! strain energy density function
double StrainEnergyDensity(FEMaterialPoint& pt) override;
FEMaterialPointData* CreateMaterialPointData() override;
DECLARE_FECORE_CLASS();
private:
FEElasticMaterial* m_pBase; //!< pointer to elastic solid material to scale
FEParamDouble m_scale; //!< scale factor
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEInitialRigidKinematics.h | .h | 1,826 | 48 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FEInitialCondition.h>
#include "febiomech_api.h"
//! Component that assigns initial velocity based on rigid body kinematics
class FEBIOMECH_API FEInitialRigidKinematics : public FENodalIC
{
public:
FEInitialRigidKinematics(FEModel* fem);
bool Init() override;
// return the values for node i
void GetNodalValues(int inode, std::vector<double>& values) override;
private:
vec3d m_v; // initial linear velocity
vec3d m_w; // initial angular velocity
vec3d m_c; // center of rotation
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/stdafx.h | .h | 1,311 | 32 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <stdlib.h>
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEEFDVerondaWestmann.h | .h | 2,205 | 65 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
#include "FEVerondaWestmann.h"
#include "FEEFDUncoupled.h"
//-----------------------------------------------------------------------------
//! This class implements a material that consists of a Veronda-Westmann matrix and
//! a continuous EFD fiber distribution.
class FEEFDVerondaWestmann : public FEUncoupledMaterial
{
public:
// constructor
FEEFDVerondaWestmann(FEModel* pfem);
//! material initialization
bool Init() override;
//! serialization
void Serialize(DumpStream& ar) override;
//! deviatoric stress
mat3ds DevStress(FEMaterialPoint& pt) override;
//! deviatoric tangent
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! calculate deviatoric strain energy density
double DevStrainEnergyDensity(FEMaterialPoint& mp) override;
public:
FEVerondaWestmann m_VW;
FEEFDUncoupled m_EFD;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEBearingLoad.cpp | .cpp | 11,765 | 336 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2022 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEBearingLoad.h"
#include "FEBioMech.h"
#include <FECore/FESurface.h>
#include <FECore/FEFacetSet.h>
#include <FECore/FEMesh.h>
#include <FECore/QuadricFit.h>
#include <FECore/log.h>
#include <string>
//-----------------------------------------------------------------------------
// Parameter block for bearing loads
BEGIN_FECORE_CLASS(FEBearingLoad, FESurfaceLoad)
ADD_PARAMETER(m_scale , "scale");
ADD_PARAMETER(m_force , "force");
ADD_PARAMETER(m_bsymm , "symmetric_stiffness");
ADD_PARAMETER(m_blinear , "linear");
ADD_PARAMETER(m_bshellb , "shell_bottom");
ADD_PARAMETER(m_profile , "profile");
END_FECORE_CLASS()
//-----------------------------------------------------------------------------
//! constructor
FEBearingLoad::FEBearingLoad(FEModel* pfem) : FESurfaceLoad(pfem)
{
m_scale = 1.0;
m_force = vec3d(0,0,0);
m_bsymm = true;
m_bshellb = false;
m_blinear = false;
m_profile = P_SINE;
}
//-----------------------------------------------------------------------------
bool FEBearingLoad::Init()
{
// get the degrees of freedom
m_dof.Clear();
if (m_bshellb == false)
{
m_dof.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
}
else
{
m_dof.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_DISPLACEMENT));
}
if (m_dof.IsEmpty()) return false;
if (FESurfaceLoad::Init() == false) return false;
std::vector<vec3d> pc;
FESurface& surf = GetSurface();
surf.SetShellBottom(m_bshellb);
FENodeList nl = surf.GetNodeList();
FEMesh* mesh = surf.GetMesh();
// figure out the pressure load distribution on the bearing surface.
// 1. Fit a quadric to the bearing surface
// 2. Confirm that the quadric is a cylinder
// 3. Set the cylinder axis ez and create local coordinate system
// based on orientation of bearing force (er)
// 4. For each face of bearing surface, get cosine of angle theta of its normal relative to er (cq)
// 5. Use cq to evaluate the pressure profile and projected area, scale to match prescribed force
// collect all the surface nodal positions into pc
if (m_bshellb == false) {
for (int i=0; i<nl.Size(); ++i)
pc.push_back(mesh->Node(nl[i]).m_r0);
}
else {
for (int i=0; i<nl.Size(); ++i)
pc.push_back(mesh->Node(nl[i]).s0());
}
// find the best fit quadric
QuadricFit* fit = new QuadricFit();
fit->Fit(pc);
QuadricFit::Q_TYPE qtype = fit->GetType();
bool cylindrical = qtype & (QuadricFit::Q_CIRCULAR_CYLINDER |
QuadricFit::Q_ELLIPTIC_CYLINDER |
QuadricFit::Q_PARABOLIC_CYLINDER|
QuadricFit::Q_HYPERBOLIC_CYLINDER);
if (cylindrical == false) {
std::string quadric = fit->GetStringType(qtype);
feLogError("Bearing load surface is %s, not cylindrical!\n",quadric.c_str());
return false;
}
// extract cylinder parameters
// vec3d c = fit->m_rc; // cylinder origin
// double R = sqrt(1./fit->m_c2.x); // radius
vec3d ez = fit->m_ax[2]; // cylinder axis
vec3d et = (ez ^ m_force).normalized();
m_er = (et ^ ez).normalized(); // radial force direction
// evaluate dot product of bearing force and axis
double dp = m_force*ez;
double eps = 1e-3;
if (fabs(dp) > m_force.norm()*eps) {
feLogWarning("Axial component of bearing force (%g) is ignored!\n",dp);
}
// create surface map for prescribed pressure
m_pc = new FESurfaceMap(FE_DOUBLE);
m_pc->Create(surf.GetFacetSet(), 0.0, FMT_MULT);
int m = m_pc->MaxNodes();
// evaluate projected area, which is needed to evaluate peak pressure
double A = 0; // effective projected area
for (int i=0; i<surf.Elements(); ++i) {
// get the surface element
FESurfaceElement& el = surf.Element(i);
// get (and negate inward) normal at face centroid
vec3d n = -surf.SurfaceNormal(el, el.cr(), el.cs());
// get face area
double area = surf.FaceArea(el);
// cosine of angle between force and surface normal
double cq = n*m_er;
// if cq is positive
if (cq > 0) {
// face projected area
double parea = area*cq;
// add to effective projected area
switch (m_profile) {
case P_SINE: A += cq*parea; break;
case P_PARA: A += pow(cq,2)*parea; break;
default: break;
}
}
}
// evaluate peak pressure p0 for a unit force magnitude
double p0 = 1.0/A;
// prescribe bearing pressure on each face
for (int i=0; i<surf.Elements(); ++i) {
// get the surface element
FESurfaceElement& el = surf.Element(i);
// get (and negate inward) normal at face centroid
vec3d n = -surf.SurfaceNormal(el, el.cr(), el.cs());
// cosine of angle between force and surface normal
double cq = n*m_er;
// if cq is positive
if (cq > 0) {
double p = p0;
switch (m_profile) {
case P_SINE: p *= cq; break;
case P_PARA: p *= pow(cq,2); break;
default: p = 0; break;
}
for (int j = 0; j < m; ++j)
m_pc->setValue(el.m_lid, j, p);
}
}
return true;
}
//-----------------------------------------------------------------------------
//! update projected area of bearing surface when nonlinear flag is set
void FEBearingLoad::Update()
{
if (m_blinear == false) {
FESurface& surf = GetSurface();
surf.SetShellBottom(m_bshellb);
int m = m_pc->MaxNodes();
// evaluate projected area, which is needed to evaluate peak pressure
double A = 0; // effective projected area
for (int i=0; i<surf.Elements(); ++i) {
// get the surface element
FESurfaceElement& el = surf.Element(i);
// get (and negate inward) normal at face centroid
vec3d n = -surf.SurfaceNormal(el, el.cr(), el.cs());
// get face area
double area = surf.FaceArea(el);
// cosine of angle between force and surface normal
double cq = n*m_er;
// if cq is positive
if (cq > 0) {
// face projected area
double parea = area*cq;
// add to effective projected area
switch (m_profile) {
case P_SINE: A += cq*parea; break;
case P_PARA: A += pow(cq,2)*parea; break;
default: break;
}
}
}
// evaluate peak pressure p0 for a unit force magnitude
double p0 = 1.0/A;
// prescribe bearing pressure on each face
for (int i=0; i<surf.Elements(); ++i) {
// get the surface element
FESurfaceElement& el = surf.Element(i);
// get (and negate inward) normal at face centroid
vec3d n = -surf.SurfaceNormal(el, el.cr(), el.cs());
// cosine of angle between force and surface normal
double cq = n*m_er;
// if cq is positive
if (cq > 0) {
double p = p0;
switch (m_profile) {
case P_SINE: p *= cq; break;
case P_PARA: p *= pow(cq,2); break;
default: p = 0; break;
}
for (int j = 0; j < m; ++j)
m_pc->setValue(el.m_lid, j, p);
}
}
}
}
//-----------------------------------------------------------------------------
void FEBearingLoad::Serialize(DumpStream& ar)
{
FESurfaceLoad::Serialize(ar);
if (ar.IsShallow() == false)
{
ar & m_er;
if (ar.IsSaving())
m_pc->Serialize(ar);
else
{
m_pc = new FESurfaceMap(FE_DOUBLE);
m_pc->Serialize(ar);
}
}
}
//-----------------------------------------------------------------------------
//! evaluate bearing pressure
double FEBearingLoad::ScalarLoad(FESurfaceMaterialPoint& mp)
{
// evaluate pressure at this material point
double P = m_pc->value(mp)*m_scale*m_force.norm();
return P;
}
//-----------------------------------------------------------------------------
void FEBearingLoad::LoadVector(FEGlobalVector& R)
{
FESurface& surf = GetSurface();
surf.SetShellBottom(m_bshellb);
// evaluate the integral
surf.LoadVector(R, m_dof, m_blinear, [&](FESurfaceMaterialPoint& pt, const FESurfaceDofShape& dof_a, std::vector<double>& val) {
// evaluate pressure at this material point
double P = -ScalarLoad(pt);
if (m_bshellb) P = -P;
double J = (pt.dxr ^ pt.dxs).norm();
// force vector
vec3d N = (pt.dxr ^ pt.dxs); N.unit();
vec3d t = N*P;
double H_u = dof_a.shape;
val[0] = H_u*t.x*J;
val[1] = H_u*t.y*J;
val[2] = H_u*t.z*J;
});
}
//-----------------------------------------------------------------------------
void FEBearingLoad::StiffnessMatrix(FELinearSystem& LS)
{
// Don't calculate stiffness for a linear load
if (m_blinear) return;
FESurface& surf = GetSurface();
surf.SetShellBottom(m_bshellb);
// evaluate the integral
surf.LoadStiffness(LS, m_dof, m_dof, [&](FESurfaceMaterialPoint& mp, const FESurfaceDofShape& dof_a, const FESurfaceDofShape& dof_b, matrix& kab) {
// evaluate pressure at this material point
double P = -ScalarLoad(mp);
if (m_bshellb) P = -P;
double H_i = dof_a.shape;
double Gr_i = dof_a.shape_deriv_r;
double Gs_i = dof_a.shape_deriv_s;
double H_j = dof_b.shape;
double Gr_j = dof_b.shape_deriv_r;
double Gs_j = dof_b.shape_deriv_s;
vec3d vab(0,0,0);
if (m_bsymm)
vab = (mp.dxr*(H_j * Gs_i - H_i * Gs_j) - mp.dxs*(H_j * Gr_i - H_i * Gr_j)) * 0.5*P;
else
vab = (mp.dxs*Gr_j - mp.dxr*Gs_j)*(P*H_i);
mat3da K(vab);
kab.set(0, 0, K);
});
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FENeoHookeanTransIso.cpp | .cpp | 15,497 | 341 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FENeoHookeanTransIso.h"
// define the material parameters
BEGIN_FECORE_CLASS(FENeoHookeanTransIso, FEElasticMaterial)
ADD_PARAMETER(m_Ep, "Ep");
ADD_PARAMETER(m_Ez, "Ez");
ADD_PARAMETER(m_vz, "vz");
ADD_PARAMETER(m_vp, "vp");
ADD_PARAMETER(m_gz, "gz");
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//////////////////////////////////////////////////////////////////////
// CompNeoHookean_Transiso
//////////////////////////////////////////////////////////////////////
mat3ds FENeoHookeanTransIso::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d &F = pt.m_F;
double detF = pt.m_J;
//define jacobian
double J = detF;
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// get the initial fiber direction
vec3d a0 = Q.col(0);
// calculate the current material axis lam*a = F*a0;
vec3d a = F*a0;
// normalize material axis and store fiber stretch
double lam = a.unit();
// calculate left Cauchy-Green tensor
// (we commented out the matrix components we do not need)
double B[3][3];
double B2[3][3];
B[0][0] = F[0][0]*F[0][0]+F[0][1]*F[0][1]+F[0][2]*F[0][2];
B[0][1] = F[0][0]*F[1][0]+F[0][1]*F[1][1]+F[0][2]*F[1][2];
B[0][2] = F[0][0]*F[2][0]+F[0][1]*F[2][1]+F[0][2]*F[2][2];
B[1][0] = F[1][0]*F[0][0]+F[1][1]*F[0][1]+F[1][2]*F[0][2];
B[1][1] = F[1][0]*F[1][0]+F[1][1]*F[1][1]+F[1][2]*F[1][2];
B[1][2] = F[1][0]*F[2][0]+F[1][1]*F[2][1]+F[1][2]*F[2][2];
B[2][0] = F[2][0]*F[0][0]+F[2][1]*F[0][1]+F[2][2]*F[0][2];
B[2][1] = F[2][0]*F[1][0]+F[2][1]*F[1][1]+F[2][2]*F[1][2];
B[2][2] = F[2][0]*F[2][0]+F[2][1]*F[2][1]+F[2][2]*F[2][2];
// calculate square of B
// (we commented out the matrix components we do not need)
B2[0][0] = B[0][0]*B[0][0]+B[0][1]*B[1][0]+B[0][2]*B[2][0];
B2[0][1] = B[0][0]*B[0][1]+B[0][1]*B[1][1]+B[0][2]*B[2][1];
B2[0][2] = B[0][0]*B[0][2]+B[0][1]*B[1][2]+B[0][2]*B[2][2];
B2[1][0] = B[1][0]*B[0][0]+B[1][1]*B[1][0]+B[1][2]*B[2][0];
B2[1][1] = B[1][0]*B[0][1]+B[1][1]*B[1][1]+B[1][2]*B[2][1];
B2[1][2] = B[1][0]*B[0][2]+B[1][1]*B[1][2]+B[1][2]*B[2][2];
B2[2][0] = B[2][0]*B[0][0]+B[2][1]*B[1][0]+B[2][2]*B[2][0];
B2[2][1] = B[2][0]*B[0][1]+B[2][1]*B[1][1]+B[2][2]*B[2][1];
B2[2][2] = B[2][0]*B[0][2]+B[2][1]*B[1][2]+B[2][2]*B[2][2];
// calculate Ba
vec3d Ba;
Ba.x = B[0][0]*a.x + B[0][1]*a.y + B[0][2]*a.z;
Ba.y = B[1][0]*a.x + B[1][1]*a.y + B[1][2]*a.z;
Ba.z = B[2][0]*a.x + B[2][1]*a.y + B[2][2]*a.z;
//compute invariants
double I1,I3,I4,I5;
I1 = B[0][0]+B[1][1]+B[2][2];
I3=J*J;
I4 = lam*lam;;
I5 = I4*(a*Ba);
// compute lame parameters
double m_gp=m_Ep/(2*(1+m_vp));
double m_lamp=-((m_Ep*(m_Ez*m_vp + m_Ep*m_vz*m_vz))/((1 + m_vp)*(m_Ez*(-1 + m_vp) + 2*m_Ep*m_vz*m_vz)));
double m_lamz=(m_Ez*m_Ez*(-1 + m_vp*m_vp) - m_Ep*(m_Ep + 4*(m_gp + m_gz)*(1 + m_vp))*m_vz*m_vz + m_Ez*(2*m_gz - m_Ep*m_vp - 2*m_gz*m_vp*m_vp - 2*m_gp*(-1 + m_vp*m_vp) + 2*m_Ep*m_vz + 2*m_Ep*m_vp*m_vz))/((1 + m_vp)*(m_Ez*(-1 + m_vp) + 2*m_Ep*m_vz*m_vz));
double m_alpha=(m_Ep*(m_Ep*m_vz*m_vz - m_Ez*(m_vp*(-1 + m_vz) + m_vz)))/((1 + m_vp)*(m_Ez*(-1 + m_vp) + 2*m_Ep*m_vz*m_vz));
// calculate stress
mat3ds s;
//trans iso
s.xx()=(2*(B[0][0]*(m_gp/2. + (m_alpha*(-1 + I4))/4.) + a.x*(a.x*B[0][0] + a.y*B[0][1] + a.z*B[0][2])*(-m_gp + m_gz)*I4 + I3*(-m_gp/(2.*I3) + ((-1 + J)*m_lamp)/(2.*J)) + a.x*a.x*I4*(m_gz/2. + (m_alpha*(-3 + I1))/4. - m_gz/(2.*I4) - (-m_gp + m_gz)*I4 + ((-1 + lam)*m_lamz)/(2.*lam))))/J;
s.xy()=(2*(B[0][1]*(m_gp/2. + (m_alpha*(-1 + I4))/4.) + ((a.y*(a.x*B[0][0] + a.y*B[0][1] + a.z*B[0][2]) + a.x*(a.x*B[0][1] + a.y*B[1][1] + a.z*B[1][2]))*(-m_gp + m_gz)*I4)/2. + a.x*a.y*I4*(m_gz/2. + (m_alpha*(-3 + I1))/4. - m_gz/(2.*I4) - (-m_gp + m_gz)*I4 + ((-1 + lam)*m_lamz)/(2.*lam))))/J;
s.xz()=(2*(B[0][2]*(m_gp/2. + (m_alpha*(-1 + I4))/4.) + ((a.z*(a.x*B[0][0] + a.y*B[0][1] + a.z*B[0][2]) + a.x*(a.x*B[0][2] + a.y*B[1][2] + a.z*B[2][2]))*(-m_gp + m_gz)*I4)/2. + a.x*a.z*I4*(m_gz/2. + (m_alpha*(-3 + I1))/4. - m_gz/(2.*I4) - (-m_gp + m_gz)*I4 + ((-1 + lam)*m_lamz)/(2.*lam))))/J;
s.yy()=(2*(B[1][1]*(m_gp/2. + (m_alpha*(-1 + I4))/4.) + a.y*(a.x*B[0][1] + a.y*B[1][1] + a.z*B[1][2])*(-m_gp + m_gz)*I4 + I3*(-m_gp/(2.*I3) + ((-1 + J)*m_lamp)/(2.*J)) + a.y*a.y*I4*(m_gz/2. + (m_alpha*(-3 + I1))/4. - m_gz/(2.*I4) - (-m_gp + m_gz)*I4 + ((-1 + lam)*m_lamz)/(2.*lam))))/J;
s.yz()=(2*(B[1][2]*(m_gp/2. + (m_alpha*(-1 + I4))/4.) + ((a.z*(a.x*B[0][1] + a.y*B[1][1] + a.z*B[1][2]) + a.y*(a.x*B[0][2] + a.y*B[1][2] + a.z*B[2][2]))*(-m_gp + m_gz)*I4)/2. + a.y*a.z*I4*(m_gz/2. + (m_alpha*(-3 + I1))/4. - m_gz/(2.*I4) - (-m_gp + m_gz)*I4 + ((-1 + lam)*m_lamz)/(2.*lam))))/J;
s.zz()=(2*(B[2][2]*(m_gp/2. + (m_alpha*(-1 + I4))/4.) + a.z*(a.x*B[0][2] + a.y*B[1][2] + a.z*B[2][2])*(-m_gp + m_gz)*I4 + I3*(-m_gp/(2.*I3) + ((-1 + J)*m_lamp)/(2.*J)) + a.z*a.z*I4*(m_gz/2. + (m_alpha*(-3 + I1))/4. - m_gz/(2.*I4) - (-m_gp + m_gz)*I4 + ((-1 + lam)*m_lamz)/(2.*lam))))/J;
//compressible neohookean (for testing--comment out)
//s.x=(2*((B[0][0]*m_gp)/2. + I3*(-m_gp/(2.*I3) + (m_lamp*log(J))/(2.*I3))))/J;
//s.xy=(B[0][1]*m_gp)/J;
//s.xz=(B[0][2]*m_gp)/J;
//s.y=(2*((B[1][1]*m_gp)/2. + I3*(-m_gp/(2.*I3) + (m_lamp*log(J))/(2.*I3))))/J;
//s.yz=(B[1][2]*m_gp)/J;
//s.z=(2*((B[2][2]*m_gp)/2. + I3*(-m_gp/(2.*I3) + (m_lamp*log(J))/(2.*I3))))/J;
return s;
}
tens4ds FENeoHookeanTransIso::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d &F = pt.m_F;
double detF = pt.m_J;
//define jacobian
double J = detF;
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// get the initial fiber direction
vec3d a0 = Q.col(0);
// calculate the current material axis lam*a = F*a0;
vec3d a = F*a0;
// normalize material axis and store fiber stretch
double lam = a.unit();
// calculate left Cauchy-Green tensor
// (we commented out the matrix components we do not need)
double B[3][3];
double B2[3][3];
B[0][0] = F[0][0]*F[0][0]+F[0][1]*F[0][1]+F[0][2]*F[0][2];
B[0][1] = F[0][0]*F[1][0]+F[0][1]*F[1][1]+F[0][2]*F[1][2];
B[0][2] = F[0][0]*F[2][0]+F[0][1]*F[2][1]+F[0][2]*F[2][2];
B[1][0] = F[1][0]*F[0][0]+F[1][1]*F[0][1]+F[1][2]*F[0][2];
B[1][1] = F[1][0]*F[1][0]+F[1][1]*F[1][1]+F[1][2]*F[1][2];
B[1][2] = F[1][0]*F[2][0]+F[1][1]*F[2][1]+F[1][2]*F[2][2];
B[2][0] = F[2][0]*F[0][0]+F[2][1]*F[0][1]+F[2][2]*F[0][2];
B[2][1] = F[2][0]*F[1][0]+F[2][1]*F[1][1]+F[2][2]*F[1][2];
B[2][2] = F[2][0]*F[2][0]+F[2][1]*F[2][1]+F[2][2]*F[2][2];
// calculate square of B
// (we commented out the matrix components we do not need)
B2[0][0] = B[0][0]*B[0][0]+B[0][1]*B[1][0]+B[0][2]*B[2][0];
B2[0][1] = B[0][0]*B[0][1]+B[0][1]*B[1][1]+B[0][2]*B[2][1];
B2[0][2] = B[0][0]*B[0][2]+B[0][1]*B[1][2]+B[0][2]*B[2][2];
B2[1][0] = B[1][0]*B[0][0]+B[1][1]*B[1][0]+B[1][2]*B[2][0];
B2[1][1] = B[1][0]*B[0][1]+B[1][1]*B[1][1]+B[1][2]*B[2][1];
B2[1][2] = B[1][0]*B[0][2]+B[1][1]*B[1][2]+B[1][2]*B[2][2];
B2[2][0] = B[2][0]*B[0][0]+B[2][1]*B[1][0]+B[2][2]*B[2][0];
B2[2][1] = B[2][0]*B[0][1]+B[2][1]*B[1][1]+B[2][2]*B[2][1];
B2[2][2] = B[2][0]*B[0][2]+B[2][1]*B[1][2]+B[2][2]*B[2][2];
// calculate Ba
vec3d Ba;
Ba.x = B[0][0]*a.x + B[0][1]*a.y + B[0][2]*a.z;
Ba.y = B[1][0]*a.x + B[1][1]*a.y + B[1][2]*a.z;
Ba.z = B[2][0]*a.x + B[2][1]*a.y + B[2][2]*a.z;
//compute invariants
double I1,I3,I4,I5;
I1 = B[0][0]+B[1][1]+B[2][2];
I3=J*J;
I4 = lam*lam;;
I5 = I4*(a*Ba);
// lame parameters
double m_gp=m_Ep/(2*(1+m_vp));
double m_lamp=-((m_Ep*(m_Ez*m_vp + m_Ep*m_vz*m_vz))/((1 + m_vp)*(m_Ez*(-1 + m_vp) + 2*m_Ep*m_vz*m_vz)));
double m_lamz=(m_Ez*m_Ez*(-1 + m_vp*m_vp) - m_Ep*(m_Ep + 4*(m_gp + m_gz)*(1 + m_vp))*m_vz*m_vz + m_Ez*(2*m_gz - m_Ep*m_vp - 2*m_gz*m_vp*m_vp - 2*m_gp*(-1 + m_vp*m_vp) + 2*m_Ep*m_vz + 2*m_Ep*m_vp*m_vz))/((1 + m_vp)*(m_Ez*(-1 + m_vp) + 2*m_Ep*m_vz*m_vz));
double m_alpha=(m_Ep*(m_Ep*m_vz*m_vz - m_Ez*(m_vp*(-1 + m_vz) + m_vz)))/((1 + m_vp)*(m_Ez*(-1 + m_vp) + 2*m_Ep*m_vz*m_vz));
//trans iso
double D[6][6] = {0};
D[0][0]=(2*a.x*a.x*B[0][0]*(m_alpha + 2*m_gz)*I4 + m_gp*(2 - 4*a.x*a.x*B[0][0]*I4 + 4*a.x*a.x*a.x*a.x*I4*I4) + J*m_lamp + a.x*a.x*a.x*a.x*(2*m_gz - 4*m_gz*I4*I4 + lam*m_lamz))/J;
D[0][1]=(a.y*a.y*m_alpha*B[0][0]*I4 + 4*a.x*a.y*B[0][1]*(-m_gp + m_gz)*I4 - J*m_lamp + 2*I3*m_lamp + a.x*a.x*(m_alpha*B[1][1]*I4 + a.y*a.y*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
D[0][2]=(a.z*a.z*m_alpha*B[0][0]*I4 + 4*a.x*a.z*B[0][2]*(-m_gp + m_gz)*I4 - J*m_lamp + 2*I3*m_lamp + a.x*a.x*(m_alpha*B[2][2]*I4 + a.z*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
D[0][3]=(a.x*(a.y*B[0][0]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.x*B[0][1]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.x*a.x*a.y*(4*m_gp*I4*I4 + m_gz*(2 - 4*I4*I4) + lam*m_lamz)))/J;
D[0][4]=(a.x*(a.z*B[0][0]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.x*B[0][2]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.x*a.x*a.z*(4*m_gp*I4*I4 + m_gz*(2 - 4*I4*I4) + lam*m_lamz)))/J;
D[0][5]=(a.y*a.z*m_alpha*B[0][0]*I4 - 2*a.x*(a.z*B[0][1] + a.y*B[0][2])*(m_gp - m_gz)*I4 + a.x*a.x*(m_alpha*B[1][2]*I4 + a.y*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
D[1][1]=(2*a.y*a.y*B[1][1]*(m_alpha + 2*m_gz)*I4 + m_gp*(2 - 4*a.y*a.y*B[1][1]*I4 + 4*a.y*a.y*a.y*a.y*I4*I4) + J*m_lamp + a.y*a.y*a.y*a.y*(2*m_gz - 4*m_gz*I4*I4 + lam*m_lamz))/J;
D[1][2]=(a.z*a.z*m_alpha*B[1][1]*I4 + 4*a.y*a.z*B[1][2]*(-m_gp + m_gz)*I4 - J*m_lamp + 2*I3*m_lamp + a.y*a.y*(m_alpha*B[2][2]*I4 + a.z*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
D[1][3]=(a.y*(a.y*B[0][1]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.x*(B[1][1]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.y*a.y*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz))))/J;
D[1][4]=(a.y*(a.y*m_alpha*B[0][2] + 2*a.z*B[0][1]*(-m_gp + m_gz))*I4 + a.x*(a.z*m_alpha*B[1][1]*I4 + 2*a.y*B[1][2]*(-m_gp + m_gz)*I4 + a.y*a.y*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
D[1][5]=(a.y*(a.z*B[1][1]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.y*B[1][2]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.y*a.y*a.z*(4*m_gp*I4*I4 + m_gz*(2 - 4*I4*I4) + lam*m_lamz)))/J;
D[2][2]=(2*a.z*a.z*B[2][2]*(m_alpha + 2*m_gz)*I4 + m_gp*(2 - 4*a.z*a.z*B[2][2]*I4 + 4*a.z*a.z*a.z*a.z*I4*I4) + J*m_lamp + a.z*a.z*a.z*a.z*(2*m_gz - 4*m_gz*I4*I4 + lam*m_lamz))/J;
D[2][3]=(a.z*(a.z*m_alpha*B[0][1] + 2*a.y*B[0][2]*(-m_gp + m_gz))*I4 + a.x*(2*a.z*B[1][2]*(-m_gp + m_gz)*I4 + a.y*(m_alpha*B[2][2]*I4 + a.z*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz))))/J;
D[2][4]=(a.z*(a.z*B[0][2]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.x*(B[2][2]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.z*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz))))/J;
D[2][5]=(a.z*(a.z*B[1][2]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.y*(B[2][2]*(m_alpha - 2*m_gp + 2*m_gz)*I4 + a.z*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz))))/J;
D[3][3]=(a.y*a.y*B[0][0]*m_gz*I4 + 2*a.x*a.y*B[0][1]*(m_alpha + m_gz)*I4 - m_gp*(-1 + 2*a.x*a.y*B[0][1]*I4 + a.x*a.x*B[1][1]*I4 + a.y*a.y*I4*(B[0][0] - 4*a.x*a.x*I4)) + J*m_lamp - I3*m_lamp + a.x*a.x*(B[1][1]*m_gz*I4 + a.y*a.y*(2*m_gz - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
D[3][4]=(a.y*a.z*B[0][0]*(-m_gp + m_gz)*I4 + a.x*(a.z*B[0][1] + a.y*B[0][2])*(m_alpha - m_gp + m_gz)*I4 + a.x*a.x*(B[1][2]*(-m_gp + m_gz)*I4 + a.y*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
D[3][5]=(a.y*(a.y*B[0][2]*(-m_gp + m_gz) + a.z*B[0][1]*(m_alpha - m_gp + m_gz))*I4 + a.x*(a.z*B[1][1]*(-m_gp + m_gz)*I4 + a.y*B[1][2]*(m_alpha - m_gp + m_gz)*I4 + a.y*a.y*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
D[4][4]=(a.z*a.z*B[0][0]*m_gz*I4 + 2*a.x*a.z*B[0][2]*(m_alpha + m_gz)*I4 - m_gp*(-1 + 2*a.x*a.z*B[0][2]*I4 + a.x*a.x*B[2][2]*I4 + a.z*a.z*I4*(B[0][0] - 4*a.x*a.x*I4)) + J*m_lamp - I3*m_lamp + a.x*a.x*(B[2][2]*m_gz*I4 + a.z*a.z*(2*m_gz - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
D[4][5]=(a.z*(a.z*B[0][1]*(-m_gp + m_gz) + a.y*B[0][2]*(m_alpha - m_gp + m_gz))*I4 + a.x*(a.z*B[1][2]*(m_alpha - m_gp + m_gz)*I4 + a.y*(B[2][2]*(-m_gp + m_gz)*I4 + a.z*a.z*(2*m_gz + 4*m_gp*I4*I4 - 4*m_gz*I4*I4 + lam*m_lamz))))/J;
D[5][5]=(a.z*a.z*B[1][1]*m_gz*I4 + 2*a.y*a.z*B[1][2]*(m_alpha + m_gz)*I4 - m_gp*(-1 + 2*a.y*a.z*B[1][2]*I4 + a.y*a.y*B[2][2]*I4 + a.z*a.z*I4*(B[1][1] - 4*a.y*a.y*I4)) + J*m_lamp - I3*m_lamp + a.y*a.y*(B[2][2]*m_gz*I4 + a.z*a.z*(2*m_gz - 4*m_gz*I4*I4 + lam*m_lamz)))/J;
// set symmetric components
D[1][0] = D[0][1]; D[2][0] = D[0][2]; D[3][0] = D[0][3]; D[4][0] = D[0][4]; D[5][0] = D[0][5];
D[2][1] = D[1][2]; D[3][1] = D[1][3]; D[4][1] = D[1][4]; D[5][1] = D[1][5];
D[3][2] = D[2][3]; D[4][2] = D[2][4]; D[5][2] = D[2][5];
D[4][3] = D[3][4]; D[5][3] = D[3][5];
D[5][4] = D[4][5];
/*
FILE* fp = fopen("C.txt", "wt");
int i, j;
for (i=0; i<6; ++i)
{
for (j=0; j<6; ++j) fprintf(fp, "%15.7lg ", D[i][j]);
fprintf(fp, "\n");
}
fclose(fp);
*/
//the following code is used for testing purposes and replaces the above stiffness when testing
//comment out for normal use
//constant trans iso
//D[0][0]=2*m_gp + m_lamp;
//D[0][1]=m_lamp;
//D[0][2]=m_alpha + m_lamp;
//D[0][3]=0;
//D[0][4]=0;
//D[0][5]=0;
//D[1][1]=2*m_gp + m_lamp;
//D[1][2]=m_alpha + m_lamp;
//D[1][3]=0;
//D[1][4]=0;
//D[1][5]=0;
//D[2][2]=2*m_alpha + 2*m_gp + 2*m_gz + m_lamp + m_lamz;
//D[2][3]=0;
//D[2][4]=0;
//D[2][5]=0;
//D[3][3]=m_gp;
//D[3][4]=0;
//D[3][5]=0;
//D[4][4]=m_gz;
//D[4][5]=0;
//D[5][5]=m_gz;
//compressible neohookean
//D[0][0]=(2*m_gp + m_lamp - m_lamp*log(I3))/J;
//D[0][1]=m_lamp/J;
//D[0][2]=m_lamp/J;
//D[0][3]=0;
//D[0][4]=0;
//D[0][5]=0;
//D[1][1]=(2*m_gp + m_lamp - m_lamp*log(I3))/J;
//D[1][2]=m_lamp/J;
//D[1][3]=0;
//D[1][4]=0;
//D[1][5]=0;
//D[2][2]=(2*m_gp + m_lamp - m_lamp*log(I3))/J;
//D[2][3]=0;
//D[2][4]=0;
//D[2][5]=0;
//D[3][3]=(m_gp - (m_lamp*log(I3))/2.)/J;
//D[3][4]=0;
//D[3][5]=0;
//D[4][4]=(m_gp - (m_lamp*log(I3))/2.)/J;
//D[4][5]=0;
//D[5][5]=(m_gp - (m_lamp*log(I3))/2.)/J;
//identity
//D[0][0]=1;
//D[0][1]=0;
//D[0][2]=0;
//D[0][3]=0;
//D[0][4]=0;
//D[0][5]=0;
//D[1][1]=1;
//D[1][2]=0;
//D[1][3]=0;
//D[1][4]=0;
//D[1][5]=0;
//D[2][2]=1;
//D[2][3]=0;
//D[2][4]=0;
//D[2][5]=0;
//D[3][3]=1;
//D[3][4]=0;
//D[3][5]=0;
//D[4][4]=1;
//D[4][5]=0;
//D[5][5]=1;
return tens4ds(D);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidAngularDamper.h | .h | 2,564 | 77 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FERigidConnector.h"
//-----------------------------------------------------------------------------
//! The FERigidAngularDamper class implements an angular damper that connects
//! two rigid bodies.
class FERigidAngularDamper : public FERigidConnector
{
public:
//! constructor
FERigidAngularDamper(FEModel* pfem);
//! destructor
~FERigidAngularDamper() {}
//! initialization
bool Init() override;
//! calculates the joint forces
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
//! calculates the joint stiffness
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
//! calculate Lagrangian augmentation
bool Augment(int naug, const FETimeInfo& tp) override;
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! update state
void Update() override;
//! Reset data
void Reset() override;
//! evaluate relative translation
vec3d RelativeTranslation(const bool global) override;
//! evaluate relative rotation
vec3d RelativeRotation(const bool global) override;
public: // parameters
double m_c; //! damping constant
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEReactivePlasticity.h | .h | 3,408 | 94 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
#include "FEDamageCriterion.h"
#include "FEDamageCDF.h"
#include "FEPlasticFlowCurve.h"
#include "FEReactivePlasticityMaterialPoint.h"
//-----------------------------------------------------------------------------
// This material models reactive plasticity in any hyper-elastic materials.
class FEReactivePlasticity : public FEElasticMaterial
{
public:
FEReactivePlasticity(FEModel* pfem);
public:
//! data initialization and checking
bool Init() override;
//! serialiation
void Serialize(DumpStream& ar) override;
//! calculate stress at material point
mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! evaluate elastic deformation gradient
void ElasticDeformationGradient(FEMaterialPoint& pt);
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
// get the elastic material
FEElasticMaterial* GetElasticMaterial() override { return m_pBase; }
// get the yield surface normal
mat3ds YieldSurfaceNormal(FEMaterialPoint& mp);
// evaluate octahedral plastic strain
void OctahedralPlasticStrain(FEMaterialPoint& pt);
// evaluate reactive heat supply
void ReactiveHeatSupplyDensity(FEMaterialPoint& pt);
bool UseSecantTangent() override { return m_secant_tangent; }
void UpdateSpecializedMaterialPoints(FEMaterialPoint& pt, const FETimeInfo& tp) override;
public:
FEElasticMaterial* m_pBase; // base elastic material
FEDamageCriterion* m_pCrit; // damage criterion
FEPlasticFlowCurve* m_pFlow; // plastic flow curve
public:
bool m_isochrc; // flag for constraining plastic def grad to be isochoric
double m_rtol; // user-defined relative tolerance
bool m_secant_tangent;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledViscoElasticMaterial.h | .h | 3,014 | 85 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
#include "FEViscoElasticMaterial.h"
//-----------------------------------------------------------------------------
//! This class implements a large deformation uncoupled visco-elastic material
//
class FEUncoupledViscoElasticMaterial : public FEUncoupledMaterial
{
public:
// NOTE: make sure that this parameter is the
// same as the MAX_TERMS in the FEViscoElasticMaterialPoint class
enum { MAX_TERMS = FEViscoElasticMaterialPoint::MAX_TERMS };
public:
//! default constructor
FEUncoupledViscoElasticMaterial(FEModel* pfem);
// get the elastic base material
FEUncoupledMaterial* GetBaseMaterial() { return m_pBase; }
// set the elastic base material
void SetBaseMaterial(FEUncoupledMaterial* pbase) { m_pBase = pbase; }
public:
//! data initialization and checking
bool Init() override;
//! deviatoric stress function
mat3ds DevStress(FEMaterialPoint& pt) override;
//! deviatoric tangent function
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! deviatoric strain energy density function
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
//! calculate exponent of right-stretch tensor in series spring
bool SeriesStretchExponent(FEMaterialPoint& pt);
//! returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
public:
double m_t[MAX_TERMS]; //!< relaxation times
double m_g0; //!< intitial visco-elastic coefficient
double m_g[MAX_TERMS]; //!< visco-elastic coefficients
private:
FEUncoupledMaterial* m_pBase; //!< pointer to elastic solid material
bool m_binit; //!< initialization flag
public:
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FENeoHookean.h | .h | 2,395 | 65 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! Neo Hookean material
//! Implementation of a neo-Hookean hyperelastic material.
class FEBIOMECH_API FENeoHookean : public FEElasticMaterial
{
public:
FENeoHookean(FEModel* pfem);
public:
FEParamDouble m_E; //!< Young's modulus
FEParamDouble m_v; //!< Poisson's ratio
public:
//! calculate stress at material point
virtual mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
virtual tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
virtual double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! calculate the 2nd Piola-Kirchhoff stress at material point
mat3ds PK2Stress(FEMaterialPoint& pt, const mat3ds E) override;
//! calculate material tangent stiffness at material point
tens4dmm MaterialTangent(FEMaterialPoint& pt, const mat3ds E) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FENodalTargetForce.h | .h | 1,789 | 53 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FENodalLoad.h>
#include "febiomech_api.h"
class FEBIOMECH_API FENodalTargetForce : public FENodalLoad
{
public:
FENodalTargetForce(FEModel* fem);
void Activate() override;
protected: // required functions of FENodalLoad
// Set the dof list
bool SetDofList(FEDofList& dofList) override;
// get the nodal values
void GetNodalValues(int inode, std::vector<double>& val) override;
private:
double m_w;
FEParamVec3 m_f;
bool m_shellBottom;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEReactiveFatigueMaterialPoint.cpp | .cpp | 7,032 | 238 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2022 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "FEReactiveFatigueMaterialPoint.h"
#include <FECore/DumpStream.h>
////////////////////// FATIGUE BOND /////////////////////////////////
FatigueBond::FatigueBond()
{
m_wft = m_wfp = m_Xfmax = m_Xftrl = m_Fft = m_Ffp = m_time = 0;
m_erase = false;
}
FatigueBond::FatigueBond(const FatigueBond& fb)
{
m_wft = fb.m_wft;
m_wfp = fb.m_wfp;
m_Xfmax = fb.m_Xfmax;
m_Xftrl = fb.m_Xftrl;
m_Fft = fb.m_Fft;
m_Ffp = fb.m_Ffp;
m_time = fb.m_time;
m_erase = fb.m_erase;
}
FatigueBond::FatigueBond(FatigueBond& fb)
{
m_wft = fb.m_wft;
m_wfp = fb.m_wfp;
m_Xfmax = fb.m_Xfmax;
m_Xftrl = fb.m_Xftrl;
m_Fft = fb.m_Fft;
m_Ffp = fb.m_Ffp;
m_time = fb.m_time;
m_erase = fb.m_erase;
}
void FatigueBond::Update()
{
m_wfp = m_wft;
m_Ffp = m_Fft;
if (m_Xftrl > m_Xfmax) m_Xfmax = m_Xftrl;
}
////////////////////// FATIGUE MATERIAL POINT /////////////////////////////////
//-----------------------------------------------------------------------------
// default constructor
FEReactiveFatigueMaterialPoint::FEReactiveFatigueMaterialPoint(FEMaterialPointData*pt) : FEDamageMaterialPoint(pt)
{
m_D = 0;
m_wit = 1;
m_wip = 1;
m_Ximax = 0;
m_Xitrl = 0;
m_Xip = 0;
m_aXit = 0;
m_aXip = 0;
m_Fit = 0;
m_Fip = 0;
m_wbt = 0;
m_wbp = 0;
m_wft = 0;
m_wfp = 0;
m_fb.clear();
}
//-----------------------------------------------------------------------------
// copy constructor
FEReactiveFatigueMaterialPoint::FEReactiveFatigueMaterialPoint(const FEReactiveFatigueMaterialPoint& rfmp) : FEDamageMaterialPoint(rfmp)
{
m_D = rfmp.m_D;
m_wit = rfmp.m_wit;
m_wip = rfmp.m_wip;
m_Ximax = rfmp.m_Ximax;
m_Xitrl = rfmp.m_Xitrl;
m_Xip = rfmp.m_Xip;
m_aXit = rfmp.m_aXit;
m_aXip = rfmp.m_aXip;
m_Fit = rfmp.m_Fit;
m_Fip = rfmp.m_Fip;
m_wbt = rfmp.m_wbt;
m_wbp = rfmp.m_wbp;
m_wft = rfmp.m_wft;
m_wfp = rfmp.m_wfp;
m_fb.clear();
for (int ig=0; ig<m_fb.size(); ++ig)
m_fb.push_back(rfmp.m_fb[ig]);
}
FEReactiveFatigueMaterialPoint::FEReactiveFatigueMaterialPoint(FEReactiveFatigueMaterialPoint& rfmp) : FEDamageMaterialPoint(rfmp)
{
m_D = rfmp.m_D;
m_wit = rfmp.m_wit;
m_wip = rfmp.m_wip;
m_Ximax = rfmp.m_Ximax;
m_Xitrl = rfmp.m_Xitrl;
m_Xip = rfmp.m_Xip;
m_aXit = rfmp.m_aXit;
m_aXip = rfmp.m_aXip;
m_Fit = rfmp.m_Fit;
m_Fip = rfmp.m_Fip;
m_wbt = rfmp.m_wbt;
m_wbp = rfmp.m_wbp;
m_wft = rfmp.m_wft;
m_wfp = rfmp.m_wfp;
m_fb.clear();
for (int ig=0; ig<m_fb.size(); ++ig)
m_fb.push_back(rfmp.m_fb[ig]);
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEReactiveFatigueMaterialPoint::Copy()
{
FEReactiveFatigueMaterialPoint* pt = new FEReactiveFatigueMaterialPoint(*this);
if (m_pNext) pt->m_pNext = m_pNext->Copy();
return pt;
}
//-----------------------------------------------------------------------------
void FEReactiveFatigueMaterialPoint::Init()
{
FEMaterialPointData::Init();
// intialize total damate
m_D = 0;
// initialize intact bond fraction to 1
m_wip = m_wit = 1.0;
// initialize intact damage criterion
m_Ximax = m_Xitrl = m_Xip = 0;
m_Fip = m_Fit = 0;
// initialize broken and fatigue bond fraction to 0
m_wbp = m_wbt = m_wfp = m_wft = 0;
// clear the fatigue bond structure
m_fb.clear();
}
//-----------------------------------------------------------------------------
void FEReactiveFatigueMaterialPoint::Update(const FETimeInfo& timeInfo)
{
FEMaterialPointData::Update(timeInfo);
// update damage response for fatigues bonds
for (int ig=0; ig<m_fb.size(); ++ig) m_fb[ig].Update();
// let's check overlapping generations of fatigued bonds
if (m_fb.size() > 1) {
for (int ig=0; ig < m_fb.size() - 1; ++ig) {
double Xfmax = m_fb[ig].m_Xfmax;
if (Xfmax <= m_fb.back().m_Xftrl) {
m_fb.back().m_wft += m_fb[ig].m_wft;
m_fb.back().m_wfp += m_fb[ig].m_wfp;
m_fb[ig].m_erase = true;
}
}
}
// cull generations that have been marked for erasure
std::deque<FatigueBond>::iterator it = m_fb.begin();
while (it != m_fb.end()) {
if (it->m_erase) it = m_fb.erase(it);
else ++it;
}
// update damage response for intact bonds
if (m_Xitrl > m_Ximax) m_Ximax = m_Xitrl;
m_Xip = m_Xitrl;
m_aXip = m_aXit;
m_Fip = m_Fit;
// update intact and damage bonds
m_wip = m_wit;
m_wbp = m_wbt;
m_wfp = m_wft;
}
//-----------------------------------------------------------------------------
void FEReactiveFatigueMaterialPoint::Serialize(DumpStream& ar)
{
FEDamageMaterialPoint::Serialize(ar);
ar & m_wit & m_wip & m_Ximax & m_Xitrl & m_Xip & m_aXit & m_aXip & m_Fit & m_Fip;
ar & m_wbt & m_wbp & m_wfp & m_wft;
// handle deques and boolean
if (ar.IsSaving()) {
int n = (int)m_fb.size();
ar << n;
for (int i=0; i<n; ++i) {
ar << m_fb[i].m_wft << m_fb[i].m_wfp;
ar << m_fb[i].m_Xfmax << m_fb[i].m_Xftrl;
ar << m_fb[i].m_Fft << m_fb[i].m_Ffp;
ar << m_fb[i].m_time << m_fb[i].m_erase;
}
} else {
int n;
ar >> n;
m_fb.clear();
for (int i=0; i<n; ++i) {
FatigueBond fb;
ar >> fb.m_wft >> fb.m_wfp;
ar >> fb.m_Xfmax >> fb.m_Xftrl;
ar >> fb.m_Fft >> fb.m_Ffp;
ar >> fb.m_time >> fb.m_erase;
m_fb.push_back(fb);
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledViscoElasticDamage.h | .h | 2,937 | 80 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEViscoElasticMaterial.h"
#include "FEDamageMaterialUC.h"
//-----------------------------------------------------------------------------
//! This class implements a large deformation visco-elastic material
//
class FEUncoupledViscoElasticDamage : public FEUncoupledMaterial
{
public:
// NOTE: make sure that this parameter is the
// same as the MAX_TERMS in the FEViscoElasticMaterialPoint class
enum { MAX_TERMS = FEViscoElasticMaterialPoint::MAX_TERMS };
public:
//! default constructor
FEUncoupledViscoElasticDamage(FEModel* pfem);
public:
//! initialization
bool Init() override;
//! stress function
mat3ds DevStress(FEMaterialPoint& pt) override;
//! tangent function
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! strain energy density
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
//! calculate exponent of right-stretch tensor in series spring
bool SeriesStretchExponent(FEMaterialPoint& pt);
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
public:
// material parameters
double m_g0; //!< intitial visco-elastic coefficient
double m_g[MAX_TERMS]; //!< visco-elastic coefficients
double m_t[MAX_TERMS]; //!< relaxation times
private:
bool m_binit; //!< initialization flag
FEDamageMaterialUC* m_pDmg; //!< pointer to uncoupled elastic damage material
public:
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FESolidSolver.h | .h | 3,924 | 133 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FECore/FENewtonSolver.h"
#include <FECore/FETimeInfo.h>
#include "FECore/FEGlobalVector.h"
#include "FERigidSolver.h"
#include <FECore/FEDofList.h>
//-----------------------------------------------------------------------------
//! The FESolidSolver class solves large deformation solid mechanics problems
//! It can deal with quasi-static and dynamic problems
//!
class FESolidSolver : public FENewtonSolver
{
public:
//! constructor
FESolidSolver(FEModel* pfem);
//! destructor
virtual ~FESolidSolver();
//! serialize data to/from dump file
void Serialize(DumpStream& ar) override;
//! Initializes data structures
bool Init() override;
//! Initialize linear equation system
bool InitEquations() override;
// get the rigid solver
FERigidSolver* GetRigidSolver() { return &m_rigidSolver; }
public:
//{ --- evaluation and update ---
//! Perform an update
void Update(vector<double>& ui) override;
//}
//{ --- Solution functions ---
//! prepares the data for the first QN iteration
void PrepStep() override;
//! Performs a Newton-Raphson iteration
bool Quasin() override;
//! update nodal positions, velocities, accelerations, etc.
virtual void UpdateKinematics(vector<double>& ui);
//}
//{ --- Stiffness matrix routines ---
//! calculates the global stiffness matrix
virtual bool StiffnessMatrix() override;
//! contact stiffness
void ContactStiffness(FELinearSystem& LS);
//! calculates stiffness contributon of nonlinear constraints
void NonLinearConstraintStiffness(FELinearSystem& LS, const FETimeInfo& tp);
//}
//{ --- Residual routines ---
//! Calculate inertial forces for dynamic problems
void InertialForces(FEGlobalVector& R);
//! Calculate the contact forces
void ContactForces(FEGlobalVector& R);
//! Calculates residual
virtual bool Residual(vector<double>& R) override;
//! Calculate nonlinear constraint forces
void NonLinearConstraintForces(FEGlobalVector& R, const FETimeInfo& tp);
//}
public:
// convergence tolerances
double m_Dtol; //!< displacement tolerance
// equation numbers
int m_nreq; //!< start of rigid body equations
// Newmark parameters (for dynamic analyses)
double m_beta; //!< Newmark parameter beta (displacement integration)
double m_gamma; //!< Newmark parameter gamme (velocity integration)
public:
vector<double> m_Fr; //!< nodal reaction forces
public:
bool m_bnew_update; //!< use new rigid body update algorithm
protected:
FEDofList m_dofU, m_dofV, m_dofSU, m_dofRQ;
protected:
FERigidSolverOld m_rigidSolver;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidDamper.cpp | .cpp | 12,405 | 377 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FERigidDamper.h"
#include "FERigidBody.h"
#include "FECore/log.h"
#include "FECore/FEAnalysis.h"
#include "FECore/FEMaterial.h"
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidDamper, FERigidConnector);
ADD_PARAMETER(m_c , "c" );
ADD_PARAMETER(m_a0 , "insertion_a");
ADD_PARAMETER(m_b0 , "insertion_b");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidDamper::FERigidDamper(FEModel* pfem) : FERigidConnector(pfem)
{
m_nID = m_ncount++;
m_c = 1.0;
}
//-----------------------------------------------------------------------------
//! TODO: This function is called twice: once in the Init and once in the Solve
//! phase. Is that necessary?
bool FERigidDamper::Init()
{
// reset force
m_F = vec3d(0,0,0);
// base class first
if (FERigidConnector::Init() == false) return false;
// set spring insertions relative to rigid body center of mass
m_qa0 = m_a0 - m_rbA->m_r0;
m_qb0 = m_b0 - m_rbB->m_r0;
m_at = m_a0;
m_bt = m_b0;
return true;
}
//-----------------------------------------------------------------------------
void FERigidDamper::Serialize(DumpStream& ar)
{
FERigidConnector::Serialize(ar);
ar & m_qa0 & m_qb0;
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidDamper::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
vector<double> fa(6);
vector<double> fb(6);
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
double alpha = tp.alphaf;
// body A
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
vec3d za = zat*alpha + zap*(1-alpha);
vec3d vat = RBa.m_vt + (RBa.m_wt ^ zat);
vec3d vap = RBa.m_vp + (RBa.m_wp ^ zap);
vec3d va = vat*alpha + vap*(1-alpha);
// body b
vec3d zbt = m_qb0; RBb.GetRotation().RotateVector(zbt);
vec3d zbp = m_qb0; RBb.m_qp.RotateVector(zbp);
vec3d zb = zbt*alpha + zbp*(1-alpha);
vec3d vbt = RBb.m_vt + (RBb.m_wt ^ zbt);
vec3d vbp = RBb.m_vp + (RBb.m_wp ^ zbp);
vec3d vb = vbt*alpha + vbp*(1-alpha);
m_F = (vb - va)*m_c;
fa[0] = m_F.x;
fa[1] = m_F.y;
fa[2] = m_F.z;
fa[3] = za.y*m_F.z-za.z*m_F.y;
fa[4] = za.z*m_F.x-za.x*m_F.z;
fa[5] = za.x*m_F.y-za.y*m_F.x;
fb[0] = -m_F.x;
fb[1] = -m_F.y;
fb[2] = -m_F.z;
fb[3] = -zb.y*m_F.z+zb.z*m_F.y;
fb[4] = -zb.z*m_F.x+zb.x*m_F.z;
fb[5] = -zb.x*m_F.y+zb.y*m_F.x;
for (int i=0; i<6; ++i) if (RBa.m_LM[i] >= 0) R[RBa.m_LM[i]] += fa[i];
for (int i=0; i<6; ++i) if (RBb.m_LM[i] >= 0) R[RBb.m_LM[i]] += fb[i];
RBa.m_Fr -= vec3d(fa[0],fa[1],fa[2]);
RBa.m_Mr -= vec3d(fa[3],fa[4],fa[5]);
RBb.m_Fr -= vec3d(fb[0],fb[1],fb[2]);
RBb.m_Mr -= vec3d(fb[3],fb[4],fb[5]);
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidDamper::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
double alpha = tp.alphaf;
double beta = tp.beta;
double gamma = tp.gamma;
// get time increment
double dt = tp.timeIncrement;
vector<int> LM(12);
FEElementMatrix ke; ke.resize(12, 12);
ke.zero();
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
mat3dd I(1);
// body A
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
vec3d za = zat*alpha + zap*(1-alpha);
mat3d zahat; zahat.skew(za);
mat3d zathat; zathat.skew(zat);
vec3d vat = RBa.m_vt + (RBa.m_wt ^ zat);
vec3d vap = RBa.m_vp + (RBa.m_wp ^ zap);
vec3d va = vat*alpha + vap*(1-alpha);
quatd qai = RBa.GetRotation()*RBa.m_qp.Inverse(); qai.MakeUnit();
vec3d cai = qai.GetVector()*(2*tan(qai.GetAngle()/2));
mat3d Ta = I + skew(cai)/2 + dyad(cai)/4;
// body b
vec3d zbt = m_qb0; RBb.GetRotation().RotateVector(zbt);
vec3d zbp = m_qb0; RBb.m_qp.RotateVector(zbp);
vec3d zb = zbt*alpha + zbp*(1-alpha);
mat3d zbhat; zbhat.skew(zb);
mat3d zbthat; zbthat.skew(zbt);
vec3d vbt = RBb.m_vt + (RBb.m_wt ^ zbt);
vec3d vbp = RBb.m_vp + (RBb.m_wp ^ zbp);
vec3d vb = vbt*alpha + vbp*(1-alpha);
quatd qbi = RBb.GetRotation()*RBb.m_qp.Inverse(); qbi.MakeUnit();
vec3d cbi = qbi.GetVector()*(2*tan(qbi.GetAngle()/2));
mat3d Tb = I + skew(cbi)/2 + dyad(cbi)/4;
m_F = (vb - va)*m_c;
mat3ds A = I*(gamma/beta/dt);
mat3d Ba = zathat*Ta.transpose()*(gamma/beta/dt) + skew(RBa.m_wt)*zathat;
mat3d Bb = zbthat*Tb.transpose()*(gamma/beta/dt) + skew(RBb.m_wt)*zbthat;
mat3d K;
// (1,1)
K = A*(alpha*m_c);
ke[0][0] = K[0][0]; ke[0][1] = K[0][1]; ke[0][2] = K[0][2];
ke[1][0] = K[1][0]; ke[1][1] = K[1][1]; ke[1][2] = K[1][2];
ke[2][0] = K[2][0]; ke[2][1] = K[2][1]; ke[2][2] = K[2][2];
// (1,2)
K = Ba*(-alpha*m_c);
ke[0][3] = K[0][0]; ke[0][4] = K[0][1]; ke[0][5] = K[0][2];
ke[1][3] = K[1][0]; ke[1][4] = K[1][1]; ke[1][5] = K[1][2];
ke[2][3] = K[2][0]; ke[2][4] = K[2][1]; ke[2][5] = K[2][2];
// (1,3)
K = A*(-alpha*m_c);
ke[0][6] = K[0][0]; ke[0][7] = K[0][1]; ke[0][8] = K[0][2];
ke[1][6] = K[1][0]; ke[1][7] = K[1][1]; ke[1][8] = K[1][2];
ke[2][6] = K[2][0]; ke[2][7] = K[2][1]; ke[2][8] = K[2][2];
// (1,4)
K = Bb*(alpha*m_c);
ke[0][9] = K[0][0]; ke[0][10] = K[0][1]; ke[0][11] = K[0][2];
ke[1][9] = K[1][0]; ke[1][10] = K[1][1]; ke[1][11] = K[1][2];
ke[2][9] = K[2][0]; ke[2][10] = K[2][1]; ke[2][11] = K[2][2];
// (2,1)
K = zahat*A*(alpha*m_c);
ke[3][0] = K[0][0]; ke[3][1] = K[0][1]; ke[3][2] = K[0][2];
ke[4][0] = K[1][0]; ke[4][1] = K[1][1]; ke[4][2] = K[1][2];
ke[5][0] = K[2][0]; ke[5][1] = K[2][1]; ke[5][2] = K[2][2];
// (2,2)
K = (zahat*Ba)*(-alpha*m_c);
ke[3][3] = K[0][0]; ke[3][4] = K[0][1]; ke[3][5] = K[0][2];
ke[4][3] = K[1][0]; ke[4][4] = K[1][1]; ke[4][5] = K[1][2];
ke[5][3] = K[2][0]; ke[5][4] = K[2][1]; ke[5][5] = K[2][2];
// (2,3)
K = zahat*A*(-alpha*m_c);
ke[3][6] = K[0][0]; ke[3][7] = K[0][1]; ke[3][8] = K[0][2];
ke[4][6] = K[1][0]; ke[4][7] = K[1][1]; ke[4][8] = K[1][2];
ke[5][6] = K[2][0]; ke[5][7] = K[2][1]; ke[5][8] = K[2][2];
// (2,4)
K = (zahat*Bb)*(alpha*m_c);
ke[3][9] = K[0][0]; ke[3][10] = K[0][1]; ke[3][11] = K[0][2];
ke[4][9] = K[1][0]; ke[4][10] = K[1][1]; ke[4][11] = K[1][2];
ke[5][9] = K[2][0]; ke[5][10] = K[2][1]; ke[5][11] = K[2][2];
// (3,1)
K = A*(-alpha*m_c);
ke[6][0] = K[0][0]; ke[6][1] = K[0][1]; ke[6][2] = K[0][2];
ke[7][0] = K[1][0]; ke[7][1] = K[1][1]; ke[7][2] = K[1][2];
ke[8][0] = K[2][0]; ke[8][1] = K[2][1]; ke[8][2] = K[2][2];
// (3,2)
K = Ba*(alpha*m_c);
ke[6][3] = K[0][0]; ke[6][4] = K[0][1]; ke[6][5] = K[0][2];
ke[7][3] = K[1][0]; ke[7][4] = K[1][1]; ke[7][5] = K[1][2];
ke[8][3] = K[2][0]; ke[8][4] = K[2][1]; ke[8][5] = K[2][2];
// (3,3)
K = A*(alpha*m_c);
ke[6][6] = K[0][0]; ke[6][7] = K[0][1]; ke[6][8] = K[0][2];
ke[7][6] = K[1][0]; ke[7][7] = K[1][1]; ke[7][8] = K[1][2];
ke[8][6] = K[2][0]; ke[8][7] = K[2][1]; ke[8][8] = K[2][2];
// (3,4)
K = Bb*(-alpha*m_c);
ke[6][9] = K[0][0]; ke[6][10] = K[0][1]; ke[6][11] = K[0][2];
ke[7][9] = K[1][0]; ke[7][10] = K[1][1]; ke[7][11] = K[1][2];
ke[8][9] = K[2][0]; ke[8][10] = K[2][1]; ke[8][11] = K[2][2];
// (4,1)
K = zbhat*A*(-alpha*m_c);
ke[9 ][0] = K[0][0]; ke[ 9][1] = K[0][1]; ke[ 9][2] = K[0][2];
ke[10][0] = K[1][0]; ke[10][1] = K[1][1]; ke[10][2] = K[1][2];
ke[11][0] = K[2][0]; ke[11][1] = K[2][1]; ke[11][2] = K[2][2];
// (4,2)
K = (zbhat*Ba)*(alpha*m_c);
ke[9 ][3] = K[0][0]; ke[ 9][4] = K[0][1]; ke[ 9][5] = K[0][2];
ke[10][3] = K[1][0]; ke[10][4] = K[1][1]; ke[10][5] = K[1][2];
ke[11][3] = K[2][0]; ke[11][4] = K[2][1]; ke[11][5] = K[2][2];
// (4,3)
K = zbhat*A*(alpha*m_c);
ke[9 ][6] = K[0][0]; ke[ 9][7] = K[0][1]; ke[ 9][8] = K[0][2];
ke[10][6] = K[1][0]; ke[10][7] = K[1][1]; ke[10][8] = K[1][2];
ke[11][6] = K[2][0]; ke[11][7] = K[2][1]; ke[11][8] = K[2][2];
// (4,4)
K = (zbhat*Bb)*(-alpha*m_c);
ke[9 ][9] = K[0][0]; ke[ 9][10] = K[0][1]; ke[ 9][11] = K[0][2];
ke[10][9] = K[1][0]; ke[10][10] = K[1][1]; ke[10][11] = K[1][2];
ke[11][9] = K[2][0]; ke[11][10] = K[2][1]; ke[11][11] = K[2][2];
for (int j=0; j<6; ++j)
{
LM[j ] = RBa.m_LM[j];
LM[j+6] = RBb.m_LM[j];
}
ke.SetIndices(LM);
LS.Assemble(ke);
}
//-----------------------------------------------------------------------------
bool FERigidDamper::Augment(int naug, const FETimeInfo& tp)
{
return true;
}
//-----------------------------------------------------------------------------
void FERigidDamper::Update()
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
const FETimeInfo& tp = GetTimeInfo();
double alpha = tp.alphaf;
// body A
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
vec3d vat = RBa.m_vt + (RBa.m_wt ^ zat);
vec3d vap = RBa.m_vp + (RBa.m_wp ^ zap);
vec3d va = vat*alpha + vap*(1-alpha);
// body b
vec3d zbt = m_qb0; RBb.GetRotation().RotateVector(zbt);
vec3d zbp = m_qb0; RBb.m_qp.RotateVector(zbp);
vec3d vbt = RBb.m_vt + (RBb.m_wt ^ zbt);
vec3d vbp = RBb.m_vp + (RBb.m_wp ^ zbp);
vec3d vb = vbt*alpha + vbp*(1-alpha);
m_at = RBa.m_rt + zat;
m_bt = RBb.m_rt + zbt;
m_F = (vb - va)*m_c;
}
//-----------------------------------------------------------------------------
void FERigidDamper::Reset()
{
m_F = vec3d(0,0,0);
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
m_qa0 = m_a0 - RBa.m_r0;
m_qb0 = m_b0 - RBb.m_r0;
}
//-----------------------------------------------------------------------------
vec3d FERigidDamper::RelativeTranslation(const bool global)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// body A
vec3d ra = RBa.m_rt;
vec3d za = m_qa0; RBa.GetRotation().RotateVector(za);
// body B
vec3d rb = RBb.m_rt;
vec3d zb = m_qb0; RBb.GetRotation().RotateVector(zb);
// relative translation in global coordinate system
vec3d x = rb + zb - ra - za;
return x;
}
//-----------------------------------------------------------------------------
vec3d FERigidDamper::RelativeRotation(const bool global)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// get relative rotation
quatd Q = RBb.GetRotation()*RBa.GetRotation().Inverse(); Q.MakeUnit();
// relative rotation vector
vec3d q = Q.GetRotationVector();
return q;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FE2DTransIsoMooneyRivlin.cpp | .cpp | 8,837 | 353 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include <limits>
#include "FE2DTransIsoMooneyRivlin.h"
#include <FECore/FEConstValueVec3.h>
// define the material parameters
BEGIN_FECORE_CLASS(FE2DTransIsoMooneyRivlin, FEUncoupledMaterial)
ADD_PARAMETER(m_c1, FE_RANGE_GREATER(0.0), "c1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c2, "c2")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_w, 2, "w");
ADD_PARAMETER(m_c3, "c3")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c4, "c4");
ADD_PARAMETER(m_c5, "c5")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_lam1, FE_RANGE_GREATER_OR_EQUAL(1.0), "lam_max");
ADD_PARAMETER(m_a, 2, "a");
ADD_PARAMETER(m_ac, "active_contraction")->setUnits(UNIT_PRESSURE);;
ADD_PROPERTY(m_fiber, "fiber");
END_FECORE_CLASS();
double FE2DTransIsoMooneyRivlin::m_cth[FE2DTransIsoMooneyRivlin::NSTEPS];
double FE2DTransIsoMooneyRivlin::m_sth[FE2DTransIsoMooneyRivlin::NSTEPS];
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
//////////////////////////////////////////////////////////////////////
// FE2DTransIsoMooneyRivlin
//////////////////////////////////////////////////////////////////////
FE2DTransIsoMooneyRivlin::FE2DTransIsoMooneyRivlin(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
static bool bfirst = true;
if (bfirst)
{
double ph;
for (int n=0; n<NSTEPS; ++n)
{
ph = 2.0*PI*n / (double) NSTEPS;
m_cth[n] = cos(ph);
m_sth[n] = sin(ph);
}
bfirst = false;
}
m_c1 = 0;
m_c2 = 0;
m_a[0] = m_a[1] = 1;
m_ac = 0;
m_w[0] = m_w[1] = 1;
m_fiber = nullptr;
m_epsf = 0.;
}
//-----------------------------------------------------------------------------
//! Calculates the deviatoric stress for this material.
//! \param pt material point at which to evaluate the stress
mat3ds FE2DTransIsoMooneyRivlin::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
const double third = 1.0/3.0;
// get the "fiber" direction
vec3d r = m_fiber->unitVector(mp);
// setup a rotation
quatd q(vec3d(1, 0, 0), r);
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
double Jm13 = pow(J, -1.0/3.0);
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
// Note that these are the invariants of deviatoric B, not of B!
double I1 = B.tr();
double I2 = 0.5*(I1*I1 - B2.tr());
// strain energy derivatives
double W1 = m_c1;
double W2 = m_c2;
// --- M A T R I X C O N T R I B U T I O N ---
// calculate T = F*dW/dC*Ft
mat3ds T = B*(W1 + W2*I1) - B2*W2;
// --- F I B E R C O N T R I B U T I O N ---
// Next, we calculate the fiber contribution. For this material
// the fibers lie randomly in a plane that is perpendicular to the transverse
// axis. We therefor need to integrate over this plane.
double w, wtot = 0;
vec3d v;
double lam, lamd, I4, W4;
mat3ds Tf; Tf.zero();
mat3ds N;
for (int n=0; n<NSTEPS; ++n)
{
// calculate the local material fiber vector
v.y = m_cth[n];
v.z = m_sth[n];
v.x = 0;
// calculate the global material fiber vector
vec3d a0 = q*v;
// calculate the global spatial fiber vector
vec3d a = F*a0;
// normalize material axis and store fiber stretch
lam = a.unit();
lamd = lam*Jm13; // i.e. lambda tilde
// fourth invariant of C
I4 = lamd*lamd;
if (lamd > 1)
{
double lamdi = 1.0/lamd;
double Wl;
if (lamd < m_lam1)
{
Wl = lamdi*m_c3*(exp(m_c4*(lamd - 1)) - 1);
}
else
{
double c6 = m_c3*(exp(m_c4*(m_lam1-1))-1) - m_c5*m_lam1;
Wl = lamdi*(m_c5*lamd + c6);
}
W4 = 0.5*lamdi*Wl;
}
else
{
W4 = 0;
}
w = 1.0/sqrt((v.y/m_w[0])*(v.y/m_w[0]) + (v.z/m_w[1])*(v.z/m_w[1]));
wtot += w;
// calculate the stress
N = dyad(a);
Tf += N*(W4*I4*w);
// add active contraction stuff
if (m_ac > 0)
{
// The .5 is to compensate for the 2 multiplier later.
double at = 0.5*w*m_ac /sqrt(SQR(v.y/m_a[0]) + SQR(v.z / m_a[1]));
Tf += N*at;
}
}
// add fiber to total
T += Tf/wtot;
return T.dev()*(2.0/J);
}
//-----------------------------------------------------------------------------
//! Calculates the deviatoric elasticity tensor for this material.
//! \param D elasticity tensor
//! \param pt material point at which to evaulate the elasticity tensor
tens4ds FE2DTransIsoMooneyRivlin::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the "fiber" direction
vec3d r = m_fiber->unitVector(mp);
// setup a rotation
quatd q(vec3d(1, 0, 0), r);
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
double Jm13 = pow(J, -1.0/3.0);
double Jm23 = Jm13*Jm13;
double Ji = 1.0/J;
// deviatoric right Cauchy-Green tensor: C = Ft*F
mat3ds C = pt.DevRightCauchyGreen();
// square of C
mat3ds C2 = C.sqr();
// Invariants of C
double I1 = C.tr();
double I2 = 0.5*(I1*I1 - C2.tr());
// calculate left Cauchy-Green tensor: B = F*Ft
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// strain energy derivatives
double W1 = m_c1;
double W2 = m_c2;
// --- M A T R I X C O N T R I B U T I O N ---
// deviatoric cauchy-stress, trs = trace[s]/3
mat3ds T = B * (W1 + W2 * I1) - B2 * W2;
mat3ds devs = T.dev() * (2.0 / J);
// calculate dWdC:C
double WC = W1*I1 + 2*W2*I2;
// calculate C:d2WdCdC:C
double CWWC = 2*I2*W2;
mat3dd I(1); // Identity
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxB = dyad1s(B);
tens4ds B4 = dyad4s(B);
// d2W/dCdC:C
mat3ds WCCxC = B*(W2*I1) - B2*W2;
tens4ds cw = (BxB - B4)*(W2*4.0*Ji) - dyad1s(WCCxC, I)*(4.0/3.0*Ji) + IxI*(4.0/9.0*Ji*CWWC);
tens4ds c = dyad1s(devs, I)*(-2.0/3.0) + (I4 - IxI/3.0)*(4.0/3.0*Ji*WC) + cw;
double eps = m_epsf * std::numeric_limits<double>::epsilon();
// --- F I B E R C O N T R I B U T I O N ---
// Next, we add the fiber contribution. Since the fibers lie
// randomly perpendicular to the transverse axis, we need
// to integrate over that plane
double lam, lamd;
double In, Wl, Wll;
vec3d v;
double w, wtot = 0;
tens4ds cf, cfw; cf.zero();
mat3ds N2;
tens4ds N4;
tens4ds I4mIxId3 = I4 - IxI/3.0;
for (int n=0; n<NSTEPS; ++n)
{
// calculate the local material fiber vector
v.y = m_cth[n];
v.z = m_sth[n];
v.x = 0;
// calculate the global material fiber vector
vec3d a0 = q*v;
// calculate the global spatial fiber vector
vec3d a = F*a0;
// normalize material axis and store fiber stretch
lam = a.unit();
lamd = lam*Jm13; // i.e. lambda tilde
// fourth invariant of C
In = lamd*lamd;
// Wi = dW/dIi
if (lamd >= 1 + eps)
{
double lamdi = 1.0/lamd;
double W4, W44;
if (lamd < m_lam1)
{
W4 = lamdi*m_c3*(exp(m_c4*(lamd - 1)) - 1);
W44 = m_c3*lamdi*(m_c4*exp(m_c4*(lamd - 1)) - lamdi*(exp(m_c4*(lamd-1))-1));
}
else
{
double c6 = m_c3*(exp(m_c4*(m_lam1-1))-1) - m_c5*m_lam1;
W4 = lamdi*(m_c5*lamd + c6);
W44 = -c6*lamdi*lamdi;
}
Wl = 0.5*lamdi*W4;
Wll = 0.25*lamdi*lamdi*(W44 - lamdi*W4);
}
else
{
Wl = 0;
Wll = 0;
}
w = 1.0/sqrt((v.y/m_w[0])*(v.y/m_w[0]) + (v.z/m_w[1])*(v.z/m_w[1]));
wtot += w;
// calculate dWdC:C
double WC = Wl*In;
// calculate C:d2WdCdC:C
double CWWC = Wll*In*In;
N2 = dyad(a);
N4 = dyad1s(N2);
WCCxC = N2*(Wll*In*In);
cfw = N4*(4.0*Wll*In*In) - dyad1s(WCCxC, I)*(4.0/3.0) + IxI*(4.0/9.0*CWWC);
cf += (I4mIxId3)*(4.0/3.0*Ji*WC*w) + cfw*(Ji*w);
}
// add fiber to total
c += cf/wtot;
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidContractileForce.cpp | .cpp | 11,711 | 364 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FERigidContractileForce.h"
#include "FERigidBody.h"
#include "FECore/log.h"
#include "FECore/FEMaterial.h"
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidContractileForce, FERigidConnector);
ADD_PARAMETER(m_f0 , "f0" );
ADD_PARAMETER(m_a0 , "insertion_a");
ADD_PARAMETER(m_b0 , "insertion_b");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidContractileForce::FERigidContractileForce(FEModel* pfem) : FERigidConnector(pfem)
{
m_nID = m_ncount++;
m_f0 = 0;
}
//-----------------------------------------------------------------------------
//! TODO: This function is called twice: once in the Init and once in the Solve
//! phase. Is that necessary?
bool FERigidContractileForce::Init()
{
// base class first
if (FERigidConnector::Init() == false) return false;
// reset force
m_F = vec3d(0,0,0);
// set force insertions relative to rigid body center of mass
m_qa0 = m_a0 - m_rbA->m_r0;
m_qb0 = m_b0 - m_rbB->m_r0;
m_at = m_a0;
m_bt = m_b0;
return true;
}
//-----------------------------------------------------------------------------
void FERigidContractileForce::Serialize(DumpStream& ar)
{
FERigidConnector::Serialize(ar);
ar & m_qa0 & m_qb0;
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidContractileForce::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
vector<double> fa(6);
vector<double> fb(6);
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
double alpha = tp.alphaf;
// body A
vec3d ra = RBa.m_rt*alpha + RBa.m_rp*(1-alpha);
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
vec3d za = zat*alpha + zap*(1-alpha);
// body b
vec3d rb = RBb.m_rt*alpha + RBb.m_rp*(1-alpha);
vec3d zbt = m_qb0; RBb.GetRotation().RotateVector(zbt);
vec3d zbp = m_qb0; RBb.m_qp.RotateVector(zbp);
vec3d zb = zbt*alpha + zbp*(1-alpha);
vec3d n = rb + zb - ra - za;
n.unit();
m_F = n*m_f0;
fa[0] = m_F.x;
fa[1] = m_F.y;
fa[2] = m_F.z;
fa[3] = za.y*m_F.z-za.z*m_F.y;
fa[4] = za.z*m_F.x-za.x*m_F.z;
fa[5] = za.x*m_F.y-za.y*m_F.x;
fb[0] = -m_F.x;
fb[1] = -m_F.y;
fb[2] = -m_F.z;
fb[3] = -zb.y*m_F.z+zb.z*m_F.y;
fb[4] = -zb.z*m_F.x+zb.x*m_F.z;
fb[5] = -zb.x*m_F.y+zb.y*m_F.x;
for (int i=0; i<6; ++i) if (RBa.m_LM[i] >= 0) R[RBa.m_LM[i]] += fa[i];
for (int i=0; i<6; ++i) if (RBb.m_LM[i] >= 0) R[RBb.m_LM[i]] += fb[i];
RBa.m_Fr -= vec3d(fa[0],fa[1],fa[2]);
RBa.m_Mr -= vec3d(fa[3],fa[4],fa[5]);
RBb.m_Fr -= vec3d(fb[0],fb[1],fb[2]);
RBb.m_Mr -= vec3d(fb[3],fb[4],fb[5]);
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidContractileForce::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
double alpha = tp.alphaf;
vector<int> LM(12);
FEElementMatrix ke; ke.resize(12, 12);
ke.zero();
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// body A
vec3d ra = RBa.m_rt*alpha + RBa.m_rp*(1-alpha);
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.GetRotation().RotateVector(zap);
vec3d za = zat*alpha + zap*(1-alpha);
mat3d zahat; zahat.skew(za);
mat3d zathat; zathat.skew(zat);
// body b
vec3d rb = RBb.m_rt*alpha + RBb.m_rp*(1-alpha);
vec3d zbt = m_qb0; RBb.GetRotation().RotateVector(zbt);
vec3d zbp = m_qb0; RBb.m_qp.RotateVector(zbp);
vec3d zb = zbt*alpha + zbp*(1-alpha);
mat3d zbhat; zbhat.skew(zb);
mat3d zbthat; zbthat.skew(zbt);
vec3d c = rb + zb - ra - za;
vec3d n(c);
double L = n.unit();
m_F = n*m_f0;
mat3ds P;
mat3dd I(1);
P = I - dyad(n);
double k = (L > 0) ? m_f0/L : 0;
mat3da chat(c);
mat3d K;
// (1,1)
K = P*(alpha*k);
ke[0][0] = K[0][0]; ke[0][1] = K[0][1]; ke[0][2] = K[0][2];
ke[1][0] = K[1][0]; ke[1][1] = K[1][1]; ke[1][2] = K[1][2];
ke[2][0] = K[2][0]; ke[2][1] = K[2][1]; ke[2][2] = K[2][2];
// (1,2)
K = (P*zathat)*(-alpha*k);
ke[0][3] = K[0][0]; ke[0][4] = K[0][1]; ke[0][5] = K[0][2];
ke[1][3] = K[1][0]; ke[1][4] = K[1][1]; ke[1][5] = K[1][2];
ke[2][3] = K[2][0]; ke[2][4] = K[2][1]; ke[2][5] = K[2][2];
// (1,3)
K = P*(-alpha*k);
ke[0][6] = K[0][0]; ke[0][7] = K[0][1]; ke[0][8] = K[0][2];
ke[1][6] = K[1][0]; ke[1][7] = K[1][1]; ke[1][8] = K[1][2];
ke[2][6] = K[2][0]; ke[2][7] = K[2][1]; ke[2][8] = K[2][2];
// (1,4)
K = P*zbthat*(alpha*k);
ke[0][9] = K[0][0]; ke[0][10] = K[0][1]; ke[0][11] = K[0][2];
ke[1][9] = K[1][0]; ke[1][10] = K[1][1]; ke[1][11] = K[1][2];
ke[2][9] = K[2][0]; ke[2][10] = K[2][1]; ke[2][11] = K[2][2];
// (2,1)
K = zahat*P*(alpha*k);
ke[3][0] = K[0][0]; ke[3][1] = K[0][1]; ke[3][2] = K[0][2];
ke[4][0] = K[1][0]; ke[4][1] = K[1][1]; ke[4][2] = K[1][2];
ke[5][0] = K[2][0]; ke[5][1] = K[2][1]; ke[5][2] = K[2][2];
// (2,2)
K = (zahat*P*zathat + chat*zathat)*(-alpha*k);
ke[3][3] = K[0][0]; ke[3][4] = K[0][1]; ke[3][5] = K[0][2];
ke[4][3] = K[1][0]; ke[4][4] = K[1][1]; ke[4][5] = K[1][2];
ke[5][3] = K[2][0]; ke[5][4] = K[2][1]; ke[5][5] = K[2][2];
// (2,3)
K = zahat*P*(-alpha*k);
ke[3][6] = K[0][0]; ke[3][7] = K[0][1]; ke[3][8] = K[0][2];
ke[4][6] = K[1][0]; ke[4][7] = K[1][1]; ke[4][8] = K[1][2];
ke[5][6] = K[2][0]; ke[5][7] = K[2][1]; ke[5][8] = K[2][2];
// (2,4)
K = (zahat*P*zbthat)*(alpha*k);
ke[3][9] = K[0][0]; ke[3][10] = K[0][1]; ke[3][11] = K[0][2];
ke[4][9] = K[1][0]; ke[4][10] = K[1][1]; ke[4][11] = K[1][2];
ke[5][9] = K[2][0]; ke[5][10] = K[2][1]; ke[5][11] = K[2][2];
// (3,1)
K = P*(-alpha*k);
ke[6][0] = K[0][0]; ke[6][1] = K[0][1]; ke[6][2] = K[0][2];
ke[7][0] = K[1][0]; ke[7][1] = K[1][1]; ke[7][2] = K[1][2];
ke[8][0] = K[2][0]; ke[8][1] = K[2][1]; ke[8][2] = K[2][2];
// (3,2)
K = (P*zathat)*(alpha*k);
ke[6][3] = K[0][0]; ke[6][4] = K[0][1]; ke[6][5] = K[0][2];
ke[7][3] = K[1][0]; ke[7][4] = K[1][1]; ke[7][5] = K[1][2];
ke[8][3] = K[2][0]; ke[8][4] = K[2][1]; ke[8][5] = K[2][2];
// (3,3)
K = P*(alpha*k);
ke[6][6] = K[0][0]; ke[6][7] = K[0][1]; ke[6][8] = K[0][2];
ke[7][6] = K[1][0]; ke[7][7] = K[1][1]; ke[7][8] = K[1][2];
ke[8][6] = K[2][0]; ke[8][7] = K[2][1]; ke[8][8] = K[2][2];
// (3,4)
K = P*zbthat*(-alpha*k);
ke[6][9] = K[0][0]; ke[6][10] = K[0][1]; ke[6][11] = K[0][2];
ke[7][9] = K[1][0]; ke[7][10] = K[1][1]; ke[7][11] = K[1][2];
ke[8][9] = K[2][0]; ke[8][10] = K[2][1]; ke[8][11] = K[2][2];
// (4,1)
K = zbhat*P*(-alpha*k);
ke[9 ][0] = K[0][0]; ke[ 9][1] = K[0][1]; ke[ 9][2] = K[0][2];
ke[10][0] = K[1][0]; ke[10][1] = K[1][1]; ke[10][2] = K[1][2];
ke[11][0] = K[2][0]; ke[11][1] = K[2][1]; ke[11][2] = K[2][2];
// (4,2)
K = (zbhat*P*zathat)*(alpha*k);
ke[9 ][3] = K[0][0]; ke[ 9][4] = K[0][1]; ke[ 9][5] = K[0][2];
ke[10][3] = K[1][0]; ke[10][4] = K[1][1]; ke[10][5] = K[1][2];
ke[11][3] = K[2][0]; ke[11][4] = K[2][1]; ke[11][5] = K[2][2];
// (4,3)
K = zbhat*P*(alpha*k);
ke[9 ][6] = K[0][0]; ke[ 9][7] = K[0][1]; ke[ 9][8] = K[0][2];
ke[10][6] = K[1][0]; ke[10][7] = K[1][1]; ke[10][8] = K[1][2];
ke[11][6] = K[2][0]; ke[11][7] = K[2][1]; ke[11][8] = K[2][2];
// (4,4)
K = (zbhat*P*zbthat - chat*zbthat)*(-alpha*k);
ke[9 ][9] = K[0][0]; ke[ 9][10] = K[0][1]; ke[ 9][11] = K[0][2];
ke[10][9] = K[1][0]; ke[10][10] = K[1][1]; ke[10][11] = K[1][2];
ke[11][9] = K[2][0]; ke[11][10] = K[2][1]; ke[11][11] = K[2][2];
for (int j=0; j<6; ++j)
{
LM[j ] = RBa.m_LM[j];
LM[j+6] = RBb.m_LM[j];
}
ke.SetIndices(LM);
LS.Assemble(ke);
}
//-----------------------------------------------------------------------------
bool FERigidContractileForce::Augment(int naug, const FETimeInfo& tp)
{
return true;
}
//-----------------------------------------------------------------------------
void FERigidContractileForce::Update()
{
vec3d ra, rb, c;
vec3d za, zb;
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
const FETimeInfo& tp = GetTimeInfo();
double alpha = tp.alphaf;
ra = RBa.m_rt*alpha + RBa.m_rp*(1-alpha);
rb = RBb.m_rt*alpha + RBb.m_rp*(1-alpha);
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
za = zat*alpha + zap*(1-alpha);
vec3d zbt = m_qb0; RBb.GetRotation().RotateVector(zbt);
vec3d zbp = m_qb0; RBb.m_qp.RotateVector(zbp);
zb = zbt*alpha + zbp*(1-alpha);
m_at = RBa.m_rt + zat;
m_bt = RBb.m_rt + zbt;
vec3d n = rb + zb - ra - za;
n.unit();
m_F = n*m_f0;
}
//-----------------------------------------------------------------------------
void FERigidContractileForce::Reset()
{
m_F = vec3d(0,0,0);
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
m_qa0 = m_a0 - RBa.m_r0;
m_qb0 = m_b0 - RBb.m_r0;
}
//-----------------------------------------------------------------------------
vec3d FERigidContractileForce::RelativeTranslation(const bool global)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// body A
vec3d ra = RBa.m_rt;
vec3d za = m_qa0; RBa.GetRotation().RotateVector(za);
// body B
vec3d rb = RBb.m_rt;
vec3d zb = m_qb0; RBb.GetRotation().RotateVector(zb);
// relative translation in global coordinate system
vec3d x = rb + zb - ra - za;
return x;
}
//-----------------------------------------------------------------------------
vec3d FERigidContractileForce::RelativeRotation(const bool global)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// get relative rotation
quatd Q = RBb.GetRotation()*RBa.GetRotation().Inverse(); Q.MakeUnit();
// relative rotation vector
vec3d q = Q.GetRotationVector();
return q;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FESlideLineConstraint.cpp | .cpp | 18,565 | 790 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FESlideLineConstraint.h"
#include <FECore/FEShellDomain.h>
#include "FECore/FEClosestPointProjection.h"
#include "FECore/FEModel.h"
#include "FECore/FEGlobalMatrix.h"
#include "FECore/log.h"
#include <FECore/FELinearSystem.h>
#include <FECore/FEAnalysis.h>
FESlideLine::FESlidingPoint::FESlidingPoint()
{
pme = nullptr;
gap = 0;
nu = vec3d(0, 0, 0);
r = 0;
Lm = 0.0;
Ln = 0.0;
}
void FESlideLine::FESlidingPoint::Serialize(DumpStream& ar)
{
ar & gap & nu;
ar & r;
ar & Lm & Ln;
}
void FESlideLine::FESlidingPoint::Init()
{
pme = nullptr;
gap = 0;
nu = vec3d(0, 0, 0);
r = 0;
Lm = Ln = 0.0;
}
FESlideLine::FESlideLine(FEModel* pfem) : FEEdge(pfem) {}
bool FESlideLine::Init()
{
// always intialize base class first!
if (FEEdge::Init() == false) return false;
// get the number of nodes
int nn = Nodes();
// allocate integration point data
m_data.resize(nn);
for (int i = 0; i < nn; ++i)
{
FESlidingPoint& d = m_data[i];
d.Init();
}
return true;
}
FEMaterialPoint* FESlideLine::CreateMaterialPoint()
{
return new FELineMaterialPoint;
}
FESlideLine::Projection FESlideLine::ClosestProjection(const vec3d& x)
{
FESlideLine::Projection P;
int NE = Elements();
double L2min = 0;
for (int i = 0; i < NE; ++i)
{
FELineElement& el = Element(i);
vec3d a = Node(el.m_lnode[0]).m_rt;
vec3d b = Node(el.m_lnode[1]).m_rt;
vec3d e = (b - a);
double D2 = e.norm2();
if (D2 != 0)
{
double l = ((x - a) * e) / D2;
if (l < 0) l = 0;
else if (l > 1) l = 1;
vec3d q = a + e * l;
double L2 = (x - q).norm2();
if ((P.pe == nullptr) || (L2 < L2min))
{
P.pe = ⪙
P.r = 2.0 * l - 1;
P.q = q;
L2min = L2;
}
}
}
assert(P.pe);
return P;
}
void FESlideLine::Serialize(DumpStream& ar)
{
// serialize base class
FEEdge::Serialize(ar);
// serialize data
// ar & m_data;
}
BEGIN_FECORE_CLASS(FESlideLineConstraint, FENLConstraint)
ADD_PARAMETER(m_laugon , "laugon" )->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0");
ADD_PARAMETER(m_atol , "tolerance" );
ADD_PARAMETER(m_eps , "penalty" );
ADD_PARAMETER(m_gtol , "gaptol" );
ADD_PARAMETER(m_naugmin , "minaug" );
ADD_PARAMETER(m_naugmax , "maxaug" );
ADD_PARAMETER(m_nsegup , "seg_up" );
ADD_PROPERTY(pl, "primary")->AddFlag(FEProperty::Reference);
ADD_PROPERTY(sl, "secondary")->AddFlag(FEProperty::Reference);
END_FECORE_CLASS();
//! build the matrix profile for use in the stiffness matrix
void FESlideLineConstraint::BuildMatrixProfile(FEGlobalMatrix& K)
{
FEMesh& mesh = GetMesh();
// get the DOFS
const int dof_X = GetDOFIndex("x");
const int dof_Y = GetDOFIndex("y");
const int dof_Z = GetDOFIndex("z");
const int dof_RU = GetDOFIndex("Ru");
const int dof_RV = GetDOFIndex("Rv");
const int dof_RW = GetDOFIndex("Rw");
const int LMSIZE = 6 * (FEElement::MAX_NODES + 1);
vector<int> lm(LMSIZE);
for (int j = 0; j < pl.Nodes(); ++j)
{
FENode& nj = pl.Node(j);
FELineElement* pe = pl.m_data[j].pme;
if (pe != 0)
{
FELineElement& me = *pe;
int* en = &me.m_lnode[0];
int n = me.Nodes();
lm.assign(LMSIZE, -1);
lm[0] = nj.m_ID[dof_X];
lm[1] = nj.m_ID[dof_Y];
lm[2] = nj.m_ID[dof_Z];
lm[3] = nj.m_ID[dof_RU];
lm[4] = nj.m_ID[dof_RV];
lm[5] = nj.m_ID[dof_RW];
for (int k = 0; k < n; ++k)
{
vector<int>& id = mesh.Node(en[k]).m_ID;
lm[6 * (k + 1) ] = id[dof_X];
lm[6 * (k + 1) + 1] = id[dof_Y];
lm[6 * (k + 1) + 2] = id[dof_Z];
lm[6 * (k + 1) + 3] = id[dof_RU];
lm[6 * (k + 1) + 4] = id[dof_RV];
lm[6 * (k + 1) + 5] = id[dof_RW];
}
K.build_add(lm);
}
}
}
FESlideLineConstraint::FESlideLineConstraint(FEModel* pfem) : FENLConstraint(pfem), pl(pfem), sl(pfem)
{
static int count = 1;
SetID(count++);
m_laugon = 0; // penalty method by default
m_naugmin = 0;
m_naugmax = 10;
m_gtol = 0;
m_nsegup = 0; // always do segment updates
};
bool FESlideLineConstraint::Init()
{
// set data
m_bfirst = true;
m_normg0 = 0.0;
// create the surfaces
if (pl.Init() == false) return false;
if (sl.Init() == false) return false;
return true;
}
void FESlideLineConstraint::Activate()
{
// don't forget to call the base class
FENLConstraint::Activate();
// project primary surface onto secondary surface
ProjectPoints(true);
}
void FESlideLineConstraint::ProjectPoints(bool bupseg)
{
// loop over all primary nodes
for (int i=0; i<pl.Nodes(); ++i)
{
FENode& node = pl.Node(i);
vec3d x = node.m_rt;
FESlideLine::FESlidingPoint& pti = pl.m_data[i];
FESlideLine::Projection P = sl.ClosestProjection(x);
if (P.pe)
{
FELineElement* pme = pti.pme;
if ((P.pe == pme) || bupseg)
{
pti.pme = P.pe;
pti.r = P.r;
// calculate gap
vec3d e = P.q - x;
pti.gap = e.unit();
pti.nu = e;
}
}
else
{
// point has left contact
pti.pme = nullptr;
pti.gap = 0;
pti.Ln = pti.Lm = 0;
}
}
}
//-----------------------------------------------------------------------------
//! updates sliding interface data
//! niter is the number of Newton iterations.
void FESlideLineConstraint::Update()
{
int niter = GetFEModel()->GetCurrentStep()->GetFESolver()->m_niter;
// should we do a segment update or not?
// TODO: check what happens when m_nsegup == -1 and m_npass = 2;
// We have to make sure that in this case, both surfaces get at least
// one pass!
bool bupdate = (m_bfirst || (m_nsegup == 0)? true : (niter <= m_nsegup));
ProjectPoints(bupdate);
// Update the net contact pressures
UpdateContactPressures();
// set the first-entry-flag to false
m_bfirst = false;
}
void FESlideLineConstraint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
// element contact force vector
vector<double> fe;
// the lm array for this force vector
vector<int> lm;
// the en array
vector<int> en;
// the elements LM vectors
vector<int> sLM;
vector<int> mLM;
const int MN = FEElement::MAX_NODES;
double w[MN];
double detJ[MN];
// loop over all primary surface facets
int ne = pl.Elements();
for (int j=0; j<ne; ++j)
{
// get the next element
FELineElement& sel = pl.Element(j);
int nseln = sel.Nodes();
vec3d a = pl.Node(sel.m_lnode[0]).m_r0;
vec3d b = pl.Node(sel.m_lnode[1]).m_r0;
double L = (b - a).norm();
// get the element's LM array
// TODO: This assumes dofs are indexed at (0,1,2)!
sLM.resize(3 * nseln);
for (int a = 0; a < nseln; ++a)
{
FENode& node = pl.Node(sel.m_lnode[a]);
sLM[3 * a] = node.m_ID[0];
sLM[3 * a + 1] = node.m_ID[1];
sLM[3 * a + 2] = node.m_ID[2];
}
// we calculate all the metrics we need before we
// calculate the nodal forces
for (int n=0; n<nseln; ++n)
{
// jacobians
detJ[n] = L/2; // TODO: This assumes local jacobian is 2!
// integration weights
w[n] = 1;// sel.GaussWeights()[n];
}
// loop over primary surface element nodes (which are the integration points as well)
// and calculate the contact nodal force
for (int n=0; n<nseln; ++n)
{
// get the local node number
int m = sel.m_lnode[n];
// see if this node's constraint is active
// that is, if it has an element associated with it
// TODO: is this a good way to test for an active constraint
// The rigid wall criteria seems to work much better.
if (pl.m_data[m].pme != 0)
{
// This node is active and could lead to a non-zero
// contact force.
// get the secondary surface element
FELineElement& mel = *pl.m_data[m].pme;
int nmeln = mel.Nodes();
mLM.resize(3 * nmeln);
for (int b = 0; b < nmeln; ++b)
{
FENode& node = sl.Node(mel.m_lnode[b]);
mLM[3 * b] = node.m_ID[0];
mLM[3 * b + 1] = node.m_ID[1];
mLM[3 * b + 2] = node.m_ID[2];
}
// calculate the nodal force
int ndof = 3 * (nmeln + 1);
fe.resize(ndof);
ContactNodalForce(m, mel, fe);
// multiply force with weights
for (int l=0; l<ndof; ++l) fe[l] *= detJ[n]*w[n];
// fill the lm array
lm.resize(3*(nmeln+1));
lm[0] = sLM[n*3 ];
lm[1] = sLM[n*3+1];
lm[2] = sLM[n*3+2];
for (int l=0; l<nmeln; ++l)
{
lm[3*(l+1) ] = mLM[l*3 ];
lm[3*(l+1)+1] = mLM[l*3+1];
lm[3*(l+1)+2] = mLM[l*3+2];
}
// fill the en array
en.resize(nmeln+1);
en[0] = sel.m_node[n];
for (int l=0; l<nmeln; ++l) en[l+1] = mel.m_node[l];
// assemble into global force vector
R.Assemble(en, lm, fe);
}
}
}
}
//! Calculates the contact force on a node.
//! \param[in] m local node number
//! \param[out] fe force vector
void FESlideLineConstraint::ContactNodalForce(int m, FELineElement& mel, vector<double>& fe)
{
// max nr of element nodes
const int MAXMN = FEElement::MAX_NODES;
// get primary node force
double gap = pl.m_data[m].gap;
double eps = Penalty();
double Ln = pl.m_data[m].Lm;
double tn = Ln + eps*gap;
// get the primary node normal
vec3d& nu = pl.m_data[m].nu;
int nmeln = mel.Nodes();
int ndof = 3*(1 + nmeln);
// isoparametric coordinates of the projected node
// onto the secondary surface element
double r = pl.m_data[m].r;
// get the secondary surface element shape function values at this node
double H[MAXMN];
mel.shape(H, r);
// --- N O R M A L T R A C T I O N ---
// calculate contact vectors for normal traction
double N[3 * (MAXMN + 1)];
N[0] = nu.x;
N[1] = nu.y;
N[2] = nu.z;
for (int l=0; l<nmeln; ++l)
{
N[3*(l+1) ] = -H[l]*nu.x;
N[3*(l+1)+1] = -H[l]*nu.y;
N[3*(l+1)+2] = -H[l]*nu.z;
}
// calculate force vector
for (int l=0; l<ndof; ++l) fe[l] = tn*N[l];
}
void FESlideLineConstraint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
FEElementMatrix ke;
const int MAXMN = FEElement::MAX_NODES;
vector<int> lm(3*(MAXMN + 1));
vector<int> en(MAXMN+1);
double w[MAXMN];
double detJ[MAXMN];
vector<int> sLM;
vector<int> mLM;
// loop over all primary elements
int ne = pl.Elements();
for (int j=0; j<ne; ++j)
{
// unpack the next element
FELineElement& se = pl.Element(j);
int nseln = se.Nodes();
vec3d a = pl.Node(se.m_lnode[0]).m_r0;
vec3d b = pl.Node(se.m_lnode[1]).m_r0;
double L = (b - a).norm();
// get the element's LM array
// TODO: This assumes dofs are indexed at (0,1,2)!
sLM.resize(3 * nseln);
for (int a = 0; a < nseln; ++a)
{
FENode& node = pl.Node(se.m_lnode[a]);
sLM[3 * a] = node.m_ID[0];
sLM[3 * a + 1] = node.m_ID[1];
sLM[3 * a + 2] = node.m_ID[2];
}
// get all the metrics we need
for (int n=0; n<nseln; ++n)
{
detJ[n] = L/2;
w[n] = 1;
}
// loop over all integration points (that is nodes)
for (int n=0; n<nseln; ++n)
{
int m = se.m_lnode[n];
// see if this node's constraint is active
// that is, if it has an element associated with it
if (pl.m_data[m].pme != 0)
{
// get the secondary surface element
FELineElement& me = *pl.m_data[m].pme;
int nmeln = me.Nodes();
int ndof = 3 * (nmeln + 1);
// get the secondary surface element's LM array
mLM.resize(3 * nmeln);
for (int b = 0; b < nmeln; ++b)
{
FENode& node = sl.Node(me.m_lnode[b]);
mLM[3 * b] = node.m_ID[0];
mLM[3 * b + 1] = node.m_ID[1];
mLM[3 * b + 2] = node.m_ID[2];
}
// calculate the stiffness matrix
ke.resize(ndof, ndof);
ContactNodalStiffness(m, me, ke);
// muliply with weights
for (int k=0; k<ndof; ++k)
for (int l=0; l<ndof; ++l) ke[k][l] *= detJ[n]*w[n];
// fill the lm array
lm[0] = sLM[n*3 ];
lm[1] = sLM[n*3+1];
lm[2] = sLM[n*3+2];
for (int k=0; k<nmeln; ++k)
{
lm[3*(k+1) ] = mLM[k*3 ];
lm[3*(k+1)+1] = mLM[k*3+1];
lm[3*(k+1)+2] = mLM[k*3+2];
}
// create the en array
en.resize(nmeln+1);
en[0] = se.m_node[n];
for (int k=0; k<nmeln; ++k) en[k+1] = me.m_node[k];
// assemble stiffness matrix
ke.SetNodes(en);
ke.SetIndices(lm);
LS.Assemble(ke);
}
}
}
}
//-----------------------------------------------------------------------------
void FESlideLineConstraint::ContactNodalStiffness(int m, FELineElement& mel, matrix& ke)
{
const int MAXMN = FEElement::MAX_NODES;
vector<int> lm(3*(MAXMN+1));
vector<int> en(MAXMN + 1);
double H[MAXMN], Hr[MAXMN];
double N[3][3 * (MAXMN + 1)] = { 0 };
double AN[3][3 * (MAXMN + 1)] = { 0 };
// get the mesh
FEMesh& mesh = GetFEModel()->GetMesh();
// nr of element nodes and degrees of freedom
int nmeln = mel.Nodes();
int ndof = 3*(1 + nmeln);
// penalty factor
double eps = Penalty();
// nodal coordinates
vec3d rt[MAXMN];
for (int j=0; j<nmeln; ++j) rt[j] = mesh.Node(mel.m_node[j]).m_rt;
// node natural coordinates in secondary surface element
double r = pl.m_data[m].r;
// gap
double gap = pl.m_data[m].gap;
// lagrange multiplier
double Lm = pl.m_data[m].Lm;
// get node normal force
double tn = Lm + eps*gap;
// get the node normal
vec3d& nu = pl.m_data[m].nu;
// get the secondary surface element shape function values and the derivatives at this node
mel.shape(H, r);
mel.shape_deriv(Hr, r);
// set up the N vector
N[0][0] = 1;
N[1][1] = 1;
N[2][2] = 1;
for (int k=0; k<nmeln; ++k)
{
N[0][(k+1)*3 ] = -H[k];
N[1][(k+1)*3+1] = -H[k];
N[2][(k+1)*3+2] = -H[k];
}
// get the tangent vector
vec3d tau(0, 0, 0);
for (int i = 0; i < nmeln; ++i)
{
tau += mesh.Node(mel.m_node[i]).m_rt * Hr[i];
}
// calculate curvature tensor
double K = 0;
double Grr[FEElement::MAX_NODES];
mel.shape_deriv2(Grr, r);
for (int k=0; k<nmeln; ++k)
{
K += (nu*rt[k])*Grr[k];
}
// setup A matrix A = M + gK
double A = (tau * tau) - gap * K;
mat3d TxT = (tau & tau);
mat3d B = mat3dd(1.0) - TxT/A;
mat3d M = B.transpose() * B;
for (int i=0; i<3; ++i)
for (int j = 0; j < ndof; ++j)
{
AN[i][j] = 0;
for (int k=0; k<3; ++k)
AN[i][j] += M[i][k] * N[k][j];
}
for (int k=0; k<ndof; ++k)
for (int l=0; l<ndof; ++l)
{
double sum = 0;
for (int i=0; i<3; ++i)
sum += N[i][k] * AN[i][l];
ke[k][l] = eps*sum;
}
}
bool FESlideLineConstraint::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (m_laugon != FECore::AUGLAG_METHOD) return true;
double Ln;
bool bconv = true;
mat2d Mi;
// penalty factor
double eps = Penalty();
// --- c a l c u l a t e i n i t i a l n o r m s ---
// a. normal component
double normL0 = 0;
for (int i=0; i<pl.Nodes(); ++i) normL0 += pl.m_data[i].Lm*pl.m_data[i].Lm;
normL0 = sqrt(normL0);
// --- c a l c u l a t e c u r r e n t n o r m s ---
// a. normal component
double normL1 = 0; // force norm
double normg1 = 0; // gap norm
int N = 0;
for (int i=0; i<pl.Nodes(); ++i)
{
// update Lagrange multipliers
Ln = pl.m_data[i].Lm + eps*pl.m_data[i].gap;
normL1 += Ln*Ln;
if (pl.m_data[i].gap > 0)
{
normg1 += pl.m_data[i].gap*pl.m_data[i].gap;
++N;
}
}
if (N == 0) N=1;
normL1 = sqrt(normL1);
normg1 = sqrt(normg1 / N);
if (naug == 0) m_normg0 = 0;
// calculate and print convergence norms
double lnorm = 0, gnorm = 0;
if (normL1 != 0) lnorm = fabs(normL1 - normL0)/normL1; else lnorm = fabs(normL1 - normL0);
// if (normg1 != 0) gnorm = fabs(normg1 - m_normg0)/normg1; else gnorm = fabs(normg1 - m_normg0);
gnorm = fabs(normg1 - m_normg0);
feLog(" slide line # %d\n", GetID());
feLog(" CURRENT REQUIRED\n");
feLog(" normal force : %15le", lnorm);
if (m_atol > 0) feLog("%15le\n", m_atol); else feLog(" ***\n");
feLog(" gap function : %15le", gnorm);
if (m_gtol > 0) feLog("%15le\n", m_gtol); else feLog(" ***\n");
// check convergence
bconv = true;
if ((m_atol > 0) && (lnorm > m_atol)) bconv = false;
if ((m_gtol > 0) && (gnorm > m_gtol)) bconv = false;
if (m_naugmin > naug) bconv = false;
if (m_naugmax <= naug) bconv = true;
if (bconv == false)
{
// we did not converge so update multipliers
for (int i=0; i<pl.Nodes(); ++i)
{
// update Lagrange multipliers
Ln = pl.m_data[i].Lm + eps*pl.m_data[i].gap;
pl.m_data[i].Lm = Ln;
}
}
// store the last gap norm
m_normg0 = normg1;
return bconv;
}
void FESlideLineConstraint::UpdateContactPressures()
{
double eps = Penalty();
// loop over all nodes of the primary line
for (int n=0; n<pl.Nodes(); ++n)
{
// get the normal tractions at the integration points
double gap = pl.m_data[n].gap;
pl.m_data[n].Ln = pl.m_data[n].Lm + eps*gap;
}
}
void FESlideLineConstraint::Serialize(DumpStream& ar)
{
// store contact data
FENLConstraint::Serialize(ar);
// store contact surface data
pl.Serialize(ar);
sl.Serialize(ar);
// restore element pointers
SerializePointers(ar);
ar & m_bfirst & m_normg0;
}
void FESlideLineConstraint::SerializePointers(DumpStream& ar)
{
if (ar.IsShallow()) return;
if (ar.IsSaving())
{
for (int i = 0; i < pl.m_data.size(); i++)
{
FELineElement* pe = pl.m_data[i].pme;
int eid = (pe ? pe->GetLocalID() : -1);
ar << eid;
}
}
else
{
for (int i = 0; i < pl.m_data.size(); i++)
{
int eid = -1;
ar >> eid;
if (eid >= 0)
{
FELineElement* pe = &sl.Element(eid);
pl.m_data[i].pme = pe;
}
else pl.m_data[i].pme = nullptr;
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedActiveContractionTransIsoUC.h | .h | 2,175 | 61 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
//-----------------------------------------------------------------------------
// This material implements an active contraction model which can be used
// as a component of an uncoupled solid mixture material.
class FEPrescribedActiveContractionTransIsoUC : public FEUncoupledMaterial
{
public:
//! constructor
FEPrescribedActiveContractionTransIsoUC(FEModel* pfem);
//! validation
bool Validate() override;
//! serialization
void Serialize(DumpStream& ar) override;
//! stress
mat3ds DevStress(FEMaterialPoint& pt) override;
//! tangent
tens4ds DevTangent(FEMaterialPoint& pt) override;
public: // material parameters
FEParamDouble m_T0; // prescribed active stress
private:
vec3d m_n0; // unit vector along fiber direction (local coordinate system)
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEDamageCDF.h | .h | 6,719 | 221 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FEMaterial.h>
#include <FECore/FEFunction1D.h>
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
// Virtual base class for damage cumulative distribution functions
class FEBIOMECH_API FEDamageCDF : public FEMaterialProperty
{
public:
FEDamageCDF(FEModel* pfem) : FEMaterialProperty(pfem) { m_Dmax = 1; }
//! damage
double Damage(FEMaterialPoint& pt);
//! cumulative distribution function
virtual double cdf(FEMaterialPoint& mp, const double X) = 0;
//! probability density function
virtual double pdf(FEMaterialPoint& mp, const double X) = 0;
public:
double m_Dmax; //!< maximum allowable damage
// declare parameter list
DECLARE_FECORE_CLASS();
FECORE_BASE_CLASS(FEDamageCDF)
};
//-----------------------------------------------------------------------------
// Simo damage cumulative distribution function
// Simo, CMAME 60 (1987), 153-173
class FEDamageCDFSimo : public FEDamageCDF
{
public:
FEDamageCDFSimo(FEModel* pfem);
~FEDamageCDFSimo() {}
//! cumulative distribution function
double cdf(FEMaterialPoint& mp, const double X) override;
//! probability density function
double pdf(FEMaterialPoint& mp, const double X) override;
public:
FEParamDouble m_alpha; //!< parameter alpha
FEParamDouble m_beta; //!< parameter beta
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// Log-normal damage cumulative distribution function
class FEDamageCDFLogNormal : public FEDamageCDF
{
public:
FEDamageCDFLogNormal(FEModel* pfem);
~FEDamageCDFLogNormal() {}
//! cumulative distribution function
double cdf(FEMaterialPoint& mp, const double X) override;
//! probability density function
double pdf(FEMaterialPoint& mp, const double X) override;
public:
FEParamDouble m_mu; //!< mean on log scale
FEParamDouble m_sigma; //!< standard deviation on log scale
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// Weibull damage cumulative distribution function
class FEDamageCDFWeibull : public FEDamageCDF
{
public:
FEDamageCDFWeibull(FEModel* pfem);
~FEDamageCDFWeibull() {}
//! cumulative distribution function
double cdf(FEMaterialPoint& mp, const double X) override;
//! probability density function
double pdf(FEMaterialPoint& mp, const double X) override;
public:
FEParamDouble m_alpha; //!< exponent alpha
FEParamDouble m_mu; //!< mean mu
FEParamDouble m_ploc; //!< location parameter
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// Step cumulative distribution function (sudden fracture)
class FEDamageCDFStep : public FEDamageCDF
{
public:
FEDamageCDFStep(FEModel* pfem);
~FEDamageCDFStep() {}
//! cumulative distribution function
double cdf(FEMaterialPoint& mp, const double X) override;
//! probability density function
double pdf(FEMaterialPoint& mp, const double X) override;
public:
FEParamDouble m_mu; //!< threshold mu
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// Piecewise S-shaped quintic polynomial cumulative distribution function
class FEDamageCDFPQP : public FEDamageCDF
{
public:
FEDamageCDFPQP(FEModel* pfem);
~FEDamageCDFPQP() {}
//! cumulative distribution function
double cdf(FEMaterialPoint& mp, const double X) override;
//! probability density function
double pdf(FEMaterialPoint& mp, const double X) override;
bool Validate() override;
public:
FEParamDouble m_mumin; //!< mu threshold
FEParamDouble m_mumax; //!< mu cap
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// Gamma damage cumulative distribution function
class FEDamageCDFGamma : public FEDamageCDF
{
public:
FEDamageCDFGamma(FEModel* pfem);
~FEDamageCDFGamma() {}
//! cumulative distribution function
double cdf(FEMaterialPoint& mp, const double X) override;
//! probability density function
double pdf(FEMaterialPoint& mp, const double X) override;
public:
FEParamDouble m_alpha; //!< exponent alpha
FEParamDouble m_mu; //!< pdf expected mean mu
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// User-specified load curve for damage cumulative distribution function
class FEDamageCDFUser : public FEDamageCDF
{
public:
FEDamageCDFUser(FEModel* pfem);
~FEDamageCDFUser() {}
//! cumulative distribution function
double cdf(FEMaterialPoint& mp, const double X) override;
//! probability density function
double pdf(FEMaterialPoint& mp, const double X) override;
public:
FEFunction1D* m_cdf; //!< user-defined CDF
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFixedNormalDisplacement.h | .h | 3,188 | 97 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FEAugLagLinearConstraint.h>
#include <FECore/FESurface.h>
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! The FEFixedNormalDisplacement class implements a linear constraint for fixing the normal component
//! of the solid displacement.
class FEFixedNormalDisplacement : public FESurfaceConstraint
{
public:
//! constructor
FEFixedNormalDisplacement(FEModel* pfem);
//! destructor
~FEFixedNormalDisplacement() {}
//! Activation
void Activate() override;
//! initialization
bool Init() override;
// allocate equations
int InitEquations(int neq) override;
// we don't use nodal integration for this constraint
bool UseNodalIntegration() { return false; };
protected:
void Update(const std::vector<double>& Ui, const std::vector<double>& ui) override;
void UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) override;
void PrepStep() override;
public:
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! add the linear constraint contributions to the residual
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
//! add the linear constraint contributions to the stiffness matrix
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
//! do the augmentation
bool Augment(int naug, const FETimeInfo& tp) override;
//! build connectivity for matrix profile
void BuildMatrixProfile(FEGlobalMatrix& M) override;
//! Get the surface
FESurface* GetSurface() override { return &m_surf; }
protected:
FESurface m_surf;
bool m_binit;
public:
bool m_bshellb;
private:
FELinearConstraintSet m_lc;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEReactiveViscoelastic.cpp | .cpp | 25,484 | 776 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEReactiveViscoelastic.h"
#include "FEElasticMixture.h"
#include "FEElasticFiberMaterial.h"
#include "FEFiberMaterialPoint.h"
#include "FEScaledElasticMaterial.h"
#include <FECore/FECoreKernel.h>
#include <FECore/log.h>
#include <limits>
///////////////////////////////////////////////////////////////////////////////
//
// FEReactiveViscoelasticMaterial
//
///////////////////////////////////////////////////////////////////////////////
// Material parameters for the FEMultiphasic material
BEGIN_FECORE_CLASS(FEReactiveViscoelasticMaterial, FEElasticMaterial)
ADD_PARAMETER(m_wmin , FE_RANGE_CLOSED(0.0, 1.0), "wmin");
ADD_PARAMETER(m_btype, FE_RANGE_CLOSED(1,2), "kinetics")->setEnums("(invalid)\0Type I\0Type II\0");
ADD_PARAMETER(m_ttype, FE_RANGE_CLOSED(0,2), "trigger")->setEnums("any strain\0distortional\0dilatational\0");
ADD_PARAMETER(m_emin , FE_RANGE_GREATER_OR_EQUAL(0.0), "emin");
// set material properties
ADD_PROPERTY(m_pBase, "elastic");
ADD_PROPERTY(m_pBond, "bond");
ADD_PROPERTY(m_pRelx, "relaxation");
ADD_PROPERTY(m_pWCDF, "recruitment", FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! constructor
FEReactiveViscoelasticMaterial::FEReactiveViscoelasticMaterial(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_wmin = 0;
m_btype = 1;
m_ttype = 0;
m_emin = 0;
m_nmax = 0;
m_pBase = nullptr;
m_pBond = nullptr;
m_pRelx = nullptr;
m_pWCDF = nullptr;
m_pDmg = nullptr;
m_pFtg = nullptr;
m_pRPD = nullptr;
}
//-----------------------------------------------------------------------------
//! data initialization
bool FEReactiveViscoelasticMaterial::Init()
{
FEUncoupledMaterial* m_pMat = dynamic_cast<FEUncoupledMaterial*>((FEElasticMaterial*)m_pBase);
if (m_pMat != nullptr) {
feLogError("Elastic material should not be of type uncoupled");
return false;
}
m_pMat = dynamic_cast<FEUncoupledMaterial*>((FEElasticMaterial*)m_pBond);
if (m_pMat != nullptr) {
feLogError("Bond material should not be of type uncoupled");
return false;
}
if (!m_pBase->Init()) return false;
if (!m_pBond->Init()) return false;
if (!m_pRelx->Init()) return false;
if (m_pWCDF && !m_pWCDF->Init()) return false;
m_pDmg = dynamic_cast<FEDamageMaterial*>(m_pBase);
m_pFtg = dynamic_cast<FEReactiveFatigue*>(m_pBase);
m_pRPD = dynamic_cast<FEReactivePlasticDamage*>(m_pBase);
return FEElasticMaterial::Init();
}
//-----------------------------------------------------------------------------
//! Create material point data arrayfor this material
FEMaterialPointData* FEReactiveViscoelasticMaterial::CreateMaterialPointData()
{
FEReactiveViscoelasticMaterialPoint* pt = new FEReactiveViscoelasticMaterialPoint();
// create materal point for strong bond (base) material
FEMaterialPoint* pbase = new FEMaterialPoint(m_pBase->CreateMaterialPointData());
pt->AddMaterialPoint(pbase);
// create materal point for weak bond material
FEReactiveVEMaterialPoint* pbond = new FEReactiveVEMaterialPoint(m_pBond->CreateMaterialPointData());
pt->AddMaterialPoint(new FEMaterialPoint(pbond));
return pt;
}
//-----------------------------------------------------------------------------
//! get base material point
FEMaterialPoint* FEReactiveViscoelasticMaterial::GetBaseMaterialPoint(FEMaterialPoint& mp)
{
// get the reactive viscoelastic point data
FEReactiveViscoelasticMaterialPoint& rvp = *mp.ExtractData<FEReactiveViscoelasticMaterialPoint>();
// get the elastic material point
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
// extract the strong bond material point data
FEMaterialPoint* sb = rvp.GetPointData(0);
sb->m_elem = mp.m_elem;
sb->m_index = mp.m_index;
sb->m_rt = mp.m_rt;
sb->m_r0 = mp.m_r0;
// copy the elastic material point data to the strong bond component
FEElasticMaterialPoint& epi = *sb->ExtractData<FEElasticMaterialPoint>();
epi.m_F = ep.m_F;
epi.m_J = ep.m_J;
epi.m_v = ep.m_v;
epi.m_a = ep.m_a;
epi.m_L = ep.m_L;
return sb;
}
//-----------------------------------------------------------------------------
//! get bond material point
FEMaterialPoint* FEReactiveViscoelasticMaterial::GetBondMaterialPoint(FEMaterialPoint& mp)
{
// get the reactive viscoelastic point data
FEReactiveViscoelasticMaterialPoint& rvp = *mp.ExtractData<FEReactiveViscoelasticMaterialPoint>();
// get the elastic material point data
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
// extract the weak bond material point data
FEMaterialPoint* wb = rvp.GetPointData(1);
wb->m_elem = mp.m_elem;
wb->m_index = mp.m_index;
wb->m_rt = mp.m_rt;
wb->m_r0 = mp.m_r0;
// copy the elastic material point data to the weak bond component
FEElasticMaterialPoint& epi = *wb->ExtractData<FEElasticMaterialPoint>();
epi.m_F = ep.m_F;
epi.m_J = ep.m_J;
epi.m_v = ep.m_v;
epi.m_a = ep.m_a;
epi.m_L = ep.m_L;
return wb;
}
//-----------------------------------------------------------------------------
//! detect new generation
bool FEReactiveViscoelasticMaterial::NewGeneration(FEMaterialPoint& mp)
{
double d;
double eps = max(m_emin, 10*std::numeric_limits<double>::epsilon());
// check if the reforming bond mass fraction is above the minimum threshold wmin
if (ReformingBondMassFraction(mp) < m_wmin) return false;
// get the reactive viscoelastic point data
FEReactiveVEMaterialPoint& pt = *mp.ExtractData<FEReactiveVEMaterialPoint>();
// get the elastic point data
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
// check if the current deformation gradient is different from that of
// the last generation, in which case store the current state
// evaluate the relative deformation gradient
mat3d F = ep.m_F;
int lg = (int)pt.m_Uv.size() - 1;
mat3ds Ui = (lg > -1) ? pt.m_Uv[lg].inverse() : mat3dd(1);
mat3d Fu = F*Ui;
switch (m_ttype) {
case 0:
{
// trigger in response to any strain
// evaluate the Lagrangian strain
mat3ds E = ((Fu.transpose()*Fu).sym() - mat3dd(1))/2;
d = E.norm();
}
break;
case 1:
{
// trigger in response to distortional strain
// evaluate spatial Hencky (logarithmic) strain
mat3ds Bu = (Fu*Fu.transpose()).sym();
double l[3];
vec3d v[3];
Bu.eigen2(l,v);
mat3ds h = (dyad(v[0])*log(l[0]) + dyad(v[1])*log(l[1]) + dyad(v[2])*log(l[2]))/2;
// evaluate distortion magnitude (always positive)
d = (h.dev()).norm();
}
break;
case 2:
{
// trigger in response to dilatational strain
d = fabs(log(Fu.det()));
}
break;
default:
d = 0;
break;
}
if (d > eps) return true;
return false;
}
//-----------------------------------------------------------------------------
//! evaluate bond mass fraction
double FEReactiveViscoelasticMaterial::BreakingBondMassFraction(FEMaterialPoint& mp, const int ig, const mat3ds D)
{
// get the reactive viscoelastic point data
FEReactiveVEMaterialPoint& pt = *mp.ExtractData<FEReactiveVEMaterialPoint>();
// bond mass fraction
double w = 0;
// current time
double time = CurrentTime();
double dtv = time - pt.m_v[ig];
switch (m_btype) {
case 1:
{
if (dtv >= 0)
w = pt.m_f[ig]*m_pRelx->Relaxation(mp, dtv, D);
}
break;
case 2:
{
if (ig == 0) {
w = m_pRelx->Relaxation(mp, dtv, D);
}
else
{
double dtu = time - pt.m_v[ig-1];
w = m_pRelx->Relaxation(mp, dtv, D) - m_pRelx->Relaxation(mp, dtu, D);
}
}
break;
default:
break;
}
assert(w >= 0);
return w;
}
//-----------------------------------------------------------------------------
//! evaluate bond mass fraction of reforming generation
double FEReactiveViscoelasticMaterial::ReformingBondMassFraction(FEMaterialPoint& mp)
{
// get the elastic material point data
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
// get the reactive viscoelastic point data
FEReactiveVEMaterialPoint& pt = *mp.ExtractData<FEReactiveVEMaterialPoint>();
mat3ds D = ep.RateOfDeformation();
// keep safe copy of deformation gradient
mat3d F = ep.m_F;
double J = ep.m_J;
// get current number of generations
int ng = (int)pt.m_Uv.size();
double f = 1;
for (int ig=0; ig<ng-1; ++ig)
{
// evaluate deformation gradient when this generation starts breaking
ep.m_F = pt.m_Uv[ig];
ep.m_J = pt.m_Jv[ig];
// evaluate the breaking bond mass fraction for this generation
f -= BreakingBondMassFraction(mp, ig, D);
}
// restore safe copy of deformation gradient
ep.m_F = F;
ep.m_J = J;
assert(f >= 0);
// return the bond mass fraction of the reforming generation
return f;
}
//-----------------------------------------------------------------------------
//! Stress function for strong bonds
mat3ds FEReactiveViscoelasticMaterial::StressStrongBonds(FEMaterialPoint& mp)
{
mat3ds s = m_pBase->Stress(*GetBaseMaterialPoint(mp));
return s;
}
//-----------------------------------------------------------------------------
//! Stress function for weak bonds
mat3ds FEReactiveViscoelasticMaterial::StressWeakBonds(FEMaterialPoint& mp)
{
double dt = CurrentTime();
if (dt == 0) return mat3ds(0, 0, 0, 0, 0, 0);
FEMaterialPoint& wb = *GetBondMaterialPoint(mp);
// get the reactive viscoelastic point data
FEReactiveVEMaterialPoint& pt = *wb.ExtractData<FEReactiveVEMaterialPoint>();
// get the elastic point data
FEElasticMaterialPoint& ep = *wb.ExtractData<FEElasticMaterialPoint>();
// get fiber material point data (if it exists)
FEFiberMaterialPoint* fp = wb.ExtractData<FEFiberMaterialPoint>();
mat3ds D = ep.RateOfDeformation();
// calculate the base material Cauchy stress
mat3ds s; s.zero();
// current number of breaking generations
int ng = (int)pt.m_Uv.size();
// no bonds have broken
if (ng == 0) {
s += m_pBond->Stress(wb);
}
// bonds have broken
else {
// keep safe copy of deformation gradient
mat3d F = ep.m_F;
double J = ep.m_J;
double w;
mat3ds sb;
// calculate the bond stresses for breaking generations
for (int ig=0; ig<ng; ++ig) {
// evaluate bond mass fraction for this generation
ep.m_F = pt.m_Uv[ig];
ep.m_J = pt.m_Jv[ig];
w = BreakingBondMassFraction(wb, ig, D)*pt.m_wv[ig];
// evaluate relative deformation gradient for this generation
if (ig > 0) {
ep.m_F = F*pt.m_Uv[ig-1].inverse();
ep.m_J = J/pt.m_Jv[ig-1];
if (fp) fp->SetPreStretch(pt.m_Uv[ig-1]);
}
else {
ep.m_F = F;
ep.m_J = J;
if (fp) fp->ResetPreStretch();
}
// evaluate bond stress
sb = m_pBond->Stress(wb);
// add bond stress to total stress
s += (ig > 0) ? sb*w/pt.m_Jv[ig-1] : sb*w;
}
// restore safe copy of deformation gradient
ep.m_F = F;
ep.m_J = J;
}
ep.m_s = s;
return s;
}
//-----------------------------------------------------------------------------
//! Stress function
mat3ds FEReactiveViscoelasticMaterial::Stress(FEMaterialPoint& mp)
{
mat3ds s = StressStrongBonds(mp);
s+= StressWeakBonds(mp)*(1-Damage(mp));
// return the total Cauchy stress
return s;
}
//-----------------------------------------------------------------------------
//! Material tangent for strong bonds
tens4ds FEReactiveViscoelasticMaterial::TangentStrongBonds(FEMaterialPoint& mp)
{
// calculate the base material tangent
return m_pBase->Tangent(*GetBaseMaterialPoint(mp));
}
//-----------------------------------------------------------------------------
//! Material tangent for weak bonds
tens4ds FEReactiveViscoelasticMaterial::TangentWeakBonds(FEMaterialPoint& mp)
{
FEMaterialPoint& wb = *GetBondMaterialPoint(mp);
// get the reactive viscoelastic point data
FEReactiveVEMaterialPoint& pt = *wb.ExtractData<FEReactiveVEMaterialPoint>();
// get the elastic point data
FEElasticMaterialPoint& ep = *wb.ExtractData<FEElasticMaterialPoint>();
// get fiber material point data (if it exists)
FEFiberMaterialPoint* fp = wb.ExtractData<FEFiberMaterialPoint>();
mat3ds D = ep.RateOfDeformation();
// calculate the base material tangent
tens4ds c; c.zero();
// current number of breaking generations
int ng = (int)pt.m_Uv.size();
// no bonds have broken
if (ng == 0) {
c += m_pBond->Tangent(wb);
}
// bonds have broken
else {
// keep safe copy of deformation gradient
mat3d F = ep.m_F;
double J = ep.m_J;
double w;
tens4ds cb;
// calculate the bond tangents for breaking generations
for (int ig=0; ig<ng; ++ig) {
// evaluate bond mass fraction for this generation
ep.m_F = pt.m_Uv[ig];
ep.m_J = pt.m_Jv[ig];
w = BreakingBondMassFraction(wb, ig, D)*pt.m_wv[ig];
// evaluate relative deformation gradient for this generation
if (ig > 0) {
ep.m_F = F*pt.m_Uv[ig-1].inverse();
ep.m_J = J/pt.m_Jv[ig-1];
if (fp) fp->SetPreStretch(pt.m_Uv[ig-1]);
}
else {
ep.m_F = F;
ep.m_J = J;
if (fp) fp->ResetPreStretch();
}
// evaluate bond tangent
cb = m_pBond->Tangent(wb);
// add bond tangent to total tangent
c += (ig > 0) ? cb*w/pt.m_Jv[ig-1] : cb*w;
}
// restore safe copy of deformation gradient
ep.m_F = F;
ep.m_J = J;
}
return c;
}
//-----------------------------------------------------------------------------
//! Material tangent
tens4ds FEReactiveViscoelasticMaterial::Tangent(FEMaterialPoint& mp)
{
tens4ds c = TangentStrongBonds(mp);
c += TangentWeakBonds(mp)*(1-Damage(mp));
// return the total tangent
return c;
}
//-----------------------------------------------------------------------------
//! strain energy density function in strong bonds
double FEReactiveViscoelasticMaterial::StrongBondSED(FEMaterialPoint& mp)
{
// calculate the base material strain energy density
return m_pBase->StrainEnergyDensity(*GetBaseMaterialPoint(mp));
}
//-----------------------------------------------------------------------------
//! strain energy density function in weak bonds
double FEReactiveViscoelasticMaterial::WeakBondSED(FEMaterialPoint& mp)
{
double dt = CurrentTime();
if (dt == 0) return 0;
FEMaterialPoint& wb = *GetBondMaterialPoint(mp);
// get the reactive viscoelastic point data
FEReactiveVEMaterialPoint& pt = *wb.ExtractData<FEReactiveVEMaterialPoint>();
// get the elastic point data
FEElasticMaterialPoint& ep = *wb.ExtractData<FEElasticMaterialPoint>();
// get fiber material point data (if it exists)
FEFiberMaterialPoint* fp = wb.ExtractData<FEFiberMaterialPoint>();
// get the viscous point data
mat3ds D = ep.RateOfDeformation();
double sed = 0;
// current number of breaking generations
int ng = (int)pt.m_Uv.size();
// no bonds have broken
if (ng == 0) {
sed += m_pBond->StrainEnergyDensity(wb);
}
// bonds have broken
else {
// keep safe copy of deformation gradient
mat3d F = ep.m_F;
double J = ep.m_J;
double w;
double sedb;
// calculate the strain energy density for breaking generations
for (int ig=0; ig<ng; ++ig) {
// evaluate bond mass fraction for this generation
ep.m_F = pt.m_Uv[ig];
ep.m_J = pt.m_Jv[ig];
w = BreakingBondMassFraction(wb, ig, D)*pt.m_wv[ig];
// evaluate relative deformation gradient for this generation
if (ig > 0) {
ep.m_F = F*pt.m_Uv[ig-1].inverse();
ep.m_J = J/pt.m_Jv[ig-1];
if (fp) fp->SetPreStretch(pt.m_Uv[ig-1]);
}
else {
ep.m_F = F;
ep.m_J = J;
if (fp) fp->ResetPreStretch();
}
// evaluate bond strain energy density
sedb = m_pBond->StrainEnergyDensity(wb);
// add bond strain energy density to total
sed += sedb*w;
}
// restore safe copy of deformation gradient
ep.m_F = F;
ep.m_J = J;
}
return sed;
}
//-----------------------------------------------------------------------------
//! strain energy density function
double FEReactiveViscoelasticMaterial::StrainEnergyDensity(FEMaterialPoint& mp)
{
double sed = StrongBondSED(mp);
sed += WeakBondSED(mp)*(1-Damage(mp));
// return the total strain energy density
return sed;
}
//-----------------------------------------------------------------------------
//! Cull generations that have relaxed below a threshold
void FEReactiveViscoelasticMaterial::CullGenerations(FEMaterialPoint& mp)
{
// get the elastic material point data
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
// get the reactive viscoelastic point data
FEReactiveVEMaterialPoint& pt = *mp.ExtractData<FEReactiveVEMaterialPoint>();
mat3ds D = ep.RateOfDeformation();
// keep safe copy of deformation gradient
mat3d F = ep.m_F;
double J = ep.m_J;
int ng = (int)pt.m_v.size();
m_nmax = max(m_nmax, ng);
// don't cull if we have too few generations
if (ng < 3) return;
// don't reduce number of generations to less than max value achieved so far
if (ng < m_nmax) return;
// always check oldest generation
ep.m_F = pt.m_Uv[0];
ep.m_J = pt.m_Jv[0];
double w0 = BreakingBondMassFraction(mp, 0, D)*pt.m_wv[0];
if (w0 < m_wmin) {
ep.m_F = pt.m_Uv[1];
ep.m_J = pt.m_Jv[1];
double w1 = BreakingBondMassFraction(mp, 1, D)*pt.m_wv[1];
pt.m_v[1] = (w0*pt.m_v[0] + w1*pt.m_v[1])/(w0+w1);
pt.m_Uv[1] = (pt.m_Uv[0]*w0 + pt.m_Uv[1]*w1)/(w0+w1);
pt.m_Jv[1] = pt.m_Uv[1].det();
pt.m_f[1] = (w0*pt.m_f[0] + w1*pt.m_f[1])/(w0+w1);
pt.m_wv[1] = (w0*pt.m_wv[0] + w1*pt.m_wv[1])/(w0+w1);
pt.m_Uv.pop_front();
pt.m_Jv.pop_front();
pt.m_v.pop_front();
pt.m_f.pop_front();
pt.m_wv.pop_front();
}
// restore safe copy of deformation gradient
ep.m_F = F;
ep.m_J = J;
return;
}
//-----------------------------------------------------------------------------
//! Update specialized material points
void FEReactiveViscoelasticMaterial::UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp)
{
FEMaterialPoint& sb = *GetBaseMaterialPoint(mp);
FEMaterialPoint& wb = *GetBondMaterialPoint(mp);
// start by updating specialized material points of base and bond materials
m_pBase->UpdateSpecializedMaterialPoints(sb, tp);
m_pBond->UpdateSpecializedMaterialPoints(wb, tp);
// if the this material is a fiber and if the fiber is in compression, skip this update
if ((dynamic_cast<FEElasticFiberMaterial*>(m_pBase)) && (dynamic_cast<FEElasticFiberMaterial*>(m_pBond)))
if ((m_pBase->Stress(mp)).norm() == 0) return;
// get the reactive viscoelastic point data
FEReactiveVEMaterialPoint& pt = *wb.ExtractData<FEReactiveVEMaterialPoint>();
// get the elastic point data
FEElasticMaterialPoint& ep = *wb.ExtractData<FEElasticMaterialPoint>();
mat3ds Uv = ep.RightStretch();
double Jv = ep.m_J;
// if new generation not already created for current time, check if it should
if (pt.m_v.empty() || (pt.m_v.back() < tp.currentTime)) {
// check if the current deformation gradient is different from that of
// the last generation, in which case store the current state
if (NewGeneration(wb)) {
pt.m_v.push_back(tp.currentTime);
pt.m_Uv.push_back(Uv);
pt.m_Jv.push_back(Jv);
if (m_pWCDF) {
pt.m_Et = ScalarStrain(mp);
pt.m_wv.push_back(m_pWCDF->brf(mp,pt.m_Et));
}
else pt.m_wv.push_back(1);
double f = (!pt.m_v.empty()) ? ReformingBondMassFraction(wb) : 1;
pt.m_f.push_back(f);
CullGenerations(wb);
}
}
// otherwise, if we already have a generation for the current time, update the stored values
else if (pt.m_v.back() == tp.currentTime) {
pt.m_Uv.back() = Uv;
pt.m_Jv.back() = Jv;
if (m_pWCDF) {
pt.m_Et = ScalarStrain(mp);
pt.m_wv.back() = m_pWCDF->brf(mp,pt.m_Et);
}
pt.m_f.back() = ReformingBondMassFraction(wb);
}
}
//-----------------------------------------------------------------------------
//! evaluate bond mass fraction of reforming generation
int FEReactiveViscoelasticMaterial::RVEGenerations(FEMaterialPoint& mp)
{
FEMaterialPoint& wb = *GetBondMaterialPoint(mp);
// get the reactive viscoelastic point data
FEReactiveVEMaterialPoint& pt = *wb.ExtractData<FEReactiveVEMaterialPoint>();
// return the bond mass fraction of the reforming generation
return (int)pt.m_v.size();
}
//-----------------------------------------------------------------------------
//! evaluate trigger strain
double FEReactiveViscoelasticMaterial::ScalarStrain(FEMaterialPoint& mp)
{
double d;
// get the elastic point data
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
switch (m_ttype) {
case 0:
{
// evaluate the Lagrangian strain
mat3ds E = ep.Strain();
d = E.norm();
}
break;
case 1:
{
// distortional strain
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = ep.LeftHencky();
// evaluate distortion magnitude (always positive)
d = (h.dev()).norm();
}
break;
case 2:
{
// dilatational strain
d = fabs(log(ep.m_J));
}
break;
default:
d = 0;
break;
}
return d;
}
//-----------------------------------------------------------------------------
double FEReactiveViscoelasticMaterial::Damage(FEMaterialPoint& mp)
{
double D = 0;
if (m_pDmg) D = m_pDmg->Damage(*GetBaseMaterialPoint(mp));
else if (m_pFtg) D = m_pFtg->Damage(*GetBaseMaterialPoint(mp));
else if (m_pRPD) {
FEMaterialPoint& pt = *GetBaseMaterialPoint(mp);
const FEReactiveMaterialPoint* ppd = pt.ExtractData<FEReactiveMaterialPoint>();
D = ppd->BrokenBonds();
}
return D;
}
void FEReactiveViscoelasticMaterial::Serialize(DumpStream& ar)
{
FEElasticMaterial::Serialize(ar);
ar & m_nmax;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFixedRotation.cpp | .cpp | 1,951 | 53 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2020 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEFixedRotation.h"
BEGIN_FECORE_CLASS(FEFixedRotation, FEFixedBC)
ADD_PARAMETER(m_dof[0], "u_dof")->setLongName("x-rotation");
ADD_PARAMETER(m_dof[1], "v_dof")->setLongName("y-rotation");
ADD_PARAMETER(m_dof[2], "w_dof")->setLongName("z-rotation");
END_FECORE_CLASS();
FEFixedRotation::FEFixedRotation(FEModel* fem) : FEFixedBC(fem)
{
m_dof[0] = false;
m_dof[1] = false;
m_dof[2] = false;
}
bool FEFixedRotation::Init()
{
vector<int> dofs;
if (m_dof[0]) dofs.push_back(GetDOFIndex("u"));
if (m_dof[1]) dofs.push_back(GetDOFIndex("v"));
if (m_dof[2]) dofs.push_back(GetDOFIndex("w"));
SetDOFList(dofs);
return FEFixedBC::Init();
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEGrowthTensor.cpp | .cpp | 6,679 | 201 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2019 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "FEGrowthTensor.h"
#include <FECore/FEConstValueVec3.h>
//-----------------------------------------------------------------------------
//! Growth tensor
//!
// define the material parameters
BEGIN_FECORE_CLASS(FEGrowthTensor, FEMaterialProperty)
ADD_PROPERTY(m_fiber, "fiber", FEProperty::Optional)->SetDefaultType("vector");
END_FECORE_CLASS();
FEGrowthTensor::FEGrowthTensor(FEModel* pfem) : FEMaterialProperty(pfem)
{
m_fiber = nullptr;
}
FEGrowthTensor::~FEGrowthTensor() {}
bool FEGrowthTensor::Init()
{
if (m_fiber == nullptr) {
FEConstValueVec3* val = fecore_new<FEConstValueVec3>("vector", nullptr);
val->value() = vec3d(1,0,0);
m_fiber = val;
}
return FEMaterialProperty::Init();
}
//-----------------------------------------------------------------------------
//! Volume growth
//!
// define the material parameters
BEGIN_FECORE_CLASS(FEVolumeGrowth, FEGrowthTensor)
ADD_PARAMETER(m_gm, "multiplier")->setLongName("volumetric growth multiplier");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! growth tensor
mat3d FEVolumeGrowth::GrowthTensor(FEMaterialPoint& pt, const vec3d& n0)
{
return mat3dd(m_gm(pt));
}
//-----------------------------------------------------------------------------
//! inverse of growth tensor
mat3d FEVolumeGrowth::GrowthTensorInverse(FEMaterialPoint& pt, const vec3d& n0)
{
return mat3dd(1./m_gm(pt));
}
//-----------------------------------------------------------------------------
//! referential solid density
double FEVolumeGrowth::GrowthDensity(FEMaterialPoint& pt, const vec3d& n0)
{
return pow(m_gm(pt), 3);
}
//-----------------------------------------------------------------------------
//! Area growth
//!
// define the material parameters
BEGIN_FECORE_CLASS(FEAreaGrowth, FEGrowthTensor)
ADD_PARAMETER(m_gm , "multiplier")->setLongName("areal growth multiplier");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! growth tensor
mat3d FEAreaGrowth::GrowthTensor(FEMaterialPoint& pt, const vec3d& n0)
{
double gmiso = sqrt(m_gm(pt));
double gmani = 2 - gmiso;
mat3d Fg = mat3dd(gmiso) + (n0 & n0)*(gmani - 1);
return Fg;
}
//-----------------------------------------------------------------------------
//! inverse of growth tensor
mat3d FEAreaGrowth::GrowthTensorInverse(FEMaterialPoint& pt, const vec3d& n0)
{
double gmiso = sqrt(m_gm(pt));
double gmani = 2 - gmiso;
mat3d Fgi = mat3dd(1./gmiso) - (n0 & n0)*((gmani - 1)/gmiso/(gmiso+gmani-1));
return Fgi;
}
//-----------------------------------------------------------------------------
//! referential solid density
double FEAreaGrowth::GrowthDensity(FEMaterialPoint& pt, const vec3d& n0)
{
return m_gm(pt);
}
//-----------------------------------------------------------------------------
//! Fiber growth
//!
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberGrowth, FEGrowthTensor)
ADD_PARAMETER(m_gm , "multiplier")->setLongName("uniaxial growth multiplier");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! growth tensor
mat3d FEFiberGrowth::GrowthTensor(FEMaterialPoint& pt, const vec3d& n0)
{
double gmiso = 1;
double gmani = m_gm(pt);
mat3d Fg = mat3dd(gmiso) + (n0 & n0)*(gmani - 1);
return Fg;
}
//-----------------------------------------------------------------------------
//! inverse of growth tensor
mat3d FEFiberGrowth::GrowthTensorInverse(FEMaterialPoint& pt, const vec3d& n0)
{
double gmiso = 1;
double gmani = m_gm(pt);
mat3d Fgi = mat3dd(1./gmiso) - (n0 & n0)*((gmani - 1)/gmiso/(gmiso+gmani-1));
return Fgi;
}
//-----------------------------------------------------------------------------
//! referential solid density
double FEFiberGrowth::GrowthDensity(FEMaterialPoint& pt, const vec3d& n0)
{
return m_gm(pt);
}
//-----------------------------------------------------------------------------
//! General growth
//!
// define the material parameters
BEGIN_FECORE_CLASS(FEGeneralGrowth, FEGrowthTensor)
ADD_PARAMETER(m_gi , "iso")->setLongName("isotropic growth multiplier");
ADD_PARAMETER(m_ga , "ani")->setLongName("anisotropic growth multiplier");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! growth tensor
mat3d FEGeneralGrowth::GrowthTensor(FEMaterialPoint& pt, const vec3d& n0)
{
double gmiso = m_gi(pt);
double gmani = m_ga(pt);
mat3d Fg = mat3dd(gmiso) + (n0 & n0)*(gmani - 1);
return Fg;
}
//-----------------------------------------------------------------------------
//! inverse of growth tensor
mat3d FEGeneralGrowth::GrowthTensorInverse(FEMaterialPoint& pt, const vec3d& n0)
{
double gmiso = m_gi(pt);
double gmani = m_ga(pt);
double den = gmiso + gmani - 1;
double da = (gmani-1)/gmiso;
double di = 1 + da;
mat3d Fgi = mat3dd(di/den) - (n0 & n0)*(da/den);
return Fgi;
}
//-----------------------------------------------------------------------------
//! referential solid density
double FEGeneralGrowth::GrowthDensity(FEMaterialPoint& pt, const vec3d& n0)
{
double gmiso = m_gi(pt);
double gmani = m_ga(pt);
double den = gmiso + gmani - 1;
return pow(gmiso,2)*(gmani+gmiso-1);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEElasticFiberMaterialUC.h | .h | 4,260 | 109 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
//-----------------------------------------------------------------------------
//! Base class for single fiber response
class FEElasticFiberMaterialUC : public FEUncoupledMaterial
{
public:
FEElasticFiberMaterialUC(FEModel* pfem);
// Get the fiber direction (in global coordinates) at a material point
vec3d FiberVector(FEMaterialPoint& mp);
// calculate stress in fiber direction a0
virtual mat3ds DevFiberStress(FEMaterialPoint& mp, const vec3d& a0) = 0;
// Spatial tangent
virtual tens4ds DevFiberTangent(FEMaterialPoint& mp, const vec3d& a0) = 0;
//! Strain energy density
virtual double DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) = 0;
// Set or clear pre-stretch, as needed in multigenerational materials (e.g., reactive viscoelasticity)
void SetPreStretch(const mat3ds& Us) { m_Us = Us; m_bUs = true; }
void ResetPreStretch() { m_bUs = false; }
vec3d FiberPreStretch(const vec3d& a0);
private:
// These are made private since fiber materials should implement the functions above instead.
// The functions can still be reached when a fiber material is used in an elastic mixture.
// In those cases the fiber vector is taken from the first column of Q.
mat3ds DevStress(FEMaterialPoint& mp) final { return DevFiberStress(mp, FiberVector(mp)); }
tens4ds DevTangent(FEMaterialPoint& mp) final { return DevFiberTangent(mp, FiberVector(mp)); }
double DevStrainEnergyDensity(FEMaterialPoint& mp) final { return DevFiberStrainEnergyDensity(mp, FiberVector(mp)); }
private:
mat3ds m_Us; //!< pre-stretch tensor for fiber
bool m_bUs; //!< flag for pre-stretch
public:
FEVec3dValuator* m_fiber; //!< fiber orientation
double m_epsf;
DECLARE_FECORE_CLASS();
};
template <class FiberMatUC>
class FEElasticFiberMaterialUC_T : public FEElasticFiberMaterialUC
{
public:
FEElasticFiberMaterialUC_T(FEModel* fem) : FEElasticFiberMaterialUC(fem), m_fib(fem) {}
bool Init() override {
if (m_fib.Init() == false) return false;
return FEElasticFiberMaterialUC::Init();
}
bool Validate() override { return m_fib.Validate(); }
FEMaterialPointData* CreateMaterialPointData() override
{
FEMaterialPointData* mp = FEUncoupledMaterial::CreateMaterialPointData();
mp->SetNext(m_fib.CreateMaterialPointData());
return mp;
}
void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override
{
FEElasticFiberMaterialUC::UpdateSpecializedMaterialPoints(mp, tp);
m_fib.UpdateSpecializedMaterialPoints(mp, tp);
}
mat3ds DevFiberStress(FEMaterialPoint& mp, const vec3d& a0) override { return m_fib.DevFiberStress(mp, a0); }
tens4ds DevFiberTangent(FEMaterialPoint& mp, const vec3d& a0) override { return m_fib.DevFiberTangent(mp, a0); }
double DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) override { return m_fib.DevFiberStrainEnergyDensity(mp, a0); }
protected:
FiberMatUC m_fib;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEDeformationMapGenerator.cpp | .cpp | 5,778 | 198 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEDeformationMapGenerator.h"
#include <FECore/FEModel.h>
#include <FECore/FENodeDataMap.h>
#include <FECore/FEDomainMap.h>
double defgrad(FESolidElement &el, std::vector<vec3d>& X, std::vector<vec3d>& u, mat3d &F, int n);
BEGIN_FECORE_CLASS(FEDeformationMapGenerator, FEElemDataGenerator)
ADD_PARAMETER(m_nodeDisplacementMap, "node_displacement_map");
END_FECORE_CLASS();
FEDeformationMapGenerator::FEDeformationMapGenerator(FEModel* fem) : FEElemDataGenerator(fem)
{
m_nodeMap = nullptr;
}
FEDeformationMapGenerator::~FEDeformationMapGenerator()
{
}
bool FEDeformationMapGenerator::Init()
{
FEModel& fem = *GetFEModel();
FEMesh& mesh = fem.GetMesh();
FEDataMap* map = mesh.FindDataMap(m_nodeDisplacementMap);
if (map == nullptr) return false;
m_nodeMap = dynamic_cast<FENodeDataMap*>(map);
if (m_nodeMap == nullptr) return false;
if (m_nodeMap->DataType() != FE_VEC3D) return false;
return FEElemDataGenerator::Init();
}
// generate the data array for the given element set
FEDataMap* FEDeformationMapGenerator::Generate()
{
FEElementSet& set = *GetElementSet();
FEDomainMap* map = new FEDomainMap(FE_MAT3D, FMT_MATPOINTS);
if (map->Create(&set) == false)
{
assert(false);
return nullptr;
}
FEMesh& mesh = *set.GetMesh();
int N = set.Elements();
for (int i = 0; i < N; ++i)
{
FESolidElement* pel = dynamic_cast<FESolidElement*>(mesh.FindElementFromID(set[i]));
if (pel == nullptr) return nullptr;
FESolidElement& el = *pel;
int ne = el.Nodes();
vector<vec3d> u(ne), X(ne);
for (int j = 0; j < ne; j++)
{
u[j] = m_nodeMap->get<vec3d>(el.m_node[j]);
X[j] = mesh.Node(el.m_node[j]).m_r0 - u[j];
}
int ni = el.GaussPoints();
for (int j = 0; j < ni; ++j)
{
mat3d F;
defgrad(el, X, u, F, j);
map->setValue(i, j, F);
}
}
return map;
}
double invjac0(FESolidElement &el, std::vector<vec3d>& r0, double Ji[3][3], int n)
{
// calculate Jacobian
double J[3][3] = { 0 };
int neln = el.Nodes();
for (int i = 0; i < neln; ++i)
{
const double& Gri = el.Gr(n)[i];
const double& Gsi = el.Gs(n)[i];
const double& Gti = el.Gt(n)[i];
const double& x = r0[i].x;
const double& y = r0[i].y;
const double& z = r0[i].z;
J[0][0] += Gri * x; J[0][1] += Gsi * x; J[0][2] += Gti * x;
J[1][0] += Gri * y; J[1][1] += Gsi * y; J[1][2] += Gti * y;
J[2][0] += Gri * z; J[2][1] += Gsi * z; J[2][2] += Gti * z;
}
// calculate the determinant
double det = J[0][0] * (J[1][1] * J[2][2] - J[1][2] * J[2][1])
+ J[0][1] * (J[1][2] * J[2][0] - J[2][2] * J[1][0])
+ J[0][2] * (J[1][0] * J[2][1] - J[1][1] * J[2][0]);
if (det != 0.0)
{
// calculate the inverse jacobian
double deti = 1.0 / det;
Ji[0][0] = deti * (J[1][1] * J[2][2] - J[1][2] * J[2][1]);
Ji[1][0] = deti * (J[1][2] * J[2][0] - J[1][0] * J[2][2]);
Ji[2][0] = deti * (J[1][0] * J[2][1] - J[1][1] * J[2][0]);
Ji[0][1] = deti * (J[0][2] * J[2][1] - J[0][1] * J[2][2]);
Ji[1][1] = deti * (J[0][0] * J[2][2] - J[0][2] * J[2][0]);
Ji[2][1] = deti * (J[0][1] * J[2][0] - J[0][0] * J[2][1]);
Ji[0][2] = deti * (J[0][1] * J[1][2] - J[1][1] * J[0][2]);
Ji[1][2] = deti * (J[0][2] * J[1][0] - J[0][0] * J[1][2]);
Ji[2][2] = deti * (J[0][0] * J[1][1] - J[0][1] * J[1][0]);
}
return det;
}
double defgrad(FESolidElement &el, std::vector<vec3d>& X, std::vector<vec3d>& u, mat3d &F, int n)
{
// calculate inverse jacobian
double Ji[3][3];
invjac0(el, X, Ji, n);
// shape function derivatives
double *Grn = el.Gr(n);
double *Gsn = el.Gs(n);
double *Gtn = el.Gt(n);
// calculate deformation gradient
F[0][0] = F[0][1] = F[0][2] = 0;
F[1][0] = F[1][1] = F[1][2] = 0;
F[2][0] = F[2][1] = F[2][2] = 0;
int neln = el.Nodes();
for (int i = 0; i < neln; ++i)
{
double Gri = Grn[i];
double Gsi = Gsn[i];
double Gti = Gtn[i];
double x = u[i].x;
double y = u[i].y;
double z = u[i].z;
// calculate global gradient of shape functions
// note that we need the transposed of Ji, not Ji itself !
double GX = Ji[0][0] * Gri + Ji[1][0] * Gsi + Ji[2][0] * Gti;
double GY = Ji[0][1] * Gri + Ji[1][1] * Gsi + Ji[2][1] * Gti;
double GZ = Ji[0][2] * Gri + Ji[1][2] * Gsi + Ji[2][2] * Gti;
// calculate deformation gradient F
F[0][0] += GX * x; F[0][1] += GY * x; F[0][2] += GZ * x;
F[1][0] += GX * y; F[1][1] += GY * y; F[1][2] += GZ * y;
F[2][0] += GX * z; F[2][1] += GY * z; F[2][2] += GZ * z;
}
F[0][0] += 1.0;
F[1][1] += 1.0;
F[2][2] += 1.0;
double D = F.det();
return D;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEForceVelocityContraction.cpp | .cpp | 9,531 | 300 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEForceVelocityContraction.h"
#include "FEElasticMaterial.h"
#include <FECore/log.h>
//-----------------------------------------------------------------------------
FEForceVelocityMaterialPoint::FEForceVelocityMaterialPoint()
{
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEForceVelocityMaterialPoint::Copy()
{
FEForceVelocityMaterialPoint* pt = new FEForceVelocityMaterialPoint(*this);
if (m_pNext) pt->m_pNext = m_pNext->Copy();
return pt;
}
//-----------------------------------------------------------------------------
void FEForceVelocityMaterialPoint::Init()
{
FEMaterialPointData::Init();
m_lambdap = 1;
for (int i=0; i<MAX_TERMS; ++i) {
m_H[i] = 0;
m_Hp[i] = 0;
};
}
//-----------------------------------------------------------------------------
void FEForceVelocityMaterialPoint::Serialize(DumpStream& ar)
{
if (ar.IsSaving())
{
ar << m_lambdap;
for (int i=0; i<MAX_TERMS; ++i) ar << m_H[i] << m_Hp[i];
}
else
{
ar >> m_lambdap;
for (int i=0; i<MAX_TERMS; ++i) ar >> m_H[i] >> m_Hp[i];
}
FEMaterialPointData::Serialize(ar);
}
//////////////////////////////////////////////////////////////////////
// FEForceVelocityContraction
//////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEForceVelocityContraction, FEActiveContractionMaterial);
ADD_PARAMETER(m_ascl , "ascl");
ADD_PARAMETER(m_Tmax , "Tmax");
ADD_PARAMETER(m_ca0 , "ca0");
ADD_PARAMETER(m_camax, "camax");
ADD_PARAMETER(m_beta , "beta");
ADD_PARAMETER(m_l0 , "l0");
ADD_PARAMETER(m_refl , "refl");
ADD_PARAMETER(m_alpha[0] , "alpha1");
ADD_PARAMETER(m_alpha[1] , "alpha2");
ADD_PARAMETER(m_alpha[2] , "alpha3");
ADD_PARAMETER(m_A[0] , "A1");
ADD_PARAMETER(m_A[1] , "A2");
ADD_PARAMETER(m_A[2] , "A3");
ADD_PARAMETER(m_at , "a_t");
ADD_PARAMETER(m_bfvel, "force_velocity" );
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEForceVelocityContraction::FEForceVelocityContraction(FEModel* pfem) : FEActiveContractionMaterial(pfem)
{
m_ascl = 0;
m_Tmax = 1.0;
m_ca0 = 1.0;
m_camax = 0.0;
m_l0 = m_refl = 0;
m_beta = 0;
m_A[0] = m_A[1] = m_A[2] = 0;
m_alpha[0] = m_alpha[1] = m_alpha[2] = 0;
m_at = 0;
m_bfvel = true;
}
//-----------------------------------------------------------------------------
bool FEForceVelocityContraction::Init()
{
if (FEActiveContractionMaterial::Init() == false) return false;
// for backward compatibility we set m_camax to m_ca0 if it is not defined
if (m_camax == 0.0) m_camax = m_ca0;
if (m_camax <= 0.0) { feLogError("camax must be larger than zero"); return false; }
return true;
}
//-----------------------------------------------------------------------------
mat3ds FEForceVelocityContraction::ActiveStress(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the deformation gradient
mat3d F = pt.m_F;
double J = pt.m_J;
double Jm13 = pow(J, -1.0 / 3.0);
// calculate the current material axis lam*a = F*a0;
vec3d a = F*a0;
double lam, lamd;
lam = a.unit();
lamd = lam*Jm13; // i.e. lambda tilde
mat3ds AxA = dyad(a);
// get the activation
double saf = 0.0;
double FVstress = 0.0;
double dt = GetTimeInfo().timeIncrement;
if (m_ascl > 0)
{
double ctenslm = m_ascl;
// current sarcomere length
double strl = m_refl*lamd;
// sarcomere length change
double dl = strl - m_l0;
if (dl >= 0)
{
// calcium sensitivity
double eca50i = (exp(m_beta*dl) - 1);
// ratio of Camax/Ca0
double rca = m_camax/m_ca0;
// active fiber stress
saf = m_Tmax*(eca50i / ( eca50i + rca*rca ))*ctenslm;
if (m_bfvel)
{
FEForceVelocityMaterialPoint& vpt = *mp.ExtractData<FEForceVelocityMaterialPoint>();
double lambdap = vpt.m_lambdap;
double Qac = 0;
double Qac2 = 0;
// double dt = GetFEModel()->GetTime().timeIncrement;
// double dt = 1;
double g;
double h;
// double Hnew;
// double Hnew = 10;
for (int i=0; i<MAX_TERMS; ++i)
{
g = exp(-dt/m_alpha[i]);
h = (1 - g)/(dt/m_alpha[i]);
if ((lamd - lambdap) <= 0)
{
vpt.m_H[i] = vpt.m_Hp[i]*g + (lamd - lambdap)*h;
}
if ((lamd - lambdap) == 0)
{
vpt.m_H[i] = vpt.m_Hp[i]*g + (lamd - lambdap)*h;
}
if ((lamd - lambdap) > 0)
{
vpt.m_H[i] = vpt.m_Hp[i]*g; // POSITIVE VELOCITY SET TO 0
}
Qac += vpt.m_H[i]*m_A[i];
Qac2 = abs(Qac);
}
// return the total Cauchy stress,
// which is the push-forward of sarcomere
// FVstress = saf*(1 - m_at*Qac2)/(1+Qac2); //NEGATIVE ABSOLUTE VALUE OF Q
FVstress = saf*(1 + m_at*Qac)/(1-Qac);
}
else
{
FVstress = saf;
}
}
}
return AxA*FVstress;
}
//-----------------------------------------------------------------------------
tens4ds FEForceVelocityContraction::ActiveStiffness(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the deformation gradient
mat3d F = pt.m_F;
double J = pt.m_J;
double Jm13 = pow(J, -1.0 / 3.0);
// calculate the current material axis lam*a = F*a0;
vec3d a = F*a0;
// normalize material axis and store fiber stretch
double lam, lamd;
lam = a.unit();
lamd = lam*Jm13; // i.e. lambda tilde
// calculate dyad of a: AxA = (a x a)
mat3ds AxA = dyad(a);
tens4ds AxAxAxA = dyad1s(AxA);
double c = 0;
if (m_ascl > 0)
{
// current sarcomere length
double strl = m_refl*lamd;
// sarcomere length change
double dl = strl - m_l0;
if (dl >= 0)
{
// calcium sensitivity
double eca50i = (exp(m_beta*dl) - 1);
double decl = m_beta*m_refl*exp(m_beta*dl);
// ratio of Camax/Ca0
double rca = m_camax / m_ca0;
double d = eca50i + rca*rca;
// active fiber stress
double saf = m_Tmax*(eca50i / d)*m_ascl;
double dsf = m_Tmax*m_ascl*decl*(1.0/ d - eca50i / (d*d));
c = (lamd*dsf - 2.0*saf);
}
}
return AxAxAxA*c;
}
//-----------------------------------------------------------------------------
// update force-velocity material point
void FEForceVelocityContraction::UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp, const vec3d& a0)
{
FEForceVelocityMaterialPoint& pt = *mp.ExtractData<FEForceVelocityMaterialPoint>();
FEElasticMaterialPoint& pe = *mp.ExtractData<FEElasticMaterialPoint>();
double Jm13 = pow(pe.m_J, -1.0/3.0);
vec3d a = pe.m_F*a0;
double lambda1 = a.unit();
pt.m_lambdap = lambda1*Jm13;
for (int i=0; i<FEForceVelocityMaterialPoint::MAX_TERMS; ++i) {
pt.m_Hp[i] = pt.m_H[i];
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPressureRobinBC.h | .h | 2,189 | 63 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FESurfaceLoad.h>
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! The pressure surface is a surface domain that sustains pressure boundary
//! conditions proportional to normal displacement and velocity (Robin BC)
//!
class FEPressureRobinBC : public FESurfaceLoad
{
public:
//! constructor
FEPressureRobinBC(FEModel* pfem);
//! initialization
bool Init() override;
//! update
void Update() override;
public:
//! calculate residual
void LoadVector(FEGlobalVector& R) override;
//! calculate stiffness
void StiffnessMatrix(FELinearSystem& LS) override;
protected:
FEParamDouble m_epsk; //!< normal displacement penalty
FEParamDouble m_epsc; //!< normal velocity penalty
bool m_bshellb; //!< flag for prescribing pressure on shell bottom
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEOgdenUnconstrained.h | .h | 2,019 | 59 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
class FEOgdenUnconstrained : public FEElasticMaterial
{
public:
enum { MAX_TERMS = 6 };
public:
FEOgdenUnconstrained(FEModel* pfem);
//! calculate the stress
mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate the tangent
tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double StrainEnergyDensity(FEMaterialPoint& pt) override;
protected:
void EigenValues(mat3ds& A, double l[3], vec3d r[3], const double eps = 0);
double m_eps;
public:
FEParamDouble m_cp; //!< coefficient mu prime
FEParamDouble m_c[MAX_TERMS]; //!< coefficients mu
FEParamDouble m_m[MAX_TERMS]; //!< powers
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEDamageMaterialUC.h | .h | 2,567 | 72 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
#include "FEDamageMaterialPoint.h"
#include "FEDamageCriterion.h"
#include "FEDamageCDF.h"
//-----------------------------------------------------------------------------
// This material models damage in any hyper-elastic materials.
class FEDamageMaterialUC : public FEUncoupledMaterial
{
public:
FEDamageMaterialUC(FEModel* pfem);
public:
//! calculate stress at material point
mat3ds DevStress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
//! damage
double Damage(FEMaterialPoint& pt);
//! data initialization and checking
bool Init() override;
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
// get the elastic material
FEUncoupledMaterial* GetElasticMaterial() override { return m_pBase; }
public:
FEUncoupledMaterial* m_pBase; // base elastic material
FEDamageCDF* m_pDamg; // damage model
FEDamageCriterion* m_pCrit; // damage criterion
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FE3FieldElasticShellDomain.cpp | .cpp | 20,425 | 612 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include <limits>
#include "FE3FieldElasticShellDomain.h"
#include "FEUncoupledMaterial.h"
#include <FECore/FEModel.h>
#include <FECore/log.h>
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FE3FieldElasticShellDomain, FEElasticShellDomain)
ADD_PARAMETER(m_blaugon, "laugon");
ADD_PARAMETER(m_augtol , "atol");
ADD_PARAMETER(m_naugmin, "minaug");
ADD_PARAMETER(m_naugmax, "maxaug");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
void FE3FieldElasticShellDomain::ELEM_DATA::Serialize(DumpStream& ar)
{
ar & eJ;
ar & ep;
ar & Lk;
}
//-----------------------------------------------------------------------------
FE3FieldElasticShellDomain::FE3FieldElasticShellDomain(FEModel* pfem) : FEElasticShellDomain(pfem)
{
m_blaugon = false;
m_augtol = 0.01;
m_naugmin = 0;
m_naugmax = 0;
}
//-----------------------------------------------------------------------------
FE3FieldElasticShellDomain& FE3FieldElasticShellDomain::operator = (FE3FieldElasticShellDomain& d)
{
m_Elem = d.m_Elem;
m_pMesh = d.m_pMesh;
return (*this);
}
//-----------------------------------------------------------------------------
bool FE3FieldElasticShellDomain::DoAugmentations() const
{
return m_blaugon;
}
//-----------------------------------------------------------------------------
//! Initialize the 3-field domain data
bool FE3FieldElasticShellDomain::Init()
{
// make sure the domain material uses an uncoupled formulation
if (dynamic_cast<FEUncoupledMaterial*>(m_pMat) == 0) return false;
if (FEElasticShellDomain::Init() == false) return false;
// allocate element data
int NE = Elements();
m_Data.resize(NE);
// initialize element data
for (int i=0; i<NE; ++i)
{
ELEM_DATA& d = m_Data[i];
d.eJ = 1.0;
d.ep = 0.0;
d.Lk = 0.0;
}
return true;
}
//-----------------------------------------------------------------------------
void FE3FieldElasticShellDomain::Reset()
{
FEElasticShellDomain::Reset();
// initialize element data
int NE = (int)m_Data.size();
for (int i=0; i<NE; ++i)
{
ELEM_DATA& d = m_Data[i];
d.eJ = 1.0;
d.ep = 0.0;
d.Lk = 0.0;
}
}
//-----------------------------------------------------------------------------
//! Stiffness matrix for three-field domain
void FE3FieldElasticShellDomain::StiffnessMatrix(FELinearSystem& LS)
{
FEModel& fem = *GetFEModel();
// repeat over all solid elements
int NE = (int)m_Elem.size();
#pragma omp parallel for
for (int iel=0; iel<NE; ++iel)
{
FEShellElement& el = m_Elem[iel];
// element stiffness matrix
FEElementMatrix ke(el);
// create the element's stiffness matrix
int ndof = 6*el.Nodes();
ke.resize(ndof, ndof);
ke.zero();
// calculate material and geometrical stiffness (i.e. constitutive component)
ElementStiffness(iel, ke);
// Calculate dilatational stiffness
ElementDilatationalStiffness(fem, iel, ke);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
//! calculates dilatational element stiffness component for element iel
void FE3FieldElasticShellDomain::ElementDilatationalStiffness(FEModel& fem, int iel, matrix& ke)
{
int i, j, i6, j6, n;
FEShellElement& elem = Element(iel);
ELEM_DATA& ed = m_Data[iel];
const int nint = elem.GaussPoints();
const int neln = elem.Nodes();
// get the material
FEUncoupledMaterial* pmi = dynamic_cast<FEUncoupledMaterial*>(m_pMat);
assert(pmi);
// average global derivatives
vector<vec3d> gradMu(neln,vec3d(0,0,0));
vector<vec3d> gradMd(neln,vec3d(0,0,0));
// initial element volume
double Ve = 0;
// global derivatives of shape functions
const double *gw = elem.GaussWeights();
double eta;
vec3d gcnt[3];
// jacobian
double Jt, J0;
const double* Mr, *Ms, *M;
// repeat over gauss-points
for (n=0; n<nint; ++n)
{
// calculate jacobian
J0 = detJ0(elem, n);
Jt = detJ(elem, n);
Jt *= gw[n];
Ve += J0*gw[n];
eta = elem.gt(n);
Mr = elem.Hr(n);
Ms = elem.Hs(n);
M = elem.H(n);
ContraBaseVectors(elem, n, gcnt);
for (i=0; i<neln; ++i)
{
vec3d gradM = gcnt[0]*Mr[i] + gcnt[1]*Ms[i];
gradMu[i] += ((gradM*(1+eta) + gcnt[2]*M[i])/2)*Jt;
gradMd[i] += ((gradM*(1-eta) - gcnt[2]*M[i])/2)*Jt;
}
}
// get effective modulus
double k = pmi->UJJ(ed.eJ);
// next, we add the Lagrangian contribution
// note that this term will always be zero if the material does not
// use the augmented lagrangian
k += ed.Lk*pmi->hpp(ed.eJ);
// divide by initial volume
k /= Ve;
// calculate dilatational stiffness component
for (i=0, i6=0; i<neln; ++i, i6 += 6)
{
for (j=0, j6 = 0; j<neln; ++j, j6 += 6)
{
mat3d Kuu = (gradMu[i] & gradMu[j])*k;
mat3d Kud = (gradMu[i] & gradMd[j])*k;
mat3d Kdu = (gradMd[i] & gradMu[j])*k;
mat3d Kdd = (gradMd[i] & gradMd[j])*k;
ke[i6 ][j6 ] += Kuu(0,0); ke[i6 ][j6+1] += Kuu(0,1); ke[i6 ][j6+2] += Kuu(0,2);
ke[i6+1][j6 ] += Kuu(1,0); ke[i6+1][j6+1] += Kuu(1,1); ke[i6+1][j6+2] += Kuu(1,2);
ke[i6+2][j6 ] += Kuu(2,0); ke[i6+2][j6+1] += Kuu(2,1); ke[i6+2][j6+2] += Kuu(2,2);
ke[i6 ][j6+3] += Kud(0,0); ke[i6 ][j6+4] += Kud(0,1); ke[i6 ][j6+5] += Kud(0,2);
ke[i6+1][j6+3] += Kud(1,0); ke[i6+1][j6+4] += Kud(1,1); ke[i6+1][j6+5] += Kud(1,2);
ke[i6+2][j6+3] += Kud(2,0); ke[i6+2][j6+4] += Kud(2,1); ke[i6+2][j6+5] += Kud(2,2);
ke[i6+3][j6 ] += Kdu(0,0); ke[i6+3][j6+1] += Kdu(0,1); ke[i6+3][j6+2] += Kdu(0,2);
ke[i6+4][j6 ] += Kdu(1,0); ke[i6+4][j6+1] += Kdu(1,1); ke[i6+4][j6+2] += Kdu(1,2);
ke[i6+5][j6 ] += Kdu(2,0); ke[i6+5][j6+1] += Kdu(2,1); ke[i6+5][j6+2] += Kdu(2,2);
ke[i6+3][j6+3] += Kdd(0,0); ke[i6+3][j6+4] += Kdd(0,1); ke[i6+3][j6+5] += Kdd(0,2);
ke[i6+4][j6+3] += Kdd(1,0); ke[i6+4][j6+4] += Kdd(1,1); ke[i6+4][j6+5] += Kdd(1,2);
ke[i6+5][j6+3] += Kdd(2,0); ke[i6+5][j6+4] += Kdd(2,1); ke[i6+5][j6+5] += Kdd(2,2);
}
}
}
//-----------------------------------------------------------------------------
//! Calculates the shell element material and geometrical stiffness matrix
void FE3FieldElasticShellDomain::ElementStiffness(int iel, matrix& ke)
{
FEShellElement& el = Element(iel);
ELEM_DATA& ed = m_Data[iel];
// get the material
FEUncoupledMaterial* pmi = dynamic_cast<FEUncoupledMaterial*>(m_pMat);
assert(pmi);
int i, i6, j, j6, n;
// Get the current element's data
const int nint = el.GaussPoints();
const int neln = el.Nodes();
const double* Mr, *Ms, *M;
vec3d gradMu[FEElement::MAX_NODES], gradMd[FEElement::MAX_NODES];
// jacobian matrix determinant
double detJt;
// weights at gauss points
const double *gw = el.GaussWeights();
double eta;
vec3d gcnt[3];
// get the material
FEUncoupledMaterial& mat = dynamic_cast<FEUncoupledMaterial&>(*m_pMat);
// we need the following tensors for the dilational stiffness
mat3dd I(1);
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds Cp = IxI - I4*2;
// calculate element stiffness matrix
for (n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *(el.GetMaterialPoint(n));
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// calculate the jacobian
detJt = detJ(el, n);
detJt *= gw[n];
// get the material's tangent
// Note that we are only grabbing the deviatoric tangent.
// The other tangent terms depend on the pressure p
// which we seperately
tens4ds C = Cp*ed.ep + mat.DevTangent(mp);
// get the stress
mat3ds s = pt.m_s;
eta = el.gt(n);
Mr = el.Hr(n);
Ms = el.Hs(n);
M = el.H(n);
ContraBaseVectors(el, n, gcnt);
// ------------ constitutive component --------------
// setup the material point
for (i=0; i<neln; ++i)
{
vec3d gradM = gcnt[0]*Mr[i] + gcnt[1]*Ms[i];
gradMu[i] = (gradM*(1+eta) + gcnt[2]*M[i])/2;
gradMd[i] = (gradM*(1-eta) - gcnt[2]*M[i])/2;
}
for (i=0, i6=0; i<neln; ++i, i6 += 6)
{
for (j=0, j6 = 0; j<neln; ++j, j6 += 6)
{
mat3d Kuu = vdotTdotv(gradMu[i], C, gradMu[j])*detJt;
mat3d Kud = vdotTdotv(gradMu[i], C, gradMd[j])*detJt;
mat3d Kdu = vdotTdotv(gradMd[i], C, gradMu[j])*detJt;
mat3d Kdd = vdotTdotv(gradMd[i], C, gradMd[j])*detJt;
ke[i6 ][j6 ] += Kuu(0,0); ke[i6 ][j6+1] += Kuu(0,1); ke[i6 ][j6+2] += Kuu(0,2);
ke[i6+1][j6 ] += Kuu(1,0); ke[i6+1][j6+1] += Kuu(1,1); ke[i6+1][j6+2] += Kuu(1,2);
ke[i6+2][j6 ] += Kuu(2,0); ke[i6+2][j6+1] += Kuu(2,1); ke[i6+2][j6+2] += Kuu(2,2);
ke[i6 ][j6+3] += Kud(0,0); ke[i6 ][j6+4] += Kud(0,1); ke[i6 ][j6+5] += Kud(0,2);
ke[i6+1][j6+3] += Kud(1,0); ke[i6+1][j6+4] += Kud(1,1); ke[i6+1][j6+5] += Kud(1,2);
ke[i6+2][j6+3] += Kud(2,0); ke[i6+2][j6+4] += Kud(2,1); ke[i6+2][j6+5] += Kud(2,2);
ke[i6+3][j6 ] += Kdu(0,0); ke[i6+3][j6+1] += Kdu(0,1); ke[i6+3][j6+2] += Kdu(0,2);
ke[i6+4][j6 ] += Kdu(1,0); ke[i6+4][j6+1] += Kdu(1,1); ke[i6+4][j6+2] += Kdu(1,2);
ke[i6+5][j6 ] += Kdu(2,0); ke[i6+5][j6+1] += Kdu(2,1); ke[i6+5][j6+2] += Kdu(2,2);
ke[i6+3][j6+3] += Kdd(0,0); ke[i6+3][j6+4] += Kdd(0,1); ke[i6+3][j6+5] += Kdd(0,2);
ke[i6+4][j6+3] += Kdd(1,0); ke[i6+4][j6+4] += Kdd(1,1); ke[i6+4][j6+5] += Kdd(1,2);
ke[i6+5][j6+3] += Kdd(2,0); ke[i6+5][j6+4] += Kdd(2,1); ke[i6+5][j6+5] += Kdd(2,2);
}
}
// ------------ initial stress component --------------
for (i=0; i<neln; ++i)
for (j=0; j<neln; ++j)
{
double Kuu = gradMu[i]*(s*gradMu[j])*detJt;
double Kud = gradMu[i]*(s*gradMd[j])*detJt;
double Kdu = gradMd[i]*(s*gradMu[j])*detJt;
double Kdd = gradMd[i]*(s*gradMd[j])*detJt;
// the u-u component
ke[6*i ][6*j ] += Kuu;
ke[6*i+1][6*j+1] += Kuu;
ke[6*i+2][6*j+2] += Kuu;
// the u-d component
ke[6*i ][6*j+3] += Kud;
ke[6*i+1][6*j+4] += Kud;
ke[6*i+2][6*j+5] += Kud;
// the d-u component
ke[6*i+3][6*j ] += Kdu;
ke[6*i+4][6*j+1] += Kdu;
ke[6*i+5][6*j+2] += Kdu;
// the d-d component
ke[6*i+3][6*j+3] += Kdd;
ke[6*i+4][6*j+4] += Kdd;
ke[6*i+5][6*j+5] += Kdd;
}
} // end loop over gauss-points
}
//-----------------------------------------------------------------------------
//! This function loops over all elements and updates the stress
void FE3FieldElasticShellDomain::Update(const FETimeInfo& tp)
{
FESSIShellDomain::Update(tp);
bool berr = false;
int NE = (int) m_Elem.size();
#pragma omp parallel for shared(NE, berr)
for (int i=0; i<NE; ++i)
{
try
{
UpdateElementStress(i);
}
catch (NegativeJacobian e)
{
#pragma omp critical
{
berr = true;
if (e.DoOutput()) feLogError(e.what());
}
}
}
if (berr) throw NegativeJacobianDetected();
}
//-----------------------------------------------------------------------------
//! This function updates the stresses for elements using the three-field formulation.
//! For such elements, the stress is a sum of a deviatoric stress, calculate by the
//! material and a dilatational term.
void FE3FieldElasticShellDomain::UpdateElementStress(int iel)
{
double dt = GetFEModel()->GetTime().timeIncrement;
// get the material
FEUncoupledMaterial& mat = *(dynamic_cast<FEUncoupledMaterial*>(m_pMat));
// get the solid element
FEShellElement& el = m_Elem[iel];
ELEM_DATA& ed = m_Data[iel];
// get the number of integration points
int nint = el.GaussPoints();
// get the integration weights
double* gw = el.GaussWeights();
// number of nodes
int neln = el.Nodes();
// nodal coordinates
const int NELN = FEElement::MAX_NODES;
vec3d r0[NELN], s0[NELN], r[NELN], s[NELN];
vec3d v[NELN], w[NELN];
vec3d a[NELN], b[NELN];
// nodal coordinates
GetCurrentNodalCoordinates(el, r, m_alphaf, false);
GetCurrentNodalCoordinates(el, s, m_alphaf, true);
GetReferenceNodalCoordinates(el, r0, false);
GetReferenceNodalCoordinates(el, s0, true);
// update dynamic quantities
if (m_update_dynamic)
{
for (int j=0; j<neln; ++j)
{
FENode& node = m_pMesh->Node(el.m_node[j]);
v[j] = node.get_vec3d(m_dofV[0], m_dofV[1], m_dofV[2])*m_alphaf + node.m_vp*(1-m_alphaf);
w[j] = node.get_vec3d(m_dofSV[0], m_dofSV[1], m_dofSV[2])*m_alphaf + node.get_vec3d_prev(m_dofSV[0], m_dofSV[1], m_dofSV[2])*(1-m_alphaf);
a[j] = node.m_at*m_alpham + node.m_ap*(1-m_alpham);
b[j] = node.get_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2])*m_alpham + node.get_vec3d_prev(m_dofSA[0], m_dofSA[1], m_dofSA[2])*(1-m_alpham);
}
}
// calculate the average dilatation and pressure
double vt = 0, V = 0;
for (int n=0; n<nint; ++n)
{
vt += detJ(el, n)*gw[n];
V += detJ0(el, n)*gw[n];
}
// calculate volume ratio
ed.eJ = vt / V;
// Calculate pressure. This is a sum of a Lagrangian term and a penalty term
// <--- Lag. mult. --> <-- penalty -->
ed.ep = ed.Lk*mat.hp(ed.eJ) + mat.UJ(ed.eJ);
// ed.ep = mat.UJ(ed.eJ);
// loop over the integration points and calculate
// the stress at the integration point
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
pt.m_p = ed.ep;
// material point coordinates
// TODO: I'm not entirly happy with this solution
// since the material point coordinates are not used by most materials.
mp.m_r0 = evaluate(el, r0, s0, n);
mp.m_rt = evaluate(el, r, s, n);
// get the deformation gradient and determinant at intermediate time
double Jt, Jp;
mat3d Ft, Fp;
Jt = defgrad(el, Ft, n);
Jp = defgradp(el, Fp, n);
pt.m_F = Ft*m_alphaf + Fp*(1-m_alphaf);
pt.m_J = pt.m_F.det();
mat3d Fi = pt.m_F.inverse();
pt.m_L = (Ft - Fp)*Fi/dt;
if (m_update_dynamic)
{
pt.m_v = evaluate(el, v, w, n);
pt.m_a = evaluate(el, a, b, n);
}
// update specialized material points
m_pMat->UpdateSpecializedMaterialPoints(mp, GetFEModel()->GetTime());
// calculate the stress at this material point
// Note that we don't call the material's Stress member function.
// The reason is that we need to use the averaged pressure for the element
// and the Stress function uses the pointwise pressure.
// Therefore we call the DevStress function and add the pressure term
// seperately.
pt.m_s = mat3dd(ed.ep) + mat.DevStress(mp);
// adjust stress for strain energy conservation
if (m_alphaf == 0.5)
{
// evaluate strain energy at current time
mat3d Ftmp = pt.m_F;
double Jtmp = pt.m_J;
pt.m_F = Ft;
pt.m_J = Jt;
FEElasticMaterial* pme = dynamic_cast<FEElasticMaterial*>(m_pMat);
pt.m_Wt = pme->StrainEnergyDensity(mp);
pt.m_F = Ftmp;
pt.m_J = Jtmp;
mat3ds D = pt.m_L.sym();
double D2 = D.dotdot(D);
if (D2 > std::numeric_limits<double>::epsilon())
pt.m_s += D*(((pt.m_Wt-pt.m_Wp)/(dt*pt.m_J) - pt.m_s.dotdot(D))/D2);
}
}
}
//-----------------------------------------------------------------------------
//! Do augmentation
bool FE3FieldElasticShellDomain::Augment(int naug)
{
FEUncoupledMaterial* pmi = dynamic_cast<FEUncoupledMaterial*>(m_pMat);
assert(pmi);
// make sure Augmented Lagrangian flag is on
if (m_blaugon == false) return true;
// do the augmentation
int n;
double normL0 = 0, normL1 = 0, L0, L1;
double k = pmi->m_K;
int NE = Elements();
for (n=0; n<NE; ++n)
{
ELEM_DATA& ed = m_Data[n];
L0 = ed.Lk;
normL0 += L0*L0;
L1 = L0 + k*pmi->h(ed.eJ);
normL1 += L1*L1;
}
normL0 = sqrt(normL0);
normL1 = sqrt(normL1);
// check convergence
double pctn = 0;
if (fabs(normL1) > 1e-10) pctn = fabs((normL1 - normL0)/normL1);
feLog(" material %d\n", pmi->GetID());
feLog(" CURRENT CHANGE REQUIRED\n");
feLog(" pressure norm : %15le%15le%15le\n", normL1, pctn, m_augtol);
// check convergence
bool bconv = true;
if (pctn >= m_augtol) bconv = false;
if (m_naugmin > naug) bconv = false;
if ((m_naugmax > 0) && (m_naugmax <= naug)) bconv = true;
// do the augmentation only if we have not yet converged
if (bconv == false)
{
for (n=0; n<NE; ++n)
{
ELEM_DATA& ed = m_Data[n];
ed.Lk += k*pmi->h(ed.eJ);
ed.ep = ed.Lk*pmi->hp(ed.eJ) + k*log(ed.eJ)/ed.eJ;
}
}
return bconv;
}
//-----------------------------------------------------------------------------
//! Data serialization
void FE3FieldElasticShellDomain::Serialize(DumpStream &ar)
{
FEElasticShellDomain::Serialize(ar);
ar & m_Data;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFungOrthotropic.h | .h | 2,128 | 60 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
class FEFungOrthotropic : public FEUncoupledMaterial
{
public:
double E1, E2, E3; // Young's moduli
double v12, v23, v31; // Poisson's ratio
double G12, G23, G31; // Shear moduli
double lam[3][3]; // first Lame coefficients
double mu[3]; // second Lame coefficients
double m_c; // c coefficient
public:
FEFungOrthotropic(FEModel* pfem);
//! calculate deviatoric stress at material point
mat3ds DevStress(FEMaterialPoint& pt) override;
//! calculate deviatoric tangent stiffness at material point
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
//! data initialization
bool Validate() override;
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FETraceFreeNeoHookean.h | .h | 2,473 | 64 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! Trace-Free Neo Hookean material
//! Implementation of a trace-free neo-Hookean hyperelastic material.
class FEBIOMECH_API FETraceFreeNeoHookean : public FEElasticMaterial
{
public:
FETraceFreeNeoHookean(FEModel* pfem) : FEElasticMaterial(pfem) {}
public:
FEParamDouble m_mu; //!< shear modulus
public:
//! calculate stress at material point
mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! calculate the 2nd Piola-Kirchhoff stress at material point
mat3ds PK2Stress(FEMaterialPoint& pt, const mat3ds E) override;
//! calculate material tangent stiffness at material point
tens4dmm MaterialTangent(FEMaterialPoint& pt, const mat3ds E) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEReactiveVEMaterialPoint.cpp | .cpp | 3,725 | 117 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEReactiveVEMaterialPoint.h"
#include "FEElasticMaterial.h"
//-----------------------------------------------------------------------------
FEReactiveViscoelasticMaterialPoint::FEReactiveViscoelasticMaterialPoint() : FEMaterialPointArray(new FEElasticMaterialPoint)
{
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEReactiveViscoelasticMaterialPoint::Copy()
{
FEReactiveViscoelasticMaterialPoint* pt = new FEReactiveViscoelasticMaterialPoint;
pt->m_mp = m_mp;
if (m_pNext) pt->m_pNext = m_pNext->Copy();
return pt;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEReactiveVEMaterialPoint
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//! Create a shallow copy of the material point data
FEMaterialPointData* FEReactiveVEMaterialPoint::Copy()
{
FEReactiveVEMaterialPoint* pt = new FEReactiveVEMaterialPoint(*this);
if (m_pNext) pt->m_pNext = m_pNext->Copy();
return pt;
}
//-----------------------------------------------------------------------------
//! Initializes material point data.
void FEReactiveVEMaterialPoint::Init()
{
// initialize data to zero
m_Uv.clear();
m_Jv.clear();
m_v.clear();
m_f.clear();
m_Et = 0;
m_wv.clear();
// don't forget to initialize the base class
FEMaterialPointData::Init();
}
void FEReactiveVEMaterialPoint::Update(const FETimeInfo& timeInfo)
{
FEMaterialPointData::Update(timeInfo);
}
//-----------------------------------------------------------------------------
//! Serialize data to the archive
void FEReactiveVEMaterialPoint::Serialize(DumpStream& ar)
{
FEMaterialPointData::Serialize(ar);
if (ar.IsSaving())
{
int n = (int)m_Uv.size();
ar << n;
for (int i=0; i<n; ++i) ar << m_Uv[i] << m_Jv[i] << m_v[i] << m_f[i];
ar << m_Et;
int m = (int)m_wv.size();
ar << m;
for (int i=0; i<m; ++i) ar << m_wv[i];
}
else
{
int n;
ar >> n;
m_Uv.resize(n);
m_Jv.resize(n);
m_v.resize(n);
m_f.resize(n);
for (int i=0; i<n; ++i) ar >> m_Uv[i] >> m_Jv[i] >> m_v[i] >> m_f[i];
ar >> m_Et;
int m;
ar >> m;
m_wv.resize(m);
for (int i=0; i<m; ++i) ar >> m_wv[i];
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationGeodesic.h | .h | 2,377 | 73 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEFiberIntegrationScheme.h"
#include "geodesic.h"
//----------------------------------------------------------------------------------
// Geodesic dome integration scheme for continuous fiber distributions
//
class FEFiberIntegrationGeodesic : public FEFiberIntegrationScheme
{
class Iterator;
public:
FEFiberIntegrationGeodesic(FEModel* pfem);
~FEFiberIntegrationGeodesic();
//! Initialization
bool Init() override;
// serialization
void Serialize(DumpStream& ar) override;
// get iterator
FEFiberIntegrationSchemeIterator* GetIterator(FEMaterialPoint* mp) override;
// get number of integration points
int IntegrationPoints() const override { return m_nint; };
protected:
void InitIntegrationRule();
private: // parameters
int m_nres; // resolution
protected:
int m_nint; // number of integration points
double m_cth[NSTH];
double m_sth[NSTH];
double m_cph[NSTH];
double m_sph[NSTH];
double m_w[NSTH];
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEPreStrainUncoupledElastic.cpp | .cpp | 4,187 | 129 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEPreStrainUncoupledElastic.h"
BEGIN_FECORE_CLASS(FEPreStrainUncoupledElastic, FEUncoupledMaterial)
ADD_PROPERTY(m_mat, "elastic");
ADD_PROPERTY(m_Fp, "prestrain", false);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPreStrainUncoupledElastic::FEPreStrainUncoupledElastic(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_mat = nullptr;
m_Fp = nullptr;
}
//-----------------------------------------------------------------------------
//! Create material point data for this material
FEMaterialPointData* FEPreStrainUncoupledElastic::CreateMaterialPointData()
{
FEMaterialPointData* pm = m_mat->CreateMaterialPointData();
if (m_Fp) pm->Append(m_Fp->CreateMaterialPointData());
return new FEPrestrainMaterialPoint(pm);
}
//-----------------------------------------------------------------------------
//! calculate (pre-strained) density
double FEPreStrainUncoupledElastic::Density(FEMaterialPoint& mp)
{
double d0 = FEElasticMaterial::Density(mp);
mat3d Fp = PrestrainGradient(mp);
double Jp = Fp.det();
return d0 / Jp;
}
//-----------------------------------------------------------------------------
mat3d FEPreStrainUncoupledElastic::PrestrainGradient(FEMaterialPoint& mp)
{
mat3d F0 = mat3d::identity();
if (m_Fp) F0 = m_Fp->Prestrain(mp);
FEPrestrainMaterialPoint& pt = *(mp.ExtractData<FEPrestrainMaterialPoint>());
pt.setInitialPrestrain(F0);
return pt.prestrain();
}
//-----------------------------------------------------------------------------
mat3ds FEPreStrainUncoupledElastic::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& ep = *(mp.ExtractData<FEElasticMaterialPoint>());
FEPrestrainMaterialPoint& pp = *(mp.ExtractData<FEPrestrainMaterialPoint>());
// store the original deformation gradient
mat3d F0 = ep.m_F;
double J0 = ep.m_J;
// get the pre-strain deformation gradient
mat3d Fp = PrestrainGradient(mp);
// pre-multiply the pre-strain
ep.m_F = ep.m_F*Fp;
ep.m_J = ep.m_F.det();
// evaluate the stress
mat3ds s = m_mat->DevStress(mp);
// restore original deformation gradient
ep.m_F = F0;
ep.m_J = J0;
// return stress
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEPreStrainUncoupledElastic::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& ep = *(mp.ExtractData<FEElasticMaterialPoint>());
FEPrestrainMaterialPoint& pt = *(mp.ExtractData<FEPrestrainMaterialPoint>());
// store the original deformation gradient
mat3d F0 = ep.m_F;
double J0 = ep.m_J;
// get the pre-strain deformation gradient
mat3d Fp = pt.prestrain();
// pre-multiply the pre-strain
ep.m_F = ep.m_F*Fp;
ep.m_J = ep.m_F.det();
// evaluate the tangent
tens4ds c = m_mat->DevTangent(mp);
// restore original deformation gradient
ep.m_F = F0;
ep.m_J = J0;
// return spatial tangent
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEReactivePlasticity.cpp | .cpp | 17,886 | 475 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include <cmath>
#include "FEReactivePlasticity.h"
#include "FEDamageCriterion.h"
#include "FEElasticMaterial.h"
#include "FEUncoupledMaterial.h"
#include "FECore/FECoreKernel.h"
#include <FECore/FEMesh.h>
#include <FECore/log.h>
#include <FECore/matrix.h>
//////////////////////// PLASTICITY MATERIAL /////////////////////////////////
// define the material parameters
BEGIN_FECORE_CLASS(FEReactivePlasticity, FEElasticMaterial)
// set material properties
ADD_PROPERTY(m_pBase, "elastic");
ADD_PROPERTY(m_pCrit, "yield_criterion");
ADD_PROPERTY(m_pFlow, "flow_curve");
ADD_PARAMETER(m_isochrc, "isochoric");
ADD_PARAMETER(m_rtol , FE_RANGE_GREATER_OR_EQUAL(0.0), "rtol");
ADD_PARAMETER(m_secant_tangent, "secant_tangent");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEReactivePlasticity::FEReactivePlasticity(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_isochrc = true;
m_rtol = 1e-4;
m_pBase = nullptr;
m_pCrit = nullptr;
m_pFlow = nullptr;
m_secant_tangent = true;
}
//-----------------------------------------------------------------------------
//! Initialization.
bool FEReactivePlasticity::Init()
{
if (m_pFlow->Init() == false) return false;
return FEElasticMaterial::Init();
}
//-----------------------------------------------------------------------------
//! serialiation
void FEReactivePlasticity::Serialize(DumpStream& ar)
{
FEElasticMaterial::Serialize(ar);
ar & m_isochrc & m_rtol;
}
//-----------------------------------------------------------------------------
//! Create material point data for this material
FEMaterialPointData* FEReactivePlasticity::CreateMaterialPointData()
{
FEMaterialPointData* ep = m_pBase->CreateMaterialPointData();
FEMaterialPointData* fp = m_pFlow->CreateMaterialPointData();
fp->SetNext(ep);
return new FEReactivePlasticityMaterialPoint(fp, this);
}
//-----------------------------------------------------------------------------
//! evaluate elastic deformation gradient
void FEReactivePlasticity::ElasticDeformationGradient(FEMaterialPoint& pt)
{
// initialize flow curve (if not done yet)
if (m_pFlow->InitFlowCurve(pt)) {
FEReactivePlasticityMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticityMaterialPoint>();
pp.Init();
}
int n = (int)m_pFlow->BondFamilies(pt);
// extract total deformation gradient
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract inverse of plastic deformation gradient and evaluate elastic deformation gradient
FEReactivePlasticityMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticityMaterialPoint>();
FEPlasticFlowCurveMaterialPoint& fp = *pt.ExtractData<FEPlasticFlowCurveMaterialPoint>();
FEShellElementNew* sel = dynamic_cast<FEShellElementNew*>(pt.m_elem);
for (int i=0; i<n; ++i) {
mat3d Fs = pe.m_F;
mat3d R = pe.m_F*pe.RightStretchInverse();
// for EAS and ANS shells, adjust calculation of Fs using enhanced strain Es
if (sel) {
mat3ds Cs = mat3dd(1) + sel->m_E[pt.m_index]*2;
double eval[3];
vec3d evec[3];
Cs.eigen2(eval,evec);
mat3ds Us = dyad(evec[0])*sqrt(eval[0]) + dyad(evec[1])*sqrt(eval[1]) + dyad(evec[2])*sqrt(eval[2]);
Fs = R*Us;
}
mat3d Fe = Fs*pp.m_Fusi[i];
// store safe copy of total deformation gradient
mat3d Ftmp = pe.m_F;
double Jtmp = pe.m_J;
pe.m_F = Fe; pe.m_J = Fe.det();
mat3ds Ue = pe.RightStretch();
// evaluate yield measure
pp.m_Kv[i] = m_pCrit->DamageCriterion(pt);
// restore total deformation gradient
pe.m_F = Ftmp; pe.m_J = Jtmp;
// if there is no yielding, we're done
double phi = pp.m_Kv[i] - fp.m_Ky[i];
if (phi <= m_rtol*fp.m_Ky[i]) {
pp.m_Fvsi[i] = pp.m_Fusi[i];
continue;
}
// check if i-th bond family is yielding
if ((pp.m_Kv[i] > pp.m_Ku[i]) && (pp.m_Ku[i] < fp.m_Ky[i]*(1+m_rtol)))
pp.m_w[i] = fp.m_w[i];
// find Fv
bool conv = false;
bool done = false;
int maxit = 20;
int iter = 0;
double lam = 0;
mat3d Fv = Fe;
Ftmp = pe.m_F; // store safe copy
Jtmp = pe.m_J;
pe.m_F = Fv; pe.m_J = Fv.det();
mat3ds Uv = pe.RightStretch();
mat3ds Nv = YieldSurfaceNormal(pt);
double Nvmag = Nv.norm();
mat3dd I(1);
double beta = 1;
mat3ds ImN = I;
double phi0=0, phi1=0, phi2=0, lam0 = 0, lam1=0, lam2=0, a, b, c=0, d;
bool mroot = false;
double lroot = 0;
while (!done) {
pe.m_F = Fv; pe.m_J = Fv.det();
pp.m_Kv[i] = m_pCrit->DamageCriterion(pt);
phi = pp.m_Kv[i] - fp.m_Ky[i]; // phi = 0 => stay on yield surface
int it = iter % 3;
if (it == 0) {
phi0 = phi;
lam0 = lam;
}
else if (it == 1) {
phi1 = phi;
lam1 = lam;
}
else if (it == 2) {
phi2 = phi;
lam2 = lam;
}
mat3d dUvdlam = -Ue*Nv*(beta/Nvmag);
if (m_isochrc)
dUvdlam += Ue*ImN*((ImN.inverse()*Nv/Nvmag).trace()*beta/3.);
double dlam = -phi/(Nv*dUvdlam.transpose()).trace();
lam += dlam;
if (it == 2) {
d = (lam0-lam1)*(lam0-lam2)*(lam1-lam2);
if (d == 0) {
if (lam0 == lam1) lam = lam1;
else if (lam1 == lam2) lam = lam2;
else lam = lam2;
}
else {
a = (lam2*(phi1-phi0)+lam1*(phi0-phi2)+lam0*(phi2-phi1))/d;
b = (pow(lam2,2)*(phi0-phi1)+pow(lam0,2)*(phi1-phi2)+pow(lam1,2)*(phi2-phi0))/d;
c = (lam0*lam2*(lam2-lam0)*phi1+pow(lam1,2)*(lam2*phi0-lam0*phi2)+lam1*(phi2*pow(lam0,2)-phi0*pow(lam2,2)))/d;
d = b*b - 4*a*c;
if (d >= 0) {
if (a != 0) {
lam1 = (-b+sqrt(d))/(2*a);
lam2 = (-b-sqrt(d))/(2*a);
if (lam1*lam2 < 0) lam = max(lam1,lam2);
else {
mroot = true;
lam = (fabs(lam1) < fabs(lam2)) ? lam1 : lam2;
lroot = (fabs(lam1) >= fabs(lam2)) ? lam1 : lam2;
}
}
else if (b != 0) lam = -c/b;
else lam = 0;
}
else if (a != 0) {
// first try a least squares linear fit
double sx = lam0 + lam1 + lam2;
double sy = phi0 + phi1 + phi2;
double sx2 = pow(lam0,2) + pow(lam1,2) + pow(lam2,2);
double sxy = lam0*phi0 + lam1*phi1 + lam2*phi2;
double slope = (3*sxy - sx*sy)/(3*sx2 - pow(sx,2));
double intercept = (sy - slope*sx)/3;
lam = -intercept/slope;
// if that produces a negative root, use the minimum of the parabola
if (lam < 0) lam = -b/(2*a);
}
else
lam = (fabs(b) > 0) ? -c/b : 0;
}
phi = a*pow(lam,2) + b*lam + c;
if (fabs(phi) < m_rtol) { conv = true; done = true; }
}
ImN = I - Nv*(lam/Nvmag);
if (m_isochrc) beta = pow((pp.m_Fusi[i]*ImN).det(), -1./3.);
Uv = (Ue*ImN).sym()*beta;
Fv = R*Uv;
if (fabs(phi) <= m_rtol) { conv = true; done = true;}
if (++iter > maxit) done = true;
if (done && !conv && mroot) {
done = mroot = false;
lam = lroot;
ImN = I - Nv*(lam/Nvmag);
if (m_isochrc) beta = pow((pp.m_Fusi[i]*ImN).det(), -1./3.);
Uv = (Ue*ImN).sym()*beta;
Fv = R*Uv;
}
}
if (!conv)
feLogWarning("Plasticity iterations did not converge for bond family %d!\n",i);
pe.m_F = Fv; pe.m_J = Fv.det();
pp.m_Kv[i] = m_pCrit->DamageCriterion(pt);
pp.m_Kv[i] = phi + fp.m_Ky[i];
pe.m_F = Ftmp; pe.m_J = Jtmp;
pp.m_Fvsi[i] = Fs.inverse()*Fv;
}
// if bond family has not yielded at this instant, and had not yielded at previous times,
// reset the mass fraction of yielded bonds to zero (in case m_w[i] was
// set to w[i] during a prior iteration at current time)
for (int i=0; i<n; ++i) {
if ((pp.m_w[i] > 0) && !pp.m_byld[i]) {
if (pp.m_Kv[i] < fp.m_Ky[i]/(1+m_rtol))
pp.m_w[i] = 0;
}
}
// evaluate octahedral plastic strain
OctahedralPlasticStrain(pt);
ReactiveHeatSupplyDensity(pt);
return;
}
//-----------------------------------------------------------------------------
//! calculate stress at material point
mat3ds FEReactivePlasticity::Stress(FEMaterialPoint& pt)
{
ElasticDeformationGradient(pt);
int n = (int)m_pFlow->BondFamilies(pt);
// extract elastic material point
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract plastic material point
FEReactivePlasticityMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticityMaterialPoint>();
mat3ds s = m_pBase->Stress(pt)*(1 - pp.YieldedBonds());
for (int i=0; i<n; ++i) {
if (pp.m_w[i] > 0) {
// get the elastic deformation gradient
mat3d Fv = pe.m_F*pp.m_Fvsi[i];
// store safe copy of total deformation gradient
mat3d Fs = pe.m_F; double Js = pe.m_J;
pe.m_F = Fv; pe.m_J = Fv.det();
// evaluate the stress using the elastic deformation gradient
s += m_pBase->Stress(pt)*pp.m_w[i];
// restore the original deformation gradient
pe.m_F = Fs; pe.m_J = Js;
}
}
// return the stress
return s;
}
//-----------------------------------------------------------------------------
//! calculate tangent stiffness at material point
tens4ds FEReactivePlasticity::Tangent(FEMaterialPoint& pt)
{
ElasticDeformationGradient(pt);
int n = (int)m_pFlow->BondFamilies(pt);
// extract elastic material point
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract plastic material point
FEReactivePlasticityMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticityMaterialPoint>();
tens4ds c = m_pBase->Tangent(pt)*(1 - pp.YieldedBonds());
for (int i=0; i<n; ++i) {
if (pp.m_w[i] > 0) {
// get the elastic deformation gradient
mat3d Fv = pe.m_F*pp.m_Fvsi[i];
// store safe copy of total deformation gradient
mat3d Fs = pe.m_F; double Js = pe.m_J;
pe.m_F = Fv; pe.m_J = Fv.det();
// evaluate the tangent using the elastic deformation gradient
c += m_pBase->Tangent(pt)*pp.m_w[i];
// restore the original deformation gradient
pe.m_F = Fs; pe.m_J = Js;
}
}
// return the tangent
return c;
}
//-----------------------------------------------------------------------------
//! calculate strain energy density at material point
double FEReactivePlasticity::StrainEnergyDensity(FEMaterialPoint& pt)
{
ElasticDeformationGradient(pt);
int n = (int)m_pFlow->BondFamilies(pt);
// extract elastic material point
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract plastic material point
FEReactivePlasticityMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticityMaterialPoint>();
double sed = m_pBase->StrainEnergyDensity(pt)*(1 - pp.YieldedBonds());
for (int i=0; i<n; ++i) {
if (pp.m_w[i] > 0) {
// get the elastic deformation gradient
mat3d Fv = pe.m_F*pp.m_Fvsi[i];
double Jvsi = m_isochrc ? 1 : pp.m_Fvsi[i].det();
// store safe copy of total deformation gradient
mat3d Fs = pe.m_F; double Js = pe.m_J;
pe.m_F = Fv; pe.m_J = Fv.det();
// evaluate the tangent using the elastic deformation gradient
sed += m_pBase->StrainEnergyDensity(pt)*pp.m_w[i]/Jvsi;
// restore the original deformation gradient
pe.m_F = Fs; pe.m_J = Js;
}
}
// return the sed
return sed;
}
//-----------------------------------------------------------------------------
// get the yield surface normal
mat3ds FEReactivePlasticity::YieldSurfaceNormal(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pe = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds s = m_pBase->Stress(mp);
tens4ds c = m_pBase->Tangent(mp);
mat3ds dPhi = m_pCrit->CriterionStressTangent(mp);
mat3d M = dPhi*s*2 - mat3dd((dPhi*s).trace()) + c.dot(dPhi);
mat3ds Ui = pe.RightStretchInverse();
mat3d R = pe.m_F*Ui;
mat3ds N = (R.transpose()*M*R*Ui).sym();
return N;
}
//-----------------------------------------------------------------------------
//! calculate stress at material point
void FEReactivePlasticity::OctahedralPlasticStrain(FEMaterialPoint& pt)
{
int n = (int)m_pFlow->BondFamilies(pt);
// extract plastic material point
FEReactivePlasticityMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticityMaterialPoint>();
double ev[3];
for (int i=0; i<n; ++i) {
mat3ds Cvsi = (pp.m_Fvsi[i].transpose()*pp.m_Fvsi[i]).sym();
Cvsi.eigen2(ev);
for (int j=0; j<3; ++j) ev[j] = 1./sqrt(ev[j]);
pp.m_gp[i] = sqrt(2.)/3.*sqrt(pow(ev[0] - ev[1],2) + pow(ev[1] - ev[2],2) + pow(ev[2] - ev[0],2));
}
}
//-----------------------------------------------------------------------------
//! evaluate reactive heat supply at material point
void FEReactivePlasticity::ReactiveHeatSupplyDensity(FEMaterialPoint& pt)
{
double Rhat = 0;
double dt = CurrentTimeIncrement();
// extract elastic material point
FEElasticMaterialPoint& pe = *pt.ExtractData<FEElasticMaterialPoint>();
// extract plastic material point
FEReactivePlasticityMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticityMaterialPoint>();
if (dt == 0) {
pp.m_Rhat = 0;
return;
}
// store safe copy of total deformation gradient
mat3d Fs = pe.m_F; double Js = pe.m_J;
int n = (int)m_pFlow->BondFamilies(pt);
for (int i=0; i<n; ++i) {
if (pp.m_w[i] > 0) {
// get the elastic deformation gradients
mat3d Fu = Fs*pp.m_Fusi[i];
// evaluate strain energy density in the absence of yielding
pe.m_F = Fu; pe.m_J = Fu.det();
// evaluate the tangent using the elastic deformation gradient
Rhat += m_pBase->StrainEnergyDensity(pt)*pp.m_w[i];
mat3d Fv = Fs*pp.m_Fvsi[i];
// evaluate strain energy density in the absence of yielding
pe.m_F = Fv; pe.m_J = Fv.det();
// evaluate the tangent using the elastic deformation gradient
Rhat -= m_pBase->StrainEnergyDensity(pt)*pp.m_w[i];
}
}
// get rate
Rhat /= dt;
// restore the original deformation gradient
pe.m_F = Fs; pe.m_J = Js;
// return the reactive heat supply
pp.m_Rhat = Rhat;
}
//-----------------------------------------------------------------------------
// update plasticity material point at each iteration
void FEReactivePlasticity::UpdateSpecializedMaterialPoints(FEMaterialPoint& pt, const FETimeInfo& tp)
{
// initialize flow curve (if not done yet)
if (m_pFlow->InitFlowCurve(pt)) {
FEReactivePlasticityMaterialPoint& pp = *pt.ExtractData<FEReactivePlasticityMaterialPoint>();
pp.Init();
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FE2DTransIsoVerondaWestmann.cpp | .cpp | 8,715 | 332 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include <limits>
#include "FE2DTransIsoVerondaWestmann.h"
// define the material parameters
BEGIN_FECORE_CLASS(FE2DTransIsoVerondaWestmann, FEUncoupledMaterial)
ADD_PARAMETER(m_c1, FE_RANGE_GREATER(0.0), "c1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c2, FE_RANGE_GREATER(0.0), "c2")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_w, 2, "w");
ADD_PARAMETER(m_c3, "c3")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c4, "c4");
ADD_PARAMETER(m_c5, "c5")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_lam1, "lam_max");
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
double FE2DTransIsoVerondaWestmann::m_cth[FE2DTransIsoVerondaWestmann::NSTEPS];
double FE2DTransIsoVerondaWestmann::m_sth[FE2DTransIsoVerondaWestmann::NSTEPS];
//////////////////////////////////////////////////////////////////////
// FE2DTransIsoVerondaWestmann
//////////////////////////////////////////////////////////////////////
FE2DTransIsoVerondaWestmann::FE2DTransIsoVerondaWestmann(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
static bool bfirst = true;
if (bfirst)
{
double ph;
for (int n=0; n<NSTEPS; ++n)
{
ph = 2.0*PI*n / (double) NSTEPS;
m_cth[n] = cos(ph);
m_sth[n] = sin(ph);
}
bfirst = false;
}
m_w[0] = m_w[1] = 1;
m_epsf = 0.0;
}
//-----------------------------------------------------------------------------
//! Calculates the deviatoric stress for this material.
//! \param pt material point at which to evaluate the stress
mat3ds FE2DTransIsoVerondaWestmann::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
double Ji = 1.0 / J;
double Jm13 = pow(J, -1.0/3.0);
double Jm23 = Jm13*Jm13;
double twoJi = 2.0*Ji;
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
double I1, I2;
I1 = B.tr();
I2 = 0.5*(I1*I1 - B2.tr() );
// --- M A T R I X C O N T R I B U T I O N ---
// strain energy derivatives
double W1, W2;
W1 = m_c1*m_c2*exp(m_c2*(I1-3));
W2 = -0.5*m_c1*m_c2;
// T = F*dW/dC*Ft
mat3ds T = B*(W1 + W2*I1) - B2*W2;
// --- F I B E R C O N T R I B U T I O N ---
mat3ds Tf; Tf.zero();
// Next, we calculate the fiber contribution. For this material
// the fibers lie randomly in a plane that is perpendicular to the transverse
// axis. We therefor need to integrate over this plane.
double w, wtot = 0;
vec3d a0, a, v;
mat3ds A;
double lam, lamd, I4, W4;
for (int n=0; n<NSTEPS; ++n)
{
// calculate the local material fiber vector
v.y = m_cth[n];
v.z = m_sth[n];
v.x = 0;
// calculate the global material fiber vector
a0 = Q*v;
// calculate the global spatial fiber vector
a = F*a0;
// normalize material axis and store fiber stretch
lam = a.unit();
lamd = lam*Jm13; // i.e. lambda tilde
// fourth invariant of C
I4 = lamd*lamd;
if (lamd > 1)
{
double lamdi = 1.0/lamd;
double Wl;
if (lamd < m_lam1)
{
Wl = lamdi*m_c3*(exp(m_c4*(lamd - 1)) - 1);
}
else
{
double c6 = m_c3*(exp(m_c4*(m_lam1-1))-1) - m_c5*m_lam1;
Wl = lamdi*(m_c5*lamd + c6);
}
W4 = 0.5*lamdi*Wl;
}
else
{
W4 = 0;
}
// calculate the weight
w = 1.0/sqrt((v.y/m_w[0])*(v.y/m_w[0]) + (v.z/m_w[1])*(v.z/m_w[1]));
wtot += w;
// Add fiber contribution to T
A = dyad(a);
Tf += A*(W4*I4*w);
}
// normalize fiber stress and add to total
T += Tf/wtot;
return T.dev()*twoJi;
}
//-----------------------------------------------------------------------------
//! Calculates the deviatoric elasticity tensor for this material.
//! \param D elasticity tensor
//! \param pt material point at which to evaulate the elasticity tensor
tens4ds FE2DTransIsoVerondaWestmann::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double eps = m_epsf * std::numeric_limits<double>::epsilon();
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
double Jm13 = pow(J, -1.0/3.0);
double Jm23 = Jm13*Jm13;
double Ji = 1.0/J;
// deviatoric right Cauchy-Green tensor: C = Ft*F
mat3ds C = pt.DevRightCauchyGreen();
// square of C
mat3ds C2 = C.sqr();
// Invariants of C
double I1 = C.tr();
double I2 = 0.5*(I1*I1 - C2.tr());
// calculate left Cauchy-Green tensor: B = F*Ft
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// --- M A T R I X C O N T R I B U T I O N ---
// strain energy derivatives
double W1, W2, W11;
W1 = m_c1*m_c2*exp(m_c2*(I1-3));
W2 = -0.5*m_c1*m_c2;
W11 = m_c2*W1;
// deviatoric cauchy-stress, trs = trace[s]/3
mat3ds T = B * (W1 + W2 * I1) - B2 * W2;
mat3ds devs = T.dev() * (2.0 / J);
// calculate dWdC:C
double WC = W1*I1 + 2*W2*I2;
// calculate C:d2WdCdC:C
double CWWC = W11*I1*I1+2*I2*W2;
mat3dd I(1); // Identity
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxB = dyad1s(B);
tens4ds B4 = dyad4s(B);
// d2W/dCdC:C
mat3ds WCCxC = B*(W11*I1 + W2*I1) - B2*W2;
tens4ds cw = BxB*((W11+W2)*4.0*Ji) - B4*(W2*4.0*Ji) - dyad1s(WCCxC, I)*(4.0/3.0*Ji) + IxI*(4.0/9.0*Ji*CWWC);
tens4ds c = dyad1s(devs, I)*(-2.0/3.0) + (I4 - IxI/3.0)*(4.0/3.0*Ji*WC) + cw;
double D[6][6];
c.extract(D);
// --- F I B E R C O N T R I B U T I O N ---
// Next, we add the fiber contribution. Since the fibers lie
// randomly perpendicular to the transverse axis, we need
// to integrate over that plane
double lam, lamd;
double In, Wl, Wll;
vec3d a0, a, v;
double w, wtot = 0;
mat3ds N2;
tens4ds N4, cf, cfw;
cf.zero();
tens4ds I4mIxId3 = I4 - IxI/3.0;
for (int n=0; n<NSTEPS; ++n)
{
// calculate the local material fiber vector
v.y = m_cth[n];
v.z = m_sth[n];
v.x = 0;
// calculate the global material fiber vector
a0 = Q*v;
// calculate the global spatial fiber vector
a.x = F[0][0]*a0.x + F[0][1]*a0.y + F[0][2]*a0.z;
a.y = F[1][0]*a0.x + F[1][1]*a0.y + F[1][2]*a0.z;
a.z = F[2][0]*a0.x + F[2][1]*a0.y + F[2][2]*a0.z;
// normalize material axis and store fiber stretch
lam = a.unit();
lamd = lam*Jm13; // i.e. lambda tilde
// fourth invariant of C
In = lamd*lamd;
// Wi = dW/dIi
if (lamd >= 1 + eps)
{
double lamdi = 1.0/lamd;
double W4, W44;
if (lamd < m_lam1)
{
W4 = lamdi*m_c3*(exp(m_c4*(lamd - 1)) - 1);
W44 = m_c3*lamdi*(m_c4*exp(m_c4*(lamd - 1)) - lamdi*(exp(m_c4*(lamd-1))-1));
}
else
{
double c6 = m_c3*(exp(m_c4*(m_lam1-1))-1) - m_c5*m_lam1;
W4 = lamdi*(m_c5*lamd + c6);
W44 = -c6*lamdi*lamdi;
}
Wl = 0.5*lamdi*W4;
Wll = 0.25*lamdi*lamdi*(W44 - lamdi*W4);
}
else
{
Wl = 0;
Wll = 0;
}
// calculate dWdC:C
double WC = Wl*In;
// calculate C:d2WdCdC:C
double CWWC = Wll*In*In;
w = 1.0/sqrt((v.y/m_w[0])*(v.y/m_w[0]) + (v.z/m_w[1])*(v.z/m_w[1]));
wtot += w;
N2 = dyad(a);
N4 = dyad1s(N2);
WCCxC = N2*(Wll*In*In);
cfw = N4*(4.0*Wll*In*In) - dyad1s(WCCxC, I)*(4.0/3.0) + IxI*(4.0/9.0*CWWC);
cf += (I4mIxId3)*(4.0/3.0*Ji*WC*w) + cfw*(Ji*w);
}
// normalize fiber tangent and add to total tangent
c += cf/wtot;
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEContinuousFiberDistributionUC.h | .h | 2,570 | 69 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
#include "FEElasticFiberMaterialUC.h"
#include "FEFiberDensityDistribution.h"
#include "FEFiberIntegrationScheme.h"
#include "FEFiberMaterialPoint.h"
#include "FEFiberMaterial.h"
// This material is a container for a fiber material, a fiber density
// distribution, and an integration scheme.
//
class FEContinuousFiberDistributionUC : public FEUncoupledMaterial
{
public:
FEContinuousFiberDistributionUC(FEModel* pfem);
~FEContinuousFiberDistributionUC();
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
public:
//! calculate stress at material point
mat3ds DevStress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! calculate deviatoric strain energy density
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
private:
double IntegratedFiberDensity(FEMaterialPoint& pt);
protected:
FEFiberMaterialUncoupled* m_pFmat; // pointer to fiber material
FEFiberDensityDistribution* m_pFDD; // pointer to fiber density distribution
FEFiberIntegrationScheme* m_pFint; // pointer to fiber integration scheme
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEElasticMaterial.h | .h | 2,601 | 74 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FESolidMaterial.h"
#include "FEElasticMaterialPoint.h"
//-----------------------------------------------------------------------------
//! Base class for (hyper-)elastic materials
class FEBIOMECH_API FEElasticMaterial : public FESolidMaterial
{
public:
//! constructor
FEElasticMaterial(FEModel* pfem);
//! destructor
~FEElasticMaterial();
//! create material point data for this material
FEMaterialPointData* CreateMaterialPointData() override;
//! calculate strain energy density at material point
virtual double StrainEnergyDensity(FEMaterialPoint& pt);
// get the elastic material
virtual FEElasticMaterial* GetElasticMaterial() { return this; }
public:
//! evaluates approximation to Cauchy stress using forward difference
mat3ds SecantStress(FEMaterialPoint& pt, bool PK2 = false) override;
public:
virtual double StrongBondSED(FEMaterialPoint& pt) { return StrainEnergyDensity(pt); }
virtual double WeakBondSED(FEMaterialPoint& pt) { return 0; }
protected:
// DECLARE_FECORE_CLASS();
FECORE_BASE_CLASS(FEElasticMaterial);
};
//-----------------------------------------------------------------------------
class FEBIOMECH_API FEElasticStress : public FEDomainParameter
{
public:
FEElasticStress();
FEParamValue value(FEMaterialPoint& mp) override;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FECentrifugalBodyForce.cpp | .cpp | 2,048 | 61 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FECentrifugalBodyForce.h"
#include "FEElasticMaterial.h"
BEGIN_FECORE_CLASS(FECentrifugalBodyForce, FEBodyForce);
ADD_PARAMETER(w, "angular_speed")->setUnits(UNIT_ANGULAR_VELOCITY);
ADD_PARAMETER(n, "rotation_axis");
ADD_PARAMETER(c, "rotation_center")->setUnits(UNIT_LENGTH);
END_FECORE_CLASS();
FECentrifugalBodyForce::FECentrifugalBodyForce(FEModel* pfem) : FEBodyForce(pfem)
{
w = 0.0;
n = vec3d(0,0,1);
c = vec3d(0,0,0);
}
vec3d FECentrifugalBodyForce::force(FEMaterialPoint& mp)
{
mat3d K = stiffness(mp);
return K*(mp.m_rt - c);
}
mat3d FECentrifugalBodyForce::stiffness(FEMaterialPoint& mp)
{
return (mat3dd(1) - dyad(n))*(-w*w);
}
double FECentrifugalBodyForce::divforce(FEMaterialPoint& mp)
{
return -2*w*w;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEYeoh.cpp | .cpp | 4,482 | 144 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEYeoh.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEYeoh, FEUncoupledMaterial)
ADD_PARAMETER(m_c[0], "c1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c[1], "c2")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c[2], "c3")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c[3], "c4")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c[4], "c5")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c[5], "c6")->setUnits(UNIT_PRESSURE);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Calculate the deviatoric stress
mat3ds FEYeoh::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double c[MAX_TERMS];
// get material parameters
for (int i=0; i<MAX_TERMS; ++i) c[i] = m_c[i](mp);
// determinant of deformation gradient
double J = pt.m_J;
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// Invariant of B tilde (= invariants of C tilde)
double I1 = B.tr();
double sum = 0;
for (int i=0; i<MAX_TERMS; ++i)
sum += c[i]*pow(I1-3,i);
// calculate sigma tilde
mat3ds sig = B*(sum*2.0/J);
return sig.dev();
}
//-----------------------------------------------------------------------------
//! Calculate the deviatoric tangent
tens4ds FEYeoh::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double c[MAX_TERMS];
// get material parameters
for (int i=0; i<MAX_TERMS; ++i) c[i] = m_c[i](mp);
// determinant of deformation gradient
double J = pt.m_J;
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// Invariant of B tilde (= invariants of C tilde)
double I1 = B.tr();
double sum = 0;
for (int i=0; i<MAX_TERMS; ++i)
sum += c[i]*pow(I1-3,i);
double csum = 0;
for (int i=1; i<MAX_TERMS; ++i)
csum += c[i]*pow(I1-3,i-1);
// calculate sigma tilde
mat3ds sd = (B*(sum*2.0/J));
// identity tensor
mat3dd I(1);
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxB = dyad1s(B);
tens4ds C = BxB*(csum*4.0/J);
C += - 1./3.*(ddots(C,IxI) - IxI*(C.tr()/3.))
+ 2./3.*((I4-IxI/3.)*sd.tr()-dyad1s(sd.dev(),I));
return C;
}
//-----------------------------------------------------------------------------
//! calculate deviatoric strain energy density
double FEYeoh::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double c[MAX_TERMS];
// get material parameters
for (int i=0; i<MAX_TERMS; ++i) c[i] = m_c[i](mp);
// determinant of deformation gradient
double J = pt.m_J;
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// Invariant of B tilde (= invariants of C tilde)
double I1 = B.tr();
double sed = 0;
for (int i=0; i<MAX_TERMS; ++i)
sed += c[i]*pow(I1-3,i+1);
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidJoint.cpp | .cpp | 10,397 | 424 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FERigidJoint.h"
#include "FERigidBody.h"
#include "FECore/log.h"
#include "FECore/FEMaterial.h"
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidJoint, FERigidConnector);
ADD_PARAMETER(m_laugon , "laugon")->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0LAGMULT\0");
ADD_PARAMETER(m_atol , "tolerance");
ADD_PARAMETER(m_eps , "penalty" );
ADD_PARAMETER(m_q0 , "joint" );
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidJoint::FERigidJoint(FEModel* pfem) : FERigidConnector(pfem)
{
static int count = 1;
m_nID = count++;
m_laugon = FECore::AUGLAG_METHOD; // Augmented Lagrangian by default for backward compatibility
m_eps = 0.0;
m_atol = 0.01;
m_rbA = m_rbB = nullptr;
}
//-----------------------------------------------------------------------------
//! destructor
FERigidJoint::~FERigidJoint()
{
}
//-----------------------------------------------------------------------------
bool FERigidJoint::Init()
{
// reset force
m_F = m_Fp = vec3d(0,0,0);
// base class first
if (FERigidConnector::Init() == false) return false;
// initialize relative joint positions
m_qa0 = m_q0 - m_rbA->m_r0;
m_qb0 = m_q0 - m_rbB->m_r0;
// we make sure we have a non-zero penalty for penalty and auglag method
if ((m_laugon != FECore::LAGMULT_METHOD) && (m_eps == 0.0)) return false;
return true;
}
//-----------------------------------------------------------------------------
// allocate equations
int FERigidJoint::InitEquations(int neq)
{
m_LM.resize(3, -1);
if (m_laugon == FECore::LAGMULT_METHOD)
{
// we allocate three equations
m_LM[0] = neq;
m_LM[1] = neq + 1;
m_LM[2] = neq + 2;
return 3;
}
else return 0;
}
//-----------------------------------------------------------------------------
// Build the matrix profile
void FERigidJoint::BuildMatrixProfile(FEGlobalMatrix& M)
{
vector<int> lm;
UnpackLM(lm);
// add it to the pile
M.build_add(lm);
}
//-----------------------------------------------------------------------------
void FERigidJoint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
double alpha = tp.alpha;
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// body A
vec3d rat = RBa.m_rt;
vec3d rap = RBa.m_rp;
vec3d ra = rat * alpha + rap*(1 - alpha);
vec3d zat = RBa.GetRotation() * m_qa0;
vec3d zap = RBa.m_qp * m_qa0;
vec3d za = zat * alpha + zap * (1 - alpha);
// body b
vec3d rbt = RBb.m_rt;
vec3d rbp = RBb.m_rp;
vec3d rb = rbt*alpha + rbp*(1 - alpha);
vec3d zbt = RBb.GetRotation() * m_qb0;
vec3d zbp = RBb.m_qp * m_qb0;
vec3d zb = zbt * alpha + zbp * (1 - alpha);
// constraint
vec3d c = rb + zb - ra - za;
// forces
vec3d F = m_L + c * m_eps;
if (m_laugon == FECore::LAGMULT_METHOD) F = -m_F;
vec3d Fa = F;
vec3d Fb = -F;
vec3d Ma = (za ^ F);
vec3d Mb = -(zb ^ F);
vector<double> fe(15, 0.0);
fe[ 0] = Fa.x;
fe[ 1] = Fa.y;
fe[ 2] = Fa.z;
fe[ 3] = Ma.x;
fe[ 4] = Ma.y;
fe[ 5] = Ma.z;
fe[ 6] = Fb.x;
fe[ 7] = Fb.y;
fe[ 8] = Fb.z;
fe[ 9] = Mb.x;
fe[10] = Mb.y;
fe[11] = Mb.z;
fe[12] = c.x;
fe[13] = c.y;
fe[14] = c.z;
vector<int> lm;
UnpackLM(lm);
R.Assemble(lm, fe);
RBa.m_Fr -= vec3d(fe[0], fe[1], fe[2]);
RBa.m_Mr -= vec3d(fe[3], fe[4], fe[5]);
RBb.m_Fr -= vec3d(fe[6], fe[7], fe[8]);
RBb.m_Mr -= vec3d(fe[9], fe[10], fe[11]);
}
//-----------------------------------------------------------------------------
void FERigidJoint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
double alpha = tp.alpha;
// body A
vec3d rat = RBa.m_rt;
vec3d rap = RBa.m_rp;
vec3d ra = rat * alpha + rap * (1 - alpha);
vec3d zat = RBa.GetRotation() * m_qa0;
vec3d zap = RBa.m_qp * m_qa0;
vec3d za = zat * alpha + zap * (1 - alpha);
// body b
vec3d rbt = RBb.m_rt;
vec3d rbp = RBb.m_rp;
vec3d rb = rbt * alpha + rbp * (1 - alpha);
vec3d zbt = RBb.GetRotation() * m_qb0;
vec3d zbp = RBb.m_qp * m_qb0;
vec3d zb = zbt * alpha + zbp * (1 - alpha);
FEElementMatrix ke;
if (m_laugon != FECore::LAGMULT_METHOD)
{
ke.resize(12, 12);
ke.zero();
// constraint
vec3d c = rb + zb - ra - za;
// forces
vec3d F = m_L + c * m_eps;
mat3da Fhat(F);
mat3da zahat(za);
mat3da zathat(zat);
mat3da zbhat(zb);
mat3da zbthat(zbt);
mat3dd I(1.0);
ke.set(0, 0, I); ke.set(0, 3, -zathat); ke.set(0, 6, -I); ke.set(0, 9, zbthat);
ke.set(3, 0, zahat); ke.set(3, 3, -zahat*zathat); ke.set(3, 6, -zahat); ke.set(3, 9, zahat*zbthat);
ke.set(6, 0, -I); ke.set(6, 3, zathat); ke.set(6, 6, I); ke.set(6, 9, -zbthat);
ke.set(9, 0, -zbhat); ke.set(9, 3, zbhat*zathat); ke.set(9, 6, zbhat); ke.set(9, 9, -zbhat*zbthat);
// scale by penalty factor
ke *= m_eps;
ke.add(3, 3, -Fhat*zathat);
ke.add(9, 9, Fhat*zbthat);
ke *= alpha;
}
else
{
ke.resize(15, 15);
ke.zero();
mat3dd I(1.0);
mat3da yaT(za);
mat3da ybT(zb);
mat3da Fhat(m_F);
ke.add_symm(0, 12, I);
ke.add_symm(3, 12, yaT);
ke.add_symm(6, 12, -I);
ke.add_symm(9, 12, -ybT);
ke.add(3, 3, Fhat*yaT);
ke.add(9, 9, -Fhat*ybT);
}
// unpack LM
vector<int> lm;
UnpackLM(lm);
ke.SetIndices(lm);
// assemle into global stiffness matrix
LS.Assemble(ke);
}
//-----------------------------------------------------------------------------
bool FERigidJoint::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (m_laugon == FECore::PENALTY_METHOD) return true;
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
quatd Qa = RBa.GetRotation();
quatd Qb = RBb.GetRotation();
vec3d ra = RBa.m_rt;
vec3d rb = RBb.m_rt;
vec3d qa = Qa*m_qa0;
vec3d qb = Qb*m_qb0;
vec3d c = rb + qb - ra - qa;
// For Lagrange multipliers we just report the values
// of the LM and the constraint
if (m_laugon == FECore::LAGMULT_METHOD)
{
feLog("\n=== rigid joint # %d:\n", m_nID);
feLog("\tLagrange m. : %15.7lg, %15.7lg, %15.7lg\n", m_F.x, m_F.y, m_F.z);
feLog("\tconstraint : %15.7lg, %15.7lg, %15.7lg\n", c.x, c.y, c.z);
return true;
}
// augmented Lagrangian
bool bconv = true;
double normF0 = sqrt(m_L*m_L);
// calculate trial multiplier
vec3d Lm = m_L + c*m_eps;
double normF1 = sqrt(Lm*Lm);
// check convergence of constraints
feLog(" rigid joint # %d\n", m_nID);
feLog(" CURRENT REQUIRED\n");
double pctn = 0;
if (fabs(normF1) > 1e-10) pctn = fabs((normF1 - normF0)/normF1);
feLog(" force : %15le %15le\n", pctn, m_atol);
feLog(" gap : %15le ***\n", c.norm());
if (pctn >= m_atol)
{
bconv = false;
// update multiplier
m_L = m_L + c*m_eps;
// update force
m_F = m_L + c*m_eps;
}
return bconv;
}
//-----------------------------------------------------------------------------
void FERigidJoint::Serialize(DumpStream& ar)
{
FERigidConnector::Serialize(ar);
ar & m_nID;
ar & m_q0 & m_qa0 & m_qb0;
ar & m_F & m_Fp & m_L & m_eps & m_atol & m_laugon;
}
//-----------------------------------------------------------------------------
void FERigidJoint::Update()
{
if (m_laugon != FECore::LAGMULT_METHOD)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
vec3d ra = RBa.m_rt;
vec3d rb = RBb.m_rt;
vec3d qa = m_qa0;
RBa.GetRotation().RotateVector(qa);
vec3d qb = m_qb0;
RBb.GetRotation().RotateVector(qb);
vec3d c = ra + qa - rb - qb;
m_F = m_L + c*m_eps;
}
}
//-----------------------------------------------------------------------------
void FERigidJoint::Reset()
{
m_F = vec3d(0,0,0);
m_Fp = vec3d(0,0,0);
m_L = vec3d(0,0,0);
m_qa0 = m_q0 - m_rbA->m_r0;
m_qb0 = m_q0 - m_rbB->m_r0;
}
//-----------------------------------------------------------------------------
void FERigidJoint::UnpackLM(vector<int>& lm)
{
// add the dofs of rigid body A
lm.reserve(15);
lm.push_back(m_rbA->m_LM[0]);
lm.push_back(m_rbA->m_LM[1]);
lm.push_back(m_rbA->m_LM[2]);
lm.push_back(m_rbA->m_LM[3]);
lm.push_back(m_rbA->m_LM[4]);
lm.push_back(m_rbA->m_LM[5]);
// add the dofs of rigid body B
lm.push_back(m_rbB->m_LM[0]);
lm.push_back(m_rbB->m_LM[1]);
lm.push_back(m_rbB->m_LM[2]);
lm.push_back(m_rbB->m_LM[3]);
lm.push_back(m_rbB->m_LM[4]);
lm.push_back(m_rbB->m_LM[5]);
// add the LM equations
if (m_laugon == FECore::LAGMULT_METHOD)
{
lm.push_back(m_LM[0]);
lm.push_back(m_LM[1]);
lm.push_back(m_LM[2]);
}
}
void FERigidJoint::PrepStep()
{
m_Fp = m_F;
}
void FERigidJoint::Update(const std::vector<double>& Ui, const std::vector<double>& ui)
{
if (m_laugon == FECore::LAGMULT_METHOD)
{
m_F.x = m_Fp.x + Ui[m_LM[0]] + ui[m_LM[0]];
m_F.y = m_Fp.y + Ui[m_LM[1]] + ui[m_LM[1]];
m_F.z = m_Fp.z + Ui[m_LM[2]] + ui[m_LM[2]];
}
}
void FERigidJoint::UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui)
{
if (m_laugon == FECore::LAGMULT_METHOD)
{
Ui[m_LM[0]] += ui[m_LM[0]];
Ui[m_LM[1]] += ui[m_LM[1]];
Ui[m_LM[2]] += ui[m_LM[2]];
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEBondRelaxation.h | .h | 13,705 | 434 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FEMaterial.h>
#include <FECore/FEFunction1D.h>
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
//! Base class for bond relaxation of reactive viscoelastic materials.
//! These materials need to define a relaxation function.
//!
class FEBIOMECH_API FEBondRelaxation : public FEMaterialProperty
{
public:
FEBondRelaxation(FEModel* pfem) : FEMaterialProperty(pfem) {}
virtual ~FEBondRelaxation() {}
//! relaxation
virtual double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) = 0;
FECORE_BASE_CLASS(FEBondRelaxation)
};
//-----------------------------------------------------------------------------
// This class implements exponential relaxation with constant relaxation time
class FEBondRelaxationExponential : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationExponential(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_tau; //!< relaxation time
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements exponential relaxation with a relaxation
// time that is a function of the distortional strain
class FEBondRelaxationExpDistortion : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationExpDistortion(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_tau0; //!< relaxation time
FEParamDouble m_tau1; //!< relaxation time coeff. of 2nd term
FEParamDouble m_alpha; //!< exponent of 2nd term for tau
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements exponential relaxation with a relaxation
// time that is a function of the distortional strain
class FEBondRelaxationExpDistUser : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationExpDistUser(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
//! performs initialization
bool Init() override;
public:
FEFunction1D* m_tau; //!< relaxation time
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements Fung's relaxation
class FEBondRelaxationFung : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationFung(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
//! data initialization and checking
bool Validate() override;
public:
FEParamDouble m_tau1; //!< lower relaxation time
FEParamDouble m_tau2; //!< upper relaxation time
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements Park's relaxation with constant relaxation time
class FEBondRelaxationPark : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationPark(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_tau; //!< relaxation time
FEParamDouble m_beta; //!< exponent
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements Park's relaxation with a relaxation
// time that is a function of the distortional strain
class FEBondRelaxationParkDistortion : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationParkDistortion(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_tau0; //!< relaxation time
FEParamDouble m_tau1; //!< relaxation time coeff. of 2nd term
FEParamDouble m_beta0; //!< exponent
FEParamDouble m_beta1; //!< coefficient of 2nd for beta
FEParamDouble m_alpha; //!< exponent of 2nd term for tau and beta
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements Park's relaxation with a relaxation
// time that is a function of the distortional strain
class FEBondRelaxationParkDistUser : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationParkDistUser(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
//! performs initialization
bool Init() override;
public:
FEFunction1D* m_tau; //!< relaxation time
FEFunction1D* m_beta; //!< exponent
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements a power-law relaxation with constant relaxation time
class FEBondRelaxationPower : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationPower(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_tau; //!< relaxation time
FEParamDouble m_beta; //!< exponent
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements a power-law relaxation with a relaxation
// time that is a function of the distortional strain
class FEBondRelaxationPowerDistortion : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationPowerDistortion(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_tau0; //!< relaxation time at zero strain
FEParamDouble m_beta0; //!< exponent of relaxation power law
FEParamDouble m_tau1; //!< relaxation time coeff. of 2nd term
FEParamDouble m_beta1; //!< coefficient of 2nd for beta
FEParamDouble m_alpha; //!< exponent of 2nd term
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements a power-law relaxation with a relaxation
// time that is a function of the distortional strain
class FEBondRelaxationPowerDistUser : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationPowerDistUser(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
//! performs initialization
bool Init() override;
public:
FEFunction1D* m_tau; //!< relaxation time
FEFunction1D* m_beta; //!< exponent
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements a relaxation that produces Carreau fluid response
// under stead-state conditions
class FEBondRelaxationCarreau : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationCarreau(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_tau0; //!< characteristic time constant
FEParamDouble m_lam; //!< time constant
FEParamDouble m_n; //!< power-law index
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements Prony series exponential relaxation with constant relaxation time
class FEBondRelaxationProny : public FEBondRelaxation
{
public:
enum { MAX_TERMS = 6 };
public:
//! constructor
FEBondRelaxationProny(FEModel* pfem);
//! data initialization and checking
bool Validate() override;
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
double m_g[MAX_TERMS]; //!< viscoelastic coefficients
double m_t[MAX_TERMS]; //!< relaxation times
double m_sg; //!< sum of viscoelastic coefficients
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements a Malkin relaxation with constant relaxation time
class FEBondRelaxationMalkin : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationMalkin(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_tau1; //!< lower relaxation time
FEParamDouble m_tau2; //!< upper relaxation time
FEParamDouble m_beta; //!< exponent
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements a Malkin relaxation with adjustable relaxation time
class FEBondRelaxationMalkinDist : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationMalkinDist(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_t1c0; //!< constant coefficient of lower relaxation time
FEParamDouble m_t1c1; //!< coefficient of exponential for lower relaxation time
FEParamDouble m_t1s0; //!< time constant of exponential for lower relaxation time
FEParamDouble m_t2c0; //!< constant coefficient of upper relaxation time
FEParamDouble m_t2c1; //!< coefficient of exponential for upper relaxation time
FEParamDouble m_t2s0; //!< time constant of exponential for upper relaxation time
FEParamDouble m_beta; //!< exponent
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements a Malkin relaxation with user-adjustable relaxation time
class FEBondRelaxationMalkinDistUser : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationMalkinDistUser(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
//! performs initialization
bool Init() override;
public:
FEFunction1D* m_tau1; //!< lower relaxation time
FEFunction1D* m_tau2; //!< upper relaxation time
FEFunction1D* m_beta; //!< exponent
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements a continuous spectrum exponential relaxation with constant relaxation time
class FEBondRelaxationCSexp : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationCSexp(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
public:
FEParamDouble m_tau; //!< relaxation time
// declare parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This class implements a continuous spectrum exponential relaxation with adjustable relaxation time
class FEBondRelaxationCSexpDistUser : public FEBondRelaxation
{
public:
//! constructor
FEBondRelaxationCSexpDistUser(FEModel* pfem);
//! relaxation
double Relaxation(FEMaterialPoint& pt, const double t, const mat3ds D) override;
//! performs initialization
bool Init() override;
public:
FEFunction1D* m_tau; //!< relaxation time
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFixedShellDisplacement.h | .h | 1,519 | 42 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FEFixedBC.h>
class FEFixedShellDisplacement : public FEFixedBC
{
public:
FEFixedShellDisplacement(FEModel* fem);
bool Init() override;
private:
bool m_dof_sx, m_dof_sy, m_dof_sz;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEElasticSolidDomain.h | .h | 4,753 | 150 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FESolidDomain.h>
#include "FEElasticDomain.h"
#include "FESolidMaterial.h"
#include <FECore/FEDofList.h>
//-----------------------------------------------------------------------------
//! domain described by Lagrange-type 3D volumetric elements
//!
class FEBIOMECH_API FEElasticSolidDomain : public FESolidDomain, public FEElasticDomain
{
public:
//! constructor
FEElasticSolidDomain(FEModel* pfem);
//! assignment operator
FEElasticSolidDomain& operator = (FEElasticSolidDomain& d);
//! activate
void Activate() override;
//! initialize elements
void PreSolveUpdate(const FETimeInfo& timeInfo) override;
//! Unpack solid element data
void UnpackLM(FEElement& el, vector<int>& lm) override;
//! Set flag for update for dynamic quantities
void SetDynamicUpdateFlag(bool b);
//! serialization
void Serialize(DumpStream& ar) override;
// get the total dof list
const FEDofList& GetDOFList() const override;
public: // overrides from FEDomain
//! get the material
FEMaterial* GetMaterial() override { return m_pMat; }
//! set the material
void SetMaterial(FEMaterial* pm) override;
public: // overrides from FEElasticDomain
// update stresses
void Update(const FETimeInfo& tp) override;
// update the element stress
virtual void UpdateElementStress(int iel, const FETimeInfo& tp);
//! intertial forces for dynamic problems
void InertialForces(FEGlobalVector& R, vector<double>& F) override;
//! internal stress forces
void InternalForces(FEGlobalVector& R) override;
//! body forces
void BodyForce(FEGlobalVector& R, FEBodyForce& BF) override;
//! calculates the global stiffness matrix for this domain
void StiffnessMatrix(FELinearSystem& LS) override;
//! calculates inertial stiffness
void MassMatrix(FELinearSystem& LS, double scale) override;
//! body force stiffness
void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override;
public:
// --- S T I F F N E S S ---
//! calculates the solid element stiffness matrix
virtual void ElementStiffness(const FETimeInfo& tp, int iel, matrix& ke);
//! geometrical stiffness (i.e. initial stress)
virtual void ElementGeometricalStiffness(FESolidElement& el, matrix& ke);
//! material stiffness component
virtual void ElementMaterialStiffness(FESolidElement& el, matrix& ke);
// --- R E S I D U A L ---
//! Calculates the internal stress vector for solid elements
void ElementInternalForce(FESolidElement& el, vector<double>& fe);
//! Calculates the inertial force vector for solid elements
void ElementInertialForce(FESolidElement& el, vector<double>& fe);
protected:
double m_alphaf;
double m_alpham;
double m_beta;
bool m_update_dynamic; //!< flag for updating quantities only used in dynamic analysis
bool m_secant_stress; //!< use secant approximation to stress
bool m_secant_tangent; //!< flag for using secant tangent
protected:
FEDofList m_dofU; // displacement dofs
FEDofList m_dofR; // rigid rotation rofs
FEDofList m_dofSU; // shell displacement dofs
FEDofList m_dofV; // velocity dofs
FEDofList m_dofSV; // shell velocity dofs
FEDofList m_dofSA; // shell acceleration dofs
FEDofList m_dof; // total dof list
FESolidMaterial* m_pMat;
};
class FEStandardElasticSolidDomain : public FEElasticSolidDomain
{
public:
FEStandardElasticSolidDomain(FEModel* fem);
private:
std::string m_elemType;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidMaterial.cpp | .cpp | 3,390 | 101 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FERigidMaterial.h"
#include "FERigidBody.h"
#include "FEMechModel.h"
#include <FECore/log.h>
// define the material parameters
BEGIN_FECORE_CLASS(FERigidMaterial, FESolidMaterial)
ADD_PARAMETER(m_E , FE_RANGE_GREATER_OR_EQUAL(0.0), "E" )->setLongName("Young's modulus");
ADD_PARAMETER(m_v , FE_RANGE_RIGHT_OPEN(-1.0, 0.5), "v")->setLongName("Poisson's ratio");
ADD_PARAMETER(m_com , "override_com")->SetFlags(FE_PARAM_WATCH);
ADD_PARAMETER(m_rc , "center_of_mass")->SetWatchVariable(&m_com);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
// constructor
FERigidMaterial::FERigidMaterial(FEModel* pfem) : FESolidMaterial(pfem)
{
m_E = 1;
m_v = 0;
m_rc = vec3d(0, 0, 0);
m_com = false; // calculate COM automatically
m_pmid = -1;
m_nRB = -1;
m_binit = false;
}
//-----------------------------------------------------------------------------
// Initialize rigid material data
bool FERigidMaterial::Init()
{
if (FESolidMaterial::Init() == false) return false;
if (m_binit == false)
{
// get this rigid body's ID
FEMechModel& fem = static_cast<FEMechModel&>(*GetFEModel());
FERigidBody& rb = *fem.GetRigidBody(GetRigidBodyID());
if (m_pmid > -1)
{
FERigidMaterial* ppm = dynamic_cast<FERigidMaterial*>(GetFEModel()->GetMaterial(m_pmid-1));
if (ppm == 0) {
feLogError("parent of rigid material %s is not a rigid material\n", GetName().c_str());
return false;
}
FERigidBody& prb = *fem.GetRigidBody(ppm->GetRigidBodyID());
rb.m_prb = &prb;
// mark all degrees of freedom as prescribed
rb.m_BC[0] = DOF_PRESCRIBED;
rb.m_BC[1] = DOF_PRESCRIBED;
rb.m_BC[2] = DOF_PRESCRIBED;
rb.m_BC[3] = DOF_PRESCRIBED;
rb.m_BC[4] = DOF_PRESCRIBED;
rb.m_BC[5] = DOF_PRESCRIBED;
}
m_binit = true;
}
return true;
}
//-----------------------------------------------------------------------------
//! Serialize data to or from the dump file
void FERigidMaterial::Serialize(DumpStream &ar)
{
FESolidMaterial::Serialize(ar);
ar & m_com;
ar & m_nRB;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPolynomialHyperElastic.h | .h | 2,091 | 62 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! Polynomial Hyperelastic
class FEPolynomialHyperElastic : public FEElasticMaterial
{
public:
FEPolynomialHyperElastic(FEModel* pfem);
public:
FEParamDouble m_c[3][3];
double m_D1, m_D2;
public:
//! calculate deviatoric stress at material point
mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate deviatoric tangent stiffness at material point
tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate deviatoric strain energy density
double StrainEnergyDensity(FEMaterialPoint& mp) override;
private:
double U(double J);
double UJ(double J);
double UJJ(double J);
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FETransIsoMooneyRivlin.cpp | .cpp | 7,134 | 239 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FETransIsoMooneyRivlin.h"
// define the material parameters
BEGIN_FECORE_CLASS(FETransIsoMooneyRivlin, FEUncoupledMaterial)
ADD_PARAMETER(m_c1 , "c1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c2 , "c2")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_fib.m_c3 , "c3")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_fib.m_c4 , "c4")->setUnits(UNIT_NONE);
ADD_PARAMETER(m_fib.m_c5 , "c5")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_fib.m_lam1, "lam_max")->setUnits(UNIT_NONE);
ADD_PROPERTY(m_fiber, "fiber")->SetDefaultType("vector");
ADD_PROPERTY(m_ac, "active_contraction", FEProperty::Optional);
END_FECORE_CLASS();
//////////////////////////////////////////////////////////////////////
// FETransIsoMooneyRivlin
//////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
FETransIsoMooneyRivlin::FETransIsoMooneyRivlin(FEModel* pfem) : FEUncoupledMaterial(pfem), m_fib(pfem)
{
m_c1 = 0.0;
m_c2 = 0.0;
m_ac = nullptr;
m_fib.SetParent(this);
m_fiber = nullptr;
}
//-----------------------------------------------------------------------------
//! create material point data
FEMaterialPointData* FETransIsoMooneyRivlin::CreateMaterialPointData()
{
// create the elastic solid material point
FEMaterialPointData* ep = new FEElasticMaterialPoint;
// create the material point from the active contraction material
if (m_ac) ep->Append(m_ac->CreateMaterialPointData());
return ep;
}
//-----------------------------------------------------------------------------
mat3ds FETransIsoMooneyRivlin::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
double J = pt.m_J;
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
double I1 = B.tr();
// material axes
mat3d Q = GetLocalCS(mp);
// get the fiber vector in local coordinates
vec3d fiber = m_fiber->unitVector(mp);
// convert to global coordinates
vec3d a0 = Q * fiber;
// --- TODO: put strain energy derivatives here ---
// Wi = dW/dIi
double W1 = m_c1(mp);
double W2 = m_c2(mp);
// ------------------------------------------------
// calculate T = F*dW/dC*Ft
mat3ds T = B*(W1 + W2*I1) - B2*W2;
// calculate stress s = pI + 2/J * dev(T)
mat3ds s = T.dev()*(2.0/J);
// calculate the passive fiber stress
mat3ds fs = m_fib.DevFiberStress(mp, a0);
// calculate the active fiber stress (if provided)
if (m_ac) fs += m_ac->ActiveStress(mp, a0);
return s + fs;
}
//-----------------------------------------------------------------------------
//! Calculate deviatoric tangent
tens4ds FETransIsoMooneyRivlin::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
double J = pt.m_J;
double Ji = 1.0/J;
// calculate deviatoric left Cauchy-Green tensor: B = F*Ft
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
double I1 = B.tr();
double I2 = 0.5*(I1*I1 - B2.tr());
// fiber vector
mat3d Q = GetLocalCS(mp);
// get the fiber vector in local coordinates
vec3d fiber = m_fiber->unitVector(mp);
// convert to global coordinates
vec3d a0 = Q * fiber;
// --- TODO: put strain energy derivatives here ---
// Wi = dW/dIi
double W1, W2;
W1 = m_c1(mp);
W2 = m_c2(mp);
// ------------------------------------
// calculate dWdC:C
double WC = W1*I1 + 2*W2*I2;
// calculate C:d2WdCdC:C
double CWWC = 2*I2*W2;
mat3dd I(1); // Identity
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxB = dyad1s(B);
tens4ds B4 = dyad4s(B);
// deviatoric cauchy-stress
mat3ds T = B * (W1 + W2 * I1) - B2 * W2;
mat3ds devs = T.dev() * (2.0 / J);
// d2W/dCdC:C
mat3ds WCCxC = B*(W2*I1) - B2*W2;
tens4ds cw = (BxB - B4)*(W2*4.0*Ji) - dyad1s(WCCxC, I)*(4.0/3.0*Ji) + IxI*(4.0/9.0*Ji*CWWC);
tens4ds c = dyad1s(devs, I)*(-2.0/3.0) + (I4 - IxI/3.0)*(4.0/3.0*Ji*WC) + cw;
// add the passive fiber stiffness
c += m_fib.DevFiberTangent(mp, a0);
// add the active fiber stiffness
if (m_ac) c += m_ac->ActiveStiffness(mp, a0);
return c;
}
//-----------------------------------------------------------------------------
double FETransIsoMooneyRivlin::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// fiber vector
mat3d Q = GetLocalCS(mp);
// get the fiber vector in local coordinates
vec3d fiber = m_fiber->unitVector(mp);
// convert to global coordinates
vec3d a0 = Q * fiber;
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
double I1 = B.tr();
double I2 = 0.5*(I1*I1 - B2.tr());
// calculate sed
double sed = m_c1(mp)*(I1-3) + m_c2(mp)*(I2-3);
// add the fiber sed
sed += m_fib.DevFiberStrainEnergyDensity(mp, a0);
return sed;
}
//-----------------------------------------------------------------------------
// update force-velocity material point
void FETransIsoMooneyRivlin::UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& timeInfo)
{
// fiber vector
mat3d Q = GetLocalCS(mp);
// get the fiber vector in local coordinates
vec3d fiber = m_fiber->unitVector(mp);
// convert to global coordinates
vec3d a0 = Q * fiber;
// get the material fiber axis
if (m_ac) m_ac->UpdateSpecializedMaterialPoints(mp, timeInfo, a0);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/ObjectDataRecord.cpp | .cpp | 3,418 | 112 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "ObjectDataRecord.h"
#include <FECore/FECoreKernel.h>
#include <FECore/FEModel.h>
#include "FERigidBody.h"
#include <FECore/FEMaterial.h>
#include "FEMechModel.h"
#include "FERigidMaterial.h"
//-----------------------------------------------------------------------------
ObjectDataRecord::ObjectDataRecord(FEModel* pfem) : DataRecord(pfem, FE_DATA_RB)
{
}
//-----------------------------------------------------------------------------
void ObjectDataRecord::SetData(const char* szexpr)
{
char szcopy[MAX_STRING] = {0};
strcpy(szcopy, szexpr);
char* sz = szcopy, *ch;
m_Data.clear();
strcpy(m_szdata, szexpr);
do
{
ch = strchr(sz, ';');
if (ch) *ch++ = 0;
FELogObjectData* pdata = fecore_new<FELogObjectData>(sz, GetFEModel());
if (pdata) m_Data.push_back(pdata);
else throw UnknownDataField(sz);
sz = ch;
}
while (ch);
}
//-----------------------------------------------------------------------------
double ObjectDataRecord::Evaluate(int item, int ndata)
{
FEMechModel* fem = dynamic_cast<FEMechModel*>(GetFEModel());
FEMesh& mesh = fem->GetMesh();
int nrb = item - 1;
if ((nrb < 0) || (nrb >= fem->Materials())) return 0;
double val = 0;
// find the rigid body that has this material
int NRB = fem->RigidBodies();
for (int i=0; i<NRB; ++i)
{
FERigidBody& obj = *fem->GetRigidBody(i);
if (obj.GetMaterialID() == nrb) return m_Data[ndata]->value(obj);
}
return val;
}
//-----------------------------------------------------------------------------
int ObjectDataRecord::Size() const { return (int)m_Data.size(); }
//-----------------------------------------------------------------------------
void ObjectDataRecord::SelectAllItems()
{
FEMechModel* fem = dynamic_cast<FEMechModel*>(GetFEModel());
int n = 0, i;
for (i=0; i<fem->Materials(); ++i)
{
FERigidMaterial* pm = dynamic_cast<FERigidMaterial*>(fem->GetMaterial(i));
if (pm) ++n;
}
if (n > 0)
{
m_item.resize(n);
n = 0;
for (i=0; i<fem->Materials(); ++i)
{
FERigidMaterial* pm = dynamic_cast<FERigidMaterial*>(fem->GetMaterial(i));
if (pm)
{
m_item[n++] = i+1;
}
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFixedNormalDisplacement.cpp | .cpp | 5,564 | 125 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEFixedNormalDisplacement.h"
#include "FECore/FECoreKernel.h"
#include <FECore/FEModel.h>
//=============================================================================
BEGIN_FECORE_CLASS(FEFixedNormalDisplacement, FESurfaceConstraint)
ADD_PARAMETER(m_lc.m_laugon, "laugon");
ADD_PARAMETER(m_lc.m_tol, "tol");
ADD_PARAMETER(m_lc.m_eps, "penalty");
ADD_PARAMETER(m_lc.m_rhs, "rhs");
ADD_PARAMETER(m_lc.m_naugmin, "minaug");
ADD_PARAMETER(m_lc.m_naugmax, "maxaug");
ADD_PARAMETER(m_bshellb , "shell_bottom");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFixedNormalDisplacement::FEFixedNormalDisplacement(FEModel* pfem) : FESurfaceConstraint(pfem), m_surf(pfem), m_lc(pfem)
{
m_binit = false;
m_bshellb = false;
}
//-----------------------------------------------------------------------------
//! Initializes data structures.
void FEFixedNormalDisplacement::Activate()
{
// don't forget to call base class
FESurfaceConstraint::Activate();
if (m_binit == false)
{
FEModel& fem = *GetFEModel();
DOFS& dofs = fem.GetDOFS();
// evaluate the nodal normals
m_surf.UpdateNodeNormals();
// create linear constraints
// for a symmetry plane the constraint on (ux, uy, uz) is
// nx*ux + ny*uy + nz*uz = 0
if (m_bshellb == false) {
for (int i = 0; i < m_surf.Nodes(); ++i) {
FENode& node = m_surf.Node(i);
if ((node.HasFlags(FENode::EXCLUDE) == false) && (node.m_rid == -1)) {
int nid = m_surf.NodeIndex(i) + 1; // NOTE: the linear constraint set still assumes 1-based indexing!
vec3d nn = m_surf.NodeNormal(i);
FEAugLagLinearConstraint* pLC = fecore_alloc(FEAugLagLinearConstraint, &fem);
pLC->AddDOF(nid, dofs.GetDOF("x"), nn.x);
pLC->AddDOF(nid, dofs.GetDOF("y"), nn.y);
pLC->AddDOF(nid, dofs.GetDOF("z"), nn.z);
// add the linear constraint to the system
m_lc.add(pLC);
}
}
}
else {
for (int i = 0; i < m_surf.Nodes(); ++i) {
FENode& node = m_surf.Node(i);
if ((node.HasFlags(FENode::EXCLUDE) == false) && (node.m_rid == -1)) {
vec3d nn = m_surf.NodeNormal(i);
int nid = m_surf.NodeIndex(i) + 1; // NOTE: the linear constraint set still assumes 1-based indexing!
FEAugLagLinearConstraint* pLC = fecore_alloc(FEAugLagLinearConstraint, &fem);
pLC->AddDOF(nid, dofs.GetDOF("sx"), nn.x);
pLC->AddDOF(nid, dofs.GetDOF("sy"), nn.y);
pLC->AddDOF(nid, dofs.GetDOF("sz"), nn.z);
// add the linear constraint to the system
m_lc.add(pLC);
}
}
}
m_lc.Init();
m_lc.Activate();
m_binit = true;
}
}
//-----------------------------------------------------------------------------
bool FEFixedNormalDisplacement::Init()
{
// initialize surface
return m_surf.Init();
}
//-----------------------------------------------------------------------------
void FEFixedNormalDisplacement::Serialize(DumpStream& ar) { m_lc.Serialize(ar); }
void FEFixedNormalDisplacement::LoadVector(FEGlobalVector& R, const FETimeInfo& tp) { m_lc.LoadVector(R, tp); }
void FEFixedNormalDisplacement::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) { m_lc.StiffnessMatrix(LS, tp); }
bool FEFixedNormalDisplacement::Augment(int naug, const FETimeInfo& tp) { return m_lc.Augment(naug, tp); }
void FEFixedNormalDisplacement::BuildMatrixProfile(FEGlobalMatrix& M) { m_lc.BuildMatrixProfile(M); }
int FEFixedNormalDisplacement::InitEquations(int neq) { return m_lc.InitEquations(neq); }
void FEFixedNormalDisplacement::Update(const std::vector<double>& Ui, const std::vector<double>& ui) { m_lc.Update(Ui, ui); }
void FEFixedNormalDisplacement::UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) { m_lc.UpdateIncrements(Ui, ui); }
void FEFixedNormalDisplacement::PrepStep() { m_lc.PrepStep(); }
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationGauss.h | .h | 2,326 | 72 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEFiberIntegrationScheme.h"
//----------------------------------------------------------------------------------
// Gauss integration scheme for continuous fiber distributions
//
class FEFiberIntegrationGauss : public FEFiberIntegrationScheme
{
class Iterator;
struct GRULE
{
int m_nph; // number of gauss integration points along phi
int m_nth; // number of trapezoidal integration points along theta
const double* m_gp; // gauss points
const double* m_gw; // gauss weights
};
public:
FEFiberIntegrationGauss(FEModel* pfem);
~FEFiberIntegrationGauss();
//! Initialization
bool Init() override;
//! Serialization
void Serialize(DumpStream& ar) override;
// get iterator
virtual FEFiberIntegrationSchemeIterator* GetIterator(FEMaterialPoint* mp) override;
// get number of integration points
int IntegrationPoints() const override { return -1; };
protected:
bool InitRule();
protected: // parameters
GRULE m_rule;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FENeoHookeanAD.h | .h | 2,497 | 68 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
#include <FECore/FEModelParam.h>
#include "adcm.h"
//! Implementation of a neo-Hookean hyperelastic material using automatic differentation
class FEBIOMECH_API FENeoHookeanAD : public FEElasticMaterial
{
public:
FENeoHookeanAD(FEModel* pfem);
public:
FEParamDouble m_E; //!< Young's modulus
FEParamDouble m_v; //!< Poisson's ratio
public:
//! calculate stress at material point
mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! calculate the 2nd Piola-Kirchhoff stress at material point
mat3ds PK2Stress(FEMaterialPoint& pt, const mat3ds E) override;
//! calculate material tangent stiffness at material point
tens4dmm MaterialTangent(FEMaterialPoint& pt, const mat3ds E) override;
public:
ad::number StrainEnergy_AD(FEMaterialPoint& mp, ad::mat3ds& C);
ad::mat3ds PK2Stress_AD(FEMaterialPoint& mp, ad::mat3ds& C);
ad2::number StrainEnergy_AD2(FEMaterialPoint& mp, ad2::mat3ds& C);
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEBioMechData.h | .h | 60,264 | 1,931 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/NodeDataRecord.h>
#include <FECore/ElementDataRecord.h>
#include <FECore/FaceDataRecord.h>
#include "ObjectDataRecord.h"
#include <FECore/NLConstraintDataRecord.h>
#include <FECore/FENLConstraint.h>
#include <FECore/SurfaceDataRecord.h>
#include <FECore/DomainDataRecord.h>
//=============================================================================
// N O D E D A T A
//=============================================================================
//-----------------------------------------------------------------------------
class FENodeXPos : public FELogNodeData
{
public:
FENodeXPos(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeYPos : public FELogNodeData
{
public:
FENodeYPos(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeZPos : public FELogNodeData
{
public:
FENodeZPos(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeXDisp : public FELogNodeData
{
public:
FENodeXDisp(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeYDisp : public FELogNodeData
{
public:
FENodeYDisp(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeZDisp : public FELogNodeData
{
public:
FENodeZDisp(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeXVel : public FELogNodeData
{
public:
FENodeXVel(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeYVel : public FELogNodeData
{
public:
FENodeYVel(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeZVel : public FELogNodeData
{
public:
FENodeZVel(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeXAcc : public FELogNodeData
{
public:
FENodeXAcc(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeYAcc : public FELogNodeData
{
public:
FENodeYAcc(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeZAcc : public FELogNodeData
{
public:
FENodeZAcc(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeForceX: public FELogNodeData
{
public:
FENodeForceX(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeForceY: public FELogNodeData
{
public:
FENodeForceY(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//-----------------------------------------------------------------------------
class FENodeForceZ: public FELogNodeData
{
public:
FENodeForceZ(FEModel* pfem) : FELogNodeData(pfem){}
double value(const FENode& node) override;
};
//=============================================================================
// F A C E D A T A
//=============================================================================
//-----------------------------------------------------------------------------
class FELogContactGap : public FELogFaceData
{
public:
FELogContactGap(FEModel* fem) : FELogFaceData(fem) {}
double value(FESurfaceElement& el) override;
};
//-----------------------------------------------------------------------------
class FELogContactPressure : public FELogFaceData
{
public:
FELogContactPressure(FEModel* fem) : FELogFaceData(fem) {}
double value(FESurfaceElement& el) override;
};
//-----------------------------------------------------------------------------
class FELogContactTractionX : public FELogFaceData
{
public:
FELogContactTractionX(FEModel* fem) : FELogFaceData(fem) {}
double value(FESurfaceElement& el) override;
};
//-----------------------------------------------------------------------------
class FELogContactTractionY : public FELogFaceData
{
public:
FELogContactTractionY(FEModel* fem) : FELogFaceData(fem) {}
double value(FESurfaceElement& el) override;
};
//-----------------------------------------------------------------------------
class FELogContactTractionZ : public FELogFaceData
{
public:
FELogContactTractionZ(FEModel* fem) : FELogFaceData(fem) {}
double value(FESurfaceElement& el) override;
};
//=============================================================================
// E L E M E N T D A T A
//=============================================================================
//-----------------------------------------------------------------------------
class FELogElemPosX : public FELogElemData
{
public:
FELogElemPosX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPosY : public FELogElemData
{
public:
FELogElemPosY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPosZ : public FELogElemData
{
public:
FELogElemPosZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemJacobian : public FELogElemData
{
public:
FELogElemJacobian(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrainX : public FELogElemData
{
public:
FELogElemStrainX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrainY : public FELogElemData
{
public:
FELogElemStrainY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrainZ : public FELogElemData
{
public:
FELogElemStrainZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrainXY : public FELogElemData
{
public:
FELogElemStrainXY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrainYZ : public FELogElemData
{
public:
FELogElemStrainYZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrainXZ : public FELogElemData
{
public:
FELogElemStrainXZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrain1 : public FELogElemData
{
public:
FELogElemStrain1(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrainEffective : public FELogElemData
{
public:
FELogElemStrainEffective(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrain2 : public FELogElemData
{
public:
FELogElemStrain2(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStrain3 : public FELogElemData
{
public:
FELogElemStrain3(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemInfStrainX : public FELogElemData
{
public:
FELogElemInfStrainX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemInfStrainY : public FELogElemData
{
public:
FELogElemInfStrainY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemInfStrainZ : public FELogElemData
{
public:
FELogElemInfStrainZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemInfStrainXY : public FELogElemData
{
public:
FELogElemInfStrainXY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemInfStrainYZ : public FELogElemData
{
public:
FELogElemInfStrainYZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemInfStrainXZ : public FELogElemData
{
public:
FELogElemInfStrainXZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretchX : public FELogElemData
{
public:
FELogElemRightStretchX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretchY : public FELogElemData
{
public:
FELogElemRightStretchY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretchZ : public FELogElemData
{
public:
FELogElemRightStretchZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretchXY : public FELogElemData
{
public:
FELogElemRightStretchXY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretchYZ : public FELogElemData
{
public:
FELogElemRightStretchYZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretchXZ : public FELogElemData
{
public:
FELogElemRightStretchXZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretch1 : public FELogElemData
{
public:
FELogElemRightStretch1(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretch2 : public FELogElemData
{
public:
FELogElemRightStretch2(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretch3 : public FELogElemData
{
public:
FELogElemRightStretch3(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightStretchEffective : public FELogElemData
{
public:
FELogElemRightStretchEffective(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretchX : public FELogElemData
{
public:
FELogElemLeftStretchX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretchY : public FELogElemData
{
public:
FELogElemLeftStretchY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretchZ : public FELogElemData
{
public:
FELogElemLeftStretchZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretchXY : public FELogElemData
{
public:
FELogElemLeftStretchXY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretchYZ : public FELogElemData
{
public:
FELogElemLeftStretchYZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretchXZ : public FELogElemData
{
public:
FELogElemLeftStretchXZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretch1 : public FELogElemData
{
public:
FELogElemLeftStretch1(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretch2 : public FELogElemData
{
public:
FELogElemLeftStretch2(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretch3 : public FELogElemData
{
public:
FELogElemLeftStretch3(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftStretchEffective : public FELogElemData
{
public:
FELogElemLeftStretchEffective(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHenckyX : public FELogElemData
{
public:
FELogElemRightHenckyX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHenckyY : public FELogElemData
{
public:
FELogElemRightHenckyY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHenckyZ : public FELogElemData
{
public:
FELogElemRightHenckyZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHenckyXY : public FELogElemData
{
public:
FELogElemRightHenckyXY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHenckyYZ : public FELogElemData
{
public:
FELogElemRightHenckyYZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHenckyXZ : public FELogElemData
{
public:
FELogElemRightHenckyXZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHencky1 : public FELogElemData
{
public:
FELogElemRightHencky1(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHencky2 : public FELogElemData
{
public:
FELogElemRightHencky2(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHencky3 : public FELogElemData
{
public:
FELogElemRightHencky3(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemRightHenckyEffective : public FELogElemData
{
public:
FELogElemRightHenckyEffective(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHenckyX : public FELogElemData
{
public:
FELogElemLeftHenckyX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHenckyY : public FELogElemData
{
public:
FELogElemLeftHenckyY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHenckyZ : public FELogElemData
{
public:
FELogElemLeftHenckyZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHenckyXY : public FELogElemData
{
public:
FELogElemLeftHenckyXY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHenckyYZ : public FELogElemData
{
public:
FELogElemLeftHenckyYZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHenckyXZ : public FELogElemData
{
public:
FELogElemLeftHenckyXZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHencky1 : public FELogElemData
{
public:
FELogElemLeftHencky1(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHencky2 : public FELogElemData
{
public:
FELogElemLeftHencky2(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHencky3 : public FELogElemData
{
public:
FELogElemLeftHencky3(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemLeftHenckyEffective : public FELogElemData
{
public:
FELogElemLeftHenckyEffective(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStressX : public FELogElemData
{
public:
FELogElemStressX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStressY : public FELogElemData
{
public:
FELogElemStressY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStressZ : public FELogElemData
{
public:
FELogElemStressZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStressXY : public FELogElemData
{
public:
FELogElemStressXY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStressYZ : public FELogElemData
{
public:
FELogElemStressYZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStressXZ : public FELogElemData
{
public:
FELogElemStressXZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStressEffective : public FELogElemData
{
public:
FELogElemStressEffective(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStress1 : public FELogElemData
{
public:
FELogElemStress1(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStress2 : public FELogElemData
{
public:
FELogElemStress2(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStress3 : public FELogElemData
{
public:
FELogElemStress3(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK2StressX : public FELogElemData
{
public:
FELogElemPK2StressX(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK2StressY : public FELogElemData
{
public:
FELogElemPK2StressY(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK2StressZ : public FELogElemData
{
public:
FELogElemPK2StressZ(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK2StressXY : public FELogElemData
{
public:
FELogElemPK2StressXY(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK2StressYZ : public FELogElemData
{
public:
FELogElemPK2StressYZ(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK2StressXZ : public FELogElemData
{
public:
FELogElemPK2StressXZ(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK1StressXX : public FELogElemData
{
public:
FELogElemPK1StressXX(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK1StressYY : public FELogElemData
{
public:
FELogElemPK1StressYY(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK1StressZZ : public FELogElemData
{
public:
FELogElemPK1StressZZ(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK1StressXY : public FELogElemData
{
public:
FELogElemPK1StressXY(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK1StressYZ : public FELogElemData
{
public:
FELogElemPK1StressYZ(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK1StressXZ : public FELogElemData
{
public:
FELogElemPK1StressXZ(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK1StressYX : public FELogElemData
{
public:
FELogElemPK1StressYX(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK1StressZY : public FELogElemData
{
public:
FELogElemPK1StressZY(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemPK1StressZX : public FELogElemData
{
public:
FELogElemPK1StressZX(FEModel* pfem) : FELogElemData(pfem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemStressEigenVector : public FELogElemData
{
public:
FELogElemStressEigenVector(FEModel* pfem) : FELogElemData(pfem), m_eigenVector(-1), m_component(-1) {}
double value(FEElement& el);
protected:
int m_eigenVector;
int m_component;
};
template <int eigenVector, int component> class FELogElemStressEigenVector_T : public FELogElemStressEigenVector
{
public:
FELogElemStressEigenVector_T(FEModel* pfem) : FELogElemStressEigenVector(pfem)
{
m_eigenVector = eigenVector;
m_component = component;
}
};
//-----------------------------------------------------------------------------
class FELogElemDeformationGradientXX : public FELogElemData
{
public:
FELogElemDeformationGradientXX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemDeformationGradientXY : public FELogElemData
{
public:
FELogElemDeformationGradientXY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemDeformationGradientXZ : public FELogElemData
{
public:
FELogElemDeformationGradientXZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemDeformationGradientYX : public FELogElemData
{
public:
FELogElemDeformationGradientYX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemDeformationGradientYY : public FELogElemData
{
public:
FELogElemDeformationGradientYY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemDeformationGradientYZ : public FELogElemData
{
public:
FELogElemDeformationGradientYZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemDeformationGradientZX : public FELogElemData
{
public:
FELogElemDeformationGradientZX(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemDeformationGradientZY : public FELogElemData
{
public:
FELogElemDeformationGradientZY(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemDeformationGradientZZ : public FELogElemData
{
public:
FELogElemDeformationGradientZZ(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
// This log variable outputs the total deformation gradient
// For prestrain materials this will include the effect of the prestrain gradient
// For other materials, this will output the same as the regular deformation gradient
class FELogTotalDeformationGradient : public FELogElemData
{
public:
FELogTotalDeformationGradient(int r, int c, FEModel* fem) : FELogElemData(fem), m_r(r), m_c(c) {}
double value(FEElement& el) override;
private:
int m_r, m_c;
};
template <int row, int col> class FELogTotalDeformationGradient_T : public FELogTotalDeformationGradient
{
public:
FELogTotalDeformationGradient_T(FEModel* fem) : FELogTotalDeformationGradient(row, col, fem){}
};
//-----------------------------------------------------------------------------
// Base class for elasticity tensor output
class FELogElemElasticity_ : public FELogElemData
{
protected:
FELogElemElasticity_(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el, int n);
};
//-----------------------------------------------------------------------------
// template class for generating the different tensor components
template <int n> class FELogElemElasticity : public FELogElemElasticity_
{
public:
FELogElemElasticity(FEModel* pfem) : FELogElemElasticity_(pfem){}
double value(FEElement& el) { return FELogElemElasticity_::value(el, n); }
};
//-----------------------------------------------------------------------------
class FELogElemStrainEnergyDensity : public FELogElemData
{
public:
FELogElemStrainEnergyDensity(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemDevStrainEnergyDensity : public FELogElemData
{
public:
FELogElemDevStrainEnergyDensity(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemFiberStretch : public FELogElemData
{
public:
FELogElemFiberStretch(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElemFiberVector_ : public FELogElemData
{
public:
FELogElemFiberVector_(FEModel* pfem, int comp) : FELogElemData(pfem), m_comp(comp) {}
double value(FEElement& el);
private:
int m_comp;
};
template <int N> class FELogElemFiberVector_N : public FELogElemFiberVector_
{
public:
FELogElemFiberVector_N(FEModel* fem) : FELogElemFiberVector_(fem, N) {}
};
//-----------------------------------------------------------------------------
//! Damage (fraction of broken bonds))
class FELogDamage_ : public FELogElemData
{
public:
FELogDamage_(FEModel* pfem, int comp = -1) : FELogElemData(pfem), m_comp(comp) {}
double value(FEElement& el);
private:
int m_comp;
};
class FELogDamage : public FELogDamage_
{
public:
FELogDamage(FEModel* pfem) : FELogDamage_(pfem, -1) {}
};
template <int n> class FELogDamage_n : public FELogDamage_
{
public:
FELogDamage_n(FEModel* fem) : FELogDamage_(fem, n) {}
};
//-----------------------------------------------------------------------------
//! Fraction of intact bonds
class FELogIntactBonds : public FELogElemData
{
public:
FELogIntactBonds(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
//! Fraction of fatigued bonds
class FELogFatigueBonds : public FELogElemData
{
public:
FELogFatigueBonds(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
//! Fraction of yielded bonds
class FELogYieldedBonds : public FELogElemData
{
public:
FELogYieldedBonds(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
//! Damage reduction factor
class FELogOctahedralPlasticStrain : public FELogElemData
{
public:
FELogOctahedralPlasticStrain(FEModel* pfem) : FELogElemData(pfem){}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
//! Discrete element stretch
class FELogDiscreteElementStretch : public FELogElemData
{
public:
FELogDiscreteElementStretch(FEModel* fem) : FELogElemData(fem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
//! Discrete element elongation
class FELogDiscreteElementElongation : public FELogElemData
{
public:
FELogDiscreteElementElongation(FEModel* fem) : FELogElemData(fem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
//! Discrete element force
class FELogDiscreteElementForce : public FELogElemData
{
public:
FELogDiscreteElementForce(FEModel* fem) : FELogElemData(fem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
//! Discrete element force
class FELogDiscreteElementForceX : public FELogElemData
{
public:
FELogDiscreteElementForceX(FEModel* fem) : FELogElemData(fem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
//! Discrete element force
class FELogDiscreteElementForceY : public FELogElemData
{
public:
FELogDiscreteElementForceY(FEModel* fem) : FELogElemData(fem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
//! Discrete element force
class FELogDiscreteElementForceZ : public FELogElemData
{
public:
FELogDiscreteElementForceZ(FEModel* fem) : FELogElemData(fem) {}
double value(FEElement& el);
};
//-----------------------------------------------------------------------------
class FELogElementMixtureStress : public FELogElemData
{
public:
FELogElementMixtureStress(FEModel* fem, int n, int m) : FELogElemData(fem), m_comp(n), m_metric(m) {}
double value(FEElement& el);
private:
int m_comp;
int m_metric;
};
template <int N, int M> class FELogElementMixtureStress_T : public FELogElementMixtureStress
{
public:
FELogElementMixtureStress_T(FEModel* fem) : FELogElementMixtureStress(fem, N, M) {}
};
//=============================================================================
// R I G I D B O D Y D A T A
//=============================================================================
//-----------------------------------------------------------------------------
class FELogRigidBodyPosX : public FELogObjectData
{
public:
FELogRigidBodyPosX(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyPosY : public FELogObjectData
{
public:
FELogRigidBodyPosY(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyPosZ : public FELogObjectData
{
public:
FELogRigidBodyPosZ(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyVelX : public FELogObjectData
{
public:
FELogRigidBodyVelX(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyVelY : public FELogObjectData
{
public:
FELogRigidBodyVelY(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyVelZ : public FELogObjectData
{
public:
FELogRigidBodyVelZ(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAccX : public FELogObjectData
{
public:
FELogRigidBodyAccX(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAccY : public FELogObjectData
{
public:
FELogRigidBodyAccY(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAccZ : public FELogObjectData
{
public:
FELogRigidBodyAccZ(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAngPosX : public FELogObjectData
{
public:
FELogRigidBodyAngPosX(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAngPosY : public FELogObjectData
{
public:
FELogRigidBodyAngPosY(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAngPosZ : public FELogObjectData
{
public:
FELogRigidBodyAngPosZ(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAngVelX : public FELogObjectData
{
public:
FELogRigidBodyAngVelX(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAngVelY : public FELogObjectData
{
public:
FELogRigidBodyAngVelY(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAngVelZ : public FELogObjectData
{
public:
FELogRigidBodyAngVelZ(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAngAccX : public FELogObjectData
{
public:
FELogRigidBodyAngAccX(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAngAccY : public FELogObjectData
{
public:
FELogRigidBodyAngAccY(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyAngAccZ : public FELogObjectData
{
public:
FELogRigidBodyAngAccZ(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyQuatX : public FELogObjectData
{
public:
FELogRigidBodyQuatX(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyQuatY : public FELogObjectData
{
public:
FELogRigidBodyQuatY(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyQuatZ : public FELogObjectData
{
public:
FELogRigidBodyQuatZ(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyQuatW : public FELogObjectData
{
public:
FELogRigidBodyQuatW(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyR11 : public FELogObjectData
{
public:
FELogRigidBodyR11(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyR12 : public FELogObjectData
{
public:
FELogRigidBodyR12(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyR13 : public FELogObjectData
{
public:
FELogRigidBodyR13(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyR21 : public FELogObjectData
{
public:
FELogRigidBodyR21(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyR22 : public FELogObjectData
{
public:
FELogRigidBodyR22(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyR23 : public FELogObjectData
{
public:
FELogRigidBodyR23(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyR31 : public FELogObjectData
{
public:
FELogRigidBodyR31(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyR32 : public FELogObjectData
{
public:
FELogRigidBodyR32(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyR33 : public FELogObjectData
{
public:
FELogRigidBodyR33(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyEulerX : public FELogObjectData
{
public:
FELogRigidBodyEulerX(FEModel* pfem) : FELogObjectData(pfem) {}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyEulerY : public FELogObjectData
{
public:
FELogRigidBodyEulerY(FEModel* pfem) : FELogObjectData(pfem) {}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyEulerZ : public FELogObjectData
{
public:
FELogRigidBodyEulerZ(FEModel* pfem) : FELogObjectData(pfem) {}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyForceX : public FELogObjectData
{
public:
FELogRigidBodyForceX(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyForceY : public FELogObjectData
{
public:
FELogRigidBodyForceY(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyForceZ : public FELogObjectData
{
public:
FELogRigidBodyForceZ(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyTorqueX : public FELogObjectData
{
public:
FELogRigidBodyTorqueX(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyTorqueY : public FELogObjectData
{
public:
FELogRigidBodyTorqueY(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyTorqueZ : public FELogObjectData
{
public:
FELogRigidBodyTorqueZ(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyKineticEnergy : public FELogObjectData
{
public:
FELogRigidBodyKineticEnergy(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorForceX : public FELogNLConstraintData
{
public:
FELogRigidConnectorForceX(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorForceY : public FELogNLConstraintData
{
public:
FELogRigidConnectorForceY(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorForceZ : public FELogNLConstraintData
{
public:
FELogRigidConnectorForceZ(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorMomentX : public FELogNLConstraintData
{
public:
FELogRigidConnectorMomentX(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorMomentY : public FELogNLConstraintData
{
public:
FELogRigidConnectorMomentY(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorMomentZ : public FELogNLConstraintData
{
public:
FELogRigidConnectorMomentZ(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorTranslationX : public FELogNLConstraintData
{
public:
FELogRigidConnectorTranslationX(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorTranslationY : public FELogNLConstraintData
{
public:
FELogRigidConnectorTranslationY(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorTranslationZ : public FELogNLConstraintData
{
public:
FELogRigidConnectorTranslationZ(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorRotationX : public FELogNLConstraintData
{
public:
FELogRigidConnectorRotationX(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorRotationY : public FELogNLConstraintData
{
public:
FELogRigidConnectorRotationY(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorRotationZ : public FELogNLConstraintData
{
public:
FELogRigidConnectorRotationZ(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogVolumeConstraint : public FELogNLConstraintData
{
public:
FELogVolumeConstraint(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogVolumePressure : public FELogNLConstraintData
{
public:
FELogVolumePressure(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidBodyIHAwx : public FELogObjectData
{
public:
FELogRigidBodyIHAwx(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyIHAwy : public FELogObjectData
{
public:
FELogRigidBodyIHAwy(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyIHAwz : public FELogObjectData
{
public:
FELogRigidBodyIHAwz(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyIHAwm : public FELogObjectData
{
public:
FELogRigidBodyIHAwm(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyIHAsx : public FELogObjectData
{
public:
FELogRigidBodyIHAsx(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyIHAsy : public FELogObjectData
{
public:
FELogRigidBodyIHAsy(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyIHAsz : public FELogObjectData
{
public:
FELogRigidBodyIHAsz(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyIHAtd : public FELogObjectData
{
public:
FELogRigidBodyIHAtd(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyFHAwx : public FELogObjectData
{
public:
FELogRigidBodyFHAwx(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyFHAwy : public FELogObjectData
{
public:
FELogRigidBodyFHAwy(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyFHAwz : public FELogObjectData
{
public:
FELogRigidBodyFHAwz(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyFHAwm : public FELogObjectData
{
public:
FELogRigidBodyFHAwm(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyFHAsx : public FELogObjectData
{
public:
FELogRigidBodyFHAsx(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyFHAsy : public FELogObjectData
{
public:
FELogRigidBodyFHAsy(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyFHAsz : public FELogObjectData
{
public:
FELogRigidBodyFHAsz(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidBodyFHAtd : public FELogObjectData
{
public:
FELogRigidBodyFHAtd(FEModel* pfem) : FELogObjectData(pfem){}
double value(FERigidBody& rb) override;
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorIHAwx : public FELogNLConstraintData
{
public:
FELogRigidConnectorIHAwx(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorIHAwy : public FELogNLConstraintData
{
public:
FELogRigidConnectorIHAwy(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorIHAwz : public FELogNLConstraintData
{
public:
FELogRigidConnectorIHAwz(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorIHAwm : public FELogNLConstraintData
{
public:
FELogRigidConnectorIHAwm(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorIHAsx : public FELogNLConstraintData
{
public:
FELogRigidConnectorIHAsx(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorIHAsy : public FELogNLConstraintData
{
public:
FELogRigidConnectorIHAsy(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorIHAsz : public FELogNLConstraintData
{
public:
FELogRigidConnectorIHAsz(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorIHAtd : public FELogNLConstraintData
{
public:
FELogRigidConnectorIHAtd(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorFHAwx : public FELogNLConstraintData
{
public:
FELogRigidConnectorFHAwx(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorFHAwy : public FELogNLConstraintData
{
public:
FELogRigidConnectorFHAwy(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorFHAwz : public FELogNLConstraintData
{
public:
FELogRigidConnectorFHAwz(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorFHAwm : public FELogNLConstraintData
{
public:
FELogRigidConnectorFHAwm(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorFHAsx : public FELogNLConstraintData
{
public:
FELogRigidConnectorFHAsx(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorFHAsy : public FELogNLConstraintData
{
public:
FELogRigidConnectorFHAsy(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorFHAsz : public FELogNLConstraintData
{
public:
FELogRigidConnectorFHAsz(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//-----------------------------------------------------------------------------
class FELogRigidConnectorFHAtd : public FELogNLConstraintData
{
public:
FELogRigidConnectorFHAtd(FEModel* pfem) : FELogNLConstraintData(pfem){}
double value(FENLConstraint& rc);
};
//=============================================================================
// S U R F A C E D A T A
//=============================================================================
class FELogContactArea : public FELogSurfaceData
{
public:
FELogContactArea(FEModel* fem) : FELogSurfaceData(fem) {}
double value(FESurface& surface) override;
};
class FELogMaxContactGap : public FELogSurfaceData
{
public:
FELogMaxContactGap(FEModel* fem) : FELogSurfaceData(fem) {}
double value(FESurface& surface) override;
};
//=============================================================================
// D O M A I N D A T A
//=============================================================================
// from Gibbons, "Finite Element Modeling of Blast Lung Injury in Sheep", JBME 2015
// this calculates the normalized time-summed internal energy
class FENormalizedInternalEnergy : public FELogDomainData
{
public:
FENormalizedInternalEnergy(FEModel* fem) : FELogDomainData(fem), m_sum(0) {}
double value(FEDomain& dom) override;
private:
double m_sum;
};
class FELogTotalEnergy : public FELogDomainData
{
public:
FELogTotalEnergy(FEModel* fem) : FELogDomainData(fem), m_sum(0) {}
double value(FEDomain& dom) override;
private:
double m_sum;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERVEFatigueMaterial.cpp | .cpp | 5,651 | 165 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FERVEFatigueMaterial.h"
#include "FEUncoupledMaterial.h"
#include <FECore/log.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERVEFatigueMaterial, FEElasticMaterial)
// set material properties
ADD_PROPERTY(m_pRVE , "viscoelastic");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FERVEFatigueMaterial::FERVEFatigueMaterial(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_pRVE = nullptr;
}
//-----------------------------------------------------------------------------
//! Initialization.
bool FERVEFatigueMaterial::Init()
{
FEUncoupledMaterial* m_pMat = dynamic_cast<FEUncoupledMaterial*>((FEElasticMaterial*)m_pRVE);
if (m_pMat != nullptr)
{
feLogError("Viscoelastic material should not be of type uncoupled");
return false;
}
FEReactiveFatigue* pmat = dynamic_cast<FEReactiveFatigue*>(m_pRVE->GetBaseMaterial());
if (pmat == nullptr)
{
feLogError("Elastic material should be of type Reactive fatigue");
return false;
}
return m_pRVE->Init();
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FERVEFatigueMaterial::CreateMaterialPointData()
{
FEReactiveViscoelasticMaterialPoint* pt = new FEReactiveViscoelasticMaterialPoint();
// create damage materal point for strong bond (base) material
FEReactiveFatigueMaterialPoint* pbase = new FEReactiveFatigueMaterialPoint(m_pRVE->GetBaseMaterial()->CreateMaterialPointData());
pt->AddMaterialPoint(new FEMaterialPoint(pbase));
// create materal point for weak bond material
FEReactiveVEMaterialPoint* pbond = new FEReactiveVEMaterialPoint(m_pRVE->GetBondMaterial()->CreateMaterialPointData());
pt->AddMaterialPoint(new FEMaterialPoint(pbond));
return pt;
}
//-----------------------------------------------------------------------------
//! calculate stress at material point
mat3ds FERVEFatigueMaterial::Stress(FEMaterialPoint& pt)
{
// evaluate the damage
double d = Damage(pt);
// evaluate the stress
mat3ds s = m_pRVE->Stress(pt);
// return damaged stress
return s*(1-d);
}
//-----------------------------------------------------------------------------
//! calculate tangent stiffness at material point
tens4ds FERVEFatigueMaterial::Tangent(FEMaterialPoint& pt)
{
// evaluate the damage
double d = Damage(pt);
// evaluate the tangent
tens4ds c = m_pRVE->Tangent(pt);
// return damaged tangent
return c*(1-d);
}
//-----------------------------------------------------------------------------
//! calculate strain energy density at material point
double FERVEFatigueMaterial::StrainEnergyDensity(FEMaterialPoint& pt)
{
// evaluate the damage
double d = Damage(pt);
// evaluate the strain energy density
double sed = m_pRVE->StrainEnergyDensity(pt);
// return damaged sed
return sed*(1-d);
}
//-----------------------------------------------------------------------------
//! calculate strong bond strain energy density at material point
double FERVEFatigueMaterial::StrongBondSED(FEMaterialPoint& pt)
{
// evaluate the damage
double d = Damage(pt);
// evaluate the strain energy density
double sed = m_pRVE->StrongBondSED(pt);
// return damaged sed
return sed*(1-d);
}
//-----------------------------------------------------------------------------
//! calculate weak bond strain energy density at material point
double FERVEFatigueMaterial::WeakBondSED(FEMaterialPoint& pt)
{
// evaluate the damage
double d = Damage(pt);
// evaluate the strain energy density
double sed = m_pRVE->WeakBondSED(pt);
// return damaged sed
return sed*(1-d);
}
//-----------------------------------------------------------------------------
//! calculate damage at material point
double FERVEFatigueMaterial::Damage(FEMaterialPoint& pt)
{
// get the reactive viscoelastic base material point
FEMaterialPoint* pb = m_pRVE->GetBaseMaterialPoint(pt);
// get the reactive fatigue material point data
FEReactiveFatigueMaterialPoint& pd = *pb->ExtractData<FEReactiveFatigueMaterialPoint>();
return pd.m_D;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberPowLinearUncoupled.h | .h | 2,450 | 66 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticFiberMaterialUC.h"
#include "FEFiberMaterial.h"
//-----------------------------------------------------------------------------
//! Material class for single fiber, tension only
//! Power-law linear response (uncoupled)
class FEFiberPowLinearUC : public FEFiberMaterialUncoupled
{
public:
FEFiberPowLinearUC(FEModel* pfem);
//! Cauchy stress
mat3ds DevFiberStress(FEMaterialPoint& mp, const vec3d& n0) override;
// Spatial tangent
tens4ds DevFiberTangent(FEMaterialPoint& mp, const vec3d& n0) override;
//! Strain energy density
double DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0) override;
public:
FEParamDouble m_E; // fiber modulus
FEParamDouble m_lam0; // stretch ratio at end of toe region
FEParamDouble m_beta; // power law exponent in toe region
// declare the parameter list
DECLARE_FECORE_CLASS();
};
class FEUncoupledFiberPowLinear : public FEElasticFiberMaterialUC_T<FEFiberPowLinearUC>
{
public:
FEUncoupledFiberPowLinear(FEModel* fem) : FEElasticFiberMaterialUC_T<FEFiberPowLinearUC>(fem) {}
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFacet2FacetTied.cpp | .cpp | 19,390 | 745 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEFacet2FacetTied.h"
#include "FECore/FEMesh.h"
#include "FECore/FEClosestPointProjection.h"
#include "FECore/FEGlobalMatrix.h"
#include <FECore/FELinearSystem.h>
#include "FECore/log.h"
//-----------------------------------------------------------------------------
// Define tied interface parameters
BEGIN_FECORE_CLASS(FEFacet2FacetTied, FEContactInterface)
ADD_PARAMETER(m_laugon , "laugon")->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0");
ADD_PARAMETER(m_atol , "tolerance" );
ADD_PARAMETER(m_eps , "penalty" );
ADD_PARAMETER(m_naugmin, "minaug" );
ADD_PARAMETER(m_naugmax, "maxaug" );
ADD_PARAMETER(m_stol , "search_tolerance");
ADD_PARAMETER(m_gapoff , "gap_offset" );
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFacetTiedSurface::Data::Data()
{
m_vgap = vec3d(0,0,0);
m_vgap0 = vec3d(0,0,0);
m_Lm = vec3d(0,0,0);
m_rs = vec2d(0,0);
m_pme = (FESurfaceElement*) 0;
}
void FEFacetTiedSurface::Data::Init()
{
FEContactMaterialPoint::Init();
m_vgap = vec3d(0, 0, 0);
m_vgap0 = vec3d(0, 0, 0);
m_Lm = vec3d(0, 0, 0);
m_rs = vec2d(0, 0);
m_pme = (FESurfaceElement*)0;
}
void FEFacetTiedSurface::Data::Serialize(DumpStream& ar)
{
FEContactMaterialPoint::Serialize(ar);
ar & m_vgap & m_vgap0 & m_Lm & m_rs;
}
//-----------------------------------------------------------------------------
FEFacetTiedSurface::FEFacetTiedSurface(FEModel* pfem) : FEContactSurface(pfem)
{
}
//-----------------------------------------------------------------------------
bool FEFacetTiedSurface::Init()
{
// initialize surface data first
if (FEContactSurface::Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
//! create material point data
FEMaterialPoint* FEFacetTiedSurface::CreateMaterialPoint()
{
return new FEFacetTiedSurface::Data;
}
//-----------------------------------------------------------------------------
void FEFacetTiedSurface::Serialize(DumpStream &ar)
{
FEContactSurface::Serialize(ar);
if (ar.IsShallow())
{
if (ar.IsSaving())
{
for (int n=0; n<Elements(); ++n)
{
FESurfaceElement& el = Element(n);
int nint = el.GaussPoints();
for (int j=0; j<nint; ++j)
{
Data& d = static_cast<Data&>(*el.GetMaterialPoint(j));
ar << d.m_vgap;
ar << d.m_vgap0;
ar << d.m_rs;
ar << d.m_Lm;
}
}
}
else
{
for (int n = 0; n<Elements(); ++n)
{
FESurfaceElement& el = Element(n);
int nint = el.GaussPoints();
for (int j = 0; j<nint; ++j)
{
Data& d = static_cast<Data&>(*el.GetMaterialPoint(j));
ar >> d.m_vgap;
ar >> d.m_vgap0;
ar >> d.m_rs;
ar >> d.m_Lm;
}
}
}
}
else
{
if (ar.IsSaving())
{
for (int n = 0; n<Elements(); ++n)
{
FESurfaceElement& el = Element(n);
int nint = el.GaussPoints();
for (int j = 0; j<nint; ++j)
{
Data& d = static_cast<Data&>(*el.GetMaterialPoint(j));
ar << d.m_vgap;
ar << d.m_vgap0;
ar << d.m_rs;
ar << d.m_Lm;
}
}
}
else
{
for (int n = 0; n<Elements(); ++n)
{
FESurfaceElement& el = Element(n);
int nint = el.GaussPoints();
for (int j = 0; j<nint; ++j)
{
Data& d = static_cast<Data&>(*el.GetMaterialPoint(j));
ar >> d.m_vgap;
ar >> d.m_vgap0;
ar >> d.m_rs;
ar >> d.m_Lm;
}
}
}
}
}
//=============================================================================
FEFacet2FacetTied::FEFacet2FacetTied(FEModel* pfem) : FEContactInterface(pfem), m_ss(pfem), m_ms(pfem)
{
// give this interface an ID
static int count = 1;
SetID(count++);
// set parents
m_ss.SetContactInterface(this);
m_ms.SetContactInterface(this);
// define sibling relationships
m_ss.SetSibling(&m_ms);
m_ms.SetSibling(&m_ss);
// initial parameter values
m_atol = 0.01;
m_eps = 1.0;
m_naugmin = 0;
m_naugmax = 10;
m_stol = 0.0001;
m_gapoff = false;
}
//-----------------------------------------------------------------------------
//! build the matrix profile for use in the stiffness matrix
void FEFacet2FacetTied::BuildMatrixProfile(FEGlobalMatrix& K)
{
FEMesh& mesh = GetMesh();
// get the DOFS
const int dof_X = GetDOFIndex("x");
const int dof_Y = GetDOFIndex("y");
const int dof_Z = GetDOFIndex("z");
const int dof_RU = GetDOFIndex("Ru");
const int dof_RV = GetDOFIndex("Rv");
const int dof_RW = GetDOFIndex("Rw");
vector<int> lm(6*FEElement::MAX_NODES*2);
FEFacetTiedSurface& ss = m_ss;
FEFacetTiedSurface& ms = m_ms;
for (int j=0; j<ss.Elements(); ++j)
{
FESurfaceElement& se = ss.Element(j);
int nint = se.GaussPoints();
int* sn = &se.m_node[0];
for (int k=0; k<nint; ++k)
{
FEFacetTiedSurface::Data& d = static_cast<FEFacetTiedSurface::Data&>(*se.GetMaterialPoint(k));
FESurfaceElement* pe = d.m_pme;
if (pe != 0)
{
FESurfaceElement& me = *pe;
int* mn = &me.m_node[0];
lm.assign(lm.size(), -1);
int nseln = se.Nodes();
int nmeln = me.Nodes();
for (int l=0; l<nseln; ++l)
{
vector<int>& id = mesh.Node(sn[l]).m_ID;
lm[6*l ] = id[dof_X];
lm[6*l+1] = id[dof_Y];
lm[6*l+2] = id[dof_Z];
lm[6*l+3] = id[dof_RU];
lm[6*l+4] = id[dof_RV];
lm[6*l+5] = id[dof_RW];
}
for (int l=0; l<nmeln; ++l)
{
vector<int>& id = mesh.Node(mn[l]).m_ID;
lm[6*(l+nseln) ] = id[dof_X];
lm[6*(l+nseln)+1] = id[dof_Y];
lm[6*(l+nseln)+2] = id[dof_Z];
lm[6*(l+nseln)+3] = id[dof_RU];
lm[6*(l+nseln)+4] = id[dof_RV];
lm[6*(l+nseln)+5] = id[dof_RW];
}
K.build_add(lm);
}
}
}
}
//-----------------------------------------------------------------------------
//! Initialization. This function intializes the surfaces data
bool FEFacet2FacetTied::Init()
{
// create the surfaces
if (m_ss.Init() == false) return false;
if (m_ms.Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
//! Interface activation. Also projects primary surface onto secondary surface
void FEFacet2FacetTied::Activate()
{
// Don't forget to call base member!
FEContactInterface::Activate();
// project primary surface onto secondary surface
ProjectSurface(m_ss, m_ms);
if (m_gapoff)
{
// loop over all primary elements
for (int i = 0; i < m_ss.Elements(); ++i)
{
// get the primary element
FESurfaceElement& se = m_ss.Element(i);
// loop over all its integration points
int nint = se.GaussPoints();
for (int j = 0; j < nint; ++j)
{
// get integration point data
FEFacetTiedSurface::Data& pt = static_cast<FEFacetTiedSurface::Data&>(*se.GetMaterialPoint(j));
pt.m_vgap0 = pt.m_vgap;
pt.m_vgap = vec3d(0, 0, 0);
pt.m_gap = 0.0;
}
}
}
}
//-----------------------------------------------------------------------------
void FEFacet2FacetTied::ProjectSurface(FEFacetTiedSurface& ss, FEFacetTiedSurface& ms)
{
// get the mesh
FEMesh& mesh = *ss.GetMesh();
// closest point projection method
FEClosestPointProjection cpp(ms);
cpp.HandleSpecialCases(true);
cpp.SetTolerance(m_stol);
cpp.Init();
// let's count contact pairs
int contacts = 0;
// loop over all primary elements
for (int i=0; i<ss.Elements(); ++i)
{
// get the primary element
FESurfaceElement& se = ss.Element(i);
// get nodal coordinates
int nn = se.Nodes();
vec3d re[FEElement::MAX_NODES];
for (int j=0; j<nn; ++j) re[j] = mesh.Node(se.m_node[j]).m_rt;
// loop over all its integration points
int nint = se.GaussPoints();
for (int j=0; j<nint; ++j)
{
// get integration point data
FEFacetTiedSurface::Data& pt = static_cast<FEFacetTiedSurface::Data&>(*se.GetMaterialPoint(j));
// calculate the global coordinates of this integration point
vec3d x = se.eval(re, j);
// find the secondary element
vec3d q; vec2d rs;
FESurfaceElement* pme = cpp.Project(x, q, rs);
if (pme)
{
// store the secondary element
pt.m_pme = pme;
pt.m_rs[0] = rs[0];
pt.m_rs[1] = rs[1];
// calculate gap
pt.m_vgap = x - q;
pt.m_gap = pt.m_vgap.norm();
contacts++;
}
else pt.m_pme = nullptr;
}
}
// if we found no contact pairs, let's report this since this is probably not the user's intention
if (contacts == 0)
{
std::string name = GetName();
feLogWarning("No contact pairs found for tied interface \"%s\".\nThis contact interface may not have any effect.", name.c_str());
}
}
//-----------------------------------------------------------------------------
//! Update tied interface data. This function re-evaluates the gaps between
//! the primary node and their projections onto the secondary surface.
//!
void FEFacet2FacetTied::Update()
{
// get the mesh
FEMesh& mesh = *m_ss.GetMesh();
// loop over all primary elements
const int NE = m_ss.Elements();
for (int i=0; i<NE; ++i)
{
// next element
FESurfaceElement& se = m_ss.Element(i);
int nseln = se.Nodes();
// get the nodal coordinates
vec3d rs[FEElement::MAX_NODES];
for (int j=0; j<nseln; ++j) rs[j] = mesh.Node(se.m_node[j]).m_rt;
// loop over all integration points
const int nint = se.GaussPoints();
for (int n=0; n<nint; ++n)
{
// get integration point data
FEFacetTiedSurface::Data& pt = static_cast<FEFacetTiedSurface::Data&>(*se.GetMaterialPoint(n));
FESurfaceElement* pme = pt.m_pme;
if (pme)
{
FESurfaceElement& me = static_cast<FESurfaceElement&>(*pme);
// get the current primary nodal position
vec3d rn = se.eval(rs, n);
// get the natural coordinates of the primary projection
double r = pt.m_rs[0];
double s = pt.m_rs[1];
// get the secondary nodal coordinates
int nmeln = me.Nodes();
vec3d y[FEElement::MAX_NODES];
for (int l=0; l<nmeln; ++l) y[l] = mesh.Node( me.m_node[l] ).m_rt;
// calculate the primary node projection
vec3d q = me.eval(y, r, s);
// calculate the gap function
pt.m_vgap = (rn - q) - pt.m_vgap0;
pt.m_gap = pt.m_vgap.norm();
}
}
}
}
//-----------------------------------------------------------------------------
//! This function calculates the contact forces for a tied interface.
void FEFacet2FacetTied::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
vector<int> sLM, mLM, LM, en;
vector<double> fe;
// shape functions
double Hm[FEElement::MAX_NODES];
// get the mesh
FEMesh& mesh = *m_ss.GetMesh();
// loop over all elements
const int NE = m_ss.Elements();
for (int i=0; i<NE; ++i)
{
// get the next element
FESurfaceElement& se = m_ss.Element(i);
int nseln = se.Nodes();
// integration weights
double* w = se.GaussWeights();
// get the element's LM vector
m_ss.UnpackLM(se, sLM);
// loop over integration points
const int nint = se.GaussPoints();
for (int n=0; n<nint; ++n)
{
// get integration point data
FEFacetTiedSurface::Data& pt = static_cast<FEFacetTiedSurface::Data&>(*se.GetMaterialPoint(n));
// get the secondary element
FESurfaceElement* pme = pt.m_pme;
if (pme)
{
// get the secondary element
FESurfaceElement& me = *pme;
m_ms.UnpackLM(me, mLM);
int nmeln = me.Nodes();
// get primary contact force
vec3d tc = pt.m_Lm + pt.m_vgap*m_eps;
// calculate jacobian
// note that we are integrating over the reference surface
double detJ = m_ss.jac0(se, n);
// primary shape functions
double* Hs = se.H(n);
// secondary shape functions
double r = pt.m_rs[0];
double s = pt.m_rs[1];
me.shape_fnc(Hm, r, s);
// calculate degrees of freedom
int ndof = 3*(nseln + nmeln);
// calculate the force vector
fe.resize(ndof);
for (int k=0; k<nseln; ++k)
{
fe[3*k ] = -detJ*w[n]*tc.x*Hs[k];
fe[3*k+1] = -detJ*w[n]*tc.y*Hs[k];
fe[3*k+2] = -detJ*w[n]*tc.z*Hs[k];
}
for (int k=0; k<nmeln; ++k)
{
fe[3*(k+nseln) ] = detJ*w[n]*tc.x*Hm[k];
fe[3*(k+nseln)+1] = detJ*w[n]*tc.y*Hm[k];
fe[3*(k+nseln)+2] = detJ*w[n]*tc.z*Hm[k];
}
// build the LM vector
LM.resize(ndof);
for (int k=0; k<nseln; ++k)
{
LM[3*k ] = sLM[3*k ];
LM[3*k+1] = sLM[3*k+1];
LM[3*k+2] = sLM[3*k+2];
}
for (int k=0; k<nmeln; ++k)
{
LM[3*(k+nseln) ] = mLM[3*k ];
LM[3*(k+nseln)+1] = mLM[3*k+1];
LM[3*(k+nseln)+2] = mLM[3*k+2];
}
// build the en vector
en.resize(nseln+nmeln);
for (int k=0; k<nseln; ++k) en[k ] = se.m_node[k];
for (int k=0; k<nmeln; ++k) en[k+nseln] = me.m_node[k];
// assemble the global residual
R.Assemble(en, LM, fe);
}
}
}
}
//-----------------------------------------------------------------------------
//! Calculate the stiffness matrix contribution.
void FEFacet2FacetTied::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
vector<int> sLM, mLM, LM, en;
FEElementMatrix ke;
// shape functions
double Hm[FEElement::MAX_NODES];
// loop over all primary elements
const int NE = m_ss.Elements();
for (int i=0; i<NE; ++i)
{
// get the next element
FESurfaceElement& se = m_ss.Element(i);
int nseln = se.Nodes();
// get the element's LM vector
m_ss.UnpackLM(se, sLM);
// integration weights
double* w = se.GaussWeights();
// loop over all integration points
const int nint = se.GaussPoints();
for (int n=0; n<nint; ++n)
{
// get intgration point data
FEFacetTiedSurface::Data& pt = static_cast<FEFacetTiedSurface::Data&>(*se.GetMaterialPoint(n));
// get the secondary element
FESurfaceElement* pme = pt.m_pme;
if (pme)
{
// get the secondary element
FESurfaceElement& me = *pme;
int nmeln = me.Nodes();
m_ms.UnpackLM(me, mLM);
// calculate jacobian
double detJ = m_ss.jac0(se, n);
// primary shape functions
double* Hs = se.H(n);
// secondary shape functions
double r = pt.m_rs[0];
double s = pt.m_rs[1];
me.shape_fnc(Hm, r, s);
// calculate degrees of freedom
int ndof = 3*(nseln + nmeln);
// create the stiffness matrix
ke.resize(ndof, ndof);
ke.zero();
for (int k=0; k<nseln; ++k)
{
for (int l=0; l<nseln; ++l)
{
ke[3*k ][3*l ] = Hs[k]*Hs[l];
ke[3*k+1][3*l+1] = Hs[k]*Hs[l];
ke[3*k+2][3*l+2] = Hs[k]*Hs[l];
}
}
for (int k=0; k<nseln; ++k)
{
for (int l=0; l<nmeln; ++l)
{
ke[3*k ][3*(l+nseln) ] = -Hs[k]*Hm[l];
ke[3*k+1][3*(l+nseln)+1] = -Hs[k]*Hm[l];
ke[3*k+2][3*(l+nseln)+2] = -Hs[k]*Hm[l];
ke[3*(l+nseln) ][3*k ] = -Hs[k]*Hm[l];
ke[3*(l+nseln)+1][3*k+1] = -Hs[k]*Hm[l];
ke[3*(l+nseln)+2][3*k+2] = -Hs[k]*Hm[l];
}
}
for (int k=0; k<nmeln; ++k)
for (int l=0; l<nmeln; ++l)
{
ke[3*(k+nseln) ][3*(l+nseln) ] = Hm[k]*Hm[l];
ke[3*(k+nseln)+1][3*(l+nseln)+1] = Hm[k]*Hm[l];
ke[3*(k+nseln)+2][3*(l+nseln)+2] = Hm[k]*Hm[l];
}
for (int k=0; k<ndof; ++k)
for (int l=0; l<ndof; ++l) ke[k][l] *= m_eps*detJ*w[n];
// build the LM vector
LM.resize(ndof);
for (int k=0; k<nseln; ++k)
{
LM[3*k ] = sLM[3*k ];
LM[3*k+1] = sLM[3*k+1];
LM[3*k+2] = sLM[3*k+2];
}
for (int k=0; k<nmeln; ++k)
{
LM[3*(k+nseln) ] = mLM[3*k ];
LM[3*(k+nseln)+1] = mLM[3*k+1];
LM[3*(k+nseln)+2] = mLM[3*k+2];
}
// build the en vector
en.resize(nseln+nmeln);
for (int k=0; k<nseln; ++k) en[k ] = se.m_node[k];
for (int k=0; k<nmeln; ++k) en[k+nseln] = me.m_node[k];
// assemble the global residual
ke.SetNodes(en);
ke.SetIndices(LM);
LS.Assemble(ke);
}
}
}
}
//-----------------------------------------------------------------------------
//! Do an augmentation.
bool FEFacet2FacetTied::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (m_laugon != FECore::AUGLAG_METHOD) return true;
// calculate initial norms
double normL0 = 0;
for (int i=0; i<m_ss.Elements(); ++i)
{
FESurfaceElement& se = m_ss.Element(i);
for (int j=0; j<se.GaussPoints(); ++j)
{
FEFacetTiedSurface::Data& pt = static_cast<FEFacetTiedSurface::Data&>(*se.GetMaterialPoint(j));
vec3d& lm = pt.m_Lm;
normL0 += lm*lm;
}
}
normL0 = sqrt(normL0);
// update Lagrange multipliers and calculate current norms
double normL1 = 0;
double normgc = 0;
int N = 0;
for (int i=0; i<m_ss.Elements(); ++i)
{
FESurfaceElement& se = m_ss.Element(i);
for (int j=0; j<se.GaussPoints(); ++j)
{
FEFacetTiedSurface::Data& pt = static_cast<FEFacetTiedSurface::Data&>(*se.GetMaterialPoint(j));
vec3d lm = pt.m_Lm + pt.m_vgap*m_eps;
normL1 += lm*lm;
if (pt.m_pme != 0)
{
double g = pt.m_vgap.norm();
normgc += g*g;
++N;
}
}
}
if (N == 0) N=1;
normL1 = sqrt(normL1);
normgc = sqrt(normgc / N);
// check convergence of constraints
feLog(" tied interface # %d\n", GetID());
feLog(" CURRENT REQUIRED\n");
double pctn = 0;
if (fabs(normL1) > 1e-10) pctn = fabs((normL1 - normL0)/normL1);
feLog(" normal force : %15le %15le\n", pctn, m_atol);
feLog(" gap function : %15le ***\n", normgc);
// check convergence
bool bconv = true;
if (pctn >= m_atol) bconv = false;
if (naug < m_naugmin ) bconv = false;
if (naug >= m_naugmax) bconv = true;
if (bconv == false)
{
for (int i=0; i<m_ss.Elements(); ++i)
{
FESurfaceElement& se = m_ss.Element(i);
for (int j=0; j<se.GaussPoints(); ++j)
{
FEFacetTiedSurface::Data& pt = static_cast<FEFacetTiedSurface::Data&>(*se.GetMaterialPoint(j));
// update Lagrange multipliers
pt.m_Lm = pt.m_Lm + pt.m_vgap*m_eps;
}
}
}
return bconv;
}
//-----------------------------------------------------------------------------
//! Serialize the data to the archive.
void FEFacet2FacetTied::Serialize(DumpStream &ar)
{
// store contact data
FEContactInterface::Serialize(ar);
// store contact surface data
m_ss.Serialize(ar);
m_ms.Serialize(ar);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEDamageMaterialPoint.h | .h | 2,213 | 59 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEReactiveMaterialPoint.h"
#include "febiomech_api.h"
#ifdef WIN32
#define max(a,b) ((a)>(b)?(a):(b))
#endif
//-----------------------------------------------------------------------------
// Define a material point that stores the damage variable.
class FEBIOMECH_API FEDamageMaterialPoint : public FEReactiveMaterialPoint
{
public:
FEDamageMaterialPoint(FEMaterialPointData*pt) : FEReactiveMaterialPoint(pt) {}
FEMaterialPointData* Copy() override;
void Init() override;
void Update(const FETimeInfo& timeInfo) override;
void Serialize(DumpStream& ar) override;
double BrokenBonds() const override { return m_D; }
double IntactBonds() const override { return 1 - m_D; }
public:
double m_Etrial; //!< trial damage criterion at time t
double m_Emax; //!< max damage criterion up to time t
double m_D; //!< damage (0 = no damage, 1 = complete damage)
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEElasticFiberMaterial.h | .h | 4,317 | 111 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
//-----------------------------------------------------------------------------
//! Base class for single fiber response
class FEElasticFiberMaterial : public FEElasticMaterial
{
public:
FEElasticFiberMaterial(FEModel* pfem);
FEMaterialPointData* CreateMaterialPointData() override;
// get the fiber vector (in global coordinates)
vec3d FiberVector(FEMaterialPoint& mp);
// calculate stress in fiber direction a0
virtual mat3ds FiberStress(FEMaterialPoint& mp, const vec3d& a0) = 0;
// Spatial tangent
virtual tens4ds FiberTangent(FEMaterialPoint& mp, const vec3d& a0) = 0;
//! Strain energy density
virtual double FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) = 0;
// Set or clear pre-stretch, as needed in multigenerational materials (e.g., reactive viscoelasticity)
void SetPreStretch(const mat3ds Us) { m_Us = Us; m_bUs = true; }
void ResetPreStretch() { m_bUs = false; }
vec3d FiberPreStretch(const vec3d a0);
private:
// These are made private since fiber materials should implement the functions above instead.
// The functions can still be reached when a fiber material is used in an elastic mixture.
// In those cases the fiber vector is taken from the first column of Q.
mat3ds Stress(FEMaterialPoint& mp) final { return FiberStress(mp, FiberVector(mp)); }
tens4ds Tangent(FEMaterialPoint& mp) final { return FiberTangent(mp, FiberVector(mp)); }
double StrainEnergyDensity(FEMaterialPoint& mp) final { return FiberStrainEnergyDensity(mp, FiberVector(mp)); }
private:
mat3ds m_Us; //!< pre-stretch tensor for fiber
bool m_bUs; //!< flag for pre-stretch
public:
FEVec3dValuator* m_fiber; //!< fiber orientation
DECLARE_FECORE_CLASS();
};
// helper class for constructing elastic fiber materials from classes derived from FEFiberMaterial.
template <class fiberMat>
class FEElasticFiberMaterial_T : public FEElasticFiberMaterial
{
public:
FEElasticFiberMaterial_T(FEModel* fem) : FEElasticFiberMaterial(fem), m_fib(fem) {}
bool Init() override
{
if (FEElasticFiberMaterial::Init() == false) return false;
return m_fib.Init();
}
bool Validate() override
{
if (FEElasticFiberMaterial::Validate() == false) return false;
return m_fib.Validate();
}
FEMaterialPointData* CreateMaterialPointData() override
{
return new FEElasticMaterialPoint(m_fib.CreateMaterialPointData());
}
void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override
{
FEElasticFiberMaterial::UpdateSpecializedMaterialPoints(mp, tp);
m_fib.UpdateSpecializedMaterialPoints(mp, tp);
}
mat3ds FiberStress(FEMaterialPoint& mp, const vec3d& a0) override { return m_fib.FiberStress(mp, a0); }
tens4ds FiberTangent(FEMaterialPoint& mp, const vec3d& a0) override { return m_fib.FiberTangent(mp, a0); }
double FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) override { return m_fib.FiberStrainEnergyDensity(mp, a0); }
protected:
fiberMat m_fib;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEPipetteAspiration.cpp | .cpp | 7,235 | 192 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEPipetteAspiration.h"
#include "FEBioMech.h"
#include <FECore/FEFacetSet.h>
#include <FECore/FEModel.h>
#include <FECore/log.h>
#include "FEContactInterface.h"
#include "FESlidingElasticInterface.h"
//-----------------------------------------------------------------------------
// Parameter block for pressure loads
BEGIN_FECORE_CLASS(FEPipetteAspiration, FESurfaceLoad)
ADD_PARAMETER(m_pressure, "pressure")->setUnits(UNIT_PRESSURE)->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE);
ADD_PARAMETER(m_radius, "radius")->setUnits(UNIT_LENGTH)->setLongName("Pipette radius");
ADD_PARAMETER(m_center, "center")->setUnits(UNIT_LENGTH)->setLongName("Pipette center");
ADD_PARAMETER(m_normal, "normal")->setLongName("Pipette normal");
END_FECORE_CLASS()
//-----------------------------------------------------------------------------
//! constructor
FEPipetteAspiration::FEPipetteAspiration(FEModel* pfem) : FESurfaceLoad(pfem)
{
m_pressure = 0.0;
m_radius = 0.0;
m_center = vec3d(0,0,0);
m_normal = vec3d(0,0,1);
m_contact = -1;
}
//-----------------------------------------------------------------------------
bool FEPipetteAspiration::Init()
{
FESurface& surf = GetSurface();
// check if this surface is a contact surface (primary)
FEModel& fem = *GetFEModel();
if (fem.SurfacePairConstraints() > 0)
{
// loop over all contact interfaces
for (int i = 0; i<fem.SurfacePairConstraints(); ++i)
{
FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i));
FESlidingElasticInterface* pbw = dynamic_cast<FESlidingElasticInterface*>(pci);
if (pbw) {
FESurface& ps = *pci->GetPrimarySurface();
// for now, use quick and dirty way to figure out if these surfaces are the same
if (ps.Elements() == surf.Elements()) {
m_contact = i;
surf = ps;
break;
}
}
}
}
else if (m_contact == -1) {
feLogWarning("Pipette surface does not match any contact surface!");
return false;
}
// get the degrees of freedom
m_dof.Clear();
if (surf.IsShellBottom() == false)
{
m_dof.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
}
else
{
m_dof.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_DISPLACEMENT));
}
if (m_dof.IsEmpty()) return false;
return FESurfaceLoad::Init();
}
//-----------------------------------------------------------------------------
void FEPipetteAspiration::PrepStep()
{
FEModel& fem = *GetFEModel();
FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(m_contact));
double psf = pci->GetPenaltyScaleFactor();
FESlidingElasticInterface* sei = dynamic_cast<FESlidingElasticInterface*>(pci);
FESurface& surf = *pci->GetPrimarySurface();
m_tag.assign(surf.Elements(), std::vector<bool>(FEElement::MAX_INTPOINTS,false));
// loop over all faces of the surface
for (int i=0; i<surf.Elements(); ++i) {
FESurfaceElement& el = surf.Element(i);
// loop over all integration points of the surface
for (int j=0; j<el.GaussPoints(); ++j) {
FEMaterialPoint& pt = *el.GetMaterialPoint(j);
// get the sliding elastic interface data at this material point
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(pt);
// penalty
double eps = sei->m_epsn*data.m_epsn*psf;
// normal gap
double g = data.m_gap;
// normal traction Lagrange multiplier
double Lm = data.m_Lmd;
double pn = sei->m_btension ? (Lm + eps*g) : MBRACKET(Lm + eps*g);
vec3d dx = pt.m_rt - m_center;
double r = (dx - m_normal*(dx*m_normal)).Length();
if ((r <= m_radius) && (pn == 0))
m_tag[i][j] = true;
}
}
}
//-----------------------------------------------------------------------------
void FEPipetteAspiration::LoadVector(FEGlobalVector& R)
{
FEModel& fem = *GetFEModel();
FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(m_contact));
FESurface& surf = *pci->GetPrimarySurface();
surf.LoadVector(R, m_dof, false, [&](FESurfaceMaterialPoint& pt, const FESurfaceDofShape& dof_a, std::vector<double>& val) {
FESurfaceElement& sel = *pt.SurfaceElement();
// evaluate pressure at this material point
double P = (m_tag[sel.m_lid][pt.m_index]) ? -m_pressure(pt) : 0;
if (surf.IsShellBottom()) P = -P;
double J = (pt.dxr ^ pt.dxs).norm();
// force vector
vec3d N = (pt.dxr ^ pt.dxs); N.unit();
vec3d t = N*P;
double H_u = dof_a.shape;
val[0] = H_u*t.x*J;
val[1] = H_u*t.y*J;
val[2] = H_u*t.z*J;
});
}
//-----------------------------------------------------------------------------
void FEPipetteAspiration::StiffnessMatrix(FELinearSystem& LS)
{
FEModel& fem = *GetFEModel();
FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(m_contact));
FESurface& surf = *pci->GetPrimarySurface();
surf.LoadStiffness(LS, m_dof, m_dof, [&](FESurfaceMaterialPoint& mp, const FESurfaceDofShape& dof_a, const FESurfaceDofShape& dof_b, matrix& kab) {
FESurfaceElement& sel = *mp.SurfaceElement();
// evaluate pressure at this material point
double P = (m_tag[sel.m_lid][mp.m_index]) ? -m_pressure(mp) : 0;
if (surf.IsShellBottom()) P = -P;
double H_i = dof_a.shape;
double Gr_i = dof_a.shape_deriv_r;
double Gs_i = dof_a.shape_deriv_s;
double H_j = dof_b.shape;
double Gr_j = dof_b.shape_deriv_r;
double Gs_j = dof_b.shape_deriv_s;
vec3d vab(0,0,0);
vab = (mp.dxs*Gr_j - mp.dxr*Gs_j)*(P*H_i);
mat3da K(vab);
kab.set(0, 0, K);
});
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEScaledUncoupledMaterial.h | .h | 2,269 | 58 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
#include <FECore/FEFunction1D.h>
//-----------------------------------------------------------------------------
//! This class implements a scaled elastic material with user-specified scale
//
class FEScaledUncoupledMaterial : public FEUncoupledMaterial
{
public:
//! default constructor
FEScaledUncoupledMaterial(FEModel* pfem) : m_pBase(nullptr), FEUncoupledMaterial(pfem) {}
public:
//! stress function
mat3ds DevStress(FEMaterialPoint& pt) override;
//! tangent function
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! strain energy density function
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
FEMaterialPointData* CreateMaterialPointData() override;
DECLARE_FECORE_CLASS();
private:
FEUncoupledMaterial* m_pBase; //!< pointer to elastic solid material to scale
FEParamDouble m_scale; //!< scale factor
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEDiscreteElementMaterial.h | .h | 2,708 | 67 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEDiscreteElasticMaterial.h"
#include <FECore/FEFunction1D.h>
class FEDiscreteContractileMaterial : public FEDiscreteElasticMaterial
{
public:
FEDiscreteContractileMaterial(FEModel* fem);
// evaluate the force at a discrete element
vec3d Force(FEDiscreteMaterialPoint& mp) override;
// evaluate the stiffness at a discrete element (= dF / dr)
mat3d Stiffness(FEDiscreteMaterialPoint& mp) override;
private:
double force(FEDiscreteMaterialPoint& mp);
double force_deriv_L(FEDiscreteMaterialPoint& mp);
double force_deriv_V(FEDiscreteMaterialPoint& mp);
double passive_force(double L, double V);
double active_force(double L, double V);
double passive_force_deriv_L(double L, double V);
double passive_force_deriv_V(double L, double V);
double active_force_deriv_L(double L, double V);
double active_force_deriv_V(double L, double V);
private:
double m_Vmax; // maximum shortening velocity
double m_ac; // activation level
double m_Fmax; // max force
double m_Ksh; // shape parameter that determines the rise of exponential in passive element
double m_Lmax; // relative length at which Fmax occurs
double m_L0; // initial reference length
FEFunction1D* m_Sv; // max velocity scale
FEFunction1D* m_Ftl; // normalized tension-length curve for active element
FEFunction1D* m_Ftv; // normalized tension-velocity curve for active element
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEElasticDomain.h | .h | 2,984 | 77 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "febiomech_api.h"
#include <vector>
//-----------------------------------------------------------------------------
class FEModel;
class FEGlobalVector;
class FEBodyForce;
class FESolver;
class FELinearSystem;
//-----------------------------------------------------------------------------
//! Abstract interface class for elastic domains.
//! An elastic domain is used by the structural mechanics solver.
//! This interface defines the functions that have to be implemented by an
//! elastic domain. There are basically two categories: residual functions
//! that contribute to the global residual vector. And stiffness matrix
//! function that calculate contributions to the global stiffness matrix.
class FEBIOMECH_API FEElasticDomain
{
public:
FEElasticDomain(FEModel* pfem);
virtual ~FEElasticDomain(){}
// --- R E S I D U A L ---
//! calculate the internal forces
virtual void InternalForces(FEGlobalVector& R) = 0;
//! Calculate the body force vector
virtual void BodyForce(FEGlobalVector& R, FEBodyForce& bf) = 0;
//! calculate the interial forces (for dynamic problems)
virtual void InertialForces(FEGlobalVector& R, std::vector<double>& F) = 0;
// --- S T I F F N E S S M A T R I X ---
//! Calculate global stiffness matrix (only contribution from internal force derivative)
//! \todo maybe I should rename this the InternalStiffness matrix?
virtual void StiffnessMatrix (FELinearSystem& LS) = 0;
//! Calculate stiffness contribution of body forces
virtual void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) = 0;
//! calculate the mass matrix (for dynamic problems)
virtual void MassMatrix(FELinearSystem& LS, double scale) = 0;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEVerondaWestmann.h | .h | 2,102 | 57 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
//-----------------------------------------------------------------------------
//! Veronda-Westmann material model
class FEVerondaWestmann : public FEUncoupledMaterial
{
public:
FEVerondaWestmann(FEModel* pfem) : FEUncoupledMaterial(pfem) {}
public:
FEParamDouble m_c1; //!< Veronda-Westmann coefficient C1;
FEParamDouble m_c2; //!< Veronda-Westmann coefficient C2;
public:
//! calculate deviatoric stress at material point
mat3ds DevStress(FEMaterialPoint& pt) override;
//! calculate deviatoric tangent stiffness at material point
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEPreStrainConstraint.h | .h | 3,201 | 86 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FENLConstraint.h>
#include <FECore/FESolidDomain.h>
#include "FEPreStrainElastic.h"
#include "FEPreStrainUncoupledElastic.h"
//-----------------------------------------------------------------------------
class FEPreStrainConstraint : public FENLConstraint
{
public:
FEPreStrainConstraint(FEModel* pfem);
// This function must be overloaded by derived classes
virtual mat3d UpdateFc(const mat3d& F, const mat3d& Fc_prev, FEMaterialPoint& mp, FEPrestrainMaterial* pmat) = 0;
public:
bool Augment(int naug, const FETimeInfo& tp) override;
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override {};
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override {};
virtual void Update(const FETimeInfo& tp) {}
void BuildMatrixProfile(FEGlobalMatrix& M) override {}
private:
bool Augment(FEDomain* pdom, int n, int naug);
public:
bool m_laugon; //!< augmented Lagrangian flag
double m_tol; //!< convergence tolerance
int m_naugmin; //!< minimum number of iterations
int m_naugmax; //!< maximum number of iterations
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// Implements a constraint that essentially eliminates the distortion
class FEGPAConstraint : public FEPreStrainConstraint
{
public:
FEGPAConstraint(FEModel* pfem) : FEPreStrainConstraint(pfem){}
mat3d UpdateFc(const mat3d& F, const mat3d& Fc_prev, FEMaterialPoint& mp, FEPrestrainMaterial* pmat) override;
};
//-----------------------------------------------------------------------------
// enforces just the fiber stretch
class FEInSituStretchConstraint: public FEPreStrainConstraint
{
public:
FEInSituStretchConstraint(FEModel* pfem);
mat3d UpdateFc(const mat3d& F, const mat3d& Fc_prev, FEMaterialPoint& mp, FEPrestrainMaterial* pmat) override;
private:
double m_max_stretch;
bool m_biso;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEElasticTrussDomain.h | .h | 3,590 | 115 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FETrussDomain.h>
#include "FEElasticDomain.h"
#include "FESolidMaterial.h"
#include <FECore/FEDofList.h>
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
//! Domain described by 3D truss elements
class FEBIOMECH_API FEElasticTrussDomain : public FETrussDomain, public FEElasticDomain
{
public:
//! Constructor
FEElasticTrussDomain(FEModel* pfem);
//! copy operator
FEElasticTrussDomain& operator = (FEElasticTrussDomain& d);
//! initialize the domain
bool Init() override;
//! Reset data
void Reset() override;
//! Initialize elements
void PreSolveUpdate(const FETimeInfo& timeInfo) override;
//! Unpack truss element data
void UnpackLM(FEElement& el, vector<int>& lm) override;
//! get the material
FEMaterial* GetMaterial() override { return m_pMat; }
//! set the material
void SetMaterial(FEMaterial* pmat) override;
//! Activate domain
void Activate() override;
//! get the dof list
const FEDofList& GetDOFList() const override;
double detJt(FETrussElement& el) const;
public: // overloads from FEElasticDomain
//! update the truss stresses
void Update(const FETimeInfo& tp) override;
//! internal stress forces
void InternalForces(FEGlobalVector& R) override;
//! calculate body force
void BodyForce(FEGlobalVector& R, FEBodyForce& bf) override;
//! Calculates inertial forces for dynamic problems
void InertialForces(FEGlobalVector& R, vector<double>& F) override { assert(false); }
//! calculates the global stiffness matrix for this domain
void StiffnessMatrix(FELinearSystem& LS) override;
//! intertial stiffness matrix
void MassMatrix(FELinearSystem& LS, double scale) override;
//! body force stiffness matrix \todo implement this
void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override { assert(false); }
//! elemental mass matrix
void ElementMassMatrix(FETrussElement& el, matrix& ke);
protected:
//! calculates the truss element stiffness matrix
void ElementStiffness(int iel, matrix& ke);
//! Calculates the internal stress vector for solid elements
void ElementInternalForces(FETrussElement& el, vector<double>& fe);
protected:
FESolidMaterial* m_pMat;
double m_a0;
double m_v;
FEDofList m_dofU;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEElasticShellDomain.cpp | .cpp | 29,688 | 949 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include <limits>
#include "FEElasticShellDomain.h"
#include "FEElasticMaterial.h"
#include "FEBodyForce.h"
#include <FECore/log.h>
#include <FECore/FEModel.h>
#include <FECore/FEAnalysis.h>
#include <math.h>
#include <FECore/FESolidDomain.h>
#include <FECore/FELinearSystem.h>
#include "FEBioMech.h"
BEGIN_FECORE_CLASS(FEElasticShellDomain, FESSIShellDomain)
ADD_PARAMETER(m_secant_stress, "secant_stress");
ADD_PARAMETER(m_secant_tangent, "secant_tangent");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEElasticShellDomain::FEElasticShellDomain(FEModel* pfem) : FESSIShellDomain(pfem), FEElasticDomain(pfem), m_dofV(pfem), m_dofSV(pfem), m_dofSA(pfem), m_dofR(pfem), m_dof(pfem)
{
m_pMat = 0;
m_alphaf = m_beta = 1;
m_alpham = 2;
m_update_dynamic = true; // default for backward compatibility
m_secant_stress = false;
m_secant_tangent = false;
// TODO: Can this be done in Init, since there is no error checking
if (pfem)
{
m_dofV.AddVariable(FEBioMech::GetVariableName(FEBioMech::VELOCITY));
m_dofSV.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_VELOCITY));
m_dofSA.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_ACCELERATION));
m_dofR.AddVariable(FEBioMech::GetVariableName(FEBioMech::RIGID_ROTATION));
}
}
//-----------------------------------------------------------------------------
FEElasticShellDomain& FEElasticShellDomain::operator = (FEElasticShellDomain& d)
{
m_Elem = d.m_Elem;
m_pMesh = d.m_pMesh;
return (*this);
}
//-----------------------------------------------------------------------------
//! Set flag for update for dynamic quantities
void FEElasticShellDomain::SetDynamicUpdateFlag(bool b)
{
m_update_dynamic = b;
}
//-----------------------------------------------------------------------------
//! serialization
void FEElasticShellDomain::Serialize(DumpStream& ar)
{
//erialize the base class, which instantiates the elements
FESSIShellDomain::Serialize(ar);
if (ar.IsShallow()) return;
// serialize class variables
ar & m_alphaf;
ar & m_alpham;
ar & m_beta;
ar & m_update_dynamic;
}
//-----------------------------------------------------------------------------
void FEElasticShellDomain::SetMaterial(FEMaterial* pmat)
{
FEDomain::SetMaterial(pmat);
m_pMat = dynamic_cast<FESolidMaterial*>(pmat);
}
//-----------------------------------------------------------------------------
//! get the total dofs
const FEDofList& FEElasticShellDomain::GetDOFList() const
{
return m_dof;
}
//-----------------------------------------------------------------------------
void FEElasticShellDomain::Activate()
{
for (int i=0; i<Nodes(); ++i)
{
FENode& node = Node(i);
if (node.HasFlags(FENode::EXCLUDE) == false)
{
if (node.m_rid < 0)
{
node.set_active(m_dofU[0]);
node.set_active(m_dofU[1]);
node.set_active(m_dofU[2]);
if (node.HasFlags(FENode::SHELL))
{
node.set_active(m_dofSU[0]);
node.set_active(m_dofSU[1]);
node.set_active(m_dofSU[2]);
}
}
}
}
}
//-----------------------------------------------------------------------------
//! Initialize element data
void FEElasticShellDomain::PreSolveUpdate(const FETimeInfo& timeInfo)
{
m_alphaf = timeInfo.alphaf;
m_alpham = timeInfo.alpham;
m_beta = timeInfo.beta;
vec3d r0, rt;
for (size_t i=0; i<m_Elem.size(); ++i)
{
FEShellElement& el = m_Elem[i];
if (el.isActive())
{
int n = el.GaussPoints();
for (int j = 0; j < n; ++j)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(j);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
pt.m_Wp = pt.m_Wt;
mp.Update(timeInfo);
}
}
}
}
//-----------------------------------------------------------------------------
// Calculates the forces due to the stress
void FEElasticShellDomain::InternalForces(FEGlobalVector& R)
{
int NS = (int)m_Elem.size();
#pragma omp parallel for shared (NS)
for (int i=0; i<NS; ++i)
{
// element force vector
vector<double> fe;
vector<int> lm;
// get the element
FEShellElement& el = m_Elem[i];
if (el.isActive())
{
// create the element force vector and initialize to zero
int ndof = 6 * el.Nodes();
fe.assign(ndof, 0);
// calculate element's internal force
ElementInternalForce(el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble the residual
R.Assemble(el.m_node, lm, fe, true);
}
}
}
//-----------------------------------------------------------------------------
//! calculates the internal equivalent nodal forces for shell elements
//! Note that we use a one-point gauss integration rule for the thickness
//! integration. This will integrate linear functions exactly.
void FEElasticShellDomain::ElementInternalForce(FEShellElement& el, vector<double>& fe)
{
int nint = el.GaussPoints();
int neln = el.Nodes();
// repeat for all integration points
double* gw = el.GaussWeights();
for (int n=0; n<nint; ++n)
{
FEElasticMaterialPoint& pt = *(el.GetMaterialPoint(n)->ExtractData<FEElasticMaterialPoint>());
// calculate the jacobian
double detJt = (m_alphaf == 1.0 ? detJ(el, n) : detJ(el, n, m_alphaf))*gw[n];
// get base vectors
vec3d gcnt[3];
if (m_alphaf == 1.0)
ContraBaseVectors(el, n, gcnt);
else
ContraBaseVectors(el, n, gcnt, m_alphaf);
// get the stress vector for this integration point
mat3ds& s = pt.m_s;
double eta = el.gt(n);
const double* Mr = el.Hr(n);
const double* Ms = el.Hs(n);
const double* M = el.H(n);
for (int i=0; i<neln; ++i)
{
vec3d gradM = gcnt[0]*Mr[i] + gcnt[1]*Ms[i];
vec3d gradMu = (gradM*(1+eta) + gcnt[2]*M[i])/2;
vec3d gradMd = (gradM*(1-eta) - gcnt[2]*M[i])/2;
vec3d fu = s*gradMu;
vec3d fd = s*gradMd;
// calculate internal force
// the '-' sign is so that the internal forces get subtracted
// from the global residual vector
fe[6*i ] -= fu.x*detJt;
fe[6*i+1] -= fu.y*detJt;
fe[6*i+2] -= fu.z*detJt;
fe[6*i+3] -= fd.x*detJt;
fe[6*i+4] -= fd.y*detJt;
fe[6*i+5] -= fd.z*detJt;
}
}
}
//-----------------------------------------------------------------------------
void FEElasticShellDomain::BodyForce(FEGlobalVector& R, FEBodyForce& BF)
{
int NS = (int)m_Elem.size();
#pragma omp parallel for
for (int i=0; i<NS; ++i)
{
// element force vector
vector<double> fe;
vector<int> lm;
// get the element
FEShellElement& el = m_Elem[i];
if (el.isActive())
{
// create the element force vector and initialize to zero
int ndof = 6 * el.Nodes();
fe.assign(ndof, 0);
// apply body forces to shells
ElementBodyForce(BF, el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble the residual
R.Assemble(el.m_node, lm, fe, true);
}
}
}
//-----------------------------------------------------------------------------
//! Calculates element body forces for shells
void FEElasticShellDomain::ElementBodyForce(FEBodyForce& BF, FEShellElement& el, vector<double>& fe)
{
// integration weights
double* gw = el.GaussWeights();
double eta;
double *M, detJt;
// loop over integration points
int nint = el.GaussPoints();
int neln = el.Nodes();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
double dens = m_pMat->Density(mp);
// calculate the jacobian
detJt = detJ0(el, n)*gw[n];
M = el.H(n);
eta = el.gt(n);
// get the force
vec3d f = BF.force(mp);
for (int i=0; i<neln; ++i)
{
vec3d fu = f*(dens*M[i]*(1+eta)/2*detJt);
vec3d fd = f*(dens*M[i]*(1-eta)/2*detJt);
fe[6*i ] -= fu.x;
fe[6*i+1] -= fu.y;
fe[6*i+2] -= fu.z;
fe[6*i+3] -= fd.x;
fe[6*i+4] -= fd.y;
fe[6*i+5] -= fd.z;
}
}
}
//-----------------------------------------------------------------------------
// Calculate inertial forces \todo Why is F no longer needed?
void FEElasticShellDomain::InertialForces(FEGlobalVector& R, vector<double>& F)
{
int NE = (int)m_Elem.size();
#pragma omp parallel for shared (NE)
for (int i=0; i<NE; ++i)
{
// element force vector
vector<double> fe;
vector<int> lm;
// get the element
FEShellElement& el = m_Elem[i];
if (el.isActive())
{
// get the element force vector and initialize it to zero
int ndof = 6 * el.Nodes();
fe.assign(ndof, 0);
// calculate internal force vector
ElementInertialForce(el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble element 'fe'-vector into global R vector
R.Assemble(el.m_node, lm, fe, true);
}
}
}
//-----------------------------------------------------------------------------
void FEElasticShellDomain::ElementInertialForce(FEShellElement& el, vector<double>& fe)
{
int nint = el.GaussPoints();
int neln = el.Nodes();
// evaluate the element inertial force vector
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
double dens = m_pMat->Density(mp);
double J0 = detJ0(el, n)*el.GaussWeights()[n];
double* M = el.H(n);
double eta = el.gt(n);
for (int i=0; i<neln; ++i)
{
vec3d fu = pt.m_a*(dens*M[i]*(1+eta)/2*J0);
vec3d fd = pt.m_a*(dens*M[i]*(1-eta)/2*J0);
fe[6*i ] -= fu.x;
fe[6*i+1] -= fu.y;
fe[6*i+2] -= fu.z;
fe[6*i+3] -= fd.x;
fe[6*i+4] -= fd.y;
fe[6*i+5] -= fd.z;
}
}
}
//-----------------------------------------------------------------------------
//! This function calculates the stiffness due to body forces
void FEElasticShellDomain::ElementBodyForceStiffness(FEBodyForce& BF, FEShellElement &el, matrix &ke)
{
int i, j, i6, j6;
int neln = el.Nodes();
// jacobian
double detJ;
double *M;
double* gw = el.GaussWeights();
mat3d K;
double Mu[FEElement::MAX_NODES], Md[FEElement::MAX_NODES];
// loop over integration points
int nint = el.GaussPoints();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
detJ = detJ0(el, n)*gw[n]*m_alphaf;
// get the stiffness
K = BF.stiffness(mp)*m_pMat->Density(mp)*detJ;
M = el.H(n);
double eta = el.gt(n);
for (i=0; i<neln; ++i)
{
Mu[i] = M[i]*(1+eta)/2;
Md[i] = M[i]*(1-eta)/2;
}
for (i=0, i6=0; i<neln; ++i, i6 += 6)
{
for (j=0, j6 = 0; j<neln; ++j, j6 += 6)
{
mat3d Kuu = K*(Mu[i]*Mu[j]);
mat3d Kud = K*(Mu[i]*Md[j]);
mat3d Kdu = K*(Md[i]*Mu[j]);
mat3d Kdd = K*(Md[i]*Md[j]);
ke[i6 ][j6 ] += Kuu(0,0); ke[i6 ][j6+1] += Kuu(0,1); ke[i6 ][j6+2] += Kuu(0,2);
ke[i6+1][j6 ] += Kuu(1,0); ke[i6+1][j6+1] += Kuu(1,1); ke[i6+1][j6+2] += Kuu(1,2);
ke[i6+2][j6 ] += Kuu(2,0); ke[i6+2][j6+1] += Kuu(2,1); ke[i6+2][j6+2] += Kuu(2,2);
ke[i6 ][j6+3] += Kud(0,0); ke[i6 ][j6+4] += Kud(0,1); ke[i6 ][j6+5] += Kud(0,2);
ke[i6+1][j6+3] += Kud(1,0); ke[i6+1][j6+4] += Kud(1,1); ke[i6+1][j6+5] += Kud(1,2);
ke[i6+2][j6+3] += Kud(2,0); ke[i6+2][j6+4] += Kud(2,1); ke[i6+2][j6+5] += Kud(2,2);
ke[i6+3][j6 ] += Kdu(0,0); ke[i6+3][j6+1] += Kdu(0,1); ke[i6+3][j6+2] += Kdu(0,2);
ke[i6+4][j6 ] += Kdu(1,0); ke[i6+4][j6+1] += Kdu(1,1); ke[i6+4][j6+2] += Kdu(1,2);
ke[i6+5][j6 ] += Kdu(2,0); ke[i6+5][j6+1] += Kdu(2,1); ke[i6+5][j6+2] += Kdu(2,2);
ke[i6+3][j6+3] += Kdd(0,0); ke[i6+3][j6+4] += Kdd(0,1); ke[i6+3][j6+5] += Kdd(0,2);
ke[i6+4][j6+3] += Kdd(1,0); ke[i6+4][j6+4] += Kdd(1,1); ke[i6+4][j6+5] += Kdd(1,2);
ke[i6+5][j6+3] += Kdd(2,0); ke[i6+5][j6+4] += Kdd(2,1); ke[i6+5][j6+5] += Kdd(2,2);
}
}
}
}
//-----------------------------------------------------------------------------
void FEElasticShellDomain::StiffnessMatrix(FELinearSystem& LS)
{
// repeat over all shell elements
int NS = (int)m_Elem.size();
#pragma omp parallel for shared (NS)
for (int iel=0; iel<NS; ++iel)
{
FEShellElement& el = m_Elem[iel];
if (el.isActive())
{
// create the element's stiffness matrix
FEElementMatrix ke(el);
int ndof = 6 * el.Nodes();
ke.resize(ndof, ndof);
// calculate the element stiffness matrix
ElementStiffness(iel, ke);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
}
//-----------------------------------------------------------------------------
void FEElasticShellDomain::MassMatrix(FELinearSystem& LS, double scale)
{
// repeat over all solid elements
int NE = (int)m_Elem.size();
#pragma omp parallel for shared (NE)
for (int iel=0; iel<NE; ++iel)
{
FEShellElement& el = m_Elem[iel];
if (el.isActive())
{
// create the element's stiffness matrix
FEElementMatrix ke(el);
int ndof = 6 * el.Nodes();
ke.resize(ndof, ndof);
ke.zero();
// calculate inertial stiffness
ElementMassMatrix(el, ke, scale);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
}
//-----------------------------------------------------------------------------
void FEElasticShellDomain::BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf)
{
// repeat over all shell elements
int NE = (int)m_Elem.size();
#pragma omp parallel for shared (NE)
for (int iel=0; iel<NE; ++iel)
{
FEShellElement& el = m_Elem[iel];
if (el.isActive())
{
// create the element's stiffness matrix
FEElementMatrix ke(el);
int ndof = 6 * el.Nodes();
ke.resize(ndof, ndof);
ke.zero();
// calculate inertial stiffness
ElementBodyForceStiffness(bf, el, ke);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
}
//-----------------------------------------------------------------------------
//! Calculates the shell element stiffness matrix
void FEElasticShellDomain::ElementStiffness(int iel, matrix& ke)
{
FEShellElement& el = Element(iel);
int i, i6, j, j6, n;
// Get the current element's data
const int nint = el.GaussPoints();
const int neln = el.Nodes();
const double* Mr, *Ms, *M;
vec3d gradMu[FEElement::MAX_NODES], gradMd[FEElement::MAX_NODES];
// jacobian matrix determinant
double detJt;
// weights at gauss points
const double *gw = el.GaussWeights();
double eta;
vec3d gcnt[3];
// calculate element stiffness matrix
ke.zero();
for (n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *(el.GetMaterialPoint(n));
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// calculate the jacobian
detJt = detJ(el, n, m_alphaf)*gw[n]*m_alphaf;
// get the stress and elasticity for this integration point
mat3ds s = pt.m_s;
// tens4ds C = m_pMat->Tangent(mp);
tens4dmm C = (m_secant_tangent ? m_pMat->SecantTangent(mp) : m_pMat->SolidTangent(mp));
eta = el.gt(n);
Mr = el.Hr(n);
Ms = el.Hs(n);
M = el.H(n);
ContraBaseVectors(el, n, gcnt);
// ------------ constitutive component --------------
// setup the material point
for (i=0; i<neln; ++i)
{
vec3d gradM = gcnt[0]*Mr[i] + gcnt[1]*Ms[i];
gradMu[i] = (gradM*(1+eta) + gcnt[2]*M[i])/2;
gradMd[i] = (gradM*(1-eta) - gcnt[2]*M[i])/2;
}
for (i=0, i6=0; i<neln; ++i, i6 += 6)
{
for (j=0, j6 = 0; j<neln; ++j, j6 += 6)
{
mat3d Kuu = vdotTdotv(gradMu[i], C, gradMu[j])*detJt;
mat3d Kud = vdotTdotv(gradMu[i], C, gradMd[j])*detJt;
mat3d Kdu = vdotTdotv(gradMd[i], C, gradMu[j])*detJt;
mat3d Kdd = vdotTdotv(gradMd[i], C, gradMd[j])*detJt;
ke[i6 ][j6 ] += Kuu(0,0); ke[i6 ][j6+1] += Kuu(0,1); ke[i6 ][j6+2] += Kuu(0,2);
ke[i6+1][j6 ] += Kuu(1,0); ke[i6+1][j6+1] += Kuu(1,1); ke[i6+1][j6+2] += Kuu(1,2);
ke[i6+2][j6 ] += Kuu(2,0); ke[i6+2][j6+1] += Kuu(2,1); ke[i6+2][j6+2] += Kuu(2,2);
ke[i6 ][j6+3] += Kud(0,0); ke[i6 ][j6+4] += Kud(0,1); ke[i6 ][j6+5] += Kud(0,2);
ke[i6+1][j6+3] += Kud(1,0); ke[i6+1][j6+4] += Kud(1,1); ke[i6+1][j6+5] += Kud(1,2);
ke[i6+2][j6+3] += Kud(2,0); ke[i6+2][j6+4] += Kud(2,1); ke[i6+2][j6+5] += Kud(2,2);
ke[i6+3][j6 ] += Kdu(0,0); ke[i6+3][j6+1] += Kdu(0,1); ke[i6+3][j6+2] += Kdu(0,2);
ke[i6+4][j6 ] += Kdu(1,0); ke[i6+4][j6+1] += Kdu(1,1); ke[i6+4][j6+2] += Kdu(1,2);
ke[i6+5][j6 ] += Kdu(2,0); ke[i6+5][j6+1] += Kdu(2,1); ke[i6+5][j6+2] += Kdu(2,2);
ke[i6+3][j6+3] += Kdd(0,0); ke[i6+3][j6+4] += Kdd(0,1); ke[i6+3][j6+5] += Kdd(0,2);
ke[i6+4][j6+3] += Kdd(1,0); ke[i6+4][j6+4] += Kdd(1,1); ke[i6+4][j6+5] += Kdd(1,2);
ke[i6+5][j6+3] += Kdd(2,0); ke[i6+5][j6+4] += Kdd(2,1); ke[i6+5][j6+5] += Kdd(2,2);
}
}
// ------------ initial stress component --------------
for (i=0; i<neln; ++i)
for (j=0; j<neln; ++j)
{
double Kuu = gradMu[i]*(s*gradMu[j])*detJt;
double Kud = gradMu[i]*(s*gradMd[j])*detJt;
double Kdu = gradMd[i]*(s*gradMu[j])*detJt;
double Kdd = gradMd[i]*(s*gradMd[j])*detJt;
// the u-u component
ke[6*i ][6*j ] += Kuu;
ke[6*i+1][6*j+1] += Kuu;
ke[6*i+2][6*j+2] += Kuu;
// the u-d component
ke[6*i ][6*j+3] += Kud;
ke[6*i+1][6*j+4] += Kud;
ke[6*i+2][6*j+5] += Kud;
// the d-u component
ke[6*i+3][6*j ] += Kdu;
ke[6*i+4][6*j+1] += Kdu;
ke[6*i+5][6*j+2] += Kdu;
// the d-d component
ke[6*i+3][6*j+3] += Kdd;
ke[6*i+4][6*j+4] += Kdd;
ke[6*i+5][6*j+5] += Kdd;
}
} // end loop over gauss-points
}
//-----------------------------------------------------------------------------
//! calculates element inertial stiffness matrix
void FEElasticShellDomain::ElementMassMatrix(FEShellElement& el, matrix& ke, double a)
{
// Get the current element's data
const int nint = el.GaussPoints();
const int neln = el.Nodes();
// weights at gauss points
const double *gw = el.GaussWeights();
// calculate element stiffness matrix
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
double D = m_pMat->Density(mp);
// shape functions
double* M = el.H(n);
// Jacobian
double J0 = detJ0(el, n)*gw[n];
// parametric coordinate through thickness
double eta = el.gt(n);
for (int i=0; i<neln; ++i)
for (int j=0; j<neln; ++j)
{
double Kuu = (1+eta)/2*M[i]*(1+eta)/2*M[j]*a*D*J0;
double Kud = (1+eta)/2*M[i]*(1-eta)/2*M[j]*a*D*J0;
double Kdu = (1-eta)/2*M[i]*(1+eta)/2*M[j]*a*D*J0;
double Kdd = (1-eta)/2*M[i]*(1-eta)/2*M[j]*a*D*J0;
// the u-u component
ke[6*i ][6*j ] += Kuu;
ke[6*i+1][6*j+1] += Kuu;
ke[6*i+2][6*j+2] += Kuu;
// the u-d component
ke[6*i ][6*j+3] += Kud;
ke[6*i+1][6*j+4] += Kud;
ke[6*i+2][6*j+5] += Kud;
// the d-u component
ke[6*i+3][6*j ] += Kdu;
ke[6*i+4][6*j+1] += Kdu;
ke[6*i+5][6*j+2] += Kdu;
// the d-d component
ke[6*i+3][6*j+3] += Kdd;
ke[6*i+4][6*j+4] += Kdd;
ke[6*i+5][6*j+5] += Kdd;
}
}
}
//-----------------------------------------------------------------------------
//! Calculates body forces for shells
void FEElasticShellDomain::ElementBodyForce(FEModel& fem, FEShellElement& el, vector<double>& fe)
{
int NF = fem.ModelLoads();
for (int nf = 0; nf < NF; ++nf)
{
FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(fem.ModelLoad(nf));
if (pbf)
{
// integration weights
double* gw = el.GaussWeights();
double eta;
double *M, detJt;
// loop over integration points
int nint = el.GaussPoints();
int neln = el.Nodes();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
double dens0 = m_pMat->Density(mp);
// calculate the jacobian
detJt = detJ0(el, n)*gw[n];
M = el.H(n);
eta = el.gt(n);
// get the force
vec3d f = pbf->force(mp);
for (int i=0; i<neln; ++i)
{
vec3d fu = f*(dens0*M[i]*(1+eta)/2);
vec3d fd = f*(dens0*M[i]*(1-eta)/2);
fe[6*i ] -= fu.x*detJt;
fe[6*i+1] -= fu.y*detJt;
fe[6*i+2] -= fu.z*detJt;
fe[6*i+3] -= fd.x*detJt;
fe[6*i+4] -= fd.y*detJt;
fe[6*i+5] -= fd.z*detJt;
}
}
}
}
}
//-----------------------------------------------------------------------------
void FEElasticShellDomain::Update(const FETimeInfo& tp)
{
FESSIShellDomain::Update(tp);
bool berr = false;
int NE = Elements();
#pragma omp parallel for shared(NE, berr)
for (int i=0; i<NE; ++i)
{
try
{
FEShellElement& el = Element(i);
if (el.isActive())
{
UpdateElementStress(i, tp);
}
}
catch (NegativeJacobian e)
{
#pragma omp critical
{
// reset the logfile mode
berr = true;
if (e.DoOutput()) feLogError(e.what());
}
}
}
if (berr) throw NegativeJacobianDetected();
}
//-----------------------------------------------------------------------------
void FEElasticShellDomain::UpdateElementStress(int iel, const FETimeInfo& tp)
{
double dt = tp.timeIncrement;
// get the shell element
FEShellElement& el = m_Elem[iel];
// get the number of integration points
int nint = el.GaussPoints();
// number of nodes
int neln = el.Nodes();
const int NELN = FEElement::MAX_NODES;
vec3d r0[NELN], s0[NELN], r[NELN], s[NELN];
vec3d v[NELN], w[NELN];
vec3d a[NELN], b[NELN];
// nodal coordinates
GetCurrentNodalCoordinates(el, r, m_alphaf, false);
GetCurrentNodalCoordinates(el, s, m_alphaf, true);
GetReferenceNodalCoordinates(el, r0, false);
GetReferenceNodalCoordinates(el, s0, true);
// update dynamic quantities
if (m_update_dynamic)
{
for (int j=0; j<neln; ++j)
{
FENode& node = m_pMesh->Node(el.m_node[j]);
v[j] = node.get_vec3d(m_dofV[0], m_dofV[1], m_dofV[2])*m_alphaf + node.m_vp*(1-m_alphaf);
w[j] = node.get_vec3d(m_dofSV[0], m_dofSV[1], m_dofSV[2])*m_alphaf + node.get_vec3d_prev(m_dofSV[0], m_dofSV[1], m_dofSV[2])*(1-m_alphaf);
a[j] = node.m_at*m_alpham + node.m_ap*(1-m_alpham);
b[j] = node.get_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2])*m_alpham + node.get_vec3d_prev(m_dofSA[0], m_dofSA[1], m_dofSA[2])*(1-m_alpham);
}
}
// loop over the integration points and calculate
// the stress at the integration point
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *(el.GetMaterialPoint(n));
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// material point coordinates
// TODO: I'm not entirly happy with this solution
// since the material point coordinates are used by most materials.
mp.m_r0 = evaluate(el, r0, s0, n);
mp.m_rt = evaluate(el, r, s, n);
// get the deformation gradient and determinant at intermediate time
mat3d Ft, Fp;
double Jt = defgrad(el, Ft, n);
double Jp = defgradp(el, Fp, n);
if (m_alphaf == 1.0)
{
pt.m_F = Ft;
pt.m_J = Jt;
}
else
{
pt.m_F = Ft * m_alphaf + Fp * (1 - m_alphaf);
pt.m_J = pt.m_F.det();
}
mat3d Fi = pt.m_F.inverse();
pt.m_L = (Ft - Fp)*Fi/dt;
if (m_update_dynamic)
{
pt.m_v = evaluate(el, v, w, n);
pt.m_a = evaluate(el, a, b, n);
}
// update specialized material points
m_pMat->UpdateSpecializedMaterialPoints(mp, tp);
// calculate the stress at this material point
// pt.m_s = m_pMat->Stress(mp);
pt.m_s = (m_secant_stress ? m_pMat->SecantStress(mp) : m_pMat->Stress(mp));
// adjust stress for strain energy conservation
if (m_alphaf == 0.5)
{
// evaluate strain energy at current time
mat3d Ftmp = pt.m_F;
double Jtmp = pt.m_J;
pt.m_F = Ft;
pt.m_J = Jt;
FEElasticMaterial* pme = dynamic_cast<FEElasticMaterial*>(m_pMat);
pt.m_Wt = pme->StrainEnergyDensity(mp);
pt.m_F = Ftmp;
pt.m_J = Jtmp;
mat3ds D = pt.m_L.sym();
double D2 = D.dotdot(D);
if (D2 > std::numeric_limits<double>::epsilon())
pt.m_s += D*(((pt.m_Wt-pt.m_Wp)/(dt*pt.m_J) - pt.m_s.dotdot(D))/D2);
}
}
}
//-----------------------------------------------------------------------------
//! Unpack the element. That is, copy element data in traits structure
//! Note that for the shell elements the lm order is different compared
//! to the solid element ordering. This is because for shell elements the
//! nodes have six degrees of freedom each, where for solids they only
//! have 3 dofs.
void FEElasticShellDomain::UnpackLM(FEElement& el, vector<int>& lm)
{
int N = el.Nodes();
lm.resize(N*9);
for (int i=0; i<N; ++i)
{
FENode& node = m_pMesh->Node(el.m_node[i]);
vector<int>& id = node.m_ID;
// first the displacement dofs
lm[6*i ] = id[m_dofU[0]];
lm[6*i+1] = id[m_dofU[1]];
lm[6*i+2] = id[m_dofU[2]];
// next the shell displacement dofs
lm[6*i+3] = id[m_dofSU[0]];
lm[6*i+4] = id[m_dofSU[1]];
lm[6*i+5] = id[m_dofSU[2]];
// rigid rotational dofs
lm[6*N + 3*i ] = id[m_dofR[0]];
lm[6*N + 3*i+1] = id[m_dofR[1]];
lm[6*N + 3*i+2] = id[m_dofR[2]];
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberDensityDistribution.h | .h | 5,653 | 169 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FECore/FEMaterial.h"
#include "febiomech_api.h"
//---------------------------------------------------------------------------
// Base class for fiber density distribution functions
//
class FEBIOMECH_API FEFiberDensityDistribution : public FEMaterialProperty
{
public:
FEFiberDensityDistribution(FEModel* pfem) : FEMaterialProperty(pfem) {}
// Evaluation of fiber density along n0
virtual double FiberDensity(FEMaterialPoint& mp, const vec3d& n0) = 0;
FECORE_BASE_CLASS(FEFiberDensityDistribution)
};
//---------------------------------------------------------------------------
// Spherical fiber density distribution
//
class FESphericalFiberDensityDistribution : public FEFiberDensityDistribution
{
public:
FESphericalFiberDensityDistribution(FEModel* pfem) : FEFiberDensityDistribution(pfem) {}
double FiberDensity(FEMaterialPoint& mp, const vec3d& n0) override { return 1.0; }
};
//---------------------------------------------------------------------------
// Ellipsoidal fiber density distribution
//
class FEEllipsoidalFiberDensityDistribution : public FEFiberDensityDistribution
{
public:
FEEllipsoidalFiberDensityDistribution(FEModel* pfem);
double FiberDensity(FEMaterialPoint& mp, const vec3d& n0) override;
public:
FEParamDouble m_spa[3]; // semi-principal axes of ellipsoid
// declare the parameter list
DECLARE_FECORE_CLASS();
};
//---------------------------------------------------------------------------
// 3D axisymmetric von Mises fiber density distribution
//
class FEVonMises3DFiberDensityDistribution : public FEFiberDensityDistribution
{
public:
FEVonMises3DFiberDensityDistribution(FEModel* pfem) : FEFiberDensityDistribution(pfem) { m_b = 0; }
double FiberDensity(FEMaterialPoint& mp, const vec3d& n0) override;
public:
FEParamDouble m_b; // concentration parameter
// declare the parameter list
DECLARE_FECORE_CLASS();
};
//---------------------------------------------------------------------------
// 3D 2-fiber families axisymmetric von Mises fiber density distribution
//
class FEVonMises3DTwoFDDAxisymmetric : public FEFiberDensityDistribution
{
public:
FEVonMises3DTwoFDDAxisymmetric(FEModel* pfem);
double FiberDensity(FEMaterialPoint& mp, const vec3d& n0) override;
public:
FEParamDouble m_b; // concentration parameter
FEParamDouble m_c; // cosine of ±angle offset of fiber families
// declare the parameter list
DECLARE_FECORE_CLASS();
};
//---------------------------------------------------------------------------
// Circular fiber density distribution (2d)
//
class FECircularFiberDensityDistribution : public FEFiberDensityDistribution
{
public:
FECircularFiberDensityDistribution(FEModel* pfem) : FEFiberDensityDistribution(pfem) {}
double FiberDensity(FEMaterialPoint& mp, const vec3d& n0) override { return 1.0; }
};
//---------------------------------------------------------------------------
// Elliptical fiber density distribution (2d)
//
class FEEllipticalFiberDensityDistribution : public FEFiberDensityDistribution
{
public:
FEEllipticalFiberDensityDistribution(FEModel* pfem) : FEFiberDensityDistribution(pfem) { m_spa[0] = 1; m_spa[1] = 1; }
double FiberDensity(FEMaterialPoint& mp, const vec3d& n0) override;
public:
FEParamDouble m_spa[2]; // semi-principal axes of ellipse
// declare the parameter list
DECLARE_FECORE_CLASS();
};
//---------------------------------------------------------------------------
// 2D planar von Mises fiber density distribution
//
class FEVonMises2DFiberDensityDistribution : public FEFiberDensityDistribution
{
public:
FEVonMises2DFiberDensityDistribution(FEModel* pfem) : FEFiberDensityDistribution(pfem) { m_b = 0; }
double FiberDensity(FEMaterialPoint& mp, const vec3d& n0) override;
public:
FEParamDouble m_b; // concentration parameter
// declare the parameter list
DECLARE_FECORE_CLASS();
};
//---------------------------------------------------------------------------
class FEStructureTensorDistribution : public FEFiberDensityDistribution
{
public:
FEStructureTensorDistribution(FEModel* fem);
double FiberDensity(FEMaterialPoint& mp, const vec3d& n0) override;
public:
FEParamMat3ds m_SPD;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberCDF.cpp | .cpp | 7,087 | 235 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2023 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEFiberCDF.h"
#include "FEFiberCDFMaterialPoint.h"
#include <limits>
#include <FECore/log.h>
//-----------------------------------------------------------------------------
// FEFiberCDF
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberCDF, FEFiberMaterial)
ADD_PARAMETER(m_E , FE_RANGE_GREATER_OR_EQUAL(0.0), "E" )->setUnits(UNIT_PRESSURE)->setLongName("fiber modulus");
ADD_PROPERTY (m_CDF, "cdf")->SetLongName("cumulative distribution function");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFiberCDF::FEFiberCDF(FEModel* pfem) : FEFiberMaterial(pfem)
{
m_E = 0;
m_epsf = 1.0;
m_CDF = nullptr;
}
//-----------------------------------------------------------------------------
// returns a pointer to a new material point object
FEMaterialPointData* FEFiberCDF::CreateMaterialPointData()
{
return new FEFiberCDFMaterialPoint(FEFiberMaterial::CreateMaterialPointData());
}
//-----------------------------------------------------------------------------
mat3ds FEFiberCDF::FiberStress(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
mat3ds s;
// Calculate In - 1 = n0*C*n0 - 1
double In_1 = n0*(C*n0) - 1;
FEFiberCDFMaterialPoint& fp = *mp.ExtractData<FEFiberCDFMaterialPoint>();
fp.SetFiberStrain(In_1);
// only take fibers in tension into consideration
const double eps = m_epsf* std::numeric_limits<double>::epsilon();
if (In_1 >= eps)
{
double ksi = m_E(mp)/4;
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
// perform integration
Integrate(mp, In_1);
// calculate strain energy first derivative
double Wl = ksi*fp.m_ds_t*In_1;
// calculate the fiber stress
s = N*(2.0*Wl/J);
}
else
{
s.zero();
}
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEFiberCDF::FiberTangent(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
tens4ds c;
// Calculate In - 1 = n0*C*n0 - 1
double In_1 = n0*(C*n0) - 1;
FEFiberCDFMaterialPoint& fp = *mp.ExtractData<FEFiberCDFMaterialPoint>();
fp.SetFiberStrain(In_1);
// only take fibers in tension into consideration
const double eps = m_epsf*std::numeric_limits<double>::epsilon();
if (In_1 >= eps)
{
double ksi = m_E(mp)/4;
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
tens4ds NxN = dyad1s(N);
// perform integration
Integrate(mp, In_1);
// calculate strain energy 2nd derivative
double Wll = ksi*fp.m_d2s_t;
// calculate the fiber tangent
c = NxN*(4.0*Wll/J);
}
else
{
c.zero();
}
return c;
}
//-----------------------------------------------------------------------------
double FEFiberCDF::FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0)
{
double sed = 0.0;
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
// Calculate In - 1 = n0*C*n0 - 1
double In = n0*(C*n0);
double In_1 = In - 1.0;
FEFiberCDFMaterialPoint& fp = *mp.ExtractData<FEFiberCDFMaterialPoint>();
fp.SetFiberStrain(In_1);
// only take fibers in tension into consideration
const double eps = 0;
if (In_1 >= eps)
{
double ksi = m_E(mp)/4;
// perform integration
Integrate(mp, In_1);
// calculate strain energy
sed = fp.m_sed_t*ksi;
}
return sed;
}
//-----------------------------------------------------------------------------
void FEFiberCDF::Integrate(FEMaterialPoint& mp, const double In_1)
{
double dImax = 1e-2;
FEFiberCDFMaterialPoint& fp = *mp.ExtractData<FEFiberCDFMaterialPoint>();
// check increment in strain
double dIn = In_1 - fp.m_In_1_p;
// if small enough, integrate in a single step
if (fabs(dIn) <= dImax) {
fp.Integrate(m_CDF->cdf(mp,In_1));
return;
}
// otherwise, integrate over multiple steps
double In_1_p = fp.m_In_1_p;
double d2s_p = fp.m_d2s_p;
double ds_p = fp.m_ds_p;
double sed_p = fp.m_sed_p;
double In_1_t, d2s_t, ds_t, sed_t;
do {
In_1_t = In_1_p + dImax;
if (In_1_t > In_1) In_1_t = In_1;
dIn = In_1_t - In_1_p;
d2s_t = m_CDF->cdf(mp,In_1_t);
sed_t = sed_p + ds_p*dIn + 0.25*dIn*dIn*(d2s_t + d2s_p);
ds_t = ds_p + 0.5*dIn*(d2s_t + d2s_p);
fp.m_d2s_t = d2s_t;
fp.m_ds_t = ds_t;
fp.m_sed_t = sed_t;
In_1_p = In_1_t;
d2s_p = d2s_t;
ds_p = ds_t;
sed_p = sed_t;
} while (In_1_t < In_1);
return;
}
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEElasticFiberCDF, FEElasticFiberMaterial)
ADD_PARAMETER(m_fib.m_E , FE_RANGE_GREATER_OR_EQUAL(0.0), "E" )->setUnits(UNIT_PRESSURE)->setLongName("fiber modulus");
ADD_PROPERTY (m_fib.m_CDF , "cdf")->SetLongName("cumulative distribution function");
END_FECORE_CLASS();
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FETrussMaterial.h | .h | 3,304 | 119 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
// Material point class for truss materials
class FETrussMaterialPoint : public FEElasticMaterialPoint
{
public:
FEMaterialPointData* Copy()
{
FETrussMaterialPoint* pt = new FETrussMaterialPoint(*this);
if (m_pNext) pt->m_pNext = m_pNext->Copy();
return pt;
}
void Serialize(DumpStream& ar)
{
FEElasticMaterialPoint::Serialize(ar);
ar & m_lam & m_tau;
}
void Init()
{
FEElasticMaterialPoint::Init();
m_lam = 1;
m_tau = 0;
}
public:
double m_lam; // stretch
double m_tau; // Kirchoff stress
};
//-----------------------------------------------------------------------------
// Base class for truss element materials
class FEBIOMECH_API FETrussMaterial : public FEMaterial
{
public:
FETrussMaterial(FEModel* pfem);
~FETrussMaterial();
public:
double m_rho; // density
public:
//! calculate Kirchhoff stress of truss
virtual double Stress(FEMaterialPoint& pt) = 0;
//! calculate elastic tangent
virtual double Tangent(FEMaterialPoint& pt) = 0;
//! create material point data
FEMaterialPointData* CreateMaterialPointData() override { return new FETrussMaterialPoint; }
//! material density
double Density();
// declare the parameter list
DECLARE_FECORE_CLASS();
FECORE_BASE_CLASS(FETrussMaterial);
};
//-----------------------------------------------------------------------------
class FELinearTrussMaterial : public FETrussMaterial
{
public:
FELinearTrussMaterial(FEModel* fem);
//! calculate Kirchhoff stress of truss
double Stress(FEMaterialPoint& pt) override;
//! calculate elastic tangent
double Tangent(FEMaterialPoint& pt) override;
public:
double m_E; // Elastic modulus
double m_v; // Poisson's ratio
// declare the parameter list
DECLARE_FECORE_CLASS();
};
class FEBIOMECH_API FETrussStress : public FEDomainParameter
{
public:
FETrussStress();
FEParamValue value(FEMaterialPoint& mp) override;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEInSituStretchGradient.h | .h | 1,997 | 55 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEPreStrainElastic.h"
//-----------------------------------------------------------------------------
// A pre-strain gradient constructed from fiber stretches
class FEInSituStretchGradient : public FEPrestrainGradient
{
public:
FEInSituStretchGradient(FEModel* pfem);
bool Init() override;
mat3d Prestrain(FEMaterialPoint& mp) override;
void Initialize(const mat3d& F, FEMaterialPoint& mp) override;
void Serialize(DumpStream& ar) override;
private:
FEVec3dValuator* GetFiberProperty();
public:
FEParamDouble m_lam; //!< in-situ stretch
bool m_biso; //!< isochoric generator option
FEVec3dValuator* m_fiber; // fiber property of the elastic material.
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEHolmesMowUC.h | .h | 2,110 | 55 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2022 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
//-----------------------------------------------------------------------------
class FEHolmesMowUC : public FEUncoupledMaterial
{
public:
FEHolmesMowUC(FEModel* pfem) : FEUncoupledMaterial(pfem) {}
public:
double m_mu; //!< shear modulus
double m_b; //!< Exponential stiffening coefficient
public:
//! calculate stress at material point
virtual mat3ds DevStress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
virtual tens4ds DevTangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
virtual double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidPrismaticJoint.h | .h | 4,620 | 127 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FECore/vec3d.h"
#include "FERigidConnector.h"
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
//! The FERigidPrismaticJoint class implements a prismatic joint. The rigid joint
//! allows the user to connect two rigid bodies at a point in space
//! and allow translation along a single prescribed axis.
class FEBIOMECH_API FERigidPrismaticJoint : public FERigidConnector
{
public:
//! constructor
FERigidPrismaticJoint(FEModel* pfem);
//! destructor
~FERigidPrismaticJoint();
//! initialization
bool Init() override;
//! calculates the joint forces
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
//! calculates the joint stiffness
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
//! calculate Lagrangian augmentation
bool Augment(int naug, const FETimeInfo& tp) override;
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! update state
void Update() override;
//! Reset data
void Reset() override;
//! evaluate relative translation
vec3d RelativeTranslation(const bool global = false) override;
//! evaluate relative rotation
vec3d RelativeRotation(const bool global = false) override;
//! initial position
vec3d InitialPosition() const;
//! current position
vec3d Position() const;
//! current orientation
quatd Orientation() const;
private: // lag. mult. methods
int InitEquations(int neq) override;
void BuildMatrixProfile(FEGlobalMatrix& M) override;
void UnpackLM(vector<int>& lm);
void PrepStep();
void Update(const std::vector<double>& Ui, const std::vector<double>& ui) override;
void UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) override;
public: // parameters
int m_laugon; //!< enforcement method
double m_atol; //! augmented Lagrangian tolerance
double m_gtol; //! augmented Lagrangian gap tolerance
double m_qtol; //! augmented Lagrangian angular gap tolerance
int m_naugmin; //! minimum number of augmentations
int m_naugmax; //! maximum number of augmentations
vec3d m_q0; //! initial position of joint
double m_dp; //! prescribed translation
bool m_bd; //! flag for prescribing translation
double m_Fp; //! prescribed force
double m_eps; //! penalty factor for constraining force
double m_ups; //! penalty factor for constraining moment
double m_cps; //! linear damping coefficient for constraining force
double m_rps; //! angular damping coefficient for constraining moment
bool m_bautopen; //!< auto-penalty for gap and ang tolerance
protected:
vec3d m_qa0; //! initial relative position vector of joint w.r.t. A
vec3d m_qb0; //! initial relative position vector of joint w.r.t. B
vec3d m_e0[3]; //! initial joint basis
vec3d m_ea0[3]; //! initial joint basis w.r.t. A
vec3d m_eb0[3]; //! initial joint basis w.r.t. B
vec3d m_L; //! Lagrange multiplier for constraining force
vec3d m_U; //! Lagrange multiplier for constraining moment
vec3d m_Lp, m_U1p, m_U2p;
vec3d m_U1, m_U2;
vector<int> m_LM; // Lagrange multiplier equation numbers
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationTriangle.h | .h | 2,408 | 73 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEFiberIntegrationScheme.h"
//----------------------------------------------------------------------------------
// Geodesic dome integration scheme for continuous fiber distributions
//
class FEFiberIntegrationTriangle : public FEFiberIntegrationScheme
{
class Iterator;
public:
FEFiberIntegrationTriangle(FEModel* pfem);
~FEFiberIntegrationTriangle();
//! Initialization
bool Init() override;
// serialization
void Serialize(DumpStream& ar) override;
// create iterator
FEFiberIntegrationSchemeIterator* GetIterator(FEMaterialPoint* mp) override;
// get number of integration points
int IntegrationPoints() const override { return m_nint; };
protected:
void InitIntegrationRule();
public: // parameters
int m_nres; // resolution
int m_nre; // resolution entry
public:
int m_nint; // number of integration points
double m_cth[2000];
double m_sth[2000];
double m_cph[2000];
double m_sph[2000];
double m_w[2000];
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberNHUC.cpp | .cpp | 4,489 | 155 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEFiberNHUC.h"
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberNHUC, FEFiberMaterialUncoupled)
ADD_PARAMETER(m_mu, FE_RANGE_GREATER_OR_EQUAL(0.0), "mu")->setUnits(UNIT_PRESSURE);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFiberNHUC::FEFiberNHUC(FEModel* pfem) : FEFiberMaterialUncoupled(pfem)
{
m_mu = 0;
}
//-----------------------------------------------------------------------------
mat3ds FEFiberNHUC::DevFiberStress(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// distortional part of deformation gradient
mat3d F = pt.m_F*pow(J, -1.0 / 3.0);
// loop over all integration points
const double eps = 0;
mat3ds C = pt.DevRightCauchyGreen();
mat3ds s;
// Calculate In = n0*C*n0
double In_1 = n0*(C*n0) - 1.0;
// only take fibers in tension into consideration
if (In_1 >= eps)
{
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
// calculate the fiber stress
s = N*(m_mu*In_1 / J);
}
else
{
s.zero();
}
return s.dev();
}
//-----------------------------------------------------------------------------
tens4ds FEFiberNHUC::DevFiberTangent(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// distortional part of deformation gradient
mat3d F = pt.m_F*pow(J, -1.0 / 3.0);
// loop over all integration points
const double eps = 0;
mat3ds C = pt.DevRightCauchyGreen();
mat3ds s;
tens4ds c;
// Calculate In = n0*C*n0
double In_1 = n0*(C*n0) - 1.0;
// only take fibers in tension into consideration
if (In_1 >= eps)
{
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
tens4ds NxN = dyad1s(N);
// calculate the fiber stress
s = N*(m_mu*In_1 / J);
// calculate the fiber tangent
c = NxN*(2 * m_mu / J);
// This is the final value of the elasticity tensor
mat3dd I(1);
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
c += ((I4 + IxI / 3.0)*s.tr() - dyad1s(I, s))*(2. / 3.)
- (ddots(IxI, c) - IxI*(c.tr() / 3.)) / 3.;
}
else
{
c.zero();
}
return c;
}
//-----------------------------------------------------------------------------
//! Strain energy density
double FEFiberNHUC::DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0)
{
double sed = 0.0;
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// loop over all integration points
const double eps = 0;
mat3ds C = pt.DevRightCauchyGreen();
// Calculate In = n0*C*n0
double In_1 = n0*(C*n0) - 1.0;
// only take fibers in tension into consideration
if (In_1 >= eps)
sed = 0.25*m_mu*In_1*In_1;
return sed;
}
// define the material parameters
BEGIN_FECORE_CLASS(FEUncoupledFiberNH, FEElasticFiberMaterialUC)
ADD_PARAMETER(m_fib.m_mu, FE_RANGE_GREATER_OR_EQUAL(0.0), "mu")->setUnits(UNIT_PRESSURE);
END_FECORE_CLASS();
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedRotation.h | .h | 1,451 | 35 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2020 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FEPrescribedDOF.h>
class FEPrescribedRotation : public FEPrescribedDOF
{
public:
FEPrescribedRotation(FEModel* fem);
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FESolidModule.h | .h | 1,467 | 36 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2020 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FEModule.h>
#include "febiomech_api.h"
class FEBIOMECH_API FESolidModule : public FEModule
{
public:
FESolidModule();
void InitModel(FEModel* fem) override;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEVolumeConstraint.cpp | .cpp | 10,682 | 413 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEVolumeConstraint.h"
#include <FECore/FEModel.h>
#include <FECore/log.h>
#include <FECore/FEDataExport.h>
#include <FECore/DumpStream.h>
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
//! constructor
FEVolumeSurface::FEVolumeSurface(FEModel* fem) : FESurface(fem)
{
m_Lp = 0.0;
m_p = 0.0;
m_V0 = 0.0;
m_Vt = 0.0;
// define class exports
EXPORT_DATA(PLT_FLOAT, FMT_REGION, &m_p, "volume pressure");
}
//-----------------------------------------------------------------------------
bool FEVolumeSurface::Init()
{
if (FESurface::Init() == false) return false;
// evaluate the initial volume
m_V0 = CalculateSurfaceVolume(*this);
m_Vt = m_V0;
return (m_V0 != 0.0);
}
//-----------------------------------------------------------------------------
void FEVolumeSurface::CopyFrom(FEVolumeSurface& s)
{
m_Node = s.m_Node;
// create elements
int NE = s.Elements();
Create(NE);
for (int i=0; i<NE; ++i) Element(i) = s.Element(i);
// copy surface data
m_Lp = s.m_Lp;
m_p = s.m_p;
m_V0 = s.m_V0;
m_Vt = s.m_Vt;
}
//-----------------------------------------------------------------------------
void FEVolumeSurface::Serialize(DumpStream& ar)
{
FESurface::Serialize(ar);
ar & m_Lp & m_p & m_V0 & m_Vt;
}
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEVolumeConstraint, FESurfaceConstraint);
ADD_PARAMETER(m_blaugon, "laugon" );
ADD_PARAMETER(m_atol , "augtol" );
ADD_PARAMETER(m_eps , "penalty");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! constructor. Set default parameter values
FEVolumeConstraint::FEVolumeConstraint(FEModel* pfem) : FESurfaceConstraint(pfem)
{
m_s = new FEVolumeSurface(pfem);
m_eps = 0.0;
m_atol = 0.0;
m_blaugon = false;
m_binit = false; // will be set to true during activation
// get the degrees of freedom
m_dofX = pfem->GetDOFIndex("x");
m_dofY = pfem->GetDOFIndex("y");
m_dofZ = pfem->GetDOFIndex("z");
}
//-----------------------------------------------------------------------------
FEVolumeConstraint::~FEVolumeConstraint()
{
delete m_s;
}
//-----------------------------------------------------------------------------
void FEVolumeConstraint::CopyFrom(FENLConstraint* plc)
{
// cast to a periodic boundary
FEVolumeConstraint& vc = dynamic_cast<FEVolumeConstraint&>(*plc);
// copy parameters
GetParameterList() = vc.GetParameterList();
// copy nodes
m_s->CopyFrom(*vc.m_s);
}
//-----------------------------------------------------------------------------
//! Returns the surface
FESurface* FEVolumeConstraint::GetSurface()
{
return m_s;
}
//-----------------------------------------------------------------------------
double FEVolumeConstraint::EnclosedVolume() const
{
return m_s->m_Vt;
}
//-----------------------------------------------------------------------------
double FEVolumeConstraint::Pressure() const
{
return m_s->m_p;
}
//-----------------------------------------------------------------------------
//! Initializes data structures.
void FEVolumeConstraint::Activate()
{
// don't forget to call base class
FENLConstraint::Activate();
// initialize the surface
if (m_binit == false) m_s->Init();
// set flag that initial volume is calculated
m_binit = true;
}
//-----------------------------------------------------------------------------
void FEVolumeConstraint::BuildMatrixProfile(FEGlobalMatrix& M)
{
// We don't do anything here since the connectivity of a surface
// is implied by the domain to which it is attached.
}
//-----------------------------------------------------------------------------
void FEVolumeConstraint::UnpackLM(FEElement& el, vector<int>& lm)
{
FEMesh& mesh = GetFEModel()->GetMesh();
int N = el.Nodes();
lm.resize(N*3);
for (int i=0; i<N; ++i)
{
int n = el.m_node[i];
FENode& node = mesh.Node(n);
vector<int>& id = node.m_ID;
lm[3*i ] = id[m_dofX];
lm[3*i+1] = id[m_dofY];
lm[3*i+2] = id[m_dofZ];
}
}
//-----------------------------------------------------------------------------
void FEVolumeConstraint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
FEVolumeSurface& s = *m_s;
FEMesh& mesh = *s.GetMesh();
vector<double> fe;
vector<int> lm;
// get the pressure
double p = s.m_p;
// loop over all elements
int NE = s.Elements();
vec3d x[FEElement::MAX_NODES];
for (int i=0; i<NE; ++i)
{
// get the next element
FESurfaceElement& el = s.Element(i);
// get the nodal coordinates
int neln = el.Nodes();
for (int j=0; j<neln; ++j) x[j] = mesh.Node(el.m_node[j]).m_rt;
// allocate element residual vector
int ndof = 3*neln;
fe.resize(ndof);
zero(fe);
// loop over all integration points
double* w = el.GaussWeights();
int nint = el.GaussPoints();
for (int n=0; n<nint; ++n)
{
// calculate the tangent vectors
double* Gr = el.Gr(n);
double* Gs = el.Gs(n);
vec3d dxr(0,0,0), dxs(0,0,0);
for (int j=0; j<neln; ++j)
{
dxr += x[j]*Gr[j];
dxs += x[j]*Gs[j];
}
// evaluate the "normal" vector
vec3d v = (dxr ^ dxs)*w[n]*p;
// evaluate the element forces
double* H = el.H(n);
for (int j=0; j<neln; ++j)
{
fe[3*j ] += H[j]*v.x;
fe[3*j+1] += H[j]*v.y;
fe[3*j+2] += H[j]*v.z;
}
}
// get the element's LM vector
UnpackLM(el, lm);
// add element force vector to global force vector
R.Assemble(el.m_node, lm, fe);
}
}
//-----------------------------------------------------------------------------
void FEVolumeConstraint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
FEVolumeSurface& s = *m_s;
FEMesh& mesh = *s.GetMesh();
// get the pressure
double p = s.m_p;
// element stiffness matrix
vector<int> lm;
vector<double> fe;
// loop over all elements
int NE = s.Elements();
vec3d x[FEElement::MAX_NODES];
for (int l=0; l<NE; ++l)
{
// get the next element
FESurfaceElement& el = s.Element(l);
FEElementMatrix ke(el);
// get the nodal coordinates
int neln = el.Nodes();
for (int j=0; j<neln; ++j) x[j] = mesh.Node(el.m_node[j]).m_rt;
// allocate the stiffness matrix
int ndof = 3*neln;
ke.resize(ndof, ndof);
ke.zero();
fe.resize(ndof);
zero(fe);
// repeat over integration points
double* w = el.GaussWeights();
int nint = el.GaussPoints();
for (int n=0; n<nint; ++n)
{
// calculate tangent vectors
double* N = el.H(n);
double* Gr = el.Gr(n);
double* Gs = el.Gs(n);
vec3d dxr(0,0,0), dxs(0,0,0);
for (int j=0; j<neln; ++j)
{
dxr += x[j]*Gr[j];
dxs += x[j]*Gs[j];
}
// calculate pressure contribution
vec3d v = (dxr ^ dxs)*w[n]*m_eps;
for (int i=0; i<neln; ++i)
{
fe[3*i ] += N[i]*v.x;
fe[3*i+1] += N[i]*v.y;
fe[3*i+2] += N[i]*v.z;
}
for (int i=0; i<neln; ++i)
for (int j=0; j<neln; ++j)
{
ke[3*i ][3*j ] += fe[3*i ]*fe[3*j ];
ke[3*i ][3*j+1] += fe[3*i ]*fe[3*j+1];
ke[3*i ][3*j+2] += fe[3*i ]*fe[3*j+2];
ke[3*i+1][3*j ] += fe[3*i+1]*fe[3*j ];
ke[3*i+1][3*j+1] += fe[3*i+1]*fe[3*j+1];
ke[3*i+1][3*j+2] += fe[3*i+1]*fe[3*j+2];
ke[3*i+2][3*j ] += fe[3*i+2]*fe[3*j ];
ke[3*i+2][3*j+1] += fe[3*i+2]*fe[3*j+1];
ke[3*i+2][3*j+2] += fe[3*i+2]*fe[3*j+2];
}
// calculate displacement contribution
vec3d kab;
for (int i=0; i<neln; ++i)
for (int j=0; j<neln; ++j)
{
kab = (dxr*(N[j]*Gs[i]-N[i]*Gs[j])
-dxs*(N[j]*Gr[i]-N[i]*Gr[j]))*w[n]*0.5*p;
ke[3*i ][3*j ] += 0;
ke[3*i ][3*j+1] += -kab.z;
ke[3*i ][3*j+2] += kab.y;
ke[3*i+1][3*j ] += kab.z;
ke[3*i+1][3*j+1] += 0;
ke[3*i+1][3*j+2] += -kab.x;
ke[3*i+2][3*j ] += -kab.y;
ke[3*i+2][3*j+1] += kab.x;
ke[3*i+2][3*j+2] += 0;
}
}
// get the element's LM vector
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
bool FEVolumeConstraint::Augment(int naug, const FETimeInfo& tp)
{
FEVolumeSurface& s = *m_s;
// make sure we are augmenting
if ((m_blaugon == false) || (m_atol <= 0.0)) return true;
feLog("\nvolume constraint:\n");
double Dp = m_eps*(s.m_Vt - s.m_V0);
double Lp = s.m_p;
double err = fabs(Dp/Lp);
feLog("\tpressure: %lg\n", Lp);
feLog("\tnorm : %lg (%lg)\n", err, m_atol);
feLog("\tvolume ratio: %lg\n", s.m_Vt / s.m_V0);
// check convergence
if (err < m_atol) return true;
// update Lagrange multiplier (and pressure variable)
s.m_Lp = Lp;
s.m_p = Lp + Dp;
return false;
}
//-----------------------------------------------------------------------------
void FEVolumeConstraint::Serialize(DumpStream& ar)
{
FENLConstraint::Serialize(ar);
m_s->Serialize(ar);
ar & m_binit;
}
//-----------------------------------------------------------------------------
void FEVolumeConstraint::Reset()
{
}
//-----------------------------------------------------------------------------
// This function is called when the FE model's state needs to be updated.
void FEVolumeConstraint::Update()
{
FEVolumeSurface& s = *m_s;
// calculate the current volume
s.m_Vt = CalculateSurfaceVolume(s);
// update pressure variable
s.m_p = s.m_Lp + m_eps*(s.m_Vt - s.m_V0);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEBioMechModule.h | .h | 1,619 | 39 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
//! The FEBioMech module
//! This module defines classes for dealing with large deformation structural
//! mechanics problems.
namespace FEBioMech
{
//! Initialize the FEBioMech module
FEBIOMECH_API void InitModule();
}
| Unknown |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.