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/FEDamageMaterial.h | .h | 2,530 | 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 "FEElasticMaterial.h"
#include "FEDamageMaterialPoint.h"
#include "FEDamageCriterion.h"
#include "FEDamageCDF.h"
//-----------------------------------------------------------------------------
// This material models damage in any hyper-elastic materials.
class FEDamageMaterial : public FEElasticMaterial
{
public:
FEDamageMaterial(FEModel* pfem);
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;
//! 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
FEElasticMaterial* GetElasticMaterial() override { return m_pBase; }
public:
FEElasticMaterial* m_pBase; // base elastic material
FEDamageCDF* m_pDamg; // damage model
FEDamageCriterion* m_pCrit; // damage criterion
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FETransIsoMREstrada.cpp | .cpp | 7,282 | 234 | /*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 "FETransIsoMREstrada.h"
//////////////////////////////////////////////////////////////////////
// FETransIsoMREstrada
//////////////////////////////////////////////////////////////////////
// define the material parameters
BEGIN_FECORE_CLASS(FETransIsoMREstrada, FEUncoupledMaterial)
ADD_PARAMETER(c1, "c1");
ADD_PARAMETER(c2, "c2");
ADD_PARAMETER(m_fib.m_c3, "c3");
ADD_PARAMETER(m_fib.m_c4, "c4");
ADD_PARAMETER(m_fib.m_c5, "c5");
ADD_PARAMETER(m_fib.m_lam1, "lam_max");
ADD_PROPERTY(m_fiber, "fiber");
ADD_PROPERTY(m_ac, "active_contraction", FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FETransIsoMREstrada::FETransIsoMREstrada(FEModel* pfem) : FEUncoupledMaterial(pfem), m_fib(pfem)
{
m_ac = nullptr;
m_fib.SetParent(this);
m_fiber = nullptr;
}
//-----------------------------------------------------------------------------
//! create material point data
FEMaterialPointData* FETransIsoMREstrada::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 FETransIsoMREstrada::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();
// 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;
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
double I1 = B.tr();
// --- TODO: put strain energy derivatives here ---
// Wi = dW/dIi
double W1 = c1(mp);
double W2 = 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 FETransIsoMREstrada::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());
// --- TODO: put strain energy derivatives here ---
// Wi = dW/dIi
double W1, W2;
W1 = c1(mp);
W2 = 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);
// 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;
// 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 FETransIsoMREstrada::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();
// 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;
// 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 = c1(mp)*(I1-3) + c2(mp)*(I2-3);
// add the fiber sed
sed += m_fib.DevFiberStrainEnergyDensity(mp, a0);
return sed;
}
//-----------------------------------------------------------------------------
// update force-velocity material point
void FETransIsoMREstrada::UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& timeInfo)
{
// 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;
if (m_ac) m_ac->UpdateSpecializedMaterialPoints(mp, timeInfo, a0);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFacet2FacetTied.h | .h | 3,902 | 128 | /*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"
//-----------------------------------------------------------------------------
//! Surface definition for the facet-to-facet tied interface
class FEFacetTiedSurface : public FEContactSurface
{
public:
//! integration point data
class Data : public FEContactMaterialPoint
{
public:
Data();
void Init() override;
void Serialize(DumpStream& ar);
public:
vec3d m_vgap; //!< gap function
vec3d m_vgap0; //!< initial gap function
vec3d m_Lm; //!< Lagrange multiplier
vec2d m_rs; //!< natural coordinates on secondary surface element
};
public:
//! constructor
FEFacetTiedSurface(FEModel* pfem);
//! Initialization
bool Init() override;
//! serialization for cold restarts
void Serialize(DumpStream& ar) override;
//! create material point data
FEMaterialPoint* CreateMaterialPoint() override;
};
//-----------------------------------------------------------------------------
//! Tied contact interface with facet-to-facet integration
class FEFacet2FacetTied : public FEContactInterface
{
public:
//! constructor
FEFacet2FacetTied(FEModel* pfem);
//! 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 false; }
//! 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 contact data
void Update() override;
protected:
//! projects primary nodes onto secondary nodes
void ProjectSurface(FEFacetTiedSurface& ss, FEFacetTiedSurface& ms);
private:
FEFacetTiedSurface m_ms; //!< secondary surface
FEFacetTiedSurface m_ss; //!< primary surface
public:
double m_atol; //!< augmentation tolerance
double m_eps; //!< penalty scale factor
double m_stol; //!< search tolerance
int m_naugmax; //!< maximum nr of augmentations
int m_naugmin; //!< minimum nr of augmentations
bool m_gapoff; //!< retain initial gap as offset
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEActiveFiberStress.h | .h | 3,367 | 92 | /*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
/*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.*/
#pragma once
#include <FECore/FEMaterial.h>
#include "FEElasticMaterial.h"
#include <FECore/tens4d.h>
#include <FECore/FEFunction1D.h>
//-----------------------------------------------------------------------------
class FEActiveFiberStress : public FEElasticMaterial
{
public:
class Data : public FEMaterialPointData
{
public:
double m_lamp;
public:
void Update()
{
// TODO:
}
void Serialize(DumpStream& ar) override;
};
public:
FEActiveFiberStress(FEModel* fem);
mat3ds Stress(FEMaterialPoint& mp) override;
tens4ds Tangent(FEMaterialPoint& mp) override;
private:
double m_smax; //!< peak stress
double m_ac; //!< activation level
FEFunction1D* m_stl; //!< stress from tension-length
FEFunction1D* m_stv; //!< stress from tension-velocity
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEResidualVector.cpp | .cpp | 5,967 | 214 | /*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 "FEResidualVector.h"
#include "FERigidBody.h"
#include "FECore/DOFS.h"
#include "FEMechModel.h"
#include <FECore/FELinearConstraintManager.h>
#include <FECore/FEAnalysis.h>
#include "FESolidSolver2.h"
using namespace std;
//-----------------------------------------------------------------------------
FEResidualVector::FEResidualVector(FEModel& fem, vector<double>& R, vector<double>& Fr) : FEGlobalVector(fem, R, Fr)
{
}
//-----------------------------------------------------------------------------
FEResidualVector::~FEResidualVector()
{
}
//-----------------------------------------------------------------------------
void FEResidualVector::Assemble(vector<int>& en, vector<int>& elm, vector<double>& fe, bool bdom)
{
FEMesh& mesh = m_fem.GetMesh();
vector<double>& R = m_R;
// assemble the element residual into the global residual
int ndof = (int)fe.size();
int ndn = ndof / (int)en.size();
for (int i = 0; i < ndof; ++i)
{
int I = elm[i];
if (I >= 0) {
#pragma omp atomic
R[I] += fe[i];
}
// TODO: Find another way to store reaction forces
else if (-I - 2 >= 0)
{
// Don't add the reaction force to rigid nodes
int nid = en[i / ndn];
if (nid >= 0)
{
FENode& node = mesh.Node(nid);
if (node.m_rid < 0)
{
#pragma omp atomic
m_Fr[-I - 2] -= fe[i];
}
}
}
}
// if there are linear constraints we need to apply them
// process linear constraints
FELinearConstraintManager& LCM = m_fem.GetLinearConstraintManager();
if (LCM.LinearConstraints())
{
LCM.AssembleResidual(R, en, elm, fe);
}
// If there are rigid bodies we need to look for rigid dofs
FEMechModel* fem = dynamic_cast<FEMechModel*>(&m_fem);//assert(fem);
if (fem && (fem->RigidBodies() > 0))
{
for (int i = 0; i < ndof; i += ndn)
{
int nid = en[i / ndn];
if (nid >= 0)
{
FENode& node = mesh.Node(nid);
if (node.m_rid >= 0)
{
vec3d F(fe[i], fe[i + 1], fe[i + 2]);
// this is an interface dof
// get the rigid body this node is connected to
FERigidBody& RB = *fem->GetRigidBody(node.m_rid);
// add to total torque of this body
double alpha = fem->GetTime().alphaf;
vec3d f = F;
vec3d a = (node.m_rt - RB.m_rt)* alpha + (node.m_rp - RB.m_rp) * (1 - alpha);
// vec3d a = node.m_rt - RB.m_rt;
vec3d m = a ^ F;
// TODO: This code is only relevant when called from the shell domain residual and applies
// the reaction of the back-face nodes.
if (bdom)
{
if (node.HasFlags(FENode::SHELL) && node.HasFlags(FENode::RIGID_CLAMP)) {
vec3d d = node.m_dt;
vec3d b = a - d;
vec3d Fd(fe[i + 3], fe[i + 4], fe[i + 5]);
f += Fd;
m += b ^ Fd;
}
}
#pragma omp atomic
RB.m_Fr.x -= f.x;
#pragma omp atomic
RB.m_Fr.y -= f.y;
#pragma omp atomic
RB.m_Fr.z -= f.z;
#pragma omp atomic
RB.m_Mr.x -= m.x;
#pragma omp atomic
RB.m_Mr.y -= m.y;
#pragma omp atomic
RB.m_Mr.z -= m.z;
const int* lm = RB.m_LM;
if (lm[0] >= 0) {
#pragma omp atomic
R[lm[0]] += f.x;
}
if (lm[1] >= 0) {
#pragma omp atomic
R[lm[1]] += f.y;
}
if (lm[2] >= 0) {
#pragma omp atomic
R[lm[2]] += f.z;
}
if (lm[3] >= 0) {
#pragma omp atomic
R[lm[3]] += m.x;
}
if (lm[4] >= 0) {
#pragma omp atomic
R[lm[4]] += m.y;
}
if (lm[5] >= 0) {
#pragma omp atomic
R[lm[5]] += m.z;
}
/*
// if the rotational degrees of freedom are constrained for a rigid node
// then we need to add an additional component to the residual
if (node.m_ID[m_dofRU] == lm[3])
{
d = node.m_Dt;
n = lm[3]; if (n >= 0) R[n] += d.y*F.z-d.z*F.y; RB.m_Mr.x -= d.y*F.z-d.z*F.y;
n = lm[4]; if (n >= 0) R[n] += d.z*F.x-d.x*F.z; RB.m_Mr.y -= d.z*F.x-d.x*F.z;
n = lm[5]; if (n >= 0) R[n] += d.x*F.y-d.y*F.x; RB.m_Mr.z -= d.x*F.y-d.y*F.x;
}
*/
}
}
}
}
}
//! Assemble into this global vector
void FEResidualVector::Assemble(int node_id, int dof, double f)
{
// get the mesh
FEMechModel& mechModel = dynamic_cast<FEMechModel&>(m_fem);
FEMesh& mesh = m_fem.GetMesh();
// get the equation number
FENode& node = mesh.Node(node_id);
int n = node.m_ID[dof];
// assemble into global vector
if (n >= 0) {
#pragma omp atomic
m_R[n] += f;
}
else {
FESolidSolver2* solver = dynamic_cast<FESolidSolver2*>(m_fem.GetCurrentStep()->GetFESolver());
if (solver)
{
FERigidSolver* rigidSolver = solver->GetRigidSolver();
rigidSolver->AssembleResidual(node_id, dof, f, m_R);
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FESolidAnalysis.cpp | .cpp | 1,662 | 38 | /*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 "FESolidAnalysis.h"
BEGIN_FECORE_CLASS(FESolidAnalysis, FEAnalysis)
// The analysis parameter is already defined in the FEAnalysis base class.
// Here, we just need to set the enum values for the analysis parameter.
FindParameterFromData(&m_nanalysis)->setEnums("STATIC\0DYNAMIC\0");
END_FECORE_CLASS()
FESolidAnalysis::FESolidAnalysis(FEModel* fem) : FEAnalysis(fem)
{
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEConstPrestrain.cpp | .cpp | 3,859 | 116 | /*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 "FEConstPrestrain.h"
//-----------------------------------------------------------------------------
FEConstPrestrainGradient::MaterialPointData::MaterialPointData()
{
Fp.unit();
}
//-----------------------------------------------------------------------------
void FEConstPrestrainGradient::MaterialPointData::Init(bool bflag)
{
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEConstPrestrainGradient::MaterialPointData::Copy()
{
MaterialPointData* pm = new MaterialPointData(*this);
return pm;
}
//-----------------------------------------------------------------------------
void FEConstPrestrainGradient::MaterialPointData::Serialize(DumpStream& ar)
{
FEMaterialPointData::Serialize(ar);
ar & Fp;
}
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEConstPrestrainGradient, FEPrestrainGradient)
ADD_PARAMETER(m_ramp, "ramp");
ADD_PARAMETER(m_Fp, "F0");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEConstPrestrainGradient::FEConstPrestrainGradient(FEModel* pfem) : FEPrestrainGradient(pfem)
{
m_ramp = 1.0;
m_Fp = mat3dd(1.0);
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEConstPrestrainGradient::CreateMaterialPointData()
{
return new MaterialPointData;
}
//-----------------------------------------------------------------------------
mat3d FEConstPrestrainGradient::Prestrain(FEMaterialPoint& mp)
{
MaterialPointData& ep = *mp.ExtractData<MaterialPointData>();
mat3d Fp = mat3dd(1.0) * (1.0 - m_ramp) + m_Fp(mp) * m_ramp;
return Fp*ep.Fp;
}
//-----------------------------------------------------------------------------
void FEConstPrestrainGradient::Initialize(const mat3d& F, FEMaterialPoint& mp)
{
FEElasticMaterialPoint* pt = mp.ExtractData<FEElasticMaterialPoint>();
FEConstPrestrainGradient::MaterialPointData* ps = mp.ExtractData<FEConstPrestrainGradient::MaterialPointData>();
/*
// calculate left polar decomposition
mat3d R;
mat3ds V;
F.left_polar(V, R);
// assign it to the pre-strain gradient
ps->Fp = V;
// adjust fiber vector
vec3d a0 = pt->m_Q.col(0);
vec3d a1 = R*a0;
// setup orthogonal system
vec3d b(0,0,1);
if (b*a1 > 0.9) b = vec3d(0,1,0);
vec3d a3 = a1^b;
vec3d a2 = a3^a1;
mat3d Q;
Q(0,0) = a1.x; Q(0,1) = a2.x; Q(0,2) = a3.x;
Q(1,0) = a1.y; Q(1,1) = a2.y; Q(1,2) = a3.y;
Q(2,0) = a1.z; Q(2,1) = a2.z; Q(2,2) = a3.z;
pt->m_Q = Q;
*/
ps->Fp = F;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPRLig.cpp | .cpp | 11,620 | 393 | /*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 "FEPRLig.h"
// Define the material parameters
BEGIN_FECORE_CLASS(FEPRLig, FEElasticMaterial)
ADD_PARAMETER(m_c1, "c1");
ADD_PARAMETER(m_c2, "c2");
ADD_PARAMETER(m_u, "mu");
ADD_PARAMETER(m_v0, "v0");
ADD_PARAMETER(m_m, "m");
ADD_PARAMETER(m_k, "k");
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
extern tens4ds material_to_spatial(tens4ds& C, mat3d& F);
//////////////////////////////////////////////////////////////////////
// PRLig
//////////////////////////////////////////////////////////////////////
FEPRLig::FEPRLig(FEModel* pfem) : FEElasticMaterial(pfem)
{
}
///////////////////////////
//////////////////////////////Cauchy Stress Calculation ////////////////////////////////////////////////
////////////////////////////
mat3ds FEPRLig::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// obtain the deformation tensor F
mat3d &F = pt.m_F;
// calculate left and right Cauchy-Green tensors and their squares
mat3ds b = pt.LeftCauchyGreen();
mat3ds c = pt.RightCauchyGreen();
mat3ds b2 = b.sqr();
mat3ds c2 = c.sqr();
// Define the 2nd order identity tensor
mat3dd I(1);
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// declare initial material direction vector
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();
//////////////////////////Strain invariants and Derivatives///////////////////////////////////////////////
// define scalar strain invariants i1:15
double i1 = c.tr();
double i2 = 0.5*(i1*i1 - c2.tr());
double i3 = c.det();
double i4 = a0*(c*a0);
double i5 = a0*(c2*a0);
// define common terms in the strain energy derivatives
double rooti4 = sqrt(i4);
double CT1 = i2 - i1*i4 + i5;
double CT2 = -2*(m_m-m_v0);
double CT3 = -1 + rooti4;
double CT4 = exp(4*CT3*m_m);
double CT4inv= 1/CT4;
double CT5= pow(i4,-2*(m_m - m_v0));
double CT5inv= 1/CT5;
double CT6 = m_k*log(CT4*CT5*CT1)/CT1;
double CTe = exp(m_c2*CT3*CT3);
double CT8= m_k*(-CT4*i1*CT5 + 2*CT4*(1/rooti4)*CT5*CT1*m_m - 2*CT4*(1/i4)*CT5*CT1*(m_m - m_v0));
// calculate the strain energy first derivatives with respect to each of the scalar invariants
double w1 = ((m_u)/2) - (i4*CT6);
double w2 = CT6;
double w3 = (-2*m_u)/(4*i3);
double w4 = m_c1*CTe*(CT3)/(2*rooti4) + (1/CT1)*CT4inv*CT5inv*CT8*CT6*CT1*(1/m_k);
double w5 = CT6;
// calculate dyadic tensor terms found in stress calculation
// calculate a_i*a_j
mat3ds aa = dyad(a);
// calculate a_i*b_jk*a_k + b_ik*a_k*aj
vec3d ba = b*a;
mat3ds aobas = dyads(a, ba);
// calculate J = sqrt(i3)
double J = sqrt(i3);
// calculate cauchy stress
mat3ds s = 2/J*(i3*w3*I + (w1 + i1*w2)*b - w2*b2 + i4*w4*aa + i4*w5*aobas);
// Stopping point debugging; comment out when not testing
// double WPR = 0;
// return stress
return s;
}
//////////////////////////////
////////////////////////////////////Elasticity Tensor Calculation//////////////////////////////////////////////////////////////////////////
///////////////////////////////
tens4ds FEPRLig::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// obtain the deformation tensor F
mat3d &F = pt.m_F;
// calculate left and right Cauchy-Green tensors, and their squares
mat3ds b = pt.LeftCauchyGreen();
mat3ds c = pt.RightCauchyGreen();
mat3ds b2 = b.sqr();
mat3ds c2 = c.sqr();
// define the 2nd order identity tensor
mat3dd I(1);
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// declare initial material direction vectors
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();
//////////////////////////////////Strain invariants and Derivatives///////////////////////////////////////
// define scalar strain invariants i1:i5
double i1 = c.tr();
double i2 = 0.5*(i1*i1 - c2.tr());
double i3 = c.det();
double i4 = a0*(c*a0);
double i5 = a0*(c2*a0);
// define common terms in the strain energy derivatives
double rooti4 = sqrt(i4);
double CT1 = i2 - i1*i4 + i5;
double CT1_2= CT1*CT1;
double CT2 = -2*(m_m-m_v0);
double CT3 = -1 + rooti4;
double CT4 = exp(4*CT3*m_m);
double CT4inv= 1/CT4;
double CT5= pow(i4,-2*(m_m - m_v0));
double CT5inv= 1/CT5;
double CT6 = m_k*log(CT4*CT5*CT1)/CT1;
double CTe = exp(m_c2*CT3*CT3);
double i4_2= i4*i4;
double CT7= CT6*1/CT1;
double CT8= m_k*(-CT4*i1*CT5 + 2*CT4*(1/rooti4)*CT5*CT1*m_m - 2*CT4*(1/i4)*CT5*CT1*(m_m - m_v0));
double CT9 = exp(m_c2*CT3*CT3);
// calculate the strain energy first derivatives with respect to each of the scalar invariants
double w1 = ((m_u)/2) - (i4*CT6);
double w2 = CT6;
double w3 = (-2*m_u)/(4*i3);
double w4 = m_c1*CTe*(CT3)/(2*rooti4) + (1/CT1)*CT4inv*CT5inv*CT8*CT6*CT1*(1/m_k);
double w5 = CT6;
// calculate the second strain strain energy derivatives with respect to each of the scalar invariants
double w11 = i4_2*m_k/CT1_2 - i4_2*CT7;
double w12 = -i4*m_k/CT1_2 + i4*CT7;
double w13 = 0;
double w14 = -(1/CT1_2)*(1/CT4)*i4*(1/CT5)*CT8- i1*i4*CT7 - CT6;
double w15 = w12;
double w22 = m_k/CT1_2 - CT7;
double w23 = 0;
double w24 = 1/CT1_2*CT4inv*CT5inv*CT8 + i1*CT7;
double w25 = w22;
double w33 = (2*m_u)/(4*i3*i3);
double w34 = 0;
double w35 = 0;
double w44 = (1/(4*i4_2*CT1_2))*(m_c1*CT9*rooti4*(1 + 2*m_c2*(rooti4 - 2*i4 + rooti4*rooti4*rooti4))*CT1_2 + 4*m_k*pow((-2*(i2 + i5)
*(CT3*m_m + m_v0)+i1*i4*(1 + 2*CT3*m_m + 2*m_v0)),2)- 4*m_k*(-2*i1*i4*(i2 + i5)*((-2 + rooti4)*m_m + 2*m_v0)
+ (i2 + i5)*(i2 + i5)*((-2+ rooti4)*m_m + 2*m_v0) + i1*i1*i4_2*(1 + (-2+ rooti4)*m_m + 2*m_v0))
*log(CT4*CT5*CT1));
double w45 = 1/(CT1_2)*CT4inv*CT5inv*CT8 + 1/CT1*CT4inv*CT5inv*m_k*(2*CT4*(1/rooti4)*CT5*m_m - 2*CT4*(1/i4)*CT5*(m_m - m_v0))
*CT6*CT1*(1/m_k) - 1/(CT1_2)*CT4inv*CT5inv*CT8*CT6*CT1*(1/m_k);
double w55 = w22;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// calculate the second order dyadic terms in the elasticity tensor calculation
mat3ds a02 = dyad(a0);
vec3d ctimesa0 = c*a0;
mat3ds di5dc = dyads(a0, ctimesa0);
mat3ds cinv=c.inverse();
mat3ds aa = dyad(a);
vec3d btimesa = b*a;
mat3ds pf_didc = dyads(btimesa,a);
// calculate the fourth order dyadic terms in the elasticity tensor calculation
tens4ds bb = dyad1s(b);
tens4ds bb2 = dyad1s(b, b2);
tens4ds b2b2 = dyad1s(b2);
tens4ds pfi4 = dyad4s(b);
tens4ds bI = dyad1s(b,I);
tens4ds b2I = dyad1s(b2,I);
tens4ds II = dyad1s(I);
tens4ds pf_dcindc = dyad4s(I);
tens4ds ba = dyad1s(b,aa);
tens4ds b2a = dyad1s(b2,aa);
tens4ds Ia = dyad1s(I,aa);
tens4ds b_pfdi = dyad1s(pf_didc,b);
tens4ds b2_pfdi = dyad1s(pf_didc, b2);
tens4ds I_pfdi = dyad1s(pf_didc, I);
tens4ds aa_pfdi = dyad1s(pf_didc,aa);
tens4ds a4 = dyad1s(aa);
tens4ds pfdi_pfdi = dyad1s(pf_didc);
tens4ds pf_ddi5dc2= dyad4s(aa,b);
// Calculate Spatial Elasticity tensor
tens4ds D = 4/sqrt(i3)*((w11 +2*i1*w12 + w2 + i1*i1*w22)*bb
-(w12+i1*w22)*(bb2)
+ w22*b2b2 - w2*pfi4
+ (i3*w13 + i1*i3*w23)*(bI)
- i3*w23*(b2I)
+ (i3*w3 + i3*i3*w33)*(II)
- w3*i3*(pf_dcindc)
+ (i4*w14+i1*i4*w24)*(ba)
- i4*w24*(b2a)
+ i3*i4*w34*(Ia)
+ (i4*w15 + i1*i4*w25)*(b_pfdi)
- i4*w25*(b2_pfdi)
+ i3*i4*w35*(I_pfdi)
+ w45*i4*i4*(aa_pfdi)
+ w44*i4*i4*(a4)
+ i4*i4*w55*(pfdi_pfdi) + i4*w5*(pf_ddi5dc2)
);
//Stopping point for stepping thru and checking stress calculation; comment out when not testing
// double PPP=1;
/////////////////alternate form of elasticity tensor in C^2 basis instead of Cinverse///////////////////////
/*
mat3ds b3= b2*b;
tens4ds bb3 =dyad1s(b,b3);
tens4ds b2b3 =dyad1s(b2,b3);
tens4ds b3_pfdi =dyad1s(pf_didc,b3);
tens4ds b3a =dyad1s(b3,aa);
tens4ds b3b3 = dyad1s(b3);
tens4ds pfdc2dc = dyad4s(b2,b);
tens4ds Dc2 = (4/sqrt(i3))*((w11 +w2 + 2*i1*w12 + 2*i2*w13 + 2*i1*i2*w23 + i1*i1*w22 + i2*i2*w33 + i1*w3)*bb
-(w3 + w12 + i1*w13 + i2*w23 + i1*w22 + i1*i2*w33 + i1*i1*w23)*bb2
+(w22 + 2*i1*w23 + i1*i1*w33)*b2b2
- (w2 + i1*w3)*pfi4
+ (w13 + i1*w23 + i2*w33)*bb3
- (w23+i1*w33)*b2b3
+ w33*b3b3 + w3*pfdc2dc
+ (i4*w14 + i1*i4*w24 + i2*i4*w34)*ba
- (i4*w24 + i1*i4*w34)*b2a
+ i4*w34*b3a
+ (i4*w15 + i1*i4*w25 + i2*i4*w35)*b_pfdi
- (i4*w25 + i1*i4*w35)*b2_pfdi
+ i4*i4*w44*a4
+ i4*w35*b3_pfdi
+ i4*i4*w45*aa_pfdi
+ i4*i4*w55*(pfdi_pfdi) + i4*w5*(pf_ddi5dc2));
double PPP2=0;
*/
return D;
}
//! calculate strain energy density at material point
double FEPRLig::StrainEnergyDensity(FEMaterialPoint& pt)
{
double sed = 0;
FEElasticMaterialPoint& mp = *pt.ExtractData<FEElasticMaterialPoint>();
// obtain the deformation tensor F
mat3d &F = mp.m_F;
// calculate left and right Cauchy-Green tensors and their squares
mat3ds c = mp.RightCauchyGreen();
mat3ds c2 = c.sqr();
// Define the 2nd order identity tensor
mat3dd I(1);
// get the local coordinate systems
mat3d Q = GetLocalCS(pt);
// declare initial material direction vector
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();
//////////////////////////Strain invariants ///////////////////////////////////////////////
// define scalar strain invariants i1:15
double i1 = c.tr();
double i2 = 0.5*(i1*i1 - c2.tr());
double i3 = c.det();
double i4 = a0*(c*a0);
double i5 = a0*(c2*a0);
double Wfiber = 0.5*m_c1/m_c2*(exp(m_c2*pow(lam-1,2))-1);
double Wmatrix = m_u/2*(i1-3) - m_u*log(sqrt(i3));
double Wvol = m_k/2*pow(log((i5-i1*i4+i2)/(pow(i4, 2*(m_m-m_v0)*exp(-4*m_m*(lam-1))))),2);
sed = Wfiber + Wmatrix + Wvol;
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEGenericBodyForce.cpp | .cpp | 2,955 | 88 | /*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 "FEGenericBodyForce.h"
#include "FEElasticMaterial.h"
BEGIN_FECORE_CLASS(FEGenericBodyForce, FEBodyForce);
ADD_PARAMETER(m_force, "force")->setUnits(UNIT_SPECIFIC_FORCE);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEGenericBodyForce::FEGenericBodyForce(FEModel* pfem) : FEBodyForce(pfem)
{
}
//-----------------------------------------------------------------------------
vec3d FEGenericBodyForce::force(FEMaterialPoint &mp)
{
return m_force(mp);
}
//-----------------------------------------------------------------------------
mat3d FEGenericBodyForce::stiffness(FEMaterialPoint& pt)
{
return mat3ds(0, 0, 0, 0, 0, 0);
}
void FEGenericBodyForce::StiffnessMatrix(FELinearSystem& LS)
{
// Nothing to do here.
}
//=============================================================================
BEGIN_FECORE_CLASS(FEConstBodyForceOld, FEBodyForce);
ADD_PARAMETER(m_f.x, "x");
ADD_PARAMETER(m_f.y, "y");
ADD_PARAMETER(m_f.z, "z");
END_FECORE_CLASS();
//=============================================================================
BEGIN_FECORE_CLASS(FENonConstBodyForceOld, FEBodyForce);
ADD_PARAMETER(m_f[0], "x");
ADD_PARAMETER(m_f[1], "y");
ADD_PARAMETER(m_f[2], "z");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FENonConstBodyForceOld::FENonConstBodyForceOld(FEModel* pfem) : FEBodyForce(pfem)
{
}
//-----------------------------------------------------------------------------
vec3d FENonConstBodyForceOld::force(FEMaterialPoint& pt)
{
vec3d F;
F.x = m_f[0](pt);
F.y = m_f[1](pt);
F.z = m_f[2](pt);
return F;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FECoupledTransIsoMooneyRivlin.cpp | .cpp | 7,301 | 271 | /*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 "FECoupledTransIsoMooneyRivlin.h"
#include <FECore/log.h>
#include <FECore/expint_Ei.h>
#include <FECore/FEConstValueVec3.h>
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FECoupledTransIsoMooneyRivlin, FEElasticMaterial)
ADD_PARAMETER(m_c1 , FE_RANGE_GREATER(0.0), "c1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c2 , "c2")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c3 , "c3")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c4 , "c4");
ADD_PARAMETER(m_c5 , "c5");
// NOTE: This was changed from "lambda" to make it consistent with febio3, but in febiostudio1 it
// was defined as "lambda". This means that old fsm files that use this material might not read in correctly.
ADD_PARAMETER(m_flam, FE_RANGE_GREATER_OR_EQUAL(1.0), "lam_max");
ADD_PARAMETER(m_K , FE_RANGE_GREATER(0.0), "k");
ADD_PROPERTY(m_fiber, "fiber");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FECoupledTransIsoMooneyRivlin::FECoupledTransIsoMooneyRivlin(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_c1 = 0.0;
m_c2 = 0.0;
m_c3 = 0.0;
m_c4 = 0.0;
m_c5 = 0.0;
m_flam = 1.0;
m_K = 0.0;
m_fiber = nullptr;
}
//-----------------------------------------------------------------------------
//! Calculate the Cauchy stress
mat3ds FECoupledTransIsoMooneyRivlin::Stress(FEMaterialPoint& mp)
{
// get the material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate left Cauchy-Green tensor
mat3ds B = pt.LeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// get the material fiber axis
vec3d a0 = m_fiber->unitVector(mp);
// get the spatial fiber axis
vec3d a = pt.m_F*a0;
double l = a.unit();
// Invariants of B (= invariants of C)
double I1 = B.tr();
double J = pt.m_J;
// some useful tensors
mat3dd I(1.0);
mat3ds A = dyad(a);
// a. define the matrix stress
//-----------------------------
// W = c1*(I1 - 3) + c2*(I2 - 3)
// Wi = dW/dIi
double W1 = m_c1(mp);
double W2 = m_c2(mp);
double flam = m_flam(mp);
double c3 = m_c3(mp);
double c4 = m_c4(mp);
double c5 = m_c5(mp);
double K = m_K(mp);
mat3ds s = (B*(W1 + I1*W2) - B2*W2 - I*(W1 + 2.0*W2))*(2.0/J);
// b. define fiber stress
//-------------------------
if (l > 1.0)
{
double Wl = 0.0;
if (l < flam)
{
Wl = c3*(exp(c4*(l - 1.0)) - 1.0);
}
else
{
double c6 = c3*(exp(c4*(flam - 1.0)) - 1.0) - c5*flam;
Wl = c5*l + c6;
}
s += A*(Wl/J);
}
// c. define dilational stress
//------------------------------
// U(J) = 1/2*k*(lnJ)^2
double UJ = K*log(J)/J;
s += I*UJ;
return s;
}
//-----------------------------------------------------------------------------
//! Calculate the spatial elasticity tangent
tens4ds FECoupledTransIsoMooneyRivlin::Tangent(FEMaterialPoint& mp)
{
// get material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate left Cauchy-Green tensor: B = F*Ft
mat3ds B = pt.LeftCauchyGreen();
// get the material fiber axis
vec3d a0 = m_fiber->unitVector(mp);
// get the spatial fiber axis
vec3d a = pt.m_F*a0;
double l = a.unit();
// Invariants of B (= invariants of C)
double J = pt.m_J;
double I4 = l*l;
// some useful tensors
mat3dd I(1.0);
mat3ds A = dyad(a);
tens4ds IxI = dyad1s(I);
tens4ds IoI = dyad4s(I);
tens4ds BxB = dyad1s(B);
tens4ds BoB = dyad4s(B);
tens4ds AxA = dyad1s(A);
// a. matrix tangent
//----------------------------------
double W1 = m_c1(mp);
double W2 = m_c2(mp);
double flam = m_flam(mp);
double c3 = m_c3(mp);
double c4 = m_c4(mp);
double c5 = m_c5(mp);
double K = m_K(mp);
tens4ds c = BxB*(4.0*W2/J) - BoB*(4.0*W2/J) + IoI*(4.0*(W1+2.0*W2)/J);
// b. fiber tangent
// ---------------------------------
if (l > 1.0)
{
double Fl = 0.0, Fll = 0.0;
if (l < flam)
{
Fl = c3*(exp(c4*(l - 1.0)) - 1.0)/l;
Fll = -c3*(exp(c4*(l-1.0)) - 1.0)/(l*l) + c3*c4*exp(c4*(l-1.0))/l;
}
else
{
double c6 = c3*(exp(c4*(flam - 1.0)) - 1.0) - c5*flam;
Fl = c5 + c6 / l;
Fll = -c6/(l*l);
}
double W44 = (Fll - Fl/l)/(4*l*l);
c += AxA*(4.0*W44*I4*I4/J);
}
// c. dilational tangent
// ---------------------------------
double UJ = K*log(J)/J;
double UJJ = K*(1 - log(J))/(J*J);
c += IxI*(UJ + J*UJJ) - IoI*(2.0*UJ);
return c;
}
//-----------------------------------------------------------------------------
//! calculate strain energy density at material point
double FECoupledTransIsoMooneyRivlin::StrainEnergyDensity(FEMaterialPoint& mp)
{
// get the material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate left Cauchy-Green tensor
mat3ds B = pt.LeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// get the material fiber axis
vec3d a0 = m_fiber->unitVector(mp);
// get the spatial fiber axis
vec3d a = pt.m_F*a0;
double l = a.unit();
// Invariants of B (= invariants of C)
double I1 = B.tr();
double I2 = 0.5*(I1*I1 - B2.tr());
double J = pt.m_J;
double lnJ = log(J);
double c1 = m_c1(mp);
double c2 = m_c2(mp);
double flam = m_flam(mp);
double c3 = m_c3(mp);
double c4 = m_c4(mp);
double c5 = m_c5(mp);
double K = m_K(mp);
// a. define the matrix sed
//-----------------------------
// W = c1*(I1 - 3) + c2*(I2 - 3)
double sed = c1*(I1 - 3) + c2*(I2 - 3) - 2*(c1 + 2*c2)*lnJ;
// b. define fiber strain energy density
//-------------------------
if (l > 1.0)
{
if (l < flam)
{
sed += c3*(exp(-c4)*(expint_Ei(c4*l) - expint_Ei(c4))-log(l));
}
else
{
double c6 = c3*(exp(c4*(flam - 1.0)) - 1.0) - c5*flam;
sed += c5*(l-1) +c6*log(l);
}
}
// c. define dilational stress
//------------------------------
// U(J) = 1/2*k*(lnJ)^2
sed += K*lnJ*lnJ/2;
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEEllipsoidalFiberDistribution.cpp | .cpp | 18,445 | 730 | /*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 "FEEllipsoidalFiberDistribution.h"
#include "FEContinuousFiberDistribution.h"
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
//-----------------------------------------------------------------------------
// FEEllipsoidalFiberDistribution
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEEllipsoidalFiberDistribution, FEElasticMaterial)
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();
//-----------------------------------------------------------------------------
mat3ds FEEllipsoidalFiberDistribution::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// 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();
// calculate material coefficients
double ksi0 = m_ksi[0](mp);
double ksi1 = m_ksi[1](mp);
double ksi2 = m_ksi[2](mp);
double beta0 = m_beta[0](mp);
double beta1 = m_beta[1](mp);
double beta2 = m_beta[2](mp);
for (int n=0; n<MAX_INT; ++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 = 1.0 / sqrt(SQR(n0a.x / ksi0) + SQR(n0a.y / ksi1) + SQR(n0a.z / ksi2));
double beta = 1.0 / sqrt(SQR(n0a.x / beta0) + SQR(n0a.y / beta1) + SQR(n0a.z / beta2));
// --- quadrant 1,1,1 ---
// rotate to reference configuration
n0e = Q*n0a;
// 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*ksi*pow(In - 1.0, beta-1.0);
// calculate the stress
s += dyad(nt)*(Wl*wn);
}
// --- quadrant -1,1,1 ---
n0q = vec3d(-n0a.x, n0a.y, 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*ksi*pow(In - 1.0, beta-1.0);
// calculate the stress
s += dyad(nt)*(Wl*wn);
}
// --- quadrant -1,-1,1 ---
n0q = vec3d(-n0a.x, -n0a.y, 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*ksi*pow(In - 1.0, beta-1.0);
// calculate the stress
s += dyad(nt)*(Wl*wn);
}
// --- quadrant 1,-1,1 ---
n0q = vec3d(n0a.x, -n0a.y, 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*ksi*pow(In - 1.0, beta-1.0);
// calculate the stress
s += dyad(nt)*(Wl*wn);
}
}
// we multiply by two to add contribution from other half-sphere
return s*(4.0/J);
}
//-----------------------------------------------------------------------------
tens4ds FEEllipsoidalFiberDistribution::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// loop over all integration points
vec3d n0e, n0a, n0q, nt;
double In, Wll;
const double eps = 0;
tens4ds cf, cfw; cf.zero();
mat3ds N2;
tens4ds N4;
tens4ds c;
c.zero();
// calculate material coefficients
double ksi0 = m_ksi[0](mp);
double ksi1 = m_ksi[1](mp);
double ksi2 = m_ksi[2](mp);
double beta0 = m_beta[0](mp);
double beta1 = m_beta[1](mp);
double beta2 = m_beta[2](mp);
for (int n=0; n<MAX_INT; ++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 = 1.0 / sqrt(SQR(n0a.x / ksi0) + SQR(n0a.y / ksi1) + SQR(n0a.z / ksi2));
double beta = 1.0 / sqrt(SQR(n0a.x / beta0) + SQR(n0a.y / beta1) + SQR(n0a.z / beta2));
// --- quadrant 1,1,1 ---
// rotate to reference configuration
n0e = Q*n0a;
// 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
Wll = beta*(beta-1.0)*ksi*pow(In - 1.0, beta-2.0);
N2 = dyad(nt);
N4 = dyad1s(N2);
c += N4*(Wll*wn);
}
// --- quadrant -1,1,1 ---
n0q = vec3d(-n0a.x, n0a.y, 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
Wll = beta*(beta-1.0)*ksi*pow(In - 1.0, beta-2.0);
N2 = dyad(nt);
N4 = dyad1s(N2);
c += N4*(Wll*wn);
}
// --- quadrant -1,-1,1 ---
n0q = vec3d(-n0a.x, -n0a.y, 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
Wll = beta*(beta-1.0)*ksi*pow(In - 1.0, beta-2.0);
N2 = dyad(nt);
N4 = dyad1s(N2);
c += N4*(Wll*wn);
}
// --- quadrant 1,-1,1 ---
n0q = vec3d(n0a.x, -n0a.y, 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
Wll = beta*(beta-1.0)*ksi*pow(In - 1.0, beta-2.0);
N2 = dyad(nt);
N4 = dyad1s(N2);
c += N4*(Wll*wn);
}
}
// multiply by two to integrate over other half of sphere
return c*(2.0*4.0/J);
}
//-----------------------------------------------------------------------------
double FEEllipsoidalFiberDistribution::StrainEnergyDensity(FEMaterialPoint& mp)
{
double sed = 0.0;
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
// 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;
// calculate material coefficients
double ksi0 = m_ksi[0](mp);
double ksi1 = m_ksi[1](mp);
double ksi2 = m_ksi[2](mp);
double beta0 = m_beta[0](mp);
double beta1 = m_beta[1](mp);
double beta2 = 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 = 1.0 / sqrt(SQR(n0a.x / ksi0) + SQR(n0a.y / ksi1) + SQR(n0a.z / ksi2));
double beta = 1.0 / sqrt(SQR(n0a.x / beta0) + SQR(n0a.y / beta1) + SQR(n0a.z / beta2));
// --- quadrant 1,1,1 ---
// rotate to reference configuration
n0e = Q*n0a;
// 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
W = ksi*pow(In - 1.0, beta);
sed += W*wn;
}
// --- quadrant -1,1,1 ---
n0q = vec3d(-n0a.x, n0a.y, 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
W = ksi*pow(In - 1.0, beta);
sed += W*wn;
}
// --- quadrant -1,-1,1 ---
n0q = vec3d(-n0a.x, -n0a.y, 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
W = ksi*pow(In - 1.0, beta);
sed += W*wn;
}
// --- quadrant 1,-1,1 ---
n0q = vec3d(n0a.x, -n0a.y, 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
W = ksi*pow(In - 1.0, beta);
sed += W*wn;
}
}
// multiply by two to integrate over other half of sphere
return sed*2.0;
}
//-----------------------------------------------------------------------------
// FEEllipsoidalFiberDistributionOld
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEEllipsoidalFiberDistributionOld, FEElasticMaterial)
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);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
// FEEllipsoidalFiberDistributionOld
//-----------------------------------------------------------------------------
FEEllipsoidalFiberDistributionOld::FEEllipsoidalFiberDistributionOld(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_nres = 0;
}
//-----------------------------------------------------------------------------
bool FEEllipsoidalFiberDistributionOld::Init()
{
if (FEElasticMaterial::Init() == false) return false;
InitIntegrationRule();
return true;
}
//-----------------------------------------------------------------------------
void FEEllipsoidalFiberDistributionOld::InitIntegrationRule()
{
// select the integration rule
const int nint = (m_nres == 0? NSTL : NSTH );
const double* phi = (m_nres == 0? PHIL : PHIH );
const double* the = (m_nres == 0? THETAL: THETAH);
const double* w = (m_nres == 0? AREAL : AREAH );
for (int n=0; n<nint; ++n)
{
m_cth[n] = cos(the[n]);
m_sth[n] = sin(the[n]);
m_cph[n] = cos(phi[n]);
m_sph[n] = sin(phi[n]);
m_w[n] = w[n];
}
}
//-----------------------------------------------------------------------------
void FEEllipsoidalFiberDistributionOld::Serialize(DumpStream& ar)
{
FEElasticMaterial::Serialize(ar);
if (ar.IsShallow() == false)
{
if (ar.IsSaving())
{
ar << m_nres;
}
else
{
ar >> m_nres;
InitIntegrationRule();
}
}
}
//-----------------------------------------------------------------------------
mat3ds FEEllipsoidalFiberDistributionOld::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
mat3d QT = Q.transpose();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
double ksi, beta;
vec3d n0e, n0a, nt;
double In, Wl;
const double eps = 0;
mat3ds C = pt.RightCauchyGreen();
mat3ds s;
s.zero();
// material coefficients
double ksi0 = m_ksi[0](mp);
double ksi1 = m_ksi[1](mp);
double ksi2 = m_ksi[2](mp);
double beta0 = m_beta[0](mp);
double beta1 = m_beta[1](mp);
double beta2 = m_beta[2](mp);
const int nint = (m_nres == 0? NSTL : NSTH );
for (int n=0; n<nint; ++n)
{
// set the global fiber direction in reference configuration
n0e.x = m_cth[n]*m_sph[n];
n0e.y = m_sth[n]*m_sph[n];
n0e.z = m_cph[n];
// Calculate In = n0e*C*n0e
In = n0e*(C*n0e);
// only take fibers in tension into consideration
if (In > 1. + eps)
{
// get the global spatial fiber direction in current configuration
nt = (F*n0e)/sqrt(In);
// calculate the outer product of nt
mat3ds N = dyad(nt);
// get the local material fiber direction in reference configuration
n0a = QT*n0e;
// calculate material coefficients
ksi = 1.0 / sqrt(SQR(n0a.x / ksi0) + SQR(n0a.y / ksi1 ) + SQR(n0a.z / ksi2 ));
beta = 1.0 / sqrt(SQR(n0a.x / beta0) + SQR(n0a.y / beta1) + SQR(n0a.z / beta2));
// calculate strain energy derivative
Wl = beta*ksi*pow(In - 1.0, beta-1.0);
// calculate the stress
s += N*(2.0/J*In*Wl*m_w[n]);
}
}
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEEllipsoidalFiberDistributionOld::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
mat3d QT = Q.transpose();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
double ksi, beta;
vec3d n0e, n0a, nt;
double In, Wll;
const double eps = 0;
tens4ds cf, cfw; cf.zero();
mat3ds N2;
tens4ds N4;
tens4ds c;
c.zero();
// material coefficients
double ksi0 = m_ksi[0](mp);
double ksi1 = m_ksi[1](mp);
double ksi2 = m_ksi[2](mp);
double beta0 = m_beta[0](mp);
double beta1 = m_beta[1](mp);
double beta2 = m_beta[2](mp);
// right Cauchy-Green tensor: C = Ft*F
mat3ds C = (F.transpose()*F).sym();
const int nint = (m_nres == 0? NSTL : NSTH );
for (int n=0; n<nint; ++n)
{
// set the global fiber direction in reference configuration
n0e.x = m_cth[n]*m_sph[n];
n0e.y = m_sth[n]*m_sph[n];
n0e.z = m_cph[n];
// Calculate In = n0e*C*n0e
In = n0e*(C*n0e);
// only take fibers in tension into consideration
if (In > 1. + eps)
{
// get the global spatial fiber direction in current configuration
nt = (F*n0e)/sqrt(In);
// calculate the outer product of nt
N2 = dyad(nt);
// get the local material fiber direction in reference configuration
n0a = QT*n0e;
// calculate material coefficients in local fiber direction
ksi = 1.0 / sqrt(SQR(n0a.x / ksi0) + SQR(n0a.y / ksi1 ) + SQR(n0a.z / ksi2 ));
beta = 1.0 / sqrt(SQR(n0a.x / beta0) + SQR(n0a.y / beta1) + SQR(n0a.z / beta2));
// calculate strain energy derivative
Wll = beta*(beta-1.0)*ksi*pow(In - 1.0, beta-2.0);
N2 = dyad(nt);
N4 = dyad1s(N2);
c += N4*(4.0/J*In*In*Wll*m_w[n]);
}
}
return c;
}
//-----------------------------------------------------------------------------
double FEEllipsoidalFiberDistributionOld::StrainEnergyDensity(FEMaterialPoint& mp)
{
double sed = 0.0;
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
mat3d QT = Q.transpose();
// deformation gradient
mat3d &F = pt.m_F;
// loop over all integration points
double ksi, beta;
vec3d n0e, n0a, nt;
double In, W;
const double eps = 0;
mat3ds C = pt.RightCauchyGreen();
const int nint = (m_nres == 0? NSTL : NSTH );
// material coefficients
double ksi0 = m_ksi[0](mp);
double ksi1 = m_ksi[1](mp);
double ksi2 = m_ksi[2](mp);
double beta0 = m_beta[0](mp);
double beta1 = m_beta[1](mp);
double beta2 = m_beta[2](mp);
for (int n=0; n<nint; ++n)
{
// set the global fiber direction in reference configuration
n0e.x = m_cth[n]*m_sph[n];
n0e.y = m_sth[n]*m_sph[n];
n0e.z = m_cph[n];
// Calculate In = n0e*C*n0e
In = n0e*(C*n0e);
// only take fibers in tension into consideration
if (In > 1. + eps)
{
// get the global spatial fiber direction in current configuration
nt = (F*n0e)/sqrt(In);
// get the local material fiber direction in reference configuration
n0a = QT*n0e;
// calculate material coefficients
ksi = 1.0 / sqrt(SQR(n0a.x / ksi0) + SQR(n0a.y / ksi1 ) + SQR(n0a.z / ksi2 ));
beta = 1.0 / sqrt(SQR(n0a.x / beta0) + SQR(n0a.y / beta1) + SQR(n0a.z / beta2));
// calculate strain energy density
W = ksi*pow(In - 1.0, beta);
sed += W*m_w[n];
}
}
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEElasticMaterial.cpp | .cpp | 3,682 | 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.*/
#include "stdafx.h"
#include "FEElasticMaterial.h"
#include "FECore/FEModel.h"
//BEGIN_FECORE_CLASS(FEElasticMaterial, FESolidMaterial)
//END_FECORE_CLASS();
FEElasticMaterial::FEElasticMaterial(FEModel* pfem) : FESolidMaterial(pfem)
{
m_density = 1;
AddDomainParameter(new FEElasticStress());
}
//-----------------------------------------------------------------------------
FEElasticMaterial::~FEElasticMaterial()
{
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEElasticMaterial::CreateMaterialPointData()
{
return new FEElasticMaterialPoint;
}
//-----------------------------------------------------------------------------
//! calculate spatial tangent stiffness at material point, using secant method
mat3ds FEElasticMaterial::SecantStress(FEMaterialPoint& mp, bool PK2)
{
// extract the deformation gradient
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d F = pt.m_F;
double J = pt.m_J;
mat3ds E = pt.Strain();
mat3dd I(1);
mat3d FiT = F.transinv();
// calculate the 2nd P-K stress at the current deformation gradient
double W = StrainEnergyDensity(mp);
// create deformation gradient increment
double eps = 1e-9;
vec3d e[3];
e[0] = vec3d(1, 0, 0); e[1] = vec3d(0, 1, 0); e[2] = vec3d(0, 0, 1);
mat3ds S(0.0);
for (int k = 0; k < 3; ++k) {
for (int l = k; l < 3; ++l) {
// evaluate incremental stress
mat3d dF = FiT * ((e[k] & e[l]))*(eps*0.5);
mat3d F1 = F + dF;
pt.m_F = F1;
pt.m_J = pt.m_F.det();
double dW = StrainEnergyDensity(mp) - W;
// evaluate the secant modulus
S(k, l) = 2.0 * dW / eps;
}
}
// restore values
pt.m_F = F;
pt.m_J = J;
if (PK2) return S;
else {
// push from material to spatial frame
mat3ds s = pt.push_forward(S);
// return secant stress
return s;
}
}
//-----------------------------------------------------------------------------
//! return the strain energy density
double FEElasticMaterial::StrainEnergyDensity(FEMaterialPoint& pt) { return 0; }
//-----------------------------------------------------------------------------
FEElasticStress::FEElasticStress() : FEDomainParameter("stress")
{
}
FEParamValue FEElasticStress::value(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
return ep.m_s;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPeriodicSurfaceConstraint.cpp | .cpp | 20,147 | 827 | /*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 "FEPeriodicSurfaceConstraint.h"
#include "FECore/FENormalProjection.h"
#include "FECore/FEGlobalMatrix.h"
#include <FECore/FELinearSystem.h>
#include "FECore/log.h"
#include <FECore/FEMesh.h>
#include "FEBioMech.h"
//-----------------------------------------------------------------------------
// Define sliding interface parameters
BEGIN_FECORE_CLASS(FEPeriodicSurfaceConstraint, 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_btwo_pass, "two_pass");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Creates a surface for use with an FEPeriodicSurfaceConstraint interface. All surface data
//! structures are allocated.
//! Note that it is assumed that the element array is already created
//! and initialized.
bool FEPeriodicSurfaceConstraintSurface::Init()
{
// always intialize base class first!
if (FEContactSurface::Init() == false) return false;
// get the number of nodes
int nn = Nodes();
// allocate other surface data
m_gap.resize(nn); // gap funtion
m_pme.assign(nn, static_cast<FESurfaceElement*>(0)); // penetrated secondary element
m_rs.resize(nn); // natural coords of projected primary node on secondary element
m_Lm.resize(nn); // Lagrangian multipliers
// set initial values
zero(m_gap);
zero(m_Lm);
return true;
}
//-----------------------------------------------------------------------------
//! Calculate the center of mass for this surface
//!
vec3d FEPeriodicSurfaceConstraintSurface::CenterOfMass()
{
vec3d c(0, 0, 0);
int N = Nodes();
for (int i = 0; i<N; ++i) c += Node(i).m_r0;
if (N != 0) c /= (double)N;
return c;
}
//-----------------------------------------------------------------------------
void FEPeriodicSurfaceConstraintSurface::Serialize(DumpStream& ar)
{
FEContactSurface::Serialize(ar);
if (ar.IsShallow())
{
if (ar.IsSaving())
{
ar << m_Lm << m_gap;
}
else
{
ar >> m_Lm >> m_gap;
}
}
else
{
if (ar.IsSaving())
{
ar << m_gap;
ar << m_rs;
ar << m_Lm;
ar << m_nref;
}
else
{
ar >> m_gap;
ar >> m_rs;
ar >> m_Lm;
ar >> m_nref;
}
}
}
//-----------------------------------------------------------------------------
// FEPeriodicSurfaceConstraint
//-----------------------------------------------------------------------------
FEPeriodicSurfaceConstraint::FEPeriodicSurfaceConstraint(FEModel* pfem) : FEContactInterface(pfem), m_ss(pfem), m_ms(pfem), m_dofU(pfem)
{
static int count = 1;
SetID(count++);
m_stol = 0.01;
m_srad = 1.0;
m_atol = 0;
m_eps = 0;
m_btwo_pass = false;
// TODO: Can this be done in Init, since there is no error checking
if (pfem)
{
m_dofU.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
}
// set parents
m_ss.SetContactInterface(this);
m_ms.SetContactInterface(this);
m_ss.SetSibling(&m_ms);
m_ms.SetSibling(&m_ss);
}
//-----------------------------------------------------------------------------
bool FEPeriodicSurfaceConstraint::Init()
{
// create the surfaces
if (m_ss.Init() == false) return false;
if (m_ms.Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
//! build the matrix profile for use in the stiffness matrix
void FEPeriodicSurfaceConstraint::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 * 5);
int nref = m_ss.m_nref;
FESurfaceElement* pref = m_ss.m_pme[nref];
int n0 = pref->Nodes();
int nr0[FEElement::MAX_NODES];
for (int j = 0; j<n0; ++j) nr0[j] = pref->m_node[j];
assign(lm, -1);
lm[0] = m_ss.Node(nref).m_ID[dof_X];
lm[1] = m_ss.Node(nref).m_ID[dof_Y];
lm[2] = m_ss.Node(nref).m_ID[dof_Z];
lm[3] = m_ss.Node(nref).m_ID[dof_RU];
lm[4] = m_ss.Node(nref).m_ID[dof_RV];
lm[5] = m_ss.Node(nref).m_ID[dof_RW];
for (int k = 0; k<n0; ++k)
{
vector<int>& id = mesh.Node(nr0[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];
}
for (int j = 0; j<m_ss.Nodes(); ++j)
{
FESurfaceElement& me = *m_ss.m_pme[j];
int* en = &me.m_node[0];
assign(lm, -1);
int n = me.Nodes();
lm[0] = m_ss.Node(j).m_ID[dof_X];
lm[1] = m_ss.Node(j).m_ID[dof_Y];
lm[2] = m_ss.Node(j).m_ID[dof_Z];
lm[3] = m_ss.Node(j).m_ID[dof_RU];
lm[4] = m_ss.Node(j).m_ID[dof_RV];
lm[5] = m_ss.Node(j).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);
}
}
//-----------------------------------------------------------------------------
void FEPeriodicSurfaceConstraint::Activate()
{
// don't forget to call the base class
FEContactInterface::Activate();
// project primary surface onto secondary surface
ProjectSurface(m_ss, m_ms, false);
ProjectSurface(m_ms, m_ss, false);
}
//-----------------------------------------------------------------------------
//! project surface
void FEPeriodicSurfaceConstraint::ProjectSurface(FEPeriodicSurfaceConstraintSurface& ss, FEPeriodicSurfaceConstraintSurface& ms, bool bmove)
{
FEMesh& mesh = GetMesh();
FENormalProjection np(ms);
np.SetTolerance(m_stol);
np.SetSearchRadius(m_srad);
np.Init();
int i;
double rs[2];
// get the primary's center of mass
vec3d cs = ss.CenterOfMass();
// get the secondary's center of mass
vec3d cm = ms.CenterOfMass();
// get the relative distance
vec3d cr = cm - cs;
// unit vector in direction of cr
// this will serve as the projection distance
vec3d cn(cr); cn.unit();
// loop over all primary nodes
for (i = 0; i<ss.Nodes(); ++i)
{
FENode& node = ss.Node(i);
// get the nodal position
vec3d r0 = node.m_r0;
// find the intersection with the secondary surface
ss.m_pme[i] = np.Project(r0, cn, rs);
assert(ss.m_pme[i]);
ss.m_rs[i][0] = rs[0];
ss.m_rs[i][1] = rs[1];
}
// if the reference node has not been located, we do it now.
if (ss.m_nref < 0)
{
// we pick the node that is closest to the center of mass
double dmin = (ss.Node(0).m_rt - cs).norm(), d;
int nref = 0;
for (i = 1; i<ss.Nodes(); ++i)
{
d = (ss.Node(i).m_rt - cs).norm();
if (d < dmin)
{
dmin = d;
nref = i;
}
}
ss.m_nref = nref;
}
}
//-----------------------------------------------------------------------------
void FEPeriodicSurfaceConstraint::Update()
{
int i, j, ne, n0;
FESurfaceElement* pme;
FEMesh& mesh = *m_ss.GetMesh();
vec3d us, um, u0;
vec3d umi[FEElement::MAX_NODES];
// update gap functions
int npass = (m_btwo_pass ? 2 : 1);
for (int np = 0; np<npass; ++np)
{
FEPeriodicSurfaceConstraintSurface& ss = (np == 0 ? m_ss : m_ms);
FEPeriodicSurfaceConstraintSurface& ms = (np == 0 ? m_ms : m_ss);
int N = ss.Nodes();
// calculate the reference node displacement
n0 = ss.m_nref;
FENode& node = ss.Node(n0);
us = node.m_rt - node.m_r0;
// get the secondary element
pme = ss.m_pme[n0];
// calculate the secondary displacement
ne = pme->Nodes();
for (j = 0; j<ne; ++j)
{
FENode& node = ms.Node(pme->m_lnode[j]);
umi[j] = node.m_rt - node.m_r0;
}
um = pme->eval(umi, ss.m_rs[n0][0], ss.m_rs[n0][1]);
// calculate relative reference displacement
u0 = us - um;
for (i = 0; i<N; ++i)
{
// calculate the primary displacement
FENode& node = ss.Node(i);
us = node.m_rt - node.m_r0;
// get the secondary element
pme = ss.m_pme[i];
// calculate the secondary displacement
ne = pme->Nodes();
for (j = 0; j<ne; ++j)
{
FENode& node = ms.Node(pme->m_lnode[j]);
umi[j] = node.m_rt - node.m_r0;
}
um = pme->eval(umi, ss.m_rs[i][0], ss.m_rs[i][1]);
// calculate gap function
ss.m_gap[i] = us - um - u0;
}
}
}
//-----------------------------------------------------------------------------
void FEPeriodicSurfaceConstraint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
int j, k, l, m, n;
int nseln, nmeln;
double *Gr, *Gs;
// jacobian
double detJ;
vec3d dxr, dxs;
vec3d rt[FEElement::MAX_NODES], r0[FEElement::MAX_NODES];
double* w;
// natural coordinates of primary node in secondary element
double r, s;
// contact force
vec3d tc;
// shape function values
double N[FEElement::MAX_NODES];
// element contact force vector
vector<double> fe;
// the lm array for this force vector
vector<int> lm;
// the en array
vector<int> en;
vector<int> sLM;
vector<int> mLM;
vector<int> LM0;
int npass = (m_btwo_pass ? 2 : 1);
for (int np = 0; np<npass; ++np)
{
FEPeriodicSurfaceConstraintSurface& ss = (np == 0 ? m_ss : m_ms);
FEPeriodicSurfaceConstraintSurface& ms = (np == 0 ? m_ms : m_ss);
// get the reference element
int nref = ss.m_nref;
FESurfaceElement* pref = ss.m_pme[nref];
// loop over all primary facets
int ne = ss.Elements();
for (j = 0; j<ne; ++j)
{
// get the primary element
FESurfaceElement& sel = ss.Element(j);
// get the element's LM vector
ss.UnpackLM(sel, sLM);
nseln = sel.Nodes();
for (int i = 0; i<nseln; ++i)
{
r0[i] = ss.GetMesh()->Node(sel.m_node[i]).m_r0;
rt[i] = ss.GetMesh()->Node(sel.m_node[i]).m_rt;
}
w = sel.GaussWeights();
// loop over primary element nodes (which are the integration points as well)
for (n = 0; n<nseln; ++n)
{
Gr = sel.Gr(n);
Gs = sel.Gs(n);
m = sel.m_lnode[n];
// calculate jacobian
dxr = dxs = vec3d(0, 0, 0);
for (k = 0; k<nseln; ++k)
{
dxr.x += Gr[k] * r0[k].x;
dxr.y += Gr[k] * r0[k].y;
dxr.z += Gr[k] * r0[k].z;
dxs.x += Gs[k] * r0[k].x;
dxs.y += Gs[k] * r0[k].y;
dxs.z += Gs[k] * r0[k].z;
}
detJ = (dxr ^ dxs).norm();
// get primary node contact force
tc = ss.m_Lm[m] + ss.m_gap[m] * m_eps;
// get the secondary element
FESurfaceElement& mel = *ss.m_pme[m];
ms.UnpackLM(mel, mLM);
nmeln = mel.Nodes();
// isoparametric coordinates of the projected primary node
// onto the secondary element
r = ss.m_rs[m][0];
s = ss.m_rs[m][1];
// get the secondary shape function values at this primary node
if (nmeln == 4)
{
// quadrilateral
N[0] = 0.25*(1 - r)*(1 - s);
N[1] = 0.25*(1 + r)*(1 - s);
N[2] = 0.25*(1 + r)*(1 + s);
N[3] = 0.25*(1 - r)*(1 + s);
}
else if (nmeln == 3)
{
// triangle
N[0] = 1 - r - s;
N[1] = r;
N[2] = s;
}
// calculate force vector
fe.resize(3 * (nmeln + 1));
fe[0] = -detJ*w[n] * tc.x;
fe[1] = -detJ*w[n] * tc.y;
fe[2] = -detJ*w[n] * tc.z;
for (l = 0; l<nmeln; ++l)
{
fe[3 * (l + 1)] = detJ*w[n] * tc.x*N[l];
fe[3 * (l + 1) + 1] = detJ*w[n] * tc.y*N[l];
fe[3 * (l + 1) + 2] = detJ*w[n] * tc.z*N[l];
}
// 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 (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 (l = 0; l<nmeln; ++l) en[l + 1] = mel.m_node[l];
// assemble into global force vector
R.Assemble(en, lm, fe);
}
}
}
}
//-----------------------------------------------------------------------------
void FEPeriodicSurfaceConstraint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
int j, k, l, n, m;
int nseln, nmeln, ndof;
FEElementMatrix ke;
vector<int> lm(15);
vector<int> en(5);
double *Gr, *Gs, *w;
vec3d rt[FEElement::MAX_NODES], r0[FEElement::MAX_NODES];
vec3d rtm[FEElement::MAX_NODES];
double detJ, r, s;
vec3d dxr, dxs;
double H[FEElement::MAX_NODES];
vec3d gap, Lm, tc;
// curvature tensor K
double K[2][2] = { 0 };
// double scale = -0.0035*m_fem.GetMesh().GetBoundingBox().radius();
vector<int> sLM;
vector<int> mLM;
vector<int> LM0;
int n0[FEElement::MAX_NODES];
int npass = (m_btwo_pass ? 2 : 1);
for (int np = 0; np<npass; ++np)
{
FEPeriodicSurfaceConstraintSurface& ss = (np == 0 ? m_ss : m_ms);
FEPeriodicSurfaceConstraintSurface& ms = (np == 0 ? m_ms : m_ss);
// get the reference element
int nref = ss.m_nref;
FESurfaceElement* pref = ss.m_pme[nref];
// grab the data we'll need for this element
ms.UnpackLM(*pref, LM0);
int ne0 = pref->Nodes();
for (j = 0; j<ne0; ++j) n0[j] = pref->m_node[j];
r = ss.m_rs[nref][0];
s = ss.m_rs[nref][1];
double N0[FEElement::MAX_NODES];
pref->shape_fnc(N0, r, s);
// number of degrees of freedom
ndof = 3 * (1 + ne0);
vector<double> N(ndof / 3);
N[0] = 1;
for (k = 0; k<ne0; ++k) N[k + 1] = -N0[k];
// stiffness matrix
ke.resize(ndof, ndof); ke.zero();
for (k = 0; k<ndof / 3; ++k)
for (l = 0; l<ndof / 3; ++l)
{
ke[3 * k][3 * l] = m_eps*N[k] * N[l];
ke[3 * k + 1][3 * l + 1] = m_eps*N[k] * N[l];
ke[3 * k + 2][3 * l + 2] = m_eps*N[k] * N[l];
}
// fill the lm array
lm.resize(3 * (ne0 + 1));
lm[0] = ss.Node(nref).m_ID[m_dofU[0]];
lm[1] = ss.Node(nref).m_ID[m_dofU[1]];
lm[2] = ss.Node(nref).m_ID[m_dofU[2]];
for (l = 0; l<ne0; ++l)
{
lm[3 * (l + 1)] = LM0[l * 3];
lm[3 * (l + 1) + 1] = LM0[l * 3 + 1];
lm[3 * (l + 1) + 2] = LM0[l * 3 + 2];
}
// fill the en array
en.resize(ne0 + 1);
en[0] = ss.NodeIndex(nref);
for (l = 0; l<ne0; ++l) en[l + 1] = n0[l];
// assemble stiffness matrix
// psolver->AssembleStiffness(en, lm, ke);
// loop over all primary elements
int ne = ss.Elements();
for (j = 0; j<ne; ++j)
{
FESurfaceElement& se = ss.Element(j);
// get the element's LM vector
ss.UnpackLM(se, sLM);
nseln = se.Nodes();
for (int i = 0; i<nseln; ++i)
{
r0[i] = ss.GetMesh()->Node(se.m_node[i]).m_r0;
rt[i] = ss.GetMesh()->Node(se.m_node[i]).m_rt;
}
w = se.GaussWeights();
// loop over all integration points (that is nodes)
for (n = 0; n<nseln; ++n)
{
Gr = se.Gr(n);
Gs = se.Gs(n);
m = se.m_lnode[n];
// calculate jacobian
dxr = dxs = vec3d(0, 0, 0);
for (k = 0; k<nseln; ++k)
{
dxr.x += Gr[k] * r0[k].x;
dxr.y += Gr[k] * r0[k].y;
dxr.z += Gr[k] * r0[k].z;
dxs.x += Gs[k] * r0[k].x;
dxs.y += Gs[k] * r0[k].y;
dxs.z += Gs[k] * r0[k].z;
}
detJ = (dxr ^ dxs).norm();
// get the secondary element
FESurfaceElement& me = *ss.m_pme[m];
ms.UnpackLM(me, mLM);
nmeln = me.Nodes();
// get the secondary element node positions
for (k = 0; k<nmeln; ++k) rtm[k] = ms.GetMesh()->Node(me.m_node[k]).m_rt;
// primary node natural coordinates in secondary element
r = ss.m_rs[m][0];
s = ss.m_rs[m][1];
// get primary node normal force
tc = ss.m_Lm[m] + ss.m_gap[m] * m_eps; //ss.T[m];
// get the secondary shape function values at this primary node
if (nmeln == 4)
{
// quadrilateral
H[0] = 0.25*(1 - r)*(1 - s);
H[1] = 0.25*(1 + r)*(1 - s);
H[2] = 0.25*(1 + r)*(1 + s);
H[3] = 0.25*(1 - r)*(1 + s);
}
else if (nmeln == 3)
{
// triangle
H[0] = 1 - r - s;
H[1] = r;
H[2] = s;
}
// number of degrees of freedom
ndof = 3 * (1 + nmeln);
vector<double> N(ndof / 3);
N[0] = 1;
for (k = 0; k<nmeln; ++k) N[k + 1] = -H[k];
ke.resize(ndof, ndof); ke.zero();
for (k = 0; k<ndof / 3; ++k)
for (l = 0; l<ndof / 3; ++l)
{
ke[3 * k][3 * l] = w[n] * detJ*m_eps*N[k] * N[l];
ke[3 * k + 1][3 * l + 1] = w[n] * detJ*m_eps*N[k] * N[l];
ke[3 * k + 2][3 * l + 2] = w[n] * detJ*m_eps*N[k] * N[l];
}
// 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 (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] = se.m_node[n];
for (l = 0; l<nmeln; ++l) en[l + 1] = me.m_node[l];
// assemble stiffness matrix
ke.SetNodes(en);
ke.SetIndices(lm);
LS.Assemble(ke);
}
}
}
}
//-----------------------------------------------------------------------------
bool FEPeriodicSurfaceConstraint::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (m_laugon != FECore::AUGLAG_METHOD) return true;
int i;
bool bconv = true;
double g;
vec3d lm;
// calculate initial norms
double normL0 = 0;
for (i = 0; i<m_ss.Nodes(); ++i)
{
lm = m_ss.m_Lm[i];
normL0 += lm*lm;
}
for (i = 0; i<m_ms.Nodes(); ++i)
{
lm = m_ms.m_Lm[i];
normL0 += lm*lm;
}
normL0 = sqrt(normL0);
// update Lagrange multipliers and calculate current norms
double normL1 = 0;
double normgc = 0;
int N = 0;
for (i = 0; i<m_ss.Nodes(); ++i)
{
lm = m_ss.m_Lm[i] + m_ss.m_gap[i] * m_eps;
normL1 += lm*lm;
g = m_ss.m_gap[i].norm();
normgc += g*g;
++N;
}
for (i = 0; i<m_ms.Nodes(); ++i)
{
lm = m_ms.m_Lm[i] + m_ms.m_gap[i] * m_eps;
normL1 += lm*lm;
g = m_ms.m_gap[i].norm();
normgc += g*g;
++N;
}
if (N == 0) N = 1;
normL1 = sqrt(normL1);
normgc = sqrt(normgc / N);
// check convergence of constraints
feLog(" surface constraint# %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);
if (pctn >= m_atol)
{
bconv = false;
for (i = 0; i<m_ss.Nodes(); ++i)
{
// update Lagrange multipliers
m_ss.m_Lm[i] = m_ss.m_Lm[i] + m_ss.m_gap[i] * m_eps;
}
for (i = 0; i<m_ms.Nodes(); ++i)
{
// update Lagrange multipliers
m_ms.m_Lm[i] = m_ms.m_Lm[i] + m_ms.m_gap[i] * m_eps;
}
}
return bconv;
}
//-----------------------------------------------------------------------------
void FEPeriodicSurfaceConstraint::Serialize(DumpStream &ar)
{
// store contact data
FEContactInterface::Serialize(ar);
// store contact surface data
m_ms.Serialize(ar);
m_ss.Serialize(ar);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedActiveContractionUniaxialUC.h | .h | 2,859 | 83 | /*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 FEPrescribedActiveContractionUniaxialUC : public FEUncoupledMaterial
{
public:
//! constructor
FEPrescribedActiveContractionUniaxialUC(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:
FEParamDouble m_T0; // prescribed active stress
private:
vec3d m_n0; // unit vector along fiber direction (local coordinate system)
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// This material implements an active contraction model which can be used
// as a component of an uncoupled solid mixture material.
class FEPrescribedActiveContractionFiberUC : public FEUncoupledMaterial
{
public:
//! constructor
FEPrescribedActiveContractionFiberUC(FEModel* pfem);
//! stress
mat3ds DevStress(FEMaterialPoint& pt) override;
//! tangent
tens4ds DevTangent(FEMaterialPoint& pt) override;
private:
FEParamDouble m_T0; // prescribed active stress
FEParamVec3 m_n0; // unit vector along fiber direction (local coordinate system)
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEInSituStretchGradient.cpp | .cpp | 4,417 | 138 | /*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 "FEInSituStretchGradient.h"
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEInSituStretchGradient, FEPrestrainGradient)
ADD_PARAMETER(m_lam , "stretch" );
ADD_PARAMETER(m_biso, "isochoric");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEInSituStretchGradient::FEInSituStretchGradient(FEModel* pfem) : FEPrestrainGradient(pfem)
{
m_lam = 1.0;
m_biso = true;
m_fiber = nullptr;
}
//-----------------------------------------------------------------------------
bool FEInSituStretchGradient::Init()
{
m_fiber = GetFiberProperty();
if (m_fiber == nullptr) return false;
return FEPrestrainGradient::Init();
}
//-----------------------------------------------------------------------------
FEVec3dValuator* FEInSituStretchGradient::GetFiberProperty()
{
// make sure the parent material is a prestrain material
FEPrestrainMaterial* prestrainMat = dynamic_cast<FEPrestrainMaterial*>(GetParent());
if (prestrainMat == nullptr) return nullptr;
// get the elastic property
FEElasticMaterial* elasticMat = prestrainMat->GetElasticMaterial();
// make sure it has a fiber property
FEVec3dValuator* fiberProp = dynamic_cast<FEVec3dValuator*>(elasticMat->GetProperty("fiber"));
if (fiberProp == nullptr) return nullptr;
// make sure it's a vector map
return fiberProp;
}
//-----------------------------------------------------------------------------
void FEInSituStretchGradient::Serialize(DumpStream& ar)
{
FEPrestrainGradient::Serialize(ar);
if ((ar.IsShallow() == false) && ar.IsLoading())
{
m_fiber = GetFiberProperty();
assert(m_fiber);
}
}
//-----------------------------------------------------------------------------
mat3d FEInSituStretchGradient::Prestrain(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the in-situ stretch
double lam = m_lam(mp);
// get the fiber vector
vec3d a0 = m_fiber->unitVector(mp);
mat3d Q = GetLocalCS(mp);
vec3d at = Q * a0;
// set-up local uni-axial stretch tensor
double l = lam;
double li = (m_biso ? 1.0/sqrt(l) : 1.0);
// setup prestrain tensor: Fp = lam*A + li*(I - A);
mat3dd I(1.0);
mat3ds A = dyad(at);
mat3d F_bar = A * lam + (I - A)*li;
return F_bar;
}
//-----------------------------------------------------------------------------
void FEInSituStretchGradient::Initialize(const mat3d& F, FEMaterialPoint& mp)
{
/* FEElasticMaterialPoint* pt = mp.ExtractData<FEElasticMaterialPoint>();
// calculate left polar decomposition
mat3d R;
mat3ds V;
F.left_polar(V, R);
// get the fiber vector
mat3d Q = GetLocalCS(mp);
vec3d a0 = Q*vec3d(1,0,0);
vec3d a1 = F*a0;
// calculate the fiber stretch
double lam = a1.unit();
// assign it to the pre_stretch
ptis->m_lam = lam;
// setup orthogonal system
vec3d b(0,0,1);
if (b*a1 > 0.9) b = vec3d(0,1,0);
vec3d a3 = a1^b;
vec3d a2 = a3^a1;
Q(0,0) = a1.x; Q(0,1) = a2.x; Q(0,2) = a3.x;
Q(1,0) = a1.y; Q(1,1) = a2.y; Q(1,2) = a3.y;
Q(2,0) = a1.z; Q(2,1) = a2.z; Q(2,2) = a3.z;
// pt->m_Q = Q;
*/
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FENodalTargetForce.cpp | .cpp | 2,787 | 79 | /*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 "FENodalTargetForce.h"
#include "FEBioMech.h"
#include <FECore/FENodeSet.h>
#include <FECore/FEMaterialPoint.h>
#include <FECore/FENode.h>
// NOTE: We pass FEModelLoad as the base since I don't want the relative flag
BEGIN_FECORE_CLASS(FENodalTargetForce, FEModelLoad)
ADD_PARAMETER(m_w, "scale")->setUnits(UNIT_NONE)->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE);
ADD_PARAMETER(m_f, "force")->setUnits(UNIT_FORCE);
ADD_PARAMETER(m_shellBottom, "shell_bottom");
END_FECORE_CLASS();
FENodalTargetForce::FENodalTargetForce(FEModel* fem) : FENodalLoad(fem)
{
m_w = 1;
m_f = vec3d(0, 0, 0);
m_shellBottom = false;
}
void FENodalTargetForce::Activate()
{
// use a little hack to get the initial reaction forces
m_brelative = true;
FENodalLoad::Activate();
m_brelative = false;
}
bool FENodalTargetForce::SetDofList(FEDofList& dofList)
{
if (m_shellBottom)
return dofList.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_DISPLACEMENT));
else
return dofList.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
}
void FENodalTargetForce::GetNodalValues(int inode, std::vector<double>& val)
{
assert(val.size() == 3);
const FENodeSet& nset = *GetNodeSet();
const FENode& node = *nset.Node(inode);
FEMaterialPoint mp;
mp.m_r0 = node.m_r0;
mp.m_index = inode;
vec3d f = m_f(mp);
val[0] = m_rval[inode][0] * (1.0 - m_w) + m_w * f.x;
val[1] = m_rval[inode][1] * (1.0 - m_w) + m_w * f.y;
val[2] = m_rval[inode][2] * (1.0 - m_w) + m_w * f.z;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberPow.cpp | .cpp | 4,644 | 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 <limits>
#include "FEFiberPow.h"
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberPow, FEFiberMaterial)
ADD_PARAMETER(m_ksi, FE_RANGE_GREATER(0.0), "ksi")->setUnits(UNIT_PRESSURE)->setLongName("fiber modulus");
ADD_PARAMETER(m_beta, FE_RANGE_GREATER_OR_EQUAL(2.0), "beta")->setLongName("power exponent");
ADD_PARAMETER(m_tension_only, "tension_only");
END_FECORE_CLASS();
FEFiberPow::FEFiberPow(FEModel* pfem) : FEFiberMaterial(pfem)
{
m_ksi = 0.0;
m_beta = 2.0;
m_epsf = 0.0;
m_tension_only = true;
}
mat3ds FEFiberPow::FiberStress(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// initialize material constants
double ksi = m_ksi(mp);
double beta = m_beta(mp);
// deformation gradient
mat3d& F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
const double eps = 0;
mat3ds C = pt.RightCauchyGreen();
mat3ds s;
// Calculate In
double In = n0 * (C * n0);
// only take fibers in tension into consideration
if (!m_tension_only || (In - 1 >= eps))
{
// get the global spatial fiber direction in current configuration
vec3d nt = F * n0 / sqrt(In);
// calculate the outer product of nt
mat3ds N = dyad(nt);
// calculate the fiber stress magnitude
double sn = 2 * In * ksi * beta * pow(In - 1, beta - 1);
// calculate the fiber stress
s = N * (sn / J);
}
else
{
s.zero();
}
return s;
}
tens4ds FEFiberPow::FiberTangent(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// initialize material constants
double ksi = m_ksi(mp);
double beta = m_beta(mp);
// 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
double In = n0 * (C * n0);
// only take fibers in tension into consideration
const double eps = m_epsf * std::numeric_limits<double>::epsilon();
if (!m_tension_only || (In >= 1 + eps))
{
// get the global spatial fiber direction in current configuration
vec3d nt = F * n0 / sqrt(In);
// calculate the outer product of nt
mat3ds N = dyad(nt);
tens4ds NxN = dyad1s(N);
// calculate modulus
double cn = 4 * In * In * ksi * beta * (beta - 1) * pow(In - 1, beta - 2);
// calculate the fiber tangent
c = NxN * (cn / J);
}
else
{
c.zero();
}
return c;
}
double FEFiberPow::FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0)
{
double sed = 0.0;
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// initialize material constants
double ksi = m_ksi(mp);
double beta = m_beta(mp);
// loop over all integration points
const double eps = 0;
mat3ds C = pt.RightCauchyGreen();
// Calculate In = n0*C*n0
double In = n0 * (C * n0);
// only take fibers in tension into consideration
if (!m_tension_only || (In - 1 >= eps))
{
// calculate strain energy density
sed = ksi * pow(In - 1, beta);
}
return sed;
}
// define the material parameters
BEGIN_FECORE_CLASS(FEElasticFiberPow, FEElasticFiberMaterial)
ADD_PARAMETER(m_fib.m_ksi, FE_RANGE_GREATER(0.0), "ksi")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_fib.m_beta, FE_RANGE_GREATER_OR_EQUAL(2.0), "beta");
ADD_PARAMETER(m_fib.m_tension_only, "tension_only");
END_FECORE_CLASS();
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEHuiskesSupply.h | .h | 2,372 | 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 "FERemodelingElasticMaterial.h"
#include <FECore/FEMeshTopo.h>
//-----------------------------------------------------------------------------
// This class implements a material that has a constant solute supply
class FEHuiskesSupply : public FESolidSupply
{
public:
//! constructor
FEHuiskesSupply(FEModel* pfem);
//! initialization
bool Init() override;
//! solid supply
double Supply(FEMaterialPoint& pt) override;
//! tangent of solute supply with respect to strain
mat3ds Tangent_Supply_Strain(FEMaterialPoint& mp) override;
//! tangent of solute supply with respect to referential density
double Tangent_Supply_Density(FEMaterialPoint& mp) override;
public:
double m_B; //!< mass supply coefficient
double m_k; //!< specific strain energy at homeostasis
double m_D; //!< characteristic sensor distance
private:
std::vector<std::vector<int>> m_EPL; //!< list of element proximity lists
FEMeshTopo m_topo; //!< mesh topology;
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationGaussKronrod.h | .h | 2,351 | 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"
//----------------------------------------------------------------------------------
// Gauss integration scheme for continuous fiber distributions
//
class FEFiberIntegrationGaussKronrod : public FEFiberIntegrationScheme
{
public:
class Iterator;
struct GKRULE
{
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:
FEFiberIntegrationGaussKronrod(FEModel* pfem);
~FEFiberIntegrationGaussKronrod();
//! Initialization
bool Init() override;
// Serialization
void Serialize(DumpStream& ar) override;
// get the iterator
FEFiberIntegrationSchemeIterator* GetIterator(FEMaterialPoint* mp) override;
// get number of integration points
int IntegrationPoints() const override { return -1; };
protected:
bool InitRule();
protected: // parameters
GKRULE m_rule;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEActiveFiberStress.cpp | .cpp | 3,313 | 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 "FEActiveFiberStress.h"
#include "FEElasticMaterial.h"
#include <FECore/log.h>
void FEActiveFiberStress::Data::Serialize(DumpStream& ar)
{
FEMaterialPointData::Serialize(ar);
ar & m_lamp;
}
//=====================================================================================
BEGIN_FECORE_CLASS(FEActiveFiberStress, FEElasticMaterial);
ADD_PARAMETER(m_smax, "smax")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_ac, "activation");
ADD_PROPERTY(m_stl, "stl", FEProperty::Optional);
ADD_PROPERTY(m_stv, "stv", FEProperty::Optional);
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
FEActiveFiberStress::FEActiveFiberStress(FEModel* fem) : FEElasticMaterial(fem)
{
m_smax = 0.0;
m_ac = 0.0;
m_stl = nullptr;
m_stv = nullptr;
}
mat3ds FEActiveFiberStress::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double dt = 0.0;
mat3d& F = pt.m_F;
double J = pt.m_J;
mat3d Q = GetLocalCS(mp);
vec3d a0 = Q.col(0);
vec3d a = F*a0;
double lam = a.unit();
double stl = (m_stl ? m_stl->value(lam) : 1.0);
double v = 0;// (lam - lamp) / dt;
double stv = (m_stv ? m_stv->value(v) : 1.0);
mat3ds A = dyad(a);
double sf = m_ac*m_smax*stl*stv;
return A*(sf / J);
}
tens4ds FEActiveFiberStress::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double dt = 1.0;
mat3d& F = pt.m_F;
double J = pt.m_J;
mat3d Q = GetLocalCS(mp);
vec3d a0 = Q.col(0);
vec3d a = F*a0;
double lam = a.unit();
mat3ds A = dyad(a);
mat3dd I(1.0);
tens4ds AA = dyad1s(A);
double stl = (m_stl ? m_stl->value(lam) : 1.0);
double v = 0;// (lam - lamp) / dt;
double stv = (m_stv ? m_stv->value(v) : 1.0);
double dstl = (m_stl ? m_stl->derive(lam) : 0.0);
double dstv = (m_stv ? m_stv->derive(v) / dt : 0.0);
double sf = m_ac*m_smax*stl*stv;
double sf_l = m_ac*m_smax*(dstl*stv + stl*dstv);
tens4ds c = AA*((lam*sf_l - 2.0*sf) / J);
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledFiberExpLinear.h | .h | 2,651 | 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 "FEElasticFiberMaterialUC.h"
#include "FEFiberMaterial.h"
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! Uncoupled formulation of the fiber-exp-linear material for use with uncoupled
//! solid mixtures.
class FEFiberExpLinearUC : public FEFiberMaterialUncoupled
{
public:
//! Constructor
FEFiberExpLinearUC(FEModel* pfem);
//! calculate deviatoric stress at material point
mat3ds DevFiberStress(FEMaterialPoint& pt, const vec3d& n0) override;
//! calculate deviatoric tangent stiffness at material point
tens4ds DevFiberTangent(FEMaterialPoint& pt, const vec3d& n0) override;
//! calculate deviatoric strain energy density at material point
double DevFiberStrainEnergyDensity(FEMaterialPoint& pt, const vec3d& n0) override;
public:
FEParamDouble m_c3; //!< Exponential stress coefficient
FEParamDouble m_c4; //!< fiber uncrimping coefficient
FEParamDouble m_c5; //!< modulus of straightened fibers
FEParamDouble m_lam1; //!< fiber stretch for straightened fibers
DECLARE_FECORE_CLASS();
};
class FEUncoupledFiberExpLinear : public FEElasticFiberMaterialUC_T<FEFiberExpLinearUC>
{
public:
FEUncoupledFiberExpLinear(FEModel* fem) : FEElasticFiberMaterialUC_T<FEFiberExpLinearUC>(fem) {}
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FECarterHayesOld.cpp | .cpp | 4,316 | 135 | /*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 "FECarterHayesOld.h"
// define the material parameters
BEGIN_FECORE_CLASS(FECarterHayesOld, FEElasticMaterial)
ADD_PARAMETER(m_c, FE_RANGE_GREATER (0.0), "c");
ADD_PARAMETER(m_g, FE_RANGE_GREATER_OR_EQUAL(0.0), "gamma");
ADD_PARAMETER(m_v, FE_RANGE_RIGHT_OPEN(-1.0, 0.5), "v");
END_FECORE_CLASS();
//////////////////////////////////////////////////////////////////////
// FECarterHayes
//////////////////////////////////////////////////////////////////////
double FECarterHayesOld::StrainEnergy(FEMaterialPoint& mp)
{
FERemodelingMaterialPoint& rpt = *mp.ExtractData<FERemodelingMaterialPoint>();
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double detF = pt.m_J;
double lndetF = log(detF);
// calculate left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
double I1 = b.tr();
// lame parameters
double rhor = rpt.m_rhor;
double m_E = YoungModulus(rhor);
double lam = m_v*m_E/((1+m_v)*(1-2*m_v));
double mu = 0.5*m_E/(1+m_v);
double sed = mu*((I1-3)/2 - lndetF)+lam*lndetF*lndetF/2;
return sed;
}
mat3ds FECarterHayesOld::Stress(FEMaterialPoint& mp)
{
FERemodelingMaterialPoint& rpt = *mp.ExtractData<FERemodelingMaterialPoint>();
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();
// lame parameters
double rhor = rpt.m_rhor;
double m_E = YoungModulus(rhor);
double lam = m_v*m_E/((1+m_v)*(1-2*m_v));
double mu = 0.5*m_E/(1+m_v);
// Identity
mat3dd I(1);
// calculate stress
mat3ds s = (b - I)*(mu*detFi) + I*(lam*lndetF*detFi);
return s;
}
tens4ds FECarterHayesOld::Tangent(FEMaterialPoint& mp)
{
FERemodelingMaterialPoint& rpt = *mp.ExtractData<FERemodelingMaterialPoint>();
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
double detF = pt.m_J;
// lame parameters
double rhor = rpt.m_rhor;
double m_E = YoungModulus(rhor);
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;
return tens4ds(D);
}
//! calculate tangent of strain energy density with mass density
double FECarterHayesOld::Tangent_SE_Density(FEMaterialPoint& mp)
{
FERemodelingMaterialPoint& rpt = *mp.ExtractData<FERemodelingMaterialPoint>();
return StrainEnergy(mp)*m_g/rpt.m_rhor;
}
//! calculate tangent of stress with mass density
mat3ds FECarterHayesOld::Tangent_Stress_Density(FEMaterialPoint& mp)
{
FERemodelingMaterialPoint& rpt = *mp.ExtractData<FERemodelingMaterialPoint>();
return Stress(mp)*m_g/rpt.m_rhor;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEContactPotential.h | .h | 3,944 | 142 | /*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"
#include <FECore/FENodeNodeList.h>
#include <set>
class FEContactPotentialSurface : public FEContactSurface
{
public:
class Data : public FEContactMaterialPoint
{
public:
vec3d m_tc;
void Serialize(DumpStream& ar) override
{
FEContactMaterialPoint::Serialize(ar);
ar & m_tc;
}
};
public:
FEContactPotentialSurface(FEModel* fem);
void InitSurface() override;
void GetContactTraction(int nelem, vec3d& tc) override;
double GetContactArea() override;
FEMaterialPoint* CreateMaterialPoint() override;
vec3d GetContactForce() override;
};
typedef FEContactPotentialSurface::Data FECPContactPoint;
class FEContactPotential : public FEContactInterface
{
class Grid;
public:
FEContactPotential(FEModel* fem);
~FEContactPotential();
// -- From FESurfacePairConstraint
public:
//! return the primary surface
FESurface* GetPrimarySurface() override;
//! return the secondary surface
FESurface* GetSecondarySurface() override;
//! temporary construct to determine if contact interface uses nodal integration rule (or facet)
bool UseNodalIntegration() override;
// Build the matrix profile
void BuildMatrixProfile(FEGlobalMatrix& M) override;
// update
void Update() override;
// init
bool Init() override;
// serialization
void Serialize(DumpStream& ar) override;
int IntegrationRule() const { return m_integrationRule; }
// -- from FEContactInterface
public:
// The LoadVector function evaluates the "forces" that contribute to the residual of the system
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
// Evaluates the contriubtion to the stiffness matrix
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
protected:
void ElementForce(FESurfaceElement& el1, FESurfaceElement& el2, std::vector<double>& fe);
void ElementStiffness(FESurfaceElement& el1, FESurfaceElement& el2, matrix& ke);
double PotentialDerive(double r);
double PotentialDerive2(double r);
void BuildNeighborTable();
void UpdateSurface(FESurface& surface);
//! checks for edge-face intersections
bool CheckIntersections(Grid& grid);
protected:
FEContactPotentialSurface m_surf1;
FEContactPotentialSurface m_surf2;
protected:
double m_kc;
double m_p;
double m_Rin;
double m_Rout;
double m_Rmin;
double m_wtol;
bool m_checkIntersections; //!< check for edge/face intersections
int m_integrationRule = 0;
double m_c1, m_c2;
std::vector< std::set<FESurfaceElement*> > m_activeElements;
std::vector< std::set<FESurfaceElement*> > m_elemNeighbors;
FENodeNodeList m_NNL;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERemodelingElasticDomain.h | .h | 2,241 | 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 "FEElasticSolidDomain.h"
//-----------------------------------------------------------------------------
//! This class implements a domain used in an elastic remodeling problem.
//! It differs from the FEElasticSolidDomain in that it adds a stiffness matrix
//! due to the deformation dependent density.
class FERemodelingElasticDomain : public FEElasticSolidDomain
{
public:
//! constructor
FERemodelingElasticDomain(FEModel* pfem);
//! reset element data
void Reset() override;
//! initialize class
bool Init() override;
//! calculates the global stiffness matrix for this domain
void StiffnessMatrix(FELinearSystem& LS) override;
//! calculates the solid element stiffness matrix (\todo is this actually used anywhere?)
virtual void ElementStiffness(const FETimeInfo& tp, int iel, matrix& ke) override;
private:
//! density stiffness component
void ElementDensityStiffness(double dt, FESolidElement& el, matrix& ke);
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidWallInterface.h | .h | 4,677 | 148 | /*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/vector.h>
#include <FECore/FESurfaceConstraint.h>
#include <FECore/FESurface.h>
#include <FECore/vec3d.h>
#include <FECore/vec2d.h>
#include <FECore/FENNQuery.h>
//-----------------------------------------------------------------------------
class FERigidWallSurface : public FESurface
{
public:
//! constructor
FERigidWallSurface(FEModel* pfem);
//! Initializes data structures
bool Init();
//! Update the surface data
void Update() {}
//! Calculate the total traction at a node
vec3d traction(int inode);
void UpdateNormals();
void Serialize(DumpStream& ar);
//! Unpack surface element data
void UnpackLM(FEElement& el, vector<int>& lm);
public:
vector<double> m_gap; //!< gap function at nodes
vector<vec3d> m_nu; //!< secondary surface normal at primary surface node
vector<FESurfaceElement*> m_pme; //!< secondary surface element a primary surface node penetrates
vector<vec2d> m_rs; //!< natural coordinates of projection on secondary surface element
vector<vec2d> m_rsp; //!< natural coordinates at previous time step
vector<double> m_Lm; //!< Lagrange multipliers for contact pressure
vector<mat2d> m_M; //!< surface metric tensor
vector<vec2d> m_Lt; //!< Lagrange multipliers for friction
vector<double> m_off; //!< gap offset (= shell thickness)
vector<double> m_eps; //!< normal penalty factors
int m_dofX;
int m_dofY;
int m_dofZ;
FENNQuery m_NQ; //!< used in finding the secondary surface element that corresponds to a primary surface node
};
//-----------------------------------------------------------------------------
//! This class implements a sliding contact interface with a rigid wall
//! This class is a specialization of the general sliding interface where
//! the secondary surface is a rigid wall
class FERigidWallInterface : public FESurfaceConstraint
{
public:
//! constructor
FERigidWallInterface(FEModel* pfem);
~FERigidWallInterface();
//! intializes rigid wall interface
bool Init() override;
//! interface activation
void Activate() override;
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! return the primary and secondary surface
FESurface* GetSurface() override { return m_ss; }
//! return integration rule class
//! TODO: Need to fix this! Maybe move to FESurfaceConstraint?
// 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;
private:
//! project surface nodes onto plane
void ProjectSurface(FERigidWallSurface& s);
private:
//! return plane normal
vec3d PlaneNormal(const vec3d& r);
//! project node onto plane
vec3d ProjectToPlane(const vec3d& r);
public:
FERigidWallSurface* m_ss; //!< primary surface
double m_a[4]; //!< plane equation
int m_laugon; //!< augmentation flag
double m_atol; //!< augmentation tolerance
double m_eps; //!< penalty scale factor
double m_d; //!< normal offset
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidCable.cpp | .cpp | 6,842 | 242 | /*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 "FERigidCable.h"
#include "FERigidBody.h"
#include "FEMechModel.h"
#include <FECore/FELinearSystem.h>
//=============================================================================
BEGIN_FECORE_CLASS(FERigidCablePoint, FECoreClass)
ADD_PARAMETER(m_rb, "rigid_body_id")->setEnums("$(rigid_materials)")->setLongName("Rigid material");
ADD_PARAMETER(m_pos, "position");
END_FECORE_CLASS();
//=============================================================================
BEGIN_FECORE_CLASS(FERigidCable, FERigidLoad)
ADD_PARAMETER(m_force , "force");
ADD_PARAMETER(m_forceDir, "force_direction");
ADD_PARAMETER(m_brelative, "relative");
// add the points property
ADD_PROPERTY(m_points, "rigid_cable_point");
END_FECORE_CLASS();
FERigidCable::FERigidCable(FEModel* fem) : FERigidLoad(fem)
{
m_force = 0;
m_forceDir = vec3d(0,0,-1);
m_brelative = true;
}
//! initialization
bool FERigidCable::Init()
{
if (FEModelLoad::Init() == false) return false;
// make sure the force direction is a unit vector
m_forceDir.unit();
// get the rigid system
FEMechModel& fem = static_cast<FEMechModel&>(*GetFEModel());
// correct the rigid body indices
for (int i=0; i<m_points.size(); ++i)
{
m_points[i]->m_rb = fem.FindRigidbodyFromMaterialID(m_points[i]->m_rb - 1);
if (m_points[i]->m_rb == -1) return false;
}
return true;
}
// helper function for applying forces to rigid bodies
void FERigidCable::applyRigidForce(FERigidBody& rb, const vec3d& F, const vec3d& p, FEGlobalVector& R)
{
vec3d rd = (m_brelative ? p : p - rb.m_r0);
vec3d M = rd ^ F;
int n;
n = rb.m_LM[0]; if (n >= 0) R[n] += F.x;
n = rb.m_LM[1]; if (n >= 0) R[n] += F.y;
n = rb.m_LM[2]; if (n >= 0) R[n] += F.z;
n = rb.m_LM[3]; if (n >= 0) R[n] += M.x;
n = rb.m_LM[4]; if (n >= 0) R[n] += M.y;
n = rb.m_LM[5]; if (n >= 0) R[n] += M.z;
rb.m_Fr += F;
rb.m_Mr += M;
}
//! forces
void FERigidCable::LoadVector(FEGlobalVector& R)
{
int npoints = (int)m_points.size();
if (npoints == 0) return;
// get the rigid system
FEMechModel& fem = static_cast<FEMechModel&>(*GetFEModel());
// get the last rigid body
int rb0 = m_points[npoints - 1]->m_rb;
FERigidBody& bodyZ = *fem.GetRigidBody(rb0);
vec3d p0 = m_points[npoints - 1]->m_pos;
// apply the force to the last attachment point
vec3d F = m_forceDir*m_force;
applyRigidForce(bodyZ, F, p0, R);
// apply paired forces to all the other pairs
for (int i=0; i<npoints-1; ++i)
{
int rbA = m_points[i ]->m_rb;
int rbB = m_points[i+1]->m_rb;
FERigidBody& bodyA = *fem.GetRigidBody(rbA);
FERigidBody& bodyB = *fem.GetRigidBody(rbB);
vec3d r0A = m_points[i ]->m_pos;
vec3d r0B = m_points[i + 1]->m_pos;
// get the attachment position in global coordinates for body A
vec3d da0 = (m_brelative ? r0A : r0A - bodyA.m_r0);
vec3d da = bodyA.GetRotation()*da0;
vec3d a = bodyA.m_rt + da;
// get the attachment position in global coordinates for body B
vec3d db0 = (m_brelative ? r0B : r0B - bodyB.m_r0);
vec3d db = bodyB.GetRotation()*db0;
vec3d b = bodyB.m_rt + db;
// get the unit axial vector
vec3d N = b - a; N.unit();
// calculate the force value
double f = m_force;
// get the axial force
vec3d F = N*f;
// apply the forces
applyRigidForce(bodyA, F, r0A, R);
applyRigidForce(bodyB, -F, r0B, R);
}
}
//! Stiffness matrix
void FERigidCable::StiffnessMatrix(FELinearSystem& LS)
{
int npoints = (int)m_points.size();
if (npoints < 2) return;
FEMechModel& fem = static_cast<FEMechModel&>(*GetFEModel());
for (int i=0; i<npoints-1; ++i)
{
int idA = m_points[i ]->m_rb;
int idB = m_points[i+1]->m_rb;
// Get the rigid bodies
FERigidBody& bodyA = *fem.GetRigidBody(idA);
FERigidBody& bodyB = *fem.GetRigidBody(idB);
// get the force positions
vec3d ra0 = m_points[i]->m_pos;
vec3d rb0 = m_points[i+1]->m_pos;
// get the attachment position in global coordinates for body A
vec3d da0 = (m_brelative ? ra0 : ra0 - bodyA.m_r0);
vec3d da = bodyA.GetRotation()*da0;
vec3d pa = da + bodyA.m_rt;
// get the attachment position in global coordinates for body B
vec3d db0 = (m_brelative ? rb0 : rb0 - bodyB.m_r0);
vec3d db = bodyB.GetRotation()*db0;
vec3d pb = db + bodyB.m_rt;
// setup the axial unit vector
vec3d N = pb - pa;
double L = N.unit();
// build the stiffness matrix components
mat3ds NxN = dyad(N);
mat3ds M = mat3dd(1.0) - NxN;
mat3ds S = M*(m_force / L);
mat3da A(-da);
mat3da B(-db);
mat3da F(m_forceDir*m_force);
mat3d SA = S*A;
mat3d SB = S*B;
mat3d AS = A*S;
mat3d BS = B*S;
mat3d FA = F*A;
mat3d FB = F*B;
mat3d ASA = A*SA;
mat3d BSB = B*SB;
mat3d ASB = A*SB;
// put it all together
FEElementMatrix K;
K.resize(12, 12); K.zero();
K.sub(0, 0, S);
K.sub(0, 3, SA);
K.add(0, 6, S);
K.add(0, 9, SB);
K.add(3, 3, ASA - FA);
K.sub(3, 6, AS);
K.sub(3, 9, ASB);
K.sub(6, 6, S);
K.sub(6, 9, SB);
K.add(9, 9, BSB + FB);
// since this is a symmetric matrix, fill the bottom triangular part
K.copy_ut();
// TODO: Not sure why, but it looks like I need a negative sign
K *= -1.0;
// get the equation numbers
vector<int> lm(12);
lm[0] = bodyA.m_LM[0];
lm[1] = bodyA.m_LM[1];
lm[2] = bodyA.m_LM[2];
lm[3] = bodyA.m_LM[3];
lm[4] = bodyA.m_LM[4];
lm[5] = bodyA.m_LM[5];
lm[6] = bodyB.m_LM[0];
lm[7] = bodyB.m_LM[1];
lm[8] = bodyB.m_LM[2];
lm[9] = bodyB.m_LM[3];
lm[10] = bodyB.m_LM[4];
lm[11] = bodyB.m_LM[5];
// assemble into global matrix
K.SetIndices(lm);
LS.Assemble(K);
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidSolidDomain.cpp | .cpp | 7,324 | 267 | /*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 "FERigidSolidDomain.h"
#include "FERigidMaterial.h"
#include <FECore/FEMesh.h>
#include "FEBodyForce.h"
//-----------------------------------------------------------------------------
FERigidSolidDomain::FERigidSolidDomain(FEModel* pfem) : FEElasticSolidDomain(pfem) {}
//-----------------------------------------------------------------------------
// NOTE: Although this function doesn't do anything we need it because we don't
// want to call the FEElasticSolidDomain::Initialize function.
bool FERigidSolidDomain::Init()
{
if (FESolidDomain::Init() == false) return false;
// set the rigid nodes ID
// Altough this is already done in FERigidSystem::CreateObjects()
// we do it here again since the mesh adaptors will call this function
// and they may have added some nodes
FERigidMaterial* pm = dynamic_cast<FERigidMaterial*>(m_pMat); assert(pm);
if (pm == nullptr) return false;
int rbid = pm->GetRigidBodyID();
for (int i = 0; i < Nodes(); ++i)
{
FENode& node = Node(i);
node.m_rid = rbid;
}
return true;
}
//-----------------------------------------------------------------------------
// We need to override it since the base class version will not work for rigid domains.
void FERigidSolidDomain::Reset()
{
// nothing to reset here
}
//-----------------------------------------------------------------------------
//! Calculates the stiffness matrix for 3D rigid elements.
//! Rigid elements don't generate stress, so there is nothing to do here
void FERigidSolidDomain::StiffnessMatrix(FELinearSystem& LS)
{
// Caught you looking!
}
//-----------------------------------------------------------------------------
// Rigid bodies do not generate stress so there is nothing to do here
void FERigidSolidDomain::InternalForces(FEGlobalVector& R)
{
// what you looking at ?!
}
//-----------------------------------------------------------------------------
//! We don't need to update the stresses for rigid elements
//!
void FERigidSolidDomain::Update(const FETimeInfo& tp)
{
// Nothing to see here. Please move on.
}
//-----------------------------------------------------------------------------
void FERigidSolidDomain::MassMatrix(FELinearSystem& LS, double scale)
{
// Only crickets here ...
}
//-----------------------------------------------------------------------------
void FERigidSolidDomain::InertialForces(FEGlobalVector& R, std::vector<double>& F)
{
// chirp, chirp ...
}
//-----------------------------------------------------------------------------
mat3d FERigidSolidDomain::CalculateMOI()
{
mat3dd I(1); // identity tensor
mat3d moi; moi.zero();
#pragma omp parallel
{
vec3d r0[FEElement::MAX_NODES];
mat3d moi_n; moi_n.zero();
// loop over all elements
int NE = Elements();
#pragma omp for nowait
for (int iel = 0; iel < NE; ++iel)
{
FESolidElement& el = Element(iel);
// initial coordinates
int neln = el.Nodes();
for (int i = 0; i < neln; ++i) r0[i] = GetMesh()->Node(el.m_node[i]).m_r0;
// loop over integration points
double* gw = el.GaussWeights();
int nint = el.GaussPoints();
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
// calculate jacobian
double Jw = detJ0(el, n) * gw[n];
// shape functions at integration point
double* H = el.H(n);
double dens = m_pMat->Density(mp);
// add to moi
for (int i = 0; i < neln; ++i)
{
for (int j = 0; j < neln; ++j)
{
mat3d Iij = (r0[i] * r0[j]) * I - (r0[i] & r0[j]);
moi_n += Iij * (H[i] * H[j] * Jw * dens);
}
}
}
}
#pragma omp critical
moi += moi_n;
}
return moi;
}
double FERigidSolidDomain::CalculateMass()
{
double mass = 0.0;
int NE = Elements();
#pragma omp parallel for reduction(+:mass)
for (int iel = 0; iel < NE; ++iel)
{
FESolidElement& el = Element(iel);
// loop over integration points
int nint = el.GaussPoints();
double* gw = el.GaussWeights();
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
// calculate jacobian
double detJ = detJ0(el, n);
// add to total mass
mass += m_pMat->Density(mp) * detJ * gw[n];
}
}
return mass;
}
vec3d FERigidSolidDomain::CalculateCOM()
{
vec3d rc(0, 0, 0);
// loop over all elements
int NE = Elements();
#pragma omp parallel
{
vector<vec3d> r0(FEElement::MAX_NODES);
vec3d rc_n(0, 0, 0);
#pragma omp for nowait
for (int iel = 0; iel < NE; ++iel)
{
FESolidElement& el = Element(iel);
// nr of integration points
int nint = el.GaussPoints();
// number of nodes
int neln = el.Nodes();
// initial coordinates
for (int i = 0; i < neln; ++i) r0[i] = GetMesh()->Node(el.m_node[i]).m_r0;
// integration weights
double* gw = el.GaussWeights();
// loop over integration points
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
// calculate jacobian
double detJ = detJ0(el, n);
// shape functions at integration point
double* H = el.H(n);
double dens = m_pMat->Density(mp);
// add to com and moi
for (int i = 0; i < el.Nodes(); ++i)
{
rc_n += r0[i] * H[i] * detJ * gw[n] * dens;
}
}
}
#pragma omp critical
rc += rc_n;
}
return rc;
}
//-----------------------------------------------------------------------------
void FERigidSolidDomain::BodyForce(FEGlobalVector& R, FEBodyForce& BF)
{
// define some parameters that will be passed to lambda
FEBodyForce* bodyForce = &BF;
// evaluate the residual contribution
LoadVector(R, m_dofU, [=](FEMaterialPoint& mp, int node_a, std::vector<double>& fa) {
// evaluate density
double density = m_pMat->Density(mp);
// get the force
vec3d f = bodyForce->force(mp);
// get element shape functions
double* H = mp.m_shape;
// get the initial Jacobian
double J0 = mp.m_J0;
// set integrand
fa[0] = -H[node_a] * density * f.x * J0;
fa[1] = -H[node_a] * density * f.y * J0;
fa[2] = -H[node_a] * density * f.z * J0;
});
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedShellDisplacement.cpp | .cpp | 1,957 | 41 | /*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 "FEPrescribedShellDisplacement.h"
//=======================================================================================
// NOTE: I'm setting FEBoundaryCondition is the base class since I don't want to pull
// in the parameters of FEPrescribedDOF.
BEGIN_FECORE_CLASS(FEPrescribedShellDisplacement, FENodalBC)
ADD_PARAMETER(m_dof, "dof", 0, "$(dof_list:shell displacement)");
ADD_PARAMETER(m_scale, "value")->setUnits(UNIT_LENGTH)->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE);
ADD_PARAMETER(m_brelative, "relative");
END_FECORE_CLASS();
FEPrescribedShellDisplacement::FEPrescribedShellDisplacement(FEModel* fem) : FEPrescribedDOF(fem)
{
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERemodelingElasticMaterial.cpp | .cpp | 5,457 | 148 | /*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 "FERemodelingElasticMaterial.h"
#include "FECore/FECoreKernel.h"
//-----------------------------------------------------------------------------
FEMaterialPointData* FERemodelingMaterialPoint::Copy()
{
FERemodelingMaterialPoint* pt = new FERemodelingMaterialPoint(*this);
if (m_pNext) pt->m_pNext = m_pNext->Copy();
return pt;
}
//-----------------------------------------------------------------------------
void FERemodelingMaterialPoint::Init()
{
// intialize data to zero
m_sed = m_dsed = 0;
m_rhor = m_rhorp = 0;
// don't forget to initialize the base class
FEMaterialPointData::Init();
}
//-----------------------------------------------------------------------------
void FERemodelingMaterialPoint::Update(const FETimeInfo& timeInfo)
{
m_rhorp = m_rhor;
// don't forget to initialize the base class
FEMaterialPointData::Update(timeInfo);
}
//-----------------------------------------------------------------------------
void FERemodelingMaterialPoint::Serialize(DumpStream& ar)
{
FEMaterialPointData::Serialize(ar);
ar & m_sed & m_dsed;
ar & m_rhor & m_rhorp;
}
//=============================================================================
// FERemodelingElasticMaterial
//=============================================================================
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FERemodelingElasticMaterial, FEElasticMaterial)
ADD_PARAMETER(m_rhormin, "min_density")->setUnits(UNIT_DENSITY)->setLongName("min density");
ADD_PARAMETER(m_rhormax, "max_density")->setUnits(UNIT_DENSITY)->setLongName("max density");
ADD_PROPERTY(m_pBase, "solid");
ADD_PROPERTY(m_pSupp, "supply");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERemodelingElasticMaterial::FERemodelingElasticMaterial(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_pBase = 0;
m_pSupp = 0;
}
//-----------------------------------------------------------------------------
//! Strain energy density function
double FERemodelingElasticMaterial::StrainEnergyDensity(FEMaterialPoint& mp)
{
return (dynamic_cast<FERemodelingInterface*>((FEElasticMaterial*)m_pBase))->StrainEnergy(mp);
}
//-----------------------------------------------------------------------------
//! evaluate referential mass density
double FERemodelingElasticMaterial::Density(FEMaterialPoint& mp)
{
FERemodelingMaterialPoint& rpt = *(mp.ExtractData<FERemodelingMaterialPoint>());
return rpt.m_rhor;
}
//-----------------------------------------------------------------------------
//! Stress function
mat3ds FERemodelingElasticMaterial::Stress(FEMaterialPoint& mp)
{
double dt = CurrentTimeIncrement();
FERemodelingMaterialPoint& rpt = *(mp.ExtractData<FERemodelingMaterialPoint>());
// calculate the strain energy density at this material point
rpt.m_sed = StrainEnergyDensity(mp);
// calculate the sed derivative with respect to mass density at this material point
rpt.m_dsed = Tangent_SE_Density(mp);
double rhorhat = m_pSupp->Supply(mp);
rpt.m_rhor = rhorhat*dt + rpt.m_rhorp;
if (rpt.m_rhor > m_rhormax) rpt.m_rhor = m_rhormax;
if (rpt.m_rhor < m_rhormin) rpt.m_rhor = m_rhormin;
return m_pBase->Stress(mp);
}
//-----------------------------------------------------------------------------
//! Tangent of stress with strain
tens4ds FERemodelingElasticMaterial::Tangent(FEMaterialPoint& mp)
{
return m_pBase->Tangent(mp);
}
//-----------------------------------------------------------------------------
//! Tangent of strain energy density with mass density
double FERemodelingElasticMaterial::Tangent_SE_Density(FEMaterialPoint& pt)
{
return (dynamic_cast<FERemodelingInterface*>((FEElasticMaterial*)m_pBase))->Tangent_SE_Density(pt);
}
//-----------------------------------------------------------------------------
//! Tangent of stress with mass density
mat3ds FERemodelingElasticMaterial::Tangent_Stress_Density(FEMaterialPoint& pt)
{
return (dynamic_cast<FERemodelingInterface*>((FEElasticMaterial*)m_pBase))->Tangent_Stress_Density(pt);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEODFFiberDistribution.cpp | .cpp | 15,419 | 534 | /*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 "FEODFFiberDistribution.h"
#include <cmath>
#include <algorithm>
#include <FECore/FEModel.h>
#include <FECore/FEDomain.h>
#include <FECore/FENode.h>
#include <FEAMR/sphericalHarmonics.h>
#include <FEAMR/SpherePointsGenerator.h>
#include <FECore/Timer.h>
#include <iostream>
using sphere = SpherePointsGenerator;
//=============================================================================
BEGIN_FECORE_CLASS(FEFiberODF, FECoreClass)
ADD_PARAMETER(m_shpHar, "shp_harmonics");
ADD_PARAMETER(m_pos, "position");
END_FECORE_CLASS();
//=============================================================================
void FEElementODF::calcODF(std::vector<std::vector<double>>& ODFs)
{
size_t npts = sphere::GetNumNodes(FULL);
m_ODF.resize(npts);
double maxWeight = std::distance(m_weights.begin(), std::max_element(m_weights.begin(), m_weights.end()));
m_ODF = ODFs[maxWeight];
// define gradient descent step size
double eps = 0.25;
// threshold for convegence
double thresh = 5e-8;
double prevPhi = 3;
double nPhi = 2;
std::vector<std::vector<double>> logmaps(ODFs.size(), std::vector<double>(npts, 0));
while(nPhi < prevPhi)
{
// compute logmaps from current meanPODF to every other ODF
for(int index = 0; index < ODFs.size(); index++)
{
auto& currentLogmap = logmaps[index];
auto& currentODF = ODFs[index];
double currentWeight = m_weights[index];
double dot = 0;
for(int index2 = 0; index2 < npts; index2++)
{
dot += m_ODF[index2]*currentODF[index2];
}
// if the two vectors are the same, tangent is the 0 vector
if(abs(1-dot) < 10e-12)
{
logmaps[index] = std::vector<double>(npts, 0);
}
else
{
double denom = sqrt(1-dot*dot)*acos(dot);
for(int index2 = 0; index2 < npts; index2++)
{
currentLogmap[index2] = (currentODF[index2] - dot*m_ODF[index2])/denom;
}
}
}
// compute tangent vector of each
std::vector<double> phi(m_ODF.size(), 0);
for(int index = 0; index < logmaps.size(); index++)
{
for(int index2 = 0; index2 < npts; index2++)
{
phi[index2] += logmaps[index][index2]*m_weights[index];
}
}
prevPhi = nPhi;
// take norm of phi
nPhi = 0;
for(double val : phi)
{
nPhi += val*val;
}
nPhi = sqrt(nPhi);
if(nPhi < thresh) break;
// apply exponential map to mean ODF in direction of tanget vector
for(int index = 0; index < phi.size(); index++)
{
phi[index] = phi[index]*eps;
}
double normPhi = 0;
for(int index = 0; index < npts; index++)
{
normPhi += phi[index]*phi[index];
}
normPhi = sqrt(normPhi);
if(normPhi >= 10e-12)
{
for(int index = 0; index < npts; index++)
{
m_ODF[index] = cos(normPhi)*m_ODF[index] + sin(normPhi)*phi[index]/normPhi;
}
}
}
// undo sqaure root transform to obtain mean ODF
for(int index = 0; index < npts; index++)
{
m_ODF[index] = m_ODF[index]*m_ODF[index];
}
}
//=============================================================================
BEGIN_FECORE_CLASS(FEODFFiberDistribution, FEElasticMaterial)
// material properties
ADD_PROPERTY(m_pFmat, "fibers");
ADD_PROPERTY(m_ODF, "fiber_odf");
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEODFFiberDistribution::FEODFFiberDistribution(FEModel* pfem)
: FEElasticMaterial(pfem), m_lengthScale(10), m_hausd(0.05), m_grad(1.3), m_interpolate(false)
{
m_pFmat = 0;
}
//-----------------------------------------------------------------------------
FEODFFiberDistribution::~FEODFFiberDistribution()
{
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEODFFiberDistribution::CreateMaterialPointData()
{
FEMaterialPointData* mp = FEElasticMaterial::CreateMaterialPointData();
mp->SetNext(m_pFmat->CreateMaterialPointData());
return mp;
}
//-----------------------------------------------------------------------------
bool FEODFFiberDistribution::Init()
{
Timer totalTime, initTime, interpTime, reduceTime;
double remeshTime = 0;
totalTime.start();
initTime.start();
// initialize base class
if (FEElasticMaterial::Init() == false) return false;
m_interpolate = m_ODF.size() > 1;
// Get harmonic order by looking at number of coefficients of first ODF
m_order = (sqrt(8*m_ODF[0]->m_shpHar.size() + 1) - 3)/2;
// Initialize spherical coordinates and T matrix
auto& nodes = sphere::GetNodes(FULL);
getSphereCoords(nodes, m_theta, m_phi);
m_T = compSH(m_order, m_theta, m_phi);
matrix transposeT = m_T->transpose();
matrix B = (transposeT*(*m_T)).inverse()*transposeT;
// Calculate the ODFs for each of the image subregions
#pragma omp parallel for
for(int index = 0; index < m_ODF.size(); index++)
{
FEFiberODF* ODF = m_ODF[index];
reconstructODF(ODF->m_shpHar, ODF->m_ODF, m_theta, m_phi);
}
initTime.stop();
if(m_interpolate)
{
// Apply the square root transform to each ODF
std::vector<std::vector<double>> pODF;
pODF.resize(m_ODF.size());
#pragma omp parallel for
for(int index = 0; index < m_ODF.size(); index++)
{
auto& currentODF = m_ODF[index]->m_ODF;
auto& currentPODF = pODF[index];
currentPODF.resize(currentODF.size());
for(int index2 = 0; index2 < currentODF.size(); index2++)
{
currentPODF[index2] = sqrt(currentODF[index2]);
}
}
FEMesh& mesh = GetFEModel()->GetMesh();
std::vector<int> ids;
for(int index = 0; index < mesh.Domains(); index++)
{
FEDomain* domain = &mesh.Domain(index);
FEMaterial* mat = dynamic_cast<FEMaterial*>(domain->GetMaterial());
if (mat != this->GetAncestor())
{
continue;
}
#pragma omp parallel for
for(int el = 0; el < domain->Elements(); el++)
{
FEElement& element = domain->ElementRef(el);
FEElementODF* odf = new FEElementODF(m_ODF.size());
// Calculate the centroid of the element
for(int node = 0; node < element.Nodes(); node++)
{
odf->m_pos += mesh.Node(element.m_node[node]).m_r0;
}
odf->m_pos /= (double)element.Nodes();
// Calculate weight to each ODF
double sum = 0;
for(int index = 0; index < m_ODF.size(); index++)
{
auto current = m_ODF[index];
double weight = 1/(odf->m_pos - current->m_pos).Length();
odf->m_weights[index] = weight;
sum += weight;
}
// Normalize weights
for(int index = 0; index < m_ODF.size(); index++)
{
odf->m_weights[index] /= sum;
}
// Add element odf object to map
#pragma omp critical
{
m_ElODF[element.GetID()] = odf;
ids.push_back(element.GetID());
}
}
}
interpTime.start();
#pragma omp parallel for
for(int index = 0; index < ids.size(); index++)
{
m_ElODF[ids[index]]->calcODF(pODF);
}
interpTime.stop();
reduceTime.start();
#pragma omp parallel for
for(int index = 0; index < ids.size(); index++)
{
reduceODF(m_ElODF[ids[index]], B, &remeshTime);
}
reduceTime.stop();
}
else
{
reduceODF(m_ODF[0], B, new double);
}
totalTime.stop();
// std::cout << "Total Time: " << totalTime.peek() << std::endl;
// std::cout << "Init Time: " << initTime.peek() << std::endl;
// std::cout << "Interp Time: " << interpTime.peek() << std::endl;
// std::cout << "Reduce Time: " << reduceTime.peek() << std::endl;
// std::cout << "Remesh Time: " << remeshTime/36 << std::endl;
return true;
}
void FEODFFiberDistribution::reduceODF(FEBaseODF* ODF, matrix& B, double* time)
{
Timer remeshTime;
vector<double>* sphHar;
if(dynamic_cast<FEElementODF*>(ODF))
{
// Calculate spherical harmonics
int sphrHarmSize = (m_order+1)*(m_order+2)/2;
sphHar = new vector<double>(sphrHarmSize);
B.mult(ODF->m_ODF, *sphHar);
}
else
{
sphHar = &dynamic_cast<FEFiberODF*>(ODF)->m_shpHar;
}
// Calculate the graident
std::vector<double> gradient;
altGradient(m_order, ODF->m_ODF, gradient);
// Remesh the sphere
vector<vec3i> elems;
remeshTime.start();
remesh(gradient, m_lengthScale, m_hausd, m_grad, ODF->m_nodePos, elems);
remeshTime.stop();
#pragma omp critical
*time += remeshTime.peek();
int NN = ODF->m_nodePos.size();
int NE = elems.size();
// Convert the new coordinates to spherical coordinates
std::vector<double> theta;
std::vector<double> phi;
getSphereCoords(ODF->m_nodePos, theta, phi);
// Compute the new ODF values
auto T = compSH(m_order, theta, phi);
ODF->m_ODF.resize(NN);
(*T).mult(*sphHar, ODF->m_ODF);
// Properly scale the ODF values based on the sizes of the surrounding elements
vector<double> area(NN, 0);
for(int index = 0; index < NE; index++)
{
int n0 = elems[index].x;
int n1 = elems[index].y;
int n2 = elems[index].z;
vec3d n01 = ODF->m_nodePos[n0] - ODF->m_nodePos[n1];
vec3d n02 = ODF->m_nodePos[n0] - ODF->m_nodePos[n2];
double temp = (n01^n02).Length()/2;
area[n0] += temp;
area[n1] += temp;
area[n2] += temp;
}
// Normalize the ODF
double sum = 0;
for(int index = 0; index < NN; index++)
{
double val = ODF->m_ODF[index];
if(ODF->m_nodePos[index].z != 0)
{
val *= 2;
}
val *= area[index];
ODF->m_ODF[index] = val;
sum += val;
}
for(int index = 0; index < NN; index++)
{
ODF->m_ODF[index] /= sum;
}
if(dynamic_cast<FEElementODF*>(ODF))
{
delete sphHar;
}
}
//-----------------------------------------------------------------------------
//! Serialization
void FEODFFiberDistribution::Serialize(DumpStream& ar)
{
FEElasticMaterial::Serialize(ar);
if (ar.IsShallow()) return;
}
//-----------------------------------------------------------------------------
//! calculate stress at material point
mat3ds FEODFFiberDistribution::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEFiberMaterialPoint& fp = *mp.ExtractData<FEFiberMaterialPoint>();
FEBaseODF* ODF;
if(m_interpolate)
{
ODF = m_ElODF[mp.m_elem->GetID()];
}
else
{
ODF = m_ODF[0];
}
// calculate stress
mat3ds s; s.zero();
// get the local coordinate system
mat3d Q = GetLocalCS(mp);
for(int index = 0; index < ODF->m_ODF.size(); index++)
{
// evaluate ellipsoidally distributed material coefficients
double R = ODF->m_ODF[index];
// convert fiber to global coordinates
vec3d n0 = Q*ODF->m_nodePos[index];
// calculate the stress
s += m_pFmat->FiberStress(mp, fp.FiberPreStretch(n0))*(R);
}
return s;
}
//-----------------------------------------------------------------------------
//! calculate tangent stiffness at material point
tens4ds FEODFFiberDistribution::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEFiberMaterialPoint& fp = *mp.ExtractData<FEFiberMaterialPoint>();
FEBaseODF* ODF;
if(m_interpolate)
{
ODF = m_ElODF[mp.m_elem->GetID()];
}
else
{
ODF = m_ODF[0];
}
// get the local coordinate system
mat3d Q = GetLocalCS(mp);
// initialize stress tensor
tens4ds c;
c.zero();
for(int index = 0; index < ODF->m_ODF.size(); index++)
{
//evaluate ellipsoidally distributed material coefficients
double R = ODF->m_ODF[index];
// convert fiber to global coordinates
vec3d n0 = Q*ODF->m_nodePos[index];
// calculate the tangent
c += m_pFmat->FiberTangent(mp, fp.FiberPreStretch(n0))*(R);
}
return c;
}
//-----------------------------------------------------------------------------
//! calculate strain energy density at material point
double FEODFFiberDistribution::StrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEFiberMaterialPoint& fp = *mp.ExtractData<FEFiberMaterialPoint>();
FEBaseODF* ODF;
if(m_interpolate)
{
ODF = m_ElODF[mp.m_elem->GetID()];
}
else
{
ODF = m_ODF[0];
}
// get the local coordinate system
mat3d Q = GetLocalCS(mp);
double sed = 0.0;
for(int index = 0; index < ODF->m_ODF.size(); index++)
{
// evaluate ellipsoidally distributed material coefficients
double R = ODF->m_ODF[index];
// convert fiber to global coordinates
vec3d n0 = Q*ODF->m_nodePos[index];
// calculate the stress
sed += m_pFmat->FiberStrainEnergyDensity(mp, fp.FiberPreStretch(n0))*(R);
}
return sed;
} | C++ |
3D | febiosoftware/FEBio | FEBioMech/FEStVenantKirchhoff.cpp | .cpp | 3,639 | 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 "FEStVenantKirchhoff.h"
// define the material parameters
BEGIN_FECORE_CLASS(FEStVenantKirchhoff, 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");
END_FECORE_CLASS();
//////////////////////////////////////////////////////////////////////
// FEStVenantKirchhoff
//////////////////////////////////////////////////////////////////////
FEStVenantKirchhoff::FEStVenantKirchhoff(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_E = 0.0;
m_v = 0.0;
}
//-----------------------------------------------------------------------------
mat3ds FEStVenantKirchhoff::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// lame parameters
double lam = m_v*m_E/((1+m_v)*(1-2*m_v));
double mu = 0.5*m_E/(1+m_v);
// calculate left Cauchy-Green tensor (ie. b-matrix)
mat3ds b = pt.LeftCauchyGreen();
mat3ds b2 = b.sqr();
// calculate trace of Green-Lagrance strain tensor
double trE = 0.5*(b.tr()-3);
// inverse jacobian
double Ji = 1.0 / pt.m_J;
// calculate stress
// s = (lam*trE*b - mu*(b2 - b))/J;
return b*(lam*trE*Ji) + (b2 - b)*(mu*Ji);
}
//-----------------------------------------------------------------------------
tens4ds FEStVenantKirchhoff::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// jacobian
double J = 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 / J;
double mu1 = mu / J;
// left cauchy-green matrix (i.e. the 'b' matrix)
mat3ds b = pt.LeftCauchyGreen();
tens4ds c = dyad1s(b)*lam1 + dyad4s(b)*(2.0*mu1);
return c;
}
//-----------------------------------------------------------------------------
double FEStVenantKirchhoff::StrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// lame parameters
double lam = m_v*m_E/((1+m_v)*(1-2*m_v));
double mu = 0.5*m_E/(1+m_v);
// calculate right Cauchy-Green tensor
mat3ds C = pt.RightCauchyGreen();
mat3ds C2 = C.sqr();
double trE = 0.5*(C.tr()-3);
double trE2 = 0.25*(C2.tr() - 2*C.tr() + 3);
// calculate strain energy density
return lam*trE*trE/2.0 + mu*trE2;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedShellDisplacement.h | .h | 1,479 | 37 | /*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 FEPrescribedShellDisplacement : public FEPrescribedDOF
{
public:
FEPrescribedShellDisplacement(FEModel* fem);
private:
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEContactInterface.cpp | .cpp | 6,923 | 209 | /*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 "FEContactInterface.h"
#include "FEElasticMaterial.h"
#include "FEContactSurface.h"
#include "FERigidMaterial.h"
#include <FECore/FEModel.h>
#include <FECore/FESolver.h>
#include <FECore/FEAnalysis.h>
#include "FEElasticDomain.h"
BEGIN_FECORE_CLASS(FEContactInterface, FESurfacePairConstraint)
ADD_PARAMETER(m_psf , "penalty_sf" )->setLongName("penalty scale factor")->SetFlags(FEParamFlag::FE_PARAM_HIDDEN);
ADD_PARAMETER(m_psfmax, "max_penalty_sf")->setLongName("Max penalty scale factor")->SetFlags(FEParamFlag::FE_PARAM_HIDDEN);
END_FECORE_CLASS();
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
FEContactInterface::FEContactInterface(FEModel* pfem) : FESurfacePairConstraint(pfem)
{
m_laugon = FECore::PENALTY_METHOD; // penalty method by default
m_psf = 1.0; // default scale factor is 1
m_psfmax = 0; // default max scale factor is not set
}
FEContactInterface::~FEContactInterface()
{
}
//-----------------------------------------------------------------------------
//! This function calculates a contact penalty parameter based on the
//! material and geometrical properties of the primary and secondary surfaces
//!
double FEContactInterface::AutoPenalty(FESurfaceElement& el, FESurface &s)
{
// get the mesh
FEMesh& m = GetFEModel()->GetMesh();
// get the element this surface element belongs to
FEElement* pe = el.m_elem[0].pe;
if (pe == nullptr) return 0.0;
// make sure the parent domain is an elastic domain
FEElasticDomain* ped = dynamic_cast<FEElasticDomain*>(pe->GetMeshPartition());
if (ped == nullptr)
{
if ((pe = el.m_elem[1].pe) == nullptr) return 0.0;
ped = dynamic_cast<FEElasticDomain*>(pe->GetMeshPartition());
if (ped == nullptr) return 0.0;
}
double eps = 0;
// extract the elastic material
FEElasticMaterial* pme = GetFEModel()->GetMaterial(pe->GetMatID())->ExtractProperty<FEElasticMaterial>();
if (pme) {
// get a material point
FEMaterialPoint& mp = *pe->GetMaterialPoint(0);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// backup the material point
mat3d F0 = pt.m_F;
double J0 = pt.m_J;
mat3ds s0 = pt.m_s;
// override the material point
pt.m_F = mat3dd(1.0);
pt.m_J = 1;
pt.m_s.zero();
// get the tangent (stiffness) and it inverse (compliance) at this point
tens4ds S = pme->Tangent(mp);
tens4ds C = S.inverse();
// restore the material point
pt.m_F = F0;
pt.m_J = J0;
pt.m_s = s0;
// evaluate element surface normal at parametric center
vec3d t[2];
s.CoBaseVectors0(el, 0, 0, t);
vec3d n = t[0] ^ t[1];
n.unit();
// evaluate normal component of the compliance matrix
// (equivalent to inverse of Young's modulus along n)
eps = 1./(n*(vdotTdotv(n, C, n)*n));
}
else {
FERigidMaterial* prm = GetFEModel()->GetMaterial(pe->GetMatID())->ExtractProperty<FERigidMaterial>();
if (prm == nullptr) return 0.0;
eps = prm->m_E/(1 - pow(prm->m_v, 2));
if (eps == 0) return 0.0;
}
// get the area of the surface element
double A = s.FaceArea(el);
// get the volume of the volume element
double V = m.ElementVolume(*pe);
// If the surface is a rigid shell with no thickness (which is allowed),
// the volume can be zero. In that case, we return 0. (which is also backward compatible)
if (V == 0.0) return 0.0;
return eps*A/V;
}
//-----------------------------------------------------------------------------
void FEContactInterface::Serialize(DumpStream& ar)
{
// store base class
FESurfacePairConstraint::Serialize(ar);
// save parameters
ar & m_laugon;
if ((ar.IsShallow() == false) && (ar.IsSaving() == false))
{
FEMesh& mesh = GetFEModel()->GetMesh();
FESurface* ss = GetPrimarySurface();
FESurface* ms = GetSecondarySurface();
if (ss) mesh.AddSurface(ss);
if (ms) mesh.AddSurface(ms);
}
}
//-----------------------------------------------------------------------------
// serialize the pointers
void FEContactInterface::SerializeElementPointers(FEContactSurface& ss, FEContactSurface& ms, DumpStream& ar)
{
if (ar.IsSaving())
{
int NE = ss.Elements();
for (int i = 0; i<NE; ++i)
{
FESurfaceElement& se = ss.Element(i);
for (int j = 0; j<se.GaussPoints(); ++j)
{
FEContactMaterialPoint& ds = static_cast<FEContactMaterialPoint&>(*se.GetMaterialPoint(j));
int eid0 = (ds.m_pme ? ds.m_pme ->m_lid : -1);
int eid1 = (ds.m_pmep ? ds.m_pmep->m_lid : -1);
ar << eid0 << eid1;
}
}
}
else
{
int lid = -1;
int NE = ss.Elements();
for (int i = 0; i<NE; ++i)
{
FESurfaceElement& se = ss.Element(i);
for (int j = 0; j<se.GaussPoints(); ++j)
{
FEContactMaterialPoint& ds = static_cast<FEContactMaterialPoint&>(*se.GetMaterialPoint(j));
int eid0 = -1, eid1 = -1;
ar >> eid0 >> eid1;
if (eid0 >= 0) ds.m_pme = &ms.Element(eid0); else ds.m_pme = nullptr;
if (eid1 >= 0) ds.m_pmep = &ms.Element(eid1); else ds.m_pmep = nullptr;
}
}
}
}
//-----------------------------------------------------------------------------
double FEContactInterface::GetPenaltyScaleFactor()
{
FEModel& fem = *GetFEModel();
FEAnalysis* pstep = fem.GetCurrentStep();
FESolver* psolver = pstep->GetFESolver();
int naug = psolver->m_naug;
double psf = pow(m_psf,naug);
if ((m_psfmax > 0) && (psf > m_psfmax)) psf = m_psfmax;
return psf;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEGenericTransIsoHyperelasticUC.cpp | .cpp | 9,650 | 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) 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 "FEGenericTransIsoHyperelasticUC.h"
#include <FECore/MMath.h>
#include <FECore/MObj2String.h>
#include <FECore/log.h>
#include <FECore/FEConstValueVec3.h>
BEGIN_FECORE_CLASS(FEGenericTransIsoHyperelasticUC, FEUncoupledMaterial)
ADD_PARAMETER(m_exp, "W");
ADD_PARAMETER(m_printDerivs, "print_derivs");
ADD_PROPERTY(m_fiber, "fiber");
END_FECORE_CLASS();
FEGenericTransIsoHyperelasticUC::FEGenericTransIsoHyperelasticUC(FEModel* fem) : FEUncoupledMaterial(fem)
{
m_fiber = nullptr;
m_printDerivs = false;
}
bool FEGenericTransIsoHyperelasticUC::Init()
{
vector<string> vars = { "I1", "I2", "I4", "I5" };
// add all user parameters
FEParameterList& pl = GetParameterList();
FEParamIterator pi = pl.first();
m_param.clear();
for (int i = 0; i < pl.Parameters(); ++i, ++pi)
{
FEParam& p = *pi;
if (p.GetFlags() & FEParamFlag::FE_PARAM_USER)
{
vars.push_back(p.name());
m_param.push_back((double*)p.data_ptr());
}
}
// create math object
m_W.AddVariables(vars);
if (m_W.Create(m_exp) == false) return false;
// calculate all derivatives
MITEM W1 = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(0), 1));
MITEM W2 = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(1), 1));
MITEM W4 = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(2), 1));
MITEM W5 = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(3), 1));
MITEM WJ = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(4), 1));
m_W1.AddVariables(vars); m_W1.SetExpression(W1);
m_W2.AddVariables(vars); m_W2.SetExpression(W2);
m_W4.AddVariables(vars); m_W4.SetExpression(W4);
m_W5.AddVariables(vars); m_W5.SetExpression(W5);
MITEM W11 = MDerive(m_W1.GetExpression(), *m_W1.Variable(0), 1);
MITEM W12 = MDerive(m_W1.GetExpression(), *m_W1.Variable(1), 1);
MITEM W14 = MDerive(m_W1.GetExpression(), *m_W1.Variable(2), 1);
MITEM W15 = MDerive(m_W1.GetExpression(), *m_W1.Variable(3), 1);
MITEM W22 = MDerive(m_W2.GetExpression(), *m_W2.Variable(1), 1);
MITEM W24 = MDerive(m_W2.GetExpression(), *m_W2.Variable(2), 1);
MITEM W25 = MDerive(m_W2.GetExpression(), *m_W2.Variable(3), 1);
MITEM W44 = MDerive(m_W4.GetExpression(), *m_W4.Variable(2), 1);
MITEM W45 = MDerive(m_W4.GetExpression(), *m_W4.Variable(3), 1);
MITEM W55 = MDerive(m_W5.GetExpression(), *m_W5.Variable(3), 1);
m_W11.AddVariables(vars); m_W11.SetExpression(W11);
m_W12.AddVariables(vars); m_W12.SetExpression(W12);
m_W14.AddVariables(vars); m_W14.SetExpression(W14);
m_W15.AddVariables(vars); m_W15.SetExpression(W15);
m_W22.AddVariables(vars); m_W22.SetExpression(W22);
m_W24.AddVariables(vars); m_W24.SetExpression(W24);
m_W25.AddVariables(vars); m_W25.SetExpression(W25);
m_W44.AddVariables(vars); m_W44.SetExpression(W44);
m_W45.AddVariables(vars); m_W45.SetExpression(W45);
m_W55.AddVariables(vars); m_W55.SetExpression(W55);
if (m_printDerivs)
{
feLog("\nStrain energy and derivatives for material %d (%s):\n", GetID(), GetName().c_str());
MObj2String o2s;
string sW = o2s.Convert(m_W); feLog("W = %s\n", sW.c_str());
string sW1 = o2s.Convert(m_W1); feLog("W1 = %s\n", sW1.c_str());
string sW2 = o2s.Convert(m_W2); feLog("W2 = %s\n", sW2.c_str());
string sW4 = o2s.Convert(m_W4); feLog("W4 = %s\n", sW4.c_str());
string sW5 = o2s.Convert(m_W5); feLog("W5 = %s\n", sW5.c_str());
string sW11 = o2s.Convert(m_W11); feLog("W11 = %s\n", sW11.c_str());
string sW12 = o2s.Convert(m_W12); feLog("W12 = %s\n", sW12.c_str());
string sW14 = o2s.Convert(m_W14); feLog("W14 = %s\n", sW14.c_str());
string sW15 = o2s.Convert(m_W15); feLog("W15 = %s\n", sW15.c_str());
string sW22 = o2s.Convert(m_W22); feLog("W22 = %s\n", sW22.c_str());
string sW24 = o2s.Convert(m_W24); feLog("W24 = %s\n", sW24.c_str());
string sW25 = o2s.Convert(m_W25); feLog("W25 = %s\n", sW25.c_str());
string sW44 = o2s.Convert(m_W44); feLog("W44 = %s\n", sW44.c_str());
string sW45 = o2s.Convert(m_W45); feLog("W45 = %s\n", sW45.c_str());
string sW55 = o2s.Convert(m_W55); feLog("W55 = %s\n", sW55.c_str());
}
return FEElasticMaterial::Init();
}
mat3ds FEGenericTransIsoHyperelasticUC::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d& F = pt.m_F;
double J = pt.m_J;
mat3ds B = pt.DevLeftCauchyGreen();
mat3ds B2 = B.sqr();
// get the material fiber axis
vec3d a0 = m_fiber->unitVector(mp);
// get the spatial fiber axis
vec3d a = pt.m_F*a0;
double lam = a.unit()*pow(J, -1./3.);
// evaluate the invariants
double I1 = B.tr();
double I2 = 0.5*(I1*I1 - B2.tr());
double I4 = lam*lam;
double I5 = I4*(a*(B*a));
// create the parameter list
vector<double> v = { I1, I2, I4, I5 };
for (int i = 0; i < m_param.size(); ++i) v.push_back(*m_param[i]);
// evaluate the strain energy derivatives
double W1 = m_W1.value_s(v);
double W2 = m_W2.value_s(v);
double W4 = m_W4.value_s(v);
double W5 = m_W5.value_s(v);
mat3dd I(1.0);
mat3ds AxA = dyad(a);
mat3ds aBa = dyads(a, B*a);
mat3ds T = (B*(W1 + W2*I1) - B2*W2 + AxA*(W4*I4) + aBa*(W5*I4));
mat3ds s = T.dev()*(2.0 / J);
// all done!
return s;
}
tens4ds FEGenericTransIsoHyperelasticUC::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d& F = pt.m_F;
double J = pt.m_J;
mat3ds B = pt.DevLeftCauchyGreen();
mat3ds B2 = B.sqr();
// get the material fiber axis
vec3d a0 = m_fiber->unitVector(mp);
// get the spatial fiber axis
vec3d a = pt.m_F*a0;
double lam = a.unit()*pow(J, -1./3.);
// evaluate the invariants
double I1 = B.tr();
double I2 = 0.5*(I1*I1 - B2.tr());
double I4 = lam*lam;
double I5 = I4*(a*(B*a));
// evaluate parameters
vector<double> v = { I1, I2, I4, I5 };
for (int i = 0; i < m_param.size(); ++i) v.push_back(*m_param[i]);
// evaluate strain energy derivatives
double W1 = m_W1.value_s(v);
double W2 = m_W2.value_s(v);
double W4 = m_W4.value_s(v);
double W5 = m_W5.value_s(v);
double W11 = m_W11.value_s(v);
double W12 = m_W12.value_s(v);
double W14 = m_W14.value_s(v);
double W15 = m_W15.value_s(v);
double W22 = m_W22.value_s(v);
double W24 = m_W24.value_s(v);
double W25 = m_W25.value_s(v);
double W44 = m_W44.value_s(v);
double W45 = m_W45.value_s(v);
double W55 = m_W55.value_s(v);
// a few tensors we'll need
mat3dd I(1.0);
tens4ds IxI = dyad1s(I);
tens4ds BxB = dyad1s(B);
tens4ds B2xB2 = dyad1s(B2);
tens4ds BoB2 = dyad1s(B, B2);
tens4ds Ib = dyad4s(B);
tens4ds II = dyad4s(I);
mat3ds A = dyad(a);
mat3ds aBa = dyads(a, B*a);
tens4ds Baa = dyad1s(B, A);
tens4ds BaBa = dyad1s(B, aBa);
tens4ds B2A = dyad1s(B2, A);
tens4ds B2aBa = dyad1s(B2, aBa);
tens4ds AxA = dyad1s(A);
tens4ds AaBa = dyad1s(A, aBa);
tens4ds aBaaBa = dyad1s(aBa, aBa);
tens4ds AB = dyad5s(A, B);
// evaluate deviatoric stress
mat3ds T = (B*(W1 + W2*I1) - B2*W2 + A*(W4*I4) + aBa*(W5*I4))*(2./J);
mat3ds devT = T.dev();
// stiffness contribution from isotropic terms
tens4ds dw_iso = BxB*(W11 + 2.0*W12*I1 + W22*I1*I1 + W2) - BoB2*(W12 + W22*I1) + B2xB2*W22 - Ib*W2;
// stiffness constribution from anisotropic terms
tens4ds dw_ani = Baa*(I4*(W14 + W24*I1)) \
+ BaBa*(I4*(W15 + W25*I1)) \
- B2A*(I4*W24) \
- B2aBa*(I4*W25) \
+ AxA*(I4*I4*W44) \
+ AaBa*(I4*I4*W45) \
+ aBaaBa*(I4*I4*W55) \
+ AB*(I4*W5);
// isochoric contribution
tens4ds dw = dw_iso + dw_ani;
mat3ds dwoI = dw.contract();
double trDw = dw.tr();
tens4ds cw = dw - dyad1s(dwoI, I) / 3.0 + IxI*(trDw / 9.0);
// put it all together
tens4ds c = (II - IxI/3.0)*(2.0/3.0*T.tr()) - dyad1s(devT, I)*(2.0/3.0) + cw*(4. / J);
// all done
return c;
}
double FEGenericTransIsoHyperelasticUC::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d& F = pt.m_F;
double J = pt.m_J;
mat3ds B = pt.DevLeftCauchyGreen();
mat3ds B2 = B.sqr();
// get the material fiber axis
vec3d a0 = m_fiber->unitVector(mp);
// get the spatial fiber axis
vec3d a = pt.m_F*a0;
double lam = a.unit()*pow(J, -1./3.);
// evaluate the invariants
double I1 = B.tr();
double I2 = 0.5*(I1*I1 - B2.tr());
double I4 = lam*lam;
double I5 = I4*(a*(B*a));
// evaluate parameters
vector<double> v = { I1, I2, I4, I5 };
for (int i = 0; i < m_param.size(); ++i) v.push_back(*m_param[i]);
double W = m_W.value_s(v);
return W;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedActiveContractionUniaxial.cpp | .cpp | 4,732 | 153 | /*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 "FEPrescribedActiveContractionUniaxial.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEPrescribedActiveContractionUniaxial, FEElasticMaterial)
ADD_PARAMETER(m_T0 , "T0" );
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPrescribedActiveContractionUniaxial::FEPrescribedActiveContractionUniaxial(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_T0 = 0.0;
}
//-----------------------------------------------------------------------------
bool FEPrescribedActiveContractionUniaxial::Validate()
{
if (FEElasticMaterial::Validate() == false) return false;
// fiber direction in local coordinate system (reference configuration)
m_n0.x = 1;
m_n0.y = 0;
m_n0.z = 0;
return true;
}
//-----------------------------------------------------------------------------
void FEPrescribedActiveContractionUniaxial::Serialize(DumpStream& ar)
{
FEElasticMaterial::Serialize(ar);
if (ar.IsShallow()) return;
ar & m_n0;
}
//-----------------------------------------------------------------------------
mat3ds FEPrescribedActiveContractionUniaxial::Stress(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// evaluate fiber direction in global coordinate system
vec3d n0 = Q*m_n0;
// evaluate the deformed fiber direction
vec3d nt = F*n0;
mat3ds N = dyad(nt);
// evaluate the active stress
double T0 = m_T0(mp);
mat3ds s = N*(T0/J);
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEPrescribedActiveContractionUniaxial::Tangent(FEMaterialPoint &mp)
{
tens4ds c;
c.zero();
return c;
}
//=============================================================================
// define the material parameters
BEGIN_FECORE_CLASS(FEPrescribedActiveContractionFiber, FEElasticMaterial)
ADD_PARAMETER(m_T0 , "T0" );
ADD_PROPERTY(m_fiber, "fiber")->SetDefaultType("vector");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPrescribedActiveContractionFiber::FEPrescribedActiveContractionFiber(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_T0 = 0.0;
m_fiber = nullptr;
}
//-----------------------------------------------------------------------------
mat3ds FEPrescribedActiveContractionFiber::Stress(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// evaluate fiber direction in global coordinate system
vec3d n0 = Q*m_fiber->unitVector(mp);
// evaluate the deformed fiber direction
vec3d nt = F*n0;
mat3ds N = dyad(nt);
// evaluate the active stress
double T0 = m_T0(mp);
mat3ds s = N*(T0/J);
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEPrescribedActiveContractionFiber::Tangent(FEMaterialPoint &mp)
{
tens4ds c;
c.zero();
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FECarterHayesOld.h | .h | 2,703 | 71 | /*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 "FERemodelingElasticMaterial.h"
//-----------------------------------------------------------------------------
//! This is a neo-Hookean material whose Young's modulus is evaluated from the density
//! according to the power-law relation proposed by Carter and Hayes for trabecular bone
class FECarterHayesOld : public FEElasticMaterial, public FERemodelingInterface
{
public:
FECarterHayesOld(FEModel* pfem) : FEElasticMaterial(pfem) {}
public:
double m_c; //!< c coefficient for calculation of Young's modulus
double m_g; //!< gamma exponent for calculation of Young's modulus
double m_v; //!< prescribed 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;
public: // --- remodeling interface ---
//! calculate strain energy density at material point
double StrainEnergy(FEMaterialPoint& pt) override;
//! calculate tangent of strain energy density with mass density
double Tangent_SE_Density(FEMaterialPoint& pt) override;
//! calculate tangent of stress with mass density
mat3ds Tangent_Stress_Density(FEMaterialPoint& pt) override;
//! return Young's modulus
double YoungModulus(double rhor) { return m_c*pow(rhor, m_g);}
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEArrudaBoyce.cpp | .cpp | 4,611 | 153 | /*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 "FEArrudaBoyce.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEArrudaBoyce, FEUncoupledMaterial)
ADD_PARAMETER(m_mu, FE_RANGE_GREATER(0.0), "mu")->setUnits(UNIT_PRESSURE)->setLongName("initial modulus");
ADD_PARAMETER(m_N , FE_RANGE_GREATER(0.0), "N" )->setLongName("links");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEArrudaBoyce::FEArrudaBoyce(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_N = 1;
}
//-----------------------------------------------------------------------------
mat3ds FEArrudaBoyce::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
const double a[] = {0.5, 0.1, 11.0/350.0, 19.0/1750.0, 519.0/134750.0};
// deformation gradient
double J = pt.m_J;
// left Cauchy-Green tensor and its square
mat3ds B = pt.DevLeftCauchyGreen();
// Invariants of B_tilde
double I1 = B.tr();
// strain energy derivative
double mu = m_mu(mp);
double f = I1/m_N;
double W1 = mu*(a[0] + (2.0*a[1] + (3*a[2] + (4*a[3] + 5*a[4]*f)*f)*f)*f);
// T = FdW/dCFt
mat3ds T = B*W1;
// deviatoric Cauchy stress is 2/J*dev(T)
return T.dev()*(2.0/J);
}
//-----------------------------------------------------------------------------
tens4ds FEArrudaBoyce::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
const double a[] = {0.5, 0.1, 11.0/350.0, 19.0/1750.0, 519.0/134750.0};
// 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();
// Invariants of B (= invariants of C)
double I1 = B.tr();
// --- TODO: put strain energy derivatives here ---
// W1 = dW/dI1
// W11 = d2W/dI1^2
double mu = m_mu(mp);
const double f = I1/m_N;
double W1 = mu*(a[0] + (2*a[1] + (3*a[2] + (4*a[3] + 5*a[4]*f)*f)*f)*f);
double W11 = 2.0*mu*(a[1] + (3*a[2] + (6*a[3] + 10*a[4]*f)*f)*f)/m_N;
// ---
// calculate dWdC:C
double WC = W1*I1;
// calculate C:d2WdCdC:C
double CWWC = W11*I1*I1;
// deviatoric cauchy-stress
mat3ds T = B * W1;
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);
// d2W/dCdC:C
mat3ds WCCxC = B*(W11*I1);
tens4ds cw = BxB*(W11*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;
return c;
}
//-----------------------------------------------------------------------------
double FEArrudaBoyce::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
const double a[] = {0.5, 0.1, 11.0/350.0, 19.0/1750.0, 519.0/134750.0};
// left Cauchy-Green tensor and its square
mat3ds B = pt.DevLeftCauchyGreen();
// Invariants of B_tilde
double I1 = B.tr();
double I1i = I1, ti = 3, Ni = 1;
double mu = m_mu(mp);
double sed = a[0]*(I1-3);
for (int i=1; i<5; ++i) {
Ni *= m_N;
ti *= 3;
I1i *= I1;
sed += a[i]*(I1i - ti)/Ni;
}
sed *= mu;
return sed;
} | C++ |
3D | febiosoftware/FEBio | FEBioMech/FETiedElasticInterface.cpp | .cpp | 40,150 | 1,106 | /*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 "FETiedElasticInterface.h"
#include "FECore/FEModel.h"
#include "FECore/FEAnalysis.h"
#include "FECore/FENormalProjection.h"
#include <FECore/FELinearSystem.h>
#include "FECore/log.h"
//-----------------------------------------------------------------------------
// Define sliding interface parameters
BEGIN_FECORE_CLASS(FETiedElasticInterface, FEContactInterface)
ADD_PARAMETER(m_laugon , "laugon" )->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0");
ADD_PARAMETER(m_atol , "tolerance" );
ADD_PARAMETER(m_gtol , "gaptol" );
ADD_PARAMETER(m_epsn , "penalty" );
ADD_PARAMETER(m_bautopen , "auto_penalty" );
ADD_PARAMETER(m_bupdtpen , "update_penalty" );
ADD_PARAMETER(m_btwo_pass, "two_pass" );
ADD_PARAMETER(m_knmult , "knmult" );
ADD_PARAMETER(m_stol , "search_tol" );
ADD_PARAMETER(m_bsymm , "symmetric_stiffness");
ADD_PARAMETER(m_srad , "search_radius" );
ADD_PARAMETER(m_naugmin , "minaug" );
ADD_PARAMETER(m_naugmax , "maxaug" );
ADD_PARAMETER(m_bflips , "flip_primary" );
ADD_PARAMETER(m_bflipm , "flip_secondary" );
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FETiedElasticSurface::Data::Data()
{
m_Gap = vec3d(0,0,0);
m_dg = vec3d(0,0,0);
m_nu = vec3d(0,0,0);
m_rs = vec2d(0,0);
m_Lmd = vec3d(0,0,0);
m_tr = vec3d(0,0,0);
m_epsn = 1.0;
}
//-----------------------------------------------------------------------------
void FETiedElasticSurface::Data::Serialize(DumpStream& ar)
{
FEContactMaterialPoint::Serialize(ar);
ar & m_Gap;
ar & m_dg;
ar & m_nu;
ar & m_rs;
ar & m_Lmd;
ar & m_epsn;
ar & m_tr;
}
void FETiedElasticSurface::Data::Init()
{
FEContactMaterialPoint::Init();
m_Gap = vec3d(0, 0, 0);
m_dg = vec3d(0, 0, 0);
m_nu = vec3d(0, 0, 0);
m_rs = vec2d(0, 0);
m_Lmd = vec3d(0, 0, 0);
m_tr = vec3d(0, 0, 0);
m_epsn = 1.0;
}
//-----------------------------------------------------------------------------
// FETiedElasticSurface
//-----------------------------------------------------------------------------
FETiedElasticSurface::FETiedElasticSurface(FEModel* pfem) : FEContactSurface(pfem)
{
}
//-----------------------------------------------------------------------------
bool FETiedElasticSurface::Init()
{
// initialize surface data first
if (FEContactSurface::Init() == false) return false;
// allocate node normals
m_nn.assign(Nodes(), vec3d(0,0,0));
// initialize nodal force vector
m_Fn.assign(Nodes(), vec3d(0, 0, 0));
return true;
}
//-----------------------------------------------------------------------------
//! This function calculates the node normal. Due to the piecewise continuity
//! of the surface elements this normal is not uniquely defined so in order to
//! obtain a unique normal the normal is averaged for each node over all the
//! element normals at the node
void FETiedElasticSurface::UpdateNodeNormals()
{
int N = Nodes(), i, j, ne, jp1, jm1;
vec3d y[FEElement::MAX_NODES], n;
// zero nodal normals
zero(m_nn);
// loop over all elements
for (i=0; i<Elements(); ++i)
{
FESurfaceElement& el = Element(i);
ne = el.Nodes();
// get the nodal coordinates
for (j=0; j<ne; ++j) y[j] = Node(el.m_lnode[j]).m_rt;
// calculate the normals
for (j=0; j<ne; ++j)
{
jp1 = (j+1)%ne;
jm1 = (j+ne-1)%ne;
n = (y[jp1] - y[j]) ^ (y[jm1] - y[j]);
m_nn[el.m_lnode[j]] += n;
}
}
// normalize all vectors
for (i=0; i<N; ++i) m_nn[i].unit();
}
//-----------------------------------------------------------------------------
//! create material point data
FEMaterialPoint* FETiedElasticSurface::CreateMaterialPoint()
{
return new FETiedElasticSurface::Data;
}
//-----------------------------------------------------------------------------
void FETiedElasticSurface::Serialize(DumpStream& ar)
{
FEContactSurface::Serialize(ar);
ar & m_nn & m_Fn;
}
//-----------------------------------------------------------------------------
void FETiedElasticSurface::GetVectorGap(int nface, vec3d& pg)
{
FESurfaceElement& el = Element(nface);
int ni = el.GaussPoints();
pg = vec3d(0,0,0);
for (int k = 0; k < ni; ++k)
{
Data& data = static_cast<Data&>(*el.GetMaterialPoint(k));
pg += data.m_dg;
}
pg /= ni;
}
//-----------------------------------------------------------------------------
void FETiedElasticSurface::GetContactTraction(int nface, vec3d& pt)
{
FESurfaceElement& el = Element(nface);
int ni = el.GaussPoints();
pt = vec3d(0,0,0);
for (int k = 0; k < ni; ++k)
{
Data& data = static_cast<Data&>(*el.GetMaterialPoint(k));
pt += data.m_tr;
}
pt /= ni;
}
//-----------------------------------------------------------------------------
vec3d FETiedElasticSurface::GetContactForce()
{
// initialize contact force
vec3d f(0, 0, 0);
// loop over all elements of the primary surface
for (int i = 0; i < m_Fn.size(); ++i) f += m_Fn[i];
return f;
}
//-----------------------------------------------------------------------------
//! evaluate net contact area
double FETiedElasticSurface::GetContactArea()
{
// initialize contact area
double a = 0;
// loop over all elements of the primary surface
for (int n = 0; n < Elements(); ++n)
{
FESurfaceElement& el = Element(n);
int nint = el.GaussPoints();
// evaluate the contact force for that element
for (int i = 0; i < nint; ++i)
{
// get data for this integration point
Data& data = static_cast<Data&>(*el.GetMaterialPoint(i));
double T = data.m_tr.norm2();
if (data.m_pme && (T != 0.0))
{
// get the base vectors
vec3d g[2];
CoBaseVectors(el, i, g);
// normal (magnitude = area)
vec3d n = g[0] ^ g[1];
// gauss weight
double w = el.GaussWeights()[i];
// contact force
a += n.norm() * w;
}
}
}
return a;
}
//-----------------------------------------------------------------------------
// FETiedElasticInterface
//-----------------------------------------------------------------------------
FETiedElasticInterface::FETiedElasticInterface(FEModel* pfem) : FEContactInterface(pfem), m_ss(pfem), m_ms(pfem)
{
static int count = 1;
SetID(count++);
// initial values
m_knmult = 1;
m_atol = 0.1;
m_epsn = 1;
m_btwo_pass = false;
m_stol = 0.01;
m_bsymm = true;
m_srad = 1.0;
m_gtol = -1; // we use augmentation tolerance by default
m_bautopen = false;
m_bupdtpen = false;
m_naugmin = 0;
m_naugmax = 10;
m_bflips = false;
m_bflipm = false;
// set parents
m_ss.SetContactInterface(this);
m_ms.SetContactInterface(this);
m_ss.SetSibling(&m_ms);
m_ms.SetSibling(&m_ss);
}
//-----------------------------------------------------------------------------
FETiedElasticInterface::~FETiedElasticInterface()
{
}
//-----------------------------------------------------------------------------
bool FETiedElasticInterface::Init()
{
// initialize surface data
if (m_ss.Init() == false) return false;
if (m_ms.Init() == false) return false;
// Flip secondary and primary surfaces, if requested.
// Note that we turn off those flags because otherwise we keep flipping, each time we get here (e.g. in optimization)
// TODO: Of course, we shouldn't get here more than once. I think we also get through the FEModel::Reset, so I'll have
// look into that.
if (m_bflips) { m_ss.Invert(); m_bflips = false; }
if (m_bflipm) { m_ms.Invert(); m_bflipm = false; }
return true;
}
//-----------------------------------------------------------------------------
//! build the matrix profile for use in the stiffness matrix
void FETiedElasticInterface::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 ndpn = 6;
vector<int> lm(ndpn*FEElement::MAX_NODES*2);
int npass = (m_btwo_pass?2:1);
for (int np=0; np<npass; ++np)
{
FETiedElasticSurface& ss = (np == 0? m_ss : m_ms);
int ni = 0, k, l;
for (int j=0; j<ss.Elements(); ++j)
{
FESurfaceElement& se = ss.Element(j);
int nint = se.GaussPoints();
int* sn = &se.m_node[0];
for (k=0; k<nint; ++k, ++ni)
{
FETiedElasticSurface::Data& pt = static_cast<FETiedElasticSurface::Data&>(*se.GetMaterialPoint(k));
FESurfaceElement* pe = pt.m_pme;
if (pe != 0)
{
FESurfaceElement& me = *pe;
int* mn = &me.m_node[0];
assign(lm, -1);
int nseln = se.Nodes();
int nmeln = me.Nodes();
for (l=0; l<nseln; ++l)
{
vector<int>& id = mesh.Node(sn[l]).m_ID;
lm[ndpn*l ] = id[dof_X];
lm[ndpn*l+1] = id[dof_Y];
lm[ndpn*l+2] = id[dof_Z];
lm[ndpn*l+3] = id[dof_RU];
lm[ndpn*l+4] = id[dof_RV];
lm[ndpn*l+5] = id[dof_RW];
}
for (l=0; l<nmeln; ++l)
{
vector<int>& id = mesh.Node(mn[l]).m_ID;
lm[ndpn*(l+nseln) ] = id[dof_X];
lm[ndpn*(l+nseln)+1] = id[dof_Y];
lm[ndpn*(l+nseln)+2] = id[dof_Z];
lm[ndpn*(l+nseln)+3] = id[dof_RU];
lm[ndpn*(l+nseln)+4] = id[dof_RV];
lm[ndpn*(l+nseln)+5] = id[dof_RW];
}
K.build_add(lm);
}
}
}
}
}
//-----------------------------------------------------------------------------
void FETiedElasticInterface::UpdateAutoPenalty()
{
// calculate the penalty
if (m_bautopen)
{
CalcAutoPenalty(m_ss);
if (m_btwo_pass) CalcAutoPenalty(m_ms);
}
}
//-----------------------------------------------------------------------------
void FETiedElasticInterface::Activate()
{
// don't forget to call the base class
FEContactInterface::Activate();
UpdateAutoPenalty();
// project the surfaces onto each other
// this will evaluate the gap functions in the reference configuration
InitialProjection(m_ss, m_ms);
if (m_btwo_pass) InitialProjection(m_ms, m_ss);
}
//-----------------------------------------------------------------------------
void FETiedElasticInterface::CalcAutoPenalty(FETiedElasticSurface& s)
{
// loop over all surface elements
for (int i=0; i<s.Elements(); ++i)
{
// get the surface element
FESurfaceElement& el = s.Element(i);
// calculate a penalty
double eps = AutoPenalty(el, s);
// assign to integation points of surface element
int nint = el.GaussPoints();
for (int j=0; j<nint; ++j)
{
FETiedElasticSurface::Data& pt = static_cast<FETiedElasticSurface::Data&>(*el.GetMaterialPoint(j));
pt.m_epsn = eps;
}
}
}
//-----------------------------------------------------------------------------
// Perform initial projection between tied surfaces in reference configuration
void FETiedElasticInterface::InitialProjection(FETiedElasticSurface& ss, FETiedElasticSurface& ms)
{
FESurfaceElement* pme;
vec3d r, nu;
double rs[2];
// initialize projection data
FENormalProjection np(ms);
np.SetTolerance(m_stol);
np.SetSearchRadius(m_srad);
np.Init();
// let's count the number of contact pairs we find.
int contacts = 0;
// loop over all integration points
int n = 0;
for (int i=0; i<ss.Elements(); ++i)
{
FESurfaceElement& el = ss.Element(i);
int nint = el.GaussPoints();
for (int j=0; j<nint; ++j, ++n)
{
// calculate the global position of the integration point
r = ss.Local2Global(el, j);
// calculate the normal at this integration point
nu = ss.SurfaceNormal(el, j);
// find the intersection point with the secondary surface
pme = np.Project2(r, nu, rs);
FETiedElasticSurface::Data& pt = static_cast<FETiedElasticSurface::Data&>(*el.GetMaterialPoint(j));
pt.m_pme = pme;
pt.m_rs[0] = rs[0];
pt.m_rs[1] = rs[1];
if (pme)
{
// the node could potentially be in contact
// find the global location of the intersection point
vec3d q = ms.Local2Global(*pme, rs[0], rs[1]);
// calculate the gap function
pt.m_Gap = q - r;
contacts++;
}
else
{
// the node is not in contact
pt.m_Gap = vec3d(0,0,0);
}
}
}
// 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());
}
}
//-----------------------------------------------------------------------------
// Evaluate gap functions for position and fluid pressure
void FETiedElasticInterface::ProjectSurface(FETiedElasticSurface& ss, FETiedElasticSurface& ms)
{
FESurfaceElement* pme;
vec3d r;
// loop over all integration points
for (int i=0; i<ss.Elements(); ++i)
{
FESurfaceElement& el = ss.Element(i);
int nint = el.GaussPoints();
for (int j=0; j<nint; ++j)
{
FETiedElasticSurface::Data& pt = static_cast<FETiedElasticSurface::Data&>(*el.GetMaterialPoint(j));
// calculate the global position of the integration point
r = ss.Local2Global(el, j);
// calculate the normal at this integration point
pt.m_nu = ss.SurfaceNormal(el, j);
// if this node is tied, evaluate gap functions
pme = pt.m_pme;
if (pme)
{
// find the global location of the intersection point
vec3d q = ms.Local2Global(*pme, pt.m_rs[0], pt.m_rs[1]);
// calculate the gap function
vec3d g = q - r;
pt.m_dg = g - pt.m_Gap;
pt.m_gap = pt.m_dg.norm();
}
else
{
// the node is not tied
pt.m_dg = vec3d(0,0,0);
pt.m_gap = 0.0;
}
}
}
}
//-----------------------------------------------------------------------------
void FETiedElasticInterface::Update()
{
// project the surfaces onto each other
// this will update the gap functions as well
ProjectSurface(m_ss, m_ms);
if (m_btwo_pass) ProjectSurface(m_ms, m_ss);
}
//-----------------------------------------------------------------------------
void FETiedElasticInterface::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
int i, j, k;
vector<int> sLM, mLM, LM, en;
vector<double> fe;
const int MN = FEElement::MAX_NODES;
double detJ[MN], w[MN], *Hs, Hm[MN];
double N[8*MN];
// zero nodal forces
m_ss.m_Fn.assign(m_ss.Nodes(), vec3d(0, 0, 0));
m_ms.m_Fn.assign(m_ms.Nodes(), vec3d(0, 0, 0));
// Update auto-penalty if requested
if (m_bupdtpen && (GetFEModel()->GetCurrentStep()->GetFESolver()->m_niter == 0))
UpdateAutoPenalty();
// loop over the nr of passes
int npass = (m_btwo_pass?2:1);
for (int np=0; np<npass; ++np)
{
// get primary and secondary surface
FETiedElasticSurface& ss = (np == 0? m_ss : m_ms);
FETiedElasticSurface& ms = (np == 0? m_ms : m_ss);
// loop over all primary elements
for (i=0; i<ss.Elements(); ++i)
{
// get the surface element
FESurfaceElement& se = ss.Element(i);
// get the nr of nodes and integration points
int nseln = se.Nodes();
int nint = se.GaussPoints();
// copy the LM vector; we'll need it later
ss.UnpackLM(se, sLM);
// we calculate all the metrics we need before we
// calculate the nodal forces
for (j=0; j<nint; ++j)
{
// get the base vectors
vec3d g[2];
ss.CoBaseVectors(se, j, g);
// jacobians: J = |g0xg1|
detJ[j] = (g[0] ^ g[1]).norm();
// integration weights
w[j] = se.GaussWeights()[j];
}
// loop over all integration points
// note that we are integrating over the current surface
for (j=0; j<nint; ++j)
{
FETiedElasticSurface::Data& pt = static_cast<FETiedElasticSurface::Data&>(*se.GetMaterialPoint(j));
// get the secondary element
FESurfaceElement* pme = pt.m_pme;
if (pme)
{
// get the secondary element
FESurfaceElement& me = *pme;
// get the nr of secondary element nodes
int nmeln = me.Nodes();
// copy LM vector
ms.UnpackLM(me, mLM);
// calculate degrees of freedom
int ndof = 3*(nseln + nmeln);
// build the LM vector
LM.resize(ndof);
for (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 (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 (k=0; k<nseln; ++k) en[k ] = se.m_node[k];
for (k=0; k<nmeln; ++k) en[k+nseln] = me.m_node[k];
// get primary element shape functions
Hs = se.H(j);
// get secondary element shape functions
double r = pt.m_rs[0];
double s = pt.m_rs[1];
me.shape_fnc(Hm, r, s);
// gap function
vec3d dg = pt.m_dg;
// lagrange multiplier
vec3d Lm = pt.m_Lmd;
// penalty
double eps = m_epsn*pt.m_epsn;
// contact traction
vec3d t = Lm + dg*eps;
pt.m_tr = t;
// calculate the force vector
fe.resize(ndof);
zero(fe);
for (k=0; k<nseln; ++k)
{
N[3*k ] = Hs[k]*t.x;
N[3*k+1] = Hs[k]*t.y;
N[3*k+2] = Hs[k]*t.z;
}
for (k=0; k<nmeln; ++k)
{
N[3*(k+nseln) ] = -Hm[k]*t.x;
N[3*(k+nseln)+1] = -Hm[k]*t.y;
N[3*(k+nseln)+2] = -Hm[k]*t.z;
}
for (k=0; k<ndof; ++k) fe[k] += N[k]*detJ[j]*w[j];
for (int k = 0; k < nseln; ++k) ss.m_Fn[se.m_lnode[k]] += vec3d(fe[3 * k], fe[3 * k + 1], fe[3 * k + 2]);
for (int k = 0; k < nmeln; ++k) ms.m_Fn[me.m_lnode[k]] += vec3d(fe[3 * nseln + 3 * k], fe[3 * nseln + 3 * k + 1], fe[3 * nseln + 3 * k + 2]);
// assemble the global residual
R.Assemble(en, LM, fe);
}
}
}
}
}
//-----------------------------------------------------------------------------
void FETiedElasticInterface::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
int i, j, k, l;
vector<int> sLM, mLM, LM, en;
const int MN = FEElement::MAX_NODES;
double detJ[MN], w[MN], *Hs, Hm[MN];
FEElementMatrix ke;
// see how many reformations we've had to do so far
int nref = GetSolver()->m_nref;
// set higher order stiffness mutliplier
// NOTE: this algrotihm doesn't really need this
// but I've added this functionality to compare with the other contact
// algorithms and to see the effect of the different stiffness contributions
double knmult = m_knmult;
if (m_knmult < 0)
{
int ni = int(-m_knmult);
if (nref >= ni)
{
knmult = 1;
feLog("Higher order stiffness terms included.\n");
}
else knmult = 0;
}
// do single- or two-pass
int npass = (m_btwo_pass?2:1);
for (int np=0; np < npass; ++np)
{
// get the primary and secondary surface
FETiedElasticSurface& ss = (np == 0? m_ss : m_ms);
FETiedElasticSurface& ms = (np == 0? m_ms : m_ss);
// loop over all primary elements
for (i=0; i<ss.Elements(); ++i)
{
// get ths primary element
FESurfaceElement& se = ss.Element(i);
// get nr of nodes and integration points
int nseln = se.Nodes();
int nint = se.GaussPoints();
// copy the LM vector
ss.UnpackLM(se, sLM);
// we calculate all the metrics we need before we
// calculate the nodal forces
for (j=0; j<nint; ++j)
{
// get the base vectors
vec3d g[2];
ss.CoBaseVectors(se, j, g);
// jacobians: J = |g0xg1|
detJ[j] = (g[0] ^ g[1]).norm();
// integration weights
w[j] = se.GaussWeights()[j];
}
// loop over all integration points
for (j=0; j<nint; ++j)
{
FETiedElasticSurface::Data& pt = static_cast<FETiedElasticSurface::Data&>(*se.GetMaterialPoint(j));
// get the secondary element
FESurfaceElement* pme = pt.m_pme;
if (pme)
{
FESurfaceElement& me = *pme;
// get the nr of secondary nodes
int nmeln = me.Nodes();
// copy the LM vector
ms.UnpackLM(me, mLM);
int ndpn; // number of dofs per node
int ndof; // number of dofs in stiffness matrix
// calculate degrees of freedom for elastic-on-elastic contact
ndpn = 3;
ndof = ndpn*(nseln + nmeln);
// build the LM vector
LM.resize(ndof);
for (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 (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 (k=0; k<nseln; ++k) en[k ] = se.m_node[k];
for (k=0; k<nmeln; ++k) en[k+nseln] = me.m_node[k];
// primary shape functions
Hs = se.H(j);
// secondary shape functions
double r = pt.m_rs[0];
double s = pt.m_rs[1];
me.shape_fnc(Hm, r, s);
// get primary normal vector
vec3d nu = pt.m_nu;
// gap function
vec3d dg = pt.m_dg;
// lagrange multiplier
vec3d Lm = pt.m_Lmd;
// penalty
double eps = m_epsn*pt.m_epsn;
// contact traction
vec3d t = Lm + dg*eps;
// create the stiffness matrix
ke.resize(ndof, ndof); ke.zero();
// --- S O L I D - S O L I D C O N T A C T ---
// a. I-term
//------------------------------------
for (k=0; k<nseln; ++k) {
for (l=0; l<nseln; ++l)
{
ke[ndpn*k ][ndpn*l ] += eps*Hs[k]*Hs[l]*detJ[j]*w[j];
ke[ndpn*k + 1][ndpn*l + 1] += eps*Hs[k]*Hs[l]*detJ[j]*w[j];
ke[ndpn*k + 2][ndpn*l + 2] += eps*Hs[k]*Hs[l]*detJ[j]*w[j];
}
for (l=0; l<nmeln; ++l)
{
ke[ndpn*k ][ndpn*(nseln+l) ] += -eps*Hs[k]*Hm[l]*detJ[j]*w[j];
ke[ndpn*k + 1][ndpn*(nseln+l) + 1] += -eps*Hs[k]*Hm[l]*detJ[j]*w[j];
ke[ndpn*k + 2][ndpn*(nseln+l) + 2] += -eps*Hs[k]*Hm[l]*detJ[j]*w[j];
}
}
for (k=0; k<nmeln; ++k) {
for (l=0; l<nseln; ++l)
{
ke[ndpn*(nseln+k) ][ndpn*l ] += -eps*Hm[k]*Hs[l]*detJ[j]*w[j];
ke[ndpn*(nseln+k) + 1][ndpn*l + 1] += -eps*Hm[k]*Hs[l]*detJ[j]*w[j];
ke[ndpn*(nseln+k) + 2][ndpn*l + 2] += -eps*Hm[k]*Hs[l]*detJ[j]*w[j];
}
for (l=0; l<nmeln; ++l)
{
ke[ndpn*(nseln+k) ][ndpn*(nseln+l) ] += eps*Hm[k]*Hm[l]*detJ[j]*w[j];
ke[ndpn*(nseln+k) + 1][ndpn*(nseln+l) + 1] += eps*Hm[k]*Hm[l]*detJ[j]*w[j];
ke[ndpn*(nseln+k) + 2][ndpn*(nseln+l) + 2] += eps*Hm[k]*Hm[l]*detJ[j]*w[j];
}
}
// b. A-term
//-------------------------------------
double* Gr = se.Gr(j);
double* Gs = se.Gs(j);
vec3d gs[2];
ss.CoBaseVectors(se, j, gs);
vec3d as[FEElement::MAX_NODES];
mat3d As[FEElement::MAX_NODES];
for (l=0; l<nseln; ++l) {
as[l] = nu ^ (gs[1]*Gr[l] - gs[0]*Gs[l]);
As[l] = t & as[l];
}
if (!m_bsymm)
{
// non-symmetric
for (k=0; k<nseln; ++k) {
for (l=0; l<nseln; ++l)
{
ke[ndpn*k ][ndpn*l ] += Hs[k]*As[l](0,0)*w[j];
ke[ndpn*k ][ndpn*l + 1] += Hs[k]*As[l](0,1)*w[j];
ke[ndpn*k ][ndpn*l + 2] += Hs[k]*As[l](0,2)*w[j];
ke[ndpn*k + 1][ndpn*l ] += Hs[k]*As[l](1,0)*w[j];
ke[ndpn*k + 1][ndpn*l + 1] += Hs[k]*As[l](1,1)*w[j];
ke[ndpn*k + 1][ndpn*l + 2] += Hs[k]*As[l](1,2)*w[j];
ke[ndpn*k + 2][ndpn*l ] += Hs[k]*As[l](2,0)*w[j];
ke[ndpn*k + 2][ndpn*l + 1] += Hs[k]*As[l](2,1)*w[j];
ke[ndpn*k + 2][ndpn*l + 2] += Hs[k]*As[l](2,2)*w[j];
}
}
for (k=0; k<nmeln; ++k) {
for (l=0; l<nseln; ++l)
{
ke[ndpn*(nseln+k) ][ndpn*l ] += -Hm[k]*As[l](0,0)*w[j];
ke[ndpn*(nseln+k) ][ndpn*l + 1] += -Hm[k]*As[l](0,1)*w[j];
ke[ndpn*(nseln+k) ][ndpn*l + 2] += -Hm[k]*As[l](0,2)*w[j];
ke[ndpn*(nseln+k) + 1][ndpn*l ] += -Hm[k]*As[l](1,0)*w[j];
ke[ndpn*(nseln+k) + 1][ndpn*l + 1] += -Hm[k]*As[l](1,1)*w[j];
ke[ndpn*(nseln+k) + 1][ndpn*l + 2] += -Hm[k]*As[l](1,2)*w[j];
ke[ndpn*(nseln+k) + 2][ndpn*l ] += -Hm[k]*As[l](2,0)*w[j];
ke[ndpn*(nseln+k) + 2][ndpn*l + 1] += -Hm[k]*As[l](2,1)*w[j];
ke[ndpn*(nseln+k) + 2][ndpn*l + 2] += -Hm[k]*As[l](2,2)*w[j];
}
}
}
else
{
// symmetric
for (k=0; k<nseln; ++k) {
for (l=0; l<nseln; ++l)
{
ke[ndpn*k ][ndpn*l ] += 0.5*(Hs[k]*As[l](0,0)+Hs[l]*As[k](0,0))*w[j];
ke[ndpn*k ][ndpn*l + 1] += 0.5*(Hs[k]*As[l](0,1)+Hs[l]*As[k](1,0))*w[j];
ke[ndpn*k ][ndpn*l + 2] += 0.5*(Hs[k]*As[l](0,2)+Hs[l]*As[k](2,0))*w[j];
ke[ndpn*k + 1][ndpn*l ] += 0.5*(Hs[k]*As[l](1,0)+Hs[l]*As[k](0,1))*w[j];
ke[ndpn*k + 1][ndpn*l + 1] += 0.5*(Hs[k]*As[l](1,1)+Hs[l]*As[k](1,1))*w[j];
ke[ndpn*k + 1][ndpn*l + 2] += 0.5*(Hs[k]*As[l](1,2)+Hs[l]*As[k](2,1))*w[j];
ke[ndpn*k + 2][ndpn*l ] += 0.5*(Hs[k]*As[l](2,0)+Hs[l]*As[k](0,2))*w[j];
ke[ndpn*k + 2][ndpn*l + 1] += 0.5*(Hs[k]*As[l](2,1)+Hs[l]*As[k](1,2))*w[j];
ke[ndpn*k + 2][ndpn*l + 2] += 0.5*(Hs[k]*As[l](2,2)+Hs[l]*As[k](2,2))*w[j];
}
}
for (k=0; k<nmeln; ++k) {
for (l=0; l<nseln; ++l)
{
ke[ndpn*(nseln+k) ][ndpn*l ] += -0.5*Hm[k]*As[l](0,0)*w[j];
ke[ndpn*(nseln+k) ][ndpn*l + 1] += -0.5*Hm[k]*As[l](0,1)*w[j];
ke[ndpn*(nseln+k) ][ndpn*l + 2] += -0.5*Hm[k]*As[l](0,2)*w[j];
ke[ndpn*(nseln+k) + 1][ndpn*l ] += -0.5*Hm[k]*As[l](1,0)*w[j];
ke[ndpn*(nseln+k) + 1][ndpn*l + 1] += -0.5*Hm[k]*As[l](1,1)*w[j];
ke[ndpn*(nseln+k) + 1][ndpn*l + 2] += -0.5*Hm[k]*As[l](1,2)*w[j];
ke[ndpn*(nseln+k) + 2][ndpn*l ] += -0.5*Hm[k]*As[l](2,0)*w[j];
ke[ndpn*(nseln+k) + 2][ndpn*l + 1] += -0.5*Hm[k]*As[l](2,1)*w[j];
ke[ndpn*(nseln+k) + 2][ndpn*l + 2] += -0.5*Hm[k]*As[l](2,2)*w[j];
}
}
for (k=0; k<nseln; ++k) {
for (l=0; l<nmeln; ++l)
{
ke[ndpn*k ][ndpn*(nseln+l) ] += -0.5*Hm[l]*As[k](0,0)*w[j];
ke[ndpn*k ][ndpn*(nseln+l) + 1] += -0.5*Hm[l]*As[k](1,0)*w[j];
ke[ndpn*k ][ndpn*(nseln+l) + 2] += -0.5*Hm[l]*As[k](2,0)*w[j];
ke[ndpn*k + 1][ndpn*(nseln+l) ] += -0.5*Hm[l]*As[k](0,1)*w[j];
ke[ndpn*k + 1][ndpn*(nseln+l) + 1] += -0.5*Hm[l]*As[k](1,1)*w[j];
ke[ndpn*k + 1][ndpn*(nseln+l) + 2] += -0.5*Hm[l]*As[k](2,1)*w[j];
ke[ndpn*k + 2][ndpn*(nseln+l) ] += -0.5*Hm[l]*As[k](0,2)*w[j];
ke[ndpn*k + 2][ndpn*(nseln+l) + 1] += -0.5*Hm[l]*As[k](1,2)*w[j];
ke[ndpn*k + 2][ndpn*(nseln+l) + 2] += -0.5*Hm[l]*As[k](2,2)*w[j];
}
}
}
// assemble the global stiffness
ke.SetNodes(en);
ke.SetIndices(LM);
LS.Assemble(ke);
}
}
}
}
}
//-----------------------------------------------------------------------------
bool FETiedElasticInterface::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (m_laugon != FECore::AUGLAG_METHOD) return true;
int i;
vec3d Ln;
bool bconv = true;
int NS = m_ss.Elements();
int NM = m_ms.Elements();
// --- 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, normP = 0, normDP = 0;
for (int i=0; i<NS; ++i)
{
FESurfaceElement& el = m_ss.Element(i);
for (int j=0; j<el.GaussPoints(); ++j)
{
FETiedElasticSurface::Data& ds = static_cast<FETiedElasticSurface::Data&>(*el.GetMaterialPoint(j));
normL0 += ds.m_Lmd*ds.m_Lmd;
}
}
for (int i=0; i<NM; ++i)
{
FESurfaceElement& el = m_ms.Element(i);
for (int j=0; j<el.GaussPoints(); ++j)
{
FETiedElasticSurface::Data& dm = static_cast<FETiedElasticSurface::Data&>(*el.GetMaterialPoint(j));
normL0 += dm.m_Lmd*dm.m_Lmd;
}
}
// b. gap component
// (is calculated during update)
double maxgap = 0;
// update Lagrange multipliers
double normL1 = 0, eps;
for (i=0; i<NS; ++i)
{
FESurfaceElement& el = m_ss.Element(i);
for (int j = 0; j<el.GaussPoints(); ++j)
{
FETiedElasticSurface::Data& ds = static_cast<FETiedElasticSurface::Data&>(*el.GetMaterialPoint(j));
// update Lagrange multipliers on primary surface
eps = m_epsn*ds.m_epsn;
ds.m_Lmd = ds.m_Lmd + ds.m_dg*eps;
normL1 += ds.m_Lmd*ds.m_Lmd;
maxgap = max(maxgap,sqrt(ds.m_dg*ds.m_dg));
}
}
for (int i = 0; i<NM; ++i)
{
FESurfaceElement& el = m_ms.Element(i);
for (int j = 0; j<el.GaussPoints(); ++j)
{
FETiedElasticSurface::Data& dm = static_cast<FETiedElasticSurface::Data&>(*el.GetMaterialPoint(j));
// update Lagrange multipliers on secondary surface
eps = m_epsn*dm.m_epsn;
dm.m_Lmd = dm.m_Lmd + dm.m_dg*eps;
normL1 += dm.m_Lmd*dm.m_Lmd;
maxgap = max(maxgap,sqrt(dm.m_dg*dm.m_dg));
}
}
// Ideally normP should be evaluated from the fluid pressure at the
// contact interface (not easily accessible). The next best thing
// is to use the contact traction.
normP = normL1;
// calculate relative norms
double lnorm = (normL1 != 0 ? fabs((normL1 - normL0) / normL1) : fabs(normL1 - normL0));
double pnorm = (normP != 0 ? (normDP/normP) : normDP);
// check convergence
if ((m_gtol > 0) && (maxgap > m_gtol)) bconv = false;
if ((m_atol > 0) && (lnorm > m_atol)) bconv = false;
if ((m_atol > 0) && (pnorm > m_atol)) bconv = false;
if (naug < m_naugmin ) bconv = false;
if (naug >= m_naugmax) bconv = true;
feLog(" sliding interface # %d\n", GetID());
feLog(" CURRENT REQUIRED\n");
feLog(" D multiplier : %15le", lnorm); if (m_atol > 0) feLog("%15le\n", m_atol); else feLog(" ***\n");
feLog(" maximum gap : %15le", maxgap);
if (m_gtol > 0) feLog("%15le\n", m_gtol); else feLog(" ***\n");
return bconv;
}
//-----------------------------------------------------------------------------
void FETiedElasticInterface::Serialize(DumpStream &ar)
{
// store contact data
FEContactInterface::Serialize(ar);
// store contact surface data
m_ms.Serialize(ar);
m_ss.Serialize(ar);
// serialize pointers
if (ar.IsShallow() == false)
{
SerializeElementPointers(m_ss, m_ms, ar);
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEIsoHencky.cpp | .cpp | 3,544 | 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.*/
#include "stdafx.h"
#include "FEIsoHencky.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEIsoHencky, FEElasticMaterial)
ADD_PARAMETER(m_E, FE_RANGE_GREATER(0.0), "E")->setUnits(UNIT_PRESSURE)->setLongName("Young's modulus");
ADD_PARAMETER(m_v, FE_RANGE_RIGHT_OPEN(-1, 0.5), "v")->setLongName("Poisson's ratio");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEIsoHencky::FEIsoHencky(FEModel* pfem) : FEElasticMaterial(pfem) {}
//-----------------------------------------------------------------------------
mat3ds FEIsoHencky::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
double lnJ = log(J);
// get the material parameters
double E = m_E(mp);
double v = m_v(mp);
// calculate left Hencky tensor
mat3ds h = pt.LeftHencky();
// lame parameters
double lam = v*E/((1+v)*(1-2*v));
double mu = 0.5*E/(1+v);
// Identity
mat3dd I(1);
// calculate stress
mat3ds s = h*(2*mu/J) + I*(lam*lnJ/J);
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEIsoHencky::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
double J = pt.m_J;
// get the material parameters
double E = m_E(mp);
double v = m_v(mp);
// lame parameters
double lam = v*E/((1+v)*(1-2*v));
double mu = 0.5*E/(1+v);
double lam1 = lam / J;
double mu1 = mu / J;
mat3dd I(1);
return dyad1s(I)*lam1 + dyad4s(I)*(2*mu1);
}
//-----------------------------------------------------------------------------
double FEIsoHencky::StrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
double lnJ = log(J);
// get the material parameters
double E = m_E(mp);
double v = m_v(mp);
// calculate right Hencky tensor
mat3ds H = pt.RightHencky();
double I1 = H.tr();
double I2 = H.dotdot(H);
// lame parameters
double lam = v*E/((1+v)*(1-2*v));
double mu = 0.5*E/(1+v);
double sed = (lam/2)*pow(I1,2) + mu*I2;
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FETransIsoVerondaWestmann.h | .h | 2,692 | 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 "FEUncoupledMaterial.h"
#include "FEUncoupledFiberExpLinear.h"
#include "FEActiveContractionMaterial.h"
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! Transversely Isotropic Veronda-Westmann material
//! This material has an isotopric Veronda-Westmann basis and single preferred
//! fiber direction.
class FETransIsoVerondaWestmann : public FEUncoupledMaterial
{
public:
FETransIsoVerondaWestmann(FEModel* 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 deviatoric strain energy density at material point
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
//! create material point data
FEMaterialPointData* CreateMaterialPointData() override;
// update force-velocity material point
void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override;
protected:
FEFiberExpLinearUC m_fib;
FEActiveContractionMaterial* m_ac;
FEVec3dValuator* m_fiber;
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEActiveFiberStressUC.cpp | .cpp | 3,580 | 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.*/
#include "stdafx.h"
#include "FEActiveFiberStressUC.h"
#include "FEElasticMaterial.h"
#include <FECore/log.h>
void FEActiveFiberStressUC::Data::Serialize(DumpStream& ar)
{
FEMaterialPointData::Serialize(ar);
ar & m_lamp;
}
//=====================================================================================
BEGIN_FECORE_CLASS(FEActiveFiberStressUC, FEUncoupledMaterial);
ADD_PARAMETER(m_smax, "smax")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_ac, "activation");
ADD_PROPERTY(m_stl, "stl", FEProperty::Optional);
ADD_PROPERTY(m_stv, "stv", FEProperty::Optional);
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
FEActiveFiberStressUC::FEActiveFiberStressUC(FEModel* fem) : FEUncoupledMaterial(fem)
{
m_smax = 0.0;
m_ac = 0.0;
m_stl = nullptr;
m_stv = nullptr;
}
mat3ds FEActiveFiberStressUC::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double dt = 0.0;
mat3d& F = pt.m_F;
double J = pt.m_J;
double J13 = pow(J, 1.0 / 3.0);
mat3d Q = GetLocalCS(mp);
vec3d a0 = Q.col(0);
vec3d a = F*a0;
double lam = a.unit() / J13;
double stl = (m_stl ? m_stl->value(lam) : 1.0);
double v = 0;// (lam - lamp) / dt;
double stv = (m_stv ? m_stv->value(v) : 1.0);
mat3ds A = dyad(a);
double sf = m_ac*m_smax*stl*stv;
return A.dev()*(sf / J);
}
tens4ds FEActiveFiberStressUC::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double dt = 1.0;
mat3d& F = pt.m_F;
double J = pt.m_J;
double J13 = pow(J, 1.0 / 3.0);
mat3d Q = GetLocalCS(mp);
vec3d a0 = Q.col(0);
vec3d a = F*a0;
double lam = a.unit() / J13;
mat3ds A = dyad(a);
mat3dd I(1.0);
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds AA = dyad1s(A.dev());
tens4ds AI = dyad1s(A, I);
double stl = (m_stl ? m_stl->value(lam) : 1.0);
double v = 0;// (lam - lamp) / dt;
double stv = (m_stv ? m_stv->value(v) : 1.0);
double dstl = (m_stl ? m_stl->derive(lam) : 0.0);
double dstv = (m_stv ? m_stv->derive(v) / dt : 0.0);
double sf = m_ac*m_smax*stl*stv;
double sf_l = m_ac*m_smax*(dstl*stv + stl*dstv);
tens4ds cff = AA*(lam*sf_l - 2.0*sf);
tens4ds cf = (AI - I4 - IxI/3.0)*(2.0*sf/3.0);
tens4ds c = (cff - cf) / J;
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FESymmetryPlane.cpp | .cpp | 5,262 | 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 "FESymmetryPlane.h"
#include "FECore/FECoreKernel.h"
//#include <FECore/FEModel.h>
BEGIN_FECORE_CLASS(FESymmetryPlane, 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");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FESymmetryPlane::FESymmetryPlane(FEModel* pfem) : FESurfaceConstraint(pfem), m_surf(pfem), m_lc(pfem)
{
m_binit = false;
}
//-----------------------------------------------------------------------------
//! Initializes data structures.
void FESymmetryPlane::Activate()
{
// don't forget to call base class
FESurfaceConstraint::Activate();
if (m_binit == false)
{
// get the dof indices
int dofX = GetDOFIndex("x");
int dofY = GetDOFIndex("y");
int dofZ = GetDOFIndex("z");
int dofSX = GetDOFIndex("sx");
int dofSY = GetDOFIndex("sy");
int dofSZ = GetDOFIndex("sz");
// 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
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 nu = m_surf.NodeNormal(i);
FEAugLagLinearConstraint* pLC = fecore_alloc(FEAugLagLinearConstraint, GetFEModel());
pLC->AddDOF(node.GetID(), dofX, nu.x);
pLC->AddDOF(node.GetID(), dofY, nu.y);
pLC->AddDOF(node.GetID(), dofZ, nu.z);
// add the linear constraint to the system
m_lc.add(pLC);
}
}
// for nodes that belong to shells, also constraint the shell bottom face displacements
for (int i = 0; i < m_surf.Nodes(); ++i) {
FENode node = m_surf.Node(i);
if ((node.HasFlags(FENode::EXCLUDE) == false) && (node.HasFlags(FENode::SHELL)) && (node.m_rid == -1)) {
vec3d nu = m_surf.NodeNormal(i);
FEAugLagLinearConstraint* pLC = fecore_alloc(FEAugLagLinearConstraint, GetFEModel());
pLC->AddDOF(node.GetID(), dofSX, nu.x);
pLC->AddDOF(node.GetID(), dofSY, nu.y);
pLC->AddDOF(node.GetID(), dofSZ, nu.z);
// add the linear constraint to the system
m_lc.add(pLC);
}
}
m_lc.Init();
m_lc.Activate();
m_binit = true;
}
}
//-----------------------------------------------------------------------------
bool FESymmetryPlane::Init()
{
// initialize surface
return m_surf.Init();
}
//-----------------------------------------------------------------------------
void FESymmetryPlane::Serialize(DumpStream& ar)
{
FESurfaceConstraint::Serialize(ar);
ar& m_binit;
m_lc.Serialize(ar);
m_surf.Serialize(ar);
}
void FESymmetryPlane::LoadVector(FEGlobalVector& R, const FETimeInfo& tp) { m_lc.LoadVector(R, tp); }
void FESymmetryPlane::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) { m_lc.StiffnessMatrix(LS, tp); }
bool FESymmetryPlane::Augment(int naug, const FETimeInfo& tp) { return m_lc.Augment(naug, tp); }
void FESymmetryPlane::BuildMatrixProfile(FEGlobalMatrix& M) { m_lc.BuildMatrixProfile(M); }
int FESymmetryPlane::InitEquations(int neq) { return m_lc.InitEquations(neq); }
void FESymmetryPlane::Update(const std::vector<double>& Ui, const std::vector<double>& ui) { m_lc.Update(Ui, ui); }
void FESymmetryPlane::UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) { m_lc.UpdateIncrements(Ui, ui); }
void FESymmetryPlane::PrepStep() { m_lc.PrepStep(); }
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEOgdenMaterial.h | .h | 2,061 | 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 "FEUncoupledMaterial.h"
//-----------------------------------------------------------------------------
class FEOgdenMaterial : public FEUncoupledMaterial
{
public:
enum { MAX_TERMS = 6 };
public:
FEOgdenMaterial(FEModel* pfem);
//! calculate the deviatoric stress
mat3ds DevStress(FEMaterialPoint& pt) override;
//! calculate the deviatoric tangent
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! calculate the deviatoric strain energy density
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
protected:
void EigenValues(mat3ds& A, double l[3], vec3d r[3], const double eps = 0);
double m_eps;
public:
FEParamDouble m_c[MAX_TERMS]; //!< coefficients
FEParamDouble m_m[MAX_TERMS]; //!< powers
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEReactivePlasticityMaterialPoint.h | .h | 3,309 | 71 | /*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 "FEReactivePlasticity.h"
#include <vector>
//-----------------------------------------------------------------------------
// Define a material point that stores the plasticity variables.
class FEReactivePlasticityMaterialPoint : public FEReactiveMaterialPoint
{
public:
//! constructor
FEReactivePlasticityMaterialPoint(FEMaterialPointData*pt, FEElasticMaterial* pmat) : FEReactiveMaterialPoint(pt) { m_pMat = pmat; }
FEMaterialPointData* Copy() override;
//! Initialize material point data
void Init() override;
//! Update material point data
void Update(const FETimeInfo& timeInfo) override;
//! Serialize data to archive
void Serialize(DumpStream& ar) override;
//! Evaluate net mass fraction of yielded bonds
double YieldedBonds() const override;
double IntactBonds() const override { return 1 - YieldedBonds(); }
public:
vector<mat3d> m_Fusi; //!< inverse of plastic deformation gradient at previous yield
vector<mat3d> m_Fvsi; //!< trial value of plastic deformation gradient at current yield
vector<double> m_w; //!< mass fraction of yielded bonds
vector<double> m_Kv; //!< value of yield measure at current yield
vector<double> m_Ku; //!< value of yield measure at previous yield
vector<double> m_gp; //!< current value of octahedral plastic shear strain
vector<double> m_gpp; //!< previous value of octahedral plastic shear strain
vector<double> m_gc; //!< cumulative value of octahedral plastic shear strain
vector<bool> m_byld; //!< flag on which bonds have already yielded at start of current time
mat3d m_Fp; //!< deformation gradient at previous time
double m_Rhat; //!< reactive heat supply density
FEElasticMaterial* m_pMat; //!< parent material
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberNeoHookean.h | .h | 2,229 | 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 "FEElasticFiberMaterial.h"
#include "FEFiberMaterial.h"
//-----------------------------------------------------------------------------
//! Neo-Hookean law
class FEFiberNH : public FEFiberMaterial
{
public:
FEFiberNH(FEModel* pfem);
//! Cauchy stress
mat3ds FiberStress(FEMaterialPoint& mp, const vec3d& a0) override;
// Spatial tangent
tens4ds FiberTangent(FEMaterialPoint& mp, const vec3d& a0) override;
//! Strain energy density
double FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) override;
public:
double m_mu; // shear modulus
double m_epsf;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
//! Neo-Hookean law
class FEElasticFiberNH : public FEElasticFiberMaterial_T<FEFiberNH>
{
public:
FEElasticFiberNH(FEModel* fem) : FEElasticFiberMaterial_T<FEFiberNH>(fem) {}
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERVEDamageMaterial.cpp | .cpp | 5,896 | 175 | /*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 "FERVEDamageMaterial.h"
#include "FEDamageCriterion.h"
#include "FEDamageCDF.h"
#include "FEUncoupledMaterial.h"
#include <FECore/log.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERVEDamageMaterial, FEElasticMaterial)
// set material properties
ADD_PROPERTY(m_pRVE , "viscoelastic");
ADD_PROPERTY(m_pDamg, "damage");
ADD_PROPERTY(m_pCrit, "criterion");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FERVEDamageMaterial::FERVEDamageMaterial(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_pRVE = nullptr;
m_pBase = nullptr;
m_pDamg = nullptr;
m_pCrit = nullptr;
}
//-----------------------------------------------------------------------------
//! Initialization.
bool FERVEDamageMaterial::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;
}
m_pBase = m_pRVE->GetBaseMaterial();
return m_pRVE->Init();
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FERVEDamageMaterial::CreateMaterialPointData()
{
FEReactiveViscoelasticMaterialPoint* pt = new FEReactiveViscoelasticMaterialPoint();
// create damage materal point for strong bond (base) material
FEDamageMaterialPoint* pbase = new FEDamageMaterialPoint(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 FERVEDamageMaterial::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 FERVEDamageMaterial::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 FERVEDamageMaterial::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 FERVEDamageMaterial::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 FERVEDamageMaterial::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 FERVEDamageMaterial::Damage(FEMaterialPoint& pt)
{
// get the reactive viscoelastic base material point
FEMaterialPoint* pb = m_pRVE->GetBaseMaterialPoint(pt);
// get the damage material point data from its base material point
FEDamageMaterialPoint& pd = *pb->ExtractData<FEDamageMaterialPoint>();
// evaluate the trial value of the damage criterion
// this must be done before evaluating the damage
pd.m_Etrial = m_pCrit->DamageCriterion(*pb);
// evaluate and set the damage
double d = m_pDamg->Damage(*pb);
pd.m_D = d;
return d;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FESlidingInterface.h | .h | 6,245 | 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.*/
#pragma once
#include "FEContactSurface.h"
#include "FEContactInterface.h"
#include <FECore/FEClosestPointProjection.h>
#include <FECore/vector.h>
//-----------------------------------------------------------------------------
class FEBIOMECH_API FESlidingSurface : public FEContactSurface
{
class FESlidingPoint : public FEContactMaterialPoint
{
public:
FESlidingPoint();
void Serialize(DumpStream& ar) override;
void Init() override;
public:
vec3d m_nu; //!< secondary surface normal at primary surface node
vec2d m_rs; //!< natural coordinates of primary surface projection on secondary surface element
vec2d m_rsp; //!< natural coordinates at previous time step
double m_Lm; //!< Lagrange multipliers for contact pressure
mat2d m_M; //!< surface metric tensor
vec2d m_Lt; //!< Lagrange multipliers for friction
double m_off; //!< gap offset (= shell thickness)
double m_eps; //!< normal penalty factors
};
public:
//! constructor
FESlidingSurface(FEModel* pfem);
//! Initializes data structures
bool Init();
//! Calculate the total traction at a node
vec3d traction(int inode);
//! evaluate net contact force
vec3d GetContactForce();
//! evaluate net contact area
double GetContactArea();
//! Serialize data to archive
void Serialize(DumpStream& ar);
public:
void GetContactTraction(int nface, vec3d& pt);
void GetNodalContactPressure(int nface, double* pg);
void GetNodalContactTraction(int nface, vec3d* pt);
public:
vector<FESlidingPoint> m_data; //!< sliding contact surface data
};
//-----------------------------------------------------------------------------
//! This class implements a sliding interface
//! The FESlidingInterface class defines an interface between two surfaces.
class FEBIOMECH_API FESlidingInterface : public FEContactInterface
{
public:
//! constructor
FESlidingInterface(FEModel* pfem);
//! destructor
virtual ~FESlidingInterface(){}
//! Initializes sliding interface
bool Init() override;
//! interface activation
void Activate() override;
//! projects primary surface nodes onto secondary surface nodes
void ProjectSurface(FESlidingSurface& ss, FESlidingSurface& ms, bool bupseg, bool bmove = false);
//! calculate penalty value
double Penalty() { return m_eps; }
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! calculate contact pressures for file output
void UpdateContactPressures();
//! 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:
//! calculate auto penalty factor
void CalcAutoPenalty(FESlidingSurface& s);
//! calculate the nodal force of a primary surface node
void ContactNodalForce(int m, FESlidingSurface& ss, FESurfaceElement& mel, vector<double>& fe);
//! calculate the stiffness contribution of a single primary surface node
void ContactNodalStiffness(int m, FESlidingSurface& ss, FESurfaceElement& mel, matrix& ke);
//! map the frictional data from the old element to the new element
void MapFrictionData(int inode, FESlidingSurface& ss, FESlidingSurface& ms, FESurfaceElement& sn, FESurfaceElement& so, vec3d& q);
private:
void SerializePointers(FESlidingSurface& ss, FESlidingSurface& ms, DumpStream& ar);
public:
FESlidingSurface m_ss; //!< primary surface
FESlidingSurface m_ms; //!< secondary surface
bool m_btwo_pass; //!< two pass algorithm flag
double m_sradius; //!< search radius for self contact
int m_naugmax; //!< maximum nr of augmentations
int m_naugmin; //!< minimum nr of augmentations
double m_gtol; //!< gap tolerance
double m_atol; //!< augmentation tolerance
double m_ktmult; //!< multiplier for tangential stiffness
double m_knmult; //!< multiplier for normal stiffness
double m_stol; //!< search tolerance
bool m_bautopen; //!< auto penalty calculation
double m_eps; //!< penalty scale factor
bool m_bupdtpen; //!< update penalty
bool m_breloc; //!< initial node relocation
double m_mu; //!< friction coefficient
double m_epsf; //!< penalty scale factor for friction
int m_nsegup; //!< segment update parameter
private:
bool m_bfirst; //!< flag to indicate the first time we enter Update
double m_normg0; //!< initial gap norm
public:
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FETiedElasticInterface.h | .h | 5,502 | 160 | /*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/FEContactInterface.h"
#include "FEContactSurface.h"
//-----------------------------------------------------------------------------
class FETiedElasticSurface : public FEContactSurface
{
public:
//! Integration point data
class Data : public FEContactMaterialPoint
{
public:
Data();
void Serialize(DumpStream& ar) override;
void Init() override;
public:
vec3d m_Gap; //!< initial gap in reference configuration
vec3d m_dg; //!< gap function at integration points
vec3d m_nu; //!< normal at integration points
vec2d m_rs; //!< natural coordinates of projection of integration point
vec3d m_Lmd; //!< lagrange multipliers for displacements
vec3d m_tr; //!< contact traction
double m_epsn; //!< penalty factors
};
//! constructor
FETiedElasticSurface(FEModel* pfem);
//! initialization
bool Init() override;
//! calculate the nodal normals
void UpdateNodeNormals();
void Serialize(DumpStream& ar) override;
//! create material point data
FEMaterialPoint* CreateMaterialPoint() override;
public:
void GetVectorGap (int nface, vec3d& pg) override;
void GetContactTraction(int nface, vec3d& pt) override;
//! evaluate net contact force
vec3d GetContactForce() override;
//! evaluate net contact area
double GetContactArea() override;
public:
vector<vec3d> m_nn; //!< node normals
vector<vec3d> m_Fn; //!< nodal forces
};
//-----------------------------------------------------------------------------
class FETiedElasticInterface : public FEContactInterface
{
public:
//! constructor
FETiedElasticInterface(FEModel* pfem);
//! destructor
~FETiedElasticInterface();
//! 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 false; }
//! 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 InitialProjection(FETiedElasticSurface& ss, FETiedElasticSurface& ms);
void ProjectSurface(FETiedElasticSurface& ss, FETiedElasticSurface& ms);
//! calculate penalty factor
void UpdateAutoPenalty();
void CalcAutoPenalty(FETiedElasticSurface& s);
public:
FETiedElasticSurface m_ss; //!< primary surface
FETiedElasticSurface m_ms; //!< secondary surface
int m_knmult; //!< higher order stiffness multiplier
bool m_btwo_pass; //!< two-pass flag
double m_atol; //!< augmentation tolerance
double m_gtol; //!< gap tolerance
double m_stol; //!< search tolerance
bool m_bsymm; //!< use symmetric stiffness components only
double m_srad; //!< contact search radius
int m_naugmax; //!< maximum nr of augmentations
int m_naugmin; //!< minimum nr of augmentations
double m_epsn; //!< normal penalty factor
bool m_bautopen; //!< use autopenalty factor
bool m_bupdtpen; //!< update penalty at each time step
bool m_bflips; //!< flip primary surface normal
bool m_bflipm; //!< flip secondary surface normal
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEContactInterface.h | .h | 2,912 | 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/FESurfacePairConstraint.h>
#include "febiomech_api.h"
class FEModel;
class FESolver;
class FEGlobalMatrix;
class FEContactSurface;
// Macauley bracket
#define MBRACKET(x) ((x)>=0? (x): 0)
// Heavyside function
#define HEAVYSIDE(x) ((x)>=0?1:0)
//-----------------------------------------------------------------------------
//! This is the base class for contact interfaces
class FEBIOMECH_API FEContactInterface : public FESurfacePairConstraint
{
public:
//! constructor
FEContactInterface(FEModel* pfem);
//! destructor
~FEContactInterface();
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! cale the penalty factor during Lagrange augmentation
double GetPenaltyScaleFactor();
public:
// The LoadVector function evaluates the "forces" that contribute to the residual of the system
virtual void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) = 0;
// Evaluates the contriubtion to the stiffness matrix
virtual void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) = 0;
protected:
//! don't call the default constructor
FEContactInterface() : FESurfacePairConstraint(0){}
//! auto-penalty calculation
double AutoPenalty(FESurfaceElement& el, FESurface& s);
// serialize the element pointers
void SerializeElementPointers(FEContactSurface& ss, FEContactSurface& ms, DumpStream& ar);
public:
int m_laugon; //!< contact enforcement method
double m_psf; //!< penalty scale factor during Lagrange augmentation
double m_psfmax; //!< max allowable penalty scale factor during laugon
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEDamageMooneyRivlin.cpp | .cpp | 6,469 | 230 | /*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 "FEDamageMooneyRivlin.h"
#include <FECore/log.h>
// define the material parameters
BEGIN_FECORE_CLASS(FEDamageMooneyRivlin, FEUncoupledMaterial)
ADD_PARAMETER(c1, FE_RANGE_GREATER(0.0), "c1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(c2, "c2")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_beta, "beta");
ADD_PARAMETER(m_smin, "smin");
ADD_PARAMETER(m_smax, "smax");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEDamageMooneyRivlin::FEDamageMooneyRivlin(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
c1 = 0;
c2 = 0;
m_beta = 0.1;
m_smin = 0.0;
m_smax = 0.5;
}
//-----------------------------------------------------------------------------
bool FEDamageMooneyRivlin::Validate()
{
if (c1 + c2 <= 0) { feLogError("c1 + c2 must be a positive number."); return false; }
return FEUncoupledMaterial::Validate();
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEDamageMooneyRivlin::CreateMaterialPointData()
{
return new FEDamageMaterialPoint(new FEElasticMaterialPoint);
}
//-----------------------------------------------------------------------------
//! Calculate the deviatoric stress
mat3ds FEDamageMooneyRivlin::DevStress(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());
// --- TODO: put strain energy derivatives here ---
//
// W = C1*(I1 - 3) + C2*(I2 - 3)
//
// Wi = dW/dIi
double W1 = c1;
double W2 = c2;
// ---
// calculate T = F*dW/dC*Ft
// T = F*dW/dC*Ft
mat3ds T = B*(W1 + W2*I1) - B2*W2;
// calculate damage reduction factor
double g = Damage(mp);
return T.dev()*(2.0*g/J);
}
//-----------------------------------------------------------------------------
//! Calculate the deviatoric tangent
tens4ds FEDamageMooneyRivlin::DevTangent(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());
// --- TODO: put strain energy derivatives here ---
// Wi = dW/dIi
double W1, W2;
W1 = c1;
W2 = c2;
// ---
// calculate dWdC:C
double WC = W1*I1 + 2*W2*I2;
// calculate C:d2WdCdC:C
double CWWC = 2*I2*W2;
// 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 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;
// calculate reduction factor at this point
double g = Damage(mp);
return c*g;
}
//-----------------------------------------------------------------------------
//! calculate deviatoric strain energy density
double FEDamageMooneyRivlin::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();
// 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());
//
// W = C1*(I1 - 3) + C2*(I2 - 3)
//
double sed = c1*(I1-3) + c2*(I2-3);
// calculate damage reduction factor
double g = Damage(mp);
return sed*g;
}
//-----------------------------------------------------------------------------
// Calculate damage reduction factor
double FEDamageMooneyRivlin::Damage(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate right Cauchy-Green tensor
mat3ds C = pt.DevRightCauchyGreen();
mat3ds C2 = C.sqr();
// Invariants
double I1 = C.tr();
double I2 = 0.5*(I1*I1 - C2.tr());
// strain-energy value
double SEF = c1*(I1 - 3) + c2*(I2 - 3);
// 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 (Es < m_smin) g = 1.0;
else if (Es > m_smax) g = 0.0;
else
{
double F = (Es - m_smin)/(m_smin - m_smax);
g = 1.0 - (1.0 - m_beta + m_beta*F*F)*(F*F);
}
dp.m_D = 1-g;
return g;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidSphericalJoint.cpp | .cpp | 18,556 | 637 | /*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 "FERigidSphericalJoint.h"
#include "FERigidBody.h"
#include "FECore/log.h"
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidSphericalJoint, FERigidConnector);
ADD_PARAMETER(m_laugon, "laugon")->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0LAGMULT\0");
ADD_PARAMETER(m_atol, "tolerance" );
ADD_PARAMETER(m_gtol, "gaptol" );
ADD_PARAMETER(m_qtol, "angtol" );
ADD_PARAMETER(m_eps , "force_penalty" );
ADD_PARAMETER(m_ups , "moment_penalty");
ADD_PARAMETER(m_q0 , "joint_origin" );
ADD_PARAMETER(m_naugmin, "minaug" );
ADD_PARAMETER(m_naugmax, "maxaug" );
ADD_PARAMETER(m_bq , "prescribed_rotation");
ADD_PARAMETER(m_qpx , "rotation_x" );
ADD_PARAMETER(m_qpy , "rotation_y" );
ADD_PARAMETER(m_qpz , "rotation_z" );
ADD_PARAMETER(m_Mpx , "moment_x" );
ADD_PARAMETER(m_Mpy , "moment_y" );
ADD_PARAMETER(m_Mpz , "moment_z" );
ADD_PARAMETER(m_bautopen, "auto_penalty");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidSphericalJoint::FERigidSphericalJoint(FEModel* pfem) : FERigidConnector(pfem)
{
m_nID = m_ncount++;
m_laugon = FECore::AUGLAG_METHOD; // for backwards compatibility
m_atol = 0;
m_gtol = 0;
m_qtol = 0;
m_eps = 1.0;
m_ups = 1.0;
m_naugmin = 0;
m_naugmax = 10;
m_qpx = m_qpy = m_qpz = 0;
m_Mpx = m_Mpy = m_Mpz = 0;
m_bq = false;
m_bautopen = false;
}
//-----------------------------------------------------------------------------
//! initial position
vec3d FERigidSphericalJoint::InitialPosition() const
{
return m_q0;
}
//-----------------------------------------------------------------------------
//! current position
vec3d FERigidSphericalJoint::Position() const
{
FERigidBody& RBa = *m_rbA;
vec3d qa = m_qa0;
RBa.GetRotation().RotateVector(qa);
return RBa.m_rt + qa;
}
//-----------------------------------------------------------------------------
//! TODO: This function is called twice: once in the Init and once in the Solve
//! phase. Is that necessary?
bool FERigidSphericalJoint::Init()
{
if (m_bq && ((m_Mpx != 0) || (m_Mpy != 0) || (m_Mpz != 0))) {
feLogError("Rotation and moment cannot be prescribed simultaneously in rigid connector %d (spherical joint)\n", m_nID+1);
return false;
}
// reset force
m_F = vec3d(0,0,0); m_L = vec3d(0,0,0); m_Fp = vec3d(0,0,0);
m_M = vec3d(0,0,0); m_U = vec3d(0,0,0);
// base class first
if (FERigidConnector::Init() == false) return false;
m_qa0 = m_q0 - m_rbA->m_r0;
m_qb0 = m_q0 - m_rbB->m_r0;
m_e0[0] = vec3d(1,0,0); m_e0[1] = vec3d(0,1,0); m_e0[2] = vec3d(0,0,1);
m_ea0[0] = m_e0[0]; m_ea0[1] = m_e0[1]; m_ea0[2] = m_e0[2];
m_eb0[0] = m_e0[0]; m_eb0[1] = m_e0[1]; m_eb0[2] = m_e0[2];
return true;
}
//-----------------------------------------------------------------------------
void FERigidSphericalJoint::Serialize(DumpStream& ar)
{
FERigidConnector::Serialize(ar);
ar & m_qa0 & m_qb0;
ar & m_L & m_U;
ar & m_Fp;
ar & m_e0;
ar & m_ea0;
ar & m_eb0;
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidSphericalJoint::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);
if (m_laugon != FECore::LAGMULT_METHOD)
{
vec3d c = rb + zb - ra - za;
m_F = m_L + c * m_eps;
if (m_bq) {
quatd q = (alpha * RBb.GetRotation() + (1 - alpha) * RBb.m_qp) * (alpha * RBa.GetRotation() + (1 - alpha) * RBa.m_qp).Inverse();
quatd a(vec3d(m_qpx, m_qpy, m_qpz));
quatd r = a * q.Inverse();
r.MakeUnit();
vec3d ksi = r.GetVector() * r.GetAngle();
m_M = m_U + ksi * m_ups;
}
else m_M = vec3d(m_Mpx, m_Mpy, m_Mpz);
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 + m_M.x;
fa[4] = za.z * m_F.x - za.x * m_F.z + m_M.y;
fa[5] = za.x * m_F.y - za.y * m_F.x + m_M.z;
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 - m_M.x;
fb[4] = -zb.z * m_F.x + zb.x * m_F.z - m_M.y;
fb[5] = -zb.x * m_F.y + zb.y * m_F.x - m_M.z;
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];
}
else
{
vec3d Ma = (za ^ m_F);
vec3d Mb = (zb ^ m_F);
fa[0] = -m_F.x;
fa[1] = -m_F.y;
fa[2] = -m_F.z;
fa[3] = -Ma.x;
fa[4] = -Ma.y;
fa[5] = -Ma.z;
fb[0] = m_F.x;
fb[1] = m_F.y;
fb[2] = m_F.z;
fb[3] = Mb.x;
fb[4] = Mb.y;
fb[5] = Mb.z;
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];
// translational constraint
vec3d c = rb + zb - ra - za;
R[m_LM[0]] += c.x;
R[m_LM[1]] += c.y;
R[m_LM[2]] += c.z;
}
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 FERigidSphericalJoint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
double alpha = tp.alphaf;
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 = rat*alpha + rap*(1-alpha);
vec3d zat = Qat * m_qa0;
vec3d zap = Qap * m_qa0;
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 = rbt*alpha + rbp*(1-alpha);
vec3d zbt = Qbt * m_qb0;
vec3d zbp = Qbp * m_qb0;
vec3d zb = zbt*alpha + zbp*(1-alpha);
mat3d zbhat; zbhat.skew(zb);
mat3d zbthat; zbthat.skew(zbt);
if (m_laugon != FECore::LAGMULT_METHOD)
{
vec3d c = rb + zb - ra - za;
m_F = m_L + c * m_eps;
mat3dd I(1);
quatd q, a, r;
if (m_bq) {
q = (alpha * RBb.GetRotation() + (1 - alpha) * RBb.m_qp) * (alpha * RBa.GetRotation() + (1 - alpha) * RBa.m_qp).Inverse();
a = quatd(vec3d(m_qpx, m_qpy, m_qpz));
r = a * q.Inverse();
r.MakeUnit();
vec3d ksi = r.GetVector() * r.GetAngle();
m_M = m_U + ksi * m_ups;
}
else m_M = vec3d(m_Mpx, m_Mpy, m_Mpz);
mat3d Wba(0, 0, 0, 0, 0, 0, 0, 0, 0), Wab(0, 0, 0, 0, 0, 0, 0, 0, 0);
if (m_bq) {
quatd qa = RBa.GetRotation() * (alpha * RBa.GetRotation() + (1 - alpha) * RBa.m_qp).Inverse();
quatd qb = RBb.GetRotation() * (alpha * RBb.GetRotation() + (1 - alpha) * RBb.m_qp).Inverse();
qa.MakeUnit();
qb.MakeUnit();
mat3d Qa = qa.RotationMatrix();
mat3d Qb = qb.RotationMatrix();
mat3d A = a.RotationMatrix();
mat3d R = r.RotationMatrix();
mat3dd I(1);
Wba = A * (I * Qa.trace() - Qa) / 2;
Wab = R * (I * Qb.trace() - Qb) / 2;
}
mat3d Fhat; Fhat.skew(m_F);
FEElementMatrix ke(12, 12);
ke.zero();
// row 1
ke.set(0, 0, I * (alpha * m_eps));
ke.set(0, 3, zathat * (-m_eps * alpha));
ke.set(0, 6, I * (-alpha * m_eps));
ke.set(0, 9, zbthat * (alpha * m_eps));
// row 2
ke.set(3, 0, zahat * (alpha * m_eps));
ke.set(3, 3, (zahat * zathat * m_eps + Fhat * zathat + Wba * m_ups) * (-alpha));
ke.set(3, 6, zahat * (-alpha * m_eps));
ke.set(3, 9, (zahat * zbthat * m_eps + Wab * m_ups) * alpha);
// row 3
ke.set(6, 0, I * (-alpha * m_eps));
ke.set(6, 3, zathat * (m_eps * alpha));
ke.set(6, 6, I * (alpha * m_eps));
ke.set(6, 9, zbthat * (-alpha * m_eps));
// row 4
ke.set(9, 0, zbhat * (-alpha * m_eps));
ke.set(9, 3, (zbhat * zathat * m_eps + Wba * m_ups) * alpha);
ke.set(9, 6, zbhat * (alpha * m_eps));
ke.set(9, 9, (zbhat * zbthat * m_eps - Fhat * zbthat + Wab * m_ups) * (-alpha));
vector<int> LM(12);
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);
}
else
{
FEElementMatrix ke; ke.resize(15, 15);
ke.zero();
mat3dd I(1.0);
// translation constraint
mat3da Fhat(m_F);
ke.sub( 3, 3, -Fhat*zahat);
ke.sub( 9, 9, Fhat*zbhat);
ke.sub( 0, 12, -I);
ke.sub( 3, 12, -zahat);
ke.sub( 6, 12, I);
ke.sub( 9, 12, zbhat);
ke.sub(12, 0, -I);
ke.sub(12, 3, zahat);
ke.sub(12, 6, I);
ke.sub(12, 9, -zbhat);
vector<int> LM;
UnpackLM(LM);
ke.SetIndices(LM);
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
bool FERigidSphericalJoint::Augment(int naug, const FETimeInfo& tp)
{
if (m_laugon != FECore::AUGLAG_METHOD) return true;
vec3d ra, rb, qa, qb, c, ksi, Lm;
vec3d za, zb;
double normF0, normF1;
vec3d Um;
double normM0, normM1;
bool bconv = true;
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
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);
c = rb + zb - ra - za;
normF0 = sqrt(m_L*m_L);
// calculate trial multiplier
Lm = m_L + c*m_eps;
normF1 = sqrt(Lm*Lm);
// check convergence of constraints
feLog(" rigid connector # %d (spherical joint)\n", m_nID+1);
feLog(" CURRENT REQUIRED\n");
double pctn = 0;
double gap = c.norm();
double qap = ksi.norm();
if (fabs(normF1) > 1e-10) pctn = fabs((normF1 - normF0)/normF1);
if (m_atol) feLog(" force : %15le %15le\n", pctn, m_atol);
else feLog(" force : %15le ***\n", pctn);
if (m_gtol) feLog(" gap : %15le %15le\n", gap, m_gtol);
else feLog(" gap : %15le ***\n", gap);
if (m_atol && (pctn >= m_atol)) bconv = false;
if (m_gtol && (gap >= m_gtol)) bconv = false;
if (m_bq) {
quatd q = (alpha*RBb.GetRotation() + (1 - alpha)*RBb.m_qp)*(alpha*RBa.GetRotation() + (1 - alpha)*RBa.m_qp).Inverse();
quatd a(vec3d(m_qpx,m_qpy,m_qpz));
quatd r = a*q.Inverse();
r.MakeUnit();
vec3d ksi = r.GetVector()*r.GetAngle();
normM0 = sqrt(m_U*m_U);
// calculate trial multiplier
Um = m_U + ksi*m_ups;
normM1 = sqrt(Um*Um);
double qctn = 0;
if (fabs(normM1) > 1e-10) qctn = fabs((normM1 - normM0)/normM1);
if (m_atol) feLog(" moment: %15le %15le\n", qctn, m_atol);
else feLog(" moment: %15le ***\n", qctn);
if (m_qtol) feLog(" angle : %15le %15le\n", qap, m_qtol);
else feLog(" angle : %15le ***\n", qap);
if (m_atol && (qctn >= m_atol)) bconv = false;
if (m_qtol && (qap >= m_qtol)) bconv = false;
}
if (naug < m_naugmin ) bconv = false;
if (naug >= m_naugmax) bconv = true;
if (!bconv)
{
// update multipliers
m_L = Lm;
m_U = Um;
}
// auto-penalty update (works only with gaptol and angtol)
if (m_bautopen)
{
if (m_gtol && (gap > m_gtol)) {
m_eps = fmax(gap / m_gtol, 100)*m_eps;
feLog(" force_penalty : %15le\n", m_eps);
}
if (m_qtol && (qap > m_qtol)) {
m_ups = fmax(qap / m_qtol, 100)*m_ups;
feLog(" moment_penalty : %15le\n", m_ups);
}
}
return bconv;
}
//-----------------------------------------------------------------------------
void FERigidSphericalJoint::Update()
{
if (m_laugon == FECore::LAGMULT_METHOD) return;
vec3d ra, rb;
vec3d za, zb;
const FETimeInfo& tp = GetTimeInfo();
double alpha = tp.alphaf;
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
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);
vec3d c = rb + zb - ra - za;
m_F = m_L + c*m_eps;
if (m_bq) {
quatd q = (alpha*RBb.GetRotation() + (1 - alpha)*RBb.m_qp)*(alpha*RBa.GetRotation() + (1 - alpha)*RBa.m_qp).Inverse();
quatd a(vec3d(m_qpx,m_qpy,m_qpz));
quatd r = a*q.Inverse();
r.MakeUnit();
vec3d ksi = r.GetVector()*r.GetAngle();
m_M = m_U + ksi*m_ups;
}
else m_M = vec3d(m_Mpx,m_Mpy,m_Mpz);
}
//-----------------------------------------------------------------------------
void FERigidSphericalJoint::Reset()
{
m_F = vec3d(0,0,0);
m_L = vec3d(0,0,0);
m_M = vec3d(0,0,0);
m_U = vec3d(0,0,0);
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
m_qa0 = m_q0 - RBa.m_r0;
m_qb0 = m_q0 - RBb.m_r0;
}
//-----------------------------------------------------------------------------
vec3d FERigidSphericalJoint::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;
// evaluate local basis for body A
vec3d ea[3];
ea[0] = m_ea0[0]; RBa.GetRotation().RotateVector(ea[0]);
ea[1] = m_ea0[1]; RBa.GetRotation().RotateVector(ea[1]);
ea[2] = m_ea0[2]; RBa.GetRotation().RotateVector(ea[2]);
// project relative translation onto local basis
vec3d y(x*ea[0], x*ea[1], x*ea[2]);
return y;
}
//-----------------------------------------------------------------------------
vec3d FERigidSphericalJoint::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();
if (global) return q;
// evaluate local basis for body A
vec3d ea[3];
ea[0] = m_ea0[0]; RBa.GetRotation().RotateVector(ea[0]);
ea[1] = m_ea0[1]; RBa.GetRotation().RotateVector(ea[1]);
ea[2] = m_ea0[2]; RBa.GetRotation().RotateVector(ea[2]);
// project relative rotation onto local basis
vec3d y(q*ea[0], q*ea[1], q*ea[2]);
return y;
}
// allocate equations
int FERigidSphericalJoint::InitEquations(int neq)
{
if (m_laugon == FECore::LAGMULT_METHOD)
{
const int LMeq = 3;
m_LM.resize(LMeq, -1);
for (int i = 0; i < LMeq; ++i) m_LM[i] = neq + i;
return LMeq;
}
else return 0;
}
// Build the matrix profile
void FERigidSphericalJoint::BuildMatrixProfile(FEGlobalMatrix& M)
{
vector<int> lm;
UnpackLM(lm);
// add it to the pile
M.build_add(lm);
}
void FERigidSphericalJoint::UnpackLM(vector<int>& lm)
{
// add the dofs of rigid body A
lm.resize(12 + m_LM.size());
lm[0] = m_rbA->m_LM[0];
lm[1] = m_rbA->m_LM[1];
lm[2] = m_rbA->m_LM[2];
lm[3] = m_rbA->m_LM[3];
lm[4] = m_rbA->m_LM[4];
lm[5] = m_rbA->m_LM[5];
// add the dofs of rigid body B
lm[6] = m_rbB->m_LM[0];
lm[7] = m_rbB->m_LM[1];
lm[8] = m_rbB->m_LM[2];
lm[9] = m_rbB->m_LM[3];
lm[10] = m_rbB->m_LM[4];
lm[11] = m_rbB->m_LM[5];
// add the LM equations
if (m_laugon == FECore::LAGMULT_METHOD)
{
for (int i = 0; i < m_LM.size(); ++i) lm[12 + i] = m_LM[i];
}
}
void FERigidSphericalJoint::PrepStep()
{
m_Fp = m_F;
}
void FERigidSphericalJoint::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 FERigidSphericalJoint::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/FEUncoupledActiveContraction.cpp | .cpp | 3,339 | 110 | /*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 "FEUncoupledActiveContraction.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEUncoupledActiveContraction, FEUncoupledMaterial)
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_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEUncoupledActiveContraction::FEUncoupledActiveContraction(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
}
//-----------------------------------------------------------------------------
mat3ds FEUncoupledActiveContraction::DevStress(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d& F = pt.m_F;
double J = pt.m_J;
double Jm13 = pow(J, -1.0/3.0);
// 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();
double lamd = lam*Jm13; // i.e. lambda tilde
// current sarcomere length
double strl = m_refl*lamd;
// sarcomere length change
double dl = strl - m_l0;
// calculate stress
mat3ds s; s.zero();
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
double saf = m_Tmax*(eca50i / ( eca50i + rca*rca ));
// calculate dyad of a: AxA = (a x a)
mat3ds AxA = dyad(a);
// add saf*(a x a)
s += AxA*saf;
}
return s;
}
//-----------------------------------------------------------------------------
// \todo Implement this
tens4ds FEUncoupledActiveContraction::DevTangent(FEMaterialPoint &pt)
{
return tens4ds(0.0);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEBCRigidDeformation.cpp | .cpp | 2,459 | 78 | /*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 "FEBCRigidDeformation.h"
#include "FEBioMech.h"
#include <FECore/FENodeSet.h>
#include <FECore/FENode.h>
BEGIN_FECORE_CLASS(FEBCRigidDeformation, FEPrescribedNodeSet)
ADD_PARAMETER(m_rt, "pos");
ADD_PARAMETER(m_qt, "rot");
END_FECORE_CLASS();
FEBCRigidDeformation::FEBCRigidDeformation(FEModel* fem) : FEPrescribedNodeSet(fem)
{
m_rt = vec3d(0, 0, 0);
m_qt = vec3d(0, 0, 0);
// TODO: Can this be done in Init, since there is no error checking
if (fem)
{
FEDofList dofs(fem);
dofs.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
SetDOFList(dofs);
}
}
void FEBCRigidDeformation::Activate()
{
m_r0 = m_rt;
FEPrescribedNodeSet::Activate();
}
void FEBCRigidDeformation::CopyFrom(FEBoundaryCondition* pbc)
{
FEBCRigidDeformation* ps = dynamic_cast<FEBCRigidDeformation*>(pbc); assert(ps);
m_rt = ps->m_rt;
m_qt = ps->m_qt;
CopyParameterListState(ps->GetParameterList());
}
void FEBCRigidDeformation::GetNodalValues(int nodelid, std::vector<double>& val)
{
vec3d X = GetNodeSet()->Node(nodelid)->m_r0;
quatd Q(m_qt);
vec3d x = Q*(X - m_r0) + m_rt;
vec3d u = x - X;
val[0] = u.x;
val[1] = u.y;
val[2] = u.z;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEMortarTiedContact.h | .h | 3,350 | 103 | /*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 "FEMortarInterface.h"
#include "FEMortarContactSurface.h"
//-----------------------------------------------------------------------------
//! This class represents a surface used by the mortar contact interface.
class FEMortarTiedSurface : public FEMortarContactSurface
{
public:
FEMortarTiedSurface(FEModel* pfem);
//! Initializes data structures
bool Init();
public:
vector<vec3d> m_L; //!< Lagrange multipliers
};
//-----------------------------------------------------------------------------
//! This class implements a mortar based tied interface.
class FEMortarTiedContact : public FEMortarInterface
{
public:
//! constructor
FEMortarTiedContact(FEModel* pfem);
//! return the primary and secondary surface
FESurface* GetPrimarySurface() override { return &m_ss; }
FESurface* GetSecondarySurface() override { return &m_ms; }
public:
//! temporary construct to determine if contact interface uses nodal integration rule (or facet)
bool UseNodalIntegration() override { return false; }
//! interface activation
void Activate() override;
//! one-time initialization
bool Init() override;
//! 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;
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! build the matrix profile for use in the stiffness matrix
void BuildMatrixProfile(FEGlobalMatrix& K) override;
//! update interface data
void Update() override;
private:
double m_atol; //!< augmented Lagrangian tolerance
double m_eps; //!< penalty factor
int m_naugmin; //!< minimum number of augmentations
int m_naugmax; //!< maximum number of augmentations
private:
FEMortarTiedSurface m_ms; //!< mortar surface
FEMortarTiedSurface m_ss; //!< non-mortar surface
int m_dofX;
int m_dofY;
int m_dofZ;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEMortarContactSurface.h | .h | 1,769 | 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.*/
#pragma once
#include "FEContactSurface.h"
//-----------------------------------------------------------------------------
//! This class represents a surface used by the mortar contact interface.
class FEMortarContactSurface : public FEContactSurface
{
public:
FEMortarContactSurface(FEModel* pfem);
//! Initializes data structures
bool Init();
//! update nodal areas
void UpdateNodalAreas();
public:
vector<double> m_A; //!< nodal areas
vector<vec3d> m_gap; //!< nodal gaps
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERemodelingElasticDomain.cpp | .cpp | 7,859 | 236 | /*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 "FERemodelingElasticDomain.h"
#include "FERemodelingElasticMaterial.h"
#include "FECore/FEAnalysis.h"
#include <FECore/FEModel.h>
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
//! constructor
FERemodelingElasticDomain::FERemodelingElasticDomain(FEModel* pfem) : FEElasticSolidDomain(pfem)
{
}
//-----------------------------------------------------------------------------
// Reset data
void FERemodelingElasticDomain::Reset()
{
FEElasticSolidDomain::Reset();
FERemodelingElasticMaterial* pre = m_pMat->ExtractProperty<FERemodelingElasticMaterial>();
FEElasticMaterial* pme = pre->GetElasticMaterial();
// initialize rhor for each material point
ForEachMaterialPoint([&](FEMaterialPoint& mp) {
FERemodelingMaterialPoint& pt = *mp.ExtractData<FERemodelingMaterialPoint>();
pt.m_rhor = pme->Density(mp);
});
}
//-----------------------------------------------------------------------------
//! \todo The material point initialization needs to move to the base class.
bool FERemodelingElasticDomain::Init()
{
// initialize base class
if (FEElasticSolidDomain::Init() == false) return false;
FERemodelingElasticMaterial* pre = m_pMat->ExtractProperty<FERemodelingElasticMaterial>();
if (pre == nullptr) return false;
FEElasticMaterial* pme = pre->GetElasticMaterial();
if (pme == nullptr) return false;
// initialize rhor for each material point
ForEachMaterialPoint([&](FEMaterialPoint& mp) {
FERemodelingMaterialPoint& pt = *mp.ExtractData<FERemodelingMaterialPoint>();
pt.m_rhor = pme->Density(mp);
});
return true;
}
//-----------------------------------------------------------------------------
//! calculates the global stiffness matrix for this domain
void FERemodelingElasticDomain::StiffnessMatrix(FELinearSystem& LS)
{
// repeat over all solid elements
int NE = (int)m_Elem.size();
// I only need this for the element density stiffness
double dt = GetFEModel()->GetTime().timeIncrement;
#pragma omp parallel for
for (int iel=0; iel<NE; ++iel)
{
FESolidElement& el = m_Elem[iel];
// element stiffness matrix
FEElementMatrix ke(el);
int ndof = 3*el.Nodes();
ke.resize(ndof, ndof);
ke.zero();
// calculate geometrical stiffness
ElementGeometricalStiffness(el, ke);
// calculate material stiffness
ElementMaterialStiffness(el, ke);
// calculate density stiffness
ElementDensityStiffness(dt, el, ke);
// assign symmetic parts
// TODO: Can this be omitted by changing the Assemble routine so that it only
// grabs elements from the upper diagonal matrix?
for (int i=0; i<ndof; ++i)
for (int j=i+1; j<ndof; ++j)
ke[j][i] = ke[i][j];
// 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 solid element stiffness matrix
void FERemodelingElasticDomain::ElementStiffness(const FETimeInfo& tp, int iel, matrix& ke)
{
FESolidElement& el = Element(iel);
// calculate material stiffness (i.e. constitutive component)
ElementMaterialStiffness(el, ke);
// calculate geometrical stiffness
ElementGeometricalStiffness(el, ke);
// calculate density stiffness
ElementDensityStiffness(tp.timeIncrement, el, ke);
// assign symmetic parts
// TODO: Can this be omitted by changing the Assemble routine so that it only
// grabs elements from the upper diagonal matrix?
int ndof = 3*el.Nodes();
for (int i=0; i<ndof; ++i)
for (int j=i+1; j<ndof; ++j)
ke[j][i] = ke[i][j];
}
//-----------------------------------------------------------------------------
//! calculates element's density stiffness component for integration point n
//! \todo Remove the FEModel parameter. We only need to dt parameter, not the entire model.
//! \todo Problems seem to run better without this stiffness matrix
void FERemodelingElasticDomain::ElementDensityStiffness(double dt, FESolidElement &el, matrix &ke)
{
int n, i, j;
// make sure this is a remodeling material
FERemodelingElasticMaterial* pmat = dynamic_cast<FERemodelingElasticMaterial*>(m_pMat); assert(pmat);
const int NE = FEElement::MAX_NODES;
vec3d gradN[NE];
double *Grn, *Gsn, *Gtn;
double Gr, Gs, Gt;
vec3d kru, kur;
// nr of nodes
int neln = el.Nodes();
// nr of integration points
int nint = el.GaussPoints();
// jacobian
double Ji[3][3], detJt;
// weights at gauss points
const double *gw = el.GaussWeights();
// density stiffness component for the stiffness matrix
mat3d kab;
// calculate geometrical element stiffness matrix
for (n=0; n<nint; ++n)
{
// calculate jacobian
double J = invjact(el, Ji, n);
detJt = J*gw[n];
Grn = el.Gr(n);
Gsn = el.Gs(n);
Gtn = el.Gt(n);
for (i=0; i<neln; ++i)
{
Gr = Grn[i];
Gs = Gsn[i];
Gt = Gtn[i];
// calculate global gradient of shape functions
// note that we need the transposed of Ji, not Ji itself !
gradN[i].x = Ji[0][0]*Gr+Ji[1][0]*Gs+Ji[2][0]*Gt;
gradN[i].y = Ji[0][1]*Gr+Ji[1][1]*Gs+Ji[2][1]*Gt;
gradN[i].z = Ji[0][2]*Gr+Ji[1][2]*Gs+Ji[2][2]*Gt;
}
// get the material point data
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
double drhohat = pmat->m_pSupp->Tangent_Supply_Density(mp);
mat3ds ruhat = pmat->m_pSupp->Tangent_Supply_Strain(mp);
mat3ds crho = pmat->Tangent_Stress_Density(mp);
double krr = (drhohat - 1./dt)/J;
for (i=0; i<neln; ++i) {
kur = (crho*gradN[i])/krr;
for (j=0; j<neln; ++j)
{
kru = ruhat*gradN[j];
kab = kur & kru;
ke[3*i ][3*j ] -= kab(0,0)*detJt;
ke[3*i ][3*j+1] -= kab(0,1)*detJt;
ke[3*i ][3*j+2] -= kab(0,2)*detJt;
ke[3*i+1][3*j ] -= kab(1,0)*detJt;
ke[3*i+1][3*j+1] -= kab(1,1)*detJt;
ke[3*i+1][3*j+2] -= kab(1,2)*detJt;
ke[3*i+2][3*j ] -= kab(2,0)*detJt;
ke[3*i+2][3*j+1] -= kab(2,1)*detJt;
ke[3*i+2][3*j+2] -= kab(2,2)*detJt;
}
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedNormalDisplacement.cpp | .cpp | 4,440 | 178 | /*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 "FEPrescribedNormalDisplacement.h"
#include <FECore/FESurface.h>
#include <FECore/FENode.h>
#include "FEBioMech.h"
BEGIN_FECORE_CLASS(FEPrescribedNormalDisplacement, FEPrescribedSurface)
ADD_PARAMETER(m_scale, "scale");
ADD_PARAMETER(m_hint, "surface_hint");
ADD_PARAMETER(m_brelative, "relative");
END_FECORE_CLASS()
FEPrescribedNormalDisplacement::FEPrescribedNormalDisplacement(FEModel* fem) : FEPrescribedSurface(fem)
{
m_scale = 0.0;
m_hint = 0;
// set the dof list
// TODO: Can this be done in Init, since there is no error checking
if (fem)
{
FEDofList dofs(fem);
dofs.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
SetDOFList(dofs);
}
}
// activation
void FEPrescribedNormalDisplacement::Activate()
{
const FESurface& surf = *GetSurface();
int N = surf.Nodes();
m_normals.resize(N);
for (int i=0; i<N; ++i)
{
m_normals[i] = vec3d(0,0,0);
}
if (m_hint == 0)
{
int NF = surf.Elements();
for (int i=0; i<NF; ++i)
{
const FESurfaceElement& el = surf.Element(i);
int nn = el.Nodes();
if ((nn==3) || (nn == 4))
{
for (int n=0; n<nn; ++n)
{
int i0 = el.m_lnode[n];
int ip = el.m_lnode[(n+1)%nn];
int im = el.m_lnode[(n + nn - 1)%nn];
vec3d r0 = surf.Node(i0).m_r0;
vec3d rp = surf.Node(ip).m_r0;
vec3d rm = surf.Node(im).m_r0;
vec3d nu = (rp - r0) ^ (rm - r0);
m_normals[i0] += nu;
}
}
else if ((nn == 6) || (nn == 7))
{
vec3d normals[7];
// corner nodes
for (int n = 0; n<3; ++n)
{
int i0 = el.m_lnode[n];
int ip = el.m_lnode[(n + 1) % 3];
int im = el.m_lnode[(n + 2) % 3];
vec3d r0 = surf.Node(i0).m_r0;
vec3d rp = surf.Node(ip).m_r0;
vec3d rm = surf.Node(im).m_r0;
vec3d nu = (rp - r0) ^ (rm - r0);
normals[n] = nu;
}
// edge nodes
for (int n=0; n<3; ++n)
{
int n0 = n + 3;
int n1 = n;
int n2 = (n+1) % 3;
normals[n0] = (normals[n1] + normals[n2]) * 0.5;
}
if (nn == 7)
{
normals[6] = (normals[0] + normals[1] + normals[2]) / 3.0;
}
for (int n=0; n<nn; ++n) m_normals[el.m_lnode[n]] += normals[n];
}
else { assert(false); }
}
for (int i = 0; i<N; ++i)
{
m_normals[i].unit();
}
}
else
{
int NN = surf.Nodes();
for (int i=0; i<NN; ++i)
{
vec3d ri = -surf.Node(i).m_r0;
ri.unit();
m_normals[i] = ri;
}
}
FEPrescribedSurface::Activate();
}
// return the values for node nodelid
void FEPrescribedNormalDisplacement::GetNodalValues(int nodelid, std::vector<double>& val)
{
vec3d v = m_normals[nodelid]*m_scale;
val[0] = v.x;
val[1] = v.y;
val[2] = v.z;
}
// copy data from another class
void FEPrescribedNormalDisplacement::CopyFrom(FEBoundaryCondition* pbc)
{
FEPrescribedNormalDisplacement* pnd = dynamic_cast<FEPrescribedNormalDisplacement*>(pbc);
assert(pnd);
m_scale = pnd->m_scale;
m_normals = pnd->m_normals;
CopyParameterListState(pnd->GetParameterList());
}
void FEPrescribedNormalDisplacement::Serialize(DumpStream& ar)
{
FEPrescribedSurface::Serialize(ar);
if (ar.IsShallow() == false)
{
ar & m_normals;
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/geodesic.h | .h | 52,686 | 804 | /*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
// This file contains a list of integration points and weights to integrate
// over a unit sphere in spherical coordinates.
// "low" resolution
const int NSTL = 320;
const double THETAL[NSTL] = {
1.884960, 2.28362, 2.37224, 2.40299,1.48629,1.88496,2.07108,1.39767,
1.698830, 1.36692, 1.88496, 2.17290,2.29151,1.59701,1.88496,1.47840,
3.141590,-2.74292,-2.65431,-2.62356,2.74292,-3.14159,-2.95547,2.65431,
2.955470, 2.62356,-3.14159,-2.85365,-2.73503,2.85365,3.14159,2.73503,
-1.884960,-1.48629,-1.39767,-1.36692,-2.28362,-1.88496,-1.69883,-2.37224,
-2.071080,-2.40299,-1.88496,-1.59701,-1.4784,-2.1729,-1.88496,-2.29151,
-0.628319,-0.229651,-0.141035,-0.110281,-1.02699,-0.628319,-0.442194,-1.1156,
-0.814443,-1.14636,-0.628319,-0.340375,-0.22176,-0.916262,-0.628319,-1.03488,
0.628319, 1.02699,1.1156,1.14636,0.229651,0.628319,0.814443,0.141035,
0.442194, 0.110281,0.628319,0.916262,1.03488,0.340375,0.628319,0.22176,
-0.738600,-0.769354,-0.857969,-1.25664,-1.07051,-1.25664,-1.6553,-1.44276,
-1.743920,-1.77467,-0.850079,-0.968693,-1.25664,-1.25664,-1.54458,-1.6632,
0.518037, 0.487283,0.398668,0.,0.186124,0.,-0.398668,-0.186124,
-0.487283,-0.518037,0.406559,0.287944,0.,0.,-0.287944,-0.406559,
1.774670, 1.74392,1.6553,1.25664,1.44276,1.25664,0.857969,1.07051,
0.769354, 0.7386,1.6632,1.54458,1.25664,1.25664,0.968693,0.850079,
3.031310, 3.00056,2.91194,2.51327,2.6994,2.51327,2.11461,2.32715,
2.025990, 1.99524,2.91983,2.80122,2.51327,2.51327,2.22533,2.10672,
-1.995240,-2.02599,-2.11461,-2.51327,-2.32715,-2.51327,-2.91194,-2.6994,
-3.000560,-3.03131,-2.10672,-2.22533,-2.51327,-2.51327,-2.80122,-2.91983,
1.418940, 1.71865,2.05126,2.35097,1.57042,1.88496,2.19949,1.72788,
2.042040, 1.88496,1.55369,1.88496,2.21623,1.72788,2.04204,1.88496,
2.675580, 2.97528,-2.97528,-2.67558,2.82706,3.14159,-2.82706,2.98451,
-2.984510, 3.14159,2.81032,3.14159,-2.81032,2.98451,-2.98451,3.14159,
-2.350970,-2.05126,-1.71865,-1.41894,-2.19949,-1.88496,-1.57042,-2.04204,
-1.727880,-1.88496,-2.21623,-1.88496,-1.55369,-2.04204,-1.72788,-1.88496,
-1.094340,-0.794628,-0.462009,-0.162302,-0.94285,-0.628319,-0.313787,-0.785398,
-0.471239,-0.628319,-0.959588,-0.628319,-0.297049,-0.785398,-0.471239,-0.628319,
0.162302, 0.462009,0.794628,1.09434,0.313787,0.628319,0.94285,0.471239,
0.785398, 0.628319,0.297049,0.628319,0.959588,0.471239,0.785398,0.628319,
-0.790621,-1.09033,-1.42295,-1.72265,-0.942106,-1.25664,-1.57117,-1.09956,
-1.413720,-1.25664,-0.925367,-1.25664,-1.58791,-1.09956,-1.41372,-1.25664,
0.466017, 0.166309,-0.166309,-0.466017,0.314531,0.,-0.314531,0.15708,
-0.157080, 0.,0.33127,0.,-0.33127,0.15708,-0.15708,0.,
1.722650, 1.42295,1.09033,0.790621,1.57117,1.25664,0.942106,1.41372,
1.099560, 1.25664,1.58791,1.25664,0.925367,1.41372,1.09956,1.25664,
2.979290, 2.67958,2.34697,2.04726,2.82781,2.51327,2.19874,2.67035,
2.356190, 2.51327,2.84454,2.51327,2.182,2.67035,2.35619,2.51327,
-2.047260,-2.34697,-2.67958,-2.97929,-2.19874,-2.51327,-2.82781,-2.35619,
-2.670350,-2.51327,-2.182,-2.51327,-2.84454,-2.35619,-2.67035,-2.51327};
const double PHIL[NSTL] = {
0.156457,0.41342,0.708355,0.983031,0.41342,0.652358,0.932965,0.708355,
0.932965,0.983031,0.292631,0.580336,0.880271,0.580336,0.833138,0.880271,
0.156457,0.41342,0.708355,0.983031,0.41342,0.652358,0.932965,0.708355,
0.932965,0.983031,0.292631,0.580336,0.880271,0.580336,0.833138,0.880271,
0.156457,0.41342,0.708355,0.983031,0.41342,0.652358,0.932965,0.708355,
0.932965,0.983031,0.292631,0.580336,0.880271,0.580336,0.833138,0.880271,
0.156457,0.41342,0.708355,0.983031,0.41342,0.652358,0.932965,0.708355,
0.932965,0.983031,0.292631,0.580336,0.880271,0.580336,0.833138,0.880271,
0.156457,0.41342,0.708355,0.983031,0.41342,0.652358,0.932965,0.708355,
0.932965,0.983031,0.292631,0.580336,0.880271,0.580336,0.833138,0.880271,
2.15856,2.43324,2.72817,2.98514,2.20863,2.48923,2.72817,2.20863,
2.43324,2.15856,2.26132,2.56126,2.84896,2.30845,2.56126,2.26132,
2.15856,2.43324,2.72817,2.98514,2.20863,2.48923,2.72817,2.20863,
2.43324,2.15856,2.26132,2.56126,2.84896,2.30845,2.56126,2.26132,
2.15856,2.43324,2.72817,2.98514,2.20863,2.48923,2.72817,2.20863,
2.43324,2.15856,2.26132,2.56126,2.84896,2.30845,2.56126,2.26132,
2.15856,2.43324,2.72817,2.98514,2.20863,2.48923,2.72817,2.20863,
2.43324,2.15856,2.26132,2.56126,2.84896,2.30845,2.56126,2.26132,
2.15856,2.43324,2.72817,2.98514,2.20863,2.48923,2.72817,2.20863,
2.43324,2.15856,2.26132,2.56126,2.84896,2.30845,2.56126,2.26132,
1.16072,1.11535,1.11535,1.16072,1.39535,1.38209,1.39535,1.64926,
1.64926,1.87799,1.21486,1.20131,1.21486,1.47441,1.47441,1.74181,
1.16072,1.11535,1.11535,1.16072,1.39535,1.38209,1.39535,1.64926,
1.64926,1.87799,1.21486,1.20131,1.21486,1.47441,1.47441,1.74181,
1.16072,1.11535,1.11535,1.16072,1.39535,1.38209,1.39535,1.64926,
1.64926,1.87799,1.21486,1.20131,1.21486,1.47441,1.47441,1.74181,
1.16072,1.11535,1.11535,1.16072,1.39535,1.38209,1.39535,1.64926,
1.64926,1.87799,1.21486,1.20131,1.21486,1.47441,1.47441,1.74181,
1.16072,1.11535,1.11535,1.16072,1.39535,1.38209,1.39535,1.64926,
1.64926,1.87799,1.21486,1.20131,1.21486,1.47441,1.47441,1.74181,
1.98088,2.02625,2.02625,1.98088,1.74624,1.75951,1.74624,1.49233,
1.49233,1.26361,1.92673,1.94029,1.92673,1.66718,1.66718,1.39978,
1.98088,2.02625,2.02625,1.98088,1.74624,1.75951,1.74624,1.49233,
1.49233,1.26361,1.92673,1.94029,1.92673,1.66718,1.66718,1.39978,
1.98088,2.02625,2.02625,1.98088,1.74624,1.75951,1.74624,1.49233,
1.49233,1.26361,1.92673,1.94029,1.92673,1.66718,1.66718,1.39978,
1.98088,2.02625,2.02625,1.98088,1.74624,1.75951,1.74624,1.49233,
1.49233,1.26361,1.92673,1.94029,1.92673,1.66718,1.66718,1.39978,
1.98088,2.02625,2.02625,1.98088,1.74624,1.75951,1.74624,1.49233,
1.49233,1.26361,1.92673,1.94029,1.92673,1.66718,1.66718,1.39978};
const double AREAL[NSTL] = {
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187,
0.0308214,0.0401741,0.0401741,0.0308214,0.0401741,0.0467453,0.0401741,0.0401741,
0.0401741,0.0308214,0.0383187,0.0443694,0.0383187,0.0443694,0.0443694,0.0383187};
// High resolution
const int NSTH = 1280;
const double THETAH[NSTH] = {
1.88496, 2.28396, 2.38043, 2.42078, 2.44115, 2.45231, 2.45889,
2.46321, 1.48595, 1.88496, 2.07971, 2.1854, 2.24917, 2.29095,
2.32028, 1.38948, 1.6902, 1.88496, 2.01114, 2.09628, 2.15657,
1.34913, 1.58451, 1.75877, 1.88496, 1.97742, 1.32876, 1.52074,
1.67363, 1.79249, 1.3176, 1.47896, 1.61334, 1.31102, 1.44963, 1.3067,
1.88496, 2.18058, 2.28751, 2.34341, 2.37904, 2.40431, 2.42315,
1.58933, 1.88496, 2.04831, 2.14849, 2.21592, 2.26429, 1.48241,
1.7216, 1.88496, 1.99911, 2.08192, 1.4265, 1.62142, 1.77081, 1.88496,
1.39087, 1.55399, 1.68799, 1.36561, 1.50562, 1.34676, 3.14159,
-2.74259, -2.64612, -2.60577, -2.5854, -2.57424, -2.56766, -2.56334,
2.74259, 3.14159, -2.94683, -2.84115, -2.77738, -2.7356, -2.70627,
2.64612, 2.94683, 3.14159, -3.01541, -2.93027, -2.86997, 2.60577,
2.84115, 3.01541, 3.14159, -3.04913, 2.5854, 2.77738, 2.93027,
3.04913, 2.57424, 2.7356, 2.86997, 2.56766, 2.70627, 2.56334,
3.14159, -2.84597, -2.73904, -2.68313, -2.64751, -2.62224, -2.6034,
2.84597, -3.14159, -2.97824, -2.87806, -2.81063, -2.76226, 2.73904,
2.97824, -3.14159, -3.02744, -2.94463, 2.68313, 2.87806, 3.02744,
3.14159, 2.64751, 2.81063, 2.94463, 2.62224, 2.76226, 2.6034,
-1.88496, -1.48595, -1.38948, -1.34913, -1.32876, -1.3176, -1.31102,
-1.3067, -2.28396, -1.88496, -1.6902, -1.58451, -1.52074, -1.47896,
-1.44963, -2.38043, -2.07971, -1.88496, -1.75877, -1.67363, -1.61334,
-2.42078, -2.1854, -2.01114, -1.88496, -1.79249, -2.44115, -2.24917,
-2.09628, -1.97742, -2.45231, -2.29095, -2.15657, -2.45889, -2.32028,
-2.46321, -1.88496, -1.58933, -1.48241, -1.4265, -1.39087, -1.36561,
-1.34676, -2.18058, -1.88496, -1.7216, -1.62142, -1.55399, -1.50562,
-2.28751, -2.04831, -1.88496, -1.77081, -1.68799, -2.34341, -2.14849,
-1.99911, -1.88496, -2.37904, -2.21592, -2.08192, -2.40431, -2.26429,
-2.42315, -0.628319, -0.229317, -0.132846, -0.0924929, -0.0721276,
-0.0609656, -0.0543856, -0.050062, -1.02732, -0.628319, -0.43356,
-0.327873, -0.264104, -0.222327, -0.192993, -1.12379, -0.823077,
-0.628319, -0.502135, -0.416997, -0.3567, -1.16414, -0.928764,
-0.754502, -0.628319, -0.535853, -1.18451, -0.992533, -0.83964,
-0.720784, -1.19567, -1.03431, -0.899938, -1.20225, -1.06364,
-1.20658, -0.628319, -0.332697, -0.225769, -0.169861, -0.134232,
-0.108969, -0.0901211, -0.92394, -0.628319, -0.464966, -0.364783,
-0.297352, -0.248987, -1.03087, -0.791671, -0.628319, -0.514169,
-0.431354, -1.08678, -0.891854, -0.742468, -0.628319, -1.1224,
-0.959285, -0.825283, -1.14767, -1.00765, -1.16652, 0.628319,
1.02732, 1.12379, 1.16414, 1.18451, 1.19567, 1.20225, 1.20658,
0.229317, 0.628319, 0.823077, 0.928764, 0.992533, 1.03431, 1.06364,
0.132846, 0.43356, 0.628319, 0.754502, 0.83964, 0.899938, 0.0924929,
0.327873, 0.502135, 0.628319, 0.720784, 0.0721276, 0.264104,
0.416997, 0.535853, 0.0609656, 0.222327, 0.3567, 0.0543856, 0.192993,
0.050062, 0.628319, 0.92394, 1.03087, 1.08678, 1.1224, 1.14767,
1.16652, 0.332697, 0.628319, 0.791671, 0.891854, 0.959285, 1.00765,
0.225769, 0.464966, 0.628319, 0.742468, 0.825283, 0.169861, 0.364783,
0.514169, 0.628319, 0.134232, 0.297352, 0.431354, 0.108969, 0.248987,
0.0901211, -0.678381, -0.682704, -0.689284, -0.700446, -0.720811,
-0.761164, -0.857635, -1.25664, -0.821311, -0.850646, -0.892423,
-0.956191, -1.06188, -1.25664, -1.65564, -0.985018, -1.04532,
-1.13045, -1.25664, -1.4514, -1.75211, -1.16417, -1.25664, -1.38282,
-1.55708, -1.79246, -1.3491, -1.46796, -1.62085, -1.81283, -1.52826,
-1.66263, -1.82399, -1.69196, -1.83057, -1.83489, -0.71844,
-0.737287, -0.762551, -0.798179, -0.854087, -0.961015, -1.25664,
-0.877306, -0.925671, -0.993101, -1.09328, -1.25664, -1.55226,
-1.05967, -1.14249, -1.25664, -1.41999, -1.65919, -1.25664, -1.37079,
-1.52017, -1.71509, -1.4536, -1.5876, -1.75072, -1.63597, -1.77599,
-1.79483, 0.578257, 0.573933, 0.567353, 0.556191, 0.535826, 0.495473,
0.399002, 0., 0.435326, 0.405991, 0.364214, 0.300446, 0.194759, 0.,
-0.399002, 0.271619, 0.211321, 0.126184, 0., -0.194759, -0.495473,
0.0924652, 0., -0.126184, -0.300446, -0.535826, -0.0924652,
-0.211321, -0.364214, -0.556191, -0.271619, -0.405991, -0.567353,
-0.435326, -0.573933, -0.578257, 0.538197, 0.51935, 0.494086,
0.458458, 0.40255, 0.295622, 0., 0.379331, 0.330967, 0.263536,
0.163353, 0., -0.295622, 0.196964, 0.11415, 0., -0.163353, -0.40255,
0., -0.11415, -0.263536, -0.458458, -0.196964, -0.330967, -0.494086,
-0.379331, -0.51935, -0.538197, 1.83489, 1.83057, 1.82399, 1.81283,
1.79246, 1.75211, 1.65564, 1.25664, 1.69196, 1.66263, 1.62085,
1.55708, 1.4514, 1.25664, 0.857635, 1.52826, 1.46796, 1.38282,
1.25664, 1.06188, 0.761164, 1.3491, 1.25664, 1.13045, 0.956191,
0.720811, 1.16417, 1.04532, 0.892423, 0.700446, 0.985018, 0.850646,
0.689284, 0.821311, 0.682704, 0.678381, 1.79483, 1.77599, 1.75072,
1.71509, 1.65919, 1.55226, 1.25664, 1.63597, 1.5876, 1.52017,
1.41999, 1.25664, 0.961015, 1.4536, 1.37079, 1.25664, 1.09328,
0.854087, 1.25664, 1.14249, 0.993101, 0.798179, 1.05967, 0.925671,
0.762551, 0.877306, 0.737287, 0.71844, 3.09153, 3.08721, 3.08063,
3.06947, 3.0491, 3.00875, 2.91228, 2.51327, 2.9486, 2.91927, 2.87749,
2.81372, 2.70803, 2.51327, 2.11427, 2.78489, 2.7246, 2.63946,
2.51327, 2.31852, 2.0178, 2.60574, 2.51327, 2.38709, 2.21283,
1.97745, 2.42081, 2.30195, 2.14906, 1.95708, 2.24166, 2.10728,
1.94592, 2.07795, 1.93934, 1.93502, 3.05147, 3.03262, 3.00736,
2.97173, 2.91582, 2.8089, 2.51327, 2.89261, 2.84424, 2.77681,
2.67663, 2.51327, 2.21765, 2.71024, 2.62742, 2.51327, 2.34992,
2.11072, 2.51327, 2.39912, 2.24974, 2.05482, 2.31631, 2.18231,
2.01919, 2.13394, 1.99392, 1.97508, -1.93502, -1.93934, -1.94592,
-1.95708, -1.97745, -2.0178, -2.11427, -2.51327, -2.07795, -2.10728,
-2.14906, -2.21283, -2.31852, -2.51327, -2.91228, -2.24166, -2.30195,
-2.38709, -2.51327, -2.70803, -3.00875, -2.42081, -2.51327, -2.63946,
-2.81372, -3.0491, -2.60574, -2.7246, -2.87749, -3.06947, -2.78489,
-2.91927, -3.08063, -2.9486, -3.08721, -3.09153, -1.97508, -1.99392,
-2.01919, -2.05482, -2.11072, -2.21765, -2.51327, -2.13394, -2.18231,
-2.24974, -2.34992, -2.51327, -2.8089, -2.31631, -2.39912, -2.51327,
-2.67663, -2.91582, -2.51327, -2.62742, -2.77681, -2.97173, -2.71024,
-2.84424, -3.00736, -2.89261, -3.03262, -3.05147, 1.33424, 1.47117,
1.62709, 1.79722, 1.97269, 2.14282, 2.29875, 2.43567, 1.40966,
1.55431, 1.71493, 1.88496, 2.05498, 2.2156, 2.36025, 1.48731,
1.63808, 1.80115, 1.96876, 2.13183, 2.2826, 1.56675, 1.72176,
1.88496, 2.04815, 2.20316, 1.64735, 1.80443, 1.96548, 2.12256,
1.72812, 1.88496, 2.04179, 1.80777, 1.96214, 1.88496, 1.39159,
1.54136, 1.70817, 1.88496, 2.06174, 2.22856, 2.37832, 1.47675,
1.63136, 1.79884, 1.97107, 2.13855, 2.29316, 1.56255, 1.71957,
1.88496, 2.05034, 2.20736, 1.64735, 1.80443, 1.96548, 2.12256,
1.72982, 1.88496, 2.04009, 1.80915, 1.96076, 1.88496, 2.59087,
2.7278, 2.88373, 3.05386, -3.05386, -2.88373, -2.7278, -2.59087,
2.6663, 2.81094, 2.97157, 3.14159, -2.97157, -2.81094, -2.6663,
2.74395, 2.89472, 3.05778, -3.05778, -2.89472, -2.74395, 2.82339,
2.9784, 3.14159, -2.9784, -2.82339, 2.90399, 3.06107, -3.06107,
-2.90399, 2.98476, 3.14159, -2.98476, 3.0644, -3.0644, 3.14159,
2.64823, 2.79799, 2.96481, 3.14159, -2.96481, -2.79799, -2.64823,
2.73338, 2.88799, 3.05548, -3.05548, -2.88799, -2.73338, 2.81919,
2.97621, 3.14159, -2.97621, -2.81919, 2.90399, 3.06107, -3.06107,
-2.90399, 2.98645, 3.14159, -2.98645, 3.06579, -3.06579, 3.14159,
-2.43567, -2.29875, -2.14282, -1.97269, -1.79722, -1.62709, -1.47117,
-1.33424, -2.36025, -2.2156, -2.05498, -1.88496, -1.71493, -1.55431,
-1.40966, -2.2826, -2.13183, -1.96876, -1.80115, -1.63808, -1.48731,
-2.20316, -2.04815, -1.88496, -1.72176, -1.56675, -2.12256, -1.96548,
-1.80443, -1.64735, -2.04179, -1.88496, -1.72812, -1.96214, -1.80777,
-1.88496, -2.37832, -2.22856, -2.06174, -1.88496, -1.70817, -1.54136,
-1.39159, -2.29316, -2.13855, -1.97107, -1.79884, -1.63136, -1.47675,
-2.20736, -2.05034, -1.88496, -1.71957, -1.56255, -2.12256, -1.96548,
-1.80443, -1.64735, -2.04009, -1.88496, -1.72982, -1.96076, -1.80915,
-1.88496, -1.17904, -1.04211, -0.886184, -0.716053, -0.540584,
-0.370453, -0.214529, -0.0775996, -1.10361, -0.958967, -0.798343,
-0.628319, -0.458294, -0.29767, -0.153027, -1.02596, -0.875192,
-0.712127, -0.54451, -0.381445, -0.230673, -0.946525, -0.791516,
-0.628319, -0.465121, -0.310112, -0.865925, -0.708845, -0.547792,
-0.390713, -0.785153, -0.628319, -0.471484, -0.705507, -0.55113,
-0.628319, -1.12168, -0.971918, -0.805104, -0.628319, -0.451533,
-0.284719, -0.134953, -1.03653, -0.881917, -0.714436, -0.542201,
-0.37472, -0.220109, -0.950723, -0.793703, -0.628319, -0.462934,
-0.305914, -0.865925, -0.708845, -0.547792, -0.390713, -0.783457,
-0.628319, -0.47318, -0.704125, -0.552512, -0.628319, 0.0775996,
0.214529, 0.370453, 0.540584, 0.716053, 0.886184, 1.04211, 1.17904,
0.153027, 0.29767, 0.458294, 0.628319, 0.798343, 0.958967, 1.10361,
0.230673, 0.381445, 0.54451, 0.712127, 0.875192, 1.02596, 0.310112,
0.465121, 0.628319, 0.791516, 0.946525, 0.390713, 0.547792, 0.708845,
0.865925, 0.471484, 0.628319, 0.785153, 0.55113, 0.705507, 0.628319,
0.134953, 0.284719, 0.451533, 0.628319, 0.805104, 0.971918, 1.12168,
0.220109, 0.37472, 0.542201, 0.714436, 0.881917, 1.03653, 0.305914,
0.462934, 0.628319, 0.793703, 0.950723, 0.390713, 0.547792, 0.708845,
0.865925, 0.47318, 0.628319, 0.783457, 0.552512, 0.704125, 0.628319,
-0.705918, -0.842848, -0.998772, -1.1689, -1.34437, -1.5145,
-1.67043, -1.80736, -0.781346, -0.925988, -1.08661, -1.25664,
-1.42666, -1.58729, -1.73193, -0.858992, -1.00976, -1.17283,
-1.34045, -1.50351, -1.65428, -0.93843, -1.09344, -1.25664, -1.41983,
-1.57484, -1.01903, -1.17611, -1.33716, -1.49424, -1.0998, -1.25664,
-1.41347, -1.17945, -1.33383, -1.25664, -0.763271, -0.913037,
-1.07985, -1.25664, -1.43342, -1.60024, -1.75, -0.848428, -1.00304,
-1.17052, -1.34275, -1.51024, -1.66485, -0.934232, -1.09125,
-1.25664, -1.42202, -1.57904, -1.01903, -1.17611, -1.33716, -1.49424,
-1.1015, -1.25664, -1.41178, -1.18083, -1.33244, -1.25664, 0.550719,
0.413789, 0.257865, 0.0877348, -0.0877348, -0.257865, -0.413789,
-0.550719, 0.475291, 0.330649, 0.170024, 0., -0.170024, -0.330649,
-0.475291, 0.397645, 0.246873, 0.0838083, -0.0838083, -0.246873,
-0.397645, 0.318207, 0.163197, 0., -0.163197, -0.318207, 0.237606,
0.0805264, -0.0805264, -0.237606, 0.156834, 0., -0.156834, 0.0771885,
-0.0771885, 0., 0.493366, 0.3436, 0.176786, 0., -0.176786, -0.3436,
-0.493366, 0.408209, 0.253599, 0.0861171, -0.0861171, -0.253599,
-0.408209, 0.322405, 0.165384, 0., -0.165384, -0.322405, 0.237606,
0.0805264, -0.0805264, -0.237606, 0.155138, 0., -0.155138, 0.0758069,
-0.0758069, 0., 1.80736, 1.67043, 1.5145, 1.34437, 1.1689, 0.998772,
0.842848, 0.705918, 1.73193, 1.58729, 1.42666, 1.25664, 1.08661,
0.925988, 0.781346, 1.65428, 1.50351, 1.34045, 1.17283, 1.00976,
0.858992, 1.57484, 1.41983, 1.25664, 1.09344, 0.93843, 1.49424,
1.33716, 1.17611, 1.01903, 1.41347, 1.25664, 1.0998, 1.33383,
1.17945, 1.25664, 1.75, 1.60024, 1.43342, 1.25664, 1.07985, 0.913037,
0.763271, 1.66485, 1.51024, 1.34275, 1.17052, 1.00304, 0.848428,
1.57904, 1.42202, 1.25664, 1.09125, 0.934232, 1.49424, 1.33716,
1.17611, 1.01903, 1.41178, 1.25664, 1.1015, 1.33244, 1.18083,
1.25664, 3.06399, 2.92706, 2.77114, 2.60101, 2.42554, 2.25541,
2.09948, 1.96256, 2.98857, 2.84392, 2.6833, 2.51327, 2.34325,
2.18263, 2.03798, 2.91092, 2.76015, 2.59708, 2.42947, 2.2664,
2.11563, 2.83148, 2.67647, 2.51327, 2.35008, 2.19507, 2.75088,
2.5938, 2.43275, 2.27567, 2.67011, 2.51327, 2.35644, 2.59046,
2.43609, 2.51327, 3.00664, 2.85687, 2.69006, 2.51327, 2.33649,
2.16967, 2.01991, 2.92148, 2.76687, 2.59939, 2.42716, 2.25968,
2.10506, 2.83568, 2.67866, 2.51327, 2.34789, 2.19087, 2.75088,
2.5938, 2.43275, 2.27567, 2.66841, 2.51327, 2.35814, 2.58908,
2.43747, 2.51327, -1.96256, -2.09948, -2.25541, -2.42554, -2.60101,
-2.77114, -2.92706, -3.06399, -2.03798, -2.18263, -2.34325, -2.51327,
-2.6833, -2.84392, -2.98857, -2.11563, -2.2664, -2.42947, -2.59708,
-2.76015, -2.91092, -2.19507, -2.35008, -2.51327, -2.67647, -2.83148,
-2.27567, -2.43275, -2.5938, -2.75088, -2.35644, -2.51327, -2.67011,
-2.43609, -2.59046, -2.51327, -2.01991, -2.16967, -2.33649, -2.51327,
-2.69006, -2.85687, -3.00664, -2.10506, -2.25968, -2.42716, -2.59939,
-2.76687, -2.92148, -2.19087, -2.34789, -2.51327, -2.67866, -2.83568,
-2.27567, -2.43275, -2.5938, -2.75088, -2.35814, -2.51327, -2.66841,
-2.43747, -2.58908, -2.51327};
const double PHIH[NSTH] = {
0.0738271, 0.191596, 0.329774, 0.478675, 0.631463, 0.781007,
0.921164, 1.04793, 0.191596, 0.293272, 0.428239, 0.578348, 0.731922,
0.879802, 1.0156, 0.329774, 0.428239, 0.558218, 0.703468, 0.850791,
0.990445, 0.478675, 0.578348, 0.703468, 0.840265, 0.97653, 0.631463,
0.731922, 0.850791, 0.97653, 0.781007, 0.879802, 0.990445, 0.921164,
1.0156, 1.04793, 0.129534, 0.256665, 0.403765, 0.560078, 0.717061,
0.866931, 1.00399, 0.256665, 0.373855, 0.516767, 0.670013, 0.82223,
0.965013, 0.403765, 0.516767, 0.652358, 0.796338, 0.937381, 0.560078,
0.670013, 0.796338, 0.927295, 0.717061, 0.82223, 0.937381, 0.866931,
0.965013, 1.00399, 0.0738271, 0.191596, 0.329774, 0.478675, 0.631463,
0.781007, 0.921164, 1.04793, 0.191596, 0.293272, 0.428239, 0.578348,
0.731922, 0.879802, 1.0156, 0.329774, 0.428239, 0.558218, 0.703468,
0.850791, 0.990445, 0.478675, 0.578348, 0.703468, 0.840265, 0.97653,
0.631463, 0.731922, 0.850791, 0.97653, 0.781007, 0.879802, 0.990445,
0.921164, 1.0156, 1.04793, 0.129534, 0.256665, 0.403765, 0.560078,
0.717061, 0.866931, 1.00399, 0.256665, 0.373855, 0.516767, 0.670013,
0.82223, 0.965013, 0.403765, 0.516767, 0.652358, 0.796338, 0.937381,
0.560078, 0.670013, 0.796338, 0.927295, 0.717061, 0.82223, 0.937381,
0.866931, 0.965013, 1.00399, 0.0738271, 0.191596, 0.329774, 0.478675,
0.631463, 0.781007, 0.921164, 1.04793, 0.191596, 0.293272, 0.428239,
0.578348, 0.731922, 0.879802, 1.0156, 0.329774, 0.428239, 0.558218,
0.703468, 0.850791, 0.990445, 0.478675, 0.578348, 0.703468, 0.840265,
0.97653, 0.631463, 0.731922, 0.850791, 0.97653, 0.781007, 0.879802,
0.990445, 0.921164, 1.0156, 1.04793, 0.129534, 0.256665, 0.403765,
0.560078, 0.717061, 0.866931, 1.00399, 0.256665, 0.373855, 0.516767,
0.670013, 0.82223, 0.965013, 0.403765, 0.516767, 0.652358, 0.796338,
0.937381, 0.560078, 0.670013, 0.796338, 0.927295, 0.717061, 0.82223,
0.937381, 0.866931, 0.965013, 1.00399, 0.0738271, 0.191596, 0.329774,
0.478675, 0.631463, 0.781007, 0.921164, 1.04793, 0.191596, 0.293272,
0.428239, 0.578348, 0.731922, 0.879802, 1.0156, 0.329774, 0.428239,
0.558218, 0.703468, 0.850791, 0.990445, 0.478675, 0.578348, 0.703468,
0.840265, 0.97653, 0.631463, 0.731922, 0.850791, 0.97653, 0.781007,
0.879802, 0.990445, 0.921164, 1.0156, 1.04793, 0.129534, 0.256665,
0.403765, 0.560078, 0.717061, 0.866931, 1.00399, 0.256665, 0.373855,
0.516767, 0.670013, 0.82223, 0.965013, 0.403765, 0.516767, 0.652358,
0.796338, 0.937381, 0.560078, 0.670013, 0.796338, 0.927295, 0.717061,
0.82223, 0.937381, 0.866931, 0.965013, 1.00399, 0.0738271, 0.191596,
0.329774, 0.478675, 0.631463, 0.781007, 0.921164, 1.04793, 0.191596,
0.293272, 0.428239, 0.578348, 0.731922, 0.879802, 1.0156, 0.329774,
0.428239, 0.558218, 0.703468, 0.850791, 0.990445, 0.478675, 0.578348,
0.703468, 0.840265, 0.97653, 0.631463, 0.731922, 0.850791, 0.97653,
0.781007, 0.879802, 0.990445, 0.921164, 1.0156, 1.04793, 0.129534,
0.256665, 0.403765, 0.560078, 0.717061, 0.866931, 1.00399, 0.256665,
0.373855, 0.516767, 0.670013, 0.82223, 0.965013, 0.403765, 0.516767,
0.652358, 0.796338, 0.937381, 0.560078, 0.670013, 0.796338, 0.927295,
0.717061, 0.82223, 0.937381, 0.866931, 0.965013, 1.00399, 2.09367,
2.22043, 2.36059, 2.51013, 2.66292, 2.81182, 2.95, 3.06777, 2.12599,
2.26179, 2.40967, 2.56324, 2.71335, 2.84832, 2.95, 2.15115, 2.2908,
2.43812, 2.58338, 2.71335, 2.81182, 2.16506, 2.30133, 2.43812,
2.56324, 2.66292, 2.16506, 2.2908, 2.40967, 2.51013, 2.15115,
2.26179, 2.36059, 2.12599, 2.22043, 2.09367, 2.1376, 2.27466,
2.42453, 2.58151, 2.73783, 2.88493, 3.01206, 2.17658, 2.31936,
2.47158, 2.62483, 2.76774, 2.88493, 2.20421, 2.34525, 2.48923,
2.62483, 2.73783, 2.2143, 2.34525, 2.47158, 2.58151, 2.20421,
2.31936, 2.42453, 2.17658, 2.27466, 2.1376, 2.09367, 2.22043,
2.36059, 2.51013, 2.66292, 2.81182, 2.95, 3.06777, 2.12599, 2.26179,
2.40967, 2.56324, 2.71335, 2.84832, 2.95, 2.15115, 2.2908, 2.43812,
2.58338, 2.71335, 2.81182, 2.16506, 2.30133, 2.43812, 2.56324,
2.66292, 2.16506, 2.2908, 2.40967, 2.51013, 2.15115, 2.26179,
2.36059, 2.12599, 2.22043, 2.09367, 2.1376, 2.27466, 2.42453,
2.58151, 2.73783, 2.88493, 3.01206, 2.17658, 2.31936, 2.47158,
2.62483, 2.76774, 2.88493, 2.20421, 2.34525, 2.48923, 2.62483,
2.73783, 2.2143, 2.34525, 2.47158, 2.58151, 2.20421, 2.31936,
2.42453, 2.17658, 2.27466, 2.1376, 2.09367, 2.22043, 2.36059,
2.51013, 2.66292, 2.81182, 2.95, 3.06777, 2.12599, 2.26179, 2.40967,
2.56324, 2.71335, 2.84832, 2.95, 2.15115, 2.2908, 2.43812, 2.58338,
2.71335, 2.81182, 2.16506, 2.30133, 2.43812, 2.56324, 2.66292,
2.16506, 2.2908, 2.40967, 2.51013, 2.15115, 2.26179, 2.36059,
2.12599, 2.22043, 2.09367, 2.1376, 2.27466, 2.42453, 2.58151,
2.73783, 2.88493, 3.01206, 2.17658, 2.31936, 2.47158, 2.62483,
2.76774, 2.88493, 2.20421, 2.34525, 2.48923, 2.62483, 2.73783,
2.2143, 2.34525, 2.47158, 2.58151, 2.20421, 2.31936, 2.42453,
2.17658, 2.27466, 2.1376, 2.09367, 2.22043, 2.36059, 2.51013,
2.66292, 2.81182, 2.95, 3.06777, 2.12599, 2.26179, 2.40967, 2.56324,
2.71335, 2.84832, 2.95, 2.15115, 2.2908, 2.43812, 2.58338, 2.71335,
2.81182, 2.16506, 2.30133, 2.43812, 2.56324, 2.66292, 2.16506,
2.2908, 2.40967, 2.51013, 2.15115, 2.26179, 2.36059, 2.12599,
2.22043, 2.09367, 2.1376, 2.27466, 2.42453, 2.58151, 2.73783,
2.88493, 3.01206, 2.17658, 2.31936, 2.47158, 2.62483, 2.76774,
2.88493, 2.20421, 2.34525, 2.48923, 2.62483, 2.73783, 2.2143,
2.34525, 2.47158, 2.58151, 2.20421, 2.31936, 2.42453, 2.17658,
2.27466, 2.1376, 2.09367, 2.22043, 2.36059, 2.51013, 2.66292,
2.81182, 2.95, 3.06777, 2.12599, 2.26179, 2.40967, 2.56324, 2.71335,
2.84832, 2.95, 2.15115, 2.2908, 2.43812, 2.58338, 2.71335, 2.81182,
2.16506, 2.30133, 2.43812, 2.56324, 2.66292, 2.16506, 2.2908,
2.40967, 2.51013, 2.15115, 2.26179, 2.36059, 2.12599, 2.22043,
2.09367, 2.1376, 2.27466, 2.42453, 2.58151, 2.73783, 2.88493,
3.01206, 2.17658, 2.31936, 2.47158, 2.62483, 2.76774, 2.88493,
2.20421, 2.34525, 2.48923, 2.62483, 2.73783, 2.2143, 2.34525,
2.47158, 2.58151, 2.20421, 2.31936, 2.42453, 2.17658, 2.27466,
2.1376, 1.13116, 1.10015, 1.07544, 1.06154, 1.06154, 1.07544,
1.10015, 1.13116, 1.23703, 1.21513, 1.19975, 1.19418, 1.19975,
1.21513, 1.23703, 1.35574, 1.34297, 1.33571, 1.33571, 1.34297,
1.35574, 1.48324, 1.47812, 1.47623, 1.47812, 1.48324, 1.61352,
1.61323, 1.61323, 1.61352, 1.73991, 1.74117, 1.73991, 1.85677,
1.85677, 1.96062, 1.15079, 1.12812, 1.11267, 1.10715, 1.11267,
1.12812, 1.15079, 1.26345, 1.24994, 1.2425, 1.2425, 1.24994, 1.26345,
1.38939, 1.38398, 1.38209, 1.38398, 1.38939, 1.52357, 1.52357,
1.52357, 1.52357, 1.65885, 1.66059, 1.65885, 1.78785, 1.78785,
1.90491, 1.13116, 1.10015, 1.07544, 1.06154, 1.06154, 1.07544,
1.10015, 1.13116, 1.23703, 1.21513, 1.19975, 1.19418, 1.19975,
1.21513, 1.23703, 1.35574, 1.34297, 1.33571, 1.33571, 1.34297,
1.35574, 1.48324, 1.47812, 1.47623, 1.47812, 1.48324, 1.61352,
1.61323, 1.61323, 1.61352, 1.73991, 1.74117, 1.73991, 1.85677,
1.85677, 1.96062, 1.15079, 1.12812, 1.11267, 1.10715, 1.11267,
1.12812, 1.15079, 1.26345, 1.24994, 1.2425, 1.2425, 1.24994, 1.26345,
1.38939, 1.38398, 1.38209, 1.38398, 1.38939, 1.52357, 1.52357,
1.52357, 1.52357, 1.65885, 1.66059, 1.65885, 1.78785, 1.78785,
1.90491, 1.13116, 1.10015, 1.07544, 1.06154, 1.06154, 1.07544,
1.10015, 1.13116, 1.23703, 1.21513, 1.19975, 1.19418, 1.19975,
1.21513, 1.23703, 1.35574, 1.34297, 1.33571, 1.33571, 1.34297,
1.35574, 1.48324, 1.47812, 1.47623, 1.47812, 1.48324, 1.61352,
1.61323, 1.61323, 1.61352, 1.73991, 1.74117, 1.73991, 1.85677,
1.85677, 1.96062, 1.15079, 1.12812, 1.11267, 1.10715, 1.11267,
1.12812, 1.15079, 1.26345, 1.24994, 1.2425, 1.2425, 1.24994, 1.26345,
1.38939, 1.38398, 1.38209, 1.38398, 1.38939, 1.52357, 1.52357,
1.52357, 1.52357, 1.65885, 1.66059, 1.65885, 1.78785, 1.78785,
1.90491, 1.13116, 1.10015, 1.07544, 1.06154, 1.06154, 1.07544,
1.10015, 1.13116, 1.23703, 1.21513, 1.19975, 1.19418, 1.19975,
1.21513, 1.23703, 1.35574, 1.34297, 1.33571, 1.33571, 1.34297,
1.35574, 1.48324, 1.47812, 1.47623, 1.47812, 1.48324, 1.61352,
1.61323, 1.61323, 1.61352, 1.73991, 1.74117, 1.73991, 1.85677,
1.85677, 1.96062, 1.15079, 1.12812, 1.11267, 1.10715, 1.11267,
1.12812, 1.15079, 1.26345, 1.24994, 1.2425, 1.2425, 1.24994, 1.26345,
1.38939, 1.38398, 1.38209, 1.38398, 1.38939, 1.52357, 1.52357,
1.52357, 1.52357, 1.65885, 1.66059, 1.65885, 1.78785, 1.78785,
1.90491, 1.13116, 1.10015, 1.07544, 1.06154, 1.06154, 1.07544,
1.10015, 1.13116, 1.23703, 1.21513, 1.19975, 1.19418, 1.19975,
1.21513, 1.23703, 1.35574, 1.34297, 1.33571, 1.33571, 1.34297,
1.35574, 1.48324, 1.47812, 1.47623, 1.47812, 1.48324, 1.61352,
1.61323, 1.61323, 1.61352, 1.73991, 1.74117, 1.73991, 1.85677,
1.85677, 1.96062, 1.15079, 1.12812, 1.11267, 1.10715, 1.11267,
1.12812, 1.15079, 1.26345, 1.24994, 1.2425, 1.2425, 1.24994, 1.26345,
1.38939, 1.38398, 1.38209, 1.38398, 1.38939, 1.52357, 1.52357,
1.52357, 1.52357, 1.65885, 1.66059, 1.65885, 1.78785, 1.78785,
1.90491, 2.01043, 2.04144, 2.06615, 2.08005, 2.08005, 2.06615,
2.04144, 2.01043, 1.90456, 1.92647, 1.94184, 1.94741, 1.94184,
1.92647, 1.90456, 1.78586, 1.79862, 1.80588, 1.80588, 1.79862,
1.78586, 1.65835, 1.66348, 1.66537, 1.66348, 1.65835, 1.52807,
1.52836, 1.52836, 1.52807, 1.40169, 1.40042, 1.40169, 1.28483,
1.28483, 1.18098, 1.9908, 2.01347, 2.02893, 2.03444, 2.02893,
2.01347, 1.9908, 1.87814, 1.89166, 1.89909, 1.89909, 1.89166,
1.87814, 1.7522, 1.75761, 1.75951, 1.75761, 1.7522, 1.61803, 1.61803,
1.61803, 1.61803, 1.48275, 1.481, 1.48275, 1.35374, 1.35374, 1.23668,
2.01043, 2.04144, 2.06615, 2.08005, 2.08005, 2.06615, 2.04144,
2.01043, 1.90456, 1.92647, 1.94184, 1.94741, 1.94184, 1.92647,
1.90456, 1.78586, 1.79862, 1.80588, 1.80588, 1.79862, 1.78586,
1.65835, 1.66348, 1.66537, 1.66348, 1.65835, 1.52807, 1.52836,
1.52836, 1.52807, 1.40169, 1.40042, 1.40169, 1.28483, 1.28483,
1.18098, 1.9908, 2.01347, 2.02893, 2.03444, 2.02893, 2.01347, 1.9908,
1.87814, 1.89166, 1.89909, 1.89909, 1.89166, 1.87814, 1.7522,
1.75761, 1.75951, 1.75761, 1.7522, 1.61803, 1.61803, 1.61803,
1.61803, 1.48275, 1.481, 1.48275, 1.35374, 1.35374, 1.23668, 2.01043,
2.04144, 2.06615, 2.08005, 2.08005, 2.06615, 2.04144, 2.01043,
1.90456, 1.92647, 1.94184, 1.94741, 1.94184, 1.92647, 1.90456,
1.78586, 1.79862, 1.80588, 1.80588, 1.79862, 1.78586, 1.65835,
1.66348, 1.66537, 1.66348, 1.65835, 1.52807, 1.52836, 1.52836,
1.52807, 1.40169, 1.40042, 1.40169, 1.28483, 1.28483, 1.18098,
1.9908, 2.01347, 2.02893, 2.03444, 2.02893, 2.01347, 1.9908, 1.87814,
1.89166, 1.89909, 1.89909, 1.89166, 1.87814, 1.7522, 1.75761,
1.75951, 1.75761, 1.7522, 1.61803, 1.61803, 1.61803, 1.61803,
1.48275, 1.481, 1.48275, 1.35374, 1.35374, 1.23668, 2.01043, 2.04144,
2.06615, 2.08005, 2.08005, 2.06615, 2.04144, 2.01043, 1.90456,
1.92647, 1.94184, 1.94741, 1.94184, 1.92647, 1.90456, 1.78586,
1.79862, 1.80588, 1.80588, 1.79862, 1.78586, 1.65835, 1.66348,
1.66537, 1.66348, 1.65835, 1.52807, 1.52836, 1.52836, 1.52807,
1.40169, 1.40042, 1.40169, 1.28483, 1.28483, 1.18098, 1.9908,
2.01347, 2.02893, 2.03444, 2.02893, 2.01347, 1.9908, 1.87814,
1.89166, 1.89909, 1.89909, 1.89166, 1.87814, 1.7522, 1.75761,
1.75951, 1.75761, 1.7522, 1.61803, 1.61803, 1.61803, 1.61803,
1.48275, 1.481, 1.48275, 1.35374, 1.35374, 1.23668, 2.01043, 2.04144,
2.06615, 2.08005, 2.08005, 2.06615, 2.04144, 2.01043, 1.90456,
1.92647, 1.94184, 1.94741, 1.94184, 1.92647, 1.90456, 1.78586,
1.79862, 1.80588, 1.80588, 1.79862, 1.78586, 1.65835, 1.66348,
1.66537, 1.66348, 1.65835, 1.52807, 1.52836, 1.52836, 1.52807,
1.40169, 1.40042, 1.40169, 1.28483, 1.28483, 1.18098, 1.9908,
2.01347, 2.02893, 2.03444, 2.02893, 2.01347, 1.9908, 1.87814,
1.89166, 1.89909, 1.89909, 1.89166, 1.87814, 1.7522, 1.75761,
1.75951, 1.75761, 1.7522, 1.61803, 1.61803, 1.61803, 1.61803,
1.48275, 1.481, 1.48275, 1.35374, 1.35374, 1.23668};
const double AREAH[NSTH] = {
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048,
0.0068027, 0.00814412, 0.00930384, 0.00999082, 0.00999082,
0.00930384, 0.00814412, 0.0068027, 0.00814412, 0.00963703, 0.0107661,
0.0111921, 0.0107661, 0.00963703, 0.00814412, 0.00930384, 0.0107661,
0.0116467, 0.0116467, 0.0107661, 0.00930384, 0.00999082, 0.0111921,
0.0116467, 0.0111921, 0.00999082, 0.00999082, 0.0107661, 0.0107661,
0.00999082, 0.00930384, 0.00963703, 0.00930384, 0.00814412,
0.00814412, 0.0068027, 0.00773048, 0.00909235, 0.0101134, 0.0104968,
0.0101134, 0.00909235, 0.00773048, 0.00909235, 0.0104969, 0.0113403,
0.0113403, 0.0104969, 0.00909235, 0.0101134, 0.0113403, 0.0118051,
0.0113403, 0.0101134, 0.0104968, 0.0113403, 0.0113403, 0.0104968,
0.0101134, 0.0104969, 0.0101134, 0.00909235, 0.00909235, 0.00773048};
const double XYZ2[45][4] = {
{ 1, 0, 0,0.003394024},
{ 0, 1, 0,0.003394024},
{ 0, 0, 1,0.003394024},
{ 0.7071068, 0.7071068, 0,0.02550091},
{ 0, 0.7071068, 0.7071068,0.02550091},
{ 0.7071068, 0, 0.7071068,0.02550091},
{ 0.9486833, 0.3162278, 0, 0.0180476},
{ 0.3162278, 0.9486833, 0, 0.0180476},
{ 0, 0.9486833, 0.3162278, 0.0180476},
{ 0, 0.3162278, 0.9486833, 0.0180476},
{ 0.9486833, 0, 0.3162278, 0.0180476},
{ 0.3162278, 0, 0.9486833, 0.0180476},
{ 0.4082483, 0.8164966, 0.4082483,0.06535968},
{ 0.4082483, 0.4082483, 0.8164966,0.06535968},
{ 0.8164966, 0.4082483, 0.4082483,0.06535968},
{ 0.9899495, 0.1414214, 0,0.01273219},
{ 0.8574929, 0.5144958, 0,0.02322682},
{ 0.5144958, 0.8574929, 0,0.02322682},
{ 0.1414214, 0.9899495, 0,0.01273219},
{ 0, 0.9899495, 0.1414214,0.01273219},
{ 0, 0.8574929, 0.5144958,0.02322682},
{ 0, 0.5144958, 0.8574929,0.02322682},
{ 0, 0.1414214, 0.9899495,0.01273219},
{ 0.9899495, 0, 0.1414214,0.01273219},
{ 0.8574929, 0, 0.5144958,0.02322682},
{ 0.5144958, 0, 0.8574929,0.02322682},
{ 0.1414214, 0, 0.9899495,0.01273219},
{ 0.5883484, 0.7844645, 0.1961161,0.05866665},
{ 0.1961161, 0.7844645, 0.5883484,0.05866665},
{ 0.5883484, 0.1961161, 0.7844645,0.05866665},
{ 0.1961161, 0.5883484, 0.7844645,0.05866665},
{ 0.7844645, 0.5883484, 0.1961161,0.05866665},
{ 0.7844645, 0.1961161, 0.5883484,0.05866665},
{ 0.9128709, 0.3651484, 0.1825742,0.04814243},
{ 0.9128709, 0.1825742, 0.3651484,0.04814243},
{ 0.9733285, 0.1622214, 0.1622214,0.03438731},
{ 0.1622214, 0.9733285, 0.1622214,0.03438731},
{ 0.1825742, 0.9128709, 0.3651484,0.04814243},
{ 0.3651484, 0.9128709, 0.1825742,0.04814243},
{ 0.1825742, 0.3651484, 0.9128709,0.04814243},
{ 0.1622214, 0.1622214, 0.9733285,0.03438731},
{ 0.3651484, 0.1825742, 0.9128709,0.04814243},
{ 0.6396021, 0.4264014, 0.6396021,0.07332545},
{ 0.4264014, 0.6396021, 0.6396021,0.07332545},
{ 0.6396021, 0.6396021, 0.4264014,0.07332545}
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEDiscreteContact.h | .h | 4,565 | 139 | /*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/FESurfaceConstraint.h>
#include "FEContactSurface.h"
#include "FEDeformableSpringDomain.h"
//-----------------------------------------------------------------------------
class FEDiscreteSet;
//-----------------------------------------------------------------------------
class FEBIOMECH_API FEDiscreteContactSurface : public FEContactSurface
{
public:
//! constructor
FEDiscreteContactSurface(FEModel* fem);
//! Initialization
bool Init();
};
//-----------------------------------------------------------------------------
class FEBIOMECH_API FEDiscreteContact : public FESurfaceConstraint
{
struct NODE
{
int nid; //!< (local) node ID
FESurfaceElement* pe; //!< secondary surface element
double gap; //!< gap distance
double Lm; //!< Lagrange multiplier
vec3d nu; //!< normal at secondary surface projection
vec3d q; //!< projection point
double proj[2]; //!< iso-parametric coordinates of projection point
};
public:
FEDiscreteContact(FEModel* pfem);
public:
bool Init() override;
void Activate() override;
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
bool Augment(int naug, const FETimeInfo& tp) override;
void BuildMatrixProfile(FEGlobalMatrix& M) override;
void Update(const FETimeInfo& tp);
void SetDiscreteSet(FEDiscreteSet* pset);
FESurface* GetSurface() override { return &m_surf; }
protected:
void ProjectSurface(bool bupseg);
void ContactNodalForce (NODE& nodeData, FESurfaceElement& mel, vector<double>& fe);
void ContactNodalStiffness(NODE& nodeData, FESurfaceElement& mel, matrix& ke);
protected:
FEDiscreteContactSurface m_surf;
vector<NODE> m_Node;
double m_normg0;
bool m_bfirst;
protected:
bool m_blaugon; //!< augmentation flag
double m_altol; //!< augmentation tolerance
double m_penalty; //!< penalty parameter
double m_gaptol; //!< gap tolerance
int m_naugmin; //!< minimum number of augmentations
int m_naugmax; //!< maximum number of augmentations
int m_nsegup; //!< number of segment updates (or zero)
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
class FEBIOMECH_API FEDiscreteContact2 : public FESurfaceConstraint
{
struct NODE
{
int node; // node index (local ID into discrete domain)
FESurfaceElement* pe; // secondary surface element
double proj[2]; // natural coordinates of projection
vec3d nu; // normal on secondary surface
vec3d q; // new position
};
public:
FEDiscreteContact2(FEModel* fem);
bool Init() override;
void Activate() override;
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
void BuildMatrixProfile(FEGlobalMatrix& M) override;
void Update(const FETimeInfo& tp);
bool Augment(int naug, const FETimeInfo& tp) override { return true; }
void SetDiscreteDomain(FEDeformableSpringDomain2* dom) { m_dom = dom; }
FESurface* GetSurface() override { return &m_surf; }
protected:
void ProjectNodes();
protected:
FEDiscreteContactSurface m_surf;
FEDeformableSpringDomain2* m_dom;
vector<NODE> m_nodeData;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidWallInterface.cpp | .cpp | 16,076 | 651 | /*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 "FERigidWallInterface.h"
#include <FECore/FENNQuery.h>
#include <FECore/FEModel.h>
#include <FECore/FEGlobalMatrix.h>
#include <FECore/log.h>
#include <FEBioMech/FEElasticShellDomainOld.h>
#include <FECore/FELinearSystem.h>
// Macauley bracket
#define MBRACKET(x) ((x)>=0? (x): 0)
#define HEAVYSIDE(x) ((x)>=0?1:0)
//-----------------------------------------------------------------------------
// Define sliding interface parameters
BEGIN_FECORE_CLASS(FERigidWallInterface, FESurfaceConstraint)
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_d , "offset" );
ADD_PARAMETER(m_a , 4, "plane" );
END_FECORE_CLASS();
///////////////////////////////////////////////////////////////////////////////
// FERigidWallSurface
///////////////////////////////////////////////////////////////////////////////
FERigidWallSurface::FERigidWallSurface(FEModel* pfem) : FESurface(pfem)
{
m_NQ.Attach(this);
// I want to use the FEModel class for this, but don't know how
DOFS& dofs = pfem->GetDOFS();
m_dofX = dofs.GetDOF("x");
m_dofY = dofs.GetDOF("y");
m_dofZ = dofs.GetDOF("z");
}
//-----------------------------------------------------------------------------
//! Creates a surface for use with a sliding interface. All surface data
//! structures are allocated.
//! Note that it is assumed that the element array is already created
//! and initialized.
bool FERigidWallSurface::Init()
{
// always intialize base class first!
if (FESurface::Init() == false) return false;
// get the number of nodes
int nn = Nodes();
// allocate other surface data
m_gap.assign(nn, 0); // gap funtion
m_nu.resize(nn); // node normal
m_pme.assign(nn, static_cast<FESurfaceElement*>(0)); // penetrated secondary surface element
m_rs.resize(nn); // natural coords of projected primary node on secondary element
m_rsp.resize(nn);
m_Lm.assign(nn, 0);
m_M.resize(nn);
m_Lt.resize(nn);
m_off.assign(nn, 0.0);
m_eps.assign(nn, 1.0);
// we calculate the gap offset values
// This value is used to take the shell thickness into account
// note that we force rigid shells to have zero thickness
FEMesh& m = *m_pMesh;
vector<double> tag(m.Nodes());
zero(tag);
for (int nd=0; nd<m.Domains(); ++nd)
{
FEElasticShellDomainOld* psd = dynamic_cast<FEElasticShellDomainOld*>(&m.Domain(nd));
if (psd)
{
for (int i=0; i<psd->Elements(); ++i)
{
FEShellElement& el = psd->Element(i);
int n = el.Nodes();
for (int j=0; j<n; ++j) tag[el.m_node[j]] = 0.5*el.m_h0[j];
}
}
}
for (int i=0; i<nn; ++i) m_off[i] = tag[NodeIndex(i)];
return true;
}
//-----------------------------------------------------------------------------
//!
vec3d FERigidWallSurface::traction(int inode)
{
vec3d t(0,0,0);
FESurfaceElement* pe = m_pme[inode];
if (pe)
{
FESurfaceElement& el = *pe;
double Tn = m_Lm[inode];
double T1 = m_Lt[inode][0];
double T2 = m_Lt[inode][1];
double r = m_rs[inode][0];
double s = m_rs[inode][1];
vec3d tn = m_nu[inode]*Tn, tt;
vec3d e[2];
ContraBaseVectors0(el, r, s, e);
tt = e[0]*T1 + e[1]*T2;
t = tn + tt;
}
return t;
}
//-----------------------------------------------------------------------------
void FERigidWallSurface::UpdateNormals()
{
int i, j, jp1, jm1;
int N = Nodes();
int NE = Elements();
for (i=0; i<N; ++i) m_nu[i] = vec3d(0,0,0);
vec3d y[FEElement::MAX_NODES], e1, e2;
for (i=0; i<NE; ++i)
{
FESurfaceElement& el = Element(i);
int ne = el.Nodes();
for (j=0; j<ne; ++j) y[j] = Node(el.m_lnode[j]).m_rt;
for (j=0; j<ne; ++j)
{
jp1 = (j+1)%ne;
jm1 = (j+ne-1)%ne;
e1 = y[jp1] - y[j];
e2 = y[jm1] - y[j];
m_nu[el.m_lnode[j]] -= e1 ^ e2;
}
}
for (i=0; i<N; ++i) m_nu[i].unit();
}
//-----------------------------------------------------------------------------
void FERigidWallSurface::Serialize(DumpStream &ar)
{
FESurface::Serialize(ar);
ar & m_gap;
ar & m_nu;
ar & m_rs;
ar & m_rsp;
ar & m_Lm;
ar & m_M;
ar & m_Lt;
ar & m_off;
ar & m_eps;
}
//-----------------------------------------------------------------------------
void FERigidWallSurface::UnpackLM(FEElement& el, vector<int>& lm)
{
int N = el.Nodes();
lm.resize(N*3);
for (int i=0; i<N; ++i)
{
int n = el.m_node[i];
FENode& node = m_pMesh->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];
}
}
///////////////////////////////////////////////////////////////////////////////
// FERigidWallInterface
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//! constructor
FERigidWallInterface::FERigidWallInterface(FEModel* pfem) : FESurfaceConstraint(pfem)
{
static int count = 1;
SetID(count++);
m_laugon = FECore::PENALTY_METHOD;
m_a[0] = m_a[1] = m_a[2] = m_a[3] = 0.0;
m_ss = new FERigidWallSurface(pfem);
m_eps = 0;
m_atol = 0;
m_d = 0.0;
};
//-----------------------------------------------------------------------------
FERigidWallInterface::~FERigidWallInterface()
{
delete m_ss;
}
//-----------------------------------------------------------------------------
//! Initializes the rigid wall interface data
bool FERigidWallInterface::Init()
{
// create the surface
if (m_ss->Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
//! build the matrix profile for use in the stiffness matrix
void FERigidWallInterface::BuildMatrixProfile(FEGlobalMatrix& K)
{
FERigidWallSurface& surf = *m_ss;
FEModel& fem = *GetFEModel();
// get the DOFS
const int dof_X = fem.GetDOFIndex("x");
const int dof_Y = fem.GetDOFIndex("y");
const int dof_Z = fem.GetDOFIndex("z");
const int dof_RU = fem.GetDOFIndex("Ru");
const int dof_RV = fem.GetDOFIndex("Rv");
const int dof_RW = fem.GetDOFIndex("Rw");
vector<int> lm(6);
for (int j=0; j< surf.Nodes(); ++j)
{
if (surf.m_gap[j] >= 0)
{
lm[0] = surf.Node(j).m_ID[dof_X];
lm[1] = surf.Node(j).m_ID[dof_Y];
lm[2] = surf.Node(j).m_ID[dof_Z];
lm[3] = surf.Node(j).m_ID[dof_RU];
lm[4] = surf.Node(j).m_ID[dof_RV];
lm[5] = surf.Node(j).m_ID[dof_RW];
K.build_add(lm);
}
}
}
//-----------------------------------------------------------------------------
void FERigidWallInterface::Activate()
{
// don't forget to call the base class
FESurfaceConstraint::Activate();
// project primary surface onto secondary surface
ProjectSurface(*m_ss);
}
//-----------------------------------------------------------------------------
//! Projects the primary surface onto the plane
void FERigidWallInterface::ProjectSurface(FERigidWallSurface& ss)
{
FERigidWallSurface& surf = *m_ss;
// loop over all primary surface nodes
for (int i=0; i< surf.Nodes(); ++i)
{
// get the nodal position
vec3d r = surf.Node(i).m_rt;
// project this node onto the plane
vec3d q = ProjectToPlane(r);
// get the local surface normal
vec3d np = PlaneNormal(q);
// calculate offset
q += np*m_d;
// the normal is set to the secondary surface element normal
surf.m_nu[i] = np;
// calculate initial gap
surf.m_gap[i] = -(np*(r - q)) + surf.m_off[i];
}
}
//-----------------------------------------------------------------------------
//! Updates rigid wall data
void FERigidWallInterface::Update()
{
// project primary surface onto secondary surface
ProjectSurface(*m_ss);
}
//-----------------------------------------------------------------------------
void FERigidWallInterface::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
int j, k, m, n;
int nseln;
double *Gr, *Gs;
// jacobian
double detJ;
vec3d dxr, dxs;
vec3d rt[FEElement::MAX_NODES], r0[FEElement::MAX_NODES];
double* w;
// normal force
double tn;
// element contact force vector
// note that this assumes that the element to which the integration node
// connects is a four noded quadrilateral
vector<double> fe(3);
// the lm array for this force vector
vector<int> lm(3);
// the en array
vector<int> en(1);
vector<int> sLM;
// penalty value
double pen = m_eps, eps;
// loop over all primary surface facets
FERigidWallSurface& surf = *m_ss;
int ne = surf.Elements();
for (j=0; j<ne; ++j)
{
// get the next element
FESurfaceElement& sel = surf.Element(j);
// get the element's LM vector
surf.UnpackLM(sel, sLM);
nseln = sel.Nodes();
for (int i=0; i<nseln; ++i)
{
r0[i] = surf.GetMesh()->Node(sel.m_node[i]).m_r0;
rt[i] = surf.GetMesh()->Node(sel.m_node[i]).m_rt;
}
w = sel.GaussWeights();
// loop over element nodes (which are the integration points as well)
for (n=0; n<nseln; ++n)
{
Gr = sel.Gr(n);
Gs = sel.Gs(n);
m = sel.m_lnode[n];
// see if this node's constraint is active
// that is, if it has a secondary surface element associated with it
// if (ss.Lm[m] >= 0)
{
// calculate jacobian
dxr = dxs = vec3d(0,0,0);
for (k=0; k<nseln; ++k)
{
dxr.x += Gr[k]*r0[k].x;
dxr.y += Gr[k]*r0[k].y;
dxr.z += Gr[k]*r0[k].z;
dxs.x += Gs[k]*r0[k].x;
dxs.y += Gs[k]*r0[k].y;
dxs.z += Gs[k]*r0[k].z;
}
detJ = (dxr ^ dxs).norm();
// get node normal force
eps = pen* surf.m_eps[m];
tn = surf.m_Lm[m] + eps* surf.m_gap[m];
tn = MBRACKET(tn);
// get the node normal
vec3d& nu = surf.m_nu[m];
// calculate force vector
fe[0] = detJ*w[n]*tn*nu.x;
fe[1] = detJ*w[n]*tn*nu.y;
fe[2] = detJ*w[n]*tn*nu.z;
// fill the lm array
lm[0] = sLM[n*3 ];
lm[1] = sLM[n*3+1];
lm[2] = sLM[n*3+2];
// fill the en array
en[0] = sel.m_node[n];
// assemble into global force vector
R.Assemble(en, lm, fe);
}
}
}
}
//-----------------------------------------------------------------------------
//! This function calculates the stiffness contribution for the rigid wall
//! interface.
//! \todo I think there are a couple of stiffness terms missing in this formulation
void FERigidWallInterface::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
int j, k, l, n, m;
int nseln, ndof;
FEElementMatrix ke;
vector<int> lm(3);
vector<int> en(1);
double *Gr, *Gs, *w;
vec3d rt[FEElement::MAX_NODES], r0[FEElement::MAX_NODES];
double detJ, tn;
vec3d dxr, dxs;
double N[3];
double gap, Lm;
vector<int> sLM;
// penalty value
double pen = m_eps, eps;
// loop over all primary surface elements
FERigidWallSurface& surf = *m_ss;
int ne = surf.Elements();
for (j=0; j<ne; ++j)
{
FESurfaceElement& se = surf.Element(j);
// get the element's LM vector
surf.UnpackLM(se, sLM);
nseln = se.Nodes();
for (int i=0; i<nseln; ++i)
{
r0[i] = surf.GetMesh()->Node(se.m_node[i]).m_r0;
rt[i] = surf.GetMesh()->Node(se.m_node[i]).m_rt;
}
w = se.GaussWeights();
// loop over all integration points (that is nodes)
for (n=0; n<nseln; ++n)
{
Gr = se.Gr(n);
Gs = se.Gs(n);
m = se.m_lnode[n];
// see if this node's constraint is active
// that is, if it has a secondary surface element associated with it
// if (ss.Lm[m] >= 0)
{
// calculate jacobian
dxr = dxs = vec3d(0,0,0);
for (k=0; k<nseln; ++k)
{
dxr.x += Gr[k]*r0[k].x;
dxr.y += Gr[k]*r0[k].y;
dxr.z += Gr[k]*r0[k].z;
dxs.x += Gs[k]*r0[k].x;
dxs.y += Gs[k]*r0[k].y;
dxs.z += Gs[k]*r0[k].z;
}
detJ = (dxr ^ dxs).norm();
// gap
gap = surf.m_gap[m];
// lagrange multiplier
Lm = surf.m_Lm[m];
// get node normal force
eps = pen* surf.m_eps[m];
tn = surf.m_Lm[m] + eps* surf.m_gap[m];
tn = MBRACKET(tn);
// get the node normal
vec3d& nu = surf.m_nu[m];
// set up the N vector
N[0] = nu.x;
N[1] = nu.y;
N[2] = nu.z;
ndof = 3;
// fill stiffness matrix
// TODO: I don't think this is correct, since
// if the rigid wall is not a plance, some terms
// are probably missing
ke.resize(ndof, ndof);
for (k=0; k<ndof; ++k)
for (l=0; l<ndof; ++l)
ke[k][l] = w[n]*detJ*eps*HEAVYSIDE(Lm+eps*gap)*N[k]*N[l];
// create lm array
lm[0] = sLM[n*3 ];
lm[1] = sLM[n*3+1];
lm[2] = sLM[n*3+2];
// create the en array
en[0] = se.m_node[n];
// assemble stiffness matrix
ke.SetNodes(en);
ke.SetIndices(lm);
LS.Assemble(ke);
}
}
}
}
//-----------------------------------------------------------------------------
bool FERigidWallInterface::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (m_laugon != FECore::AUGLAG_METHOD) return true;
int i;
double Lm;
bool bconv = true;
FERigidWallSurface& surf = *m_ss;
// penalty value
double pen = m_eps, eps;
// calculate initial norms
double normL0 = 0;
for (i=0; i< surf.Nodes(); ++i) normL0 += surf.m_Lm[i]* surf.m_Lm[i];
normL0 = sqrt(normL0);
// update Lagrange multipliers and calculate current norms
double normL1 = 0;
double normgc = 0;
int N = 0;
for (i=0; i< surf.Nodes(); ++i)
{
// update Lagrange multipliers
eps = pen* surf.m_eps[i];
Lm = surf.m_Lm[i] + eps* surf.m_gap[i];
Lm = MBRACKET(Lm);
normL1 += Lm*Lm;
if (surf.m_gap[i] > 0)
{
normgc += surf.m_gap[i]* surf.m_gap[i];
++N;
}
}
if (N==0) N = 1;
normL1 = sqrt(normL1);
normgc = sqrt(normgc / N);
// check convergence of constraints
feLog(" rigid wall 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);
if (pctn >= m_atol)
{
bconv = false;
for (i=0; i< surf.Nodes(); ++i)
{
// update Lagrange multipliers
eps = pen* surf.m_eps[i];
Lm = surf.m_Lm[i] + eps* surf.m_gap[i];
surf.m_Lm[i] = MBRACKET(Lm);
}
}
return bconv;
}
//-----------------------------------------------------------------------------
vec3d FERigidWallInterface::PlaneNormal(const vec3d& r)
{
vec3d n(m_a[0], m_a[1], m_a[2]);
n.unit();
return n;
}
//-----------------------------------------------------------------------------
vec3d FERigidWallInterface::ProjectToPlane(const vec3d& r)
{
double d = m_a[3];
double l = m_a[0] * r.x + m_a[1] * r.y + m_a[2] * r.z - d;
return vec3d(r.x - l * m_a[0], r.y - l * m_a[1], r.z - l * m_a[2]);
}
//-----------------------------------------------------------------------------
void FERigidWallInterface::Serialize(DumpStream &ar)
{
FESurfaceConstraint::Serialize(ar);
m_ss->Serialize(ar);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FETractionLoad.cpp | .cpp | 3,617 | 110 | /*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 "FETractionLoad.h"
#include "FEBioMech.h"
#include <FECore/FEFacetSet.h>
//=============================================================================
BEGIN_FECORE_CLASS(FETractionLoad, FESurfaceLoad)
ADD_PARAMETER(m_scale , "scale")->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE);
ADD_PARAMETER(m_traction, "traction")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_bshellb , "shell_bottom");
ADD_PARAMETER(m_blinear, "linear");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! constructor
FETractionLoad::FETractionLoad(FEModel* pfem) : FESurfaceLoad(pfem)
{
m_scale = 1.0;
m_traction = vec3d(0, 0, 0);
m_bshellb = false;
m_blinear = false;
}
//-----------------------------------------------------------------------------
//! allocate storage
void FETractionLoad::SetSurface(FESurface* ps)
{
FESurfaceLoad::SetSurface(ps);
m_traction.SetItemList(ps->GetFacetSet());
}
//-----------------------------------------------------------------------------
// initialization
bool FETractionLoad::Init()
{
FESurface& surf = GetSurface();
surf.SetShellBottom(m_bshellb);
// 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;
return FESurfaceLoad::Init();
}
//-----------------------------------------------------------------------------
void FETractionLoad::LoadVector(FEGlobalVector& R)
{
// evaluate the integral
FESurface& surf = GetSurface();
FETractionLoad* load = this;
surf.LoadVector(R, m_dof, m_blinear, [=](FESurfaceMaterialPoint& pt, const FESurfaceDofShape& dof_a, std::vector<double>& val) {
// evaluate traction at this material point
vec3d t = m_traction(pt)*m_scale;
if (load->m_bshellb) t = -t;
double J = (pt.dxr ^ pt.dxs).norm();
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 FETractionLoad::StiffnessMatrix(FELinearSystem& LS)
{
// Nothing to do here.
// TODO: I think if the linear flag is false, I do need to evaluate a stiffness.
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEHGOCoronary.h | .h | 2,294 | 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 "FEUncoupledFiberExpLinear.h"
//-----------------------------------------------------------------------------
// Constitutive formulation from:
// Holzapfel, et.a., "Determination of layer-specific mechanical properties of human
// coronary arteries with nonatherosclerotic intimal thickening
// and related constitutive modeling", Am J Physiol Heart Circ Physiol 289
class FEHGOCoronary : public FEUncoupledMaterial
{
public:
FEHGOCoronary(FEModel* pfem);
public:
double m_rho;
double m_k1;
double m_k2;
FEVec3dValuator* m_fiber;
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 deviatoric strain energy density at material point
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
protected:
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEPerfectOsmometer.h | .h | 2,251 | 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 "FEElasticMaterial.h"
//-----------------------------------------------------------------------------
//! Material class that implements the equilibrium of a perfect osmometer.
//! When used on its own (not in a solid mixture), this materials
//! is intrinsically unstable
class FEPerfectOsmometer : public FEElasticMaterial
{
public:
// constructor
FEPerfectOsmometer(FEModel* pfem);
//! Initialization routine
bool Init() override;
//! Returns the Cauchy stress
virtual mat3ds Stress(FEMaterialPoint& mp) override;
//! Returs the spatial tangent
virtual tens4ds Tangent(FEMaterialPoint& mp) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
public:
double m_phiwr; //!< fluid volume fraction in reference configuration
double m_iosm; //!< internal osmolarity in reference configuration
double m_Rgas; //!< universal gas constant
double m_Tabs; //!< absolute temperature
double m_bosm; //!< bath osmolarity
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEPointBodyForce.cpp | .cpp | 4,251 | 156 | /*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 "FEPointBodyForce.h"
#include <FECore/FEMesh.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEPointBodyForce, FEBodyForce);
ADD_PARAMETER(m_a, "a");
ADD_PARAMETER(m_b, "b");
ADD_PARAMETER(m_rc, "rc");
ADD_PARAMETER(m_inode, "node");
ADD_PARAMETER(m_brigid, "rigid");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPointBodyForce::FEPointBodyForce(FEModel* pfem) : FEBodyForce(pfem)
{
m_pel = 0;
m_brigid = true;
m_inode = -1;
}
//-----------------------------------------------------------------------------
vec3d FEPointBodyForce::force(FEMaterialPoint& mp)
{
vec3d x = mp.m_rt;
vec3d n = x - m_rc;
double l = n.unit();
double g = m_a*exp(-m_b*l);
return n*g;
}
//-----------------------------------------------------------------------------
double FEPointBodyForce::divforce(FEMaterialPoint& mp)
{
vec3d x = mp.m_rt;
vec3d n = x - m_rc;
double l = n.unit();
double g = m_a*exp(-m_b*l);
return (3-m_b*l)*g;
}
//-----------------------------------------------------------------------------
mat3d FEPointBodyForce::stiffness(FEMaterialPoint &mp)
{
vec3d x = mp.m_rt;
vec3d n = x - m_rc;
double l = n.unit();
mat3ds k;
if (l == 0.0)
{
k.zero();
}
else
{
double g = m_a*exp(-m_b*l);
mat3ds nxn = dyad(n);
mat3ds I = mat3dd(1.0);
k = (nxn*m_b - (I - nxn)/l)*g;
}
return k;
}
//-----------------------------------------------------------------------------
void FEPointBodyForce::Serialize(DumpStream &ar)
{
FEBodyForce::Serialize(ar);
ar & m_a & m_b & m_rc;
ar & m_inode & m_brigid;
}
//-----------------------------------------------------------------------------
bool FEPointBodyForce::Init()
{
FEMesh& m = GetMesh();
if (m_inode == -1)
{
if (!m_brigid)
{
// find the element in which point r0 lies
m_pel = m.FindSolidElement(m_rc, m_rs);
}
else m_pel = 0;
}
else
{
m_rc = m.Node(m_inode).m_r0;
}
return true;
}
//-----------------------------------------------------------------------------
// Update the position of the body force
void FEPointBodyForce::Update()
{
if (m_inode == -1)
{
if (m_pel)
{
FEMesh& m = GetMesh();
vec3d x[FEElement::MAX_NODES];
for (int i=0; i<8; ++i) x[i] = m.Node(m_pel->m_node[i]).m_rt;
double* r = m_rs;
double H[FEElement::MAX_NODES];
H[0] = 0.125*(1 - r[0])*(1 - r[1])*(1 - r[2]);
H[1] = 0.125*(1 + r[0])*(1 - r[1])*(1 - r[2]);
H[2] = 0.125*(1 + r[0])*(1 + r[1])*(1 - r[2]);
H[3] = 0.125*(1 - r[0])*(1 + r[1])*(1 - r[2]);
H[4] = 0.125*(1 - r[0])*(1 - r[1])*(1 + r[2]);
H[5] = 0.125*(1 + r[0])*(1 - r[1])*(1 + r[2]);
H[6] = 0.125*(1 + r[0])*(1 + r[1])*(1 + r[2]);
H[7] = 0.125*(1 - r[0])*(1 + r[1])*(1 + r[2]);
m_rc = vec3d(0,0,0);
for (int i=0; i<8; ++i) m_rc += x[i]*H[i];
}
}
else
{
FEMesh& m = GetMesh();
m_rc = m.Node(m_inode).m_rt;
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEActiveFiberContraction.h | .h | 2,254 | 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 "FEActiveContractionMaterial.h"
//-----------------------------------------------------------------------------
//! A material class describing the active fiber contraction
class FEActiveFiberContraction : public FEActiveContractionMaterial
{
public:
FEActiveFiberContraction(FEModel* pfem);
//! initialization
bool Init() override;
//! calculate the fiber stress
mat3ds ActiveStress(FEMaterialPoint& mp, const vec3d& a0) override;
//! active contraction stiffness contribution
tens4ds ActiveStiffness(FEMaterialPoint& mp, const vec3d& a0) override;
protected:
double m_ascl; //!< activation scale factor
double m_Tmax; //!< activation scale factor
double m_ca0; //!< intracellular calcium concentration
double m_camax; //!< peak calcium concentration
double m_beta; //!< shape of peak isometric tension-sarcomere length relation
double m_l0; //!< unloaded length
double m_refl; //!< sarcomere length
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FENeoHookeanAD.cpp | .cpp | 4,396 | 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 "FENeoHookeanAD.h"
#include <FECore/ad.h>
#include "adcm.h"
inline double lambdaFromEV(double E, double v)
{
return v* E / ((1.0 + v) * (1.0 - 2.0 * v));
}
inline double muFromEV(double E, double v)
{
return 0.5 * E / (1.0 + v);
}
// define the material parameters
BEGIN_FECORE_CLASS(FENeoHookeanAD, FEElasticMaterial)
ADD_PARAMETER(m_E, FE_RANGE_GREATER(0.0), "E")->setUnits(UNIT_PRESSURE)->setLongName("Young's modulus");
ADD_PARAMETER(m_v, FE_RANGE_RIGHT_OPEN(-1, 0.5), "v")->setLongName("Poisson's ratio");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FENeoHookeanAD::FENeoHookeanAD(FEModel* pfem) : FEElasticMaterial(pfem) {}
ad::number FENeoHookeanAD::StrainEnergy_AD(FEMaterialPoint& mp, ad::mat3ds& C)
{
// get the material parameters
double E = m_E(mp);
double v = m_v(mp);
double lam = lambdaFromEV(E, v);
double mu = muFromEV(E, v);
ad::number I1 = C.tr();
ad::number J = ad::sqrt(C.det());
ad::number lnJ = ad::log(J);
ad::number sed = mu * ((I1 - 3) / 2.0 - lnJ) + lam * lnJ * lnJ / 2.0;
return sed;
}
ad2::number FENeoHookeanAD::StrainEnergy_AD2(FEMaterialPoint& mp, ad2::mat3ds& C)
{
// get the material parameters
double E = m_E(mp);
double v = m_v(mp);
double lam = lambdaFromEV(E, v);
double mu = muFromEV(E, v);
ad2::number I1 = C.tr();
ad2::number J = ad2::sqrt(C.det());
ad2::number lnJ = ad2::log(J);
ad2::number sed = mu * ((I1 - 3) / 2.0 - lnJ) + lam * lnJ * lnJ / 2.0;
return sed;
}
ad::mat3ds FENeoHookeanAD::PK2Stress_AD(FEMaterialPoint& mp, ad::mat3ds& C)
{
// get the material parameters
double E = m_E(mp);
double v = m_v(mp);
double lam = lambdaFromEV(E, v);
double mu = muFromEV(E, v);
ad::mat3ds I(1.0);
ad::mat3ds Ci = C.inverse();
ad::number J = ad::sqrt(C.det());
ad::number lnJ = ad::log(J);
ad::mat3ds S = (I - Ci) * mu + Ci * (lam * lnJ);
return S;
}
mat3ds FENeoHookeanAD::Stress(FEMaterialPoint& mp)
{
// calculate PK2 stress
// mat3ds S = ad::PK2Stress<FENeoHookeanAD>(this, mp);
mat3ds S = ad2::PK2Stress<FENeoHookeanAD>(this, mp);
// push-forward to obtain Cauchy-stress
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds s = pt.push_forward(S);
return s;
}
tens4ds FENeoHookeanAD::Tangent(FEMaterialPoint& mp)
{
// calculate material tangent
// tens4ds C4 = ad::Tangent<FENeoHookeanAD>(this, mp);
tens4ds C4 = ad2::Tangent<FENeoHookeanAD>(this, mp);
// push forward to get spatial tangent
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
tens4ds c4 = pt.push_forward(C4);
return c4;
}
double FENeoHookeanAD::StrainEnergyDensity(FEMaterialPoint& mp)
{
return ad::StrainEnergy<FENeoHookeanAD>(this, mp);
}
mat3ds FENeoHookeanAD::PK2Stress(FEMaterialPoint& mp, const mat3ds ES)
{
mat3ds C = mat3dd(1) + ES * 2;
mat3ds S = ad::PK2Stress<FENeoHookeanAD>(this, mp, C);
return S;
}
tens4dmm FENeoHookeanAD::MaterialTangent(FEMaterialPoint& mp, const mat3ds ES)
{
mat3ds C = mat3dd(1) + ES * 2;
tens4ds C4 = ad::Tangent<FENeoHookeanAD>(this, mp, C);
return tens4dmm(C4);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FECoupledTransIsoVerondaWestmann.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>
//-----------------------------------------------------------------------------
//! Coupled transversely-isotropic Veronda-Westmann material
//!
class FECoupledTransIsoVerondaWestmann: public FEElasticMaterial
{
public:
FECoupledTransIsoVerondaWestmann(FEModel* pfem);
public:
double m_c1; //!< Veronda-Westmann coefficient C1
double m_c2; //!< Veronda-Westmann coefficient C2
double m_c3; //!< fiber stress scale factor
double m_c4; //!< exponential scale factor
double m_c5; //!< slope of linear stress region
double m_flam; //!< fiber stretch at which fibers are straight
double m_K; //!< "bulk"-modulus
FEVec3dValuator* m_fiber;
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 strain energy density at material point
double StrainEnergyDensity(FEMaterialPoint& pt) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledReactiveViscoelastic.cpp | .cpp | 25,107 | 752 | /*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 "FEUncoupledReactiveViscoelastic.h"
#include "FEUncoupledElasticMixture.h"
#include "FEFiberMaterialPoint.h"
#include "FEElasticFiberMaterialUC.h"
#include "FEScaledUncoupledMaterial.h"
#include <FECore/FECoreKernel.h>
#include <FECore/log.h>
#include <limits>
///////////////////////////////////////////////////////////////////////////////
//
// FEUncoupledReactiveViscoelasticMaterial
//
///////////////////////////////////////////////////////////////////////////////
// Material parameters for the FEUncoupledReactiveViscoelastic material
BEGIN_FECORE_CLASS(FEUncoupledReactiveViscoelasticMaterial, FEUncoupledMaterial)
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
FEUncoupledReactiveViscoelasticMaterial::FEUncoupledReactiveViscoelasticMaterial(FEModel* pfem) : FEUncoupledMaterial(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;
}
//-----------------------------------------------------------------------------
//! data initialization
bool FEUncoupledReactiveViscoelasticMaterial::Init()
{
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<FEDamageMaterialUC*>(m_pBase);
m_pFtg = dynamic_cast<FEUncoupledReactiveFatigue*>(m_pBase);
return FEUncoupledMaterial::Init();
}
//-----------------------------------------------------------------------------
//! Create material point data for this material
FEMaterialPointData* FEUncoupledReactiveViscoelasticMaterial::CreateMaterialPointData()
{
FEReactiveViscoelasticMaterialPoint* pt = new FEReactiveViscoelasticMaterialPoint();
// create materal point for strong bond (base) material
FEMaterialPointData* pbase = m_pBase->CreateMaterialPointData();
pt->AddMaterialPoint(new FEMaterialPoint(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* FEUncoupledReactiveViscoelasticMaterial::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* FEUncoupledReactiveViscoelasticMaterial::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 FEUncoupledReactiveViscoelasticMaterial::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 FEUncoupledReactiveViscoelasticMaterial::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 FEUncoupledReactiveViscoelasticMaterial::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 in strong bonds
mat3ds FEUncoupledReactiveViscoelasticMaterial::DevStressStrongBonds(FEMaterialPoint& mp)
{
mat3ds s = m_pBase->DevStress(*GetBaseMaterialPoint(mp));
return s;
}
//-----------------------------------------------------------------------------
//! Stress function in weak bonds
mat3ds FEUncoupledReactiveViscoelasticMaterial::DevStressWeakBonds(FEMaterialPoint& mp)
{
double dt = CurrentTimeIncrement();
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->DevStress(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->DevStress(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 FEUncoupledReactiveViscoelasticMaterial::DevStress(FEMaterialPoint& mp)
{
// calculate the base material Cauchy stress
mat3ds s = DevStressStrongBonds(mp);
s+= DevStressWeakBonds(mp)*(1-Damage(mp));
// return the total Cauchy stress
return s;
}
//-----------------------------------------------------------------------------
//! Material tangent in strong bonds
tens4ds FEUncoupledReactiveViscoelasticMaterial::DevTangentStrongBonds(FEMaterialPoint& mp)
{
// calculate the base material tangent
return m_pBase->DevTangent(*GetBaseMaterialPoint(mp));
}
//-----------------------------------------------------------------------------
//! Material tangent in weak bonds
tens4ds FEUncoupledReactiveViscoelasticMaterial::DevTangentWeakBonds(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->DevTangent(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->DevTangent(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 FEUncoupledReactiveViscoelasticMaterial::DevTangent(FEMaterialPoint& mp)
{
tens4ds c = DevTangentStrongBonds(mp);
c+= DevTangentWeakBonds(mp)*(1-Damage(mp));
// return the total tangent
return c;
}
//-----------------------------------------------------------------------------
//! strain energy density function for weak bonds
double FEUncoupledReactiveViscoelasticMaterial::StrongBondDevSED(FEMaterialPoint& mp)
{
// calculate the base material deviatoric strain energy density
return m_pBase->DevStrainEnergyDensity(*GetBaseMaterialPoint(mp));
}
//-----------------------------------------------------------------------------
//! strain energy density function
double FEUncoupledReactiveViscoelasticMaterial::WeakBondDevSED(FEMaterialPoint& mp)
{
double dt = CurrentTimeIncrement();
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->DevStrainEnergyDensity(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->DevStrainEnergyDensity(wb);
// add bond stress to total strain energy density
sed += sedb*w;
}
// restore safe copy of deformation gradient
ep.m_F = F;
ep.m_J = J;
}
return sed;
}
//-----------------------------------------------------------------------------
//! strain energy density function
double FEUncoupledReactiveViscoelasticMaterial::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
double sed = StrongBondDevSED(mp);
sed += WeakBondDevSED(mp)*(1-Damage(mp));
// return the total strain energy density
return sed;
}
//-----------------------------------------------------------------------------
//! Cull generations that have relaxed below a threshold
void FEUncoupledReactiveViscoelasticMaterial::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 FEUncoupledReactiveViscoelasticMaterial::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<FEElasticFiberMaterialUC*>(m_pBase)) && (dynamic_cast<FEElasticFiberMaterialUC*>(m_pBond)))
if ((m_pBase->DevStress(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);
double f = (!pt.m_v.empty()) ? ReformingBondMassFraction(wb) : 1;
pt.m_f.push_back(f);
if (m_pWCDF) {
pt.m_Et = ScalarStrain(wb);
pt.m_wv.push_back(m_pWCDF->brf(mp,pt.m_Et));
}
else pt.m_wv.push_back(1);
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(wb);
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 FEUncoupledReactiveViscoelasticMaterial::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 FEUncoupledReactiveViscoelasticMaterial::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 FEUncoupledReactiveViscoelasticMaterial::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));
return D;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEDeformableSpringDomain.h | .h | 5,494 | 181 | /*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/FEDiscreteDomain.h>
#include <FECore/FEDofList.h>
#include "FEElasticDomain.h"
#include "FESpringMaterial.h"
//-----------------------------------------------------------------------------
//! domain for deformable springs
class FEDeformableSpringDomain : public FEDiscreteDomain, public FEElasticDomain
{
public:
//! constructor
FEDeformableSpringDomain(FEModel* pfem);
//! Unpack LM data
void UnpackLM(FEElement& el, vector<int>& lm) override;
//! get the material (overridden from FEDomain)
FEMaterial* GetMaterial() override { return m_pMat; }
//! set the material
void SetMaterial(FEMaterial* pmat) override;
void Activate() override;
//! get the total dofs
const FEDofList& GetDOFList() const override;
public: // overridden from FEElasticDomain
//! build the matrix profile
void BuildMatrixProfile(FEGlobalMatrix& K) override;
//! calculate stiffness matrix
void StiffnessMatrix(FELinearSystem& LS) override;
void MassMatrix(FELinearSystem& LS, double scale) override {}
void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override {}
//! Calculates inertial forces for dynamic problems | todo implement (removed assert DSR)
void InertialForces(FEGlobalVector& R, vector<double>& F) override { }
//! update domain data
void Update(const FETimeInfo& tp) override {}
//! internal stress forces
void InternalForces(FEGlobalVector& R) override;
//! calculate bodyforces (not used since springs are considered mass-less)
void BodyForce(FEGlobalVector& R, FEBodyForce& bf) override {}
protected:
double InitialLength();
double CurrentLength();
protected:
FESpringMaterial* m_pMat;
double m_kbend; // bending stiffness
double m_kstab; // stabilization penalty
double m_L0; //!< initial spring length
protected:
FEDofList m_dofU, m_dofR, m_dof;
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
//! domain for deformable springs
//! This approach assumes that the nodes are distributed evenly between anchor
//! points. An anchor is a point that is constrained (e.g. prescribed, or in contact).
class FEDeformableSpringDomain2 : public FEDiscreteDomain, public FEElasticDomain
{
struct NodeData
{
bool banchor;
};
public:
//! constructor
FEDeformableSpringDomain2(FEModel* pfem);
//! Unpack LM data
void UnpackLM(FEElement& el, vector<int>& lm) override;
//! get the material (overridden from FEDomain)
FEMaterial* GetMaterial() override { return m_pMat; }
//! set the material
void SetMaterial(FEMaterial* pmat) override;
//! initialization
bool Init() override;
//! activation
void Activate() override;
//! get the total dofs
const FEDofList& GetDOFList() const override;
public:
//! Set the position of a node
void SetNodePosition(int node, const vec3d& r);
//! Anchor (or release) a node
void AnchorNode(int node, bool banchor);
//! see if a node is anchored
bool IsAnchored(int node) { return m_nodeData[node].banchor; }
//! Update the position of all the nodes
void UpdateNodes();
//! Get the net force on this node
vec3d NodalForce(int node);
//! get net spring force
double SpringForce();
//! tangent
vec3d Tangent(int node);
public: // overridden from FEElasticDomain
//! calculate stiffness matrix
void StiffnessMatrix(FELinearSystem& LS) override;
void MassMatrix(FELinearSystem& LS, double scale) override {}
void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override {}
//! Calculates inertial forces for dynamic problems | todo implement (removed assert DSR)
void InertialForces(FEGlobalVector& R, vector<double>& F) override { }
//! update domain data
void Update(const FETimeInfo& tp) override;
//! internal stress forces
void InternalForces(FEGlobalVector& R) override;
//! calculate bodyforces (not used since springs are considered mass-less)
void BodyForce(FEGlobalVector& R, FEBodyForce& bf) override {}
public:
double InitialLength();
double CurrentLength();
protected:
FESpringMaterial* m_pMat;
double m_L0; //!< initial wire length
double m_Lt; //!< current wire length
vector<NodeData> m_nodeData;
protected:
FEDofList m_dofU, m_dofR, m_dof;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEViscoElasticMaterial.cpp | .cpp | 11,031 | 329 | /*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 "FEViscoElasticMaterial.h"
#include "FEUncoupledMaterial.h"
#include <FECore/FECoreKernel.h>
#include <FECore/FEModel.h>
#include <FECore/DumpStream.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEViscoElasticMaterial, FEElasticMaterial)
// material parameters
ADD_PARAMETER(m_t[0], "t1")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[1], "t2")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[2], "t3")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[3], "t4")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[4], "t5")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[5], "t6")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_g0 , "g0");
ADD_PARAMETER(m_g[0], "g1");
ADD_PARAMETER(m_g[1], "g2");
ADD_PARAMETER(m_g[2], "g3");
ADD_PARAMETER(m_g[3], "g4");
ADD_PARAMETER(m_g[4], "g5");
ADD_PARAMETER(m_g[5], "g6");
// define the material properties
ADD_PROPERTY(m_Base, "elastic");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEViscoElasticMaterialPoint::FEViscoElasticMaterialPoint(FEMaterialPointData* mp) : FEMaterialPointData(mp)
{
m_sed = 0.0;
m_sedp = 0.0;
}
//-----------------------------------------------------------------------------
//! Create a shallow copy of the material point data
FEMaterialPointData* FEViscoElasticMaterialPoint::Copy()
{
FEViscoElasticMaterialPoint* pt = new FEViscoElasticMaterialPoint(*this);
if (m_pNext) pt->m_pNext = m_pNext->Copy();
return pt;
}
//-----------------------------------------------------------------------------
//! Initializes material point data.
void FEViscoElasticMaterialPoint::Init()
{
// intialize data to zero
m_Se.zero();
m_Sep.zero();
m_sed = 0.0;
m_sedp = 0.0;
for (int i=0; i<MAX_TERMS; ++i) {
m_H[i].zero();
m_Hp[i].zero();
m_alpha[i] = m_alphap[i] = 1.0;
}
// don't forget to initialize the base class
FEMaterialPointData::Init();
}
//-----------------------------------------------------------------------------
//! Update material point data.
void FEViscoElasticMaterialPoint::Update(const FETimeInfo& timeInfo)
{
// the elastic stress stored in pt is the Cauchy stress.
// however, we need to store the 2nd PK stress
m_Sep = m_Se;
m_sedp = m_sed;
// copy previous data
for (int i=0; i<MAX_TERMS; ++i) {
m_Hp[i] = m_H[i];
m_alphap[i] = m_alpha[i];
}
// don't forget to call the base class
FEMaterialPointData::Update(timeInfo);
}
//-----------------------------------------------------------------------------
//! Serialize data to the archive
void FEViscoElasticMaterialPoint::Serialize(DumpStream& ar)
{
FEMaterialPointData::Serialize(ar);
ar & m_Se;
ar & m_Sep;
ar & m_H & m_Hp;
ar & m_sed & m_sedp;
ar & m_alpha & m_alphap;
}
//-----------------------------------------------------------------------------
//! constructor
FEViscoElasticMaterial::FEViscoElasticMaterial(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_g0 = 1;
for (int i=0; i<MAX_TERMS; ++i)
{
m_t[i] = 1;
m_g[i] = 0;
}
m_Base = 0;
}
//-----------------------------------------------------------------------------
//! get the elastic base material \todo I want to call this GetElasticMaterial, but this name is being used
FEElasticMaterial* FEViscoElasticMaterial::GetBaseMaterial()
{
return m_Base;
}
//-----------------------------------------------------------------------------
//! Set the base material
void FEViscoElasticMaterial::SetBaseMaterial(FEElasticMaterial* pbase)
{
m_Base = pbase;
}
//-----------------------------------------------------------------------------
//! Create material point data for this material
FEMaterialPointData* FEViscoElasticMaterial::CreateMaterialPointData()
{
return new FEViscoElasticMaterialPoint(m_Base->CreateMaterialPointData());
}
//-----------------------------------------------------------------------------
//! Stress function
mat3ds FEViscoElasticMaterial::Stress(FEMaterialPoint& mp)
{
double dt = GetFEModel()->GetTime().timeIncrement;
if (dt == 0) return mat3ds(0, 0, 0, 0, 0, 0);
// get the elastic part
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
// get the viscoelastic point data
FEViscoElasticMaterialPoint& pt = *mp.ExtractData<FEViscoElasticMaterialPoint>();
// Calculate the new elastic Cauchy stress
mat3ds se = m_Base->Stress(mp);
// pull-back to get PK2 stress
mat3ds Se = pt.m_Se = ep.pull_back(se);
// get elastic PK2 stress of previous timestep
mat3ds Sep = pt.m_Sep;
// calculate new history variables
// terms are accumulated in S, the total PK2-stress
mat3ds S = Se* m_g0(mp);
double g, h;
for (int i=0; i<MAX_TERMS; ++i)
{
g = exp(-dt/m_t[i]);
h = (1 - g)/(dt/m_t[i]);
pt.m_H[i] = pt.m_Hp[i]*g + (Se - Sep)*h;
S += pt.m_H[i]*m_g[i];
}
// return the total Cauchy stress,
// which is the push-forward of S
return ep.push_forward(S);
}
//-----------------------------------------------------------------------------
//! Material tangent
tens4ds FEViscoElasticMaterial::Tangent(FEMaterialPoint& pt)
{
double dt = GetFEModel()->GetTime().timeIncrement;
// calculate the spatial elastic tangent
tens4ds C = m_Base->Tangent(pt);
if (dt == 0.0) return C;
// calculate the visco scale factor
double f = m_g0(pt), g, h;
for (int i=0; i<MAX_TERMS; ++i)
{
g = exp(-dt/m_t[i]);
h = ( 1 - exp(-dt/m_t[i]) )/( dt/m_t[i] );
f += m_g[i]*h;
}
// multiply tangent with visco-factor
return C*f;
}
//-----------------------------------------------------------------------------
//! Strain energy density function
double FEViscoElasticMaterial::StrainEnergyDensity(FEMaterialPoint& mp)
{
// get the viscoelastic point data
FEViscoElasticMaterialPoint& pt = *mp.ExtractData<FEViscoElasticMaterialPoint>();
FEElasticMaterialPoint& et = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d Fsafe = et.m_F; double Jsafe = et.m_J;
// Calculate the new elastic strain energy density
pt.m_sed = m_Base->StrainEnergyDensity(mp);
double sed = pt.m_sed;
double sedt = sed*m_g0(mp);
if (SeriesStretchExponent(mp)) {
// get the elastic point data and evaluate the right-stretch tensor
for (int i=0; i<MAX_TERMS; ++i)
{
if (m_g[i] > 0) {
mat3ds C = et.RightCauchyGreen();
double l2[3], l[3];
vec3d v[3];
C.eigen2(l2, v);
l[0] = sqrt(l2[0]); l[1] = sqrt(l2[1]); l[2] = sqrt(l2[2]);
mat3ds Ua = dyad(v[0])*pow(l[0],pt.m_alpha[i])
+ dyad(v[1])*pow(l[1],pt.m_alpha[i]) + dyad(v[2])*pow(l[2],pt.m_alpha[i]);
et.m_F = Ua; et.m_J = Ua.det();
sedt += m_g[i]*m_Base->StrainEnergyDensity(mp);
}
}
}
else
throw std::runtime_error("FEViscoElasticMaterial::strain energy density calculation did not converge!");
et.m_F = Fsafe; et.m_J = Jsafe;
// return the total strain energy density
return sedt;
}
//-----------------------------------------------------------------------------
//! calculate exponent of right-stretch tensor in series spring
bool FEViscoElasticMaterial::SeriesStretchExponent(FEMaterialPoint& mp)
{
const double errrel = 1e-6;
const double almin = 0.001;
const int maxiter = 50;
// get the elastic point data and evaluate the right-stretch tensor
FEElasticMaterialPoint& et = *mp.ExtractData<FEElasticMaterialPoint>();
// get the right stretch tensor
mat3ds C = et.RightCauchyGreen();
double l2[3], l[3];
vec3d v[3];
C.eigen2(l2, v);
l[0] = sqrt(l2[0]); l[1] = sqrt(l2[1]); l[2] = sqrt(l2[2]);
mat3ds U = dyad(v[0])*l[0] + dyad(v[1])*l[1] + dyad(v[2])*l[2];
double gamma = 0;
for (int i=0; i<MAX_TERMS; ++i) gamma += m_g[i];
// get the viscoelastic point data
FEViscoElasticMaterialPoint& pt = *mp.ExtractData<FEViscoElasticMaterialPoint>();
// use previous time solution as initial guess for the exponent
mat3ds Se = pt.m_Se;
mat3ds S = et.pull_back(et.m_s);
double fmag = Se.dotdot(U);
mat3d Fsafe = et.m_F; double Jsafe = et.m_J;
for (int i=0; i<MAX_TERMS; ++i) {
if (m_g[i] > 0) {
double alpha = pt.m_alphap[i];
bool done = false;
int iter = 0;
do {
mat3ds Ua = dyad(v[0])*pow(l[0],alpha) + dyad(v[1])*pow(l[1],alpha) + dyad(v[2])*pow(l[2],alpha);
et.m_F = Ua; et.m_J = Ua.det();
mat3ds Sea = et.pull_back(m_Base->Stress(mp));
double f = (Sea*m_g[i] - S + Se).dotdot(U);
tens4ds Cea = et.pull_back(m_Base->Tangent(mp));
mat3ds U2ap = dyad(v[0])*(pow(l[0],2*alpha)*log(l[0]))
+ dyad(v[1])*(pow(l[1],2*alpha)*log(l[1]))
+ dyad(v[2])*(pow(l[2],2*alpha)*log(l[2]));
double fprime = (Cea.dot(U2ap)).dotdot(U)*m_g[i];
if (fprime != 0) {
double dalpha = -f/fprime;
alpha += dalpha;
if (fabs(f) < errrel*fmag) done = true;
else if (fabs(dalpha) < errrel*fabs(alpha)) done = true;
else if (alpha > 1) { alpha = 1; done = true; }
else if (alpha < almin) { alpha = 0; done = true; }
else if (++iter > maxiter) done = true;
}
else
done = true;
} while (!done);
if (iter > maxiter) {
et.m_F = Fsafe; et.m_J = Jsafe;
return false;
}
pt.m_alpha[i] = alpha;
}
}
et.m_F = Fsafe; et.m_J = Jsafe;
return true;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEInitialDisplacement.cpp | .cpp | 2,410 | 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) 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 "FEInitialDisplacement.h"
#include "FEBioMech.h"
#include <FECore/FEMaterialPoint.h>
#include <FECore/FENode.h>
BEGIN_FECORE_CLASS(FEInitialDisplacement, FENodalIC)
ADD_PARAMETER(m_u0, "value")->setUnits(UNIT_LENGTH);
END_FECORE_CLASS();
FEInitialDisplacement::FEInitialDisplacement(FEModel* fem) : FENodalIC(fem)
{
m_u0 = vec3d(0, 0, 0);
}
// set the initial value
void FEInitialDisplacement::SetValue(const vec3d& u0)
{
m_u0 = u0;
}
// initialization
bool FEInitialDisplacement::Init()
{
FEDofList dofs(GetFEModel());
if (dofs.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT)) == false) return false;
SetDOFList(dofs);
return true;
}
// return the values for node i
void FEInitialDisplacement::GetNodalValues(int inode, std::vector<double>& values)
{
assert(values.size() == 3);
const FENodeSet& nset = *GetNodeSet();
const FENode& node = *nset.Node(inode);
FEMaterialPoint mp;
mp.m_r0 = node.m_r0;
mp.m_index = inode;
vec3d u0 = m_u0(mp);
values[0] = u0.x;
values[1] = u0.y;
values[2] = u0.z;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEContinuousElasticDamage.h | .h | 4,920 | 160 | /*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 "FEElasticFiberMaterial.h"
// These classes implement the elastic damage framework from
// Balzani, Brinkhues, Holzapfel, Comput. Methods Appl. Mech. Engrg. 213216 (2012) 139151
class FEFiberDamagePoint;
//=================================================================================================
// Base class for continuous damage elastic fiber materials.
//
class FEDamageElasticFiber : public FEElasticFiberMaterial
{
public:
FEDamageElasticFiber(FEModel* fem);
double Damage(FEMaterialPoint& mp);
double Damage(FEMaterialPoint& mp, int n);
//! Strain energy density
double FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) override;
// calculate stress in fiber direction a0
mat3ds FiberStress(FEMaterialPoint& mp, const vec3d& a0) override;
// Spatial tangent
tens4ds FiberTangent(FEMaterialPoint& mp, const vec3d& a0) override;
protected:
// strain-energy and its derivatives
virtual double Psi0(FEMaterialPoint& mp, const vec3d& a0);
virtual mat3ds dPsi0_dC(FEMaterialPoint& mp, const vec3d& a0);
virtual tens4ds d2Psi0_dC(FEMaterialPoint& mp, const vec3d& a0);
virtual double m(double P);
virtual double dm_dP(double P);
virtual double d2m_dP(double P);
protected:
// damage model parameters
double m_tinit; // start time of damage
double m_Dmax; // max damage
double m_beta_s; // saturation parameter
double m_gamma_max; // saturation parameter
double m_r_s, m_r_inf;
// D2 parameters
double m_D2_a;
double m_D2_b;
double m_D2_c;
double m_D2_d;
double m_D3_g0;
double m_D3_rg;
double m_D3_inf;
DECLARE_FECORE_CLASS();
};
//=================================================================================================
class FEDamageFiberPower : public FEDamageElasticFiber
{
public:
FEDamageFiberPower(FEModel* fem);
FEMaterialPointData* CreateMaterialPointData() override;
protected:
double Psi0(FEMaterialPoint& mp, const vec3d& a0) override;
mat3ds dPsi0_dC(FEMaterialPoint& mp, const vec3d& a0) override;
tens4ds d2Psi0_dC(FEMaterialPoint& mp, const vec3d& a0) override;
double m(double P) override;
double dm_dP(double P) override;
double d2m_dP(double P) override;
public:
// fiber parameters
double m_a1, m_a2, m_kappa;
DECLARE_FECORE_CLASS();
};
//=================================================================================================
class FEDamageFiberExponential : public FEDamageElasticFiber
{
public:
FEDamageFiberExponential(FEModel* fem);
FEMaterialPointData* CreateMaterialPointData() override;
protected:
double Psi0(FEMaterialPoint& mp, const vec3d& a0) override;
mat3ds dPsi0_dC(FEMaterialPoint& mp, const vec3d& a0) override;
tens4ds d2Psi0_dC(FEMaterialPoint& mp, const vec3d& a0) override;
double m(double P) override;
double dm_dP(double P) override;
double d2m_dP(double P) override;
public:
// fiber parameters
double m_k1, m_k2, m_kappa;
DECLARE_FECORE_CLASS();
};
//=================================================================================================
class FEDamageFiberExpLinear: public FEDamageElasticFiber
{
public:
FEDamageFiberExpLinear(FEModel* fem);
FEMaterialPointData* CreateMaterialPointData() override;
protected:
double Psi0(FEMaterialPoint& mp, const vec3d& a0) override;
mat3ds dPsi0_dC(FEMaterialPoint& mp, const vec3d& a0) override;
tens4ds d2Psi0_dC(FEMaterialPoint& mp, const vec3d& a0) override;
double m(double P) override;
double dm_dP(double P) override;
double d2m_dP(double P) override;
public:
double m_c3;
double m_c4;
double m_c5;
double m_lamax;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEMooneyRivlinAD.cpp | .cpp | 4,511 | 149 | /*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 "FEMooneyRivlinAD.h"
#include "adcm.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEMooneyRivlinAD, FEUncoupledMaterial)
ADD_PARAMETER(m_c1, "c1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_c2, "c2")->setUnits(UNIT_PRESSURE);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Calculate the deviatoric stress
mat3ds FEMooneyRivlinAD::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get material parameters
double c1 = m_c1(mp);
double c2 = m_c2(mp);
// 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());
// --- TODO: put strain energy derivatives here ---
//
// W = C1*(I1 - 3) + C2*(I2 - 3)
//
// Wi = dW/dIi
double W1 = c1;
double W2 = c2;
// ---
// calculate T = F*dW/dC*Ft
// T = F*dW/dC*Ft
mat3ds T = B * (W1 + W2 * I1) - B2 * W2;
return T.dev() * (2.0 / J);
}
ad::mat3ds FEMooneyRivlinAD::PK2Stress_AD(FEMaterialPoint& mp, ad::mat3ds& C)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get material parameters
double c1 = m_c1(mp);
double c2 = m_c2(mp);
// determinant of deformation gradient
double J = pt.m_J;
double Jm23 = pow(J, -1.0 / 3.0);
ad::mat3ds C2 = C.sqr();
ad::mat3ds Ci = C.inverse();
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
ad::number I1 = C.tr();
ad::number I2 = 0.5 * (I1 * I1 - C2.tr());
// calculate T = dW/dC
ad::mat3ds I(1.0);
ad::mat3ds T = I*c1 + C*(0.5*c2);
// calculte S = 2*DEV[T]
ad::mat3ds S = (T - Ci * (T.dotdot(C) / 3.0))*(2.0*Jm23);
return S;
}
//-----------------------------------------------------------------------------
//! Calculate the deviatoric tangent
tens4ds FEMooneyRivlinAD::DevTangent(FEMaterialPoint& mp)
{
// calculate material tangent
tens4ds C4 = ad::Tangent<FEMooneyRivlinAD>(this, mp);
// push forward to get spatial tangent
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
tens4ds c4 = pt.push_forward(C4);
return c4;
}
//-----------------------------------------------------------------------------
//! calculate deviatoric strain energy density
double FEMooneyRivlinAD::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get material parameters
double c1 = m_c1(mp);
double c2 = m_c2(mp);
// 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());
//
// W = C1*(I1 - 3) + C2*(I2 - 3)
//
double sed = c1 * (I1 - 3) + c2 * (I2 - 3);
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEStickyInterface.h | .h | 4,530 | 145 | /*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"
//-----------------------------------------------------------------------------
//! This class describes a contact surface used for sticky contact.
//! this class is used in contact analyses to describe a contacting
//! surface in a sticky contact interface.
class FEStickySurface : public FEContactSurface
{
public:
class Data
{
public:
Data();
void Serialize(DumpStream& ar);
public:
vec3d gap; //!< "gap" function
double scalar_gap;
vec2d rs; //!< natural coordinates of projection on secondary surface element
vec3d Lm; //!< Lagrange multiplier
vec3d tn; //!< traction vector
FESurfaceElement* pme; //!< secondary surface element a node penetrates
};
public:
//! constructor
FEStickySurface(FEModel* pfem) : FEContactSurface(pfem) {}
//! Initializes data structures
bool Init();
//! data serialization
void Serialize(DumpStream& ar);
public:
void GetContactTraction(int nface, vec3d& pt);
void GetNodalContactPressure(int nface, double* pn);
void GetNodalContactTraction(int nface, vec3d* tn);
public:
vector<Data> m_data; //!< node contact data
};
//-----------------------------------------------------------------------------
//! This class implements a sticky interface.
//! A sticky interface is like tied, but nodes are only tied when they come into
//! contact.
class FEStickyInterface : public FEContactInterface
{
public:
//! constructor
FEStickyInterface(FEModel* pfem);
//! destructor
virtual ~FEStickyInterface(){}
//! Initializes sliding interface
bool Init() override;
//! interface activation
void Activate() override;
//! projects nodes onto secondary surface
void ProjectSurface(FEStickySurface& ss, FEStickySurface& ms, bool bmove = false);
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! return the primary and secondary surface
FESurface* GetPrimarySurface() override { return &ss; }
FESurface* GetSecondarySurface() override { return &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;
private:
void SerializePointers(FEStickySurface& ss, FEStickySurface& ms, DumpStream& ar);
public:
FEStickySurface ss; //!< primary surface
FEStickySurface ms; //!< secondary surface
double m_atol; //!< augmentation tolerance
double m_eps; //!< penalty scale factor
double m_stol; //!< search tolerance
int m_naugmax; //!< maximum nr of augmentations
int m_naugmin; //!< minimum nr of augmentations
double m_tmax; //!< max traction
double m_snap; //!< snap tolerance
bool m_flip_secondary; //!< flip the normal on the secondary surface
double m_gap_offset; //!< offset added to gap
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FE2DTransIsoMooneyRivlin.h | .h | 2,645 | 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 "FEUncoupledMaterial.h"
//-----------------------------------------------------------------------------
//! 2D transversely isotropic Mooney-Rivlin
//! This class describes a transversely isotropic matrix where the base material
//! is Mooney-Rivlin. The difference between this material and the FETransIsoMooneyRivlin
//! material is that in this material the fibers lie in the plane that is perpendicular
//! to the transverse axis.
class FE2DTransIsoMooneyRivlin : public FEUncoupledMaterial
{
enum { NSTEPS = 12 }; // nr of integration steps
public:
// material parameters
double m_c1; //!< Mooney-Rivlin parameter c1
double m_c2; //!< Mooney-Rivlin parameter c2
// fiber parameters
double m_c3;
double m_c4;
double m_c5;
double m_lam1;
double m_w[2];
double m_epsf;
FEVec3dValuator* m_fiber;
//--- active contraction stuff ---
double m_a[2];
double m_ac;
// -------------------------------
public:
//! constructor
FE2DTransIsoMooneyRivlin(FEModel* pfem);
//! calculate deviatoric stress at material point
virtual mat3ds DevStress(FEMaterialPoint& pt) override;
//! calculate deviatoric tangent stiffness at material point
virtual tens4ds DevTangent(FEMaterialPoint& pt) override;
// declare parameter list
DECLARE_FECORE_CLASS();
protected:
static double m_cth[NSTEPS];
static double m_sth[NSTEPS];
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEDistanceConstraint.cpp | .cpp | 8,939 | 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 "FEDistanceConstraint.h"
#include <FECore/FELinearSystem.h>
#include "FEBioMech.h"
#include <FECore/FEMesh.h>
#include <FECore/log.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEDistanceConstraint, FENLConstraint);
ADD_PARAMETER(m_blaugon, "laugon" );
ADD_PARAMETER(m_atol , "augtol" );
ADD_PARAMETER(m_eps , "penalty");
ADD_PARAMETER(m_nodeID , 2, "node");
ADD_PARAMETER(m_nminaug, "minaug");
ADD_PARAMETER(m_nmaxaug, "maxaug");
ADD_PARAMETER(m_target, "target");
ADD_PARAMETER(m_brelative, "relative");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! constructor
FEDistanceConstraint::FEDistanceConstraint(FEModel* pfem) : FENLConstraint(pfem), m_dofU(pfem)
{
m_eps = 0.0;
m_atol = 0.01;
m_blaugon = false;
m_node[0] = -1;
m_node[1] = -1;
m_nodeID[0] = -1;
m_nodeID[1] = -1;
m_l0 = 0.0;
m_Lm = 0.0;
m_nminaug = 0;
m_nmaxaug = 10;
m_target = 0;
m_brelative = true;
// TODO: Can this be done in Init, since there is no error checking
if (pfem)
{
m_dofU.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
}
}
//-----------------------------------------------------------------------------
//! Initializes data structures.
bool FEDistanceConstraint::Init()
{
// get the FE mesh
FEMesh& mesh = GetMesh();
int NN = mesh.Nodes();
// make sure the nodes are valid
m_node[0] = mesh.FindNodeIndexFromID(m_nodeID[0]);
m_node[1] = mesh.FindNodeIndexFromID(m_nodeID[1]);
if ((m_node[0] < 0)||(m_node[0] >= NN)) return false;
if ((m_node[1] < 0)||(m_node[1] >= NN)) return false;
return true;
}
//-----------------------------------------------------------------------------
void FEDistanceConstraint::Activate()
{
// don't forget to call base class
FENLConstraint::Activate();
// get the FE mesh
FEMesh& mesh = GetMesh();
int NN = mesh.Nodes();
// get the initial position of the two nodes
vec3d ra = mesh.Node(m_node[0]).m_rt;
vec3d rb = mesh.Node(m_node[1]).m_rt;
// set the initial length
m_l0 = (ra - rb).norm();
}
//-----------------------------------------------------------------------------
void FEDistanceConstraint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
// get the FE mesh
FEMesh& mesh = GetMesh();
// get the two nodes
FENode& nodea = mesh.Node(m_node[0]);
FENode& nodeb = mesh.Node(m_node[1]);
// get the current position of the two nodes
vec3d ra = nodea.m_rt;
vec3d rb = nodeb.m_rt;
// calculate the force
double lt = (ra - rb).norm();
double l0 = (m_brelative ? m_l0 + m_target : m_target);
if (l0 < 0) l0 = 0;
double Lm = m_Lm + m_eps*(lt - l0);
vec3d Fc = (ra - rb)*(Lm/lt);
// setup the "element" force vector
vector<double> fe(6);
fe[0] = -Fc.x;
fe[1] = -Fc.y;
fe[2] = -Fc.z;
fe[3] = Fc.x;
fe[4] = Fc.y;
fe[5] = Fc.z;
// setup the LM vector
vector<int> lm(6);
lm[0] = nodea.m_ID[m_dofU[0]];
lm[1] = nodea.m_ID[m_dofU[1]];
lm[2] = nodea.m_ID[m_dofU[2]];
lm[3] = nodeb.m_ID[m_dofU[0]];
lm[4] = nodeb.m_ID[m_dofU[1]];
lm[5] = nodeb.m_ID[m_dofU[2]];
// setup element vector
vector<int> en(2);
en[0] = m_node[0];
en[1] = m_node[1];
// add element force vector to global force vector
R.Assemble(en, lm, fe);
}
//-----------------------------------------------------------------------------
void FEDistanceConstraint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
// get the FE mesh
FEMesh& mesh = GetMesh();
// get the two nodes
FENode& nodea = mesh.Node(m_node[0]);
FENode& nodeb = mesh.Node(m_node[1]);
// get the current position of the two nodes
vec3d ra = nodea.m_rt;
vec3d rb = nodeb.m_rt;
vec3d rab = ra - rb;
// calculate the Lagrange mulitplier
double lt = rab.norm();
double l3 = lt*lt*lt;
double l0 = (m_brelative ? m_l0 + m_target : m_target);
if (l0 < 0) l0 = 0;
double Lm = m_Lm + m_eps*(lt - l0);
// calculate the stiffness
mat3d kab;
kab[0][0] = (m_eps*l0*rab.x*rab.x/l3 + Lm/lt);
kab[1][1] = (m_eps*l0*rab.y*rab.y/l3 + Lm/lt);
kab[2][2] = (m_eps*l0*rab.z*rab.z/l3 + Lm/lt);
kab[0][1] = kab[1][0] = (m_eps*l0*rab.x*rab.y/l3);
kab[0][2] = kab[2][0] = (m_eps*l0*rab.x*rab.z/l3);
kab[1][2] = kab[2][1] = (m_eps*l0*rab.y*rab.z/l3);
// element stiffness matrix
FEElementMatrix ke;
ke.resize(6, 6);
ke.zero();
ke[0][0] = kab[0][0]; ke[0][1] = kab[0][1]; ke[0][2] = kab[0][2]; ke[0][3] = -kab[0][0]; ke[0][4] = -kab[0][1]; ke[0][5] = -kab[0][2];
ke[1][0] = kab[1][0]; ke[1][1] = kab[1][1]; ke[1][2] = kab[1][2]; ke[1][3] = -kab[1][0]; ke[1][4] = -kab[1][1]; ke[1][5] = -kab[1][2];
ke[2][0] = kab[2][0]; ke[2][1] = kab[2][1]; ke[2][2] = kab[2][2]; ke[2][3] = -kab[2][0]; ke[2][4] = -kab[2][1]; ke[2][5] = -kab[2][2];
ke[3][0] = -kab[0][0]; ke[3][1] = -kab[0][1]; ke[3][2] = -kab[0][2]; ke[3][3] = kab[0][0]; ke[3][4] = kab[0][1]; ke[3][5] = kab[0][2];
ke[4][0] = -kab[1][0]; ke[4][1] = -kab[1][1]; ke[4][2] = -kab[1][2]; ke[4][3] = kab[1][0]; ke[4][4] = kab[1][1]; ke[4][5] = kab[1][2];
ke[5][0] = -kab[2][0]; ke[5][1] = -kab[2][1]; ke[5][2] = -kab[2][2]; ke[5][3] = kab[2][0]; ke[5][4] = kab[2][1]; ke[5][5] = kab[2][2];
// setup the LM vector
vector<int> lm(6);
lm[0] = nodea.m_ID[m_dofU[0]];
lm[1] = nodea.m_ID[m_dofU[1]];
lm[2] = nodea.m_ID[m_dofU[2]];
lm[3] = nodeb.m_ID[m_dofU[0]];
lm[4] = nodeb.m_ID[m_dofU[1]];
lm[5] = nodeb.m_ID[m_dofU[2]];
// setup element vector
vector<int> en(2);
en[0] = m_node[0];
en[1] = m_node[1];
// assemble element matrix in global stiffness matrix
ke.SetNodes(en);
ke.SetIndices(lm);
LS.Assemble(ke);
}
//-----------------------------------------------------------------------------
bool FEDistanceConstraint::Augment(int naug, const FETimeInfo& tp)
{
// make sure we are augmenting
if ((m_blaugon == false) || (m_atol <= 0.0)) return true;
// get the FE mesh
FEMesh& mesh = GetMesh();
// get the two nodes
FENode& nodea = mesh.Node(m_node[0]);
FENode& nodeb = mesh.Node(m_node[1]);
// get the current position of the two nodes
vec3d ra = nodea.m_rt;
vec3d rb = nodeb.m_rt;
// calculate the Lagrange multipler
double l = (ra - rb).norm();
double l0 = (m_brelative ? m_l0 + m_target : m_target);
if (l0 < 0) l0 = 0;
double Lm = m_Lm + m_eps*(l - l0);
// calculate force
vec3d Fc = (ra - rb)*(Lm/l);
// calculate relative error
bool bconv = false;
double err = fabs((Lm - m_Lm)/Lm);
if (err < m_atol) bconv = true;
feLog("\ndistance constraint:\n");
feLog("\tmultiplier= %lg (error = %lg / %lg)\n", Lm, err, m_atol);
feLog("\tforce = %lg, %lg, %lg\n", Fc.x, Fc.y, Fc.z);
feLog("\tdistance = %lg (L0 = %lg)\n", l, m_l0);
// check convergence
if (m_nminaug > naug) bconv = false;
if (m_nmaxaug <= naug) bconv = true;
// update Lagrange multiplier
// (only when we did not converge)
if (bconv == false) m_Lm = Lm;
return bconv;
}
//-----------------------------------------------------------------------------
void FEDistanceConstraint::BuildMatrixProfile(FEGlobalMatrix& M)
{
FEMesh& mesh = GetMesh();
vector<int> lm(6);
FENode& n0 = mesh.Node(m_node[0]);
lm[0] = n0.m_ID[m_dofU[0]];
lm[1] = n0.m_ID[m_dofU[1]];
lm[2] = n0.m_ID[m_dofU[2]];
FENode& n1 = mesh.Node(m_node[1]);
lm[3] = n1.m_ID[m_dofU[0]];
lm[4] = n1.m_ID[m_dofU[1]];
lm[5] = n1.m_ID[m_dofU[2]];
M.build_add(lm);
}
//-----------------------------------------------------------------------------
void FEDistanceConstraint::Serialize(DumpStream& ar)
{
FENLConstraint::Serialize(ar);
ar & m_Lm;
}
//-----------------------------------------------------------------------------
void FEDistanceConstraint::Reset()
{
m_Lm = 0.0;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FETractionRobinBC.cpp | .cpp | 5,346 | 163 | /*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 "FETractionRobinBC.h"
#include "FEBioMech.h"
#include <FECore/FEFacetSet.h>
#include <FECore/FEModel.h>
//=============================================================================
BEGIN_FECORE_CLASS(FETractionRobinBC, FESurfaceLoad)
ADD_PARAMETER(m_epsk , "spring_eps")->setUnits("P/L");
ADD_PARAMETER(m_epsc , "dashpot_eps")->setUnits("P.t/L");
ADD_PARAMETER(m_bshellb , "shell_bottom");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! constructor
FETractionRobinBC::FETractionRobinBC(FEModel* pfem) : FESurfaceLoad(pfem)
{
m_epsk = 0.0;
m_epsc = 0.0;
m_bshellb = false;
}
//-----------------------------------------------------------------------------
//! allocate storage
void FETractionRobinBC::SetSurface(FESurface* ps)
{
FESurfaceLoad::SetSurface(ps);
}
//-----------------------------------------------------------------------------
// initialization
bool FETractionRobinBC::Init()
{
FESurface& surf = GetSurface();
surf.SetShellBottom(m_bshellb);
// 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;
return FESurfaceLoad::Init();
}
//-----------------------------------------------------------------------------
void FETractionRobinBC::Update()
{
FETimeInfo tp = GetFEModel()->GetTime();
FESurface& surf = GetSurface();
for (int i=0; i<surf.Elements(); ++i) {
FESurfaceElement& el = surf.Element(i);
int nint = el.GaussPoints();
for (int n=0; n<nint; ++n) {
FEMaterialPoint* mp = el.GetMaterialPoint(n);
mp->Update(tp);
}
}
surf.Update(tp);
}
//-----------------------------------------------------------------------------
void FETractionRobinBC::LoadVector(FEGlobalVector& R)
{
if (GetFEModel()->GetTime().currentTime == 0) return;
double dt = GetFEModel()->GetTime().timeIncrement;
// evaluate the integral
FESurface& surf = GetSurface();
surf.LoadVector(R, m_dof, false, [=](FESurfaceMaterialPoint& pt, const FESurfaceDofShape& dof_a, std::vector<double>& val) {
// evaluate traction at this material point
double epsk = m_epsk(pt);
double epsc = m_epsc(pt);
vec3d u = pt.m_rt - pt.m_r0;
vec3d udot = (dt > 0) ? (pt.m_rt - pt.m_rp)/dt : vec3d(0,0,0);
vec3d t = -u*epsk - udot*epsc;
if (m_bshellb) t = -t;
double J = (pt.dxr ^ pt.dxs).norm();
double Na = dof_a.shape;
val[0] = Na * t.x*J;
val[1] = Na * t.y*J;
val[2] = Na * t.z*J;
});
}
//-----------------------------------------------------------------------------
void FETractionRobinBC::StiffnessMatrix(FELinearSystem& LS)
{
if (GetFEModel()->GetTime().currentTime == 0) return;
double dt = GetFEModel()->GetTime().timeIncrement;
// evaluate the integral
FESurface& surf = GetSurface();
surf.LoadStiffness(LS, m_dof, m_dof, [&](FESurfaceMaterialPoint& pt, const FESurfaceDofShape& dof_a, const FESurfaceDofShape& dof_b, matrix& kab) {
// evaluate pressure at this material point
vec3d n = (pt.dxr ^ pt.dxs);
double J = n.unit();
mat3dd I(1);
double epsk = m_epsk(pt);
double epsc = m_epsc(pt);
vec3d u = pt.m_rt - pt.m_r0;
vec3d udot = (dt > 0) ? (pt.m_rt - pt.m_rp)/dt : vec3d(0,0,0);
vec3d t = -u*epsk - udot*epsc;
if (m_bshellb) t = -t;
double Na = dof_a.shape;
double dNar = dof_a.shape_deriv_r;
double dNas = dof_a.shape_deriv_s;
double Nb = dof_b.shape;
double dNbr = dof_b.shape_deriv_r;
double dNbs = dof_b.shape_deriv_s;
mat3d Kab = (J*Na*Nb)*(epsk+epsc/dt)*mat3dd(1)
+((t & n)*mat3da(pt.dxr*dNbs - pt.dxs*dNbr)*(Na*J));
kab.set(0, 0, Kab);
});
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERVEFatigueMaterial.h | .h | 2,796 | 78 | /*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 "FEReactiveViscoelastic.h"
#include "FEReactiveFatigue.h"
//-----------------------------------------------------------------------------
// This material models damage in any reactive viscoelastic material.
class FERVEFatigueMaterial : public FEElasticMaterial
{
public:
FERVEFatigueMaterial(FEModel* pfem);
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;
//! 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
FEElasticMaterial* GetElasticMaterial() override { return m_pRVE->GetElasticMaterial(); }
//! specialized material points
void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override
{
m_pRVE->UpdateSpecializedMaterialPoints(mp, tp);
}
public:
double StrongBondSED(FEMaterialPoint& pt) override;
double WeakBondSED(FEMaterialPoint& pt) override;
public:
FEReactiveViscoelasticMaterial* m_pRVE; // reactive viscoelastic material
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberNeoHookean.cpp | .cpp | 4,260 | 148 | /*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 "FEFiberNeoHookean.h"
//-----------------------------------------------------------------------------
// FEFiberNH
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberNH, FEFiberMaterial)
ADD_PARAMETER(m_mu, FE_RANGE_GREATER_OR_EQUAL(0.0), "mu")->setUnits(UNIT_PRESSURE);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFiberNH::FEFiberNH(FEModel* pfem) : FEFiberMaterial(pfem)
{
m_mu = 0;
m_epsf = 0.0;
}
//-----------------------------------------------------------------------------
mat3ds FEFiberNH::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();
// Calculate In = n0*C*n0
double In_1 = n0*(C*n0) - 1.0;
// only take fibers in tension into consideration
mat3ds s;
if (In_1 > 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 the fiber stress
s = N*(m_mu*In_1/J);
}
else
{
s.zero();
}
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEFiberNH::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();
// Calculate In = n0*C*n0
double In_1 = n0*(C*n0) - 1.0;
// only take fibers in tension into consideration
tens4ds c;
const double eps = m_epsf*std::numeric_limits<double>::epsilon();
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 tangent
c = NxN*(2*m_mu/J);
}
else
{
c.zero();
}
return c;
}
//-----------------------------------------------------------------------------
//! Strain energy density
double FEFiberNH::FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
// Calculate In = n0*C*n0
double In_1 = n0*(C*n0) - 1.0;
// only take fibers in tension into consideration
double sed = 0.0;
if (In_1 > 0.0)
sed = 0.25*m_mu*In_1*In_1;
return sed;
}
// define the material parameters
BEGIN_FECORE_CLASS(FEElasticFiberNH, FEElasticFiberMaterial)
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/FEDamageCriterion.cpp | .cpp | 12,556 | 344 | /*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 "FEDamageCriterion.h"
#include "FEDamageMaterial.h"
#include <algorithm>
#include <limits>
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
//-----------------------------------------------------------------------------
// Simo's damage criterion uses sqrt(2*strain energy density)
double FEDamageCriterionSimo::DamageCriterion(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
double sed = m_pBase->StrainEnergyDensity(pt);
// clean up round-off errors
if (sed < 0) sed = 0;
return sqrt(2*sed);
}
//-----------------------------------------------------------------------------
// Strain energy density damage criterion
double FEDamageCriterionSED::DamageCriterion(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
double sed = m_pBase->StrainEnergyDensity(pt);
return sed;
}
//-----------------------------------------------------------------------------
// Specific strain energy damage criterion
double FEDamageCriterionSSE::DamageCriterion(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
double sed = m_pBase->StrainEnergyDensity(pt);
return sed/ m_pBase->Density(pt);
}
//-----------------------------------------------------------------------------
// von Mises stress damage criterion
double FEDamageCriterionVMS::DamageCriterion(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
double vms = sqrt((SQR(s.xx()-s.yy()) + SQR(s.yy()-s.zz()) + SQR(s.zz()-s.xx())
+ 6*(SQR(s.xy()) + SQR(s.yz()) + SQR(s.xz())))/2);
return vms;
}
//-----------------------------------------------------------------------------
//! criterion tangent with respect to stress
mat3ds FEDamageCriterionVMS::CriterionStressTangent(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
double vms = DamageCriterion(pt);
mat3ds dPhi = (vms > std::numeric_limits<double>::epsilon()) ? s.dev()*(1.5/vms) : mat3dd(1);
return dPhi;
}
//-----------------------------------------------------------------------------
// Drucker yield criterion
BEGIN_FECORE_CLASS(FEDamageCriterionDrucker, FEDamageCriterion)
ADD_PARAMETER(m_c, FE_RANGE_CLOSED(-27.0/8.0,9.0/4.0), "c");
END_FECORE_CLASS();
double FEDamageCriterionDrucker::DamageCriterion(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
mat3ds sdev = s.dev();
double J2 = (sdev*sdev).trace()/2;
double J3 = sdev.det();
double c = m_c(pt);
double tau = pow(pow(J2,3) - c*pow(J3,2),1./6.);
return tau;
}
//-----------------------------------------------------------------------------
//! criterion tangent with respect to stress
mat3ds FEDamageCriterionDrucker::CriterionStressTangent(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
mat3ds sdev = s.dev();
double J2 = (sdev*sdev).trace()/2;
double J3 = sdev.det();
double c = m_c(pt);
double tau = pow(pow(J2,3) - c*pow(J3,2),1./6.);
return (s.dev()*(pow(J2,2)/2) - (sdev.inverse()).dev()*(pow(J3, 2)*c/3))/pow(tau, 5);
}
//-----------------------------------------------------------------------------
// max shear stress damage criterion
double FEDamageCriterionMSS::DamageCriterion(FEMaterialPoint& pt)
{
// evaluate stress tensor
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
// evaluate principal normal stresses
double ps[3];
s.eigen2(ps); // sorted in ascending order
// evaluate max shear stresses
double mss = (ps[2] - ps[0])/2;
return mss;
}
//-----------------------------------------------------------------------------
//! criterion tangent with respect to stress
mat3ds FEDamageCriterionMSS::CriterionStressTangent(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
// evaluate principal normal stresses
double ps[3];
vec3d v[3];
s.eigen2(ps,v); // sorted in ascending order
// clean up small differences
const double eps = 1e-6;
if (fabs(ps[2] - ps[0]) <= eps*fabs(ps[2])) ps[0] = ps[2];
if (fabs(ps[2] - ps[1]) <= eps*fabs(ps[2])) ps[1] = ps[2];
// return tangent
mat3ds N;
if (ps[2] > ps[1]) {
if (ps[1] > ps[0])
N = (dyad(v[2])-dyad(v[0]))/2;
else
N = (dyad(v[2])-(dyad(v[1]) + dyad(v[0]))/2)/2;
}
else if (ps[1] > ps[0])
N = ((dyad(v[2]) + dyad(v[1]))/2 - dyad(v[0]))/2;
else N.zero();
return N;
}
//-----------------------------------------------------------------------------
// max normal stress damage criterion
double FEDamageCriterionMNS::DamageCriterion(FEMaterialPoint& pt)
{
// evaluate stress tensor
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
// evaluate principal normal stresses
double ps[3];
s.eigen2(ps); // sorted in ascending order
return ps[2];
}
//-----------------------------------------------------------------------------
//! criterion tangent with respect to stress
mat3ds FEDamageCriterionMNS::CriterionStressTangent(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
// evaluate principal normal stresses
double ps[3];
vec3d v[3];
s.eigen2(ps,v); // sorted in ascending order
// clean up small differences
const double eps = 1e-6;
if (fabs(ps[2] - ps[0]) <= eps*fabs(ps[2])) ps[0] = ps[2];
if (fabs(ps[2] - ps[1]) <= eps*fabs(ps[2])) ps[1] = ps[2];
// return tangent
mat3ds N;
if (ps[2] > ps[1]) N = dyad(v[2]);
else if (ps[2] > ps[0]) N = dyad(v[2]) + dyad(v[1]);
else N = mat3dd(1);
return N;
}
//-----------------------------------------------------------------------------
// max normal Lagrange strain damage criterion
double FEDamageCriterionMNLS::DamageCriterion(FEMaterialPoint& mp)
{
// evaluate strain tensor
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
// evaluate principal normal strains
double ps[3];
E.eigen2(ps);
// evaluate max normal Lagrange strain
double mnls = max(max(ps[0],ps[1]),ps[2]);
return mnls;
}
//-----------------------------------------------------------------------------
// octahedral shear strain damage criterion
double FEDamageCriterionOSS::DamageCriterion(FEMaterialPoint& mp)
{
// evaluate strain tensor
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
mat3ds devE = E.dev();
double oss = sqrt(devE.dotdot(devE)*(2./3.));
return oss;
}
//-----------------------------------------------------------------------------
// octahedral natural shear strain damage criterion
double FEDamageCriterionONS::DamageCriterion(FEMaterialPoint& mp)
{
// evaluate strain tensor
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
mat3ds devh = h.dev();
double ons = sqrt(devh.dotdot(devh)*(2./3.));
return ons;
}
//-----------------------------------------------------------------------------
// Drucker-Prager yield criterion
BEGIN_FECORE_CLASS(FEDamageCriterionDruckerPrager, FEDamageCriterion)
ADD_PARAMETER(m_b, "b");
END_FECORE_CLASS();
double FEDamageCriterionDruckerPrager::DamageCriterion(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
double se = sqrt((SQR(s.xx()-s.yy()) + SQR(s.yy()-s.zz()) + SQR(s.zz()-s.xx())
+ 6*(SQR(s.xy()) + SQR(s.yz()) + SQR(s.xz())))/2);
double sm = s.tr()/3;
double b = m_b(pt);
double Phi = se - b*sm;
return Phi;
}
//-----------------------------------------------------------------------------
//! criterion tangent with respect to stress
mat3ds FEDamageCriterionDruckerPrager::CriterionStressTangent(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
double se = sqrt((SQR(s.xx()-s.yy()) + SQR(s.yy()-s.zz()) + SQR(s.zz()-s.xx())
+ 6*(SQR(s.xy()) + SQR(s.yz()) + SQR(s.xz())))/2);
double sm = s.tr()/3;
double b = m_b(pt);
mat3dd I(1);
return s.dev()*(1.5/se) - I*b/(3*sqrt(3));
}
//-----------------------------------------------------------------------------
// Deshpande-Fleck yield criterion
BEGIN_FECORE_CLASS(FEDamageCriterionDeshpandeFleck, FEDamageCriterion)
ADD_PARAMETER(m_beta, "beta");
END_FECORE_CLASS();
double FEDamageCriterionDeshpandeFleck::DamageCriterion(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
double se = sqrt((SQR(s.xx()-s.yy()) + SQR(s.yy()-s.zz()) + SQR(s.zz()-s.xx())
+ 6*(SQR(s.xy()) + SQR(s.yz()) + SQR(s.xz())))/2);
double sm = s.tr()/3;
double beta = m_beta(pt);
double Phi = sqrt((se*se+pow(3*beta*sm,2))/(1+beta*beta));
return Phi;
}
//-----------------------------------------------------------------------------
//! Deshpande-Fleck criterion tangent with respect to stress
mat3ds FEDamageCriterionDeshpandeFleck::CriterionStressTangent(FEMaterialPoint& pt)
{
FEElasticMaterial* m_pMat = dynamic_cast<FEElasticMaterial*>(GetParent());
FEElasticMaterial* m_pBase = m_pMat->GetElasticMaterial();
mat3ds s = m_pBase->Stress(pt);
double se = sqrt((SQR(s.xx()-s.yy()) + SQR(s.yy()-s.zz()) + SQR(s.zz()-s.xx())
+ 6*(SQR(s.xy()) + SQR(s.yz()) + SQR(s.xz())))/2);
double sm = s.tr()/3;
double beta = m_beta(pt);
mat3dd I(1);
return (s.dev()/2+I*(beta*beta*sm))*(3/(sqrt(se*se+pow(3*beta*sm,2))*sqrt(1+beta*beta)));
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEMuscleMaterial.h | .h | 2,501 | 71 | /*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/FEModelParam.h>
//-----------------------------------------------------------------------------
//! Muscle Material
//! This material uses the constitutive model developed by Blemker et.al. to model
//! muscles which undergo active contraction
class FEMuscleMaterial: public FEUncoupledMaterial
{
public:
FEMuscleMaterial(FEModel* pfem);
public:
// transverse constants
FEParamDouble m_G1; //!< along-fiber shear modulus
FEParamDouble m_G2; //!< cross-fiber shear modulus
FEParamDouble m_G3; //!< new term
// along fiber constants
FEParamDouble m_P1; //!< muscle fiber constant P1
FEParamDouble m_P2; //!< muscle fiber constant P2
FEParamDouble m_Lofl; //!< optimal sarcomere length
FEParamDouble m_smax; //!< maximum isometric stretch
FEParamDouble m_lam1;
FEParamDouble m_alpha; //!< activation parameter
FEVec3dValuator* m_fiber;
public:
//! calculate deviatoric stress at material point
virtual mat3ds DevStress(FEMaterialPoint& pt) override;
//! calculate deviatoric tangent stiffness at material point
virtual tens4ds DevTangent(FEMaterialPoint& pt) override;
// declare the material parameters
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEShenoyMaterial.h | .h | 726 | 32 | #pragma once
#include <FEBioMech/FEElasticMaterial.h>
// This plugin implements the constitutive model by
// Wang et al. (Biophysical Journal, 107, 2014, pp:2592 - 2603).
// This novel material proposes a mechanism for long-range force transmission in
// fibrous matrices enabled by tension-driven alignment of fibers.
class FEShenoyMaterial : public FEElasticMaterial
{
public:
FEShenoyMaterial(FEModel* fem);
mat3ds Stress(FEMaterialPoint& mp) override;
tens4ds Tangent(FEMaterialPoint& mp) override;
private:
double fiberStress(double lam);
double fiberTangent(double lam);
private:
double m_mu;
double m_k;
double m_Ef;
double m_lamc;
double m_lamt;
double m_n;
double m_m;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEMooneyRivlinAD.h | .h | 2,146 | 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"
#include <FECore/FEModelParam.h>
#include <FECore/ad.h>
//! Mooney-Rivlin material using automatic differentiation
class FEMooneyRivlinAD : public FEUncoupledMaterial
{
public:
FEMooneyRivlinAD(FEModel* pfem) : FEUncoupledMaterial(pfem) {}
public:
FEParamDouble m_c1; //!< Mooney-Rivlin coefficient C1
FEParamDouble m_c2; //!< Mooney-Rivlin 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 deviatoric strain energy density
double DevStrainEnergyDensity(FEMaterialPoint& mp) override;
public:
ad::mat3ds PK2Stress_AD(FEMaterialPoint& pt, ad::mat3ds& C);
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEInitialDisplacement.h | .h | 1,795 | 50 | /*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/FEInitialCondition.h>
#include "febiomech_api.h"
#include <FECore/FEModelParam.h>
class FEBIOMECH_API FEInitialDisplacement : public FENodalIC
{
public:
FEInitialDisplacement(FEModel* fem);
bool Init() override;
// set the initial value
void SetValue(const vec3d& v0);
// return the values for node i
void GetNodalValues(int inode, std::vector<double>& values) override;
private:
FEParamVec3 m_u0;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEReactivePlasticDamageMaterialPoint.cpp | .cpp | 5,117 | 157 | /*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 "FEReactivePlasticDamageMaterialPoint.h"
#include "FEElasticMaterial.h"
#ifndef max
#define max(a, b) ((a)>(b)?(a):(b))
#endif
////////////////////// PLASTIC DAMAGE MATERIAL POINT //////////////////////////////
//-----------------------------------------------------------------------------
FEMaterialPointData* FEReactivePlasticDamageMaterialPoint::Copy()
{
FEReactivePlasticDamageMaterialPoint* pt = new FEReactivePlasticDamageMaterialPoint(*this);
if (m_pNext) pt->m_pNext = m_pNext->Copy();
pt->m_Fusi = m_Fusi;
pt->m_Fvsi = m_Fvsi;
pt->m_Kv = m_Kv;
pt->m_Ku = m_Ku;
pt->m_gp = m_gp;
pt->m_gpp = m_gpp;
pt->m_gc = m_gc;
pt->m_wy = m_wy;
pt->m_Eyt = m_Eyt;
pt->m_Eym = m_Eym;
pt->m_di = m_di;
pt->m_dy = m_dy;
pt->m_d = m_d;
pt->m_byld = m_byld;
pt->m_byldt = m_byldt;
return pt;
}
//-----------------------------------------------------------------------------
void FEReactivePlasticDamageMaterialPoint::Init()
{
FEPlasticFlowCurveMaterialPoint& fp = *ExtractData<FEPlasticFlowCurveMaterialPoint>();
if (fp.m_binit) {
size_t n = fp.m_Ky.size();
// intialize data
m_Fusi.assign(n, mat3d(1,0,0,
0,1,0,
0,0,1));
m_Fvsi.assign(n, mat3d(1,0,0,
0,1,0,
0,0,1));
m_Fp = mat3dd(1);
m_Ku.assign(n, 0);
m_Kv.assign(n, 0);
m_gp.assign(n, 0);
m_gpp.assign(n, 0);
m_gc.assign(n, 0);
m_Rhat = 0;
m_wy.assign(n,0);
m_gp.assign(n, 0);
m_Eyt.assign(n, 0);
m_Eym.assign(n, 0);
m_di.assign(n+1, 0);
m_dy.assign(n, 0);
m_d.assign(n+1, 0);
m_byld.assign(n, false);
m_byldt.assign(n, false);
// don't forget to initialize the base class
FEDamageMaterialPoint::Init();
}
}
//-----------------------------------------------------------------------------
void FEReactivePlasticDamageMaterialPoint::Update(const FETimeInfo& timeInfo)
{
FEElasticMaterialPoint& pt = *m_pNext->ExtractData<FEElasticMaterialPoint>();
for (int i=0; i<m_Fusi.size(); ++i) {
m_Fusi[i] = m_Fvsi[i];
m_Ku[i] = m_Kv[i];
m_gc[i] += fabs(m_gp[i] - m_gpp[i]);
m_gpp[i] = m_gp[i];
if (m_wy[i] > 0) m_byld[i] = true;
m_Eym[i] = max(m_Eym[i], m_Eyt[i]);
}
m_Emax = max(m_Emax, m_Etrial);
m_Fp = pt.m_F;
// don't forget to update the base class
FEDamageMaterialPoint::Update(timeInfo);
}
//-----------------------------------------------------------------------------
void FEReactivePlasticDamageMaterialPoint::Serialize(DumpStream& ar)
{
FEMaterialPointData::Serialize(ar);
if (ar.IsSaving())
{
ar << m_Fp << m_D << m_Etrial << m_Emax;
ar << m_Fusi << m_Fvsi << m_Ku << m_Kv << m_gp << m_gpp << m_gc;
ar << m_wy << m_Eyt << m_Eym;
ar << m_di << m_dy << m_d << m_byld << m_byldt;
}
else
{
ar >> m_Fp >> m_D >> m_Etrial >> m_Emax;
ar >> m_Fusi >> m_Fvsi >> m_Ku >> m_Kv >> m_gp >> m_gpp >> m_gc;
ar >> m_wy >> m_Eyt >> m_Eym;
ar >> m_di >> m_dy >> m_d >> m_byld >> m_byldt;
}
}
//! Evaluate net mass fraction of yielded bonds
double FEReactivePlasticDamageMaterialPoint::YieldedBonds() const
{
double w = 0;
for (int i=0; i<m_wy.size(); ++i) w += m_wy[i];
return w;
}
//! Evaluate net mass fraction of intact bonds
double FEReactivePlasticDamageMaterialPoint::IntactBonds() const
{
double w = 0;
int n = (int) m_wy.size();
if (n == 0) return 1.0;
for (int i=0; i<n; ++i) w += m_wy[i] + m_d[i];
w += m_d[n];
return 1.0-w;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEDamageTransIsoMooneyRivlin.h | .h | 3,913 | 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 "FEUncoupledMaterial.h"
#ifdef WIN32
#define max(a,b) ((a)>(b)?(a):(b))
#endif
//-----------------------------------------------------------------------------
// We first define a material point that stores the damage variable.
class FETIMRDamageMaterialPoint : public FEMaterialPointData
{
public:
FETIMRDamageMaterialPoint(FEMaterialPointData*pt);
FEMaterialPointData* Copy();
void Init();
void Update(const FETimeInfo& timeInfo);
void Serialize(DumpStream& ar);
public:
// matrix
double m_MEtrial; //!< trial strain at time t
double m_MEmax; //!< max strain variable up to time t
double m_Dm; //!< damage
// fiber
double m_FEtrial; //!< trial strain at time t
double m_FEmax; //!< max strain variable up to time t
double m_Df; //!< damage
};
//-----------------------------------------------------------------------------
class FEDamageTransIsoMooneyRivlin : public FEUncoupledMaterial
{
public:
FEDamageTransIsoMooneyRivlin(FEModel* pfem);
public:
// Mooney-Rivlin parameters
double m_c1; //!< Mooney-Rivlin coefficient C1
double m_c2; //!< Mooney-Rivlin coefficient C2
// fiber parameters
double m_c3;
double m_c4;
// Matrix damage parameters
double m_Mbeta; //!< damage parameter beta
double m_Msmin; //!< damage parameter psi-min
double m_Msmax; //!< damage parameter psi-max
// Fiber damage parameters
double m_Fbeta;
double m_Fsmin;
double m_Fsmax;
public:
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
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 deviatoric strain energy density at material point
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
//! damage
double Damage(FEMaterialPoint& pt);
protected:
mat3ds MatrixStress(FEMaterialPoint& mp);
mat3ds FiberStress (FEMaterialPoint& mp);
tens4ds MatrixTangent(FEMaterialPoint& pt);
tens4ds FiberTangent (FEMaterialPoint& pt);
double MatrixStrainEnergyDensity(FEMaterialPoint& pt);
double FiberStrainEnergyDensity (FEMaterialPoint& pt);
protected:
// calculate damage reduction factor for matrix
double MatrixDamage(FEMaterialPoint& pt);
// calculate damage reduction factor for fibers
double FiberDamage(FEMaterialPoint& pt);
double MatrixDamageDerive(FEMaterialPoint& pt);
double FiberDamageDerive(FEMaterialPoint& pt);
public:
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FENeoHookeanTransIso.h | .h | 2,029 | 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 "FEElasticMaterial.h"
//-----------------------------------------------------------------------------
//! This material was added by Shawn Reese
class FENeoHookeanTransIso : public FEElasticMaterial
{
public:
FENeoHookeanTransIso(FEModel* pfem) : FEElasticMaterial(pfem) {}
public:
double m_Ep; //!< Young's modulus
double m_Ez; //!< Young's modulus
double m_vz; //!< Poisson's ratio
double m_vp; //!< Poisson's ratio
double m_gz; //!< shear modulus
public:
//! calculate stress at material point
virtual mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
virtual tens4ds Tangent(FEMaterialPoint& pt) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FE3FieldElasticSolidDomain.h | .h | 3,393 | 105 | /*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 "FEElasticSolidDomain.h"
//-----------------------------------------------------------------------------
//! The following domain implements the finite element formulation for a three-field
//! volume element.
class FEBIOMECH_API FE3FieldElasticSolidDomain : public FEElasticSolidDomain
{
protected:
struct ELEM_DATA
{
double eJ; // average element jacobian at intermediate time
double ep; // average pressure
double Lk; // Lagrangian multiplier
double eJt; // average element jacobian at current time
double eJp; // average element jacobian at previous time
void Serialize(DumpStream& ar);
};
public:
//! constructor
FE3FieldElasticSolidDomain(FEModel* pfem);
//! \todo Do I really use this?
FE3FieldElasticSolidDomain& operator = (FE3FieldElasticSolidDomain& d);
//! initialize class
bool Init() override;
//! initialize elements
void PreSolveUpdate(const FETimeInfo& timeInfo) 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 stiffness component
void ElementMaterialStiffness(int iel, matrix& ke);
//! geometrical stiffness (i.e. initial stress)
void ElementGeometricalStiffness(int iel, matrix& ke);
//! update the stress of an element
void UpdateElementStress(int iel, const FETimeInfo& tp) override;
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/FEOsmoticVirialExpansion.h | .h | 2,156 | 56 | /*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"
//-----------------------------------------------------------------------------
//! Material class that implements osmotic pressure using a virial expansion.
//
class FEOsmoticVirialExpansion : public FEElasticMaterial
{
public:
FEOsmoticVirialExpansion(FEModel* pfem);
//! Returns the Cauchy stress
mat3ds Stress(FEMaterialPoint& mp) override;
//! Returs the spatial tangent
tens4ds Tangent(FEMaterialPoint& mp) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
public:
double m_phiwr; //!< fluid volume fraction in reference configuration
double m_cr; //!< concentration in reference configuration
double m_c1; //!< first virial coefficient
double m_c2; //!< second virial coefficient
double m_c3; //!< third virial coefficient
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidSolver.h | .h | 4,962 | 134 | /*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 "FEBodyForce.h"
#include <FECore/FETimeInfo.h>
#include <FECore/FESolver.h>
#include <vector>
//-----------------------------------------------------------------------------
class matrix;
class FEModel;
class SparseMatrix;
class FEGlobalVector;
class FERigidBody;
class FESolidSolver2;
class DumpStream;
class FEElementMatrix;
class FEMechModel;
//-----------------------------------------------------------------------------
//! This is a helper class that helps the solid deformables solvers update the
//! state of the rigid system.
class FEBIOMECH_API FERigidSolver
{
public:
FERigidSolver(FEModel* fem);
// destructor
virtual ~FERigidSolver(){}
// initialize the equation
// neq is the number of equations that already have been assigned
// returns the new total number of equations or -1 on error
int InitEquations(int neq);
// This is called at the start of each time step
void PrepStep(const FETimeInfo& timeInfo, vector<double>& ui);
// correct stiffness matrix for rigid bodies
void RigidStiffness(SparseMatrix& K, std::vector<double>& ui, std::vector<double>& F, const FEElementMatrix& ke, double alpha);
// correct stiffness matrix for rigid bodies accounting for rigid-body-deformable-shell interfaces
void RigidStiffnessSolid(SparseMatrix& K, std::vector<double>& ui, std::vector<double>& F, const std::vector<int>& en, const std::vector<int>& lmi, const std::vector<int>& lmj, const matrix& ke, double alpha);
// correct stiffness matrix for rigid bodies accounting for rigid-body-deformable-shell interfaces
void RigidStiffnessShell(SparseMatrix& K, std::vector<double>& ui, std::vector<double>& F, const std::vector<int>& en, const std::vector<int>& lmi, const std::vector<int>& lmj, const matrix& ke, double alpha);
// adjust residual for rigid-deformable interface nodes
void AssembleResidual(int node_id, int dof, double f, std::vector<double>& R);
// this is called during residual evaluation
// Currently, this is used for resetting rigid body forces
void Residual();
// contribution from rigid bodies to stiffness matrix
void StiffnessMatrix(SparseMatrix& K, const FETimeInfo& tp);
// calculate contribution to mass matrix from a rigid body
void RigidMassMatrix(FELinearSystem& LS, const FETimeInfo& timeInfo);
//! Serialization
void Serialize(DumpStream& ar);
//! return the FEModel
FEModel* GetFEModel();
public:
void AllowMixedBCs(bool b) { m_bAllowMixedBCs = b; }
protected:
FEMechModel* m_fem;
int m_dofX, m_dofY, m_dofZ;
int m_dofVX, m_dofVY, m_dofVZ;
int m_dofU, m_dofV, m_dofW;
int m_dofSX, m_dofSY, m_dofSZ;
int m_dofSVX, m_dofSVY, m_dofSVZ;
bool m_bAllowMixedBCs;
};
//-----------------------------------------------------------------------------
class FEBIOMECH_API FERigidSolverOld : public FERigidSolver
{
public:
FERigidSolverOld(FEModel* fem) : FERigidSolver(fem) { AllowMixedBCs(true); }
//! update rigid body kinematics for dynamic problems
void UpdateRigidKinematics();
//! Update rigid body data
void UpdateRigidBodies(std::vector<double>& Ui, std::vector<double>& ui, bool bnewUpdate);
};
//-----------------------------------------------------------------------------
class FEBIOMECH_API FERigidSolverNew : public FERigidSolver
{
public:
FERigidSolverNew(FEModel* fem) : FERigidSolver(fem){}
// evaluate inertial data
void InertialForces(FEGlobalVector& R, const FETimeInfo& timeInfo);
// update rigid DOF increments
void UpdateIncrements(std::vector<double>& Ui, std::vector<double>& ui, bool emap);
// update rigid bodies
void UpdateRigidBodies(vector<double> &Ui, vector<double>& ui);
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEOgdenUnconstrained.cpp | .cpp | 7,138 | 252 | /*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 "FEOgdenUnconstrained.h"
BEGIN_FECORE_CLASS(FEOgdenUnconstrained, FEElasticMaterial);
ADD_PARAMETER(m_cp , "cp")->setUnits(UNIT_PRESSURE);
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);
ADD_PARAMETER(m_m[0], FE_RANGE_NOT_EQUAL(0.0), "m1");
ADD_PARAMETER(m_m[1], FE_RANGE_NOT_EQUAL(0.0), "m2");
ADD_PARAMETER(m_m[2], FE_RANGE_NOT_EQUAL(0.0), "m3");
ADD_PARAMETER(m_m[3], FE_RANGE_NOT_EQUAL(0.0), "m4");
ADD_PARAMETER(m_m[4], FE_RANGE_NOT_EQUAL(0.0), "m5");
ADD_PARAMETER(m_m[5], FE_RANGE_NOT_EQUAL(0.0), "m6");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! constructor
FEOgdenUnconstrained::FEOgdenUnconstrained(FEModel* pfem) : FEElasticMaterial(pfem)
{
for (int i=0; i<MAX_TERMS; ++i)
{
m_c[i] = 0;
m_m[i] = 1;
}
m_eps = 1e-12;
}
//-----------------------------------------------------------------------------
void FEOgdenUnconstrained::EigenValues(mat3ds& A, double l[3], vec3d r[3], const double eps)
{
A.eigen(l, r);
// correct for numerical inaccuracy
double d01 = fabs(l[0] - l[1]);
double d12 = fabs(l[1] - l[2]);
double d02 = fabs(l[0] - l[2]);
if (d01 < eps) l[1] = l[0]; //= 0.5*(l[0]+l[1]);
if (d02 < eps) l[2] = l[0]; //= 0.5*(l[0]+l[2]);
if (d12 < eps) l[2] = l[1]; //= 0.5*(l[1]+l[2]);
}
//-----------------------------------------------------------------------------
//! Calculates the Cauchy stress
mat3ds FEOgdenUnconstrained::Stress(FEMaterialPoint &mp)
{
// extract elastic material data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// jacobian
double J = pt.m_J;
// get the left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
// get the eigenvalues and eigenvectors of b
double lam2[3]; // these are the squares of the eigenvalues of V
vec3d ev[3];
EigenValues(b, lam2, ev, m_eps);
// get the eigenvalues of V
double lam[3];
lam[0] = sqrt(lam2[0]);
lam[1] = sqrt(lam2[1]);
lam[2] = sqrt(lam2[2]);
// evaluate coefficients at material points
double cp = m_cp(mp);
double ci[MAX_TERMS] = { 0 }, mi[MAX_TERMS] = {0};
for (int i = 0; i < MAX_TERMS; ++i) {
ci[i] = m_c[i](mp);
mi[i] = m_m[i](mp);
}
// stress
mat3ds s;
s.zero();
double T;
for (int i=0; i<3; ++i) {
T = cp*(J-1);
for (int j=0; j<MAX_TERMS; ++j)
T += ci[j]/mi[j]*(pow(lam[i], mi[j]) - 1)/J;
s += dyad(ev[i])*T;
}
return s;
}
//-----------------------------------------------------------------------------
//! Calculates the spatial tangent
tens4ds FEOgdenUnconstrained::Tangent(FEMaterialPoint& mp)
{
int i,j,k;
// extract elastic material data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// jacobian
double J = pt.m_J;
// get the left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
// get the eigenvalues and eigenvectors of b
double lam2[3]; // these are the squares of the eigenvalues of V
vec3d ev[3];
EigenValues(b, lam2, ev, m_eps);
// get the eigenvalues of V
double lam[3];
mat3ds N[3];
for (i=0; i<3; ++i) {
lam[i] = sqrt(lam2[i]);
N[i] = dyad(ev[i]);
}
// evaluate coefficients at material points
double cp = m_cp(mp);
double ci[MAX_TERMS] = { 0 }, mi[MAX_TERMS] = { 0 };
for (int i = 0; i < MAX_TERMS; ++i) {
ci[i] = m_c[i](mp);
mi[i] = m_m[i](mp);
}
// calculate the powers of eigenvalues
double lamp[3][MAX_TERMS];
for (j=0; j<MAX_TERMS; ++j)
{
lamp[0][j] = pow(lam[0], mi[j]);
lamp[1][j] = pow(lam[1], mi[j]);
lamp[2][j] = pow(lam[2], mi[j]);
}
// principal stresses
mat3ds s;
s.zero();
double T[3];
for (i=0; i<3; ++i) {
T[i] = cp*(J-1);
for (j=0; j<MAX_TERMS; ++j)
T[i] += ci[j]/mi[j]*(lamp[i][j] - 1)/J;
s += N[i]*T[i];
}
// coefficients appearing in elasticity tensor
double D[3][3],E[3][3];
for (j=0; j<3; ++j) {
D[j][j] = cp;
for (k=0; k<MAX_TERMS; ++k)
D[j][j] += ci[k]/mi[k]*((mi[k]-2)*lamp[j][k]+2)/J;
for (i=j+1; i<3; ++i) {
D[i][j] = cp*(2*J-1);
if (lam2[j] != lam2[i])
E[i][j] = 2*(lam2[j]*T[i] - lam2[i]*T[j])/(lam2[i]-lam2[j]);
else {
E[i][j] = 2*cp*(1-J);
for (k=0; k<MAX_TERMS; ++k)
E[i][j] += ci[k]/mi[k]*((mi[k]-2)*lamp[j][k]+2)/J;
}
}
}
// spatial elasticity tensor
tens4ds c(0.0);
mat3dd I(1.0);
for (j=0; j<3; ++j) {
c += dyad1s(N[j])*D[j][j];
for (i=j+1; i<3; ++i) {
c += dyad1s(N[i],N[j])*D[i][j];
c += dyad4s(N[i],N[j])*E[i][j];
}
}
return c;
}
//-----------------------------------------------------------------------------
double FEOgdenUnconstrained::StrainEnergyDensity(FEMaterialPoint& mp)
{
// extract elastic material data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// jacobian
double J = pt.m_J;
double lnJ = log(J);
// get the left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
// get the eigenvalues and eigenvectors of b
double lam2[3]; // these are the squares of the eigenvalues of V
vec3d ev[3];
EigenValues(b, lam2, ev, m_eps);
// get the eigenvalues of V
double lam[3];
lam[0] = sqrt(lam2[0]);
lam[1] = sqrt(lam2[1]);
lam[2] = sqrt(lam2[2]);
// evaluate coefficients at material points
double cp = m_cp(mp);
double ci[MAX_TERMS] = { 0 }, mi[MAX_TERMS] = { 0 };
for (int i = 0; i < MAX_TERMS; ++i) {
ci[i] = m_c[i](mp);
mi[i] = m_m[i](mp);
}
// strain energy density
double sed = cp*(J-1)*(J-1)/2;
for (int j=0; j<MAX_TERMS; ++j)
sed += ci[j]/(mi[j]*mi[j])*
(pow(lam[0], mi[j]) + pow(lam[1], mi[j]) + pow(lam[2], mi[j])
- 3 - mi[j]*lnJ);
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidSolidDomain.h | .h | 2,365 | 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 "FEElasticSolidDomain.h"
//-----------------------------------------------------------------------------
//! domain class for 3D rigid elements
//!
class FERigidSolidDomain : public FEElasticSolidDomain
{
public:
//! constructor
FERigidSolidDomain(FEModel* pfem);
//! Initialize
bool Init() override;
//! reset data
void Reset() override;
public:
//! calculates the global stiffness matrix for this domain
void StiffnessMatrix(FELinearSystem& LS) override;
//! calculates the residual (nothing to do)
void InternalForces(FEGlobalVector& R) override;
//! calculates mass matrix (nothing to do)
void MassMatrix(FELinearSystem& LS, double scale) override;
//! calculates the inertial forces (nothing to do)
void InertialForces(FEGlobalVector& R, std::vector<double>& F) override;
// update domain data
void Update(const FETimeInfo& tp) override;
void BodyForce(FEGlobalVector& R, FEBodyForce& BF) override;
public:
// calculate contribution of MOI for this domain
mat3d CalculateMOI();
double CalculateMass();
vec3d CalculateCOM();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledViscoElasticDamage.cpp | .cpp | 9,906 | 272 | /*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 "FEUncoupledViscoElasticDamage.h"
#include <FECore/log.h>
#include <FECore/FEModel.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEUncoupledViscoElasticDamage, FEUncoupledMaterial)
// material parameters
ADD_PARAMETER(m_t[0], "t1")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[1], "t2")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[2], "t3")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[3], "t4")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[4], "t5")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[5], "t6")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_g0 , "g0");
ADD_PARAMETER(m_g[0], "g1");
ADD_PARAMETER(m_g[1], "g2");
ADD_PARAMETER(m_g[2], "g3");
ADD_PARAMETER(m_g[3], "g4");
ADD_PARAMETER(m_g[4], "g5");
ADD_PARAMETER(m_g[5], "g6");
// define the material properties
ADD_PROPERTY(m_pDmg, "elastic");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! constructor
FEUncoupledViscoElasticDamage::FEUncoupledViscoElasticDamage(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_g0 = 1;
for (int i=0; i<MAX_TERMS; ++i)
{
m_t[i] = 1;
m_g[i] = 0;
}
m_binit = false;
m_pDmg = nullptr;
}
//-----------------------------------------------------------------------------
//! data initialization
bool FEUncoupledViscoElasticDamage::Init()
{
if (dynamic_cast<FEDamageMaterialUC*>(m_pDmg) == 0) {
feLogError("elastic component of viscoelastic damage material must be of type uncoupled elastic damage!");
return false;
}
if (m_pDmg->Init() == false) return false;
// combine bulk modulus from base material and uncoupled viscoelastic material
if (m_binit == false) m_K += m_pDmg->m_K;
m_binit = true;
return true;
}
//-----------------------------------------------------------------------------
//! Create material point data for this material
FEMaterialPointData* FEUncoupledViscoElasticDamage::CreateMaterialPointData()
{
return new FEViscoElasticMaterialPoint(m_pDmg->CreateMaterialPointData());
}
//-----------------------------------------------------------------------------
//! Stress function
mat3ds FEUncoupledViscoElasticDamage::DevStress(FEMaterialPoint& mp)
{
double dt = GetFEModel()->GetTime().timeIncrement;
if (dt == 0) return mat3ds(0, 0, 0, 0, 0, 0);
// get the elastic part
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
// get the viscoelastic point data
FEViscoElasticMaterialPoint& pt = *mp.ExtractData<FEViscoElasticMaterialPoint>();
// Calculate the new elastic Cauchy stress
mat3ds se = m_pDmg->GetElasticMaterial()->DevStress(mp);
// pull-back to get PK2 stress
mat3ds Se = pt.m_Se = ep.pull_back(se);
// get elastic PK2 stress of previous timestep
mat3ds Sep = pt.m_Sep;
// calculate new history variables
// terms are accumulated in S, the total PK2-stress
mat3ds S = Se*m_g0;
double g, h;
for (int i=0; i<MAX_TERMS; ++i)
{
g = exp(-dt/m_t[i]);
h = (1 - g)/(dt/m_t[i]);
pt.m_H[i] = pt.m_Hp[i]*g + (Se - Sep)*h;
S += pt.m_H[i]*m_g[i];
}
// return the total Cauchy stress,
// which is the push-forward of S
double D = m_pDmg->Damage(mp);
return ep.push_forward(S)*(1-D);
}
//-----------------------------------------------------------------------------
//! Material tangent
tens4ds FEUncoupledViscoElasticDamage::DevTangent(FEMaterialPoint& pt)
{
double dt = GetFEModel()->GetTime().timeIncrement;
// calculate the spatial elastic tangent
tens4ds C = m_pDmg->GetElasticMaterial()->DevTangent(pt);
if (dt == 0.0) return C;
// calculate the visco scale factor
double f = m_g0, g, h;
for (int i=0; i<MAX_TERMS; ++i)
{
g = exp(-dt/m_t[i]);
h = ( 1 - exp(-dt/m_t[i]) )/( dt/m_t[i] );
f += m_g[i]*h;
}
double D = m_pDmg->Damage(pt);
// multiply tangent with visco-factor
return C*(f*(1-D));
}
//-----------------------------------------------------------------------------
//! Strain energy density function
double FEUncoupledViscoElasticDamage::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
// get the viscoelastic point data
FEViscoElasticMaterialPoint& pt = *mp.ExtractData<FEViscoElasticMaterialPoint>();
FEElasticMaterialPoint& et = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d Fsafe = et.m_F; double Jsafe = et.m_J;
// Calculate the new elastic strain energy density
pt.m_sed = m_pDmg->GetElasticMaterial()->DevStrainEnergyDensity(mp);
double sed = pt.m_sed;
double sedt = sed*m_g0;
if (SeriesStretchExponent(mp)) {
// get the elastic point data and evaluate the right-stretch tensor
for (int i=0; i<MAX_TERMS; ++i)
{
if (m_g[i] > 0) {
mat3ds C = et.RightCauchyGreen();
double l2[3], l[3];
vec3d v[3];
C.eigen2(l2, v);
l[0] = sqrt(l2[0]); l[1] = sqrt(l2[1]); l[2] = sqrt(l2[2]);
mat3ds Ua = dyad(v[0])*pow(l[0],pt.m_alpha[i])
+ dyad(v[1])*pow(l[1],pt.m_alpha[i]) + dyad(v[2])*pow(l[2],pt.m_alpha[i]);
et.m_F = Ua; et.m_J = Ua.det();
sedt += m_g[i]*m_pDmg->GetElasticMaterial()->DevStrainEnergyDensity(mp);
}
}
}
else
throw std::runtime_error("FEUncoupledViscoElasticDamage::strain energy density calculation did not converge!");
et.m_F = Fsafe; et.m_J = Jsafe;
double D = m_pDmg->Damage(mp);
// return the total strain energy density
return sedt*(1-D);
}
//-----------------------------------------------------------------------------
//! calculate exponent of right-stretch tensor in series spring
bool FEUncoupledViscoElasticDamage::SeriesStretchExponent(FEMaterialPoint& mp)
{
const double errrel = 1e-6;
const double almin = 0.001;
const int maxiter = 50;
// get the elastic point data and evaluate the right-stretch tensor
FEElasticMaterialPoint& et = *mp.ExtractData<FEElasticMaterialPoint>();
// get the right stretch tensor
mat3ds C = et.RightCauchyGreen();
double l2[3], l[3];
vec3d v[3];
C.eigen2(l2, v);
l[0] = sqrt(l2[0]); l[1] = sqrt(l2[1]); l[2] = sqrt(l2[2]);
mat3ds U = dyad(v[0])*l[0] + dyad(v[1])*l[1] + dyad(v[2])*l[2];
double gamma = 0;
for (int i=0; i<MAX_TERMS; ++i) gamma += m_g[i];
// get the viscoelastic point data
FEViscoElasticMaterialPoint& pt = *mp.ExtractData<FEViscoElasticMaterialPoint>();
// use previous time solution as initial guess for the exponent
mat3ds Se = pt.m_Se;
mat3ds S = et.pull_back(et.m_s);
double fmag = Se.dotdot(U);
mat3d Fsafe = et.m_F; double Jsafe = et.m_J;
for (int i=0; i<MAX_TERMS; ++i) {
if (m_g[i] > 0) {
double alpha = pt.m_alphap[i];
bool done = false;
int iter = 0;
do {
mat3ds Ua = dyad(v[0])*pow(l[0],alpha) + dyad(v[1])*pow(l[1],alpha) + dyad(v[2])*pow(l[2],alpha);
et.m_F = Ua; et.m_J = Ua.det();
mat3ds Sea = et.pull_back(m_pDmg->GetElasticMaterial()->Stress(mp));
double f = (Sea*m_g[i] - S + Se).dotdot(U);
tens4ds Cea = et.pull_back(m_pDmg->GetElasticMaterial()->Tangent(mp));
mat3ds U2ap = dyad(v[0])*(pow(l[0],2*alpha)*log(l[0]))
+ dyad(v[1])*(pow(l[1],2*alpha)*log(l[1]))
+ dyad(v[2])*(pow(l[2],2*alpha)*log(l[2]));
double fprime = (Cea.dot(U2ap)).dotdot(U)*m_g[i];
if (fprime != 0) {
double dalpha = -f/fprime;
alpha += dalpha;
if (fabs(f) < errrel*fmag) done = true;
else if (fabs(dalpha) < errrel*fabs(alpha)) done = true;
else if (alpha > 1) { alpha = 1; done = true; }
else if (alpha < almin) { alpha = 0; done = true; }
else if (++iter > maxiter) done = true;
}
else
done = true;
} while (!done);
if (iter > maxiter) {
et.m_F = Fsafe; et.m_J = Jsafe;
return false;
}
pt.m_alpha[i] = alpha;
}
}
et.m_F = Fsafe; et.m_J = Jsafe;
return true;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberMaterialPoint.cpp | .cpp | 2,641 | 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.*/
#include "FEFiberMaterialPoint.h"
#include "stdafx.h"
#include "FEElasticMaterial.h"
#include <FECore/DumpStream.h>
//-----------------------------------------------------------------------------
FEFiberMaterialPoint::FEFiberMaterialPoint(FEMaterialPointData* pt) : FEMaterialPointData(pt) {}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEFiberMaterialPoint::Copy()
{
FEFiberMaterialPoint* pt = new FEFiberMaterialPoint(*this);
if (m_pNext) pt->m_pNext = m_pNext->Copy();
return pt;
}
//-----------------------------------------------------------------------------
void FEFiberMaterialPoint::Init()
{
// initialize data to identity
m_Us = mat3dd(1);
m_bUs = false;
// don't forget to intialize the nested data
FEMaterialPointData::Init();
}
//-----------------------------------------------------------------------------
void FEFiberMaterialPoint::Serialize(DumpStream& ar)
{
FEMaterialPointData::Serialize(ar);
ar & m_Us & m_bUs;
}
//-----------------------------------------------------------------------------
vec3d FEFiberMaterialPoint::FiberPreStretch(const vec3d a0)
{
// account for prior deformation in multigenerational formulation
if (m_bUs) {
vec3d a = (m_Us*a0);
a.unit();
return a;
}
else
return a0;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedActiveContractionIsotropicUC.cpp | .cpp | 2,423 | 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.*/
#include "stdafx.h"
#include "FEPrescribedActiveContractionIsotropicUC.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEPrescribedActiveContractionIsotropicUC, FEUncoupledMaterial)
ADD_PARAMETER(m_T0 , "T0" );
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPrescribedActiveContractionIsotropicUC::FEPrescribedActiveContractionIsotropicUC(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_T0 = 0.0;
}
//-----------------------------------------------------------------------------
mat3ds FEPrescribedActiveContractionIsotropicUC::DevStress(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
mat3ds b = pt.LeftCauchyGreen();
// evaluate the active stress
double T0 = m_T0(mp);
mat3ds s = b*(T0/J);
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEPrescribedActiveContractionIsotropicUC::DevTangent(FEMaterialPoint &mp)
{
return tens4ds(0.0);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEMortarSlidingContact.cpp | .cpp | 15,446 | 578 | /*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 "FEMortarSlidingContact.h"
#include "FECore/mortar.h"
#include "FECore/FEGlobalMatrix.h"
#include "FECore/log.h"
#include <FECore/FELinearSystem.h>
#include <FECore/FEDataExport.h>
//=============================================================================
// FEMortarSlidingSurface
//=============================================================================
//-----------------------------------------------------------------------------
FEMortarSlidingSurface::FEMortarSlidingSurface(FEModel* pfem) : FEMortarContactSurface(pfem)
{
// class exports
EXPORT_DATA(PLT_VEC3F, FMT_NODE, &m_gap, "mortar-gap vector");
EXPORT_DATA(PLT_VEC3F, FMT_NODE, &m_nu , "mortar-normal" );
}
//-----------------------------------------------------------------------------
bool FEMortarSlidingSurface::Init()
{
// always intialize base class first!
if (FEMortarContactSurface::Init() == false) return false;
// get the number of nodes
int NN = Nodes();
// allocate data structures
m_p.resize(NN, 0.0);
m_L.resize(NN, 0.0);
m_nu.resize(NN, vec3d(0,0,0));
m_norm0.resize(NN, 0.0);
return true;
}
//-----------------------------------------------------------------------------
void FEMortarSlidingSurface::UpdateNormals(bool binit)
{
const int NN = Nodes();
// reset normals
m_nu.assign(NN, vec3d(0,0,0));
// recalculate normals
const int NF = Elements();
for (int i=0; i<NF; ++i)
{
FESurfaceElement& el = Element(i);
int neln = el.Nodes();
for (int j=0; j<neln; ++j)
{
vec3d r0 = Node(el.m_lnode[j]).m_rt;
vec3d r1 = Node(el.m_lnode[(j+1)%neln]).m_rt;
vec3d r2 = Node(el.m_lnode[(j+neln-1)%neln]).m_rt;
vec3d n = (r1 - r0)^(r2 - r0);
m_nu[el.m_lnode[j]] += n;
}
}
// normalize
if (binit)
{
for (int i=0; i<NN; ++i)
{
double d = m_nu[i].unit();
m_norm0[i] = 1.0/d;
}
}
else
{
for (int i=0; i<NN; ++i) m_nu[i] *= m_norm0[i];
}
}
//=============================================================================
// FEMortarSlidingContact
//=============================================================================
//-----------------------------------------------------------------------------
// Define sliding interface parameters
BEGIN_FECORE_CLASS(FEMortarSlidingContact, FEMortarInterface)
ADD_PARAMETER(m_atol , "tolerance" );
ADD_PARAMETER(m_eps , "penalty" );
ADD_PARAMETER(m_naugmin, "minaug" );
ADD_PARAMETER(m_naugmax, "maxaug" );
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEMortarSlidingContact::FEMortarSlidingContact(FEModel* pfem) : FEMortarInterface(pfem), m_ss(pfem), m_ms(pfem)
{
m_dofX = GetDOFIndex("x");
m_dofY = GetDOFIndex("y");
m_dofZ = GetDOFIndex("z");
}
//-----------------------------------------------------------------------------
FEMortarSlidingContact::~FEMortarSlidingContact()
{
}
//-----------------------------------------------------------------------------
bool FEMortarSlidingContact::Init()
{
// initialize surfaces
if (m_ms.Init() == false) return false;
if (m_ss.Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
void FEMortarSlidingContact::Activate()
{
//! don't forget the base class
FEContactInterface::Activate();
// update the normals on the primary surface
m_ss.UpdateNormals(true);
// update nodal areas
m_ss.UpdateNodalAreas();
// update the mortar weights
UpdateMortarWeights(m_ss, m_ms);
// update the nodal gaps
// (must be done after mortar eights are updated)
UpdateNodalGaps(m_ss, m_ms);
}
//-----------------------------------------------------------------------------
//! build the matrix profile for use in the stiffness matrix
void FEMortarSlidingContact::BuildMatrixProfile(FEGlobalMatrix& K)
{
// For now we'll assume that each node on the primary side is connected to the secondary side
// This is obviously too much, but we'll worry about improving this later
int NS = m_ss.Nodes();
int NM = m_ms.Nodes();
vector<int> LM(3*(NS+NM));
for (int i=0; i<NS; ++i)
{
FENode& ni = m_ss.Node(i);
LM[3*i ] = ni.m_ID[0];
LM[3*i+1] = ni.m_ID[1];
LM[3*i+2] = ni.m_ID[2];
}
for (int i=0; i<NM; ++i)
{
FENode& ni = m_ms.Node(i);
LM[3*NS + 3*i ] = ni.m_ID[0];
LM[3*NS + 3*i+1] = ni.m_ID[1];
LM[3*NS + 3*i+2] = ni.m_ID[2];
}
K.build_add(LM);
}
//-----------------------------------------------------------------------------
//! calculate contact forces
void FEMortarSlidingContact::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
int NS = m_ss.Nodes();
int NM = m_ms.Nodes();
// loop over all primary nodes
for (int A=0; A<NS; ++A)
{
vec3d nuA = m_ss.m_nu[A];
vec3d gA = m_ss.m_gap[A];
double eps = m_eps*m_ss.m_A[A];
double gap = gA*nuA;
double pA = m_ss.m_L[A] + eps*gap;
// if (gap < 0.0) pA = 0.0;
vec3d tA = nuA*(pA);
// loop over all primary nodes
vector<int> en(1);
vector<int> lm(3);
vector<double> fe(3);
for (int B=0; B<NS; ++B)
{
FENode& nodeB = m_ss.Node(B);
en[0] = m_ss.NodeIndex(B);
lm[0] = nodeB.m_ID[m_dofX];
lm[1] = nodeB.m_ID[m_dofY];
lm[2] = nodeB.m_ID[m_dofZ];
double nAB = -m_n1[A][B];
if (nAB != 0.0)
{
fe[0] = tA.x*nAB;
fe[1] = tA.y*nAB;
fe[2] = tA.z*nAB;
R.Assemble(en, lm, fe);
}
}
// loop over secondary side
for (int C=0; C<NM; ++C)
{
FENode& nodeC = m_ms.Node(C);
en[0] = m_ms.NodeIndex(C);
lm[0] = nodeC.m_ID[m_dofX];
lm[1] = nodeC.m_ID[m_dofY];
lm[2] = nodeC.m_ID[m_dofZ];
double nAC = m_n2[A][C];
if (nAC != 0.0)
{
fe[0] = tA.x*nAC;
fe[1] = tA.y*nAC;
fe[2] = tA.z*nAC;
R.Assemble(en, lm, fe);
}
}
}
}
//-----------------------------------------------------------------------------
//! calculate contact stiffness
void FEMortarSlidingContact::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
ContactGapStiffness(LS);
ContactNormalStiffness(LS);
}
//-----------------------------------------------------------------------------
//! calculate contact stiffness
void FEMortarSlidingContact::ContactGapStiffness(FELinearSystem& LS)
{
int NS = m_ss.Nodes();
int NM = m_ms.Nodes();
// A. Linearization of the gap function
vector<int> lmi(3), lmj(3);
matrix kA(3, 3), kG(3, 3);
FEElementMatrix ke;
ke.resize(3, 3);
for (int A=0; A<NS; ++A)
{
vec3d nuA = m_ss.m_nu[A];
double eps = m_eps*m_ss.m_A[A];
// loop over all primary nodes
for (int B=0; B<NS; ++B)
{
FENode& nodeB = m_ss.Node(B);
lmi[0] = nodeB.m_ID[0];
lmi[1] = nodeB.m_ID[1];
lmi[2] = nodeB.m_ID[2];
double nAB = m_n1[A][B];
if (nAB != 0.0)
{
kA[0][0] = eps*nAB*(nuA.x*nuA.x); kA[0][1] = eps*nAB*(nuA.x*nuA.y); kA[0][2] = eps*nAB*(nuA.x*nuA.z);
kA[1][0] = eps*nAB*(nuA.y*nuA.x); kA[1][1] = eps*nAB*(nuA.y*nuA.y); kA[1][2] = eps*nAB*(nuA.y*nuA.z);
kA[2][0] = eps*nAB*(nuA.z*nuA.x); kA[2][1] = eps*nAB*(nuA.z*nuA.y); kA[2][2] = eps*nAB*(nuA.z*nuA.z);
// loop over primary nodes
for (int C=0; C<NS; ++C)
{
FENode& nodeC = m_ss.Node(C);
lmj[0] = nodeC.m_ID[0];
lmj[1] = nodeC.m_ID[1];
lmj[2] = nodeC.m_ID[2];
double nAC = m_n1[A][C];
if (nAC != 0.0)
{
kG[0][0] = nAC; kG[0][1] = 0.0; kG[0][2] = 0.0;
kG[1][0] = 0.0; kG[1][1] = nAC; kG[1][2] = 0.0;
kG[2][0] = 0.0; kG[2][1] = 0.0; kG[2][2] = nAC;
ke = kA*kG;
ke.SetIndices(lmi, lmj);
LS.Assemble(ke);
}
}
// loop over secondary nodes
for (int C=0; C<NM; ++C)
{
FENode& nodeC = m_ms.Node(C);
lmj[0] = nodeC.m_ID[0];
lmj[1] = nodeC.m_ID[1];
lmj[2] = nodeC.m_ID[2];
double nAC = -m_n2[A][C];
if (nAC != 0.0)
{
kG[0][0] = nAC; kG[0][1] = 0.0; kG[0][2] = 0.0;
kG[1][0] = 0.0; kG[1][1] = nAC; kG[1][2] = 0.0;
kG[2][0] = 0.0; kG[2][1] = 0.0; kG[2][2] = nAC;
ke = kA*kG;
ke.SetIndices(lmi, lmj);
LS.Assemble(ke);
}
}
}
}
// loop over all secondary nodes
for (int B=0; B<NM; ++B)
{
FENode& nodeB = m_ms.Node(B);
lmi[0] = nodeB.m_ID[0];
lmi[1] = nodeB.m_ID[1];
lmi[2] = nodeB.m_ID[2];
double nAB = -m_n2[A][B];
if (nAB != 0.0)
{
kA[0][0] = eps*nAB*(nuA.x*nuA.x); kA[0][1] = eps*nAB*(nuA.x*nuA.y); kA[0][2] = eps*nAB*(nuA.x*nuA.z);
kA[1][0] = eps*nAB*(nuA.y*nuA.x); kA[1][1] = eps*nAB*(nuA.y*nuA.y); kA[1][2] = eps*nAB*(nuA.y*nuA.z);
kA[2][0] = eps*nAB*(nuA.z*nuA.x); kA[2][1] = eps*nAB*(nuA.z*nuA.y); kA[2][2] = eps*nAB*(nuA.z*nuA.z);
// loop over primary nodes
for (int C=0; C<NS; ++C)
{
FENode& nodeC = m_ss.Node(C);
lmj[0] = nodeC.m_ID[0];
lmj[1] = nodeC.m_ID[1];
lmj[2] = nodeC.m_ID[2];
double nAC = m_n1[A][C];
if (nAC != 0.0)
{
kG[0][0] = nAC; kG[0][1] = 0.0; kG[0][2] = 0.0;
kG[1][0] = 0.0; kG[1][1] = nAC; kG[1][2] = 0.0;
kG[2][0] = 0.0; kG[2][1] = 0.0; kG[2][2] = nAC;
ke = kA*kG;
ke.SetIndices(lmi, lmj);
LS.Assemble(ke);
}
}
// loop over secondary nodes
for (int C=0; C<NM; ++C)
{
FENode& nodeC = m_ms.Node(C);
lmj[0] = nodeC.m_ID[0];
lmj[1] = nodeC.m_ID[1];
lmj[2] = nodeC.m_ID[2];
double nAC = -m_n2[A][C];
if (nAC != 0.0)
{
kG[0][0] = nAC; kG[0][1] = 0.0; kG[0][2] = 0.0;
kG[1][0] = 0.0; kG[1][1] = nAC; kG[1][2] = 0.0;
kG[2][0] = 0.0; kG[2][1] = 0.0; kG[2][2] = nAC;
ke = kA*kG;
ke.SetIndices(lmi, lmj);
LS.Assemble(ke);
}
}
}
}
}
}
//-----------------------------------------------------------------------------
//! calculate contact stiffness
void FEMortarSlidingContact::ContactNormalStiffness(FELinearSystem& LS)
{
int NS = m_ss.Nodes();
int NM = m_ms.Nodes();
vector<int> lm1(3);
vector<int> lm2(3);
FEElementMatrix ke;
ke.resize(3, 3);
int NF = m_ss.Elements();
for (int i=0; i<NF; ++i)
{
FESurfaceElement& f = m_ss.Element(i);
int nn = f.Nodes();
for (int j=0; j<nn; ++j)
{
int jp1 = (j+1)%nn;
int jm1 = (j+nn-1)%nn;
int A = f.m_lnode[j];
vec3d vA = m_ss.m_nu[A];
vec3d gA = m_ss.m_gap[A];
double eps = m_eps*m_ss.m_A[A];
double pA = m_ss.m_L[A] + eps*(gA*vA);
double normA = m_ss.m_norm0[A];
mat3d kA = ((vA&gA)*eps + mat3dd(pA));
FENode& nodej1 = m_ss.Node(f.m_lnode[jp1]);
vec3d& x1 = nodej1.m_rt;
mat3da k1(x1);
lm1[0] = nodej1.m_ID[0];
lm1[1] = nodej1.m_ID[1];
lm1[2] = nodej1.m_ID[2];
FENode& nodej2 = m_ss.Node(f.m_lnode[jm1]);
vec3d& x2 = nodej2.m_rt;
mat3da k2(x2);
lm2[0] = nodej2.m_ID[0];
lm2[1] = nodej2.m_ID[1];
lm2[2] = nodej2.m_ID[2];
// loop over primary nodes
for (int B=0; B<NS; ++B)
{
FENode& nodeB = m_ss.Node(B);
double nAB = m_n1[A][B];
if (nAB != 0.0)
{
vector<int> lmi(3);
lmi[0] = nodeB.m_ID[0];
lmi[1] = nodeB.m_ID[1];
lmi[2] = nodeB.m_ID[2];
mat3d kab = (kA*k1)*(nAB*normA);
ke[0][0] = kab(0,0); ke[0][1] = kab(0,1); ke[0][2] = kab(0,2);
ke[1][0] = kab(1,0); ke[1][1] = kab(1,1); ke[1][2] = kab(1,2);
ke[2][0] = kab(2,0); ke[2][1] = kab(2,1); ke[2][2] = kab(2,2);
ke.SetIndices(lmi, lm2);
LS.Assemble(ke);
kab = (kA*k2)*(-nAB*normA);
ke[0][0] = kab(0,0); ke[0][1] = kab(0,1); ke[0][2] = kab(0,2);
ke[1][0] = kab(1,0); ke[1][1] = kab(1,1); ke[1][2] = kab(1,2);
ke[2][0] = kab(2,0); ke[2][1] = kab(2,1); ke[2][2] = kab(2,2);
ke.SetIndices(lmi, lm1);
LS.Assemble(ke);
}
}
// loop over secondary nodes
for (int B=0; B<NM; ++B)
{
FENode& nodeB = m_ms.Node(B);
double nAB = m_n2[A][B];
if (nAB != 0.0)
{
vector<int> lmi(3);
lmi[0] = nodeB.m_ID[0];
lmi[1] = nodeB.m_ID[1];
lmi[2] = nodeB.m_ID[2];
mat3d kab = (kA*k1)*(nAB*normA);
ke[0][0] = kab(0,0); ke[0][1] = kab(0,1); ke[0][2] = kab(0,2);
ke[1][0] = kab(1,0); ke[1][1] = kab(1,1); ke[1][2] = kab(1,2);
ke[2][0] = kab(2,0); ke[2][1] = kab(2,1); ke[2][2] = kab(2,2);
ke.SetIndices(lmi, lm2);
LS.Assemble(ke);
kab = (kA*k2)*(-nAB*normA);
ke[0][0] = kab(0,0); ke[0][1] = kab(0,1); ke[0][2] = kab(0,2);
ke[1][0] = kab(1,0); ke[1][1] = kab(1,1); ke[1][2] = kab(1,2);
ke[2][0] = kab(2,0); ke[2][1] = kab(2,1); ke[2][2] = kab(2,2);
ke.SetIndices(lmi, lm1);
LS.Assemble(ke);
}
}
}
}
}
//-----------------------------------------------------------------------------
//! calculate Lagrangian augmentations
bool FEMortarSlidingContact::Augment(int naug, const FETimeInfo& tp)
{
if (m_laugon != FECore::AUGLAG_METHOD) return true;
double max_err = 0.0;
int NS = m_ss.Nodes();
// loop over all primary nodes
for (int A=0; A<NS; ++A)
{
vec3d vA = m_ss.m_nu[A];
vec3d gA = m_ss.m_gap[A];
double gap = gA*vA;
double eps = m_eps*m_ss.m_A[A];
double Lold = m_ss.m_L[A];
double Lnew = Lold + eps*gap;
double err = fabs((Lold - Lnew)/(Lold + Lnew));
if (err > max_err) max_err = err;
}
bool bconv = true;
if ((m_atol > 0) && (max_err > m_atol)) bconv = false;
if (m_naugmin > naug) bconv = false;
if (m_naugmax <= naug) bconv = true;
feLog(" mortar interface # %d\n", GetID());
feLog(" CURRENT REQUIRED\n");
feLog(" normal force : %15le", max_err);
if (m_atol > 0) feLog("%15le\n", m_atol); else feLog(" ***\n");
if (bconv == false)
{
// loop over all primary nodes
for (int A=0; A<NS; ++A)
{
vec3d vA = m_ss.m_nu[A];
vec3d gA = m_ss.m_gap[A];
double gap = gA*vA;
double eps = m_eps*m_ss.m_A[A];
double Lold = m_ss.m_L[A];
double Lnew = Lold + eps*gap;
m_ss.m_L[A] = Lnew;
}
}
return bconv;
}
//-----------------------------------------------------------------------------
//! update interface data
void FEMortarSlidingContact::Update()
{
m_ss.UpdateNormals(false);
UpdateMortarWeights(m_ss, m_ms);
UpdateNodalGaps(m_ss, m_ms);
}
//-----------------------------------------------------------------------------
//! serialize data to archive
void FEMortarSlidingContact::Serialize(DumpStream& ar)
{
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPlasticFlowCurve.h | .h | 4,760 | 138 | /*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/FEPointFunction.h>
#include "febiomech_api.h"
class FEPlasticFlowCurve;
//-----------------------------------------------------------------------------
// Material point for plastic flow curve
class FEPlasticFlowCurveMaterialPoint : public FEMaterialPointData
{
public:
FEPlasticFlowCurveMaterialPoint(FEMaterialPointData* pt) : FEMaterialPointData(pt) { m_binit = false; }
//! copy material point data
FEMaterialPointData* Copy() override;
//! Initialize material point data
void Init() override;
//! Serialize data to archive
void Serialize(DumpStream& ar) override;
public:
vector<double> m_Ky; //!< bond yield measures
vector<double> m_w; //!< bond mass fractions
bool m_binit; //!< flag for initialization
};
//-----------------------------------------------------------------------------
// Virtual base class for plastic flow curve
class FEBIOMECH_API FEPlasticFlowCurve : public FEMaterialProperty
{
public:
FEPlasticFlowCurve(FEModel* pfem) : FEMaterialProperty(pfem) {}
//! return
vector<double> BondYieldMeasures(FEMaterialPoint& mp);
vector<double> BondMassFractions(FEMaterialPoint& mp);
size_t BondFamilies(FEMaterialPoint& mp);
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
// initialize flow curve. Return true upon successful initialization,
// false otherwise
virtual bool InitFlowCurve(FEMaterialPoint& mp) = 0;
FECORE_BASE_CLASS(FEPlasticFlowCurve);
};
//-----------------------------------------------------------------------------
// Flow curve from reactive plasticity paper
class FEPlasticFlowCurvePaper : public FEPlasticFlowCurve
{
public:
FEPlasticFlowCurvePaper(FEModel* pfem);
bool InitFlowCurve(FEMaterialPoint& mp) override;
public:
FEParamDouble m_wmin; // initial fraction of yielding bonds
FEParamDouble m_wmax; // final fraction of yielding bonds
FEParamDouble m_we; // fraction of unyielding bonds
FEParamDouble m_Ymin; // initial yield measure
FEParamDouble m_Ymax; // yield measure when all bonds have yielded
int m_n; // number of yield levels
FEParamDouble m_bias; // biasing factor for intervals in yield measures and bond fractions
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// User-defined flow curve
class FEPlasticFlowCurveUser : public FEPlasticFlowCurve
{
public:
FEPlasticFlowCurveUser(FEModel* pfem);
bool InitFlowCurve(FEMaterialPoint& mp) override;
public:
FEPointFunction* m_Y; //!< true stress-true strain flow curve
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
// Math equation for flow curve
class FEPlasticFlowCurveMath : public FEPlasticFlowCurve
{
public:
FEPlasticFlowCurveMath(FEModel* pfem);
bool InitFlowCurve(FEMaterialPoint& mp) override;
public:
int m_n; //!< number of yield levels
double m_emin; //!< min true strain
double m_emax; //!< max true strain
std::string m_Ymath; //!< true stress-true strain flow curve
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationScheme.cpp | .cpp | 1,433 | 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) 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 "FEFiberIntegrationScheme.h"
FEFiberIntegrationScheme::FEFiberIntegrationScheme(FEModel* pfem) : FEMaterialProperty(pfem)
{
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEMechModel.h | .h | 3,151 | 110 | /*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/FEModel.h>
#include "febiomech_api.h"
//---------------------------------------------------------------------------------------
class FERigidSystem;
class FERigidBody;
class FERigidBC;
class FERigidIC;
class FERigidNodeSet;
//---------------------------------------------------------------------------------------
// This class extends the basic FEModel class by adding a rigid body system
class FEBIOMECH_API FEMechModel : public FEModel
{
public:
FEMechModel();
// clear all model data
void Clear() override;
// model initialization
bool Init() override;
// model activation
void Activate() override;
// TODO: temporary construction. Would like to call Activate
void Reactivate() override;
// reset
bool Reset() override;
// initialize mesh
bool InitMesh() override;
//! Initialize shells
bool InitShells() override;
// find a parameter value
FEParamValue GetParameterValue(const ParamString& param) override;
//! serialize data for restarts
void SerializeGeometry(DumpStream& ar) override;
//! Build the matrix profile for this model
void BuildMatrixProfile(FEGlobalMatrix& G, bool breset) override;
// update rigid part of mesh
void UpdateRigidMesh();
public:
// get the rigid system
FERigidSystem* GetRigidSystem();
// initialize the rigid system
bool InitRigidSystem();
// number of rigid bodies
int RigidBodies() const;
// get a rigid body
FERigidBody* GetRigidBody(int n);
// find a rigid body from a material ID
int FindRigidbodyFromMaterialID(int matId);
// return number or rigid BCs
int RigidBCs() const;
// return the rigid prescribed displacement
FERigidBC* GetRigidBC(int i);
// add a rigid BC
void AddRigidBC(FERigidBC* pDC);
// add a rigid initial condition
void AddRigidInitialCondition(FERigidIC* pIC);
private:
FERigidSystem* m_prs;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FETransIsoMooneyRivlin.h | .h | 2,670 | 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 "FEUncoupledMaterial.h"
#include "FEUncoupledFiberExpLinear.h"
#include "FEActiveContractionMaterial.h"
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! Transversely Isotropic Mooney-Rivlin material
//! This material has an isotopric Mooney-Rivlin basis and single preferred
//! fiber direction.
class FETransIsoMooneyRivlin: public FEUncoupledMaterial
{
public:
FETransIsoMooneyRivlin(FEModel* pfem);
public:
FEParamDouble m_c1; //!< Mooney-Rivlin coefficient C1
FEParamDouble m_c2; //!< Mooney-Rivlin 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 deviatoric strain energy density at material point
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
//! create material point data
FEMaterialPointData* CreateMaterialPointData() override;
// update force-velocity material point
void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override;
protected:
FEFiberExpLinearUC m_fib;
FEActiveContractionMaterial* m_ac;
FEVec3dValuator* m_fiber;
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.