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/FEReactiveMaterialPoint.cpp | .cpp | 1,332 | 31 | /*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 "FEDamageMaterialPoint.h"
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFacet2FacetSliding.cpp | .cpp | 36,906 | 1,332 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEFacet2FacetSliding.h"
#include "FECore/FEModel.h"
#include "FECore/FEClosestPointProjection.h"
#include "FECore/log.h"
#include "FECore/FEGlobalMatrix.h"
#include "FECore/FEDataExport.h"
#include <FECore/FELinearSystem.h>
#include <FECore/FEAnalysis.h>
//-----------------------------------------------------------------------------
// Define sliding interface parameters
BEGIN_FECORE_CLASS(FEFacet2FacetSliding, FEContactInterface)
BEGIN_PARAM_GROUP("Enforcement");
ADD_PARAMETER(m_laugon , "laugon")->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0");
ADD_PARAMETER(m_epsn , "penalty" );
ADD_PARAMETER(m_bautopen , "auto_penalty" );
ADD_PARAMETER(m_bupdtpen , "update_penalty");
ADD_PARAMETER(m_atol , "tolerance" );
ADD_PARAMETER(m_btwo_pass, "two_pass" );
ADD_PARAMETER(m_gtol , "gaptol" )->setLongName("gap tolerance")->setUnits(UNIT_LENGTH);;
ADD_PARAMETER(m_naugmin , "minaug" )->setLongName("min. augmentations");
ADD_PARAMETER(m_naugmax , "maxaug" )->setLongName("max. augmentations");
ADD_PARAMETER(m_bsmaug , "smooth_aug" )->setLongName("Smooth augmentations");
END_PARAM_GROUP();
BEGIN_PARAM_GROUP("Projection");
ADD_PARAMETER(m_stol , "search_tol" );
ADD_PARAMETER(m_srad , "search_radius")->setUnits(UNIT_LENGTH);;
ADD_PARAMETER(m_nsegup , "seg_up" )->setLongName("max. segment updates");
ADD_PARAMETER(m_breloc , "node_reloc")->setLongName("node relocation");
END_PARAM_GROUP();
BEGIN_PARAM_GROUP("Miscellaneous");
ADD_PARAMETER(m_dxtol , "dxtol" )->SetFlags(FEParamFlag::FE_PARAM_HIDDEN);
ADD_PARAMETER(m_mu , "fric_coeff" )->SetFlags(FEParamFlag::FE_PARAM_HIDDEN);
ADD_PARAMETER(m_epsf , "fric_penalty" )->SetFlags(FEParamFlag::FE_PARAM_HIDDEN);
ADD_PARAMETER(m_knmult , "knmult")->setLongName("Stiffness scale factor");
END_PARAM_GROUP();
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFacetSlidingSurface::Data::Data()
{
m_Lm = 0.0;
m_eps = 1.0;
m_nu = vec3d(0,0,0);
m_rs = vec2d(0,0);
}
void FEFacetSlidingSurface::Data::Init()
{
FEContactMaterialPoint::Init();
m_Lm = 0.0;
m_eps = 1.0;
m_nu = vec3d(0, 0, 0);
m_rs = vec2d(0, 0);
}
//-----------------------------------------------------------------------------
void FEFacetSlidingSurface::Data::Serialize(DumpStream& ar)
{
FEContactMaterialPoint::Serialize(ar);
ar & m_Lm;
ar & m_eps;
ar & m_nu;
ar & m_rs;
}
//-----------------------------------------------------------------------------
// FEFacetSlidingSurface
//-----------------------------------------------------------------------------
FEFacetSlidingSurface::FEFacetSlidingSurface(FEModel* pfem) : FEContactSurface(pfem)
{
// define class exports
EXPORT_DATA(PLT_VEC3F, FMT_NODE, &m_Fn, "contact nodal forces");
}
//-----------------------------------------------------------------------------
FEMaterialPoint* FEFacetSlidingSurface::CreateMaterialPoint()
{
return new FEFacetSlidingSurface::Data;
}
//-----------------------------------------------------------------------------
bool FEFacetSlidingSurface::Init()
{
// initialize surface data first
if (FEContactSurface::Init() == false) return false;
int nn = Nodes();
m_Fn.assign(nn, vec3d(0,0,0));
return true;
}
//-----------------------------------------------------------------------------
//! serialization
void FEFacetSlidingSurface::Serialize(DumpStream& ar)
{
FEContactSurface::Serialize(ar);
ar & m_Fn;
}
//-----------------------------------------------------------------------------
vec3d FEFacetSlidingSurface::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;
}
//-----------------------------------------------------------------------------
double FEFacetSlidingSurface::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);
if (el.isActive())
{
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 s = (data.m_Ln > 0) ? 1 : 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 * s);
}
}
}
return a;
}
//-----------------------------------------------------------------------------
void FEFacetSlidingSurface::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& d = static_cast<Data&>(*el.GetMaterialPoint(k));
pt -= d.m_nu*d.m_Ln;
}
pt /= ni;
}
//-----------------------------------------------------------------------------
void FEFacetSlidingSurface::GetNodalContactPressure(int nface, double* pn)
{
FESurfaceElement& el = Element(nface);
int ne = el.Nodes();
int ni = el.GaussPoints();
double ti[FEElement::MAX_INTPOINTS];
for (int k=0; k<ni; ++k)
{
Data& d = static_cast<Data&>(*el.GetMaterialPoint(k));
double L = d.m_Ln;
ti[k] = L;// + pf->m_epsn*gi[k];
ti[k] = (ti[k]>=0?ti[k] : 0);
}
el.FEElement::project_to_nodes(ti, pn);
for (int k=0; k<ni; ++k)
pn[k] = (pn[k]>=0?pn[k] : 0);
}
//-----------------------------------------------------------------------------
void FEFacetSlidingSurface::GetNodalContactTraction(int nface, vec3d* tn)
{
FESurfaceElement& el = Element(nface);
int ne = el.Nodes();
int ni = el.GaussPoints();
vec3d t;
const int MFI = FEElement::MAX_INTPOINTS;
double tix[MFI], tiy[MFI], tiz[MFI];
for (int k=0; k<ni; ++k)
{
Data& d = static_cast<Data&>(*el.GetMaterialPoint(k));
double gi = d.m_gap;
double Li = d.m_Ln;
vec3d ti = d.m_nu;
if (gi > 0) t = ti*(Li); else t = vec3d(0,0,0);
tix[k] = t.x; tiy[k] = t.y; tiz[k] = t.z;
}
// project traction to nodes
const int MFN = FEElement::MAX_NODES;
double tnx[MFN], tny[MFN], tnz[MFN];
el.FEElement::project_to_nodes(tix, tnx);
el.FEElement::project_to_nodes(tiy, tny);
el.FEElement::project_to_nodes(tiz, tnz);
// store data
for (int k=0; k<ne; ++k)
{
tn[k].x = tnx[k];
tn[k].y = tny[k];
tn[k].z = tnz[k];
}
}
//-----------------------------------------------------------------------------
// FEFacet2FacetSliding
//-----------------------------------------------------------------------------
FEFacet2FacetSliding::FEFacet2FacetSliding(FEModel* pfem) : FEContactInterface(pfem), m_ss(pfem), m_ms(pfem)
{
static int ncount = 1;
SetID(ncount++);
// default parameters
m_epsn = 1.0;
m_knmult = 1.0;
m_stol = 0.01;
m_btwo_pass = false;
m_bautopen = false;
m_bupdtpen = false;
m_nsegup = 0; // always do segment updates
m_breloc = false;
m_bsmaug = false;
m_srad = 0.0;
m_atol = 0.01;
m_gtol = 0;
m_naugmin = 0;
m_naugmax = 10;
m_dxtol = 0;
// Note that friction has not been implemented yet
m_mu = 0;
m_epsf = 0;
// set parents
m_ss.SetContactInterface(this);
m_ms.SetContactInterface(this);
m_ss.SetSibling(&m_ms);
m_ms.SetSibling(&m_ss);
}
//-----------------------------------------------------------------------------
//! build the matrix profile for use in the stiffness matrix
void FEFacet2FacetSliding::BuildMatrixProfile(FEGlobalMatrix& K)
{
FEModel& fem = *GetFEModel();
FEMesh& mesh = fem.GetMesh();
// 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*FEElement::MAX_NODES*2);
int npass = (m_btwo_pass?2:1);
for (int np=0; np<npass; ++np)
{
FEFacetSlidingSurface& ss = (np == 0? m_ss : m_ms);
FEFacetSlidingSurface& ms = (np == 0? m_ms : m_ss);
for (int j=0; j<ss.Elements(); ++j)
{
FESurfaceElement& se = ss.Element(j);
int nint = se.GaussPoints();
int* sn = &se.m_node[0];
for (int k=0; k<nint; ++k)
{
FEFacetSlidingSurface::Data& pt = static_cast<FEFacetSlidingSurface::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 (int l=0; l<nseln; ++l)
{
vector<int>& id = mesh.Node(sn[l]).m_ID;
lm[6*l ] = id[dof_X];
lm[6*l+1] = id[dof_Y];
lm[6*l+2] = id[dof_Z];
lm[6*l+3] = id[dof_RU];
lm[6*l+4] = id[dof_RV];
lm[6*l+5] = id[dof_RW];
}
for (int l=0; l<nmeln; ++l)
{
vector<int>& id = mesh.Node(mn[l]).m_ID;
lm[6*(l+nseln) ] = id[dof_X];
lm[6*(l+nseln)+1] = id[dof_Y];
lm[6*(l+nseln)+2] = id[dof_Z];
lm[6*(l+nseln)+3] = id[dof_RU];
lm[6*(l+nseln)+4] = id[dof_RV];
lm[6*(l+nseln)+5] = id[dof_RW];
}
K.build_add(lm);
}
}
}
}
}
//-----------------------------------------------------------------------------
//! Initialization routine
bool FEFacet2FacetSliding::Init()
{
m_bfirst = true;
m_normg0 = 0.0;
// initialize surface data
if (m_ss.Init() == false) return false;
if (m_ms.Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
void FEFacet2FacetSliding::UpdateAutoPenalty()
{
// calculate penalty factors
if (m_bautopen) CalcAutoPenalty(m_ss);
}
//-----------------------------------------------------------------------------
void FEFacet2FacetSliding::Activate()
{
// don't forget the base class
FEContactInterface::Activate();
UpdateAutoPenalty();
// project primary surface onto secondary surface
ProjectSurface(m_ss, m_ms, true, m_breloc);
if (m_btwo_pass)
{
ProjectSurface(m_ms, m_ss, true);
if (m_bautopen) CalcAutoPenalty(m_ms);
}
// check friction parameters
// since friction has not been implemented yet
if ((m_mu != 0) || (m_epsf != 0))
{
feLogWarning("Friction has NOT been implemented yet for facet-to-facet contact interfaces.\nFriction parameters are ignored.");
m_mu = 0;
m_epsf = 0;
}
}
//-----------------------------------------------------------------------------
void FEFacet2FacetSliding::CalcAutoPenalty(FEFacetSlidingSurface& s)
{
// get the mesh
FEMesh& m = GetFEModel()->GetMesh();
// 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)
{
FEFacetSlidingSurface::Data& pt = static_cast<FEFacetSlidingSurface::Data&>(*el.GetMaterialPoint(j));
pt.m_eps = eps;
}
}
}
//-----------------------------------------------------------------------------
//! In this function we project the integration points to the secondary surface,
//! calculate the projection's natural coordinates and normal vector
//
void FEFacet2FacetSliding::ProjectSurface(FEFacetSlidingSurface &ss, FEFacetSlidingSurface &ms, bool bsegup, bool bmove)
{
FEClosestPointProjection cpp(ms);
cpp.HandleSpecialCases(true);
cpp.SetSearchRadius(m_srad);
cpp.SetTolerance(m_stol);
cpp.Init();
// if we need to project the nodes onto the secondary surface,
// let's do this first
if (bmove)
{
int NN = ss.Nodes();
int NE = ss.Elements();
// first we need to calculate the node normals
vector<vec3d> normal; normal.assign(NN, vec3d(0,0,0));
for (int i=0; i<NE; ++i)
{
FESurfaceElement& el = ss.Element(i);
if (el.isActive())
{
int ne = el.Nodes();
for (int j = 0; j < ne; ++j)
{
vec3d r0 = ss.Node(el.m_lnode[j]).m_rt;
vec3d rp = ss.Node(el.m_lnode[(j + 1) % ne]).m_rt;
vec3d rm = ss.Node(el.m_lnode[(j + ne - 1) % ne]).m_rt;
vec3d n = (rp - r0) ^ (rm - r0);
normal[el.m_lnode[j]] += n;
}
}
}
for (int i=0; i<NN; ++i) normal[i].unit();
// loop over all nodes
for (int i=0; i<NN; ++i)
{
FENode& node = ss.Node(i);
// get the spatial nodal coordinates
vec3d rt = node.m_rt;
vec3d nu = normal[i];
// project onto the secondary surface
vec3d q;
vec2d rs(0,0);
FESurfaceElement* pme = cpp.Project(ss.NodeIndex(i), q, rs);
if (pme)
{
double gap = (nu*(rt - q));
if (gap>0) node.m_r0 = node.m_rt = q;
}
}
}
// loop over all primary surface elements
int NE = ss.Elements();
#pragma omp parallel for shared(cpp) schedule(dynamic)
for (int i=0; i<NE; ++i)
{
// get the next element
FESurfaceElement& se = ss.Element(i);
if (se.isActive())
{
int nn = se.Nodes();
// get nodal coordinates
vec3d re[FEElement::MAX_NODES];
for (int l = 0; l < nn; ++l) re[l] = ss.GetMesh()->Node(se.m_node[l]).m_rt;
// loop over all its integration points
int nint = se.GaussPoints();
for (int j = 0; j < nint; ++j)
{
// get the integration point data
FEFacetSlidingSurface::Data& pt = static_cast<FEFacetSlidingSurface::Data&>(*se.GetMaterialPoint(j));
// calculate the global coordinates of this integration point
double* H = se.H(j);
vec3d x(0, 0, 0), q;
for (int k = 0; k < nn; ++k) x += re[k] * H[k];
FESurfaceElement* pme_prev = pt.m_pme;
if (bsegup)
{
if (pt.m_pme)
{
// see if it still projects to the same facet
q = ms.ProjectToSurface(*pt.m_pme, x, pt.m_rs[0], pt.m_rs[1]);
if (ms.IsInsideElement(*pt.m_pme, pt.m_rs[0], pt.m_rs[1], m_stol) == false)
{
pt.m_pme = nullptr;
}
}
if (pt.m_pme == nullptr)
{
// find the secondary surface segment this element belongs to
pt.m_rs = vec2d(0, 0);
FESurfaceElement* pme = 0;
pme = cpp.Project(&se, j, q, pt.m_rs);
pt.m_pme = pme;
}
}
else if (pt.m_pme)
{
// update projection to secondary surface element
FESurfaceElement& mel = *pt.m_pme;
q = ms.ProjectToSurface(mel, x, pt.m_rs[0], pt.m_rs[1]);
}
// update normal and gap at integration point
if (pt.m_pme)
{
double r = pt.m_rs[0];
double s = pt.m_rs[1];
// the normal is set to the secondary surface element normal
pt.m_nu = ms.SurfaceNormal(*pt.m_pme, r, s);
// calculate gap
pt.m_gap = -pt.m_nu * (x - q);
// if gap is negative reset contact
if (bsegup && (pt.m_gap < 0.0))
{
// pt.m_gap = 0.0;
// pt.m_pme = nullptr;
}
}
if (pt.m_pme == nullptr)
{
// since the node is not in contact, we set the gap and Lagrange multiplier to zero
pt.m_gap = 0;
// pt.m_Lm = 0;
}
}
}
}
}
//-----------------------------------------------------------------------------
void FEFacet2FacetSliding::Update()
{
FEModel& fem = *GetFEModel();
int niter = fem.GetCurrentStep()->GetFESolver()->m_niter;
// should we do a segment update or not?
// TODO: check what happens when m_nsegup == -1 and m_npass = 2;
// We have to make sure that in this case, both surfaces get at least
// one pass!
bool bupdate = (m_bfirst || (m_nsegup == 0)? true : (niter <= m_nsegup));
if ((niter == 0) && m_bupdtpen) UpdateAutoPenalty();
// project primary surface to secondary surface
ProjectSurface(m_ss, m_ms, bupdate);
if (m_btwo_pass) ProjectSurface(m_ms, m_ss, bupdate);
// Update the net contact pressures
UpdateContactPressures();
m_bfirst = false;
}
//-----------------------------------------------------------------------------
void FEFacet2FacetSliding::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
vector<int> sLM, mLM, LM, en;
vector<double> fe;
const int MELN = FEElement::MAX_NODES;
double detJ[MELN], w[MELN], *Hs, Hm[MELN];
vec3d r0[MELN];
m_ss.m_Fn.assign(m_ss.Nodes(), vec3d(0,0,0));
m_ms.m_Fn.assign(m_ms.Nodes(), vec3d(0,0,0));
int npass = (m_btwo_pass?2:1);
for (int np=0; np<npass; ++np)
{
FEFacetSlidingSurface& ss = (np == 0? m_ss : m_ms);
FEFacetSlidingSurface& ms = (np == 0? m_ms : m_ss);
// loop over all primary surface elements
for (int i=0; i<ss.Elements(); ++i)
{
FESurfaceElement& se = ss.Element(i);
if (se.isActive())
{
int nseln = se.Nodes();
int nint = se.GaussPoints();
// get the element's LM vector
ss.UnpackLM(se, sLM);
// nodal coordinates
for (int j = 0; j < nseln; ++j) r0[j] = ss.GetMesh()->Node(se.m_node[j]).m_r0;
// we calculate all the metrics we need before we
// calculate the nodal forces
for (int j = 0; j < nint; ++j)
{
double* Gr = se.Gr(j);
double* Gs = se.Gs(j);
// calculate jacobian
// note that we are integrating over the reference surface
vec3d dxr, dxs;
for (int 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;
}
// jacobians
detJ[j] = (dxr ^ dxs).norm();
// integration weights
w[j] = se.GaussWeights()[j];
}
// loop over all integration points
for (int j = 0; j < nint; ++j)
{
// get integration point data
FEFacetSlidingSurface::Data& pt = static_cast<FEFacetSlidingSurface::Data&>(*se.GetMaterialPoint(j));
// get the secondary surface element
FESurfaceElement* pme = pt.m_pme;
if (pme)
{
FESurfaceElement& me = *pme;
int nmeln = me.Nodes();
ms.UnpackLM(me, mLM);
// calculate degrees of freedom
int ndof = 3 * (nseln + nmeln);
// build the LM vector
LM.resize(ndof);
for (int k = 0; k < nseln; ++k)
{
LM[3 * k] = sLM[3 * k];
LM[3 * k + 1] = sLM[3 * k + 1];
LM[3 * k + 2] = sLM[3 * k + 2];
}
for (int k = 0; k < nmeln; ++k)
{
LM[3 * (k + nseln)] = mLM[3 * k];
LM[3 * (k + nseln) + 1] = mLM[3 * k + 1];
LM[3 * (k + nseln) + 2] = mLM[3 * k + 2];
}
// build the en vector
en.resize(nseln + nmeln);
for (int k = 0; k < nseln; ++k) en[k] = se.m_node[k];
for (int k = 0; k < nmeln; ++k) en[k + nseln] = me.m_node[k];
// calculate shape functions
Hs = se.H(j);
double r = pt.m_rs[0];
double s = pt.m_rs[1];
me.shape_fnc(Hm, r, s);
// get normal vector
vec3d nu = pt.m_nu;
// gap function
double g = pt.m_gap;
// lagrange multiplier
double Lm = pt.m_Lm;
// penalty value
double eps = m_epsn * pt.m_eps;
// contact traction
double tn = Lm + eps * g;
tn = MBRACKET(tn);
// calculate the force vector
fe.resize(ndof);
for (int k = 0; k < nseln; ++k)
{
fe[3 * k] = Hs[k] * nu.x;
fe[3 * k + 1] = Hs[k] * nu.y;
fe[3 * k + 2] = Hs[k] * nu.z;
}
for (int k = 0; k < nmeln; ++k)
{
fe[3 * (k + nseln)] = -Hm[k] * nu.x;
fe[3 * (k + nseln) + 1] = -Hm[k] * nu.y;
fe[3 * (k + nseln) + 2] = -Hm[k] * nu.z;
}
for (int k = 0; k < ndof; ++k) fe[k] *= tn * 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 FEFacet2FacetSliding::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
vector<int> sLM, mLM, LM, en;
const int MN = FEElement::MAX_NODES;
const int ME = 3*MN*2;
double N[ME], T1[ME], T2[ME], N1[ME] = {0}, N2[ME] = {0}, D1[ME], D2[ME], Nb1[ME], Nb2[ME];
FEElementMatrix ke;
// get the mesh
FEMesh* pm = m_ss.GetMesh();
// see how many reformations we've had to do so far
int nref = GetSolver()->m_nref;
// get the "size" of the model
// We need this to scale the insertion distance
double R = GetFEModel()->GetMesh().GetBoundingBox().radius();
double dxtol = R*m_dxtol;
// set higher order stiffness mutliplier
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;
}
double detJ[MN], w[MN], *Hs, Hm[MN], Hmr[MN], Hms[MN];
vec3d r0[MN];
int npass = (m_btwo_pass?2:1);
for (int np=0; np < npass; ++np)
{
FEFacetSlidingSurface& ss = (np == 0? m_ss : m_ms);
FEFacetSlidingSurface& ms = (np == 0? m_ms : m_ss);
// loop over all primary surface elements
for (int i=0; i<ss.Elements(); ++i)
{
FESurfaceElement& se = ss.Element(i);
if (se.isActive())
{
int nseln = se.Nodes();
int nint = se.GaussPoints();
// get the element's LM vector
ss.UnpackLM(se, sLM);
// nodal coordinates
for (int j = 0; j < nseln; ++j) r0[j] = ss.GetMesh()->Node(se.m_node[j]).m_r0;
// we calculate all the metrics we need before we
// calculate the nodal forces
for (int j = 0; j < nint; ++j)
{
double* Gr = se.Gr(j);
double* Gs = se.Gs(j);
// calculate jacobian
// note that we are integrating over the reference surface
vec3d dxr, dxs;
for (int 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;
}
// jacobians
detJ[j] = (dxr ^ dxs).norm();
// integration weights
w[j] = se.GaussWeights()[j];
}
// loop over all integration points
for (int j = 0; j < nint; ++j)
{
// get integration point data
FEFacetSlidingSurface::Data& pt = static_cast<FEFacetSlidingSurface::Data&>(*se.GetMaterialPoint(j));
// get the secondary surface element
FESurfaceElement* pme = pt.m_pme;
if (pme)
{
FESurfaceElement& me = *pme;
int nmeln = me.Nodes();
ms.UnpackLM(me, mLM);
// calculate degrees of freedom
int ndof = 3 * (nseln + nmeln);
// build the LM vector
LM.resize(ndof);
for (int k = 0; k < nseln; ++k)
{
LM[3 * k] = sLM[3 * k];
LM[3 * k + 1] = sLM[3 * k + 1];
LM[3 * k + 2] = sLM[3 * k + 2];
}
for (int k = 0; k < nmeln; ++k)
{
LM[3 * (k + nseln)] = mLM[3 * k];
LM[3 * (k + nseln) + 1] = mLM[3 * k + 1];
LM[3 * (k + nseln) + 2] = mLM[3 * k + 2];
}
// build the en vector
en.resize(nseln + nmeln);
for (int k = 0; k < nseln; ++k) en[k] = se.m_node[k];
for (int k = 0; k < nmeln; ++k) en[k + nseln] = me.m_node[k];
// calculate shape functions
Hs = se.H(j);
double r = pt.m_rs[0];
double s = pt.m_rs[1];
me.shape_fnc(Hm, r, s);
// get normal vector
vec3d nu = pt.m_nu;
// gap function
double g = pt.m_gap;
// when the node is on the surface, the gap value
// can flip-flop between positive and negative.
if (fabs(g) < 1e-20) g = 0;
// lagrange multiplier
double Lm = pt.m_Lm;
// penalty value
double eps = m_epsn * pt.m_eps;
// contact traction
double tn = Lm + eps * g;
tn = MBRACKET(tn);
double dtn = eps * HEAVYSIDE(Lm + eps * g);
// define buffer layer for penalty insertion
// TODO: I don't think this does anything since dtn cannot < 0
if ((dtn < 1e-7) && (g < 0) && (dxtol != 0))
{
if (dxtol < 0) dtn = eps * exp(-g / dxtol);
else if (-g <= dxtol) dtn = eps * (1 + g / dxtol);
}
// calculate the N-vector
for (int k = 0; k < nseln; ++k)
{
N[3 * k] = Hs[k] * nu.x;
N[3 * k + 1] = Hs[k] * nu.y;
N[3 * k + 2] = Hs[k] * nu.z;
}
for (int k = 0; k < nmeln; ++k)
{
N[3 * (k + nseln)] = -Hm[k] * nu.x;
N[3 * (k + nseln) + 1] = -Hm[k] * nu.y;
N[3 * (k + nseln) + 2] = -Hm[k] * nu.z;
}
// --- N O R M A L S T I F F N E S S ---
// create the stiffness matrix
ke.resize(ndof, ndof);
// add the first order term (= D(tn)*dg )
for (int k = 0; k < ndof; ++k)
for (int l = 0; l < ndof; ++l) ke[k][l] = dtn * N[k] * N[l] * detJ[j] * w[j];
// add the higher order terms (= tn*D(dg) )
if (knmult > 0)
{
// calculate the secondary surface shape fncs derivatives
me.shape_deriv(Hmr, Hms, r, s);
// get the secondary surface nodes
vec3d rt[MN];
for (int k = 0; k < nmeln; ++k) rt[k] = ms.GetMesh()->Node(me.m_node[k]).m_rt;
// get the tangent vectors
vec3d tau1(0, 0, 0), tau2(0, 0, 0);
for (int k = 0; k < nmeln; ++k)
{
tau1.x += Hmr[k] * rt[k].x;
tau1.y += Hmr[k] * rt[k].y;
tau1.z += Hmr[k] * rt[k].z;
tau2.x += Hms[k] * rt[k].x;
tau2.y += Hms[k] * rt[k].y;
tau2.z += Hms[k] * rt[k].z;
}
// set up the Ti vectors
for (int k = 0; k < nseln; ++k)
{
T1[k * 3] = Hs[k] * tau1.x; T2[k * 3] = Hs[k] * tau2.x;
T1[k * 3 + 1] = Hs[k] * tau1.y; T2[k * 3 + 1] = Hs[k] * tau2.y;
T1[k * 3 + 2] = Hs[k] * tau1.z; T2[k * 3 + 2] = Hs[k] * tau2.z;
}
for (int k = 0; k < nmeln; ++k)
{
T1[(k + nseln) * 3] = -Hm[k] * tau1.x;
T1[(k + nseln) * 3 + 1] = -Hm[k] * tau1.y;
T1[(k + nseln) * 3 + 2] = -Hm[k] * tau1.z;
T2[(k + nseln) * 3] = -Hm[k] * tau2.x;
T2[(k + nseln) * 3 + 1] = -Hm[k] * tau2.y;
T2[(k + nseln) * 3 + 2] = -Hm[k] * tau2.z;
}
// set up the Ni vectors
for (int k = 0; k < nmeln; ++k)
{
N1[(k + nseln) * 3] = -Hmr[k] * nu.x;
N1[(k + nseln) * 3 + 1] = -Hmr[k] * nu.y;
N1[(k + nseln) * 3 + 2] = -Hmr[k] * nu.z;
N2[(k + nseln) * 3] = -Hms[k] * nu.x;
N2[(k + nseln) * 3 + 1] = -Hms[k] * nu.y;
N2[(k + nseln) * 3 + 2] = -Hms[k] * nu.z;
}
// calculate metric tensor
mat2d M;
M[0][0] = tau1 * tau1; M[0][1] = tau1 * tau2;
M[1][0] = tau2 * tau1; M[1][1] = tau2 * tau2;
// calculate reciprocal metric tensor
mat2d Mi = M.inverse();
// calculate curvature tensor
double K[2][2] = { 0 };
double Grr[MN];
double Gss[MN];
double Grs[MN];
me.shape_deriv2(Grr, Grs, Gss, r, s);
for (int k = 0; k < nmeln; ++k)
{
K[0][0] += (nu * rt[k]) * Grr[k];
K[0][1] += (nu * rt[k]) * Grs[k];
K[1][0] += (nu * rt[k]) * Grs[k];
K[1][1] += (nu * rt[k]) * Gss[k];
}
// setup A matrix A = M + gK
double A[2][2];
A[0][0] = M[0][0] + g * K[0][0];
A[0][1] = M[0][1] + g * K[0][1];
A[1][0] = M[1][0] + g * K[1][0];
A[1][1] = M[1][1] + g * K[1][1];
// calculate determinant of A
double detA = A[0][0] * A[1][1] - A[0][1] * A[1][0];
// setup Di vectors
for (int k = 0; k < ndof; ++k)
{
D1[k] = (1 / detA) * (A[1][1] * (T1[k] + g * N1[k]) - A[0][1] * (T2[k] + g * N2[k]));
D2[k] = (1 / detA) * (A[0][0] * (T2[k] + g * N2[k]) - A[0][1] * (T1[k] + g * N1[k]));
}
// setup Nbi vectors
for (int k = 0; k < ndof; ++k)
{
Nb1[k] = N1[k] - K[0][1] * D2[k];
Nb2[k] = N2[k] - K[0][1] * D1[k];
}
// add it to the stiffness
double sum;
for (int k = 0; k < ndof; ++k)
for (int l = 0; l < ndof; ++l)
{
sum = Mi[0][0] * Nb1[k] * Nb1[l] + Mi[0][1] * (Nb1[k] * Nb2[l] + Nb2[k] * Nb1[l]) + Mi[1][1] * Nb2[k] * Nb2[l];
sum *= g;
sum -= D1[k] * N1[l] + D2[k] * N2[l] + N1[k] * D1[l] + N2[k] * D2[l];
sum += K[0][1] * (D1[k] * D2[l] + D2[k] * D1[l]);
sum *= tn * knmult;
ke[k][l] += sum * detJ[j] * w[j];
}
}
// assemble the global residual
ke.SetNodes(en);
ke.SetIndices(LM);
LS.Assemble(ke);
}
}
}
}
}
}
//-----------------------------------------------------------------------------
void FEFacet2FacetSliding::UpdateContactPressures()
{
int npass = (m_btwo_pass?2:1);
for (int np=0; np<npass; ++np)
{
FEFacetSlidingSurface& ss = (np == 0? m_ss : m_ms);
FEFacetSlidingSurface& ms = (np == 0? m_ms : m_ss);
// loop over all elements of the primary surface
for (int n=0; n<ss.Elements(); ++n)
{
FESurfaceElement& el = ss.Element(n);
if (el.isActive())
{
int nint = el.GaussPoints();
// get the normal tractions at the integration points
double gap, eps;
for (int i = 0; i < nint; ++i)
{
FEFacetSlidingSurface::Data& pt = static_cast<FEFacetSlidingSurface::Data&>(*el.GetMaterialPoint(i));
gap = pt.m_gap;
eps = m_epsn * pt.m_eps;
pt.m_Ln = MBRACKET(pt.m_Lm + eps * gap);
FESurfaceElement* pme = pt.m_pme;
if (m_btwo_pass && pme)
{
// get secondary surface element data
int mint = pme->GaussPoints();
double ti[FEElement::MAX_NODES];
for (int j = 0; j < mint; ++j)
{
FEFacetSlidingSurface::Data& md = static_cast<FEFacetSlidingSurface::Data&>(*pme->GetMaterialPoint(j));
gap = md.m_gap;
eps = m_epsn * md.m_eps;
ti[j] = MBRACKET(md.m_Lm + m_epsn * md.m_eps * md.m_gap);
}
// project the data to the nodes
double tn[FEElement::MAX_NODES];
pme->FEElement::project_to_nodes(ti, tn);
// now evaluate the traction at the intersection point
double Ln = pme->eval(tn, pt.m_rs[0], pt.m_rs[1]);
pt.m_Ln += MBRACKET(Ln);
}
}
}
}
}
}
//-----------------------------------------------------------------------------
bool FEFacet2FacetSliding::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (m_laugon != FECore::AUGLAG_METHOD) return true;
bool bconv = true;
// --- c a l c u l a t e i n i t i a l n o r m s ---
// a. normal component
int NS = (int) m_ss.Elements();
int NM = (int) m_ms.Elements();
double normL0 = 0;
for (int i=0; i<NS; ++i)
{
FESurfaceElement& el = m_ss.Element(i);
if (el.isActive())
{
int nint = el.GaussPoints();
for (int j = 0; j < nint; ++j)
{
FEFacetSlidingSurface::Data& ds = static_cast<FEFacetSlidingSurface::Data&>(*el.GetMaterialPoint(j));
normL0 += ds.m_Lm * ds.m_Lm;
}
}
}
for (int i=0; i<NM; ++i)
{
FESurfaceElement& el = m_ms.Element(i);
if (el.isActive())
{
int nint = el.GaussPoints();
for (int j = 0; j < nint; ++j)
{
FEFacetSlidingSurface::Data& dm = static_cast<FEFacetSlidingSurface::Data&>(*el.GetMaterialPoint(j));
normL0 += dm.m_Lm * dm.m_Lm;
}
}
}
normL0 = sqrt(normL0);
// --- c a l c u l a t e c u r r e n t n o r m s ---
// b. normal component
double normL1 = 0; // force norm
double normg1 = 0; // gap norm
int N = 0;
double Ln;
for (int i=0; i<m_ss.Elements(); ++i) {
FESurfaceElement& el = m_ss.Element(i);
if (el.isActive())
{
vec3d tn[FEElement::MAX_INTPOINTS];
if (m_bsmaug) m_ss.GetGPSurfaceTraction(i, tn);
for (int j = 0; j < el.GaussPoints(); ++j) {
FEFacetSlidingSurface::Data& data = static_cast<FEFacetSlidingSurface::Data&>(*el.GetMaterialPoint(j));
// update Lagrange multipliers on primary surface
if (m_bsmaug) {
// replace this multiplier with a smoother version
Ln = -(tn[j] * data.m_nu);
data.m_Lm = MBRACKET(Ln);
if (m_btwo_pass) data.m_Lm /= 2;
}
else {
double eps = m_epsn * data.m_eps;
Ln = data.m_Lm + eps * data.m_gap;
double Lm = MBRACKET(Ln);
normL1 += Lm * Lm;
}
if (data.m_gap > 0)
{
normg1 += data.m_gap * data.m_gap;
++N;
}
}
}
}
for (int i=0; i<m_ms.Elements(); ++i) {
FESurfaceElement& el = m_ms.Element(i);
if (el.isActive())
{
vec3d tn[FEElement::MAX_INTPOINTS];
if (m_bsmaug) m_ms.GetGPSurfaceTraction(i, tn);
for (int j = 0; j < el.GaussPoints(); ++j) {
FEFacetSlidingSurface::Data& data = static_cast<FEFacetSlidingSurface::Data&>(*el.GetMaterialPoint(j));
// update Lagrange multipliers on secondary surface
if (m_bsmaug) {
// replace this multiplier with a smoother version
Ln = -(tn[j] * data.m_nu);
data.m_Lm = MBRACKET(Ln);
if (m_btwo_pass) data.m_Lm /= 2;
}
else {
double eps = m_epsn * data.m_eps;
Ln = data.m_Lm + eps * data.m_gap;
double Lm = MBRACKET(Ln);
normL1 += Lm * Lm;
}
if (data.m_gap > 0)
{
normg1 += data.m_gap * data.m_gap;
++N;
}
}
}
}
if (N == 0) N=1;
normL1 = sqrt(normL1);
normg1 = sqrt(normg1 / N);
if (naug == 0) m_normg0 = 0;
// calculate and print convergence norms
double lnorm = 0, gnorm = 0;
if (normL1 != 0) lnorm = fabs(normL1 - normL0)/normL1; else lnorm = fabs(normL1 - normL0);
// if (normg1 != 0) gnorm = fabs(normg1 - m_normg0)/normg1; else gnorm = fabs(normg1 - m_normg0);
gnorm = normg1;
feLog(" sliding interface # %d\n", GetID());
feLog(" CURRENT REQUIRED\n");
feLog(" normal force : %15le", lnorm);
if (m_atol > 0) feLog("%15le\n", m_atol); else feLog(" ***\n");
feLog(" gap function : %15le", gnorm);
if (m_gtol > 0) feLog("%15le\n", m_gtol); else feLog(" ***\n");
// check convergence
bconv = true;
if ((m_atol > 0) && (lnorm > m_atol)) bconv = false;
if ((m_gtol > 0) && (gnorm > m_gtol)) bconv = false;
if (m_naugmin > naug) bconv = false;
if (m_naugmax <= naug) bconv = true;
if (bconv == false)
{
// we did not converge so update multipliers
for (int i=0; i<NS; ++i)
{
FESurfaceElement& el = m_ss.Element(i);
if (el.isActive())
{
for (int j = 0; j < el.GaussPoints(); ++j)
{
FEFacetSlidingSurface::Data& ds = static_cast<FEFacetSlidingSurface::Data&>(*el.GetMaterialPoint(j));
// penalty value
double eps = m_epsn * ds.m_eps;
// update Lagrange multipliers
double Ln = ds.m_Lm + eps * ds.m_gap;
ds.m_Lm = MBRACKET(Ln);
}
}
}
for (int i=0; i<NM; ++i)
{
FESurfaceElement& el = m_ms.Element(i);
if (el.isActive())
{
for (int j = 0; j < el.GaussPoints(); ++j)
{
FEFacetSlidingSurface::Data& dm = static_cast<FEFacetSlidingSurface::Data&>(*el.GetMaterialPoint(j));
// penalty value
double eps = m_epsn * dm.m_eps;
// update Lagrange multipliers
double Ln = dm.m_Lm + eps * dm.m_gap;
dm.m_Lm = MBRACKET(Ln);
}
}
}
}
// store the last gap norm
m_normg0 = normg1;
return bconv;
}
//-----------------------------------------------------------------------------
void FEFacet2FacetSliding::Serialize(DumpStream &ar)
{
// store contact data
FEContactInterface::Serialize(ar);
// store contact surface data
m_ms.Serialize(ar);
m_ss.Serialize(ar);
// serialize element pointers
SerializeElementPointers(m_ss, m_ms, ar);
SerializeElementPointers(m_ms, m_ss, ar);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberMaterial.cpp | .cpp | 1,858 | 48 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEFiberMaterial.h"
#include "FEFiberMaterialPoint.h"
FEFiberMaterial::FEFiberMaterial(FEModel* fem) : FEMaterialProperty(fem)
{
}
FEMaterialPointData* FEFiberMaterial::CreateMaterialPointData()
{
return new FEFiberMaterialPoint(nullptr);
}
//===========================================================================================
FEFiberMaterialUncoupled::FEFiberMaterialUncoupled(FEModel* fem) : FEMaterialProperty(fem)
{
}
FEMaterialPointData* FEFiberMaterialUncoupled::CreateMaterialPointData()
{
return new FEFiberMaterialPoint(nullptr);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPreStrainElastic.cpp | .cpp | 4,659 | 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 "FEPreStrainElastic.h"
//! constructor
FEPrestrainMaterialPoint::FEPrestrainMaterialPoint(FEMaterialPointData* mp) : FEMaterialPointData(mp)
{
F0.unit();
Fc.unit();
}
//! copy
FEMaterialPointData* FEPrestrainMaterialPoint::Copy()
{
FEMaterialPointData* mp = new FEPrestrainMaterialPoint(*this);
if (m_pNext) mp->SetNext(m_pNext->Copy());
return mp;
}
//! initialization
void FEPrestrainMaterialPoint::Init(bool bflag)
{
}
//! Serialization
void FEPrestrainMaterialPoint::Serialize(DumpStream& dmp)
{
FEMaterialPointData::Serialize(dmp);
dmp & F0 & Fc;
}
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEPrestrainElastic, FEElasticMaterial)
ADD_PROPERTY(m_mat, "elastic");
ADD_PROPERTY(m_Fp, "prestrain", false);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPrestrainElastic::FEPrestrainElastic(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_mat = nullptr;
m_Fp = nullptr;
}
//-----------------------------------------------------------------------------
// evaluate density in (pre-strained) reference configuration
double FEPrestrainElastic::Density(FEMaterialPoint& mp)
{
double d0 = FEElasticMaterial::Density(mp);
mat3d Fp = PrestrainGradient(mp);
double Jp = Fp.det();
return d0 / Jp;
}
//-----------------------------------------------------------------------------
//! Create material point data for this material
FEMaterialPointData* FEPrestrainElastic::CreateMaterialPointData()
{
FEMaterialPointData* pm = new FEPrestrainMaterialPoint(m_mat->CreateMaterialPointData());
if (m_Fp) pm->Append(m_Fp->CreateMaterialPointData());
return pm;
}
//-----------------------------------------------------------------------------
mat3d FEPrestrainElastic::PrestrainGradient(FEMaterialPoint& mp)
{
mat3d F0 = mat3d::identity();
if (m_Fp) F0 = m_Fp->Prestrain(mp);
FEPrestrainMaterialPoint& pt = *(mp.ExtractData<FEPrestrainMaterialPoint>());
pt.setInitialPrestrain(F0);
return pt.prestrain();
}
//-----------------------------------------------------------------------------
mat3ds FEPrestrainElastic::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& ep = *(mp.ExtractData<FEElasticMaterialPoint>());
FEPrestrainMaterialPoint& pp = *(mp.ExtractData<FEPrestrainMaterialPoint>());
// store the original deformation gradient
mat3d F0 = ep.m_F;
double J0 = ep.m_J;
// pre-multiply the pre-strain
mat3d Fp = PrestrainGradient(mp);
ep.m_F = ep.m_F*Fp;
ep.m_J = ep.m_F.det();
// evaluate the stress
mat3ds s = m_mat->Stress(mp);
// restore original deformation gradient
ep.m_F = F0;
ep.m_J = J0;
// return stress
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEPrestrainElastic::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& ep = *(mp.ExtractData<FEElasticMaterialPoint>());
FEPrestrainMaterialPoint& pt = *(mp.ExtractData<FEPrestrainMaterialPoint>());
// store the original deformation gradient
mat3d F0 = ep.m_F;
double J0 = ep.m_J;
// pre-multiply the pre-strain
mat3d Fp = pt.prestrain();
ep.m_F = ep.m_F*Fp;
ep.m_J = ep.m_F.det();
// evaluate the elastic tangent
tens4ds ce = m_mat->Tangent(mp);
// restore original deformation gradient
ep.m_F = F0;
ep.m_J = J0;
// return spatial tangent
return ce;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberMaterialPoint.h | .h | 2,161 | 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 "FECore/FEMaterial.h"
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
// Define a material point that stores the fiber pre-stretch
class FEBIOMECH_API FEFiberMaterialPoint : public FEMaterialPointData
{
public:
FEFiberMaterialPoint(FEMaterialPointData* pt);
FEMaterialPointData* Copy();
void Init();
void Serialize(DumpStream& ar);
public:
// Set or clear pre-stretch, as needed in multigenerational materials (e.g., reactive viscoelasticity)
void SetPreStretch(const mat3ds Us) { m_Us = Us; m_bUs = true; }
void ResetPreStretch() { m_bUs = false; }
vec3d FiberPreStretch(const vec3d a0);
public:
mat3ds m_Us; //!< pre-stretch tensor for fiber
bool m_bUs; //!< flag for pre-stretch
int m_index = -1; //!< used as index in CDF material
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledMaterial.h | .h | 5,503 | 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.*/
#pragma once
#include "FEElasticMaterial.h"
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
//! Base class for uncoupled hyperelastic material formulations.
//! In FEBio, for uncoupled materials it is assumed that the strain energy function
//! is a sum of two terms, a deviatoric strain energy term, which only depends on the
//! deviatoric right Cauchy-Green tensor C_tilde, and a volumetric term which only
//! depends on J, the determinant of the deformation gradient. The total Cauchy stress
//! is therefore also a sum of two contributions, namely the deviatoric Cauchy stress
//! and a pressure term where p = dU/dJ.
//! One of the main motivations for the alternative material interface is that some
//! finite element implementations can take advantage of the uncoupling. For example,
//! the three-field formulation integrates the two different material terms differently
//! in order to avoid locking problems for (nearly-) incompressible materials.
//! When implementing a new material derived from this base class, the developer needs
//! to provide the deviatoric stress function and the pressure function as well as their
//! derivatives.
class FEBIOMECH_API FEUncoupledMaterial : public FEElasticMaterial
{
public:
//! constructor
FEUncoupledMaterial(FEModel* pfem);
//! initialization
bool Init() override;
public:
//----------------->
// The following functions need to be overloaded
// for each material derived from this class.
//! Deviatoric Cauchy stress
virtual mat3ds DevStress(FEMaterialPoint& mp) = 0;
//! Deviatoric spatial Tangent
virtual tens4ds DevTangent(FEMaterialPoint& mp) = 0;
//! Deviatoric strain energy density
virtual double DevStrainEnergyDensity(FEMaterialPoint& mp) { return 0; }
public:
virtual double StrongBondDevSED(FEMaterialPoint& pt) { return DevStrainEnergyDensity(pt); }
virtual double WeakBondDevSED(FEMaterialPoint& pt) { return 0; }
public:
// TODO: removing virtual from the following 3 functions causes changes
// to the convergence criteria on macOS, despite these functions not
// being overridden anywhere.
//! strain energy density U(J)
virtual double U(double J) {
switch (m_npmodel) {
case 0: return 0.5*m_K*pow(log(J),2); break; // FEBio default
case 1: return 0.25*m_K*(J*J - 2.0*log(J) - 1.0); break; // NIKE3D's Ogden material
case 2: return 0.5*m_K*(J-1)*(J-1); break; // ABAQUS
case 3: return 0.5*m_K*((J*J-1)/2-log(J)); break; // ABAQUS - GOH
default: { assert(false); return 0; }
}
}
//! pressure, i.e. first derivative of U(J)
virtual double UJ(double J) {
switch (m_npmodel) {
case 0: return m_K*log(J)/J; break;
case 1: return 0.5*m_K*(J - 1.0/J); break;
case 2: return m_K*(J-1); break;
case 3: return 0.5*m_K*(J-1.0/J); break;
default: { assert(false); return 0; }
}
}
//! second derivative of U(J)
virtual double UJJ(double J) {
switch (m_npmodel) {
case 0: return m_K*(1-log(J))/(J*J); break;
case 1: return 0.5*m_K*(1 + 1.0/(J*J)); break;
case 2: return m_K; break;
case 3: return 0.5*m_K*(1+1.0/(J*J)); break;
default: { assert(false); return 0; }
}
}
public:
// incompressibility constraint fnc and derivs
double h (double J) { return log(J); }
double hp (double J) { return 1.0 / J; }
double hpp(double J) { return -1.0 / (J*J); }
public:
//! total Cauchy stress (do not overload!)
mat3ds Stress(FEMaterialPoint& mp) final;
//! total spatial tangent (do not overload!)
tens4ds Tangent(FEMaterialPoint& mp) final;
//! calculate strain energy (do not overload!)
double StrainEnergyDensity(FEMaterialPoint& pt) final;
double StrongBondSED(FEMaterialPoint& pt) final;
double WeakBondSED(FEMaterialPoint& pt) final;
// Create material point data
FEMaterialPointData* CreateMaterialPointData() override;
public:
double m_K; //!< bulk modulus
int m_npmodel; //!< pressure model for U(J)
DECLARE_FECORE_CLASS();
FECORE_BASE_CLASS(FEUncoupledMaterial)
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEGenericHyperelasticUC.h | .h | 2,285 | 69 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
class FEGenericHyperelasticUC : public FEUncoupledMaterial
{
public:
FEGenericHyperelasticUC(FEModel* fem);
// initialization
bool Init() override;
// serialization
void Serialize(DumpStream& ar) override;
//! Deviatoric Cauchy stress
mat3ds DevStress(FEMaterialPoint& mp) override;
//! Deviatoric spatial Tangent
tens4ds DevTangent(FEMaterialPoint& mp) override;
//! Deviatoric strain energy density
double DevStrainEnergyDensity(FEMaterialPoint& mp) override;
private:
bool BuildMathExpressions();
private:
std::string m_exp; // the string with the strain energy expression
bool m_printDerivs; // option to print out derivatives
private:
MSimpleExpression m_W; // deviatoric strain-energy function
vector<double*> m_param; // user parameters
// strain energy derivatives
MSimpleExpression m_W1;
MSimpleExpression m_W2;
MSimpleExpression m_W11;
MSimpleExpression m_W12;
MSimpleExpression m_W22;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEHGOCoronary.cpp | .cpp | 6,514 | 223 | /*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 "FEHGOCoronary.h"
// define the material parameters
BEGIN_FECORE_CLASS(FEHGOCoronary, FEUncoupledMaterial)
ADD_PARAMETER(m_rho, "rho");
ADD_PARAMETER(m_k1 , "k1");
ADD_PARAMETER(m_k2 , "k2");
ADD_PROPERTY(m_fiber, "fiber");
END_FECORE_CLASS();
//////////////////////////////////////////////////////////////////////
// FETransIsoMooneyRivlin
//////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
FEHGOCoronary::FEHGOCoronary(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_rho = 0.0;
m_k1 = 0.0;
m_k2 = 1.0;
m_fiber = nullptr;
}
//-----------------------------------------------------------------------------
mat3ds FEHGOCoronary::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);
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// fiber vector
vec3d fiber = m_fiber->unitVector(mp);
mat3d Q = GetLocalCS(mp);
vec3d a0 = Q*fiber; a0.unit();
vec3d a = F * a0;
double lam = Jm13 * a.unit();
mat3ds m = dyad(a);
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
double I1 = B.tr();
double I4 = lam * lam;
// material parameters
double rho = m_rho;
double k1 = m_k1;
double k2 = m_k2;
// --- TODO: put strain energy derivatives here ---
// Wi = dW/dIi
double w = k2 * ((1.0 - rho) * (I1 - 3.0) * (I1 - 3.0) + rho*(I4 - 1.0) * (I4 - 1.0));
double w1 = 2.0 * k2 * (1.0 - rho) * (I1 - 3.0);
double w4 = 2.0 * k2 * rho * (I4 - 1.0);
double kew = k1*exp(w) / k2;
double W1 = kew * w1;
double W4 = kew * w4;
// ------------------------------------------------
// calculate T = F*dW/dC*Ft
mat3ds T = B * W1 + m*(W4*I4);
// calculate stress s = pI + 2/J * dev(T)
mat3ds s = T.dev() * (2.0 / J);
return s;
}
//-----------------------------------------------------------------------------
//! Calculate deviatoric tangent
tens4ds FEHGOCoronary::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d F = pt.m_F;
double J = pt.m_J;
double Ji = 1.0 / pt.m_J;
double Jm13 = pow(J, -1.0 / 3.0);
// calculate deviatoric left Cauchy-Green tensor: B = F*Ft
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// fiber vector
vec3d fiber = m_fiber->unitVector(mp);
mat3d Q = GetLocalCS(mp);
vec3d a0 = Q*fiber; a0.unit();
vec3d a = F * a0;
double lam = Jm13 * a.unit();
mat3ds m = dyad(a);
// Invariants of B (= invariants of C)
double J1 = B.tr();
double J4 = lam * lam;
// material parameters
double rho = m_rho;
double k1 = m_k1;
double k2 = m_k2;
// --- TODO: put strain energy derivatives here ---
// Wi = dW/dIi
double w = k2 * ((1.0 - rho) * (J1 - 3.0) * (J1 - 3.0) + rho * (J4 - 1.0) * (J4 - 1.0));
double w1 = 2.0 * k2 * (1.0 - rho) * (J1 - 3.0);
double w11 = 2.0 * k2 * (1.0 - rho);
double w4 = 2.0 * k2 * rho * (J4 - 1.0);
double w44 = 2.0 * k2 * rho;
double kew = k1 * exp(w) / k2;
double W1 = kew * w1;
double W4 = kew * w4;
double W11 = kew * (w1*w1 + w11);
double W44 = kew * (w4*w4 + w44);
double W14 = kew * (w1*w4);
// ------------------------------------
// calculate T = F*dW/dC*Ft
mat3ds T = B * W1 + m * (W4 * J4);
// calculate stress s = pI + 2/J * dev(T)
mat3ds devs = T.dev() * (2.0 / J);
// calculate dWdC:C
double WC = W1 * J1 + W4 * J4;
// calculate C:d2WdCdC:C
double CWWC = W11 * J1 * J1 + 2.0 * W14 * J1 * J4 + W44 * J4 * J4;
mat3dd I(1); // Identity
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxB = dyad1s(B);
tens4ds B4 = dyad4s(B);
tens4ds Bxm = dyad1s(B, m);
tens4ds mxm = dyad1s(m);
// d2W/dCdC:C
mat3ds WCCxC = B * (W11 * J1) + B*(W14*J4) + m*(W14*J4*J1) + m*(W44*J4*J4);
tens4ds Cw = BxB * W11 + Bxm * (W14 * J4) + mxm * (W44 * J4 * J4);
tens4ds cw = Cw*(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 FEHGOCoronary::DevStrainEnergyDensity(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);
// calculate deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// fiber vector
vec3d fiber = m_fiber->unitVector(mp);
mat3d Q = GetLocalCS(mp);
vec3d a0 = Q*fiber; a0.unit();
vec3d a = F * a0;
double lam = Jm13 * a.unit();
// Invariants of B (= invariants of C)
double J1 = B.tr();
double J4 = lam * lam;
// material parameters
double rho = m_rho;
double k1 = m_k1;
double k2 = m_k2;
// calculate sed
double w = k2 * ((1.0 - rho) * (J1 - 3.0) * (J1 - 3.0) + rho * (J4 - 1.0) * (J4 - 1.0));
double sed = (k1/k2)*(exp(w) - 1.0);
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FETraceFreeNeoHookean.cpp | .cpp | 3,970 | 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 "FETraceFreeNeoHookean.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FETraceFreeNeoHookean, FEElasticMaterial)
ADD_PARAMETER(m_mu, FE_RANGE_GREATER(0.0), "mu")->setLongName("shear modulus");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
mat3ds FETraceFreeNeoHookean::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// get the material parameter
double mu = m_mu(mp);
// calculate left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
double I1 = b.tr();
// Identity
mat3dd I(1);
// calculate stress
mat3ds s = (b*(3/I1) - I)*(mu/J);
return s;
}
//-----------------------------------------------------------------------------
tens4ds FETraceFreeNeoHookean::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// get the material parameter
double mu = m_mu(mp);
mat3dd I(1);
return dyad4s(I)*(2*mu/J);
}
//-----------------------------------------------------------------------------
double FETraceFreeNeoHookean::StrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// get the material parameter
double mu = m_mu(mp);
// calculate left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
double I1 = b.tr();
double sed = mu*log(pow(I1/3,1.5)/J);
return sed;
}
//-----------------------------------------------------------------------------
mat3ds FETraceFreeNeoHookean::PK2Stress(FEMaterialPoint& mp, const mat3ds ES)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the material parameter
double mu = m_mu(mp);
mat3ds C = pt.RightCauchyGreen();
double I1 = C.tr();
// Identity
mat3dd I(1);
// calculate stress
mat3ds S = (I*(3/I1) - C.inverse())*mu;
return S;
}
//-----------------------------------------------------------------------------
tens4dmm FETraceFreeNeoHookean::MaterialTangent(FEMaterialPoint& mp, const mat3ds ES)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// get the material parameter
double mu = m_mu(mp);
mat3ds C = pt.RightCauchyGreen();
tens4dmm c = dyad4s(C.inverse())*(2*mu);
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FESolidLinearSystem.h | .h | 2,048 | 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 <FECore/FELinearSystem.h>
#include "febiomech_api.h"
class FERigidSolver;
class FEBIOMECH_API FESolidLinearSystem : public FELinearSystem
{
public:
FESolidLinearSystem(FEModel* fem, FERigidSolver* rigidSolver, FEGlobalMatrix& K, std::vector<double>& F, std::vector<double>& u, bool bsymm, double alpha, int nreq);
// Assembly routine
// This assembles the element stiffness matrix ke into the global matrix.
// The contributions of prescribed degrees of freedom will be stored in m_F
void Assemble(const FEElementMatrix& ke) override;
// scale factor for stiffness matrix
void StiffnessAssemblyScaleFactor(double a);
private:
FEModel* fem;
FERigidSolver* m_rigidSolver;
double m_alpha;
int m_nreq;
double m_stiffnessScale;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEEFDMooneyRivlin.h | .h | 2,156 | 63 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
#include "FEMooneyRivlin.h"
#include "FEEFDUncoupled.h"
//-----------------------------------------------------------------------------
//! This class implements a material that consists of a Mooney-Rivlin matrix and
//! a continuous EFD fiber distribution.
class FEEFDMooneyRivlin : public FEUncoupledMaterial
{
public:
// constructor
FEEFDMooneyRivlin(FEModel* pfem);
//! Data initialization
bool Init() override;
public:
//! Calculate the deviatoric stress
mat3ds DevStress(FEMaterialPoint& pt) override;
//! Calculate deviatoric tangent
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! calculate deviatoric strain energy density
double DevStrainEnergyDensity(FEMaterialPoint& mp) override;
public:
FEMooneyRivlin m_MR;
FEEFDUncoupled m_EFD;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEScaledUncoupledMaterial.cpp | .cpp | 2,790 | 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) 2022 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "FEScaledUncoupledMaterial.h"
BEGIN_FECORE_CLASS(FEScaledUncoupledMaterial, FEUncoupledMaterial)
ADD_PROPERTY(m_pBase, "solid");
ADD_PARAMETER(m_scale, FE_RANGE_CLOSED(0,1), "scale");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! stress function
mat3ds FEScaledUncoupledMaterial::DevStress(FEMaterialPoint& pt)
{
// get the elastic material point data
FEElasticMaterialPoint& mp = *pt.ExtractData<FEElasticMaterialPoint>();
double scale = m_scale(pt);
return m_pBase->DevStress(pt)*scale;
}
//-----------------------------------------------------------------------------
//! tangent function
tens4ds FEScaledUncoupledMaterial::DevTangent(FEMaterialPoint& pt)
{
// get the elastic material point data
FEElasticMaterialPoint& mp = *pt.ExtractData<FEElasticMaterialPoint>();
double scale = m_scale(pt);
return m_pBase->DevTangent(pt)*scale;
}
//-----------------------------------------------------------------------------
//! strain energy density function
double FEScaledUncoupledMaterial::DevStrainEnergyDensity(FEMaterialPoint& pt)
{
// get the elastic material point data
FEElasticMaterialPoint& mp = *pt.ExtractData<FEElasticMaterialPoint>();
double scale = m_scale(pt);
return m_pBase->DevStrainEnergyDensity(pt)*scale;
}
FEMaterialPointData* FEScaledUncoupledMaterial::CreateMaterialPointData()
{
return m_pBase->CreateMaterialPointData();
} | C++ |
3D | febiosoftware/FEBio | FEBioMech/FEIncompNeoHookean.cpp | .cpp | 3,443 | 108 | /*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 "FEIncompNeoHookean.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEIncompNeoHookean, FEUncoupledMaterial)
ADD_PARAMETER(m_G, FE_RANGE_GREATER(0.0), "G")->setUnits(UNIT_PRESSURE)->setLongName("shear modulus");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEIncompNeoHookean::FEIncompNeoHookean(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_G = 0.0;
}
//-----------------------------------------------------------------------------
//! Calculate deviatoric stress
mat3ds FEIncompNeoHookean::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// shear modulus
double G = m_G(mp);
// deformation gradient
double J = pt.m_J;
// calculate left Cauchy-Green tensor
mat3ds B = pt.LeftCauchyGreen();
// calculate deviatoric stress
return (B - mat3dd(B.tr()/3.))*(G/pow(J, 5.0/3.0));
}
//-----------------------------------------------------------------------------
//! Calculate deviatoric tangent
tens4ds FEIncompNeoHookean::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// shear modulus
double G = m_G(mp);
// deformation gradient
double J = pt.m_J;
// left cauchy-green matrix (i.e. the 'b' matrix)
mat3ds B = pt.LeftCauchyGreen();
// trace of b
double Ib = B.tr();
double muJ = G/pow(J, 5.0/3.0);
mat3ds I(1,1,1,0,0,0); // Identity
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxI = dyad1s(B, I); // = BxI + IxB
return (I4*Ib -BxI + IxI*(Ib/3))*(2.0*muJ/3.0);
}
//-----------------------------------------------------------------------------
//! Calculate deviatoric strain energy density
double FEIncompNeoHookean::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// shear modulus
double G = m_G(mp);
mat3ds C = pt.DevRightCauchyGreen();
double I1 = C.tr();
// calculate deviatoric stress
return (I1-3)*G/2;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberEntropyChain.h | .h | 2,606 | 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) 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 "FEElasticFiberMaterial.h"
#include "FEFiberMaterial.h"
//-----------------------------------------------------------------------------
//! Exponential-power law
//! (Variation that includes a shear term)
class FEFiberEntropyChain : public FEFiberMaterial
{
public:
FEFiberEntropyChain(FEModel* pfem);
//! Initialization
bool Validate() override;
//! 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_N; // coefficient of micro-combination number
FEParamDouble m_ksi; // measure of fiber modulus which equals to nkT
int m_term; // how many Tayler approximation terms will be used
FEParamDouble m_mu; // shear modulus
double m_epsf;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
class FEElasticFiberEntropyChain : public FEElasticFiberMaterial_T<FEFiberEntropyChain>
{
public:
FEElasticFiberEntropyChain(FEModel* fem) : FEElasticFiberMaterial_T<FEFiberEntropyChain>(fem) {}
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEAzimuthConstraint.cpp | .cpp | 8,603 | 353 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEAzimuthConstraint.h"
#include "FEBioMech.h"
#include <FECore/FELinearSystem.h>
#include <FECore/FENode.h>
#include <FECore/log.h>
BEGIN_FECORE_CLASS(FEAzimuthConstraint, FENodeSetConstraint)
ADD_PARAMETER(m_laugon, "laugon")->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0LAGMULT\0");
ADD_PARAMETER(m_tol, "augtol");
ADD_PARAMETER(m_eps, "penalty");
ADD_PARAMETER(m_minaug, "minaug");
ADD_PARAMETER(m_maxaug, "maxaug");
END_FECORE_CLASS();
FEAzimuthConstraint::FEAzimuthConstraint(FEModel* fem) : FENodeSetConstraint(fem), m_dofU(fem), m_nodeSet(fem)
{
m_laugon = FECore::PENALTY_METHOD;
m_tol = 0.1;
m_eps = 0.0;
m_minaug = 0;
m_maxaug = 0;
// TODO: Can this be done in Init, since there is no error checking
if (fem)
{
m_dofU.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
}
}
//-----------------------------------------------------------------------------
bool FEAzimuthConstraint::Init()
{
if (FENLConstraint::Init() == false) return false;
// make sure there is a node set
if (m_nodeSet.Size() == 0) return false;
return true;
}
//-----------------------------------------------------------------------------
void FEAzimuthConstraint::Serialize(DumpStream& ar)
{
FENLConstraint::Serialize(ar);
ar & m_Lm & m_Lp;
}
//-----------------------------------------------------------------------------
//! return node set
FENodeSet* FEAzimuthConstraint::GetNodeSet()
{
return &m_nodeSet;
}
//-----------------------------------------------------------------------------
void FEAzimuthConstraint::BuildMatrixProfile(FEGlobalMatrix& M)
{
int N = m_nodeSet.Size();
for (int i = 0; i < N; ++i)
{
vector<int> lm(2);
FENode& n0 = *m_nodeSet.Node(i);
lm[0] = n0.m_ID[m_dofU[0]];
lm[1] = n0.m_ID[m_dofU[1]];
if (m_laugon == FECore::LAGMULT_METHOD)
{
lm.push_back(m_eq[2*i ]);
lm.push_back(m_eq[2*i+1]);
}
M.build_add(lm);
}
}
//-----------------------------------------------------------------------------
//! return number of equations to be allocated for Lagrange multipliers
int FEAzimuthConstraint::InitEquations(int neq)
{
int N = m_nodeSet.Size();
m_Lm.assign(N, vec3d(0, 0, 0));
m_Lp = m_Lm;
// make sure we want to use Lagrange Multiplier method
if (m_laugon != FECore::LAGMULT_METHOD) return 0;
// allocate two equations per node
m_eq.resize(2 * N);
for (int i = 0; i < N; ++i)
{
m_eq[2*i ] = neq++;
m_eq[2*i+1] = neq++;
}
return 2*N;
}
//! Calculate the constraint force
void FEAzimuthConstraint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
int N = m_nodeSet.Size();
for (int i = 0; i < N; ++i)
{
FENode& node = *m_nodeSet.Node(i);
vec3d e0 = node.m_r0; e0.z = 0.0; e0.unit();
vec3d et = node.m_rt; et.z = 0.0; double l = et.unit();
// projection mat3ds
mat3dd I(1.0);
mat3ds P = (I - dyad(et)) / l;
// evaluate constraint
vec3d c = et - e0;
// calculate force
vector<double> F;
vector<int> lm;
if (m_laugon == FECore::LAGMULT_METHOD)
{
// Lagrange multiplier formulation
vec3d Pl = P * m_Lm[i];
F.resize(4);
F[0] = -Pl.x;
F[1] = -Pl.y;
F[2] = -c.x;
F[3] = -c.y;
lm.resize(4);
lm[0] = node.m_ID[m_dofU[0]];
lm[1] = node.m_ID[m_dofU[1]];
lm[2] = m_eq[2*i ];
lm[3] = m_eq[2*i+1];
}
else
{
// Augmented Lagrangian formulation
vec3d lam = m_Lm[i] + c * m_eps;
vec3d Pl = P * lam;
F.resize(2);
F[0] = -Pl.x;
F[1] = -Pl.y;
lm.resize(2);
lm[0] = node.m_ID[m_dofU[0]];
lm[1] = node.m_ID[m_dofU[1]];
}
R.Assemble(lm, F);
}
}
//! calculate the constraint stiffness
void FEAzimuthConstraint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
int N = m_nodeSet.Size();
for (int i = 0; i < N; ++i)
{
FENode* node = m_nodeSet.Node(i); assert(node);
vec3d e0 = node->m_r0; e0.z = 0.0; e0.unit();
vec3d et = node->m_rt; et.z = 0.0; double l = et.unit();
// projection mat3ds
mat3dd I(1.0);
mat3ds P = (I - dyad(et)) / l;
// evaluate constraint
vec3d c = et - e0;
mat3ds Ploe = dyads(P*m_Lm[i], et);
mat3ds Q = (Ploe + P * (et*m_Lm[i])) / (-l);
// stiffness
if (m_laugon == FECore::LAGMULT_METHOD)
{
FEElementMatrix ke(4, 4); ke.zero();
ke[0][0] = Q(0, 0); ke[0][1] = Q(0, 1);
ke[1][0] = Q(1, 0); ke[1][1] = Q(1, 1);
ke[0][2] = P(0, 0); ke[0][3] = P(0, 1);
ke[1][2] = P(1, 0); ke[1][3] = P(1, 1);
ke[2][0] = P(0, 0); ke[3][0] = P(0, 1);
ke[2][1] = P(1, 0); ke[3][1] = P(1, 1);
vector<int> lm(4);
lm[0] = node->m_ID[m_dofU[0]];
lm[1] = node->m_ID[m_dofU[1]];
lm[2] = m_eq[2*i ];
lm[3] = m_eq[2*i+1];
ke.SetIndices(lm);
vector<int> en(1);
en[0] = m_nodeSet[i];
ke.SetNodes(en);
LS.Assemble(ke);
}
else
{
vec3d lam = m_Lm[i] + c * m_eps;
mat3ds K = Q + (P.sqr())*m_eps;
FEElementMatrix ke(2, 2); ke.zero();
ke[0][0] = K(0, 0); ke[0][1] = K(0, 1);
ke[1][0] = K(1, 0); ke[1][1] = K(1, 1);
vector<int> lm(2);
lm[0] = node->m_ID[m_dofU[0]];
lm[1] = node->m_ID[m_dofU[1]];
vector<int> en(1);
en[0] = m_nodeSet[i];
ke.SetIndices(lm);
ke.SetNodes(en);
LS.Assemble(ke);
}
}
}
void FEAzimuthConstraint::PrepStep()
{
m_Lp = m_Lm;
}
void FEAzimuthConstraint::Update(const std::vector<double>& Ui, const std::vector<double>& ui)
{
if (m_laugon == FECore::LAGMULT_METHOD)
{
int N = m_nodeSet.Size();
for (int i = 0; i < N; ++i)
{
m_Lm[i].x = m_Lp[i].x + Ui[m_eq[2*i ]] + ui[m_eq[2*i ]];
m_Lm[i].y = m_Lp[i].y + Ui[m_eq[2*i+1]] + ui[m_eq[2*i+1]];
}
}
}
void FEAzimuthConstraint::UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui)
{
if (m_laugon == FECore::LAGMULT_METHOD)
{
int N = m_nodeSet.Size();
for (int i = 0; i < N; ++i)
{
Ui[m_eq[2*i ]] += ui[m_eq[2*i ]];
Ui[m_eq[2*i+1]] += ui[m_eq[2*i+1]];
}
}
}
//! augmentations
bool FEAzimuthConstraint::Augment(int naug, const FETimeInfo& tp)
{
bool bconv = true;
int N = m_nodeSet.Size();
for (int i = 0; i < N; ++i)
{
FENode& node = *m_nodeSet.Node(i);
int nodeId = node.GetID();
vec3d e0 = node.m_r0; e0.z = 0.0; e0.unit();
vec3d et = node.m_rt; et.z = 0.0; double l = et.unit();
// projection mat3ds
mat3dd I(1.0);
mat3ds P = (I - dyad(et)) / l;
// Lagrange multiplier
vec3d c = et - e0;
vec3d lam1 = m_Lm[i] + c * m_eps;
double g = c.norm();
double L0 = m_Lm[i].norm();
double L1 = lam1.norm();
if (m_laugon == FECore::PENALTY_METHOD)
{
// penalty-formulation
feLog("\t%d: %lg, %lg\n", nodeId, g, L1);
}
else if (m_laugon == FECore::LAGMULT_METHOD)
{
// Lagrange multiplier
feLog("\t%d: %lg, %lg\n", nodeId, g, L0);
}
else
{
// aug-lag constraint
bool bconvi = true;
if (m_Lm[i].norm() == 0.0)
{
feLog("\t%d: %lg, %lg\n", nodeId, g, L1);
bconvi = (L1 == 0.0);
}
else
{
double dl = fabs((L1 - L0) / L1);
feLog("\t%d: %lg, %lg (%lg)\n", nodeId, g, L1, dl);
if (dl >= m_tol)
{
bconvi = false;
}
}
// check augmentation range
naug++;
if ((m_minaug > 0) && (naug < m_minaug)) bconvi = false;
if ((m_maxaug > 0) && (naug >= m_maxaug)) bconvi = true;
// update LM if not converged
if (bconvi == false)
{
m_Lm[i] = lam1;
}
bconv = bconv & bconvi;
}
}
return bconv;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEContactGapCriterion.h | .h | 1,568 | 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) 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/FEMeshAdaptorCriterion.h>
class FEContactGapCriterion : public FEMeshAdaptorCriterion
{
public:
FEContactGapCriterion(FEModel* fem);
FEMeshAdaptorSelection GetElementSelection(FEElementSet* elset) override;
private:
double m_gap;
DECLARE_FECORE_CLASS()
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FETorsionalSpring.h | .h | 1,871 | 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 "FEDiscreteElasticMaterial.h"
#include "febiomech_api.h"
class FEBIOMECH_API FETorsionalSpring : public FEDiscreteElasticMaterial
{
public:
FETorsionalSpring(FEModel* fem);
// evaluate the force at a discrete element
vec3d Force(FEDiscreteMaterialPoint& mp) override;
// evaluate the stiffness at a discrete element (= dF / dr)
mat3d Stiffness(FEDiscreteMaterialPoint& mp) override;
// evaluate the force at a discrete element
double StrainEnergy(FEDiscreteMaterialPoint& mp) override;
private:
double m_r; //!< rotational stiffness
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationGauss.cpp | .cpp | 7,254 | 299 | /*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 "FEFiberIntegrationGauss.h"
#include "gauss.h"
#include <FECore/log.h>
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
class FEFiberIntegrationGauss::Iterator : public FEFiberIntegrationSchemeIterator
{
public:
Iterator(FEMaterialPoint* mp, FEFiberIntegrationGauss::GRULE& rule)
{
m_ncase = -1;
m_nth = rule.m_nth;
m_nph = rule.m_nph;
m_gp = rule.m_gp;
m_gw = rule.m_gw;
const double eps = 1e-9;
if (mp)
{
FEElasticMaterialPoint& pt = *mp->ExtractData<FEElasticMaterialPoint>();
// right Cauchy-Green tensor and its eigenvalues & eigenvectors
mat3ds C = (pt.m_buncoupled ? pt.DevRightCauchyGreen() : pt.RightCauchyGreen());
C.eigen(lC, vC);
// check if there is no tension
if ((lC[0] <= 1 + eps) && (lC[1] <= 1 + eps) && (lC[2] <= 1 + eps)) {
return;
}
// bubble sort eigenvalues & eigenvectors from smallest to largest
double ltmp;
vec3d vtmp;
bool swp = true;
while (swp) {
swp = false;
for (int i = 1; i<3; ++i) {
int j = i - 1;
if (lC[i] < lC[j]) {
ltmp = lC[i]; vtmp = vC[i];
lC[i] = lC[j]; vC[i] = vC[j];
lC[j] = ltmp; vC[j] = vtmp;
swp = true;
}
}
}
// check the other case
if (lC[0] > 1 + eps) m_ncase = 0;
else if (lC[1] <= 1 + eps) m_ncase = 1;
else m_ncase = 2;
}
else
{
m_ncase = 0;
vC[0] = vec3d(1,0,0);
vC[1] = vec3d(0,1,0);
vC[2] = vec3d(0,0,1);
}
// check remaining stretch states
double pi = 4 * atan(1.0);
dth = 2 * pi / m_nth;
vec3d n0e, n0a;
// tension along all three eigenvectors (all directions)
if (m_ncase == 0)
{
ksia = 0;
ksib = 1;
dksi = (ksib - ksia) / 2;
sksi = (ksib + ksia) / 2;
}
// tension along one eigenvector and compression along other two
else if (m_ncase == 1)
{
// nothing to do
// ksia and ksib are update in FiberVector
}
// tension along two eigenvectors and compression along third
else
{
// swap first and last eigenvalues/eigenvectors to maintain consistency in formulas
double ltmp = lC[2]; vec3d vtmp = vC[2];
lC[2] = lC[0]; vC[2] = vC[0];
lC[0] = ltmp; vC[0] = vtmp;
}
i = 0; j = -1;
i_old = -1;
cth = 1.0; sth = 0.0;
Next();
}
bool IsValid()
{
return (m_ncase != -1);
}
// move to the next integration point
bool Next()
{
// make sure the iterator is valid
if (m_ncase == -1) return false;
// update loop counters
j++;
if (j >= m_nph)
{
j = 0;
i++;
if (i >= m_nth)
{
// all done
m_ncase = -1;
return false;
}
}
// update vector
if (i_old != i)
{
double theta = i*dth;
cth = cos(theta);
sth = sin(theta);
if (m_ncase == 1)
{
ksia = sqrt(1 - lC[0] * SQR(cth) - lC[1] * SQR(sth)) / sqrt(lC[2] - lC[0] * SQR(cth) - lC[1] * SQR(sth));
ksib = 1;
dksi = (ksib - ksia) / 2;
sksi = (ksib + ksia) / 2;
}
else if (m_ncase == 2)
{
ksia = 0;
ksib = sqrt(lC[0] * SQR(cth) + lC[1] * SQR(sth) - 1) / sqrt(lC[0] * SQR(cth) + lC[1] * SQR(sth) - lC[2]);
dksi = (ksib - ksia) / 2;
sksi = (ksib + ksia) / 2;
}
}
double ksi = sksi + dksi*m_gp[j];
double sph = sqrt(1.0 - ksi*ksi); // = sin(acos(ksi));
m_fiber = vC[0] * (cth*sph) + vC[1] * (sth*sph) + vC[2] * ksi;
// we multiply by two to add contribution from other half-sphere
m_weight = (m_gw[j] * dth*dksi)*2.0;
i_old = i;
return true;
}
public:
int m_ncase;
double lC[3];
vec3d vC[3];
int m_nth, m_nph;
const double* m_gp;
const double* m_gw;
int i, j, i_old;
double ksia, ksib, dksi, sksi;
double dth;
double cth, sth;
};
//-----------------------------------------------------------------------------
// FEFiberIntegrationGauss
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberIntegrationGauss, FEFiberIntegrationScheme)
ADD_PARAMETER(m_rule.m_nph, FE_RANGE_GREATER(0), "nph");
ADD_PARAMETER(m_rule.m_nth, FE_RANGE_GREATER(0), "nth");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
void FEFiberIntegrationGauss::Serialize(DumpStream& ar)
{
FEFiberIntegrationScheme::Serialize(ar);
if ((ar.IsSaving() == false) && (ar.IsShallow() == false))
{
InitRule();
}
}
//-----------------------------------------------------------------------------
bool FEFiberIntegrationGauss::InitRule()
{
switch (m_rule.m_nph) {
case 1:
m_rule.m_gp = gp1;
m_rule.m_gw = gw1;
break;
case 2:
m_rule.m_gp = gp2;
m_rule.m_gw = gw2;
break;
case 3:
m_rule.m_gp = gp3;
m_rule.m_gw = gw3;
break;
case 4:
m_rule.m_gp = gp4;
m_rule.m_gw = gw4;
break;
case 5:
m_rule.m_gp = gp5;
m_rule.m_gw = gw5;
break;
case 6:
m_rule.m_gp = gp6;
m_rule.m_gw = gw6;
break;
case 7:
m_rule.m_gp = gp7;
m_rule.m_gw = gw7;
break;
case 8:
m_rule.m_gp = gp8;
m_rule.m_gw = gw8;
break;
case 9:
m_rule.m_gp = gp9;
m_rule.m_gw = gw9;
break;
case 10:
m_rule.m_gp = gp10;
m_rule.m_gw = gw10;
break;
default:
return false;
break;
}
return true;
}
FEFiberIntegrationGauss::FEFiberIntegrationGauss(FEModel* pfem) : FEFiberIntegrationScheme(pfem)
{
m_rule.m_nph = 5;
m_rule.m_nth = 2 * m_rule.m_nph;
}
FEFiberIntegrationGauss::~FEFiberIntegrationGauss()
{
}
bool FEFiberIntegrationGauss::Init()
{
if (InitRule() == false) {
feLogError("nint must not exceed 10."); return false;
}
// also initialize the parent class
return FEFiberIntegrationScheme::Init();
}
//-----------------------------------------------------------------------------
FEFiberIntegrationSchemeIterator* FEFiberIntegrationGauss::GetIterator(FEMaterialPoint* mp)
{
return new Iterator(mp, m_rule);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FESlideLineConstraint.h | .h | 4,187 | 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.*/
#pragma once
#include <FECore/FENLConstraint.h>
#include <FECore/FEEdge.h>
#include "febiomech_api.h"
class FEBIOMECH_API FESlideLine : public FEEdge
{
public:
class FESlidingPoint
{
public:
FESlidingPoint();
void Serialize(DumpStream& ar);
void Init();
public:
FELineElement* pme = nullptr;
double gap = 0;
vec3d nu;
double r = 0; //!< natural coordinates of primary surface projection on secondary surface element
double Ln = 0; //!< contact pressure
double Lm = 0; //!< Lagrange multipliers for contact pressure
};
public:
struct Projection
{
FELineElement* pe = nullptr;
vec3d q;
double r = 0;
};
public:
//! constructor
FESlideLine(FEModel* pfem);
//! Initializes data structures
bool Init();
FEMaterialPoint* CreateMaterialPoint() override;
//! Serialize data to archive
void Serialize(DumpStream& ar);
Projection ClosestProjection(const vec3d& x);
public:
vector<FESlidingPoint> m_data; //!< sliding contact surface data
};
class FEBIOMECH_API FESlideLineConstraint : public FENLConstraint
{
public:
//! constructor
FESlideLineConstraint(FEModel* pfem);
//! Initializes sliding interface
bool Init() override;
//! interface activation
void Activate() override;
//! projects primary line nodes onto secondary line nodes
void ProjectPoints(bool bupseg);
//! 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();
//! 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 the nodal force of a primary surface node
void ContactNodalForce(int m, FELineElement& mel, vector<double>& fe);
//! calculate the stiffness contribution of a single primary surface node
void ContactNodalStiffness(int m, FELineElement& mel, matrix& ke);
private:
void SerializePointers(DumpStream& ar);
public:
int m_laugon;
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_eps; //!< penalty scale factor
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
private:
FESlideLine pl; // primary line
FESlideLine sl; // secondary line
public:
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberDensityDistribution.cpp | .cpp | 5,668 | 150 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FEFiberDensityDistribution.h"
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
//-----------------------------------------------------------------------------
// define the ellipsoidal fiber density distributionmaterial parameters
BEGIN_FECORE_CLASS(FEEllipsoidalFiberDensityDistribution, FEFiberDensityDistribution)
ADD_PARAMETER(m_spa, 3, FE_RANGE_GREATER_OR_EQUAL(0.0), "spa");
END_FECORE_CLASS();
FEEllipsoidalFiberDensityDistribution::FEEllipsoidalFiberDensityDistribution(FEModel* pfem) : FEFiberDensityDistribution(pfem)
{
m_spa[0] = 1;
m_spa[1] = 1;
m_spa[2] = 1;
}
double FEEllipsoidalFiberDensityDistribution::FiberDensity(FEMaterialPoint& mp, const vec3d& n0)
{
double a0 = m_spa[0](mp);
double a1 = m_spa[1](mp);
double a2 = m_spa[2](mp);
double R = 1.0/sqrt(SQR(n0.x/a0)+SQR(n0.y/a1)+SQR(n0.z/a2));
return R;
}
//-----------------------------------------------------------------------------
// define the 3d von Mises fiber density distribution material parameters
BEGIN_FECORE_CLASS(FEVonMises3DFiberDensityDistribution, FEFiberDensityDistribution)
ADD_PARAMETER(m_b, FE_RANGE_GREATER_OR_EQUAL(0.0), "b" )->setLongName("concentration");
END_FECORE_CLASS();
double FEVonMises3DFiberDensityDistribution::FiberDensity(FEMaterialPoint& mp, const vec3d& n0)
{
// The local x-direction is the principal fiber bundle direction
// The x-component of n0 is cos(phi)
double b = m_b(mp);
double R = exp(b*(2*SQR(n0.x)-1));
return R;
}
//-----------------------------------------------------------------------------
// define the 3d 2-fiber family axisymmetric von Mises fiber density distribution material parameters
BEGIN_FECORE_CLASS(FEVonMises3DTwoFDDAxisymmetric, FEFiberDensityDistribution)
ADD_PARAMETER(m_b, FE_RANGE_GREATER_OR_EQUAL(0.0), "b" );
ADD_PARAMETER(m_c, FE_RANGE_CLOSED(0, 1), "cosg" );
END_FECORE_CLASS();
FEVonMises3DTwoFDDAxisymmetric::FEVonMises3DTwoFDDAxisymmetric(FEModel* pfem) : FEFiberDensityDistribution(pfem)
{
m_b = 0;
m_c = 1;
}
double FEVonMises3DTwoFDDAxisymmetric::FiberDensity(FEMaterialPoint& mp, const vec3d& n0)
{
double b = m_b(mp);
double c = m_c(mp);
// The local x-direction is the principal fiber bundle direction
// The x-component of n0 is cos(phi)
double cphi = n0.x; double sphi = sqrt(1-cphi*cphi);
double sing = sqrt(1-c*c);
double cp = cphi*c - sphi*sing;
double cm = cphi*c + sphi*sing;
double R = exp(b*(2*SQR(cp)-1)) + exp(b*(2*SQR(cm)-1));
return R;
}
//-----------------------------------------------------------------------------
// define the ellipsoidal fiber density distributionmaterial parameters
BEGIN_FECORE_CLASS(FEEllipticalFiberDensityDistribution, FEFiberDensityDistribution)
ADD_PARAMETER(m_spa[0], FE_RANGE_GREATER_OR_EQUAL(0.0), "spa1" );
ADD_PARAMETER(m_spa[1], FE_RANGE_GREATER_OR_EQUAL(0.0), "spa2" );
END_FECORE_CLASS();
double FEEllipticalFiberDensityDistribution::FiberDensity(FEMaterialPoint& mp, const vec3d& n0)
{
// 2d fibers lie in the local x-y plane
// n0.x = cos(theta) and n0.y = sin(theta)
double a0 = m_spa[0](mp);
double a1 = m_spa[1](mp);
double R = 1.0/sqrt(SQR(n0.x/a0)+SQR(n0.y/a1));
return R;
}
//-----------------------------------------------------------------------------
// define the 2d von Mises fiber density distribution material parameters
BEGIN_FECORE_CLASS(FEVonMises2DFiberDensityDistribution, FEFiberDensityDistribution)
ADD_PARAMETER(m_b, FE_RANGE_GREATER_OR_EQUAL(0.0), "b" )->setLongName("concentration");
END_FECORE_CLASS();
double FEVonMises2DFiberDensityDistribution::FiberDensity(FEMaterialPoint& mp, const vec3d& n0)
{
// The fiber bundle is in the x-y plane and
// the local x-direction is the principal fiber bundle direction
// The x-component of n0 is cos(theta)
double b = m_b(mp);
double R = exp(b*(2*SQR(n0.x)-1));
return R;
}
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEStructureTensorDistribution, FEFiberDensityDistribution)
ADD_PARAMETER(m_SPD, "spd");
END_FECORE_CLASS();
FEStructureTensorDistribution::FEStructureTensorDistribution(FEModel* fem) : FEFiberDensityDistribution(fem)
{
m_SPD = mat3dd(1.0);
}
double FEStructureTensorDistribution::FiberDensity(FEMaterialPoint& mp, const vec3d& n0)
{
return n0 * (m_SPD(mp)*n0);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidForce.h | .h | 4,615 | 167 | /*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/FEModelLoad.h"
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
class FEBIOMECH_API FERigidLoad : public FEModelLoad
{
public:
FERigidLoad(FEModel* fem) : FEModelLoad(fem) {}
FECORE_BASE_CLASS(FERigidLoad)
};
//-----------------------------------------------------------------------------
//! an axial force between two rigid bodies
class FEBIOMECH_API FERigidAxialForce : public FERigidLoad
{
public:
//! constructor
FERigidAxialForce(FEModel* pfem);
//! initialization
bool Init() override;
//! Serialization
void Serialize(DumpStream& ar) override;
//! Residual
void LoadVector(FEGlobalVector& R) override;
//! Stiffness matrix
void StiffnessMatrix(FELinearSystem& LS) override;
public:
int m_ida, m_idb; //!< rigid body ID's
vec3d m_ra0, m_rb0; //!< coordinates of attachements in reference state
double m_s; //!< scale factor
bool m_brelative; //!< if active, the ra0 and rb0 are relative w.r.t. the COM
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
//! rigid body force
//! TODO: I'd like to split this class into two classes: one handling the case
//! were the force is const, and one where the force is a follower force.
//! Perhaps I can derive the const force from FENodalLoad since it applies
//! a force directly to the rigid "node".
class FEBIOMECH_API FERigidBodyForce : public FERigidLoad
{
public:
enum { FORCE_LOAD, FORCE_FOLLOW, FORCE_TARGET }; // values for m_ntype
public:
FERigidBodyForce(FEModel* pfem);
//! Activation
void Activate() override;
//! initialization
bool Init() override;
//! Serialization
void Serialize(DumpStream& ar) override;
//! forces
void LoadVector(FEGlobalVector& R) override;
//! Stiffness matrix
void StiffnessMatrix(FELinearSystem& LS) override;
public:
void SetRigidMaterialID(int nid);
void SetDOF(int bc);
void SetLoadType(int loadType);
void SetForce(double f);
private:
int m_rigidMat; //!< rigid body material id
int m_dof; //!< force direction
bool m_brelative; //!< relative flag
int m_ntype; //!< type of force
double m_force; //!< applied force
double m_force0; //!< initial force at activation
int m_rid;
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
//! rigid body moment
class FEBIOMECH_API FERigidBodyMoment : public FERigidLoad
{
public:
enum { MOMENT_LOAD, MOMENT_FOLLOW, MOMENT_TARGET }; // values for m_ntype
public:
FERigidBodyMoment(FEModel* pfem);
//! Activation
void Activate() override;
//! initialization
bool Init() override;
//! Serialization
void Serialize(DumpStream& ar) override;
//! forces
void LoadVector(FEGlobalVector& R) override;
//! Stiffness matrix
void StiffnessMatrix(FELinearSystem& LS) override;
public:
void SetRigidMaterialID(int nid);
void SetDOF(int bc);
void SetValue(double f);
private:
int m_rigidMat; //!< rigid body material id
int m_dof; //!< force direction
bool m_brelative; //!< relative flag
double m_value; //!< applied moment
int m_ntype; //!< type of moment
double m_value0; //!< initial moment at activation (used with brelative flag)
int m_rid;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFungOrthoCompressible.cpp | .cpp | 8,318 | 255 | /*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 "FEFungOrthoCompressible.h"
#include <FECore/log.h>
// define the material parameters
BEGIN_FECORE_CLASS(FEFungOrthoCompressible, FEElasticMaterial)
ADD_PARAMETER(E1, FE_RANGE_GREATER(0.0), "E1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(E2, FE_RANGE_GREATER(0.0), "E2")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(E3, FE_RANGE_GREATER(0.0), "E3")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(G12, "G12")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(G23, "G23")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(G31, "G31")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(v12, "v12");
ADD_PARAMETER(v23, "v23");
ADD_PARAMETER(v31, "v31");
ADD_PARAMETER(m_c, FE_RANGE_GREATER(0.0),"c")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_k, FE_RANGE_GREATER(0.0), "k")->setUnits(UNIT_PRESSURE);
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Data initialization
bool FEFungOrthoCompressible::Validate()
{
if (FEElasticMaterial::Validate() == false) return false;
if (v12 > sqrt(E1/E2)) { feLogError("Invalid value for v12. Let v12 > sqrt(E1/E2)"); return false; }
if (v23 > sqrt(E2/E3)) { feLogError("Invalid value for v23. Let v23 > sqrt(E2/E3)"); return false; }
if (v31 > sqrt(E3/E1)) { feLogError("Invalid value for v31. Let v31 > sqrt(E3/E1)"); return false; }
// Evaluate Lame coefficients
mu[0] = G12 + G31 - G23;
mu[1] = G12 - G31 + G23;
mu[2] =-G12 + G31 + G23;
lam[0][0] = 1.0/E1; lam[0][1] = -v12/E1; lam[0][2] = -v31/E3;
lam[1][0] = -v12/E1; lam[1][1] = 1.0/E2; lam[1][2] = -v23/E2;
lam[2][0] = -v31/E3; lam[2][1] = -v23/E2; lam[2][2] = 1.0/E3;
mat3d c(lam);
c = c.inverse();
lam[0][0] = c[0][0] - 2*mu[0];
lam[1][1] = c[1][1] - 2*mu[1];
lam[2][2] = c[2][2] - 2*mu[2];
lam[1][2] = c[1][2]; lam[2][1] = c[2][1];
lam[2][0] = c[2][0]; lam[0][2] = c[0][2];
lam[0][1] = c[0][1]; lam[1][0] = c[1][0];
return true;
}
//-----------------------------------------------------------------------------
//! Calculates the stress
mat3ds FEFungOrthoCompressible::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
int i,j;
vec3d a0[3]; // texture direction in reference configuration
vec3d a[3]; // texture direction in current configuration
mat3ds A[3]; // texture tensor in current configuration
double K[3]; // Ka
double L[3]; // La
double eQ; // exp(Q)
mat3ds bmi; // B - I
// Evaluate the deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// calculate left and right Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
mat3ds c = pt.RightCauchyGreen();
mat3ds c2 = c.sqr();
mat3dd I(1.);
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
for (i=0; i<3; i++) { // Perform sum over all three texture directions
// Copy the texture direction in the reference configuration to a0
a0[i].x = Q[0][i]; a0[i].y = Q[1][i]; a0[i].z = Q[2][i];
K[i] = a0[i]*(c*a0[i]);
L[i] = a0[i]*(c2*a0[i]);
a[i] = F*a0[i]/sqrt(K[i]); // Evaluate the texture direction in the current configuration
A[i] = dyad(a[i]); // Evaluate the texture tensor in the current configuration
}
// Evaluate exp(Q)
eQ = 0;
for (i=0; i<3; i++) {
eQ += 2*mu[i]*(L[i]-2*K[i]+1);
for (j=0; j<3; j++)
eQ += lam[i][j]*(K[i]-1)*(K[j]-1);
}
eQ = exp(eQ/(4.*m_c));
// Evaluate the stress
mat3ds s;
s.zero(); // Initialize for summation
bmi = b - I;
for (i=0; i<3; i++) {
s += (A[i]*bmi).sym()*(2.0*mu[i] * K[i]);
for (j=0; j<3; j++)
s += lam[i][j]*((K[i]-1)*K[j]*A[j]+(K[j]-1)*K[i]*A[i])/2.;
}
s *= eQ/(2.0*J);
s += I*(m_k*log(J)/J);
return s;
}
//-----------------------------------------------------------------------------
//! Calculates the tangent
tens4ds FEFungOrthoCompressible::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
int i,j;
vec3d a0[3]; // texture direction in reference configuration
vec3d a[3]; // texture direction in current configuration
mat3ds A[3]; // texture tensor in current configuration
double K[3]; // Ka
double L[3]; // La
double eQ; // exp(Q)
mat3ds bmi; // B - I
// Evaluate the strain and texture
mat3d &F = pt.m_F;
double J = pt.m_J;
// calculate left and right Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
mat3ds c = pt.RightCauchyGreen();
mat3ds c2 = c.sqr();
mat3dd I(1.);
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
for (i=0; i<3; i++) { // Perform sum over all three texture directions
// Copy the texture direction in the reference configuration to a0
a0[i].x = Q[0][i]; a0[i].y = Q[1][i]; a0[i].z = Q[2][i];
K[i] = a0[i]*(c*a0[i]);
L[i] = a0[i]*(c2*a0[i]);
a[i] = F*a0[i]/sqrt(K[i]); // Evaluate the texture direction in the current configuration
A[i] = dyad(a[i]); // Evaluate the texture tensor in the current configuration
}
// Evaluate exp(Q)
eQ = 0;
for (i=0; i<3; i++) {
eQ += 2*mu[i]*(L[i]-2*K[i]+1);
for (j=0; j<3; j++)
eQ += lam[i][j]*(K[i]-1)*(K[j]-1);
}
eQ = exp(eQ/(4.*m_c));
// Evaluate the Cauchy stress
mat3ds s;
s.zero(); // Initialize for summation
// tens4ds C;
// C.zero();
tens4ds C(0.0);
bmi = b - I;
for (i=0; i<3; i++) {
s += (A[i]*bmi).sym()*(2.0*mu[i] * K[i]);
for (j=0; j<3; j++)
s += lam[i][j]*((K[i]-1)*K[j]*A[j]+(K[j]-1)*K[i]*A[i])/2.;
C += mu[i]*K[i]*dyad4s(A[i],b);
for (j=0; j<3; j++)
C += lam[i][j]*K[i]*K[j]*dyad1s(A[i],A[j])/2.;
}
s *= eQ/(2.0*J);
// Elasticity tensor
C = (eQ/J)*C + (2*J/m_c/eQ)*dyad1s(s);
C += (dyad1s(I) - dyad4s(I)*(2*log(J)))*(m_k/J);
return C;
}
//-----------------------------------------------------------------------------
//! Calculates the strain energy density
double FEFungOrthoCompressible::StrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
int i,j;
vec3d a0[3]; // texture direction in reference configuration
mat3ds A0[3]; // texture tensor in current configuration
double eQ = 0.0; // exp(Q)
double AE[3], AE2[3];
double J = pt.m_J;
double lnJ = log(J);
// calculate right Cauchy-Green tensor and Lagrange strain tensor
mat3ds C = pt.RightCauchyGreen();
mat3dd I(1.);
mat3ds E = (C - I)*0.5;
mat3ds E2 = E.sqr();
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
for (i=0; i<3; i++) { // Perform sum over all three texture directions
// Copy the texture direction in the reference configuration to a0
a0[i].x = Q[0][i]; a0[i].y = Q[1][i]; a0[i].z = Q[2][i];
A0[i] = dyad(a0[i]); // Evaluate the texture tensor in the reference configuration
AE[i] = A0[i].dotdot(E);
AE2[i] = A0[i].dotdot(E2);
}
// Evaluate exp(Q)
for (i=0; i<3; i++) {
eQ += 2*mu[i]*AE2[i];
for (j=0; j<3; j++)
eQ += lam[i][j]*AE[i]*AE[j];
}
eQ = exp(eQ/m_c);
// Evaluate the strain energy density
double sed = 0.5*(m_c*(eQ-1) + m_k*lnJ*lnJ);
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/gauss.h | .h | 4,643 | 202 | /*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
// gaussian quadrature
const int nint1 = 1;
const double gp1[nint1] = {
0
};
const double gw1[nint1] = {
2
};
const int nint2 = 2;
const double gp2[nint2] = {
-sqrt(3.)/3.,
sqrt(3.)/3.
};
const double gw2[nint2] = {
1,
1
};
const int nint3 = 3;
const double gp3[nint3] = {
-sqrt(3./5.),
0.,
sqrt(3./5.)
};
const double gw3[nint3] = {
5./9.,
8./9.,
5./9.
};
const int nint4 = 4;
const double gp4[nint4] = {
-sqrt((3+2*sqrt(6./5.))/7.),
-sqrt((3-2*sqrt(6./5.))/7.),
sqrt((3-2*sqrt(6./5.))/7.),
sqrt((3+2*sqrt(6./5.))/7.)
};
const double gw4[nint4] = {
(18-sqrt(30.))/36.,
(18+sqrt(30.))/36.,
(18+sqrt(30.))/36.,
(18-sqrt(30.))/36.
};
const int nint5 = 5;
const double gp5[nint5] = {
-1./3.*sqrt(5+2*sqrt(10./7.)),
-1./3.*sqrt(5-2*sqrt(10./7.)),
0.,
1./3.*sqrt(5-2*sqrt(10./7.)),
1./3.*sqrt(5+2*sqrt(10./7.))
};
const double gw5[nint5] = {
(322-13*sqrt(70.))/900.,
(322+13*sqrt(70.))/900.,
128./225.,
(322+13*sqrt(70.))/900.,
(322-13*sqrt(70.))/900.
};
const int nint6 = 6;
const double gp6[nint6] = {
0.661209386466264,
-0.661209386466264,
-0.238619186083196,
0.238619186083196,
-0.932469514203152,
0.932469514203152
};
const double gw6[nint6] = {
0.360761573048138,
0.360761573048138,
0.467913934572691,
0.467913934572691,
0.171324492379170,
0.171324492379170
};
const int nint7 = 7;
const double gp7[nint7] = {
0.000000000000000,
0.405845151377397,
-0.405845151377397,
-0.741531185599394,
0.741531185599394,
-0.949107912342758,
0.949107912342758
};
const double gw7[nint7] = {
0.417959183673469,
0.381830050505118,
0.381830050505118,
0.279705391489276,
0.279705391489276,
0.129484966168869,
0.129484966168869
};
const int nint8 = 8;
const double gp8[nint8] = {
-0.183434642495649,
0.183434642495649,
-0.525532409916329,
0.525532409916329,
-0.796666477413626,
0.796666477413626,
-0.960289856497536,
0.960289856497536
};
const double gw8[nint8] = {
0.362683783378362,
0.362683783378362,
0.313706645877887,
0.313706645877887,
0.222381034453374,
0.222381034453374,
0.101228536290376,
0.101228536290376
};
const int nint9 = 9;
const double gp9[nint9] = {
0.000000000000000,
-0.836031107326635,
0.836031107326635,
-0.968160239507626,
0.968160239507626,
-0.324253423403808,
0.324253423403808,
-0.613371432700590,
0.613371432700590
};
const double gw9[nint9] = {
0.330239355001259,
0.180648160694857,
0.180648160694857,
0.081274388361574,
0.081274388361574,
0.312347077040002,
0.312347077040002,
0.260610696402935,
0.260610696402935
};
const int nint10 = 10;
const double gp10[nint10] = {
-0.148874338981631,
0.148874338981631,
-0.433395394129247,
0.433395394129247,
-0.679409568299024,
0.679409568299024,
-0.865063366688984,
0.865063366688984,
-0.973906528517171,
0.973906528517171
};
const double gw10[nint10] = {
0.295524224714752,
0.295524224714752,
0.269266719309996,
0.269266719309996,
0.219086362515982,
0.219086362515982,
0.149451349150580,
0.149451349150580,
0.0666713443086881,
0.0666713443086881
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedActiveContractionUniaxialUC.cpp | .cpp | 4,726 | 146 | /*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 "FEPrescribedActiveContractionUniaxialUC.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEPrescribedActiveContractionUniaxialUC, FEUncoupledMaterial)
ADD_PARAMETER(m_T0 , "T0" );
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPrescribedActiveContractionUniaxialUC::FEPrescribedActiveContractionUniaxialUC(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_T0 = 0.0;
}
//-----------------------------------------------------------------------------
bool FEPrescribedActiveContractionUniaxialUC::Validate()
{
if (FEUncoupledMaterial::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 FEPrescribedActiveContractionUniaxialUC::Serialize(DumpStream& ar)
{
FEUncoupledMaterial::Serialize(ar);
if (ar.IsShallow()) return;
ar & m_n0;
}
//-----------------------------------------------------------------------------
mat3ds FEPrescribedActiveContractionUniaxialUC::DevStress(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
double J = pt.m_J;
mat3d F = pt.m_F;
// 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 FEPrescribedActiveContractionUniaxialUC::DevTangent(FEMaterialPoint &mp)
{
return tens4ds(0.0);
}
//=============================================================================
// define the material parameters
BEGIN_FECORE_CLASS(FEPrescribedActiveContractionFiberUC, FEUncoupledMaterial)
ADD_PARAMETER(m_T0 , "T0" );
ADD_PARAMETER(m_n0 , "fiber" );
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPrescribedActiveContractionFiberUC::FEPrescribedActiveContractionFiberUC(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_T0 = 0.0;
m_n0 = vec3d(1, 0, 0);
}
//-----------------------------------------------------------------------------
mat3ds FEPrescribedActiveContractionFiberUC::DevStress(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
double J = pt.m_J;
mat3d F = pt.m_F;
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// evaluate fiber direction in global coordinate system
vec3d n0 = Q*m_n0.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 FEPrescribedActiveContractionFiberUC::DevTangent(FEMaterialPoint &mp)
{
return tens4ds(0.0);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberMaterial.h | .h | 2,334 | 63 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FEMaterial.h>
#include "febiomech_api.h"
#include <FECore/tens4d.h>
class FEBIOMECH_API FEFiberMaterial : public FEMaterialProperty
{
FECORE_BASE_CLASS(FEFiberMaterial);
public:
FEFiberMaterial(FEModel* fem);
FEMaterialPointData* CreateMaterialPointData();
virtual mat3ds FiberStress(FEMaterialPoint& mp, const vec3d& fiber) = 0;
virtual tens4ds FiberTangent(FEMaterialPoint& mp, const vec3d& fiber) = 0;
virtual double FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& fiber) = 0;
};
// fiber materials for use in uncoupled materials
class FEBIOMECH_API FEFiberMaterialUncoupled : public FEMaterialProperty
{
FECORE_BASE_CLASS(FEFiberMaterialUncoupled);
public:
FEFiberMaterialUncoupled(FEModel* fem);
FEMaterialPointData* CreateMaterialPointData();
virtual mat3ds DevFiberStress(FEMaterialPoint& mp, const vec3d& fiber) = 0;
virtual tens4ds DevFiberTangent(FEMaterialPoint& mp, const vec3d& fiber) = 0;
virtual double DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& fiber) = 0;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEBondRelaxation.cpp | .cpp | 29,822 | 824 | /*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 "FEBondRelaxation.h"
#include "FEElasticMaterial.h"
#include <FECore/log.h>
#include <FECore/expint_Ei.h>
#include <FECore/gamma.h>
#include <FECore/besselIK.h>
#include <math.h>
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationExponential
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationExponential, FEBondRelaxation)
ADD_PARAMETER(m_tau, FE_RANGE_GREATER(0.0), "tau")->setLongName("time constant")->setUnits(UNIT_TIME);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationExponential::FEBondRelaxationExponential(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau = 0;
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationExponential::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double tau = m_tau(mp);
// --- constant relaxation times ---
double g = exp(-t/tau);
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationExpDistortion
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationExpDistortion, FEBondRelaxation)
ADD_PARAMETER(m_tau0 , FE_RANGE_GREATER (0.0), "tau0" )->setLongName("constant coefficient")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_tau1 , FE_RANGE_GREATER_OR_EQUAL(0.0), "tau1" )->setLongName("power coefficient")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_alpha, FE_RANGE_GREATER_OR_EQUAL(0.0), "alpha")->setLongName("power exponent");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationExpDistortion::FEBondRelaxationExpDistortion(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau0 = 0;
m_tau1 = 0;
m_alpha = 1;
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationExpDistortion::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double alpha = m_alpha(mp);
double tau0 = m_tau0(mp);
double tau1 = m_tau1(mp);
// get the elastic material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = pt.LeftHencky();
// evaluate distortion magnitude (always positive)
double K2 = (h.dev()).norm();
double K2a = pow(K2,alpha);
double tau = tau0 + tau1*K2a;
double g = exp(-t/tau);
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationExpDistUser
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationExpDistUser, FEBondRelaxation)
ADD_PROPERTY(m_tau , "tau");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationExpDistUser::FEBondRelaxationExpDistUser(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau = nullptr;
}
//-----------------------------------------------------------------------------
//! performs initialization
bool FEBondRelaxationExpDistUser::Init()
{
if (!m_tau->Init()) return false;
return FEBondRelaxation::Init();
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationExpDistUser::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
// get the elastic material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = pt.LeftHencky();
// evaluate distortion magnitude (always positive)
double K2 = (h.dev()).norm();
double tau = m_tau->value(K2);
double g = exp(-t/tau);
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationFung
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationFung, FEBondRelaxation)
ADD_PARAMETER(m_tau1, FE_RANGE_GREATER(0.0), "tau1")->setLongName("min. relaxation time")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_tau2, FE_RANGE_GREATER(0.0), "tau2")->setLongName("max. relaxation time")->setUnits(UNIT_TIME);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationFung::FEBondRelaxationFung(FEModel* pfem) : FEBondRelaxation(pfem)
{
}
//-----------------------------------------------------------------------------
//! Initialization.
bool FEBondRelaxationFung::Validate()
{
if (FEBondRelaxation::Validate() == false) return false;
// if (m_tau2 <= m_tau1) { feLogError("tau2 must be > tau1"); return false; }
return true;
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationFung::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double tau1 = m_tau1(mp);
double tau2 = m_tau2(mp);
double g = 0;
if (t > 0) {
g = (tau2*exp(-t/tau2) - tau1*exp(-t/tau1)
+ t*(expint_Ei(-t/tau2) - expint_Ei(-t/tau1)))
/(tau2 - tau1);
}
else
g = 1;
if (g < 0) g = 0;
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationPark
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationPark, FEBondRelaxation)
ADD_PARAMETER(m_tau , FE_RANGE_GREATER(0.0), "tau")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_beta, FE_RANGE_GREATER(0.0), "beta");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationPark::FEBondRelaxationPark(FEModel* pfem) : FEBondRelaxation(pfem)
{
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationPark::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double tau = m_tau(mp);
double beta = m_beta(mp);
double g = 1./(1+pow(t/tau,beta));
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationParkDistortion
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationParkDistortion, FEBondRelaxation)
ADD_PARAMETER(m_tau0 , FE_RANGE_GREATER (0.0), "tau0" )->setLongName("constant coefficient tau0")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_tau1 , FE_RANGE_GREATER_OR_EQUAL(0.0), "tau1" )->setLongName("power coefficient tau1")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_beta0, FE_RANGE_GREATER (0.0), "beta0")->setLongName("constant coefficient beta0");
ADD_PARAMETER(m_beta1, FE_RANGE_GREATER_OR_EQUAL(0.0), "beta1")->setLongName("power coefficient beta1");
ADD_PARAMETER(m_alpha, FE_RANGE_GREATER_OR_EQUAL(0.0), "alpha")->setLongName("power exponent alpha");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationParkDistortion::FEBondRelaxationParkDistortion(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau0 = 0;
m_beta0 = 0;
m_tau1 = 0;
m_beta1 = 0;
m_alpha = 1;
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationParkDistortion::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g;
double alpha = m_alpha(mp);
double tau0 = m_tau0(mp);
double tau1 = m_tau1(mp);
double beta0 = m_beta0(mp);
double beta1 = m_beta1(mp);
// get the elastic material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = pt.LeftHencky();
// evaluate distortion magnitude (always positive)
double K2 = (h.dev()).norm();
double K2a = pow(K2,alpha);
double tau = tau0 + tau1*K2a;
double beta = beta0 + beta1*K2a;
g = 1./(1+pow(t/tau,beta));
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationParkDistUser
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationParkDistUser, FEBondRelaxation)
ADD_PROPERTY(m_tau , "tau");
ADD_PROPERTY(m_beta , "beta");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationParkDistUser::FEBondRelaxationParkDistUser(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau = nullptr;
m_beta = nullptr;
}
//-----------------------------------------------------------------------------
//! performs initialization
bool FEBondRelaxationParkDistUser::Init()
{
if (!m_tau->Init()) return false;
if (!m_beta->Init()) return false;
return FEBondRelaxation::Init();
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationParkDistUser::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g;
// get the elastic material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = pt.LeftHencky();
// evaluate distortion magnitude (always positive)
double K2 = (h.dev()).norm();
double tau = m_tau->value(K2);
double beta = m_beta->value(K2);
g = 1./(1+pow(t/tau,beta));
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationPower
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationPower, FEBondRelaxation)
ADD_PARAMETER(m_tau , FE_RANGE_GREATER(0.0), "tau" )->setLongName("time constant")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_beta, FE_RANGE_GREATER(0.0), "beta")->setLongName("power exponent");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationPower::FEBondRelaxationPower(FEModel* pfem) : FEBondRelaxation(pfem)
{
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationPower::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double tau = m_tau(mp);
double beta = m_beta(mp);
double g = pow(1+t/tau,-beta);
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationPowerDistortion
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationPowerDistortion, FEBondRelaxation)
ADD_PARAMETER(m_tau0 , FE_RANGE_GREATER (0.0), "tau0" )->setLongName("constant coefficient tau0")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_tau1 , FE_RANGE_GREATER_OR_EQUAL(0.0), "tau1" )->setLongName("power coefficient tau1")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_beta0, FE_RANGE_GREATER (0.0), "beta0")->setLongName("constant coefficient beta0");
ADD_PARAMETER(m_beta1, FE_RANGE_GREATER_OR_EQUAL(0.0), "beta1")->setLongName("power coefficient beta1");
ADD_PARAMETER(m_alpha, FE_RANGE_GREATER_OR_EQUAL(0.0), "alpha")->setLongName("power exponent alpha");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationPowerDistortion::FEBondRelaxationPowerDistortion(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau1 = 0;
m_alpha = 1;
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationPowerDistortion::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g;
double tau0 = m_tau0(mp);
double tau1 = m_tau1(mp);
double beta0 = m_beta0(mp);
double beta1 = m_beta1(mp);
double alpha = m_alpha(mp);
// get the elastic material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = pt.LeftHencky();
// evaluate distortion magnitude (always positive)
double K2 = (h.dev()).norm();
double K2a = pow(K2,alpha);
double tau = tau0 + tau1*K2a;
double beta = beta0 + beta1*K2a;
g = pow(1+t/tau,-beta);
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationPowerDistUser
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationPowerDistUser, FEBondRelaxation)
ADD_PROPERTY(m_tau , "tau");
ADD_PROPERTY(m_beta , "beta");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationPowerDistUser::FEBondRelaxationPowerDistUser(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau = nullptr;
m_beta = nullptr;
}
//-----------------------------------------------------------------------------
//! performs initialization
bool FEBondRelaxationPowerDistUser::Init()
{
if (!m_tau->Init()) return false;
if (!m_beta->Init()) return false;
return FEBondRelaxation::Init();
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationPowerDistUser::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g;
// get the elastic material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = pt.LeftHencky();
// evaluate distortion magnitude (always positive)
double K2 = (h.dev()).norm();
double tau = m_tau->value(K2);
double beta = m_beta->value(K2);
g = pow(1+t/tau,-beta);
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationCarreau
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationCarreau, FEBondRelaxation)
ADD_PARAMETER(m_tau0 , FE_RANGE_GREATER (0.0), "tau0")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_lam , FE_RANGE_GREATER_OR_EQUAL(0.0), "lambda");
ADD_PARAMETER(m_n , FE_RANGE_GREATER (0.0), "n");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationCarreau::FEBondRelaxationCarreau(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau0 = 0;
m_lam = 0;
m_n = 1;
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationCarreau::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g;
double tau0 = m_tau0(mp);
double lam = m_lam(mp);
double n = m_n(mp);
// evaluate the engineering shear rate
double gdot = sqrt(2.)*D.norm();
// evaluate the relaxation time
double tau = tau0*pow(1+pow(lam*gdot,2),(n-1)/2.);
g = exp(-t/tau);
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationProny
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationProny, FEBondRelaxation)
// material parameters
ADD_PARAMETER(m_t[0], FE_RANGE_GREATER_OR_EQUAL(0.0), "t1")->setLongName("relaxation time t1")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[1], FE_RANGE_GREATER_OR_EQUAL(0.0), "t2")->setLongName("relaxation time t2")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[2], FE_RANGE_GREATER_OR_EQUAL(0.0), "t3")->setLongName("relaxation time t3")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[3], FE_RANGE_GREATER_OR_EQUAL(0.0), "t4")->setLongName("relaxation time t4")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[4], FE_RANGE_GREATER_OR_EQUAL(0.0), "t5")->setLongName("relaxation time t5")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t[5], FE_RANGE_GREATER_OR_EQUAL(0.0), "t6")->setLongName("relaxation time t6")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_g[0], FE_RANGE_CLOSED(0.0, 1.0) , "g1")->setLongName("coefficient g1");
ADD_PARAMETER(m_g[1], FE_RANGE_CLOSED(0.0, 1.0) , "g2")->setLongName("coefficient g2");
ADD_PARAMETER(m_g[2], FE_RANGE_CLOSED(0.0, 1.0) , "g3")->setLongName("coefficient g3");
ADD_PARAMETER(m_g[3], FE_RANGE_CLOSED(0.0, 1.0) , "g4")->setLongName("coefficient g4");
ADD_PARAMETER(m_g[4], FE_RANGE_CLOSED(0.0, 1.0) , "g5")->setLongName("coefficient g5");
ADD_PARAMETER(m_g[5], FE_RANGE_CLOSED(0.0, 1.0) , "g6")->setLongName("coefficient g6");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationProny::FEBondRelaxationProny(FEModel* pfem) : FEBondRelaxation(pfem)
{
for (int i=0; i<MAX_TERMS; ++i)
{
m_t[i] = 1;
m_g[i] = 0;
}
m_sg = 0.0;
}
//-----------------------------------------------------------------------------
//! Initialization.
bool FEBondRelaxationProny::Validate()
{
if (FEBondRelaxation::Validate() == false) return false;
m_sg = 0;
for (int i=0; i<MAX_TERMS; ++i) m_sg += m_g[i];
if (m_sg <= 0) return false;
return true;
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationProny::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
// --- Prony series ---
double g = 0;
for (int i=0; i<MAX_TERMS; ++i) g += m_g[i]*exp(-t/m_t[i]);
g /= m_sg;
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationMalkin
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationMalkin, FEBondRelaxation)
ADD_PARAMETER(m_tau1 , FE_RANGE_GREATER(0.0), "tau1")->setLongName("min. relaxation time")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_tau2 , FE_RANGE_GREATER(0.0), "tau2")->setLongName("max. relaxation time")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_beta , FE_RANGE_GREATER_OR_EQUAL(1.0), "beta")->setLongName("power exponent");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationMalkin::FEBondRelaxationMalkin(FEModel* pfem) : FEBondRelaxation(pfem)
{
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationMalkin::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g = 1.0;
if (t == 0) return g;
double tau1 = m_tau1(mp);
double tau2 = m_tau2(mp);
double beta = m_beta(mp);
if (beta != 1) {
double bm1 = beta - 1;
double Q1 = gamma_inc_Q(bm1, t/tau1);
double den = pow(tau1,-bm1) - pow(tau2,-bm1);
double Q2 = gamma_inc_Q(bm1, t/tau2);
g = bm1*pow(t,-bm1)*(Q2-Q1)/den;
}
else {
g = (expint_Ei(-t/tau2) - expint_Ei(-t/tau1))/(log(tau1/tau2));
}
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationMalkinDist
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationMalkinDist, FEBondRelaxation)
ADD_PARAMETER(m_t1c0 , FE_RANGE_GREATER(0.0), "t1c0")->setLongName("constant for tau1")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t1c1 , "t1c1")->setLongName("coefficient for tau1")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t1s0 , FE_RANGE_GREATER(0.0), "t1s0")->setLongName("strain for tau1");
ADD_PARAMETER(m_t2c0 , FE_RANGE_GREATER(0.0), "t2c0")->setLongName("constant for tau2")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t2c1 , "t2c1")->setLongName("coefficient for tau2")->setUnits(UNIT_TIME);
ADD_PARAMETER(m_t2s0 , FE_RANGE_GREATER(0.0), "t2s0")->setLongName("strain for tau2");
ADD_PARAMETER(m_beta , FE_RANGE_GREATER(0.0), "beta")->setLongName("power exponent beta");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationMalkinDist::FEBondRelaxationMalkinDist(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_t1c0 = 0;
m_t1c1 = 0;
m_t1s0 = 1;
m_t2c0 = 0;
m_t2c1 = 0;
m_t2s0 = 1;
m_beta = 1;
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationMalkinDist::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g = 1.0;
if (t == 0) return g;
// get the elastic material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = pt.LeftHencky();
// evaluate distortion magnitude (always positive)
double K2 = (h.dev()).norm();
double tau1 = m_t1c0(mp) + m_t1c1(mp)*exp(-K2/m_t1s0(mp));
double tau2 = m_t2c0(mp) + m_t2c1(mp)*exp(-K2/m_t2s0(mp));
double beta = m_beta(mp);
if (beta != 1) {
double bm1 = beta - 1;
double Q1 = gamma_inc_Q(bm1, t/tau1);
double den = pow(tau1,-bm1) - pow(tau2,-bm1);
double Q2 = gamma_inc_Q(bm1, t/tau2);
g = bm1*pow(t,-bm1)*(Q2-Q1)/den;
}
else {
g = (expint_Ei(-t/tau2) - expint_Ei(-t/tau1))/(log(tau1/tau2));
}
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationMalkinDistUser
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationMalkinDistUser, FEBondRelaxation)
ADD_PROPERTY(m_tau1 , "tau1");
ADD_PROPERTY(m_tau2 , "tau2");
ADD_PROPERTY(m_beta , "beta");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationMalkinDistUser::FEBondRelaxationMalkinDistUser(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau1 = nullptr;
m_tau2 = nullptr;
m_beta = nullptr;
}
//-----------------------------------------------------------------------------
//! performs initialization
bool FEBondRelaxationMalkinDistUser::Init()
{
if (!m_tau1->Init()) return false;
if (!m_tau2->Init()) return false;
if (!m_beta->Init()) return false;
return FEBondRelaxation::Init();
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationMalkinDistUser::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g = 1.0;
if (t == 0) return g;
// get the elastic material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = pt.LeftHencky();
// evaluate distortion magnitude (always positive)
double K2 = (h.dev()).norm();
double tau1 = m_tau1->value(K2);
double tau2 = m_tau2->value(K2);
double beta = m_beta->value(K2);
if (beta != 1) {
double bm1 = beta - 1;
double Q1 = gamma_inc_Q(bm1, t/tau1);
double den = pow(tau1,-bm1) - pow(tau2,-bm1);
double Q2 = gamma_inc_Q(bm1, t/tau2);
g = bm1*pow(t,-bm1)*(Q2-Q1)/den;
}
else {
g = (expint_Ei(-t/tau2) - expint_Ei(-t/tau1))/(log(tau1/tau2));
}
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationCSexp
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationCSexp, FEBondRelaxation)
ADD_PARAMETER(m_tau , FE_RANGE_GREATER(0.0), "tau")->setLongName("exponential spectrum constant")->setUnits(UNIT_TIME);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationCSexp::FEBondRelaxationCSexp(FEModel* pfem) : FEBondRelaxation(pfem)
{
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationCSexp::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g = 1;
if (t == 0) return g;
double tau = m_tau(mp);
double ts = 2*sqrt(t/tau);
g = ts*k1(ts);
return g;
}
///////////////////////////////////////////////////////////////////////////////
//
// FEBondRelaxationCSexpDistUser
//
///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEBondRelaxationCSexpDistUser, FEBondRelaxation)
ADD_PROPERTY(m_tau , "tau");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEBondRelaxationCSexpDistUser::FEBondRelaxationCSexpDistUser(FEModel* pfem) : FEBondRelaxation(pfem)
{
m_tau = nullptr;
}
//-----------------------------------------------------------------------------
//! performs initialization
bool FEBondRelaxationCSexpDistUser::Init()
{
if (!m_tau->Init()) return false;
return FEBondRelaxation::Init();
}
//-----------------------------------------------------------------------------
//! Relaxation function
double FEBondRelaxationCSexpDistUser::Relaxation(FEMaterialPoint& mp, const double t, const mat3ds D)
{
double g = 1;
if (t == 0) return g;
// get the elastic material point data
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// evaluate spatial Hencky (logarithmic) strain
mat3ds h = pt.LeftHencky();
// evaluate distortion magnitude (always positive)
double K2 = (h.dev()).norm();
double tau = m_tau->value(K2);
// evaluate relaxation function
double ts = 2*sqrt(t/tau);
// k1 is the modified bessel function of the second kind
g = ts*k1(ts);
return g;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEPeriodicBoundary.h | .h | 4,214 | 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 "FEContactInterface.h"
#include "FEContactSurface.h"
#include <FECore/vec2d.h>
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
class FEBIOMECH_API FEPeriodicSurface : public FEContactSurface
{
public:
class Data : public FEContactMaterialPoint
{
public:
Data();
void Init() override;
void Serialize(DumpStream& ar) override;
public:
vec3d m_gap; //!< gap function at nodes
vec2d m_rs; //!< natural coordinates of projection on secondary surface element
vec3d m_Lm; //!< Lagrange multipliers
vec3d m_Tn; //!< nodal traction forces
vec3d m_Fr; //!< reaction forces
};
public:
//! constructor
FEPeriodicSurface(FEModel* pfem) : FEContactSurface(pfem) {}
//! initializes data
bool Init();
//! copy data
void CopyFrom(FEPeriodicSurface& s);
//! calculates the center of mass of the surface
vec3d CenterOfMass();
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<Data> m_data; // integration point data
};
//-----------------------------------------------------------------------------
class FEPeriodicBoundary : public FEContactInterface
{
public:
//! constructor
FEPeriodicBoundary(FEModel* pfem);
//! destructor
virtual ~FEPeriodicBoundary(void) {}
//! initialization
bool Init() override;
//! interface activation
void Activate() override;
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! return the primary and secondary surface
FESurface* GetPrimarySurface() override { return &m_ss; }
FESurface* GetSecondarySurface() override { return &m_ms; }
//! return integration rule class
bool UseNodalIntegration() override { return true; }
//! build the matrix profile for use in the stiffness matrix
void BuildMatrixProfile(FEGlobalMatrix& K) override;
//! create a copy of this interface
void CopyFrom(FESurfacePairConstraint* pci) override;
public:
//! calculate contact forces
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
//! calculate contact stiffness
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
//! calculate Lagrangian augmentations
bool Augment(int naug, const FETimeInfo& tp) override;
//! update
void Update() override;
protected:
void ProjectSurface(FEPeriodicSurface& ss, FEPeriodicSurface& ms, bool bmove);
public:
FEPeriodicSurface m_ss; //!< primary surface
FEPeriodicSurface m_ms; //!< secondary surface
double m_atol; //!< augmentation tolerance
double m_eps; //!< penalty scale factor
double m_stol; //!< search tolerance
bool m_btwo_pass; //!< two-pass flag
int m_naugmin; //!< minimum number of augmentations
vec3d m_off; //!< relative displacement offset
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEReactiveFatigueMaterialPoint.h | .h | 4,132 | 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) 2022 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEDamageMaterialPoint.h"
#include <deque>
#include <FECore/FEMaterialPoint.h>
//-----------------------------------------------------------------------------
// structure for fatigue bonds
class FatigueBond
{
public:
// constructor
FatigueBond();
// copy constructor
FatigueBond(const FatigueBond& fb);
FatigueBond(FatigueBond& fb);
// update
void Update();
public:
double m_wft; //!< fatigued bond fraction at current time
double m_wfp; //!< fatigued bond fraction at previous time
double m_Xfmax; //!< max damage criterion for fatigued bonds
double m_Xftrl; //!< trial value of Xfmax
double m_Fft; //!< fatigue bond damage CDF at current time
double m_Ffp; //!< fatigue bond damage CDF at previous time
double m_time; //!< fatigue bond generation time
bool m_erase; //!< flag for erasing a generation
};
//-----------------------------------------------------------------------------
// Define a material point that stores the fatigue and damage variables.
class FEReactiveFatigueMaterialPoint : public FEDamageMaterialPoint
{
public:
// default constructor
FEReactiveFatigueMaterialPoint(FEMaterialPointData*pt);
// copy constructors
FEReactiveFatigueMaterialPoint(const FEReactiveFatigueMaterialPoint& rfmp);
FEReactiveFatigueMaterialPoint(FEReactiveFatigueMaterialPoint& rfmp);
FEMaterialPointData* Copy() override;
void Init() override;
void Update(const FETimeInfo& timeInfo) override;
void Serialize(DumpStream& ar) override;
double IntactBonds() const override { return m_wit; }
double FatigueBonds() const override { return m_wft; }
public:
double m_wit; //!< intact bond mass fraction at current time
double m_wip; //!< intact bond mass fraction at previous time
double m_Ximax; //!< max damage criterion for intact bonds
double m_Xitrl; //!< trial value of Ximax
double m_Xip; //!< Xi at previous time
double m_aXit; //!< rate of change of Xi at current time
double m_aXip; //!< rate of change of Xi at previous time
double m_Fit; //!< intact bond damage CDF at current time
double m_Fip; //!< intact bond damage CDF at previous time
double m_wbt; //!< broken (damaged) bond fraction at current time
double m_wbp; //!< broken (damaged) bond fraction at previous time
double m_wft; //!< fatigue bond fraction at current time
double m_wfp; //!< fatigue bond fraction at previous time
std::deque <FatigueBond> m_fb; //!< generations of fatigued bonds
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEStickyInterface.cpp | .cpp | 18,900 | 739 | /*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 "FEStickyInterface.h"
#include <FECore/FEClosestPointProjection.h>
#include <FECore/FELinearSystem.h>
#include <FECore/log.h>
FEStickySurface::Data::Data()
{
gap = vec3d(0.0, 0.0, 0.0);
scalar_gap = 0;
pme = nullptr;
}
void FEStickySurface::Data::Serialize(DumpStream& ar)
{
ar & gap;
ar & rs;
ar & Lm;
ar & tn;
}
//-----------------------------------------------------------------------------
// Define sliding interface parameters
BEGIN_FECORE_CLASS(FEStickyInterface, FEContactInterface)
ADD_PARAMETER(m_laugon , "laugon" )->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0");
ADD_PARAMETER(m_atol , "tolerance" );
ADD_PARAMETER(m_eps , "penalty" );
ADD_PARAMETER(m_naugmin, "minaug" );
ADD_PARAMETER(m_naugmax, "maxaug" );
ADD_PARAMETER(m_stol , "search_tolerance");
ADD_PARAMETER(m_tmax , "max_traction" );
ADD_PARAMETER(m_snap , "snap_tol" );
ADD_PARAMETER(m_flip_secondary, "flip_secondary");
ADD_PARAMETER(m_gap_offset, "gap_offset");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! 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 FEStickySurface::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_data.resize(nn);
return true;
}
//-----------------------------------------------------------------------------
void FEStickySurface::Serialize(DumpStream &ar)
{
FEContactSurface::Serialize(ar);
ar & m_data;
}
//-----------------------------------------------------------------------------
void FEStickySurface::GetContactTraction(int nface, vec3d& pt)
{
FESurfaceElement& el = Element(nface);
int ne = el.Nodes();
pt = vec3d(0,0,0);
for (int k=0; k<ne; ++k) pt += m_data[el.m_lnode[k]].tn;
pt /= ne;
}
//-----------------------------------------------------------------------------
void FEStickySurface::GetNodalContactPressure(int nface, double* pn)
{
FESurfaceElement& f = Element(nface);
int ne = f.Nodes();
for (int j= 0; j< ne; ++j) pn[j] = m_data[f.m_lnode[j]].tn.norm();
}
//-----------------------------------------------------------------------------
void FEStickySurface::GetNodalContactTraction(int nface, vec3d* tn)
{
FESurfaceElement& f = Element(nface);
int ne = f.Nodes();
for (int j= 0; j< ne; ++j) tn[j] = m_data[f.m_lnode[j]].tn;
}
//=============================================================================
//
// F E S T I C K Y I N T E R F A C E
//
//=============================================================================
//-----------------------------------------------------------------------------
//! Constructor. Initialize default values.
FEStickyInterface::FEStickyInterface(FEModel* pfem) : FEContactInterface(pfem), ss(pfem), ms(pfem)
{
static int count = 1;
SetID(count++);
// set parents
ss.SetContactInterface(this);
ms.SetContactInterface(this);
// define sibling relationships
ss.SetSibling(&ms);
ms.SetSibling(&ss);
// initial parameter values
m_atol = 0.01;
m_eps = 1.0;
m_stol = 0.0001;
m_naugmin = 0;
m_naugmax = 10;
m_tmax = 0.0;
m_snap = 0.0;
m_flip_secondary = false;
m_gap_offset = 0.0;
}
//-----------------------------------------------------------------------------
//! Initialization. This function intializes the surfaces data and projects the
//! primary surface onto the secondary surface.
//!
bool FEStickyInterface::Init()
{
// create the surfaces
if (ss.Init() == false) return false;
if (ms.Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
//! build the matrix profile for use in the stiffness matrix
void FEStickyInterface::BuildMatrixProfile(FEGlobalMatrix& K)
{
FEMesh& mesh = GetMesh();
// get the DOFS
const int dof_X = GetDOFIndex("x");
const int dof_Y = GetDOFIndex("y");
const int dof_Z = GetDOFIndex("z");
const int dof_RU = GetDOFIndex("Ru");
const int dof_RV = GetDOFIndex("Rv");
const int dof_RW = GetDOFIndex("Rw");
const int LMSIZE = 6*(FEElement::MAX_NODES+1);
vector<int> lm(LMSIZE);
for (int j=0; j<ss.Nodes(); ++j)
{
FEStickySurface::Data& snj = ss.m_data[j];
FESurfaceElement* pe = snj.pme;
if (pe != 0)
{
FESurfaceElement& me = *pe;
int* en = &me.m_lnode[0];
int n = me.Nodes();
lm.assign(LMSIZE, -1);
lm[0] = ss.Node(j).m_ID[dof_X];
lm[1] = ss.Node(j).m_ID[dof_Y];
lm[2] = ss.Node(j).m_ID[dof_Z];
lm[3] = ss.Node(j).m_ID[dof_RU];
lm[4] = ss.Node(j).m_ID[dof_RV];
lm[5] = ss.Node(j).m_ID[dof_RW];
for (int k=0; k<n; ++k)
{
vector<int>& id = ms.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);
}
}
}
//-----------------------------------------------------------------------------
//! Interface activation
void FEStickyInterface::Activate()
{
// Don't forget to call base member!
FEContactInterface::Activate();
// project primary surface onto secondary surface
ProjectSurface(ss, ms, false);
}
//-----------------------------------------------------------------------------
//! Update sticky interface data. This function re-evaluates the gaps between
//! the primary node and their projections onto the secondary surface.
//!
void FEStickyInterface::Update()
{
// closest point projection method
FEClosestPointProjection cpp(ms);
cpp.HandleSpecialCases(true);
cpp.SetTolerance(m_stol);
cpp.Init();
// get the mesh
FEMesh& mesh = *ss.GetMesh();
// loop over all primary nodes
#pragma omp parallel for shared(cpp, mesh) schedule(dynamic, 5)
for (int i=0; i<ss.Nodes(); ++i)
{
FEStickySurface::Data& sni = ss.m_data[i];
FESurfaceElement* pme = sni.pme;
if (pme)
{
// get the current primary nodal position
vec3d rt = ss.Node(i).m_rt;
if (m_gap_offset != 0)
{
vec3d n = ss.NodeNormal(i);
rt += n * m_gap_offset;
}
// get the natural coordinates of the primary projection
// onto the secondary element
double r = sni.rs[0];
double s = sni.rs[1];
// get the nodal coordinates
int ne = pme->Nodes();
vec3d y[FEElement::MAX_NODES];
for (int l=0; l<ne; ++l) y[l] = ms.Node( pme->m_lnode[l] ).m_rt;
// calculate the primary node projection
vec3d q = pme->eval(y, r, s);
// calculate the gap function
sni.gap = rt - q;
// see if the max traction was exceded
if (m_tmax > 0.0)
{
// get primary node contact force
vec3d tc = sni.Lm + sni.gap*m_eps;
// calculate the secondary normal
vec3d nu = ms.SurfaceNormal(*sni.pme, sni.rs[0], sni.rs[1]);
if (m_flip_secondary) nu = -nu;
double t = nu*tc;
if (t > m_tmax)
{
// detach this node
sni.gap = vec3d(0,0,0);
sni.pme = 0;
sni.Lm = vec3d(0,0,0);
sni.tn = vec3d(0,0,0);
}
}
}
else if (m_eps != 0)
{
// get the nodal position of this primary node
FENode& node = ss.Node(i);
vec3d x = node.m_rt;
if (m_gap_offset != 0)
{
vec3d n = ss.NodeNormal(i);
x += n * m_gap_offset;
}
// find the secondary element
vec3d q; vec2d rs;
FESurfaceElement* pme = cpp.Project(x, q, rs);
if (pme)
{
// calculate the secondary normal
vec3d nu = ms.SurfaceNormal(*pme, rs[0], rs[1]);
if (m_flip_secondary) nu = -nu;
// calculate gap
double d = nu*(q - x);
// only allow contact after penetration
if (d > -m_snap)
{
// calculate signed distance
sni.gap = x - q;
sni.scalar_gap = d;
// store the secondary element
sni.pme = pme;
sni.rs[0] = rs[0];
sni.rs[1] = rs[1];
}
}
}
}
}
//-----------------------------------------------------------------------------
//! project surface
void FEStickyInterface::ProjectSurface(FEStickySurface& ss, FEStickySurface& ms, bool bmove)
{
if (m_eps == 0) return;
// closest point projection method
FEClosestPointProjection cpp(ms);
cpp.HandleSpecialCases(true);
cpp.SetTolerance(m_stol);
cpp.Init();
// loop over all primary nodes
#pragma omp parallel for shared(cpp) schedule(dynamic, 5)
for (int i=0; i<ss.Nodes(); ++i)
{
// get the next node
FENode& node = ss.Node(i);
FEStickySurface::Data& sni = ss.m_data[i];
// assume we won't find a projection
sni.pme = 0;
// get the nodal position of this primary node
vec3d x = node.m_rt;
if (m_gap_offset != 0)
{
vec3d n = ss.NodeNormal(i);
x += n* m_gap_offset;
}
// find the secondary element
vec3d q; vec2d rs;
FESurfaceElement* pme = cpp.Project(x, q, rs);
if (pme)
{
// calculate the secondary normal
vec3d nu = ms.SurfaceNormal(*pme, rs[0], rs[1]);
if (m_flip_secondary) nu = -nu;
// calculate gap
double d = nu*(q - x);
// only allow contact after penetration
if (d > 0)
{
// calculate signed distance
sni.gap = x - q;
// store the secondary element
sni.pme = pme;
sni.rs[0] = rs[0];
sni.rs[1] = rs[1];
// move the node if necessary
if (bmove && (sni.gap.norm()>0))
{
node.m_r0 = node.m_rt = q;
sni.gap = vec3d(0,0,0);
}
}
}
}
}
//-----------------------------------------------------------------------------
//! This function calculates the contact forces for a tied interface.
void FEStickyInterface::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
#pragma omp parallel shared(R, tp)
{
// 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;
// loop over all primary facets
const int NE = ss.Elements();
#pragma omp for
for (int j = 0; j < NE; ++j)
{
// get the primary element
FESurfaceElement& sel = ss.Element(j);
// get the element's LM vector
ss.UnpackLM(sel, sLM);
int nseln = sel.Nodes();
double* w = sel.GaussWeights();
// loop over primary element nodes (which are the integration points as well)
for (int n = 0; n < nseln; ++n)
{
int m = sel.m_lnode[n];
FEStickySurface::Data& sm = ss.m_data[m];
// see if this node's constraint is active
// that is, if it has a secondary element associated with it
// TODO: is this a good way to test for an active constraint
// The rigid wall criteria seems to work much better.
if (sm.pme != 0)
{
// calculate jacobian
double detJ = ss.jac0(sel, n);
// get primary node contact force
vec3d tc = sm.Lm + sm.gap * m_eps;
// cap it
if (m_tmax > 0.0)
{
// calculate the secondary normal
vec3d nu = ms.SurfaceNormal(*sm.pme, sm.rs[0], sm.rs[1]);
if (m_flip_secondary) nu = -nu;
double t = nu * tc;
if (t > m_tmax) tc = vec3d(0, 0, 0);
}
// store traction
sm.tn = tc;
// get the secondary element
FESurfaceElement& mel = *sm.pme;
ms.UnpackLM(mel, mLM);
int nmeln = mel.Nodes();
// isoparametric coordinates of the projected primary node
// onto the secondary element
double r = sm.rs[0];
double s = sm.rs[1];
// get the secondary shape function values at this primary node
mel.shape_fnc(N, r, 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 (int 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 (int l = 0; l < nmeln; ++l)
{
lm[3 * (l + 1)] = mLM[l * 3];
lm[3 * (l + 1) + 1] = mLM[l * 3 + 1];
lm[3 * (l + 1) + 2] = mLM[l * 3 + 2];
}
// fill the en array
en.resize(nmeln + 1);
en[0] = sel.m_node[n];
for (int l = 0; l < nmeln; ++l) en[l + 1] = mel.m_node[l];
// assemble into global force vector
R.Assemble(en, lm, fe);
}
}
}
}
}
//-----------------------------------------------------------------------------
//! Calculate the stiffness matrix contribution.
void FEStickyInterface::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
vector<int> sLM, mLM, lm, en;
const int MN = FEElement::MAX_NODES;
FEElementMatrix ke;
// shape functions
double H[MN];
// loop over all primary elements
const int NE = ss.Elements();
for (int i=0; i<NE; ++i)
{
// get the next element
FESurfaceElement& se = ss.Element(i);
int nseln = se.Nodes();
// get the element's LM vector
ss.UnpackLM(se, sLM);
double* w = se.GaussWeights();
// loop over all integration points (that is nodes)
for (int n=0; n<nseln; ++n)
{
int m = se.m_lnode[n];
FEStickySurface::Data& sm = ss.m_data[m];
// get the secondary element
FESurfaceElement* pme = sm.pme;
if (pme)
{
// get the secondary element
FESurfaceElement& me = *pme;
int nmeln = me.Nodes();
ms.UnpackLM(me, mLM);
// calculate jacobian
double detJ = ss.jac0(se, n);
// primary node natural coordinates in secondary element
double r = sm.rs[0];
double s = sm.rs[1];
// get the secondary shape function values at this primary node
me.shape_fnc(H, r, s);
// number of degrees of freedom
int ndof = 3*(1 + nmeln);
// fill stiffness matrix
ke.resize(ndof, ndof); ke.zero();
ke[0][0] = w[n]*detJ*m_eps;
ke[1][1] = w[n]*detJ*m_eps;
ke[2][2] = w[n]*detJ*m_eps;
for (int k=0; k<nmeln; ++k)
{
ke[0][3+3*k ] = -w[n]*detJ*m_eps*H[k];
ke[1][3+3*k+1] = -w[n]*detJ*m_eps*H[k];
ke[2][3+3*k+2] = -w[n]*detJ*m_eps*H[k];
ke[3+3*k ][0] = -w[n]*detJ*m_eps*H[k];
ke[3+3*k+1][1] = -w[n]*detJ*m_eps*H[k];
ke[3+3*k+2][2] = -w[n]*detJ*m_eps*H[k];
}
for (int k=0; k<nmeln; ++k)
for (int l=0; l<nmeln; ++l)
{
ke[3+3*k ][3+3*l ] = w[n]*detJ*m_eps*H[k]*H[l];
ke[3+3*k+1][3+3*l+1] = w[n]*detJ*m_eps*H[k]*H[l];
ke[3+3*k+2][3+3*l+2] = w[n]*detJ*m_eps*H[k]*H[l];
}
// create lm array
lm.resize(3*(1+nmeln));
lm[0] = sLM[n*3 ];
lm[1] = sLM[n*3+1];
lm[2] = sLM[n*3+2];
for (int k=0; k<nmeln; ++k)
{
lm[3*(k+1) ] = mLM[k*3 ];
lm[3*(k+1)+1] = mLM[k*3+1];
lm[3*(k+1)+2] = mLM[k*3+2];
}
// create the en array
en.resize(nmeln+1);
en[0] = se.m_node[n];
for (int k=0; k<nmeln; ++k) en[k+1] = me.m_node[k];
// assemble stiffness matrix
ke.SetNodes(en);
ke.SetIndices(lm);
LS.Assemble(ke);
}
}
}
}
//-----------------------------------------------------------------------------
//! Do an augmentation.
bool FEStickyInterface::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (m_laugon != FECore::AUGLAG_METHOD) return true;
int i;
// calculate initial norms
double normL0 = 0;
for (i=0; i<ss.Nodes(); ++i)
{
FEStickySurface::Data& si = ss.m_data[i];
vec3d lm = si.Lm;
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<ss.Nodes(); ++i)
{
FEStickySurface::Data& si = ss.m_data[i];
vec3d lm = si.Lm + si.gap*m_eps;
normL1 += lm*lm;
if (si.pme != 0)
{
double g = si.gap.norm();
normgc += g*g;
++N;
}
}
if (N == 0) N=1;
normL1 = sqrt(normL1);
normgc = sqrt(normgc / N);
// check convergence of constraints
feLog(" tied interface # %d\n", GetID());
feLog(" CURRENT REQUIRED\n");
double pctn = 0;
if (fabs(normL1) > 1e-10) pctn = fabs((normL1 - normL0)/normL1);
feLog(" normal force : %15le %15le\n", pctn, m_atol);
feLog(" gap function : %15le ***\n", normgc);
// check convergence
bool bconv = true;
if (pctn >= m_atol) bconv = false;
if (naug < m_naugmin ) bconv = false;
if (naug >= m_naugmax) bconv = true;
if (bconv == false)
{
for (i=0; i<ss.Nodes(); ++i)
{
FEStickySurface::Data& si = ss.m_data[i];
// update Lagrange multipliers
si.Lm = si.Lm + si.gap*m_eps;
}
}
return bconv;
}
//-----------------------------------------------------------------------------
//! Serialize the data to the archive.
void FEStickyInterface::Serialize(DumpStream &ar)
{
// store contact data
FEContactInterface::Serialize(ar);
// store contact surface data
ms.Serialize(ar);
ss.Serialize(ar);
// restore secondary element pointers
SerializePointers(ss, ms, ar);
SerializePointers(ms, ss, ar);
}
void FEStickyInterface::SerializePointers(FEStickySurface& ss, FEStickySurface& ms, DumpStream& ar)
{
if (ar.IsSaving())
{
for (int i = 0; i < ss.m_data.size(); i++)
{
FESurfaceElement* pe = ss.m_data[i].pme;
int eid = (pe ? pe->m_lid : -1);
ar << eid;
}
}
else
{
for (int i = 0; i < ss.m_data.size(); i++)
{
int eid = -1;
ar >> eid;
if (eid >= 0)
{
FESurfaceElement* pe = &ms.Element(eid);
ss.m_data[i].pme = pe;
}
else ss.m_data[i].pme = nullptr;
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/stdafx.cpp | .cpp | 1,297 | 30 | /*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"
| C++ |
3D | febiosoftware/FEBio | FEBioMech/RigidBC.cpp | .cpp | 13,639 | 465 | /*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 "RigidBC.h"
#include <FECore/FEModel.h>
#include <FECore/FEMesh.h>
#include "FERigidBody.h"
#include <FECore/FEMaterial.h>
#include <FECore/FELoadCurve.h>
#include "FEMechModel.h"
#include "FERigidMaterial.h"
#include <FECore/DumpStream.h>
#include <FECore/log.h>
//=============================================================================
FERigidBC::FERigidBC(FEModel* fem) : FEBoundaryCondition(fem)
{
m_rigidMat = -1;
m_rb = -1;
m_binit = false;
}
void FERigidBC::SetRigidMaterial(int rigidMat)
{
m_rigidMat = rigidMat;
}
void FERigidBC::InitTimeStep()
{
}
bool FERigidBC::Init()
{
// Make sure the rigid material ID is valid
FEModel& fem = *GetFEModel();
FERigidMaterial* pm = dynamic_cast<FERigidMaterial*>(fem.GetMaterial(m_rigidMat - 1));
if (pm == nullptr) return false;
m_rb = pm->GetRigidBodyID(); assert(m_rb >= 0);
m_binit = true;
return FEBoundaryCondition::Init();
}
void FERigidBC::CopyFrom(FEBoundaryCondition* pbc)
{
FERigidBC* rbc = dynamic_cast<FERigidBC*>(pbc);
GetParameterList() = rbc->GetParameterList();
m_rb = rbc->m_rb;
}
void FERigidBC::Serialize(DumpStream& ar)
{
ar & m_rb & m_binit;
FEBoundaryCondition::Serialize(ar);
}
FERigidBody& FERigidBC::GetRigidBody()
{
FEMechModel& fem = static_cast<FEMechModel&>(*GetFEModel());
FERigidBody& RB = *fem.GetRigidBody(m_rb);
return RB;
}
//=============================================================================
FERigidFixedBC::FERigidFixedBC(FEModel* pfem) : FERigidBC(pfem)
{
}
//=============================================================================
BEGIN_FECORE_CLASS(FERigidFixedBCNew, FERigidFixedBC)
ADD_PARAMETER(m_rigidMat, "rb")->setEnums("$(rigid_materials)")->setLongName("Rigid material");
ADD_PARAMETER(m_dof[0], "Rx_dof")->setLongName("X-displacement");
ADD_PARAMETER(m_dof[1], "Ry_dof")->setLongName("Y-displacement");
ADD_PARAMETER(m_dof[2], "Rz_dof")->setLongName("Z-displacement");
ADD_PARAMETER(m_dof[3], "Ru_dof")->setLongName("X-rotation");
ADD_PARAMETER(m_dof[4], "Rv_dof")->setLongName("Y-rotation");
ADD_PARAMETER(m_dof[5], "Rw_dof")->setLongName("Z-rotation");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidFixedBCNew::FERigidFixedBCNew(FEModel* pfem) : FERigidFixedBC(pfem)
{
for (int i = 0; i < 6; ++i) m_dof[i] = false;
m_binit = false;
}
//-----------------------------------------------------------------------------
void FERigidFixedBCNew::Activate()
{
FERigidFixedBC::Activate();
if (m_binit == false) Init();
if (m_binit)
{
FERigidBody& RB = GetRigidBody();
// we only fix the open dofs. If a user accidentally applied a fixed and prescribed
// rigid degree of freedom, then we make sure the prescribed takes precedence.
for (int i = 0; i < 6; ++i)
{
if (m_dof[i] && (RB.m_BC[i] == DOF_OPEN)) RB.m_BC[i] = DOF_FIXED;
}
}
}
//-----------------------------------------------------------------------------
void FERigidFixedBCNew::Deactivate()
{
if (m_binit)
{
FERigidBody& RB = GetRigidBody();
// Since fixed rigid dofs can be overwritten by prescribed dofs,
// we have to make sure that this dof is actually a fixed dof.
for (int i = 0; i < 6; ++i)
{
if (m_dof[i] && (RB.m_BC[i] == DOF_FIXED)) RB.m_BC[i] = DOF_OPEN;
}
}
FERigidBC::Deactivate();
}
//=============================================================================
BEGIN_FECORE_CLASS(FERigidFixedBCOld, FERigidFixedBC)
ADD_PARAMETER(m_rigidMat, "rb")->setEnums("$(rigid_materials)")->setLongName("Rigid material");
ADD_PARAMETER(m_dofs, "dofs", 0, "Rx\0Ry\0Rz\0Ru\0Rv\0Rw\0");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidFixedBCOld::FERigidFixedBCOld(FEModel* pfem) : FERigidFixedBC(pfem)
{
}
//-----------------------------------------------------------------------------
bool FERigidFixedBCOld::Init()
{
// make sure we have a valid dof
// TODO: Can I test this automatically during validation?
for (int i = 0; i < m_dofs.size(); ++i)
{
int dof_i = m_dofs[i];
if ((dof_i < 0) || (dof_i >= 6))
{
feLogError("Invalid value for dofs of fixed rigid constraint %s", GetName().c_str());
return false;
}
}
return FERigidFixedBC::Init();
}
//-----------------------------------------------------------------------------
void FERigidFixedBCOld::Activate()
{
FERigidFixedBC::Activate();
if (m_binit == false) Init();
if (m_binit)
{
FERigidBody& RB = GetRigidBody();
// we only fix the open dofs. If a user accidentally applied a fixed and prescribed
// rigid degree of freedom, then we make sure the prescribed takes precedence.
for (int i = 0; i < m_dofs.size(); ++i)
{
int dof_i = m_dofs[i];
if (RB.m_BC[dof_i] == DOF_OPEN) RB.m_BC[dof_i] = DOF_FIXED;
}
}
}
//-----------------------------------------------------------------------------
void FERigidFixedBCOld::Deactivate()
{
if (m_binit)
{
FERigidBody& RB = GetRigidBody();
// Since fixed rigid dofs can be overwritten by prescribed dofs,
// we have to make sure that this dof is actually a fixed dof.
for (int i = 0; i < m_dofs.size(); ++i)
{
int dof_i = m_dofs[i];
if (RB.m_BC[dof_i] == DOF_FIXED) RB.m_BC[dof_i] = DOF_OPEN;
}
}
}
//=============================================================================
FERigidPrescribedBC::FERigidPrescribedBC(FEModel* pfem) : FERigidBC(pfem)
{
m_dof = -1;
m_val = 0.0;
m_ref= 0.0;
m_brel = false;
m_binit = false;
}
//-----------------------------------------------------------------------------
bool FERigidPrescribedBC::Init()
{
// make sure we have a valid dof
if ((m_dof < 0)||(m_dof >=6)) return false;
m_binit = true;
return FERigidBC::Init();
}
//-----------------------------------------------------------------------------
void FERigidPrescribedBC::Activate()
{
// don't forget to call the base class
FERigidBC::Activate();
if (m_binit == false) Init();
// get the rigid body
FERigidBody& RB = GetRigidBody();
// set some stuff
RB.m_pDC[m_dof] = this;
// mark the dof as prescribed
RB.m_BC[m_dof] = DOF_PRESCRIBED;
// set the relative offset
m_ref = 0.0;
if (m_brel)
{
quatd Q = RB.GetRotation();
vec3d q = Q.GetRotationVector();
switch (m_dof)
{
case 0: m_ref = RB.m_rt.x - RB.m_r0.x; break;
case 1: m_ref = RB.m_rt.y - RB.m_r0.y; break;
case 2: m_ref = RB.m_rt.z - RB.m_r0.z; break;
case 3: m_ref = q.x; break;
case 4: m_ref = q.y; break;
case 5: m_ref = q.z; break;
}
}
}
//-----------------------------------------------------------------------------
void FERigidPrescribedBC::Deactivate()
{
FERigidBC::Deactivate();
// get the rigid body
// Since Deactivate is called before Init (for multi-step analysis; in the FEBio input)
// we have to make sure the data is initialized
if (m_binit)
{
FERigidBody& RB = GetRigidBody();
// turn off the prescribed displacement
RB.m_pDC[m_dof] = 0;
RB.m_BC[m_dof] = DOF_OPEN;
}
}
//-----------------------------------------------------------------------------
void FERigidPrescribedBC::Serialize(DumpStream& ar)
{
FERigidBC::Serialize(ar);
if (ar.IsShallow()) return;
ar & m_dof & m_ref & m_binit & m_brel;
}
//-----------------------------------------------------------------------------
double FERigidPrescribedBC::Value()
{
return m_val + m_ref;
}
//-----------------------------------------------------------------------------
void FERigidPrescribedBC::InitTimeStep()
{
FERigidBody& RB = GetRigidBody();
int I = GetBC();
RB.m_dul[I] = Value() - RB.m_Ut[I];
}
//===============================================================================
BEGIN_FECORE_CLASS(FERigidDisplacement, FERigidPrescribedBC)
ADD_PARAMETER(m_rigidMat, "rb")->setEnums("$(rigid_materials)")->setLongName("Rigid material");
ADD_PARAMETER(m_bc, "dof", 0, "$(dof_list:displacement)");
ADD_PARAMETER(m_val, "value")->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE)->setUnits(UNIT_LENGTH);
ADD_PARAMETER(m_brel, "relative");
END_FECORE_CLASS();
FERigidDisplacement::FERigidDisplacement(FEModel* fem) : FERigidPrescribedBC(fem)
{
m_bc = -1;
}
bool FERigidDisplacement::Init()
{
int dofX = GetDOFIndex("x");
int dofY = GetDOFIndex("y");
int dofZ = GetDOFIndex("z");
if (m_bc == dofX) m_dof = 0;
if (m_bc == dofY) m_dof = 1;
if (m_bc == dofZ) m_dof = 2;
return FERigidPrescribedBC::Init();
}
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidRotation, FERigidPrescribedBC)
ADD_PARAMETER(m_rigidMat, "rb")->setEnums("$(rigid_materials)")->setLongName("Rigid material");
ADD_PARAMETER(m_bc, "dof", 0, "$(dof_list:rigid rotation)");
ADD_PARAMETER(m_val, "value")->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE)->setUnits(UNIT_RADIAN);
ADD_PARAMETER(m_brel, "relative");
END_FECORE_CLASS();
FERigidRotation::FERigidRotation(FEModel* fem) : FERigidPrescribedBC(fem)
{
m_bc = -1;
}
bool FERigidRotation::Init()
{
int dofRu = GetDOFIndex("Ru");
int dofRv = GetDOFIndex("Rv");
int dofRw = GetDOFIndex("Rw");
if (m_bc == dofRu) m_dof = 3;
if (m_bc == dofRv) m_dof = 4;
if (m_bc == dofRw) m_dof = 5;
return FERigidPrescribedBC::Init();
}
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidPrescribedOld, FERigidPrescribedBC)
ADD_PARAMETER(m_rigidMat, "rb")->setEnums("$(rigid_materials)")->setLongName("Rigid material");
ADD_PARAMETER(m_dof, "dof", 0, "Rx\0Ry\0Rz\0Ru\0Rv\0Rw\0");
ADD_PARAMETER(m_val, "value");
ADD_PARAMETER(m_brel, "relative");
END_FECORE_CLASS();
FERigidPrescribedOld::FERigidPrescribedOld(FEModel* fem) : FERigidPrescribedBC(fem) {}
//=============================================================================
BEGIN_FECORE_CLASS(FERigidIC, FEInitialCondition)
ADD_PARAMETER(m_rigidMat, "rb")->setEnums("$(rigid_materials)")->setLongName("Rigid material");
END_FECORE_CLASS();
FERigidIC::FERigidIC(FEModel* fem) : FEInitialCondition(fem)
{
m_rigidMat = -1;
m_rb = -1;
}
bool FERigidIC::Init()
{
FEModel& fem = *GetFEModel();
int matIndex = m_rigidMat - 1;
if ((matIndex < 0) || (matIndex >= fem.Materials()))
{
feLogError("Invalid value for rb");
return false;
}
// Make sure the rigid material ID is valid
FERigidMaterial* pm = dynamic_cast<FERigidMaterial*>(fem.GetMaterial(matIndex));
if (pm == nullptr) return false;
return FEInitialCondition::Init();
}
void FERigidIC::Activate()
{
// Get the Rigidbody ID
FEModel& fem = *GetFEModel();
FERigidMaterial* pm = dynamic_cast<FERigidMaterial*>(fem.GetMaterial(m_rigidMat - 1)); assert(pm);
m_rb = pm->GetRigidBodyID(); assert(m_rb >= 0);
FEInitialCondition::Activate();
}
void FERigidIC::Serialize(DumpStream& ar)
{
ar& m_rb;
FEInitialCondition::Serialize(ar);
}
FERigidBody& FERigidIC::GetRigidBody()
{
FEMechModel& fem = static_cast<FEMechModel&>(*GetFEModel());
FERigidBody& RB = *fem.GetRigidBody(m_rb);
return RB;
}
//=============================================================================
BEGIN_FECORE_CLASS(FERigidBodyVelocity, FERigidIC)
ADD_PARAMETER(m_vel, "value")->setUnits(UNIT_VELOCITY);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidBodyVelocity::FERigidBodyVelocity(FEModel* pfem) : FERigidIC(pfem)
{
m_vel = vec3d(0, 0, 0);
}
//-----------------------------------------------------------------------------
void FERigidBodyVelocity::Activate()
{
FERigidIC::Activate();
FERigidBody& RB = GetRigidBody();
RB.m_vp = RB.m_vt = m_vel;
}
//=============================================================================
BEGIN_FECORE_CLASS(FERigidBodyAngularVelocity, FERigidIC)
ADD_PARAMETER(m_w, "value")->setUnits(UNIT_ANGULAR_VELOCITY);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidBodyAngularVelocity::FERigidBodyAngularVelocity(FEModel* pfem) : FERigidIC(pfem)
{
m_w = vec3d(0, 0, 0);
}
//-----------------------------------------------------------------------------
void FERigidBodyAngularVelocity::Activate()
{
FERigidIC::Activate();
FERigidBody& RB = GetRigidBody();
RB.m_wp = RB.m_wt = m_w;
// TODO: We need to set the initial angular momentum as well,
// but I'd rather have the RB do this somewhere else instead.
RB.m_hp = RB.m_ht = RB.m_moi * m_w;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidShellDomain.h | .h | 4,604 | 147 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticShellDomain.h"
#include "FEElasticShellDomainOld.h"
class FEBodyForce;
class FERigidMaterial;
//-----------------------------------------------------------------------------
//! domain class for 3D rigid shell elements
//!
class FERigidShellDomainOld : public FEElasticShellDomainOld
{
public:
//! constructor
FERigidShellDomainOld(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 internal forces (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;
};
//-----------------------------------------------------------------------------
// Implements a rigid shell domain. We need to inherit from FEShellDomain and FEElasticDomain.
// The latter is needed because most of the solid solver classes assume that domains inherit this class.
class FERigidShellDomain : public FEShellDomain, public FEElasticDomain
{
public:
FERigidShellDomain(FEModel* fem);
public: // from FEMeshPartition
//! return number of elements
int Elements() const override { return (int)m_Elem.size(); };
//! return a reference to an element \todo this is not the preferred interface but I've added it for now
FEElement& ElementRef(int i) override { return m_Elem[i]; };
const FEElement& ElementRef(int i) const override { return m_Elem[i]; };
public: // from FEDomain
// create function
bool Create(int elements, FE_Element_Spec espec) override;
void Activate() override;
const FEDofList& GetDOFList() const override { return m_dof; }
void Update(const FETimeInfo& tp) override;
void Reset() override;
void SetMaterial(FEMaterial* pm) override;
//! get the material (overridden from FEDomain)
FEMaterial* GetMaterial() override;
public: // from FEShellDomain
// get a shell element
FEShellElement& Element(int i) override { return m_Elem[i]; }
void AssignDefaultShellThickness() override;
public: // from FEElasticDomain
void InternalForces(FEGlobalVector& R) override;
void BodyForce(FEGlobalVector& R, FEBodyForce& bf) override;
void InertialForces(FEGlobalVector& R, std::vector<double>& F) override;
void StiffnessMatrix(FELinearSystem& LS) override;
void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override;
void MassMatrix(FELinearSystem& LS, double scale) override;
public:
// calculate contribution of MOI for this domain
mat3d CalculateMOI();
double CalculateMass();
vec3d CalculateCOM();
private:
//! Calculate extenral body forces for shell elements
void ElementBodyForce(FEBodyForce& BF, FEShellElement& el, vector<double>& fe);
void ElementBodyForceStiffness(FEBodyForce& BF, FEShellElement& el, matrix& ke);
public:
double detJ0(FEShellElement& el, int n);
protected:
double m_h0; // TODO: move to base class?
protected:
std::vector<FEShellElement> m_Elem;
FEDofList m_dof;
FERigidMaterial* m_pMat;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERVEDamageMaterial.h | .h | 3,042 | 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 "FEReactiveViscoelastic.h"
#include "FEDamageMaterialPoint.h"
#include "FEDamageCriterion.h"
#include "FEDamageCDF.h"
//-----------------------------------------------------------------------------
// This material models damage in any reactive viscoelastic material.
class FERVEDamageMaterial : public FEElasticMaterial
{
public:
FERVEDamageMaterial(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; }
//! 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
FEElasticMaterial* m_pBase; // base strong bond material
FEDamageCDF* m_pDamg; // damage model
FEDamageCriterion* m_pCrit; // damage criterion
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEGenericRigidJoint.h | .h | 3,070 | 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.*/
#pragma once
#include <FECore/vec3d.h>
#include "FERigidConnector.h"
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
class FEBIOMECH_API FEGenericRigidJoint : public FERigidConnector
{
public:
FEGenericRigidJoint(FEModel* fem);
//! initialization
bool Init() override;
// allocate equations
int InitEquations(int neq) override;
//! calculates the joint forces
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
//! calculates the joint stiffness
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
//! calculate Lagrangian augmentation
bool Augment(int naug, const FETimeInfo& tp) override;
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! update state
void Update() override;
//! Reset data
void Reset() override;
//! initial position
vec3d InitialPosition() const;
//! current position
vec3d Position() const;
protected:
void UnpackLM(vector<int>& lm);
// Build the matrix profile
void BuildMatrixProfile(FEGlobalMatrix& M) override;
void Update(const std::vector<double>& Ui, const std::vector<double>& ui) override;
void UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) override;
void PrepStep() override;
protected:
//! stiffness matrix for penalty and augmented Lagrangian
void StiffnessMatrixAL(FELinearSystem& LS, const FETimeInfo& tp);
//! stiffness matrix for Lagrange Multipliers
void StiffnessMatrixLM(FELinearSystem& LS, const FETimeInfo& tp);
private:
int m_laugon;
double m_eps;
double m_tol;
vec3d m_q0;
bool m_bsymm;
private:
vec3d m_qa0;
vec3d m_qb0;
bool m_bc[6];
vec3d m_v0[3];
double m_dc[6];
int m_EQ[6];
double m_Lm[6], m_Lmp[6];
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEDiscreteContact.cpp | .cpp | 22,804 | 945 | /*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 "FEDiscreteContact.h"
#include <FECore/FEModel.h>
#include <FECore/FEGlobalMatrix.h>
#include "FEContactInterface.h"
#include <FECore/FEClosestPointProjection.h>
#include <FECore/FELinearSystem.h>
#include <FECore/log.h>
FEDiscreteContactSurface::FEDiscreteContactSurface(FEModel* fem) : FEContactSurface(fem)
{
}
bool FEDiscreteContactSurface::Init()
{
return FEContactSurface::Init();
}
BEGIN_FECORE_CLASS(FEDiscreteContact, FESurfaceConstraint)
ADD_PARAMETER(m_blaugon, "laugon");
ADD_PARAMETER(m_altol , FE_RANGE_GREATER_OR_EQUAL(0.0), "altol");
ADD_PARAMETER(m_gaptol , FE_RANGE_GREATER_OR_EQUAL(0.0), "gaptol");
ADD_PARAMETER(m_penalty, FE_RANGE_GREATER_OR_EQUAL(0.0), "penalty");
ADD_PARAMETER(m_naugmin, "minaug");
ADD_PARAMETER(m_naugmax, "maxaug");
ADD_PARAMETER(m_nsegup , "segup");
END_FECORE_CLASS();
FEDiscreteContact::FEDiscreteContact(FEModel* pfem) : FESurfaceConstraint(pfem), m_surf(pfem)
{
m_blaugon = false;
m_altol = 0.01;
m_penalty = 1.0;
m_gaptol = 0.0;
m_naugmin = 0;
m_naugmax = 100;
m_bfirst = true;
m_nsegup = 0;
}
bool FEDiscreteContact::Init()
{
return m_surf.Init();
}
void FEDiscreteContact::Activate()
{
FENLConstraint::Activate();
ProjectSurface(true);
}
void FEDiscreteContact::Update(const FETimeInfo& tp)
{
bool bupdate = (m_bfirst || (m_nsegup == 0)? true : (tp.currentIteration <= m_nsegup));
ProjectSurface(true);
m_bfirst = false;
}
void FEDiscreteContact::SetDiscreteSet(FEDiscreteSet* pset)
{
FEMesh& mesh = GetFEModel()->GetMesh();
vector<int> tag(mesh.Nodes(), 0);
m_Node.clear();
int nsize = pset->size();
for (int i=0; i<nsize; ++i)
{
const FEDiscreteSet::NodePair& delem = pset->Element(i);
tag[delem.n0] = 1;
tag[delem.n1] = 1;
}
for (int i=0; i<mesh.Nodes(); ++i)
{
if (tag[i])
{
NODE node;
node.nid = i;
node.pe = 0;
node.Lm = 0;
node.gap = 0;
node.nu = vec3d(0,0,0);
node.q = vec3d(0,0,0);
node.proj[0] = node.proj[1] = 0.0;
m_Node.push_back(node);
}
}
}
void FEDiscreteContact::ProjectSurface(bool bsegup)
{
FEClosestPointProjection cpp(m_surf);
cpp.SetTolerance(0.01);
cpp.SetSearchRadius(0.0);
cpp.HandleSpecialCases(true);
cpp.Init();
// loop over all primary nodes
FEMesh& mesh = *m_surf.GetMesh();
for (int i=0; i<(int)m_Node.size(); ++i)
{
NODE& nodeData = m_Node[i];
// get the node
FENode& node = mesh.Node(nodeData.nid);
// get the nodal position
vec3d x = node.m_rt;
// If the node is in contact, let's see if the node still is
// on the same secondary element
if (nodeData.pe != 0)
{
FESurfaceElement& mel = *nodeData.pe;
double r = nodeData.proj[0];
double s = nodeData.proj[1];
vec3d q = m_surf.ProjectToSurface(mel, x, r, s);
nodeData.proj[0] = r;
nodeData.proj[1] = s;
nodeData.q = q;
if (bsegup && (!m_surf.IsInsideElement(mel, r, s, 0.01)))
{
// see if the node might have moved to another secondary element
vec2d rs(0,0);
nodeData.pe = cpp.Project(x, q, rs);
nodeData.proj[0] = rs.x();
nodeData.proj[1] = rs.y();
nodeData.q = q;
}
}
else if (bsegup)
{
vec2d rs(0,0); vec3d q;
nodeData.pe = cpp.Project(x, q, rs);
nodeData.proj[0] = rs.x();
nodeData.proj[1] = rs.y();
nodeData.q = q;
}
// if we found a secondary element, update the gap and normal data
if (nodeData.pe != 0)
{
FESurfaceElement& mel = *nodeData.pe;
double r = nodeData.proj[0];
double s = nodeData.proj[1];
// the primary normal is set to the secondary element normal
nodeData.nu = m_surf.SurfaceNormal(mel, r, s);
// calculate gap
nodeData.gap = -(nodeData.nu*(x - nodeData.q));
}
else
{
// TODO: Is this a good criteria for out-of-contact?
// perhaps this is not even necessary.
// since the node is not in contact, we set the gap function
// and Lagrangian multiplier to zero
nodeData.gap = 0;
nodeData.Lm = 0;
}
}
}
void FEDiscreteContact::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
// element contact force vector
vector<double> fe;
// the lm array for this force vector
vector<int> lm;
// the en array
vector<int> en;
// the elements LM vectors
vector<int> mLM;
// loop over all primary nodes
FEMesh& mesh = *m_surf.GetMesh();
int nodes = (int) m_Node.size();
for (int i=0; i<nodes; ++i)
{
NODE& nodeData = m_Node[i];
FENode& node = mesh.Node(nodeData.nid);
vector<int>& sLM = node.m_ID;
FESurfaceElement* pe = nodeData.pe;
// see if this node's constraint is active
// that is, if it has a secondary element associated with it
// TODO: is this a good way to test for an active constraint
// The rigid wall criteria seems to work much better.
if (pe != 0)
{
// This node is active and could lead to a non-zero
// contact force.
// get the secondary element
FESurfaceElement& mel = *pe;
m_surf.UnpackLM(mel, mLM);
// calculate the degrees of freedom
int nmeln = mel.Nodes();
int ndof = 3*(nmeln+1);
fe.resize(ndof);
// calculate the nodal force
ContactNodalForce(nodeData, mel, fe);
// fill the lm array
lm.resize(3*(nmeln+1));
lm[0] = sLM[0];
lm[1] = sLM[1];
lm[2] = sLM[2];
for (int l=0; l<nmeln; ++l)
{
lm[3*(l+1) ] = mLM[l*3 ];
lm[3*(l+1)+1] = mLM[l*3+1];
lm[3*(l+1)+2] = mLM[l*3+2];
}
// fill the en array
en.resize(nmeln+1);
en[0] = nodeData.nid;
for (int l=0; l<nmeln; ++l) en[l+1] = mel.m_node[l];
// assemble into global force vector
R.Assemble(en, lm, fe);
}
}
}
void FEDiscreteContact::ContactNodalForce(FEDiscreteContact::NODE& nodeData, FESurfaceElement& mel, vector<double>& fe)
{
// max nr of secondary element nodes
const int MAXMN = FEElement::MAX_NODES;
// secondary element nodes
vec3d rtm[MAXMN];
// secondary shape function values at projection point
double H[MAXMN];
// contact forces
double N[3*(MAXMN+1)];
// get the mesh
FEMesh& mesh = *m_surf.GetMesh();
// gap function
double gap = nodeData.gap;
// penalty
double eps = m_penalty;
// get primary node normal force
double Ln = nodeData.Lm;
double tn = Ln + eps*gap;
tn = MBRACKET(tn);
// get the primary node normal
vec3d nu = nodeData.nu;
int nmeln = mel.Nodes();
int ndof = 3*(1 + nmeln);
// get the secondary element node positions
for (int k=0; k<nmeln; ++k) rtm[k] = mesh.Node(mel.m_node[k]).m_rt;
// isoparametric coordinates of the projected primary node
// onto the secondary element
double r = nodeData.proj[0];
double s = nodeData.proj[1];
// get the secondary shape function values at this primary node
mel.shape_fnc(H, r, s);
// calculate contact vectors for normal traction
N[0] = nu.x;
N[1] = nu.y;
N[2] = nu.z;
for (int l=0; l<nmeln; ++l)
{
N[3*(l+1) ] = -H[l]*nu.x;
N[3*(l+1)+1] = -H[l]*nu.y;
N[3*(l+1)+2] = -H[l]*nu.z;
}
// calculate force vector
for (int l=0; l<ndof; ++l) fe[l] = tn*N[l];
}
void FEDiscreteContact::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
FEElementMatrix ke;
const int MAXMN = FEElement::MAX_NODES;
vector<int> lm(3*(MAXMN + 1));
vector<int> en(MAXMN+1);
vector<int> sLM;
vector<int> mLM;
// loop over all integration points (that is nodes)
FEMesh& mesh = *m_surf.GetMesh();
int nodes = (int) m_Node.size();
for (int i=0; i<nodes; ++i)
{
NODE& nodeData = m_Node[i];
vector<int>& sLM = mesh.Node(nodeData.nid).m_ID;
// see if this node's constraint is active
// that is, if it has a secondary element associated with it
if (nodeData.pe != 0)
{
// get the secondary element
FESurfaceElement& me = *nodeData.pe;
// get the secondary surface element's LM array
m_surf.UnpackLM(me, mLM);
int nmeln = me.Nodes();
int ndof = 3*(nmeln+1);
// calculate the stiffness matrix
ke.resize(ndof, ndof);
ContactNodalStiffness(nodeData, me, ke);
// fill the lm array
lm[0] = sLM[0];
lm[1] = sLM[1];
lm[2] = sLM[2];
for (int k=0; k<nmeln; ++k)
{
lm[3*(k+1) ] = mLM[k*3 ];
lm[3*(k+1)+1] = mLM[k*3+1];
lm[3*(k+1)+2] = mLM[k*3+2];
}
// create the en array
en.resize(nmeln+1);
en[0] = nodeData.nid;
for (int k=0; k<nmeln; ++k) en[k+1] = me.m_node[k];
// assemble stiffness matrix
ke.SetNodes(en);
ke.SetIndices(lm);
LS.Assemble(ke);
}
}
}
void FEDiscreteContact::ContactNodalStiffness(FEDiscreteContact::NODE& nodeData, FESurfaceElement& mel, matrix& ke)
{
const int MAXMN = FEElement::MAX_NODES;
vector<int> lm(3*(MAXMN+1));
vector<int> en(MAXMN + 1);
double H[MAXMN], Hr[MAXMN], Hs[MAXMN];
double N[3*(MAXMN+1)], T1[3*(MAXMN+1)], T2[3*(MAXMN+1)];
double N1[3*(MAXMN+1)], N2[3*(MAXMN+1)], D1[3*(MAXMN+1)], D2[3*(MAXMN+1)];
double Nb1[3*(MAXMN+1)], Nb2[3*(MAXMN+1)];
// get the mesh
FEMesh& mesh = *m_surf.GetMesh();
// nr of element nodes and degrees of freedom
int nmeln = mel.Nodes();
int ndof = 3*(1 + nmeln);
// penalty factor
double eps = m_penalty;
// nodal coordinates
vec3d rt[MAXMN];
for (int j=0; j<nmeln; ++j) rt[j] = mesh.Node(mel.m_node[j]).m_rt;
// primary node natural coordinates in secondary element
double r = nodeData.proj[0];
double s = nodeData.proj[1];
// primary gap
double gap = nodeData.gap;
// lagrange multiplier
double Lm = nodeData.Lm;
// get primary node normal force
double tn = Lm + eps*gap;
tn = MBRACKET(tn);
// get the primary node normal
vec3d nu = nodeData.nu;
// get the secondary shape function values and the derivatives at this primary node
mel.shape_fnc(H, r, s);
mel.shape_deriv(Hr, Hs, r, s);
// get the tangent vectors
vec3d tau[2];
m_surf.CoBaseVectors(mel, r, s, tau);
// set up the N vector
N[0] = nu.x;
N[1] = nu.y;
N[2] = nu.z;
for (int k=0; k<nmeln; ++k)
{
N[(k+1)*3 ] = -H[k]*nu.x;
N[(k+1)*3+1] = -H[k]*nu.y;
N[(k+1)*3+2] = -H[k]*nu.z;
}
// set up the Ti vectors
T1[0] = tau[0].x; T2[0] = tau[1].x;
T1[1] = tau[0].y; T2[1] = tau[1].y;
T1[2] = tau[0].z; T2[2] = tau[1].z;
for (int k=0; k<nmeln; ++k)
{
T1[(k+1)*3 ] = -H[k]*tau[0].x;
T1[(k+1)*3+1] = -H[k]*tau[0].y;
T1[(k+1)*3+2] = -H[k]*tau[0].z;
T2[(k+1)*3 ] = -H[k]*tau[1].x;
T2[(k+1)*3+1] = -H[k]*tau[1].y;
T2[(k+1)*3+2] = -H[k]*tau[1].z;
}
// set up the Ni vectors
N1[0] = N2[0] = 0;
N1[1] = N2[1] = 0;
N1[2] = N2[2] = 0;
for (int k=0; k<nmeln; ++k)
{
N1[(k+1)*3 ] = -Hr[k]*nu.x;
N1[(k+1)*3+1] = -Hr[k]*nu.y;
N1[(k+1)*3+2] = -Hr[k]*nu.z;
N2[(k+1)*3 ] = -Hs[k]*nu.x;
N2[(k+1)*3+1] = -Hs[k]*nu.y;
N2[(k+1)*3+2] = -Hs[k]*nu.z;
}
// calculate metric tensor
mat2d M;
M[0][0] = tau[0]*tau[0]; M[0][1] = tau[0]*tau[1];
M[1][0] = tau[1]*tau[0]; M[1][1] = tau[1]*tau[1];
// calculate reciprocal metric tensor
mat2d Mi = M.inverse();
// calculate curvature tensor
double K[2][2] = {0};
double Grr[FEElement::MAX_NODES];
double Grs[FEElement::MAX_NODES];
double Gss[FEElement::MAX_NODES];
mel.shape_deriv2(Grr, Grs, Gss, r, s);
for (int k=0; k<nmeln; ++k)
{
K[0][0] += (nu*rt[k])*Grr[k];
K[0][1] += (nu*rt[k])*Grs[k];
K[1][0] += (nu*rt[k])*Grs[k];
K[1][1] += (nu*rt[k])*Gss[k];
}
// setup A matrix A = M + gK
double A[2][2];
A[0][0] = M[0][0] + gap*K[0][0];
A[0][1] = M[0][1] + gap*K[0][1];
A[1][0] = M[1][0] + gap*K[1][0];
A[1][1] = M[1][1] + gap*K[1][1];
// calculate determinant of A
double detA = A[0][0]*A[1][1] - A[0][1]*A[1][0];
// setup Di vectors
for (int k=0; k<ndof; ++k)
{
D1[k] = (1/detA)*(A[1][1]*(T1[k]+gap*N1[k]) - A[0][1]*(T2[k] + gap*N2[k]));
D2[k] = (1/detA)*(A[0][0]*(T2[k]+gap*N2[k]) - A[0][1]*(T1[k] + gap*N1[k]));
}
// setup Nbi vectors
for (int k=0; k<ndof; ++k)
{
Nb1[k] = N1[k] - K[0][1]*D2[k];
Nb2[k] = N2[k] - K[0][1]*D1[k];
}
// --- N O R M A L S T I F F N E S S ---
double sum;
for (int k=0; k<ndof; ++k)
for (int l=0; l<ndof; ++l)
{
sum = 0;
sum = Mi[0][0]*Nb1[k]*Nb1[l]+Mi[0][1]*(Nb1[k]*Nb2[l]+Nb2[k]*Nb1[l])+Mi[1][1]*Nb2[k]*Nb2[l];
sum *= gap;
sum -= D1[k]*N1[l]+D2[k]*N2[l]+N1[k]*D1[l]+N2[k]*D2[l];
sum += K[0][1]*(D1[k]*D2[l]+D2[k]*D1[l]);
sum *= tn;
sum += eps*HEAVYSIDE(Lm+eps*gap)*N[k]*N[l];
ke[k][l] = sum;
}
}
bool FEDiscreteContact::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (!m_blaugon) return true;
bool bconv = true;
mat2d Mi;
// penalty factor
double eps = m_penalty;
// --- c a l c u l a t e i n i t i a l n o r m s ---
double normL0 = 0;
for (int i=0; i<(int) m_Node.size(); ++i) normL0 += m_Node[i].Lm * m_Node[i].Lm;
normL0 = sqrt(normL0);
// --- c a l c u l a t e c u r r e n t n o r m s ---
double normL1 = 0; // force norm
double normg1 = 0; // gap norm
int N = 0;
for (int i=0; i<(int)m_Node.size(); ++i)
{
// update Lagrange multipliers
double Ln = m_Node[i].Lm + eps*m_Node[i].gap;
Ln = MBRACKET(Ln);
normL1 += Ln*Ln;
if (m_Node[i].gap > 0)
{
normg1 += m_Node[i].gap*m_Node[i].gap;
++N;
}
}
if (N == 0) N=1;
normL1 = sqrt(normL1);
normg1 = sqrt(normg1 / N);
if (naug == 0) m_normg0 = 0;
// calculate and print convergence norms
double lnorm = 0, gnorm = 0;
if (normL1 != 0) lnorm = fabs(normL1 - normL0)/normL1; else lnorm = fabs(normL1 - normL0);
if (normg1 != 0) gnorm = fabs(normg1 - m_normg0)/normg1; else gnorm = fabs(normg1 - m_normg0);
feLog(" discrete contact # %d\n", GetID());
feLog(" CURRENT REQUIRED\n");
feLog(" normal force : %15le", lnorm);
if (m_altol > 0) feLog("%15le\n", m_altol); else feLog(" ***\n");
feLog(" gap function : %15le", gnorm);
if (m_gaptol > 0) feLog("%15le\n", m_gaptol); else feLog(" ***\n");
// check convergence
bconv = true;
if ((m_altol > 0) && (lnorm > m_altol)) bconv = false;
if ((m_gaptol > 0) && (gnorm > m_gaptol)) bconv = false;
if (m_naugmin > naug) bconv = false;
if (m_naugmax <= naug) bconv = true;
if (bconv == false)
{
// we did not converge so update multipliers
for (int i=0; i<(int) m_Node.size(); ++i)
{
NODE& node = m_Node[i];
// update Lagrange multipliers
double Ln = node.Lm + eps*node.gap;
node.Lm = MBRACKET(Ln);
}
}
// store the last gap norm
m_normg0 = normg1;
return bconv;
}
void FEDiscreteContact::BuildMatrixProfile(FEGlobalMatrix& K)
{
// TODO: this is currently for max 6 nodes (hence 7=6+1)
vector<int> lm(6*7);
FEModel& fem = *GetFEModel();
FEMesh& mesh = fem.GetMesh();
// 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");
const int nodes = (int) m_Node.size();
for (int i=0; i<nodes; ++i)
{
NODE& nodeData = m_Node[i];
// get the FE node
FENode& node = mesh.Node(nodeData.nid);
// get the secondary surface element
FESurfaceElement* pe = nodeData.pe;
if (pe != 0)
{
FESurfaceElement& me = *pe;
int* en = &me.m_node[0];
// Note that we need to grab the rigid degrees of freedom as well
// this is in case one of the nodes belongs to a rigid body.
int n = me.Nodes();
if (n == 3)
{
lm[6*(3+1) ] = -1;lm[6*(3+2) ] = -1;lm[6*(3+3) ] = -1;
lm[6*(3+1)+1] = -1;lm[6*(3+2)+1] = -1;lm[6*(3+3)+1] = -1;
lm[6*(3+1)+2] = -1;lm[6*(3+2)+2] = -1;lm[6*(3+3)+2] = -1;
lm[6*(3+1)+3] = -1;lm[6*(3+2)+3] = -1;lm[6*(3+3)+3] = -1;
lm[6*(3+1)+4] = -1;lm[6*(3+2)+4] = -1;lm[6*(3+3)+4] = -1;
lm[6*(3+1)+5] = -1;lm[6*(3+2)+5] = -1;lm[6*(3+3)+5] = -1;
}
if (n == 4)
{
lm[6*(4+1) ] = -1;lm[6*(4+2) ] = -1;
lm[6*(4+1)+1] = -1;lm[6*(4+2)+1] = -1;
lm[6*(4+1)+2] = -1;lm[6*(4+2)+2] = -1;
lm[6*(4+1)+3] = -1;lm[6*(4+2)+3] = -1;
lm[6*(4+1)+4] = -1;lm[6*(4+2)+4] = -1;
lm[6*(4+1)+5] = -1;lm[6*(4+2)+5] = -1;
}
lm[0] = node.m_ID[dof_X];
lm[1] = node.m_ID[dof_Y];
lm[2] = node.m_ID[dof_Z];
lm[3] = node.m_ID[dof_RU];
lm[4] = node.m_ID[dof_RV];
lm[5] = node.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);
}
}
}
//=============================================================================
BEGIN_FECORE_CLASS(FEDiscreteContact2, FESurfaceConstraint);
END_FECORE_CLASS();
FEDiscreteContact2::FEDiscreteContact2(FEModel* fem) : FESurfaceConstraint(fem), m_surf(fem)
{
m_dom = 0;
}
bool FEDiscreteContact2::Init()
{
// let's make sure we have a discrete domain set
if (m_dom == 0) return false;
// initialize node data
int NN = m_dom->Nodes();
m_nodeData.resize(NN);
for (int i=0; i<NN; ++i)
{
NODE& nd = m_nodeData[i];
nd.node = i;
nd.pe = 0;
}
// initialize surface
if (m_surf.Init() == false) return false;
// let's do base class initiialization
return FENLConstraint::Init();
}
void FEDiscreteContact2::Activate()
{
FENLConstraint::Activate();
ProjectNodes();
}
void FEDiscreteContact2::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
int NN = m_dom->Nodes();
FEMesh& mesh = *m_surf.GetMesh();
// skip first and last
for (int n=1; n<NN-1; ++n)
{
if (m_dom->IsAnchored(n))
{
NODE& nodeData = m_nodeData[n];
assert(nodeData.pe);
FESurfaceElement& el = *nodeData.pe;
double r = nodeData.proj[0];
double s = nodeData.proj[1];
double H[FEElement::MAX_NODES];
int neln = el.Nodes();
el.shape_fnc(H, r, s);
vec3d F = m_dom->NodalForce(n);
vec3d nu = nodeData.nu;
if (F*nu < 0.0)
{
vector<double> fe(3*neln, 0.0);
for (int i=0; i<neln; ++i)
{
fe[3*i ] = H[i]*F.x;
fe[3*i+1] = H[i]*F.y;
fe[3*i+2] = H[i]*F.z;
}
vector<int> lm(3*neln, -1);
for (int i=0; i<neln; ++i)
{
FENode& nodei = mesh.Node(el.m_node[i]);
lm[3*i ] = nodei.m_ID[0];
lm[3*i+1] = nodei.m_ID[1];
lm[3*i+2] = nodei.m_ID[2];
}
R.Assemble(el.m_node, lm, fe);
}
}
}
}
void FEDiscreteContact2::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
}
void FEDiscreteContact2::BuildMatrixProfile(FEGlobalMatrix& M)
{
}
void FEDiscreteContact2::Update(const FETimeInfo& tp)
{
ProjectNodes();
}
void FEDiscreteContact2::ProjectNodes()
{
// setup closest point projection
FEClosestPointProjection cpp(m_surf);
cpp.SetTolerance(0.01);
cpp.SetSearchRadius(0.0);
cpp.HandleSpecialCases(true);
cpp.Init();
// number of nodes
int NN = m_dom->Nodes();
double L = m_dom->InitialLength();
bool bdone = false;
m_dom->UpdateNodes();
const double snap_tol = 1e-6;
const int maxIter = 1000;
int iter = 0;
while ((bdone == false) && (iter < maxIter))
{
bdone = true;
iter++;
// skip first and last
for (int i = 1; i<NN - 1; ++i)
{
FENode& nd = m_dom->Node(i);
NODE& nodeData = m_nodeData[i];
// get nodal position
vec3d x = nd.m_rt;
// If the node is in contact, let's see if it remains in contact
if (nodeData.pe != 0)
{
// TODO: project the node on the surface to make sure we are using the updated projection position
FESurfaceElement& mel = *nodeData.pe;
double r = nodeData.proj[0];
double s = nodeData.proj[1];
// find the position of neighbors
vec3d ra = m_dom->Node(i - 1).m_rt;
vec3d rb = m_dom->Node(i + 1).m_rt;
// evaluate center
vec3d c = (ra + rb)*0.5;
// try the same element first
FESurfaceElement* pe = nodeData.pe;
vec3d q = m_surf.ProjectToSurface(mel, c, r, s);
if (m_surf.IsInsideElement(mel, r, s, 0.05) == false)
{
// project onto surface
vec2d rs(r,s);
pe = cpp.Project(c, q, rs);
r = rs.x();
s = rs.y();
}
if (pe)
{
vec3d nu = m_surf.SurfaceNormal(*pe, r, s);
double gap = nu*(c - q);
if (gap < 0.0)
{
nodeData.pe = pe;
nodeData.proj[0] = r;
nodeData.proj[1] = s;
nodeData.nu = nu;
nodeData.q = q;
// see if the node moved significantly
double d = (q - x).norm();
if (d / L > 1e-2) bdone = false;
}
else if (gap > snap_tol)
{
// projection failed, release node and redo
m_dom->AnchorNode(i, false);
nodeData.pe = 0;
bdone = false;
}
else if ((x - c).norm2() > snap_tol)
{
// projection failed, release node and redo
m_dom->AnchorNode(i, false);
nodeData.pe = 0;
bdone = false;
}
}
else
{
// projection faild, release node and redo
m_dom->AnchorNode(i, false);
nodeData.pe = 0;
bdone = false;
}
}
else
{
// see it the node establishes contact
vec2d rs(0, 0); vec3d q;
FESurfaceElement* pe = cpp.Project(x, q, rs);
// if it does, update nodal data
// and position the node
if (pe)
{
vec3d nu = m_surf.SurfaceNormal(*pe, rs.x(), rs.y());
if (nu*(x - q) < 0)
{
nodeData.pe = pe;
nodeData.proj[0] = rs.x();
nodeData.proj[1] = rs.y();
nodeData.nu = nu;
nodeData.q = q;
m_dom->AnchorNode(i, true);
bdone = false;
}
}
}
}
// update anchor positions
for (int i=1; i<NN-1; ++i)
{
NODE& nodeData = m_nodeData[i];
if (nodeData.pe != 0) m_dom->SetNodePosition(i, nodeData.q);
}
// tell the domain to update the positions of the free nodes
m_dom->UpdateNodes();
}
// assert(iter < maxIter);
feLog("iterations = %d\n", iter);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEContinuousFiberDistribution.h | .h | 2,625 | 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 "FEElasticMaterial.h"
#include "FEFiberMaterial.h"
#include "FEFiberDensityDistribution.h"
#include "FEFiberIntegrationScheme.h"
#include "FEFiberMaterialPoint.h"
// This material is a container for a fiber material, a fiber density
// distribution, and an integration scheme.
//
class FEContinuousFiberDistribution : public FEElasticMaterial
{
public:
FEContinuousFiberDistribution(FEModel* pfem);
~FEContinuousFiberDistribution();
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
// Initialization
bool Init() override;
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;
//! Serialization
void Serialize(DumpStream& ar) override;
private:
double IntegratedFiberDensity(FEMaterialPoint& pt);
protected:
FEFiberMaterial* m_pFmat; // pointer to fiber material
FEFiberDensityDistribution* m_pFDD; // pointer to fiber density distribution
FEFiberIntegrationScheme* m_pFint; // pointer to fiber integration scheme
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FESolidSolver2.cpp | .cpp | 50,182 | 1,645 | /*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 "FESolidSolver2.h"
#include "FERigidConnector.h"
#include "FESlidingElasticInterface.h"
#include "FE3FieldElasticSolidDomain.h"
#include "FE3FieldElasticShellDomain.h"
#include "FEElasticEASShellDomain.h"
#include "FEElasticANSShellDomain.h"
#include "FEBodyForce.h"
#include "FEResidualVector.h"
#include "FEUncoupledMaterial.h"
#include "FEContactInterface.h"
#include "FESSIShellDomain.h"
#include <FECore/log.h>
#include <FECore/DOFS.h>
#include <FECore/sys.h>
#include <FECore/FEModel.h>
#include <FECore/FEAnalysis.h>
#include <FECore/FEBoundaryCondition.h>
#include <FECore/FENodalLoad.h>
#include <FECore/FESurfaceLoad.h>
#include <FECore/FEModelLoad.h>
#include <FECore/FELinearConstraintManager.h>
#include <FECore/LinearSolver.h>
#include <FECore/vector.h>
#include "FESolidLinearSystem.h"
#include "FEBioMech.h"
#include "FESolidAnalysis.h"
#include "FETrussMaterial.h"
#include "FELinearTrussDomain.h"
#include "FEMechModel.h"
#include "FERigidBody.h"
//-----------------------------------------------------------------------------
// define the parameter list
BEGIN_FECORE_CLASS(FESolidSolver2, FENewtonSolver)
BEGIN_PARAM_GROUP("Nonlinear solver"); // make sure this matches FENewtonSolver.
ADD_PARAMETER(m_Dtol , FE_RANGE_GREATER_OR_EQUAL(0.0), "dtol" );
ADD_PARAMETER(m_Etol , FE_RANGE_GREATER_OR_EQUAL(0.0), "etol");
ADD_PARAMETER(m_Rtol , FE_RANGE_GREATER_OR_EQUAL(0.0), "rtol");
ADD_PARAMETER(m_rhoi , "rhoi" );
ADD_PARAMETER(m_alpha , "alpha" );
ADD_PARAMETER(m_beta , "beta" );
ADD_PARAMETER(m_gamma , "gamma" );
ADD_PARAMETER(m_logSolve , "logSolve" );
ADD_PARAMETER(m_arcLength , "arc_length" );
ADD_PARAMETER(m_al_scale , "arc_length_scale");
ADD_PARAMETER(m_init_accelerations, "init_accelerations")->SetFlags(FE_PARAM_HIDDEN);
END_PARAM_GROUP();
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! FESolidSolver2 Construction
//
FESolidSolver2::FESolidSolver2(FEModel* pfem) : FENewtonSolver(pfem), m_rigidSolver(pfem),\
m_dofU(pfem), m_dofV(pfem), m_dofQ(pfem), m_dofRQ(pfem), m_dofSU(pfem), m_dofSV(pfem), m_dofSA(pfem),
m_dofBW(pfem), m_dofBA(pfem)
{
// default values
m_Rtol = 0; // deactivate residual convergence
m_Dtol = 0.001;
m_Etol = 0.01;
m_Rmin = 1.0e-20;
m_Rmax = 0; // not used if zero
m_niter = 0;
m_nreq = 0;
m_logSolve = false;
// default Newmark parameters (trapezoidal rule)
m_rhoi = -2;
m_alpha = m_alphaf = 1.0;
m_alpham = 1.0;
m_beta = 0.25;
m_gamma = 0.5;
m_init_accelerations = true;
// arc-length parameters
m_arcLength = ARC_LENGTH_METHOD::NONE; // no arc-length
m_al_scale = 0.0;
m_al_lam = 0.0;
m_al_inc = 0.0;
m_al_ds = 0.0;
m_solutionNorm.push_back(ConvergenceInfo());
// get the DOF indices
// TODO: Can this be done in Init, since there is no error checking
if (pfem)
{
m_dofU.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
m_dofQ.AddVariable(FEBioMech::GetVariableName(FEBioMech::ROTATION));
m_dofRQ.AddVariable(FEBioMech::GetVariableName(FEBioMech::RIGID_ROTATION));
m_dofV.AddVariable(FEBioMech::GetVariableName(FEBioMech::VELOCITY));
m_dofSU.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_DISPLACEMENT));
m_dofSV.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_VELOCITY));
m_dofSA.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_ACCELERATION));
m_dofBW.AddVariable(FEBioMech::GetVariableName(FEBioMech::BEAM_ANGULAR_VELOCITY));
m_dofBA.AddVariable(FEBioMech::GetVariableName(FEBioMech::BEAM_ANGULAR_ACCELERATION));
}
}
//-----------------------------------------------------------------------------
FESolidSolver2::~FESolidSolver2()
{
}
//-----------------------------------------------------------------------------
//! Return the rigid solver
FERigidSolver* FESolidSolver2::GetRigidSolver()
{
return &m_rigidSolver;
}
//-----------------------------------------------------------------------------
//! Generate warnings if needed
void FESolidSolver2::SolverWarnings()
{
FEModel& fem = *GetFEModel();
// Generate warning if rigid connectors are used with symmetric stiffness
if (m_msymm == REAL_SYMMETRIC) {
for (int i=0; i<fem.NonlinearConstraints(); ++i)
{
FENLConstraint* plc = fem.NonlinearConstraint(i);
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(plc);
if (prc) {
feLogWarning("Rigid connectors require non-symmetric stiffness matrix.\nSet symmetric_stiffness flag to 0 in Control section.");
break;
}
}
// Generate warning if sliding-elastic contact is used with symmetric stiffness
if (fem.SurfacePairConstraints() > 0)
{
// loop over all contact interfaces
for (int i = 0; i<fem.SurfacePairConstraints(); ++i)
{
FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i));
FESlidingElasticInterface* pbw = dynamic_cast<FESlidingElasticInterface*>(pci);
if (pbw) {
feLogWarning("The sliding-elastic contact algorithm runs better with a non-symmetric stiffness matrix.\nYou may set symmetric_stiffness flag to 0 in Control section.");
break;
}
}
}
}
}
//-----------------------------------------------------------------------------
//! Allocates and initializes the data structures used by the FESolidSolver2
//
bool FESolidSolver2::Init()
{
// initialize base class
if (FENewtonSolver::Init() == false) return false;
FEModel& fem = *GetFEModel();
if (fem.GetCurrentStep()->m_nanalysis == FESolidAnalysis::DYNAMIC)
{
if (m_rhoi == -1) {
// Euler integration
m_alpha = m_alphaf = m_alpham = 1.0;
m_beta = pow(1 + m_alpham - m_alphaf, 2) / 4;
m_gamma = 0.5 + m_alpham - m_alphaf;
}
else if ((m_rhoi >= 0) && (m_rhoi <= 1)) {
// Generalized-alpha integration (2nd order system)
m_alpha = m_alphaf = 1.0 / (1 + m_rhoi);
m_alpham = (2 - m_rhoi) / (1 + m_rhoi);
m_beta = pow(1 + m_alpham - m_alphaf, 2) / 4;
m_gamma = 0.5 + m_alpham - m_alphaf;
}
else {
// for any other value of rhoi, use the user-defined alpha, beta, gamma parameters
m_alphaf = m_alpham = m_alpha;
}
}
else
{
m_alpha = m_alphaf = m_alpham = 1.0;
}
// allocate vectors
// m_Fn.assign(m_neq, 0);
m_Fr.assign(m_neq, 0);
m_Ui.assign(m_neq, 0);
m_Ut.assign(m_neq, 0);
m_Uip.assign(m_neq, 0);
// we need to fill the total displacement vector m_Ut
FEMesh& mesh = fem.GetMesh();
gather(m_Ut, mesh, m_dofU[0]);
gather(m_Ut, mesh, m_dofU[1]);
gather(m_Ut, mesh, m_dofU[2]);
gather(m_Ut, mesh, m_dofQ[0]);
gather(m_Ut, mesh, m_dofQ[1]);
gather(m_Ut, mesh, m_dofQ[2]);
gather(m_Ut, mesh, m_dofSU[0]);
gather(m_Ut, mesh, m_dofSU[1]);
gather(m_Ut, mesh, m_dofSU[2]);
SolverWarnings();
if (m_arcLength > 0)
{
m_Fint.assign(m_neq, 0.0);
m_Fext.assign(m_neq, 0.0);
}
// set the dynamic update flag only if we are running a dynamic analysis
bool b = (fem.GetCurrentStep()->m_nanalysis == FESolidAnalysis::DYNAMIC ? true : false);
for (int i = 0; i < mesh.Domains(); ++i)
{
FEElasticSolidDomain* d = dynamic_cast<FEElasticSolidDomain*>(&mesh.Domain(i));
FEElasticShellDomain* s = dynamic_cast<FEElasticShellDomain*>(&mesh.Domain(i));
FEElasticEASShellDomain* seas = dynamic_cast<FEElasticEASShellDomain*>(&mesh.Domain(i));
FEElasticANSShellDomain* sans = dynamic_cast<FEElasticANSShellDomain*>(&mesh.Domain(i));
if (d) d->SetDynamicUpdateFlag(b);
if (s) s->SetDynamicUpdateFlag(b);
if (seas) seas->SetDynamicUpdateFlag(b);
if (sans) sans->SetDynamicUpdateFlag(b);
}
// For dynamic problems we need to calculate the initial accelerations
// TODO: We currently only do this when time == 0. But what if the first step is static and the
// second is dynamic?
if (m_init_accelerations)
{
FEAnalysis* pstep = fem.GetCurrentStep();
double currentTime = fem.GetTime().currentTime;
if ((pstep->m_nanalysis == FESolidAnalysis::DYNAMIC) && (currentTime == 0.0))
{
if (InitAccelerations() == false) return false;
}
}
return true;
}
bool FESolidSolver2::InitAccelerations()
{
FEModel& fem = *GetFEModel();
// calculate applied force vector
// TODO: What if there is internal stress at time 0?
vector<double> F(m_neq, 0.0), dummy(m_neq, 0.0);
FEResidualVector RHS(fem, F, dummy);
ExternalForces(RHS);
// Only calculate initial accelerations
// if a nonzero inital force is applied.
double f_norm = sqrt(F * F);
if (f_norm > 0)
{
// We need to solve the linear system of equations F = M*a
// So, we build the mass matrix and then solve for a
const FETimeInfo& tp = fem.GetTime();
// Form the stiffness matrix
if (!CreateStiffness(true)) return false;
// setup the linear system
m_pK->Zero();
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), 1.0, m_nreq);
// build the global mass matrix
FEMesh& mesh = fem.GetMesh();
for (int i = 0; i < mesh.Domains(); ++i)
{
FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(&mesh.Domain(i));
if (edom) edom->MassMatrix(LS, 1.0);
}
m_rigidSolver.RigidMassMatrix(LS, tp);
// Don't forget to factor the matrix first!
if (m_plinsolve == nullptr) return false;
if (m_plinsolve->Factor() == false)
{
throw FactorizationError();
}
// Solve for the initial accelerations
vector<double> a0(m_neq);
SolveEquations(a0, F);
// apply to nodes
for (int i = 0, n; i < mesh.Nodes(); ++i)
{
FENode& nodei = mesh.Node(i);
n = nodei.m_ID[m_dofU[0]]; if (n >= 0) nodei.m_at.x = a0[n];
n = nodei.m_ID[m_dofU[1]]; if (n >= 0) nodei.m_at.y = a0[n];
n = nodei.m_ID[m_dofU[2]]; if (n >= 0) nodei.m_at.z = a0[n];
vec3d aqt(0, 0, 0);
n = nodei.m_ID[m_dofSU[0]]; if (n >= 0) aqt.x = a0[n];
n = nodei.m_ID[m_dofSU[1]]; if (n >= 0) aqt.y = a0[n];
n = nodei.m_ID[m_dofSU[2]]; if (n >= 0) aqt.z = a0[n];
nodei.set_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2], aqt);
}
// apply to rigid bodies
FEMechModel& mech = dynamic_cast<FEMechModel&>(fem);
for (int i = 0, n; i < mech.RigidBodies(); ++i)
{
FERigidBody& rb = *mech.GetRigidBody(i);
n = rb.m_LM[0]; if (n >= 0) rb.m_at.x = rb.m_ap.x = a0[n];
n = rb.m_LM[1]; if (n >= 0) rb.m_at.y = rb.m_ap.y = a0[n];
n = rb.m_LM[2]; if (n >= 0) rb.m_at.z = rb.m_ap.z = a0[n];
n = rb.m_LM[3]; if (n >= 0) rb.m_alt.x = rb.m_alp.x = a0[n];
n = rb.m_LM[4]; if (n >= 0) rb.m_alt.y = rb.m_alp.y = a0[n];
n = rb.m_LM[5]; if (n >= 0) rb.m_alt.z = rb.m_alp.z = a0[n];
}
// since rigid nodes don't get equations assigned, we'll grab
// their initial accelerations from the rigid bodies
for (int i = 0; i < mesh.Nodes(); ++i)
{
FENode& nodei = mesh.Node(i);
if (nodei.m_rid >= 0)
{
FERigidBody& rb = *mech.GetRigidBody(nodei.m_rid);
// TODO: What if the rb has initial rotation or rotational acceleration?
nodei.m_at = rb.m_at;
nodei.set_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2], rb.m_at);
}
}
// TODO: What if there are linear constraints present? We'll probably need to do
// something similar for the constrained nodes since they also don't have equations assigned.
}
return true;
}
//-----------------------------------------------------------------------------
//! Save data to dump file
void FESolidSolver2::Serialize(DumpStream& ar)
{
// Serialize parameters
FENewtonSolver::Serialize(ar);
ar & m_nrhs;
ar & m_niter;
ar & m_nref & m_ntotref;
ar & m_naug;
ar & m_nreq;
ar & m_alphaf;
ar & m_alpham;
ar & m_Ut & m_Ui;
ar & m_arcLength;
ar & m_al_scale;
ar & m_al_lam & m_al_inc;// &m_al_ds;
if (ar.IsLoading())
{
// m_Fn.assign(m_neq, 0);
m_Fr.assign(m_neq, 0);
// m_Ui.assign(m_neq, 0);
}
// serialize rigid solver
m_rigidSolver.Serialize(ar);
}
//-----------------------------------------------------------------------------
bool FESolidSolver2::InitEquations()
{
// First call the base class.
// This will initialize all equation numbers, except the rigid body equation numbers
if (FENewtonSolver::InitEquations() == false) return false;
// store the number of equations we currently have
m_nreq = m_neq;
// Next, we assign equation numbers to the rigid body degrees of freedom
int neq = m_rigidSolver.InitEquations(m_neq);
if (neq == -1) return false;
else m_neq = neq;
// Next, we add any Lagrange Multipliers
FEModel& fem = *GetFEModel();
for (int i = 0; i < fem.NonlinearConstraints(); ++i)
{
FENLConstraint* lmc = fem.NonlinearConstraint(i);
if (lmc->IsActive())
{
m_neq += lmc->InitEquations(m_neq);
}
}
for (int i = 0; i < fem.SurfacePairConstraints(); ++i)
{
FESurfacePairConstraint* spc = fem.SurfacePairConstraint(i);
if (spc->IsActive())
{
m_neq += spc->InitEquations(m_neq);
}
}
// All initialization is done
return true;
}
//-----------------------------------------------------------------------------
bool FESolidSolver2::InitEquations2()
{
// First call the base class.
// This will initialize all equation numbers, except the rigid body equation numbers
if (FENewtonSolver::InitEquations2() == false) return false;
// store the number of equations we currently have
m_nreq = m_neq;
// Next, we assign equation numbers to the rigid body degrees of freedom
int neq = m_rigidSolver.InitEquations(m_neq);
if (neq == -1) return false;
else m_neq = neq;
// Next, we add any Lagrange Multipliers
FEModel& fem = *GetFEModel();
for (int i = 0; i < fem.NonlinearConstraints(); ++i)
{
FENLConstraint* lmc = fem.NonlinearConstraint(i);
if (lmc->IsActive())
{
m_neq += lmc->InitEquations(m_neq);
}
}
for (int i = 0; i < fem.SurfacePairConstraints(); ++i)
{
FESurfacePairConstraint* spc = fem.SurfacePairConstraint(i);
if (spc->IsActive())
{
m_neq += spc->InitEquations(m_neq);
}
}
// All initialization is done
return true;
}
//-----------------------------------------------------------------------------
//! Update the kinematics of the model, such as nodal positions, velocities,
//! accelerations, etc.
void FESolidSolver2::UpdateKinematics(vector<double>& ui)
{
FEModel& fem = *GetFEModel();
// get the mesh
FEMesh& mesh = fem.GetMesh();
// update rigid bodies
m_rigidSolver.UpdateRigidBodies(m_Ui, ui);
// total displacements
vector<double> U(m_Ut.size());
int U_size = (int)U.size();
#pragma omp parallel for
for (int i = 0; i < U_size; ++i)
{
U[i] = ui[i] + m_Ui[i] + m_Ut[i];
}
// update flexible nodes
// translational dofs
scatter3(U, mesh, m_dofU[0], m_dofU[1], m_dofU[2]);
// rotational dofs
scatter3(U, mesh, m_dofQ[0], m_dofQ[1], m_dofQ[2]);
// shell dofs
scatter3(U, mesh, m_dofSU[0], m_dofSU[1], m_dofSU[2]);
// make sure the boundary conditions are fullfilled
int nbcs = fem.BoundaryConditions();
for (int i = 0; i<nbcs; ++i)
{
FEBoundaryCondition& bc = *fem.BoundaryCondition(i);
if (bc.IsActive()) bc.Update();
}
// enforce the linear constraints
// TODO: do we really have to do this? Shouldn't the algorithm
// already guarantee that the linear constraints are satisfied?
FELinearConstraintManager& LCM = fem.GetLinearConstraintManager();
if (LCM.LinearConstraints() > 0)
{
LCM.Update();
}
// Update the spatial nodal positions
// Don't update rigid nodes since they are already updated
int NN = mesh.Nodes();
#pragma omp parallel
{
#pragma omp for
for (int i = 0; i < NN; ++i)
{
FENode& node = mesh.Node(i);
if (node.m_rid == -1) {
node.m_rt = node.m_r0 + node.get_vec3d(m_dofU[0], m_dofU[1], m_dofU[2]);
}
node.m_dt = node.m_d0 + node.get_vec3d(m_dofU[0], m_dofU[1], m_dofU[2])
- node.get_vec3d(m_dofSU[0], m_dofSU[1], m_dofSU[2]);
}
// update velocity and accelerations
// for dynamic simulations
FEAnalysis* pstep = fem.GetCurrentStep();
if (pstep->m_nanalysis == FESolidAnalysis::DYNAMIC)
{
double dt = fem.GetTime().timeIncrement;
double a = 1.0 / (m_beta * dt);
double b = a / dt;
double c = 1.0 - 0.5 / m_beta;
#pragma omp for nowait
for (int i = 0; i < NN; ++i)
{
FENode& n = mesh.Node(i);
n.m_at = (n.m_rt - n.m_rp) * b - n.m_vp * a + n.m_ap * c;
vec3d vt = n.m_vp + (n.m_ap * (1.0 - m_gamma) + n.m_at * m_gamma) * dt;
n.set_vec3d(m_dofV[0], m_dofV[1], m_dofV[2], vt);
// shell kinematics
{
vec3d qt = n.get_vec3d(m_dofSU[0], m_dofSU[1], m_dofSU[2]);
vec3d qp = n.get_vec3d_prev(m_dofSU[0], m_dofSU[1], m_dofSU[2]);
vec3d vqp = n.get_vec3d_prev(m_dofSV[0], m_dofSV[1], m_dofSV[2]);
vec3d aqp = n.get_vec3d_prev(m_dofSA[0], m_dofSA[1], m_dofSA[2]);
vec3d aqt = (qt - qp) * b - vqp * a + aqp * c;
vec3d vqt = vqp + (aqp * (1.0 - m_gamma) + aqt * m_gamma) * dt;
n.set_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2], aqt);
n.set_vec3d(m_dofSV[0], m_dofSV[1], m_dofSV[2], vqt);
}
// beam kinematics
{
vec3d Rp = n.get_vec3d_prev(m_dofQ[0], m_dofQ[1], m_dofQ[2]);
vec3d wp = n.get_vec3d_prev(m_dofBW[0], m_dofBW[1], m_dofBW[2]);
vec3d ap = n.get_vec3d_prev(m_dofBA[0], m_dofBA[1], m_dofBA[2]);
// rotation at previous time step
quatd Qp(Rp);
quatd Qp_T = Qp.Conjugate();
// convert to material quantities
vec3d Wp = Qp_T * wp;
vec3d Ap = Qp_T * ap;
// get equation numbers for rotations
// (and ensure that they are all free or all prescribed)
int eq[3] = { n.m_ID[m_dofQ[0]], n.m_ID[m_dofQ[1]], n.m_ID[m_dofQ[2]] };
assert(((eq[0] >= 0) && (eq[1] >= 0) && (eq[2] >= 0)) ||
((eq[0] < 0) && (eq[1] < 0) && (eq[2] < 0)));
// get rotation increment
vec3d ri, Ri;
int m;
m = eq[0]; if (m >= 0) { ri.x = ui[m]; Ri.x = m_Ui[m]; }
m = eq[1]; if (m >= 0) { ri.y = ui[m]; Ri.y = m_Ui[m]; }
m = eq[2]; if (m >= 0) { ri.z = ui[m]; Ri.z = m_Ui[m]; }
quatd dq(ri), qi(Ri);
quatd qn = dq * qi;
vec3d rn = qn.GetRotationVector();
// check for prescribed values
if ((eq[0] < 0) && (eq[1] < 0) && (eq[2] < 0))
{
vec3d Rt;
m = eq[0]; if (m < -1) { Rt.x = n.get(m_dofQ[0]); }
m = eq[1]; if (m < -1) { Rt.y = n.get(m_dofQ[1]); }
m = eq[2]; if (m < -1) { Rt.z = n.get(m_dofQ[2]); }
quatd Qt(Rt);
qn = Qp.Conjugate() * Qt;
rn = qn.GetRotationVector();
}
// convert to material increment
vec3d Qn = Qp_T * rn;
// update material angular velocity and angular acceleration
vec3d At = (Qn - Wp * dt) * b + Ap * c;
vec3d Wt = Qn * (m_gamma * a) + Wp * (1.0 - m_gamma / m_beta) + Ap * (dt * (1.0 - 0.5 * m_gamma / m_beta));
// convert to spatial
quatd Qt = qn * Qp;
vec3d wt = Qt * Wt;
vec3d at = Qt * At;
// store updated values
if ((eq[0] >= 0) && (eq[1] >= 0) && (eq[2] >= 0))
{
vec3d Rt = Qt.GetRotationVector();
n.set_vec3d(m_dofQ[0], m_dofQ[1], m_dofQ[2], Rt);
}
n.set_vec3d(m_dofBW[0], m_dofBW[1], m_dofBW[2], wt);
n.set_vec3d(m_dofBA[0], m_dofBA[1], m_dofBA[2], at);
}
}
}
}
// update nonlinear constraints (needed for updating Lagrange Multiplier)
for (int i = 0; i < fem.NonlinearConstraints(); ++i)
{
FENLConstraint* nlc = fem.NonlinearConstraint(i);
if (nlc->IsActive()) nlc->Update(m_Ui, ui);
}
for (int i = 0; i < fem.SurfacePairConstraints(); ++i)
{
FESurfacePairConstraint* spc = fem.SurfacePairConstraint(i);
if (spc->IsActive()) spc->Update(m_Ui, ui);
}
}
//-----------------------------------------------------------------------------
//! Update DOF increments
void FESolidSolver2::UpdateIncrements(vector<double>& Ui, vector<double>& ui, bool emap)
{
FEModel& fem = *GetFEModel();
// get the mesh
FEMesh& mesh = fem.GetMesh();
// update rigid bodies
m_rigidSolver.UpdateIncrements(Ui, ui, emap);
// update flexible nodes
int n;
for (int i=0; i<mesh.Nodes(); ++i)
{
FENode& node = mesh.Node(i);
// displacement dofs
// current position = initial + total at prev conv step + total increment so far + current increment
if ((n = node.m_ID[m_dofU[0]]) >= 0) Ui[n] += ui[n];
if ((n = node.m_ID[m_dofU[1]]) >= 0) Ui[n] += ui[n];
if ((n = node.m_ID[m_dofU[2]]) >= 0) Ui[n] += ui[n];
// beam rotations
{
vec3d ri, Ri;
if ((n = node.m_ID[m_dofQ[0]]) >= 0) { ri.x = ui[n]; Ri.x = Ui[n]; }
if ((n = node.m_ID[m_dofQ[1]]) >= 0) { ri.y = ui[n]; Ri.y = Ui[n]; }
if ((n = node.m_ID[m_dofQ[2]]) >= 0) { ri.z = ui[n]; Ri.z = Ui[n]; }
quatd qi(ri), Qi(Ri);
quatd Qn = qi * Qi;
vec3d rn = Qn.GetRotationVector();
if ((n = node.m_ID[m_dofQ[0]]) >= 0) { Ui[n] = rn.x; }
if ((n = node.m_ID[m_dofQ[1]]) >= 0) { Ui[n] = rn.y; }
if ((n = node.m_ID[m_dofQ[2]]) >= 0) { Ui[n] = rn.z; }
}
// shell dofs
{
if ((n = node.m_ID[m_dofSU[0]]) >= 0) Ui[n] += ui[n];
if ((n = node.m_ID[m_dofSU[1]]) >= 0) Ui[n] += ui[n];
if ((n = node.m_ID[m_dofSU[2]]) >= 0) Ui[n] += ui[n];
}
}
for (int i = 0; i < fem.NonlinearConstraints(); ++i)
{
FENLConstraint* plc = fem.NonlinearConstraint(i);
if (plc && plc->IsActive()) plc->UpdateIncrements(Ui, ui);
}
for (int i = 0; i < fem.SurfacePairConstraints(); ++i)
{
FESurfacePairConstraint* psc = fem.SurfacePairConstraint(i);
if (psc && psc->IsActive()) psc->UpdateIncrements(Ui, ui);
}
// TODO: This is a hack!
// The problem is that I only want to call the domain's IncrementalUpdate during
// the quasi-Newtoon loop. However, this function is also called after the loop
// converges. The emap parameter is used here to detect wether we are inside the
// loop (emap == false), or not (emap == true).
if (emap == false)
{
for (int i = 0; i < mesh.Domains(); ++i)
{
FEDomain& dom = mesh.Domain(i);
dom.IncrementalUpdate(ui, true);
}
}
}
//-----------------------------------------------------------------------------
//! Updates the current state of the model
void FESolidSolver2::Update(vector<double>& ui)
{
FEModel& fem = *GetFEModel();
FETimeInfo& tp = fem.GetTime();
tp.currentIteration = m_niter;
// update EAS
UpdateEAS(ui);
UpdateIncrementsEAS(ui, true);
// update kinematics
UpdateKinematics(ui);
// update domains
FEMesh& mesh = fem.GetMesh();
for (int i = 0; i < mesh.Domains(); ++i)
{
FEDomain& dom = mesh.Domain(i);
dom.IncrementalUpdate(ui, false);
}
// update model state
UpdateModel();
}
//-----------------------------------------------------------------------------
//! Updates the current state of the model
//! NOTE: The ui vector also contains prescribed displacement increments. Also note that this
//! only works for a limited set of FEBio features (no rigid bodies!).
void FESolidSolver2::Update2(const vector<double>& ui)
{
// get the mesh
FEModel& fem = *GetFEModel();
FEMesh& mesh = fem.GetMesh();
// total displacements
vector<double> U(m_Ut.size());
for (size_t i = 0; i<m_Ut.size(); ++i) U[i] = ui[i] + m_Ui[i] + m_Ut[i];
// update free nodes
scatter3(U, mesh, m_dofU[0], m_dofU[1], m_dofU[2]);
// Update the spatial nodal positions
for (int i = 0; i<mesh.Nodes(); ++i)
{
FENode& node = mesh.Node(i);
vec3d du(0, 0, 0);
int nx = -node.m_ID[m_dofU[0]] - 2; if (nx >= 0) du.x = ui[nx];
int ny = -node.m_ID[m_dofU[1]] - 2; if (ny >= 0) du.y = ui[ny];
int nz = -node.m_ID[m_dofU[2]] - 2; if (nz >= 0) du.z = ui[nz];
if (node.m_rid == -1)
{
vec3d rt = node.m_r0 + node.get_vec3d(m_dofU[0], m_dofU[1], m_dofU[2]) + du;
node.m_rt = rt;
}
vec3d db(0, 0, 0);
int nbx = -node.m_ID[m_dofSU[0]] - 2; if (nbx >= 0) db.x = ui[nbx];
int nby = -node.m_ID[m_dofSU[1]] - 2; if (nby >= 0) db.y = ui[nby];
int nbz = -node.m_ID[m_dofSU[2]] - 2; if (nbz >= 0) db.z = ui[nbz];
vec3d dt = node.m_d0 + node.get_vec3d(m_dofU[0], m_dofU[1], m_dofU[2]) + du
- (node.get_vec3d(m_dofSU[0], m_dofSU[1], m_dofSU[2]) + db);
node.m_dt = dt;
}
// update model state
UpdateModel();
}
//-----------------------------------------------------------------------------
//! Update EAS
void FESolidSolver2::UpdateEAS(vector<double>& ui)
{
FEModel& fem = *GetFEModel();
FEMesh& mesh = fem.GetMesh();
// update EAS on shell domains
for (int i=0; i<mesh.Domains(); ++i) {
FESSIShellDomain* sdom = dynamic_cast<FESSIShellDomain*>(&mesh.Domain(i));
if (sdom && sdom->IsActive()) sdom->UpdateEAS(ui);
}
}
//-----------------------------------------------------------------------------
//! Update EAS
void FESolidSolver2::UpdateIncrementsEAS(vector<double>& ui, const bool binc)
{
FEModel& fem = *GetFEModel();
FEMesh& mesh = fem.GetMesh();
// update EAS on shell domains
for (int i=0; i<mesh.Domains(); ++i) {
FESSIShellDomain* sdom = dynamic_cast<FESSIShellDomain*>(&mesh.Domain(i));
if (sdom && sdom->IsActive()) sdom->UpdateIncrementsEAS(ui, binc);
}
}
//-----------------------------------------------------------------------------
bool FESolidSolver2::InitStep(double time)
{
FEModel& fem = *GetFEModel();
// set time integration parameters
FETimeInfo& tp = fem.GetTime();
tp.alpha = m_alpha;
tp.beta = m_beta;
tp.gamma = m_gamma;
tp.alphaf = m_alphaf;
tp.alpham = m_alpham;
// evaluate load curve values at current (or intermediate) time
double t = tp.currentTime;
// double dt = tp.timeIncrement;
// double ta = (t > 0) ? t - (1-m_alpha)*dt : m_alpha*dt;
// return FESolver::InitStep(ta);
return FESolver::InitStep(t);
}
//-----------------------------------------------------------------------------
//! Prepares the data for the first BFGS-iteration.
void FESolidSolver2::PrepStep()
{
FEModel& fem = *GetFEModel();
FETimeInfo& tp = fem.GetTime();
double dt = tp.timeIncrement;
tp.augmentation = 0;
// zero total displacements
zero(m_Ui);
// store previous mesh state
// we need them for velocity and acceleration calculations
FEMesh& mesh = fem.GetMesh();
for (int i=0; i<mesh.Nodes(); ++i)
{
FENode& ni = mesh.Node(i);
ni.m_rp = ni.m_rt;
ni.m_vp = ni.get_vec3d(m_dofV[0], m_dofV[1], m_dofV[2]);
ni.m_ap = ni.m_at;
ni.m_dp = ni.m_dt;
ni.UpdateValues();
// initial guess at start of new time step
// solid
ni.m_at = ni.m_ap*(1-0.5/m_beta) - ni.m_vp/(m_beta*dt);
vec3d vs = ni.m_vp + (ni.m_at*m_gamma + ni.m_ap*(1-m_gamma))*dt;
ni.set_vec3d(m_dofV[0], m_dofV[1], m_dofV[2], vs);
// solid shell
vec3d aqp = ni.get_vec3d_prev(m_dofSA[0], m_dofSA[1], m_dofSA[2]);
vec3d vqp = ni.get_vec3d_prev(m_dofSV[0], m_dofSV[1], m_dofSV[2]);
vec3d aqt = aqp*(1-0.5/m_beta) - vqp/(m_beta*dt);
ni.set_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2], aqt);
vec3d vqt = vqp + (aqt*m_gamma + aqp*(1-m_gamma))*dt;
ni.set_vec3d(m_dofSV[0], m_dofSV[1], m_dofSV[2], vqt);
// beams (rotational kinematics)
{
// get rotation
vec3d rp = ni.get_vec3d_prev(m_dofQ[0], m_dofQ[1], m_dofQ[2]);
quatd Q(rp);
quatd Qt = Q.Conjugate();
// get previous spatial quantities
vec3d wp = ni.get_vec3d_prev(m_dofBW[0], m_dofBW[1], m_dofBW[2]);
vec3d ap = ni.get_vec3d_prev(m_dofBA[0], m_dofBA[1], m_dofBA[2]);
// convert to material frame
vec3d Wp = Qt * wp;
vec3d Ap = Qt * ap;
// initial guess
vec3d At = Ap * (1.0 - 0.5/m_beta) - Wp / (m_beta*dt);
vec3d Wt = Wp + (Ap * (1.0 - m_gamma) + At*m_gamma)*dt;
// back to spatial frame
vec3d at = Q * At;
vec3d wt = Q * Wt;
ni.set_vec3d(m_dofBW[0], m_dofBW[1], m_dofBW[2], wt);
ni.set_vec3d(m_dofBA[0], m_dofBA[1], m_dofBA[2], at);
}
}
// apply concentrated nodal forces
// since these forces do not depend on the geometry
// we can do this once outside the NR loop.
// vector<double> dummy(m_neq, 0.0);
// zero(m_Fn);
// FEResidualVector Fn(*GetFEModel(), m_Fn, dummy);
// NodalLoads(Fn, tp);
// apply boundary conditions
// we save the prescribed displacements increments in the ui vector
vector<double>& ui = m_ui;
zero(ui);
int nbc = fem.BoundaryConditions();
for (int i=0; i<nbc; ++i)
{
FEBoundaryCondition& dc = *fem.BoundaryCondition(i);
if (dc.IsActive()) dc.PrepStep(ui);
}
// do the linear constraints
fem.GetLinearConstraintManager().PrepStep();
// initialize rigid bodies
m_rigidSolver.PrepStep(tp, ui);
// intialize material point data
// NOTE: do this before the stresses are updated
// TODO: does it matter if the stresses are updated before
// the material point data is initialized
for (int i=0; i<mesh.Domains(); ++i)
{
FEDomain& dom = mesh.Domain(i);
if (dom.IsActive()) dom.PreSolveUpdate(tp);
}
// update model state
UpdateModel();
for (int i = 0; i < fem.NonlinearConstraints(); ++i)
{
FENLConstraint* plc = fem.NonlinearConstraint(i);
if (plc && plc->IsActive()) plc->PrepStep();
}
for (int i = 0; i < fem.SurfacePairConstraints(); ++i)
{
FESurfacePairConstraint* psc = fem.SurfacePairConstraint(i);
if (psc && psc->IsActive()) psc->PrepStep();
}
for (int i = 0; i < fem.ModelLoads(); ++i)
{
FEModelLoad* pl = fem.ModelLoad(i);
if (pl->IsActive()) pl->PrepStep();
}
// see if we need to do contact augmentations
m_baugment = false;
for (int i = 0; i<fem.SurfacePairConstraints(); ++i)
{
FEContactInterface& ci = dynamic_cast<FEContactInterface&>(*fem.SurfacePairConstraint(i));
if (ci.IsActive() && (ci.m_laugon == FECore::AUGLAG_METHOD)) m_baugment = true;
}
// see if we need to do incompressible augmentations
// TODO: Should I do these augmentations in a nlconstraint class instead?
int ndom = mesh.Domains();
for (int i = 0; i < ndom; ++i)
{
FEDomain* dom = &mesh.Domain(i);
FE3FieldElasticSolidDomain* dom3f = dynamic_cast<FE3FieldElasticSolidDomain*>(dom);
if (dom3f && dom3f->DoAugmentations()) m_baugment = true;
FE3FieldElasticShellDomain* dom3fs = dynamic_cast<FE3FieldElasticShellDomain*>(dom);
if (dom3fs && dom3fs->DoAugmentations()) m_baugment = true;
}
// see if we have to do nonlinear constraint augmentations
if (fem.NonlinearConstraints() != 0) m_baugment = true;
}
//-----------------------------------------------------------------------------
// Performs the quasi-newton iterations.
bool FESolidSolver2::Quasin()
{
vector<double> u0(m_neq);
vector<double> Rold(m_neq);
// convergence norms
double normR1; // residual norm
double normE1; // energy norm
double normU; // displacement norm
double normu; // displacement increment norm
double normRi; // initial residual norm
double normEi; // initial energy norm
double normEm; // max energy norm
double normUi; // initial displacement norm
FEModel& fem = *GetFEModel();
// Get the current step
FEAnalysis* pstep = fem.GetCurrentStep();
// set the time information
FETimeInfo& tp = fem.GetTime();
// initialize arc length stuff
if (m_arcLength > 0)
{
m_al_inc = 0.0;
// store the total increment from the last time step
// we need it later to decide in which direction to proceed.
m_Uip = m_Ui;
}
// prepare for the first iteration
PrepStep();
// Initialize the QN-method
if (QNInit() == false) return false;
// loop until converged or when max nr of reformations reached
bool bconv = false; // convergence flag
do
{
feLog(" %d\n", m_niter+1);
// assume we'll converge.
bconv = true;
// solve the equations
SolveEquations(m_ui, m_R0);
// apply arc-length method
if (m_arcLength > 0) DoArcLength();
// do the line search
double s = DoLineSearch();
// set initial convergence norms
if (m_niter == 0)
{
normRi = fabs(m_R0*m_R0);
normEi = fabs(m_ui*m_R0);
normUi = fabs(m_ui*m_ui);
normEm = normEi;
m_residuNorm.norm0 = normRi;
m_energyNorm.norm0 = normEi;
m_solutionNorm[0].norm0 = normUi;
}
// calculate actual displacement increment
// NOTE: We don't apply the line search directly to m_ui since we need the unscaled search direction for the QN update below
int neq = (int)m_Ui.size();
vector<double> ui(m_ui);
for (int i = 0; i<neq; ++i) ui[i] *= s;
// update total displacements
UpdateIncrements(m_Ui, ui, false);
// calculate norms
normR1 = m_R1*m_R1;
normu = ui*ui;
normU = m_Ui*m_Ui;
normE1 = fabs(ui*m_R1);
m_residuNorm.norm = normR1;
m_energyNorm.norm = normE1;
m_solutionNorm[0].norm = normu;
// check for nans
if (ISNAN(normR1)) throw NANInResidualDetected();
if (ISNAN(normu)) throw NANInSolutionDetected();
// check residual norm
if ((m_Rtol > 0) && (normR1 > m_Rtol*normRi)) bconv = false;
// check displacement norm
if ((m_Dtol > 0) && (normu > (m_Dtol*m_Dtol)*normU )) bconv = false;
// check energy norm
if ((m_Etol > 0) && (normE1 > m_Etol*normEi)) bconv = false;
// check linestep size
if ((m_lineSearch->m_LStol > 0) && (s < m_lineSearch->m_LSmin)) bconv = false;
// check energy divergence
if (m_bdivreform)
{
if (normE1 > normEm) bconv = false;
}
// print convergence summary
feLog(" Nonlinear solution status: time= %lg\n", tp.currentTime);
feLog("\tstiffness updates = %d\n", m_qnstrategy->m_nups);
feLog("\tright hand side evaluations = %d\n", m_nrhs);
feLog("\tstiffness matrix reformations = %d\n", m_nref);
if (m_lineSearch->m_LStol > 0) feLog("\tstep from line search = %lf\n", s);
feLog("\tconvergence norms : INITIAL CURRENT REQUIRED\n");
feLog("\t residual %15le %15le %15le \n", normRi, normR1, m_Rtol*normRi);
feLog("\t energy %15le %15le %15le \n", normEi, normE1, m_Etol*normEi);
feLog("\t displacement %15le %15le %15le \n", normUi, normu ,(m_Dtol*m_Dtol)*normU );
// see if we may have a small residual
if ((bconv == false) && (normR1 < m_Rmin))
{
// check for almost zero-residual on the first iteration
// this might be an indication that there is no force on the system
feLogWarning("No force acting on the system.");
bconv = true;
}
// see if we have exceeded the max residual
if ((bconv == false) && (m_Rmax > 0) && (normR1 >= m_Rmax))
{
// doesn't look like we're getting anywhere, so let's retry the time step
throw MaxResidualError();
}
// check if we have converged.
// If not, calculate the BFGS update vectors
if (bconv == false)
{
// do additional checks that may trigger a stiffness reformation
if (s < m_lineSearch->m_LSmin)
{
// check for zero linestep size
feLogWarning("Zero linestep size. Stiffness matrix will now be reformed");
QNForceReform(true);
}
else if ((normE1 > normEm) && m_bdivreform)
{
// check for diverging
feLogWarning("Problem is diverging. Stiffness matrix will now be reformed");
normEm = normE1;
normEi = normE1;
normRi = normR1;
QNForceReform(true);
}
// Do the QN update (This may also do a stiffness reformation if necessary)
bool bret = QNUpdate();
// something went wrong with the update, so we'll need to break
if (bret == false) break;
}
else if (m_baugment)
{
// do the augmentations
bconv = DoAugmentations();
}
// increase iteration number
m_niter++;
// do minor iterations callbacks
fem.DoCallback(CB_MINOR_ITERS);
}
while (bconv == false);
fem.DoCallback(CB_QUASIN_CONVERGED);
// if converged we update the total displacements
if (bconv)
{
UpdateIncrementsEAS(m_Ui, false);
UpdateIncrements(m_Ut, m_Ui, true);
// TODO: To zero or not to zero. That is the question!
// The arc-length method requires that we do NOT zero
// here, so that m_Uip gets initialized properly.
// However, the "jfnk-tangent test" requires that we zero this
// Otherwise the displacement increment can get counted twice in
// Update2 (from m_Ui and m_Ut since we just added it)
if (m_arcLength == 0)
zero(m_Ui);
}
return bconv;
}
//-----------------------------------------------------------------------------
// Exception that is thrown when the arc-length method has failed
class ArcLengthFailed : public FEException
{
public:
ArcLengthFailed() : FEException("arc-length update has failed") {}
};
//-----------------------------------------------------------------------------
bool quadratic_solve(double a, double b, double c, double x[2])
{
double D2 = b*b - 4.0*a*c;
if (D2 < 0) return false;
double D = sqrt(D2);
if (b >= 0)
{
x[0] = (-b - D) / (2.0*a);
x[1] = 2.0*c / (-b - D);
}
else
{
x[0] = 2.0*c / (-b + D);
x[1] = (-b + D) / (2.0*a);
}
return true;
}
//-----------------------------------------------------------------------------
//! Apply arc-length
void FESolidSolver2::DoArcLength()
{
// auxiliary displacement
vector<double> uF(m_neq, 0.0);
// the arc-length scale factor
double psi = m_al_scale;
assert(psi == 0.0);
const FETimeInfo& tp = GetFEModel()->GetTime();
m_al_gamma = 0.0;
if (m_arcLength == ARC_LENGTH_METHOD::CRISFIELD)
{
// solve for auxiliary displacement
SolveEquations(uF, m_Fext);
// if this is the first time step, we pick a special gamma
if (m_niter == 0)
{
if (GetFEModel()->GetCurrentStep()->m_ntimesteps == 0)
{
// The first time we get here, we simply pick the arc-length step size
// from the solution
m_al_gamma = tp.timeIncrement;
m_al_ds = m_al_gamma*sqrt(uF*uF + psi*(m_Fext*m_Fext));
}
else
{
m_al_gamma = m_al_ds / sqrt(uF*uF + psi*(m_Fext*m_Fext));
double uFdx = uF*m_Uip;
if (uFdx < 0.0) m_al_gamma = -m_al_gamma;
}
}
else
{
// The general case requires solving a quadratic equation
// setup quadratic equation
double Fe_norm2 = m_Fext*m_Fext;
double a = uF*uF + (psi*psi)*Fe_norm2;
double b = 2.0*(uF*(m_Ui + m_ui)) + 2 * m_al_inc*(psi*psi)*Fe_norm2;
double c = m_ui*(m_Ui*2.0 + m_ui) + m_Ui*m_Ui - m_al_ds*m_al_ds + (psi*psi)*(m_al_inc*m_al_inc)*Fe_norm2;
// solve quadratic equation
double g[2];
if (quadratic_solve(a, b, c, g) == false)
{
m_al_ds *= 0.5;
throw ArcLengthFailed();
}
// two possible solution vectors
vector<double> u1 = m_ui + uF*g[0];
vector<double> u2 = m_ui + uF*g[1];
// calculate two s-vectors
vector<double> sk(2 * m_neq, 0.0), s1(2 * m_neq, 0.0), s2(2 * m_neq, 0.0);
for (int i = 0; i < m_neq; ++i)
{
sk[i] = m_Ui[i];
sk[i + m_neq] = m_al_inc*psi*m_Fext[i];
s1[i] = m_Ui[i] + u1[i];
s1[i + m_neq] = (m_al_inc + g[0])*psi*m_Fext[i];
s2[i] = m_Ui[i] + u2[i];
s2[i + m_neq] = (m_al_inc + g[1])*psi*m_Fext[i];
}
// calculate the norms of these vectors
// NOTE: Should be Ds!!
double norm_sk = 0, norm_s1 = 0, norm_s2 = 0;
for (int i = 0; i < 2 * m_neq; ++i)
{
norm_sk += sk[i] * sk[i];
norm_s1 += s1[i] * s1[i];
norm_s2 += s2[i] * s2[i];
}
norm_sk = sqrt(norm_sk);
norm_s1 = sqrt(norm_s1);
norm_s2 = sqrt(norm_s2);
// see which one produces the closest angle to the current path
double c1 = (sk*s1) / (norm_sk*norm_s1);
double c2 = (sk*s2) / (norm_sk*norm_s2);
if (c1 >= c2)
{
m_al_gamma = g[0];
}
else
{
m_al_gamma = g[1];
}
}
m_al_inc += m_al_gamma;
m_al_lam += m_al_gamma;
m_ui = m_ui + uF*m_al_gamma;
}
// evaluate the arc-length equation.
double sk2 = (m_Ui + m_ui)*(m_Ui + m_ui) + (psi*psi)*m_al_inc*m_al_inc*(m_Fext*m_Fext);
double sk = sqrt(sk2);
double serr = fabs((sk - m_al_ds) / m_al_ds);
feLog("\tarc-length increment : %lg (%lg)\n", m_al_inc, m_al_gamma);
feLog("\tarc-length factor : %lg\n", m_al_lam);
feLog("\tarc-length constraint: %lg (%lg, err = %lg)\n", sk, m_al_ds, serr);
}
//-----------------------------------------------------------------------------
//! Calculates global stiffness matrix.
bool FESolidSolver2::StiffnessMatrix()
{
FEModel& fem = *GetFEModel();
const FETimeInfo& tp = fem.GetTime();
// get the mesh
FEMesh& mesh = fem.GetMesh();
// setup the linear system
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alpha, m_nreq);
// calculate the stiffness matrix for each domain
for (int i=0; i<mesh.Domains(); ++i)
{
if (mesh.Domain(i).IsActive())
{
FEElasticDomain& dom = dynamic_cast<FEElasticDomain&>(mesh.Domain(i));
dom.StiffnessMatrix(LS);
}
}
// calculate the body force stiffness matrix for each non-rigid domain
for (int j = 0; j<fem.ModelLoads(); ++j)
{
FEModelLoad* pml = fem.ModelLoad(j);
if (pml->IsActive()) pml->StiffnessMatrix(LS);
}
// TODO: add body force stiffness for rigid bodies
// Add mass matrix for dynamic problems
FEAnalysis* pstep = fem.GetCurrentStep();
if (pstep->m_nanalysis == FESolidAnalysis::DYNAMIC)
{
// scale factor
double dt = tp.timeIncrement;
double a = tp.alpham / (m_beta*dt*dt);
// loop over all elastic domains
for (int i = 0; i<mesh.Domains(); ++i)
{
FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(&mesh.Domain(i));
if (edom) edom->MassMatrix(LS, a);
}
m_rigidSolver.RigidMassMatrix(LS, tp);
}
// calculate contact stiffness
ContactStiffness(LS);
// calculate stiffness matrices for surface loads
// for arclength method we need to apply the scale factor to all the
// external forces stiffness matrix.
if (m_arcLength > 0) LS.StiffnessAssemblyScaleFactor(m_al_lam);
/* int nsl = fem.SurfaceLoads();
for (int i = 0; i<nsl; ++i)
{
FESurfaceLoad* psl = fem.SurfaceLoad(i);
if (psl->IsActive())
{
psl->StiffnessMatrix(LS, tp);
}
}
if (m_arcLength > 0) LS.StiffnessAssemblyScaleFactor(1.0);
*/
// calculate nonlinear constraint stiffness
// note that this is the contribution of the
// constrainst enforced with augmented lagrangian
NonLinearConstraintStiffness(LS, tp);
// add contributions from rigid bodies
m_rigidSolver.StiffnessMatrix(*m_pK, tp);
return true;
}
//-----------------------------------------------------------------------------
//! Calculate the stiffness contribution due to nonlinear constraints
void FESolidSolver2::NonLinearConstraintStiffness(FELinearSystem& LS, const FETimeInfo& tp)
{
FEModel& fem = *GetFEModel();
int N = fem.NonlinearConstraints();
for (int i=0; i<N; ++i)
{
FENLConstraint* plc = fem.NonlinearConstraint(i);
if (plc->IsActive()) plc->StiffnessMatrix(LS, tp);
}
}
//-----------------------------------------------------------------------------
//! This function calculates the contact stiffness matrix
void FESolidSolver2::ContactStiffness(FELinearSystem& LS)
{
FEModel& fem = *GetFEModel();
const FETimeInfo& tp = fem.GetTime();
for (int i = 0; i<fem.SurfacePairConstraints(); ++i)
{
FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i));
if (pci->IsActive()) pci->StiffnessMatrix(LS, tp);
}
}
//-----------------------------------------------------------------------------
//! Calculates the contact forces
void FESolidSolver2::ContactForces(FEGlobalVector& R)
{
FEModel& fem = *GetFEModel();
const FETimeInfo& tp = fem.GetTime();
for (int i = 0; i<fem.SurfacePairConstraints(); ++i)
{
FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i));
if (pci->IsActive()) pci->LoadVector(R, tp);
}
}
//-----------------------------------------------------------------------------
//! calculates the residual vector
//! Note that the concentrated nodal forces are not calculated here.
//! This is because they do not depend on the geometry
//! so we only calculate them once (in Quasin) and then add them here.
bool FESolidSolver2::Residual(vector<double>& R)
{
// get the time information
FEModel& fem = *GetFEModel();
const FETimeInfo& tp = fem.GetTime();
// zero nodal reaction forces
zero(m_Fr);
// setup the global vector
zero(R);
FEResidualVector RHS(fem, R, m_Fr);
// zero rigid body reaction forces
m_rigidSolver.Residual();
// calculate the internal (stress) forces
InternalForces(RHS);
// calculate nodal reaction forces
for (int i = 0; i < m_neq; ++i) m_Fr[i] -= R[i];
// extract the internal forces
// (only when we really need it, below)
if (m_logSolve && fem.GetCurrentStep()->m_ntimesteps > 0)
{
m_Fint = R;
}
if (m_arcLength > 0)
{
// Note the negative sign. This is because during residual assembly
// a negative sign is applied to the internal force vector.
// The model loads assume the residual is Fe - Fi (i.e. -R)
m_Fint = -R;
}
// calculate external forces
ExternalForces(RHS);
// For arc-length we need the external loads
if (m_arcLength > 0)
{
// extract the external force
m_Fext = R + m_Fint;
// we need to apply the arc-length factor to the external loads
for (int i=0; i<R.size();++i) R[i] = m_Fext[i]* m_al_lam - m_Fint[i];
}
// apply the residual transformation
// NOTE: This is an implementation of Ankush Aggarwal method to accelerate the Newton convergence
if (m_logSolve && fem.GetCurrentStep()->m_ntimesteps > 0)
{
double TOL = 1.e-8;
bool logused = false;
vector<double> RHSlog;
RHSlog.resize(R.size());
for (int i = 0; i<m_Fint.size(); ++i)
{
if (fabs(RHS[i] - m_Fint[i])>TOL && fabs(m_Fint[i])>TOL && (m_Fint[i] - RHS[i]) / m_Fint[i]>0)
{
RHSlog[i] = -m_Fint[i] * log((m_Fint[i] - RHS[i]) / m_Fint[i]);
logused = true;
}
else
{
RHSlog[i] = RHS[i];
}
}
for (int i = 0; i<m_Fint.size(); ++i) R[i] = RHSlog[i];
if (logused)
feLog("Log method used\n");
}
// increase RHS counter
m_nrhs++;
return true;
}
//-----------------------------------------------------------------------------
//! Internal forces
void FESolidSolver2::InternalForces(FEGlobalVector& R)
{
FEMesh& mesh = GetFEModel()->GetMesh();
for (int i = 0; i<mesh.Domains(); ++i)
{
FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(&mesh.Domain(i));
if (edom) edom->InternalForces(R);
}
}
//-----------------------------------------------------------------------------
//! external forces
void FESolidSolver2::ExternalForces(FEGlobalVector& RHS)
{
FEModel& fem = *GetFEModel();
const FETimeInfo& tp = fem.GetTime();
FEMesh& mesh = fem.GetMesh();
// apply loads
for (int j = 0; j<fem.ModelLoads(); ++j)
{
FEModelLoad* pml = fem.ModelLoad(j);
if (pml->IsActive()) pml->LoadVector(RHS);
}
// calculate inertial forces for dynamic problems
if (fem.GetCurrentStep()->m_nanalysis == FESolidAnalysis::DYNAMIC)
{
// allocate F
vector<double> F;
// calculate the inertial forces for all elastic domains
for (int nd = 0; nd < mesh.Domains(); ++nd)
{
FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(&mesh.Domain(nd));
if (edom) edom->InertialForces(RHS, F);
}
// update rigid bodies
m_rigidSolver.InertialForces(RHS, tp);
}
// calculate forces due to surface loads
/* int nsl = fem.SurfaceLoads();
for (int i = 0; i<nsl; ++i)
{
FESurfaceLoad* psl = fem.SurfaceLoad(i);
if (psl->IsActive()) psl->LoadVector(RHS, tp);
}
*/
// calculate contact forces
ContactForces(RHS);
// calculate nonlinear constraint forces
// note that these are the linear constraints
// enforced using the augmented lagrangian
NonLinearConstraintForces(RHS, tp);
// forces due to point constraints
// for (i=0; i<(int) fem.m_PC.size(); ++i) fem.m_PC[i]->Residual(this, R);
// set the nodal reaction forces
// TODO: Is this a good place to do this?
for (int i = 0; i<mesh.Nodes(); ++i)
{
FENode& node = mesh.Node(i);
node.set_load(m_dofU[0], 0);
node.set_load(m_dofU[1], 0);
node.set_load(m_dofU[2], 0);
int n;
if ((n = node.m_ID[m_dofU[0]]) >= 0) node.set_load(m_dofU[0], -m_Fr[n]);
if ((n = -node.m_ID[m_dofU[0]] - 2) >= 0) node.set_load(m_dofU[0], -m_Fr[n]);
if ((n = node.m_ID[m_dofU[1]]) >= 0) node.set_load(m_dofU[1], -m_Fr[n]);
if ((n = -node.m_ID[m_dofU[1]] - 2) >= 0) node.set_load(m_dofU[1], -m_Fr[n]);
if ((n = node.m_ID[m_dofU[2]]) >= 0) node.set_load(m_dofU[2], -m_Fr[n]);
if ((n = -node.m_ID[m_dofU[2]] - 2) >= 0) node.set_load(m_dofU[2], -m_Fr[n]);
// add nodal loads
double s = (m_arcLength>0 ? m_al_lam : 1.0);
// if ((n = node.m_ID[m_dofU[0]]) >= 0) node.set_load(m_dofU[0], -m_Fn[n]*s);
// if ((n = node.m_ID[m_dofU[1]]) >= 0) node.set_load(m_dofU[1], -m_Fn[n]*s);
// if ((n = node.m_ID[m_dofU[2]]) >= 0) node.set_load(m_dofU[2], -m_Fn[n]*s);
}
}
//-----------------------------------------------------------------------------
//! calculate the nonlinear constraint forces
void FESolidSolver2::NonLinearConstraintForces(FEGlobalVector& R, const FETimeInfo& tp)
{
FEModel& fem = *GetFEModel();
int N = fem.NonlinearConstraints();
for (int i=0; i<N; ++i)
{
FENLConstraint* plc = fem.NonlinearConstraint(i);
if (plc->IsActive()) plc->LoadVector(R, tp);
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEContactGapCriterion.cpp | .cpp | 2,884 | 90 | /*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 "FEContactGapCriterion.h"
#include <FECore/FEModel.h>
#include <FECore/FEAnalysis.h>
#include "FEContactInterface.h"
#include "FEContactSurface.h"
BEGIN_FECORE_CLASS(FEContactGapCriterion, FEMeshAdaptorCriterion)
ADD_PARAMETER(m_gap, "gap");
END_FECORE_CLASS();
FEContactGapCriterion::FEContactGapCriterion(FEModel* fem) : FEMeshAdaptorCriterion(fem)
{
m_gap = 0;
}
FEMeshAdaptorSelection FEContactGapCriterion::GetElementSelection(FEElementSet* elset)
{
FEMeshAdaptorSelection sel;
FEModel& fem = *GetFEModel();
FEMesh& mesh = fem.GetMesh();
for (int i = 0; i < fem.SurfacePairConstraints(); ++i)
{
FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i));
if (pci && pci->IsActive())
{
FEContactSurface* pcs = dynamic_cast<FEContactSurface*>(pci->GetPrimarySurface());
if (pcs)
{
for (int j = 0; j < pcs->Elements(); ++j)
{
FESurfaceElement& face = pcs->Element(j);
if (face.isActive())
{
int nint = face.GaussPoints();
double max_gap = m_gap;
for (int k = 0; k < nint; ++k)
{
FEMaterialPoint* mp = face.GetMaterialPoint(k);
FEContactMaterialPoint* cp = dynamic_cast<FEContactMaterialPoint*>(mp);
if (cp)
{
if (cp->m_gap > max_gap) max_gap = cp->m_gap;
}
}
if (max_gap > m_gap)
{
FEElement* pe = face.m_elem[0].pe;
if (pe)
{
// TODO: Add check for duplicate element addition
sel.push_back({ pe->GetID(), max_gap});
}
}
}
}
}
}
}
return sel;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEIsoHencky.h | .h | 2,118 | 59 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! Neo Hookean material
//! Implementation of an isotropic Hencky hyperelastic material.
class FEBIOMECH_API FEIsoHencky : public FEElasticMaterial
{
public:
FEIsoHencky(FEModel* pfem);
public:
FEParamDouble m_E; //!< Young's modulus
FEParamDouble m_v; //!< Poisson's ratio
public:
//! calculate stress at material point
virtual mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
virtual tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
virtual double StrainEnergyDensity(FEMaterialPoint& pt) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedActiveContractionTransIso.cpp | .cpp | 3,366 | 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.*/
#include "stdafx.h"
#include "FEPrescribedActiveContractionTransIso.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEPrescribedActiveContractionTransIso, FEElasticMaterial)
ADD_PARAMETER(m_T0 , "T0" );
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEPrescribedActiveContractionTransIso::FEPrescribedActiveContractionTransIso(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_T0 = 0.0;
}
//-----------------------------------------------------------------------------
bool FEPrescribedActiveContractionTransIso::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 FEPrescribedActiveContractionTransIso::Serialize(DumpStream& ar)
{
FEElasticMaterial::Serialize(ar);
if (ar.IsShallow()) return;
ar & m_n0;
}
//-----------------------------------------------------------------------------
mat3ds FEPrescribedActiveContractionTransIso::Stress(FEMaterialPoint &mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
mat3ds b = pt.LeftCauchyGreen();
// 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 = (b-N)*(T0/J);
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEPrescribedActiveContractionTransIso::Tangent(FEMaterialPoint &mp)
{
tens4ds c;
c.zero();
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEEdgeToSurfaceContactPotential.h | .h | 3,147 | 119 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FESurfaceConstraint.h>
#include <FECore/FEEdge.h>
#include "FEContactSurface.h"
#include <set>
class FEE2SCPPoint : public FELineMaterialPoint
{
public:
double m_gap = 0.0;
double m_Ln = 0.0;
vec3d m_tc;
void Serialize(DumpStream& ar) override
{
FELineMaterialPoint::Serialize(ar);
ar& m_tc & m_gap;
}
};
class FEE2SCPSurface : public FESurface
{
public:
FEE2SCPSurface(FEModel* fem);
void Update();
};
class FEE2SCPEdge : public FEEdge
{
public:
FEE2SCPEdge(FEModel* fem);
FEMaterialPoint* CreateMaterialPoint() override;
void Update();
bool Create(FESegmentSet& eset) override;
};
class FEEdgeToSurfaceContactPotential : public FESurfaceConstraint
{
public:
FEEdgeToSurfaceContactPotential(FEModel* fem);
public:
//! return the surface
FESurface* GetSurface() override;
// Build the matrix profile
void BuildMatrixProfile(FEGlobalMatrix& M) override;
// update
void Update() override;
// init
bool Init() override;
// serialization
void Serialize(DumpStream& ar) override;
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(FELineElement& el1, FESurfaceElement& el2, std::vector<double>& fe);
void ElementStiffness(FELineElement& el1, FESurfaceElement& el2, matrix& ke);
double PotentialDerive(double r);
double PotentialDerive2(double r);
protected:
FEE2SCPEdge m_edge;
FEE2SCPSurface m_surf;
protected:
double m_kc;
double m_p;
double m_Rin;
double m_Rout;
double m_Rmin;
double m_wtol;
double m_c1, m_c2;
std::vector< std::set<FESurfaceElement*> > m_activeElements;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEGentMaterial.cpp | .cpp | 4,986 | 171 | /*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 "FEGentMaterial.h"
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FEGentMaterial, FEUncoupledMaterial)
ADD_PARAMETER(m_G , FE_RANGE_GREATER(0.0), "G")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_Jm, FE_RANGE_GREATER(0.0), "Jm");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEGentMaterial::FEGentMaterial(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_G = 0.0;
m_Jm = 0.0;
}
//-----------------------------------------------------------------------------
mat3ds FEGentMaterial::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
double J = ep.m_J;
mat3ds b = ep.DevLeftCauchyGreen();
double I1 = b.tr();
double mu = m_G;
double Jm = m_Jm;
double W1 = 0.5*mu*Jm / (Jm - I1 + 3.0);
mat3ds T = b*W1;
return T.dev()*(2.0/J);
}
//-----------------------------------------------------------------------------
tens4ds FEGentMaterial::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();
// Invariants of B (= invariants of C)
double I1 = B.tr();
// --- TODO: put strain energy derivatives here ---
// Wi = dW/dIi
double W1 = 0.5*m_G*m_Jm / (m_Jm - I1 + 3.0);
// ---
// calculate dWdC:C
double WC = W1*I1;
// deviatoric cauchy-stress
mat3ds T = B*W1;
T = 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);
tens4ds c = dyad1s(T, I)*(-2.0/3.0) + (I4 - IxI/3.0)*(4.0/3.0*Ji*WC);
return c;
}
//=============================================================================
BEGIN_FECORE_CLASS(FECompressibleGentMaterial, FEElasticMaterial)
ADD_PARAMETER(m_G , FE_RANGE_GREATER(0.0), "G")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_K , FE_RANGE_GREATER(0.0), "K")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_Jm, FE_RANGE_GREATER(0.0), "Jm");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FECompressibleGentMaterial::FECompressibleGentMaterial(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_G = 0.0;
m_K = 0.0;
m_Jm = 0.0;
}
//-----------------------------------------------------------------------------
mat3ds FECompressibleGentMaterial::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
double J = ep.m_J;
mat3ds b = ep.LeftCauchyGreen();
double I1 = b.tr();
double mu = m_G;
double k = m_K;
double Jm = m_Jm;
double W1 = 0.5*mu*Jm / (Jm - I1 + 3.0);
double h = 0.5*(J*J - 1.0) - log(J);
double WJ = 2.0*k*(h*h*h)*(J - 1.0/J);
mat3dd I(1.0);
mat3ds s = b*(2.0*W1/J) + I*WJ;
return s;
}
//-----------------------------------------------------------------------------
tens4ds FECompressibleGentMaterial::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
double J = ep.m_J;
mat3ds b = ep.LeftCauchyGreen();
double I1 = b.tr();
double mu = m_G;
double k = m_K;
double Jm = m_Jm;
double W11 = 0.5*mu*Jm/((Jm-I1+3)*(Jm-I1+3));
double h = 0.5*(J*J - 1.0) - log(J);
double WJ = 2.0*k*(h*h*h)*(J - 1.0/J);
double WJJ = 6*k*h*h*(J-1.0/J)*(J-1.0/J) + 2*k*h*h*h*(1.0 + 1.0/(J*J));
mat3dd I(1.0);
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxB = dyad1s(b);
tens4ds c = BxB*(4.0*W11/J) + IxI*(WJ + J*WJJ) - I4*(2*WJ);
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FECarreauYasudaViscousSolid.cpp | .cpp | 3,684 | 101 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FECarreauYasudaViscousSolid.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FECarreauYasudaViscousSolid, FEElasticMaterial)
ADD_PARAMETER(m_mu0, FE_RANGE_GREATER_OR_EQUAL(0.0), "mu0");
ADD_PARAMETER(m_mui, FE_RANGE_GREATER_OR_EQUAL(0.0), "mui");
ADD_PARAMETER(m_lam, FE_RANGE_GREATER_OR_EQUAL(0.0), "lambda");
ADD_PARAMETER(m_n , FE_RANGE_GREATER_OR_EQUAL(0.0), "n");
ADD_PARAMETER(m_a , FE_RANGE_GREATER_OR_EQUAL(2.0), "a");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
mat3ds FECarreauYasudaViscousSolid::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds D = pt.RateOfDeformation();
// double d[3];
// D.eigen(d);
double mu0 = m_mu0(mp);
double mui = m_mui(mp);
double lam = m_lam(mp);
double n = m_n(mp);
double a = m_a(mp);
double gdot = sqrt(2*(D.sqr()).tr());
// double gdot = max(fabs(d[2]-d[1]),max(fabs(d[0]-d[2]),fabs(d[1]-d[0])));
double lamga = pow(lam*gdot,a);
double mu = mui + (mu0 - mui)*pow(1+lamga, (n-1)/a);
mat3ds s = D*(2*mu);
return s;
}
//-----------------------------------------------------------------------------
tens4ds FECarreauYasudaViscousSolid::Tangent(FEMaterialPoint& mp)
{
const FETimeInfo& tp = GetTimeInfo();
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
tens4ds Cv;
if (tp.timeIncrement > 0) {
mat3ds D = pt.RateOfDeformation();
double mu0 = m_mu0(mp);
double mui = m_mui(mp);
double lam = m_lam(mp);
double n = m_n(mp);
double a = m_a(mp);
double gdot = sqrt(2*(D.sqr()).tr());
double lamga = pow(lam*gdot,a);
double mu = mui + (mu0 - mui)*pow(1+lamga, (n-1)/a);
double dmu = 2*(mu0 - mui)*(n-1)*pow(lam,a)*pow(gdot,a-2)*pow(1+lamga, (n-a-1)/a);
mat3dd I(1);
double tmp = tp.alphaf*tp.gamma/(tp.beta*tp.timeIncrement);
Cv = (dyad1s(D)*(2*dmu) + dyad4s(I)*(2*mu))*tmp;
}
else Cv.zero();
return Cv;
}
//-----------------------------------------------------------------------------
double FECarreauYasudaViscousSolid::StrainEnergyDensity(FEMaterialPoint& mp)
{
return 0;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEActiveFiberStressUC.h | .h | 3,381 | 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 <FECore/tens4d.h>
#include <FECore/FEFunction1D.h>
#include "FEUncoupledMaterial.h"
//-----------------------------------------------------------------------------
class FEActiveFiberStressUC : public FEUncoupledMaterial
{
public:
class Data : public FEMaterialPointData
{
public:
double m_lamp;
public:
void Update()
{
// TODO:
}
void Serialize(DumpStream& ar) override;
};
public:
FEActiveFiberStressUC(FEModel* fem);
mat3ds DevStress(FEMaterialPoint& mp) override;
tens4ds DevTangent(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/FEContactSurface.cpp | .cpp | 9,160 | 245 | /*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 "FEContactSurface.h"
#include "FECore/FEModel.h"
#include "FEBioMech/FEElasticMaterial.h"
#include <assert.h>
//-----------------------------------------------------------------------------
FEContactSurface::FEContactSurface(FEModel* pfem) : FESurface(pfem), m_pfem(pfem)
{
m_pContactInterface = nullptr;
m_pSibling = nullptr;
m_dofX = -1;
m_dofY = -1;
m_dofZ = -1;
}
//-----------------------------------------------------------------------------
FEContactSurface::~FEContactSurface()
{
m_pSibling = nullptr;
m_pContactInterface = nullptr;
}
//-----------------------------------------------------------------------------
bool FEContactSurface::Init()
{
// I want to use the FEModel class for this, but don't know how
DOFS& dofs = GetFEModel()->GetDOFS();
m_dofX = dofs.GetDOF("x");
m_dofY = dofs.GetDOF("y");
m_dofZ = dofs.GetDOF("z");
SetInterfaceStatus(true);
return FESurface::Init();
}
//-----------------------------------------------------------------------------
// serialization
void FEContactSurface::Serialize(DumpStream& ar)
{
FESurface::Serialize(ar);
if (ar.IsShallow() == false)
{
ar & m_dofX & m_dofY & m_dofZ;
}
}
//-----------------------------------------------------------------------------
void FEContactSurface::SetSibling(FEContactSurface* ps) { m_pSibling = ps; }
//-----------------------------------------------------------------------------
void FEContactSurface::SetContactInterface(FEContactInterface* ps) { m_pContactInterface = ps; }
//-----------------------------------------------------------------------------
void FEContactSurface::GetVectorGap(int nface, vec3d& pg) {}
//-----------------------------------------------------------------------------
void FEContactSurface::GetContactTraction(int nface, vec3d& pt) {}
//-----------------------------------------------------------------------------
void FEContactSurface::GetNodalVectorGap(int nface, vec3d* pg) {}
//-----------------------------------------------------------------------------
void FEContactSurface::GetNodalContactPressure(int nface, double* pg) {}
//-----------------------------------------------------------------------------
void FEContactSurface::GetNodalContactTraction(int nface, vec3d* pt) {}
//-----------------------------------------------------------------------------
vec3d FEContactSurface::GetContactForce() { return vec3d(0,0,0); }
//-----------------------------------------------------------------------------
double FEContactSurface::GetContactArea() { return 0; }
//-----------------------------------------------------------------------------
// Evaluate surface traction from the stress tensor of the attached solid element
void FEContactSurface::GetSurfaceTraction(int nface, vec3d& pt)
{
FESurfaceElement& el = Element(nface);
FEElement* e = el.m_elem[0].pe;
FESolidElement* se = dynamic_cast<FESolidElement*>(e);
if (se) {
mat3ds si[FEElement::MAX_INTPOINTS];
mat3ds so[FEElement::MAX_NODES];
for (int i=0; i<se->GaussPoints(); ++i) {
FEMaterialPoint* pt = se->GetMaterialPoint(i);
FEElasticMaterialPoint* ep = pt->ExtractData<FEElasticMaterialPoint>();
if (ep)
si[i] = ep->m_s;
else
si[i].zero();
}
// project stresses from integration points to nodes
se->project_to_nodes(si, so);
// only keep the stresses at the nodes of the contact face
mat3ds sn[FEElement::MAX_NODES];
for (int i=0; i<el.Nodes(); ++i)
sn[i] = so[se->FindNode(el.m_node[i])];
// evaluate tractions at integration points of that face
vec3d t[FEElement::MAX_INTPOINTS];
for (int i=0; i<el.GaussPoints(); ++i) {
double *H = el.H(i);
t[i] = vec3d(0,0,0);
for (int j=0; j<el.Nodes(); ++j) {
vec3d n = SurfaceNormal(el, j);
t[i] += sn[j]*n*H[j];
}
}
// now save the average traction on that face
int ni = el.GaussPoints();
pt = vec3d(0,0,0);
for (int k=0; k<ni; ++k) pt += t[k];
pt /= ni;
}
else
pt = vec3d(0,0,0);
}
//-----------------------------------------------------------------------------
// Evaluate surface traction from the stress tensor of the attached solid element
void FEContactSurface::GetNodalSurfaceTraction(int nface, vec3d* pt)
{
FESurfaceElement& el = Element(nface);
FEElement* e = el.m_elem[0].pe;
FESolidElement* se = dynamic_cast<FESolidElement*>(e);
if (se) {
mat3ds si[FEElement::MAX_INTPOINTS];
mat3ds so[FEElement::MAX_NODES];
for (int i=0; i<se->GaussPoints(); ++i) {
FEMaterialPoint* pt = se->GetMaterialPoint(i);
FEElasticMaterialPoint* ep = pt->ExtractData<FEElasticMaterialPoint>();
if (ep)
si[i] = ep->m_s;
else
si[i].zero();
}
// project stresses from integration points to nodes
se->project_to_nodes(si, so);
// only keep the stresses at the nodes of the contact face
mat3ds sn[FEElement::MAX_NODES];
for (int i=0; i<el.Nodes(); ++i)
sn[i] = so[se->FindNode(el.m_node[i])];
// evaluate tractions at integration points of that face
vec3d t[FEElement::MAX_INTPOINTS];
for (int i=0; i<el.GaussPoints(); ++i) {
double *H = el.H(i);
t[i] = vec3d(0,0,0);
for (int j=0; j<el.Nodes(); ++j) {
vec3d n = SurfaceNormal(el, j);
t[i] += sn[j]*n*H[j];
}
}
// now project the traction from integration points back to nodes
el.project_to_nodes(t, pt);
}
else
for (int i=0; i<el.Nodes(); ++i) pt[i] = vec3d(0,0,0);
}
//-----------------------------------------------------------------------------
// Evaluate surface traction from the stress tensor of the attached solid element
void FEContactSurface::GetGPSurfaceTraction(int nface, vec3d* pt)
{
FESurfaceElement& el = Element(nface);
FEElement* e = el.m_elem[0].pe;
FESolidElement* se = dynamic_cast<FESolidElement*>(e);
if (se) {
mat3ds si[FEElement::MAX_INTPOINTS];
mat3ds so[FEElement::MAX_NODES];
for (int i=0; i<se->GaussPoints(); ++i) {
FEMaterialPoint* pt = se->GetMaterialPoint(i);
FEElasticMaterialPoint* ep = pt->ExtractData<FEElasticMaterialPoint>();
if (ep)
si[i] = ep->m_s;
else
si[i].zero();
}
// project stresses from integration points to nodes
se->project_to_nodes(si, so);
// only keep the stresses at the nodes of the contact face
mat3ds sn[FEElement::MAX_NODES];
for (int i=0; i<el.Nodes(); ++i)
sn[i] = so[se->FindNode(el.m_node[i])];
// evaluate tractions at integration points of that face
for (int i=0; i<el.GaussPoints(); ++i) {
double *H = el.H(i);
pt[i] = vec3d(0,0,0);
for (int j=0; j<el.Nodes(); ++j) {
vec3d n = SurfaceNormal(el, j);
pt[i] += sn[j]*n*H[j];
}
}
}
else
for (int i=0; i<el.Nodes(); ++i) pt[i] = vec3d(0,0,0);
}
//-----------------------------------------------------------------------------
void FEContactSurface::GetStickStatus(int nface, double& pt) {}
//-----------------------------------------------------------------------------
void FEContactSurface::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];
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FESlidingElasticInterface.cpp | .cpp | 58,268 | 1,840 | /*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 "FESlidingElasticInterface.h"
#include "FECore/FENormalProjection.h"
#include "FECore/FEModel.h"
#include "FECore/FEAnalysis.h"
#include <FECore/FELinearSystem.h>
#include <FECore/log.h>
//-----------------------------------------------------------------------------
// Define sliding interface parameters
BEGIN_FECORE_CLASS(FESlidingElasticInterface, FEContactInterface)
ADD_PARAMETER(m_laugon , "laugon" )->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0");
ADD_PARAMETER(m_atol , "tolerance" );
ADD_PARAMETER(m_gtol , "gaptol" )->setUnits(UNIT_LENGTH);
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" )->setUnits(UNIT_LENGTH);;
ADD_PARAMETER(m_nsegup , "seg_up" );
ADD_PARAMETER(m_btension , "tension" );
ADD_PARAMETER(m_naugmin , "minaug" );
ADD_PARAMETER(m_naugmax , "maxaug" );
ADD_PARAMETER(m_breloc , "node_reloc" );
ADD_PARAMETER(m_mu , "fric_coeff" );
ADD_PARAMETER(m_bsmaug , "smooth_aug" );
ADD_PARAMETER(m_bflips , "flip_primary" );
ADD_PARAMETER(m_bflipm , "flip_secondary" );
ADD_PARAMETER(m_bshellbs , "shell_bottom_primary" );
ADD_PARAMETER(m_bshellbm , "shell_bottom_secondary");
ADD_PARAMETER(m_offset , "offset" )->setUnits(UNIT_LENGTH);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FESlidingElasticSurface::Data::Data()
{
m_Lmd = 0.0;
m_epsn = 1.0;
m_Lmt = vec3d(0,0,0);
m_nu = m_s1 = m_dg = vec3d(0,0,0);
m_tr = vec3d(0,0,0);
m_rs = m_rsp = vec2d(0,0);
m_bstick = false;
}
//-----------------------------------------------------------------------------
void FESlidingElasticSurface::Data::Init()
{
FEContactMaterialPoint::Init();
m_Lmd = 0.0;
m_epsn = 1.0;
m_Lmt = vec3d(0, 0, 0);
m_nu = m_s1 = m_dg = vec3d(0, 0, 0);
m_tr = vec3d(0, 0, 0);
m_rs = m_rsp = vec2d(0, 0);
m_bstick = false;
}
//-----------------------------------------------------------------------------
void FESlidingElasticSurface::Data::Serialize(DumpStream& ar)
{
FEContactMaterialPoint::Serialize(ar);
ar & m_dg;
ar & m_Lmd;
ar & m_epsn;
ar & m_Lmt;
ar & m_nu;
ar & m_s1;
ar & m_tr;
ar & m_rs;
ar & m_rsp;
ar & m_bstick;
}
//-----------------------------------------------------------------------------
// FESlidingElasticSurface
//-----------------------------------------------------------------------------
FESlidingElasticSurface::FESlidingElasticSurface(FEModel* pfem) : FEContactSurface(pfem)
{
}
//-----------------------------------------------------------------------------
bool FESlidingElasticSurface::Init()
{
// initialize surface data first
if (FEContactSurface::Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
void FESlidingElasticSurface::InitSlidingSurface()
{
for (int i=0; i<Elements(); ++i)
{
FESurfaceElement& el = Element(i);
int nint = el.GaussPoints();
for (int j=0; j<nint; ++j)
{
Data& data = static_cast<Data&>(*el.GetMaterialPoint(j));
// Store current surface projection values as previous
data.m_rsp = data.m_rs;
data.m_pmep = data.m_pme;
}
}
}
//-----------------------------------------------------------------------------
//! create material point data
FEMaterialPoint* FESlidingElasticSurface::CreateMaterialPoint()
{
return new FESlidingElasticSurface::Data;
}
//-----------------------------------------------------------------------------
//! serialization
void FESlidingElasticSurface::Serialize(DumpStream& ar)
{
FEContactSurface::Serialize(ar);
ar & m_Ft;
}
//-----------------------------------------------------------------------------
vec3d FESlidingElasticSurface::GetContactForce()
{
return m_Ft;
}
//-----------------------------------------------------------------------------
double FESlidingElasticSurface::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 s = (data.m_Ln > 0) ? 1 : 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*s);
}
}
return a;
}
//-----------------------------------------------------------------------------
void FESlidingElasticSurface::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 FESlidingElasticSurface::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;
}
//-----------------------------------------------------------------------------
void FESlidingElasticSurface::GetNodalVectorGap(int nface, vec3d* pg)
{
FESurfaceElement& el = Element(nface);
int ni = el.GaussPoints();
vec3d gi[FEElement::MAX_INTPOINTS];
for (int k = 0; k < ni; ++k)
{
Data& data = static_cast<Data&>(*el.GetMaterialPoint(k));
gi[k] = data.m_dg;
}
el.project_to_nodes(gi, pg);
}
//-----------------------------------------------------------------------------
void FESlidingElasticSurface::GetNodalContactPressure(int nface, double* pg)
{
FESurfaceElement& el = Element(nface);
int ni = el.GaussPoints();
double ti[FEElement::MAX_INTPOINTS];
for (int k = 0; k < ni; ++k)
{
Data& data = static_cast<Data&>(*el.GetMaterialPoint(k));
ti[k] = data.m_Ln;
}
el.FEElement::project_to_nodes(ti, pg);
}
//-----------------------------------------------------------------------------
void FESlidingElasticSurface::GetNodalContactTraction(int nface, vec3d* pt)
{
FESurfaceElement& el = Element(nface);
int ni = el.GaussPoints();
vec3d ti[FEElement::MAX_INTPOINTS];
for (int k = 0; k < ni; ++k)
{
Data& data = static_cast<Data&>(*el.GetMaterialPoint(k));
ti[k] = data.m_tr;
}
el.project_to_nodes(ti, pt);
}
//-----------------------------------------------------------------------------
void FESlidingElasticSurface::GetStickStatus(int nface, double& pg)
{
FESurfaceElement& el = Element(nface);
int ni = el.GaussPoints();
pg = 0;
for (int k = 0; k < ni; ++k)
{
Data& data = static_cast<Data&>(*el.GetMaterialPoint(k));
if (data.m_bstick) pg += 1.0;
}
pg /= ni;
}
//-----------------------------------------------------------------------------
// FESlidingElasticInterface
//-----------------------------------------------------------------------------
FESlidingElasticInterface::FESlidingElasticInterface(FEModel* pfem) : FEContactInterface(pfem), m_ss(pfem), m_ms(pfem)
{
static int count = 1;
SetID(count++);
// initial values
m_knmult = 0;
m_atol = 0.1;
m_epsn = 1;
m_btwo_pass = false;
m_gtol = 0;
m_stol = 0.01;
m_bsymm = true;
m_srad = 1.0;
m_nsegup = 0;
m_bautopen = false;
m_bupdtpen = false;
m_btension = false;
m_breloc = false;
m_bsmaug = false;
m_mu = 0.0;
m_naugmin = 0;
m_naugmax = 10;
m_bfreeze = false;
m_bflipm = m_bflips = false;
m_bshellbm = m_bshellbs = false;
m_offset = 0;
// set parents
m_ss.SetContactInterface(this);
m_ms.SetContactInterface(this);
m_ss.SetSibling(&m_ms);
m_ms.SetSibling(&m_ss);
}
//-----------------------------------------------------------------------------
FESlidingElasticInterface::~FESlidingElasticInterface()
{
}
//-----------------------------------------------------------------------------
bool FESlidingElasticInterface::Init()
{
// check friction and tension parameters
// since they cannot be used simultaneously
if ((m_mu != 0) && m_btension) {
feLogError("The tension option cannot be used with friction in sliding-elastic.");
return false;
}
// when the friction coefficient is non-zero include higher-order terms in stiffness matrix
if (m_mu != 0) m_knmult = 1;
// 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; }
if (m_bshellbs) { m_ss.SetShellBottom(m_bshellbs); m_bshellbs = false; }
if (m_bshellbm) { m_ms.SetShellBottom(m_bshellbm); m_bshellbm = false; }
return true;
}
//-----------------------------------------------------------------------------
void FESlidingElasticInterface::UpdateAutoPenalty()
{
// calculate the penalty
if (m_bautopen)
{
CalcAutoPenalty(m_ss);
CalcAutoPenalty(m_ms);
}
}
//-----------------------------------------------------------------------------
void FESlidingElasticInterface::Activate()
{
// don't forget to call the base class!
FEContactInterface::Activate();
UpdateAutoPenalty();
// update sliding interface data
Update();
}
//-----------------------------------------------------------------------------
//! build the matrix profile for use in the stiffness matrix
void FESlidingElasticInterface::BuildMatrixProfile(FEGlobalMatrix& K)
{
FEModel& fem = *GetFEModel();
FEMesh& mesh = fem.GetMesh();
// 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*FEElement::MAX_NODES*2);
int npass = (m_btwo_pass?2:1);
for (int np=0; np<npass; ++np)
{
FESlidingElasticSurface& ss = (np == 0? m_ss : m_ms);
int 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)
{
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(*se.GetMaterialPoint(k));
FESurfaceElement* pe = data.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[6*l ] = id[dof_X];
lm[6*l+1] = id[dof_Y];
lm[6*l+2] = id[dof_Z];
lm[6*l+3] = id[dof_RU];
lm[6*l+4] = id[dof_RV];
lm[6*l+5] = id[dof_RW];
}
for (l=0; l<nmeln; ++l)
{
vector<int>& id = mesh.Node(mn[l]).m_ID;
lm[6*(l+nseln) ] = id[dof_X];
lm[6*(l+nseln)+1] = id[dof_Y];
lm[6*(l+nseln)+2] = id[dof_Z];
lm[6*(l+nseln)+3] = id[dof_RU];
lm[6*(l+nseln)+4] = id[dof_RV];
lm[6*(l+nseln)+5] = id[dof_RW];
}
K.build_add(lm);
}
}
}
}
}
//-----------------------------------------------------------------------------
void FESlidingElasticInterface::CalcAutoPenalty(FESlidingElasticSurface& s)
{
// get the mesh
FEMesh& m = GetFEModel()->GetMesh();
// 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)
{
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(*el.GetMaterialPoint(j));
data.m_epsn = eps;
}
}
}
//-----------------------------------------------------------------------------
void FESlidingElasticInterface::ProjectSurface(FESlidingElasticSurface& ss, FESlidingElasticSurface& ms, bool bupseg, bool bmove)
{
FEMesh& mesh = GetFEModel()->GetMesh();
// initialize projection data
FENormalProjection np(ms);
np.SetTolerance(m_stol);
np.SetSearchRadius(m_srad);
np.Init();
double psf = GetPenaltyScaleFactor();
// if we need to project the nodes onto the secondary surface,
// let's do this first
if (bmove)
{
int NN = ss.Nodes();
int NE = ss.Elements();
// first we need to calculate the node normals
vector<vec3d> normal; normal.assign(NN, vec3d(0,0,0));
for (int i=0; i<NE; ++i)
{
FESurfaceElement& el = ss.Element(i);
int ne = el.Nodes();
for (int j=0; j<ne; ++j)
{
vec3d r0, rp, rm;
if (!ss.IsShellBottom()) {
r0 = ss.Node(el.m_lnode[ j ]).m_rt;
rp = ss.Node(el.m_lnode[(j+ 1)%ne]).m_rt;
rm = ss.Node(el.m_lnode[(j+ne-1)%ne]).m_rt;
}
else {
r0 = ss.Node(el.m_lnode[ j ]).st();
rp = ss.Node(el.m_lnode[(j+ 1)%ne]).st();
rm = ss.Node(el.m_lnode[(j+ne-1)%ne]).st();
}
vec3d n = (rp - r0)^(rm - r0);
normal[el.m_lnode[j]] += n;
}
}
for (int i=0; i<NN; ++i) normal[i].unit();
if (ss.IsShellBottom()) for (int i=0; i<NN; ++i) normal[i] = -normal[i];
// loop over all nodes
for (int i=0; i<NN; ++i)
{
FENode& node = ss.Node(i);
// get the spatial nodal coordinates
vec3d rt = ss.IsShellBottom() ? node.st() : node.m_rt;
vec3d nu = normal[i];
// project onto the secondary surface
vec3d q;
double rs[2] = {0,0};
FESurfaceElement* pme = np.Project(rt, nu, rs);
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
// NOTE: this has the opposite sign compared
// to Gerard's notes.
double gap = nu*(rt - q);
if (gap>0) {
if (!ss.IsShellBottom()) {
node.m_r0 = node.m_rt = q;
}
else {
node.m_r0 = node.m_rt = q + node.m_d0;
}
}
}
}
}
// loop over all integration points
#pragma omp parallel for schedule(dynamic)
for (int i=0; i<ss.Elements(); ++i)
{
FESurfaceElement& el = ss.Element(i);
if (el.isActive())
{
int nint = el.GaussPoints();
for (int j = 0; j < nint; ++j)
{
// get the integration point data
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(*el.GetMaterialPoint(j));
// calculate the global position of the integration point
vec3d r = ss.Local2Global(el, j);
// calculate the normal at this integration point
vec3d nu = ss.SurfaceNormal(el, j);
// first see if the old intersected face is still good enough
FESurfaceElement* pme = data.m_pme;
double rs[2] = { 0,0 };
if (pme && pme->isActive())
{
double g;
// see if the ray intersects this element
if (ms.Intersect(*pme, r, nu, rs, g, m_stol))
{
data.m_rs[0] = rs[0];
data.m_rs[1] = rs[1];
}
else
{
pme = 0;
}
}
// find the intersection point with the secondary surface
if (pme == 0 && bupseg) pme = np.Project(r, nu, rs);
data.m_pme = pme;
data.m_nu = nu;
data.m_rs[0] = rs[0];
data.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
// NOTE: this has the opposite sign compared
// to Gerard's notes.
double g = nu * (r - q) + m_offset;
double eps = m_epsn * data.m_epsn * psf;
double Ln = data.m_Lmd + eps * g;
data.m_gap = (g <= m_srad ? g : 0);
if ((g > m_srad) || ((!m_btension) && (Ln < 0))) {
data.m_Lmd = 0;
data.m_pme = 0;
data.m_gap = 0;
data.m_dg = data.m_Lmt = vec3d(0, 0, 0);
}
}
else
{
// the node is not in contact
data.m_Lmd = 0;
data.m_gap = 0;
data.m_dg = data.m_Lmt = vec3d(0, 0, 0);
}
}
}
}
}
//-----------------------------------------------------------------------------
void FESlidingElasticInterface::Update()
{
static int naug = 0;
static int biter = 0;
FEModel& fem = *GetFEModel();
// get the iteration number
// we need this number to see if we can do segment updates or not
// also reset number of iterations after each augmentation
FEAnalysis* pstep = fem.GetCurrentStep();
FESolver* psolver = pstep->GetFESolver();
if (psolver->m_niter == 0) {
biter = 0;
naug = psolver->m_naug;
// check update of auto-penalty
if (m_bautopen && m_bupdtpen) UpdateAutoPenalty();
} else if (psolver->m_naug > naug) {
biter = psolver->m_niter;
naug = psolver->m_naug;
}
int niter = psolver->m_niter - biter;
bool bupseg = ((m_nsegup == 0)? true : (niter <= m_nsegup));
// get the logfile
// Logfile& log = GetLogfile();
// log.printf("seg_up iteration # %d\n", niter+1);
// project the surfaces onto each other
// this will update the gap functions as well
static bool bfirst = true;
ProjectSurface(m_ss, m_ms, bupseg, (m_breloc && bfirst));
bfirst = false;
if (m_btwo_pass) ProjectSurface(m_ms, m_ss, bupseg);
int nsolve_iter = GetFEModel()->GetCurrentStep()->GetFESolver()->m_niter;
if (nsolve_iter == 0)
{
m_ss.InitSlidingSurface();
if (m_btwo_pass) m_ms.InitSlidingSurface();
m_bfreeze = false;
}
// Update the net contact pressures
UpdateContactPressures();
if (niter == 0) m_bfreeze = false;
return;
}
//-----------------------------------------------------------------------------
vec3d FESlidingElasticInterface::SlipTangent(FESlidingElasticSurface& ss, const int nel, const int nint, FESlidingElasticSurface& ms, double& dh, vec3d& r)
{
vec3d s1(0,0,0);
dh = 0;
// get primary surface element
FESurfaceElement& se = ss.Element(nel);
// get integration point data
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(*se.GetMaterialPoint(nint));
double g = data.m_gap;
vec3d nu = data.m_nu;
// find secondary surface element
FESurfaceElement* pme = data.m_pme;
// calculate previous positions
vec3d x2p = ms.Local2GlobalP(*pme, data.m_rs[0], data.m_rs[1]);
vec3d x1p = ss.Local2GlobalP(se, nint);
// calculate dx2
vec3d x2 = ms.Local2Global(*pme, data.m_rs[0], data.m_rs[1]);
vec3d dx2 = x2 - x2p;
// calculate dx1
vec3d x1 = ss.Local2Global(se, nint);
vec3d dx1 = x1 - x1p;
// get current and previous covariant basis vectors
vec3d gscov[2], gscovp[2];
ss.CoBaseVectors(se, nint, gscov);
ss.CoBaseVectorsP(se, nint, gscovp);
// calculate delta gscov
vec3d dgscov[2];
dgscov[0] = gscov[0] - gscovp[0];
dgscov[1] = gscov[1] - gscovp[1];
// calculate m, J, Nhat
vec3d m = ((dgscov[0] ^ gscov[1]) + (gscov[0] ^ dgscov[1]));
double detJ = (gscov[0] ^ gscov[1]).norm();
mat3d Nhat = (mat3dd(1) - (nu & nu));
// calculate q
vec3d c = Nhat*m*(1.0/detJ);
// calculate slip direction s1
double norm = (Nhat*(c*(-g)*m_knmult + dx1 - dx2)).norm();
if (norm != 0)
{
s1 = (Nhat*(c*(-g)*m_knmult + dx1 - dx2))/norm;
dh = norm;
r = c*(-g)*m_knmult + dx1 - dx2;
}
return s1;
}
//-----------------------------------------------------------------------------
vec3d FESlidingElasticInterface::ContactTraction(FESlidingElasticSurface& ss, const int nel, const int n, FESlidingElasticSurface& ms, double& pn)
{
vec3d s1(0,0,0);
vec3d drdot(0,0,0);
vec3d t(0,0,0);
pn = 0;
double tn = 0, ts = 0;
double psf = GetPenaltyScaleFactor();
// get the primary surface element
FESurfaceElement& se = ss.Element(nel);
// get the integration point data
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(*se.GetMaterialPoint(n));
// penalty
double eps = m_epsn*data.m_epsn*psf;
// normal gap
double g = data.m_gap;
// normal traction Lagrange multiplier
double Lm = data.m_Lmd;
// vector traction Lagrange multiplier
vec3d Lt = data.m_Lmt;
// calculate the normal at this integration point
vec3d nu = data.m_nu;
// get current and previous secondary elements
FESurfaceElement* pme = data.m_pme;
FESurfaceElement* pmep = data.m_pmep;
// if we just returned from an augmentation, do not update stick or slip status
if (m_bfreeze && pme) {
if (data.m_bstick) {
// calculate current global position of the integration point
vec3d xo = ss.Local2Global(se, n);
// calculate current global position of the previous intersection point
vec3d xt = ms.Local2Global(*pmep, data.m_rsp[0], data.m_rsp[1]);
// vector and normal gaps
vec3d dg = xt - xo;
// calculate trial stick traction, normal component, shear component
t = Lt + dg*eps;
tn = t*nu;
ts = (t - nu*tn).norm();
// contact pressure
pn = m_btension ? (-tn) : MBRACKET(-tn);
// store the previous values as the current
data.m_pme = data.m_pmep;
data.m_rs = data.m_rsp;
// recalculate gap
data.m_dg = dg + nu*m_offset;
}
else {
// recalculate contact pressure for slip
pn = m_btension ? (Lm + eps*g) : MBRACKET(Lm + eps*g);
if (pn != 0)
{
double dh = 0;
// slip direction
s1 = FESlidingElasticInterface::SlipTangent(ss, nel, n, ms, dh, drdot);
// total traction
t = (nu + s1*(m_mu))*(-pn);
// reset slip direction
data.m_s1 = s1;
}
else
{
t = vec3d(0,0,0);
}
}
}
// update contact tractions
else {
data.m_bstick = false;
if (pme)
{
// assume stick and calculate traction
if (pmep)
{
// calculate current global position of the integration point
vec3d xo = ss.Local2Global(se, n);
// calculate current global position of the previous intersection point
vec3d xt = ms.Local2Global(*pmep, data.m_rsp[0], data.m_rsp[1]);
// vector and normal gaps
vec3d dg = xt - xo;
// calculate trial stick traction, normal component, shear component
t = Lt + dg*eps;
tn = t*nu;
ts = (t - nu*tn).norm();
// check if stick
if ( (tn < 0) && (ts < m_mu*fabs(tn)) )
{
// set boolean flag for stick
data.m_bstick = true;
// contact pressure
pn = m_btension ? (-tn) : MBRACKET(-tn);
// store the previous values as the current
data.m_pme = data.m_pmep;
data.m_rs = data.m_rsp;
// recalculate gap
data.m_dg = dg + nu*m_offset;
}
else
{
// recalculate contact pressure for slip
pn = m_btension ? (Lm + eps*g) : MBRACKET(Lm + eps*g);
if (pn != 0)
{
double dh = 0;
// slip direction
s1 = FESlidingElasticInterface::SlipTangent(ss, nel, n, ms, dh, drdot);
// total traction
t = (nu + s1*(m_mu))*(-pn);
// reset slip direction
data.m_s1 = s1;
data.m_bstick = false;
}
else
{
t = vec3d(0,0,0);
}
}
}
else
{
// assume slip upon first contact
// calculate contact pressure for slip
pn = m_btension ? (Lm + eps*g) : MBRACKET(Lm + eps*g);
if (pn != 0)
{
double dh = 0;
// slip direction
s1 = FESlidingElasticInterface::SlipTangent(ss, nel, n, ms, dh, drdot);
// calculate frictional traction
t = (nu + s1*(m_mu))*(-pn);
// reset slip direction
data.m_s1 = s1;
data.m_bstick = false;
}
}
}
}
return t;
}
//-----------------------------------------------------------------------------
void FESlidingElasticInterface::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
const int MN = FEElement::MAX_NODES;
vector<int> sLM, mLM, LM, en;
vector<double> fe;
double detJ[MN], w[MN], Hm[MN];
double N[MN*6];
m_ss.m_Ft = vec3d(0,0,0);
m_ms.m_Ft = vec3d(0,0,0);
// 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
FESlidingElasticSurface& ss = (np == 0? m_ss : m_ms);
FESlidingElasticSurface& ms = (np == 0? m_ms : m_ss);
// loop over all primary elements
//#pragma omp parallel for private(sLM, mLM, LM, en, fe, detJ, w, Hm, N)
for (int i=0; i<ss.Elements(); ++i)
{
// get the surface element
FESurfaceElement& se = ss.Element(i);
if (se.isActive())
{
// 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 (int 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 (int j = 0; j < nint; ++j)
{
// get integration point data
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(*se.GetMaterialPoint(j));
// calculate contact pressure and account for stick
double pn;
vec3d t = ContactTraction(ss, i, j, ms, pn);
// get the secondary element
FESurfaceElement* pme = data.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 (int k = 0; k < nseln; ++k)
{
LM[3 * k] = sLM[3 * k];
LM[3 * k + 1] = sLM[3 * k + 1];
LM[3 * k + 2] = sLM[3 * k + 2];
}
for (int k = 0; k < nmeln; ++k)
{
LM[3 * (k + nseln)] = mLM[3 * k];
LM[3 * (k + nseln) + 1] = mLM[3 * k + 1];
LM[3 * (k + nseln) + 2] = mLM[3 * k + 2];
}
// build the en vector
en.resize(nseln + nmeln);
for (int k = 0; k < nseln; ++k) en[k] = se.m_node[k];
for (int k = 0; k < nmeln; ++k) en[k + nseln] = me.m_node[k];
// get primary element shape functions
double* Hs = se.H(j);
// get secondary element shape functions
double r = data.m_rs[0];
double s = data.m_rs[1];
me.shape_fnc(Hm, r, s);
if (pn != 0) {
// calculate the force vector
fe.resize(ndof);
zero(fe);
for (int 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 (int 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 (int k = 0; k < ndof; ++k) fe[k] += N[k] * detJ[j] * w[j];
// calculate contact forces
for (int k = 0; k < nseln; ++k)
{
ss.m_Ft += vec3d(fe[k * 3], fe[k * 3 + 1], fe[k * 3 + 2]);
}
for (int k = 0; k < nmeln; ++k)
{
ms.m_Ft += vec3d(fe[(k + nseln) * 3], fe[(k + nseln) * 3 + 1], fe[(k + nseln) * 3 + 2]);
}
// assemble the global residual
R.Assemble(en, LM, fe);
}
}
}
}
}
}
}
//-----------------------------------------------------------------------------
void FESlidingElasticInterface::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
// see how many reformations we've had to do so far
int nref = GetSolver()->m_nref;
const int MN = FEElement::MAX_NODES;
double detJ[MN], w[MN], Hm[MN];
double N[MN*6];
vector<int> sLM, mLM, LM, en;
FEElementMatrix ke;
double psf = GetPenaltyScaleFactor();
// 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
FESlidingElasticSurface& ss = (np == 0? m_ss : m_ms);
FESlidingElasticSurface& ms = (np == 0? m_ms : m_ss);
// loop over all primary elements
//#pragma omp parallel for private(detJ, w, Hm, N, sLM, mLM, LM, en, ke)
for (int i = 0; i < ss.Elements(); ++i)
{
// get ths primary element
FESurfaceElement& se = ss.Element(i);
if (se.isActive())
{
// 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 (int 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 (int j = 0; j < nint; ++j)
{
// get integration point data
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(*se.GetMaterialPoint(j));
// calculate contact pressure and account for stick
double pn;
vec3d t = ContactTraction(ss, i, j, ms, pn);
// get the secondary element
FESurfaceElement* pme = data.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);
// calculate degrees of freedom
int ndpn = 3;
int ndof = ndpn * (nseln + nmeln);
// build the LM vector
LM.resize(ndof);
for (int k = 0; k < nseln; ++k)
{
LM[3 * k] = sLM[3 * k];
LM[3 * k + 1] = sLM[3 * k + 1];
LM[3 * k + 2] = sLM[3 * k + 2];
}
for (int k = 0; k < nmeln; ++k)
{
LM[3 * (k + nseln)] = mLM[3 * k];
LM[3 * (k + nseln) + 1] = mLM[3 * k + 1];
LM[3 * (k + nseln) + 2] = mLM[3 * k + 2];
}
// build the en vector
en.resize(nseln + nmeln);
for (int k = 0; k < nseln; ++k) en[k] = se.m_node[k];
for (int k = 0; k < nmeln; ++k) en[k + nseln] = me.m_node[k];
// primary shape functions
double* Hs = se.H(j);
// secondary shape functions
double r = data.m_rs[0];
double s = data.m_rs[1];
me.shape_fnc(Hm, r, s);
// get primary normal vector
vec3d nu = data.m_nu;
// gap function
double g = data.m_gap;
// penalty
double eps = m_epsn * data.m_epsn * psf;
// only evaluate stiffness matrix if contact traction is non-zero
if (pn != 0)
{
// if stick
if (data.m_bstick)
{
double dtn = eps;
// create the stiffness matrix
ke.resize(ndof, ndof); ke.zero();
// evaluate basis vectors on primary surface
vec3d gscov[2];
ss.CoBaseVectors(se, j, gscov);
// identity tensor
mat3d I = mat3dd(1);
// evaluate Mc and Ac and combine them into As
double* Gsr = se.Gr(j);
double* Gss = se.Gs(j);
mat3d As[MN];
mat3d gscovh[2];
gscovh[0].skew(gscov[0]); gscovh[1].skew(gscov[1]);
for (int k = 0; k < nseln; ++k) {
mat3d Ac = (gscovh[1] * Gsr[k] - gscovh[0] * Gss[k]) / detJ[j];
As[k] = t & (Ac * nu);
}
// --- S O L I D - S O L I D C O N T A C T ---
// a. I-term
//------------------------------------
for (int k = 0; k < nseln; ++k) N[k] = Hs[k];
for (int k = 0; k < nmeln; ++k) N[k + nseln] = -Hm[k];
double tmp = dtn * detJ[j] * w[j];
for (int l = 0; l < nseln + nmeln; ++l)
{
for (int k = 0; k < nseln + nmeln; ++k)
{
ke[k * ndpn][l * ndpn] -= -tmp * N[k] * N[l] * I[0][0];
ke[k * ndpn][l * ndpn + 1] -= -tmp * N[k] * N[l] * I[0][1];
ke[k * ndpn][l * ndpn + 2] -= -tmp * N[k] * N[l] * I[0][2];
ke[k * ndpn + 1][l * ndpn] -= -tmp * N[k] * N[l] * I[1][0];
ke[k * ndpn + 1][l * ndpn + 1] -= -tmp * N[k] * N[l] * I[1][1];
ke[k * ndpn + 1][l * ndpn + 2] -= -tmp * N[k] * N[l] * I[1][2];
ke[k * ndpn + 2][l * ndpn] -= -tmp * N[k] * N[l] * I[2][0];
ke[k * ndpn + 2][l * ndpn + 1] -= -tmp * N[k] * N[l] * I[2][1];
ke[k * ndpn + 2][l * ndpn + 2] -= -tmp * N[k] * N[l] * I[2][2];
}
}
// b. A-term
//-------------------------------------
tmp = detJ[j] * w[j];
// non-symmetric
for (int l = 0; l < nseln; ++l)
{
for (int k = 0; k < nseln + nmeln; ++k)
{
ke[k * ndpn][l * ndpn] -= tmp * N[k] * As[l][0][0];
ke[k * ndpn][l * ndpn + 1] -= tmp * N[k] * As[l][0][1];
ke[k * ndpn][l * ndpn + 2] -= tmp * N[k] * As[l][0][2];
ke[k * ndpn + 1][l * ndpn] -= tmp * N[k] * As[l][1][0];
ke[k * ndpn + 1][l * ndpn + 1] -= tmp * N[k] * As[l][1][1];
ke[k * ndpn + 1][l * ndpn + 2] -= tmp * N[k] * As[l][1][2];
ke[k * ndpn + 2][l * ndpn] -= tmp * N[k] * As[l][2][0];
ke[k * ndpn + 2][l * ndpn + 1] -= tmp * N[k] * As[l][2][1];
ke[k * ndpn + 2][l * ndpn + 2] -= tmp * N[k] * As[l][2][2];
}
}
// assemble the global stiffness
{
ke.SetNodes(en);
ke.SetIndices(LM);
LS.Assemble(ke);
}
}
// if slip
else
{
double tn = -pn;
// create the stiffness matrix
ke.resize(ndof, ndof); ke.zero();
// obtain the slip direction s1 and inverse of spatial increment dh
double dh = 0, hd = 0;
vec3d dr(0, 0, 0);
vec3d s1 = FESlidingElasticInterface::SlipTangent(ss, i, j, ms, dh, dr);
if (dh != 0)
{
hd = 1.0 / dh;
}
// evaluate basis vectors on both surfaces
vec3d gscov[2], gmcov[2];
ss.CoBaseVectors(se, j, gscov);
ms.CoBaseVectors(me, r, s, gmcov);
mat2d A;
A[0][0] = gscov[0] * gmcov[0]; A[0][1] = gscov[0] * gmcov[1];
A[1][0] = gscov[1] * gmcov[0]; A[1][1] = gscov[1] * gmcov[1];
mat2d a = A.inverse();
// evaluate covariant basis vectors on primary surface at previous time step
vec3d gscovp[2];
ss.CoBaseVectorsP(se, j, gscovp);
// calculate delta gscov
vec3d dgscov[2];
dgscov[0] = gscov[0] - gscovp[0];
dgscov[1] = gscov[1] - gscovp[1];
// evaluate contravariant basis vectors
vec3d gscnt[2], gmcnt[2];
if (m_knmult == 0)
{
// evaluate true contravariant basis vectors when gap = 0
ss.ContraBaseVectors(se, j, gscnt);
ms.ContraBaseVectors(me, r, s, gmcnt);
}
else
{
// evaluate approximate contravariant basis vectors when gap != 0
gmcnt[0] = gscov[0] * a[0][0] + gscov[1] * a[0][1];
gmcnt[1] = gscov[0] * a[1][0] + gscov[1] * a[1][1];
gscnt[0] = gmcov[0] * a[0][0] + gmcov[1] * a[1][0];
gscnt[1] = gmcov[0] * a[0][1] + gmcov[1] * a[1][1];
}
// evaluate N and S tensors and approximations when gap != 0
mat3ds N1 = dyad(nu);
mat3d Nh1 = mat3dd(1) - (nu & nu);
mat3d Nb1 = mat3dd(1) - (gscov[0] & gscnt[0]) * m_knmult - (gscov[1] & gscnt[1]) * m_knmult;
mat3d Nt1 = nu & (Nb1 * nu);
mat3d S1 = s1 & nu;
mat3d Sh1 = (mat3dd(1) - (s1 & s1)) * hd;
mat3d Sb1 = s1 & (Nb1 * nu);
// evaluate m, c, B, and R
// evaluate L1 from Mg and R
vec3d m = ((dgscov[0] ^ gscov[1]) + (gscov[0] ^ dgscov[1]));
vec3d c = Sh1 * Nh1 * m * (1 / detJ[j]);
mat3d Mg = (mat3dd(1) * (nu * m) + (nu & m)) * (1 / detJ[j]);
mat3d B = (c & (Nb1 * nu)) * m_knmult - Sh1 * Nh1;
mat3d R = mat3dd(1) * (nu * dr) + (nu & dr);
mat3d L1 = Sh1 * ((Nh1 * Mg - mat3dd(1)) * (-g) * m_knmult + R) * Nh1;
// evaluate Mc and Ac and combine them into As
// evaluate s1 dyad (N1*mc - Ac*nu) + c dyad (N1*mc + Ac*nu)*g*hd as Pc
// evaluate Fc from Ac_bar (Ab)
double* Gsr = se.Gr(j);
double* Gss = se.Gs(j);
mat3d As[MN];
mat3d gscovh[2];
mat3d dgscovh[2];
mat3d Pc[MN];
mat3d Jc[MN];
gscovh[0].skew(gscov[0]); gscovh[1].skew(gscov[1]);
dgscovh[0].skew(dgscov[0]); dgscovh[1].skew(dgscov[1]);
for (int k = 0; k < nseln; ++k) {
vec3d mc = gscnt[0] * Gsr[k] + gscnt[1] * Gss[k];
mat3d Mc = nu & mc;
mat3d Ac = (gscovh[1] * Gsr[k] - gscovh[0] * Gss[k]) / detJ[j];
mat3d Ab = (dgscovh[1] * Gsr[k] - dgscovh[0] * Gss[k]) / detJ[j];
Pc[k] = (s1 & (N1 * mc * m_knmult - Ac * nu)) + ((c & (N1 * mc + Ac * nu)) * (-g) * m_knmult);
As[k] = Ac + Mc * N1 * m_knmult;
Jc[k] = (L1 * Ac - (Sh1 * Nh1 * Ab * (-g) * m_knmult));
}
// evaluate Mb
// evaluate s1 dyad mb and combine as Psb
double Gmr[MN], Gms[MN];
me.shape_deriv(Gmr, Gms, r, s);
mat3d Pb[MN];
for (int k = 0; k < nmeln; ++k) {
vec3d n(0, 0, 0);
if (m_knmult == 0)
{
n = gmcnt[0] ^ gmcnt[1];
n.unit();
}
else
{
n = -nu;
}
vec3d mb = gmcnt[0] * Gmr[k] + gmcnt[1] * Gms[k];
mat3d Mb = n & mb;
Pb[k] = Mb - ((s1 & mb) * m_mu);
}
// evaluate Gbc
matrix Gbc(nmeln, nseln);
for (int b = 0; b < nmeln; ++b) {
for (int c = 0; c < nseln; ++c) {
Gbc(b, c)
= (a[0][0] * Gmr[b] * Gsr[c]
+ a[0][1] * Gmr[b] * Gss[c]
+ a[1][0] * Gms[b] * Gsr[c]
+ a[1][1] * Gms[b] * Gss[c]) * (-g) * m_knmult;
}
}
// define T, Ttb
mat3d T = N1 + (S1 * m_mu);
mat3d Ttb = Nt1 + (Sb1 * m_mu);
// --- S O L I D - S O L I D C O N T A C T ---
// a. NxN-term
//------------------------------------
for (int k = 0; k < nseln; ++k) N[k] = Hs[k];
for (int k = 0; k < nmeln; ++k) N[k + nseln] = -Hm[k];
double tmp = detJ[j] * w[j];
for (int l = 0; l < nseln + nmeln; ++l)
{
for (int k = 0; k < nseln + nmeln; ++k)
{
ke[k * ndpn][l * ndpn] -= -tmp * N[k] * N[l] * (eps * Ttb[0][0] + m_mu * tn * B[0][0]);
ke[k * ndpn][l * ndpn + 1] -= -tmp * N[k] * N[l] * (eps * Ttb[0][1] + m_mu * tn * B[0][1]);
ke[k * ndpn][l * ndpn + 2] -= -tmp * N[k] * N[l] * (eps * Ttb[0][2] + m_mu * tn * B[0][2]);
ke[k * ndpn + 1][l * ndpn] -= -tmp * N[k] * N[l] * (eps * Ttb[1][0] + m_mu * tn * B[1][0]);
ke[k * ndpn + 1][l * ndpn + 1] -= -tmp * N[k] * N[l] * (eps * Ttb[1][1] + m_mu * tn * B[1][1]);
ke[k * ndpn + 1][l * ndpn + 2] -= -tmp * N[k] * N[l] * (eps * Ttb[1][2] + m_mu * tn * B[1][2]);
ke[k * ndpn + 2][l * ndpn] -= -tmp * N[k] * N[l] * (eps * Ttb[2][0] + m_mu * tn * B[2][0]);
ke[k * ndpn + 2][l * ndpn + 1] -= -tmp * N[k] * N[l] * (eps * Ttb[2][1] + m_mu * tn * B[2][1]);
ke[k * ndpn + 2][l * ndpn + 2] -= -tmp * N[k] * N[l] * (eps * Ttb[2][2] + m_mu * tn * B[2][2]);
}
}
// b. Na,Nb-term
//-------------------------------------
tmp = tn * detJ[j] * w[j];
// non-symmetric
for (int l = 0; l < nseln; ++l)
{
for (int k = 0; k < nseln + nmeln; ++k)
{
ke[k * ndpn][l * ndpn] -= -tmp * N[k] * (As[l][0][0] + m_mu * (Pc[l][0][0] - Jc[l][0][0]));
ke[k * ndpn][l * ndpn + 1] -= -tmp * N[k] * (As[l][0][1] + m_mu * (Pc[l][0][1] - Jc[l][0][1]));
ke[k * ndpn][l * ndpn + 2] -= -tmp * N[k] * (As[l][0][2] + m_mu * (Pc[l][0][2] - Jc[l][0][2]));
ke[k * ndpn + 1][l * ndpn] -= -tmp * N[k] * (As[l][1][0] + m_mu * (Pc[l][1][0] - Jc[l][1][0]));
ke[k * ndpn + 1][l * ndpn + 1] -= -tmp * N[k] * (As[l][1][1] + m_mu * (Pc[l][1][1] - Jc[l][1][1]));
ke[k * ndpn + 1][l * ndpn + 2] -= -tmp * N[k] * (As[l][1][2] + m_mu * (Pc[l][1][2] - Jc[l][1][2]));
ke[k * ndpn + 2][l * ndpn] -= -tmp * N[k] * (As[l][2][0] + m_mu * (Pc[l][2][0] - Jc[l][2][0]));
ke[k * ndpn + 2][l * ndpn + 1] -= -tmp * N[k] * (As[l][2][1] + m_mu * (Pc[l][2][1] - Jc[l][2][1]));
ke[k * ndpn + 2][l * ndpn + 2] -= -tmp * N[k] * (As[l][2][2] + m_mu * (Pc[l][2][2] - Jc[l][2][2]));
}
}
// c. Nc,Nd-term
//---------------------------------------
tmp = tn * detJ[j] * w[j];
// non-symmetric
for (int k = 0; k < nmeln; ++k)
{
for (int l = 0; l < nseln + nmeln; ++l)
{
ke[(k + nseln) * ndpn][l * ndpn] -= tmp * N[l] * Pb[k][0][0];
ke[(k + nseln) * ndpn][l * ndpn + 1] -= tmp * N[l] * Pb[k][0][1];
ke[(k + nseln) * ndpn][l * ndpn + 2] -= tmp * N[l] * Pb[k][0][2];
ke[(k + nseln) * ndpn + 1][l * ndpn] -= tmp * N[l] * Pb[k][1][0];
ke[(k + nseln) * ndpn + 1][l * ndpn + 1] -= tmp * N[l] * Pb[k][1][1];
ke[(k + nseln) * ndpn + 1][l * ndpn + 2] -= tmp * N[l] * Pb[k][1][2];
ke[(k + nseln) * ndpn + 2][l * ndpn] -= tmp * N[l] * Pb[k][2][0];
ke[(k + nseln) * ndpn + 2][l * ndpn + 1] -= tmp * N[l] * Pb[k][2][1];
ke[(k + nseln) * ndpn + 2][l * ndpn + 2] -= tmp * N[l] * Pb[k][2][2];
}
}
// c. Gbc-term
//---------------------------------------
tmp = tn * detJ[j] * w[j];
for (int k = 0; k < nmeln; ++k)
{
for (int l = 0; l < nseln; ++l)
{
mat3d gT = T * (Gbc[k][l] * tmp);
ke[(k + nseln) * ndpn][l * ndpn] -= gT[0][0];
ke[(k + nseln) * ndpn][l * ndpn + 1] -= gT[0][1];
ke[(k + nseln) * ndpn][l * ndpn + 2] -= gT[0][2];
ke[(k + nseln) * ndpn + 1][l * ndpn] -= gT[1][0];
ke[(k + nseln) * ndpn + 1][l * ndpn + 1] -= gT[1][1];
ke[(k + nseln) * ndpn + 1][l * ndpn + 2] -= gT[1][2];
ke[(k + nseln) * ndpn + 2][l * ndpn] -= gT[2][0];
ke[(k + nseln) * ndpn + 2][l * ndpn + 1] -= gT[2][1];
ke[(k + nseln) * ndpn + 2][l * ndpn + 2] -= gT[2][2];
}
}
// assemble the global stiffness
{
ke.SetNodes(en);
ke.SetIndices(LM);
LS.Assemble(ke);
}
}
}
}
}
}
}
}
}
//-----------------------------------------------------------------------------
void FESlidingElasticInterface::UpdateContactPressures()
{
double psf = GetPenaltyScaleFactor();
int npass = (m_btwo_pass?2:1);
const int MN = FEElement::MAX_NODES;
const int MI = FEElement::MAX_INTPOINTS;
for (int np=0; np<npass; ++np)
{
FESlidingElasticSurface& ss = (np == 0? m_ss : m_ms);
FESlidingElasticSurface& ms = (np == 0? m_ms : m_ss);
// loop over all elements of the primary surface
#pragma omp parallel for
for (int n=0; n<ss.Elements(); ++n)
{
FESurfaceElement& el = ss.Element(n);
if (el.isActive())
{
int nint = el.GaussPoints();
// get the normal tractions at the integration points
for (int i = 0; i < nint; ++i)
{
// get integration point data
FESlidingElasticSurface::Data& sd = static_cast<FESlidingElasticSurface::Data&>(*el.GetMaterialPoint(i));
double pn = 0;
// evaluate traction on primary surface
double eps = m_epsn * sd.m_epsn * psf;
if (sd.m_bstick) {
// if stick, evaluate total traction
sd.m_tr = sd.m_Lmt + sd.m_dg * eps;
// then derive normal component
sd.m_Ln = -sd.m_tr * sd.m_nu;
}
else {
// if slip, evaluate normal traction
double Ln = sd.m_Lmd + eps * sd.m_gap;
sd.m_Ln = m_btension ? Ln : MBRACKET(Ln);
// then derive total traction
sd.m_tr = -(sd.m_nu + sd.m_s1 * m_mu) * sd.m_Ln;
}
FESurfaceElement* pme = sd.m_pme;
if (m_btwo_pass && pme)
{
// get secondary element data
int mint = pme->GaussPoints();
double pi[MI];
vec3d ti[MI];
for (int j = 0; j < mint; ++j)
{
FESlidingElasticSurface::Data& md = static_cast<FESlidingElasticSurface::Data&>(*pme->GetMaterialPoint(j));
pn = 0;
// evaluate traction on secondary surface
double eps = m_epsn * md.m_epsn * psf;
if (md.m_bstick) {
// if stick, evaluate total traction
ti[j] = md.m_Lmt + md.m_dg * eps;
// then derive normal component
pi[j] = -ti[j] * md.m_nu;
}
else {
// if slip, evaluate normal traction
double Ln = md.m_Lmd + eps * md.m_gap;
pi[j] = m_btension ? Ln : MBRACKET(Ln);
// then derive total traction
ti[j] = -(md.m_nu + md.m_s1 * m_mu) * pi[j];
}
}
// project the data to the nodes
double pn[MN];
vec3d tn[MN];
pme->FEElement::project_to_nodes(pi, pn);
pme->project_to_nodes(ti, tn);
// now evaluate the traction at the intersection point
double Ln = pme->eval(pn, sd.m_rs[0], sd.m_rs[1]);
vec3d trac = pme->eval(tn, sd.m_rs[0], sd.m_rs[1]);
sd.m_Ln += (m_btension ? Ln : MBRACKET(Ln));
// tractions on secondary-primary are opposite, so subtract
sd.m_tr -= trac;
}
}
}
}
}
}
//-----------------------------------------------------------------------------
bool FESlidingElasticInterface::Augment(int naug, const FETimeInfo& tp)
{
// make sure we need to augment
if (m_laugon != FECore::AUGLAG_METHOD) return true;
// don't augment if tolerance is zero (or negative)
if ((m_atol <= 0.0) && (m_gtol <= 0.0))
{
feLogInfo("Augmentation skipped since tolerance is zero.");
return true;
}
double psf = GetPenaltyScaleFactor();
double 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;
for (int i=0; i<NS; ++i)
{
FESurfaceElement& se = m_ss.Element(i);
if (se.isActive())
{
for (int j = 0; j < se.GaussPoints(); ++j)
{
FESlidingElasticSurface::Data& ds = static_cast<FESlidingElasticSurface::Data&>(*se.GetMaterialPoint(j));
if (ds.m_bstick)
normL0 += ds.m_Lmt * ds.m_Lmt;
else
normL0 += ds.m_Lmd * ds.m_Lmd;
}
}
}
for (int i=0; i<NM; ++i)
{
FESurfaceElement& me = m_ms.Element(i);
if (me.isActive())
{
for (int j = 0; j < me.GaussPoints(); ++j)
{
FESlidingElasticSurface::Data& dm = static_cast<FESlidingElasticSurface::Data&>(*me.GetMaterialPoint(j));
if (dm.m_bstick)
normL0 += dm.m_Lmt * dm.m_Lmt;
else
normL0 += dm.m_Lmd * dm.m_Lmd;
}
}
}
// b. gap component
// (is calculated during update)
double maxgap = 0;
// update Lagrange multipliers
double normL1 = 0;
for (int i=0; i<m_ss.Elements(); ++i) {
FESurfaceElement& el = m_ss.Element(i);
if (el.isActive())
{
vec3d tn[FEElement::MAX_INTPOINTS];
if (m_bsmaug) m_ss.GetGPSurfaceTraction(i, tn);
for (int j = 0; j < el.GaussPoints(); ++j) {
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(*el.GetMaterialPoint(j));
// update Lagrange multipliers on primary surface
if (data.m_bstick) {
// if stick, augment total traction
if (m_bsmaug) {
data.m_Lmt = tn[j];
if (m_btwo_pass) data.m_Lmt /= 2;
}
else {
double eps = m_epsn * data.m_epsn * psf;
data.m_Lmt += data.m_dg * eps;
}
// then derive normal component
data.m_Lmd = -data.m_Lmt * data.m_nu;
Ln = data.m_Lmd;
normL1 += data.m_Lmt * data.m_Lmt;
if (m_btension)
maxgap = max(maxgap, data.m_dg.norm());
else if (Ln > 0) maxgap = max(maxgap, data.m_dg.norm());
}
else {
// if slip, augment normal traction
if (m_bsmaug) {
Ln = -(tn[j] * data.m_nu);
data.m_Lmd = m_btension ? Ln : MBRACKET(Ln);
if (m_btwo_pass) data.m_Lmd /= 2;
}
else {
double eps = m_epsn * data.m_epsn * psf;
Ln = data.m_Lmd + eps * data.m_gap;
data.m_Lmd = m_btension ? Ln : MBRACKET(Ln);
}
// then derive total traction
data.m_Lmt = -(data.m_nu + data.m_s1 * m_mu) * data.m_Lmd;
normL1 += data.m_Lmd * data.m_Lmd;
if (m_btension)
maxgap = max(maxgap, fabs(data.m_gap));
else if (Ln > 0) maxgap = max(maxgap, fabs(data.m_gap));
}
}
}
}
for (int i=0; i<m_ms.Elements(); ++i) {
FESurfaceElement& el = m_ms.Element(i);
if (el.isActive())
{
vec3d tn[FEElement::MAX_INTPOINTS];
if (m_bsmaug) m_ms.GetGPSurfaceTraction(i, tn);
for (int j = 0; j < el.GaussPoints(); ++j) {
FESlidingElasticSurface::Data& data = static_cast<FESlidingElasticSurface::Data&>(*el.GetMaterialPoint(j));
// update Lagrange multipliers on secondary surface
if (data.m_bstick) {
// if stick, augment total traction
if (m_bsmaug) {
data.m_Lmt = tn[j];
if (m_btwo_pass) data.m_Lmt /= 2;
}
else {
double eps = m_epsn * data.m_epsn * psf;
data.m_Lmt += data.m_dg * eps;
}
// then derive normal component
data.m_Lmd = -data.m_Lmt * data.m_nu;
Ln = data.m_Lmd;
normL1 += data.m_Lmt * data.m_Lmt;
if (m_btension)
maxgap = max(maxgap, fabs(data.m_dg.norm()));
else if (Ln > 0) maxgap = max(maxgap, fabs(data.m_dg.norm()));
}
else {
// if slip, augment normal traction
if (m_bsmaug) {
Ln = -(tn[j] * data.m_nu);
data.m_Lmd = m_btension ? Ln : MBRACKET(Ln);
if (m_btwo_pass) data.m_Lmd /= 2;
}
else {
double eps = m_epsn * data.m_epsn * psf;
Ln = data.m_Lmd + eps * data.m_gap;
data.m_Lmd = m_btension ? Ln : MBRACKET(Ln);
}
// then derive total traction
data.m_Lmt = -(data.m_nu + data.m_s1 * m_mu) * data.m_Lmd;
normL1 += data.m_Lmd * data.m_Lmd;
if (m_btension)
maxgap = max(maxgap, fabs(data.m_gap));
else if (Ln > 0) maxgap = max(maxgap, fabs(data.m_gap));
}
}
}
}
// calculate relative norms
double lnorm = (normL1 != 0 ? fabs((normL1 - normL0) / normL1) : fabs(normL1 - normL0));
// check convergence
if ((m_gtol > 0) && (maxgap > m_gtol)) bconv = false;
if ((m_atol > 0) && (lnorm > 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");
ProjectSurface(m_ss, m_ms, true);
if (m_btwo_pass) ProjectSurface(m_ms, m_ss, true);
m_bfreeze = true;
return bconv;
}
//-----------------------------------------------------------------------------
void FESlidingElasticInterface::Serialize(DumpStream &ar)
{
// serialize contact data
FEContactInterface::Serialize(ar);
ar & m_bfreeze;
// serialize contact surface data
m_ms.Serialize(ar);
m_ss.Serialize(ar);
// restore pointers
SerializeElementPointers(m_ss, m_ms, ar);
SerializeElementPointers(m_ms, m_ss, ar);
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEBioMech.h | .h | 1,815 | 53 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
//! The FEBioMech module
//! This module defines classes for dealing with large deformation structural
//! mechanics problems.
namespace FEBioMech
{
enum MECH_VARIABLE {
DISPLACEMENT,
ROTATION,
RIGID_ROTATION,
SHELL_DISPLACEMENT,
VELOCITY,
SHELL_VELOCITY,
SHELL_ACCELERATION,
BEAM_ANGULAR_VELOCITY,
BEAM_ANGULAR_ACCELERATION,
};
FEBIOMECH_API const char* GetVariableName(MECH_VARIABLE var);
}
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidLock.h | .h | 4,093 | 113 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FECore/vec3d.h"
#include "FERigidConnector.h"
//-----------------------------------------------------------------------------
//! The FERigidLock class implements a locking joint. This rigid joint
//! allows the user to connect two rigid bodies at a point in space
//! and prevents any relative motion.
class FERigidLock : public FERigidConnector
{
public:
//! constructor
FERigidLock(FEModel* pfem);
//! destructor
virtual ~FERigidLock() {}
//! initialization
bool Init() override;
//! calculates the joint forces
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
//! calculates the joint stiffness
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
//! calculate Lagrangian augmentation
bool Augment(int naug, const FETimeInfo& tp) override;
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! update state
void Update() override;
//! Reset data
void Reset() override;
//! evaluate relative translation
vec3d RelativeTranslation(const bool global = false) override;
//! evaluate relative rotation
vec3d RelativeRotation(const bool global = false) override;
private: // lag. mult. methods
int InitEquations(int neq) override;
void BuildMatrixProfile(FEGlobalMatrix& M) override;
void UnpackLM(vector<int>& lm);
void Update(const std::vector<double>& Ui, const std::vector<double>& ui) override;
void UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) override;
void PrepStep() override;
public: // parameters
int m_laugon; //!< enforcement method
double m_atol; //! augmented Lagrangian tolerance
double m_gtol; //! augmented Lagrangian gap tolerance
double m_qtol; //! augmented Lagrangian angular gap tolerance
int m_naugmin; //! minimum number of augmentations
int m_naugmax; //! maximum number of augmentations
vec3d m_q0; //! initial position of joint
double m_eps; //! penalty factor for constraining force
double m_ups; //! penalty factor for constraining moment
bool m_bautopen; //!< auto-penalty for gap and ang tolerance
protected:
vec3d m_qa0; //! initial relative position vector of joint w.r.t. A
vec3d m_qb0; //! initial relative position vector of joint w.r.t. B
vec3d m_e0[3]; //! initial joint basis
vec3d m_ea0[3]; //! initial joint basis w.r.t. A
vec3d m_eb0[3]; //! initial joint basis w.r.t. B
vec3d m_L; //! Lagrange multiplier for constraining force
vec3d m_U; //! Lagrange multiplier for constraining moment
vec3d m_U1, m_U2;
vec3d m_Fp, m_U1p, m_U2p;
vector<int> m_LM; // Lagrange multiplier equation numbers
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEViscoElasticDamage.h | .h | 2,827 | 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.*/
#pragma once
#include "FEViscoElasticMaterial.h"
#include "FEDamageMaterial.h"
//-----------------------------------------------------------------------------
//! This class implements a large deformation visco-elastic material
//
class FEViscoElasticDamage : public FEElasticMaterial
{
public:
// NOTE: make sure that this parameter is the
// same as the MAX_TERMS in the FEViscoElasticMaterialPoint class
enum { MAX_TERMS = FEViscoElasticMaterialPoint::MAX_TERMS };
public:
//! default constructor
FEViscoElasticDamage(FEModel* pfem);
public:
//! initialization
bool Init() override;
//! stress function
mat3ds Stress(FEMaterialPoint& pt) override;
//! tangent function
tens4ds Tangent(FEMaterialPoint& pt) override;
//! strain energy density
double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! calculate exponent of right-stretch tensor in series spring
bool SeriesStretchExponent(FEMaterialPoint& pt);
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
public:
// material parameters
double m_g0; //!< intitial visco-elastic coefficient
double m_g[MAX_TERMS]; //!< visco-elastic coefficients
double m_t[MAX_TERMS]; //!< relaxation times
private:
FEDamageMaterial* m_pDmg; //!< pointer to elastic damage material
public:
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidCable.h | .h | 2,310 | 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 "FERigidForce.h"
#include <FECore/FECoreClass.h>
class FERigidBody;
class FEBIOMECH_API FERigidCablePoint : public FECoreClass
{
public:
FERigidCablePoint(FEModel* fem) : FECoreClass(fem) {}
public:
int m_rb; //!< rigid body ID
vec3d m_pos; //!< position of attachment point
DECLARE_FECORE_CLASS();
FECORE_BASE_CLASS(FERigidCablePoint);
};
class FERigidCable : public FERigidLoad
{
public:
FERigidCable(FEModel* fem);
//! initialization
bool Init() override;
//! forces
void LoadVector(FEGlobalVector& R) override;
//! Stiffness matrix
void StiffnessMatrix(FELinearSystem& LS) override;
private:
void applyRigidForce(FERigidBody& rb, const vec3d& F, const vec3d& d, FEGlobalVector& R);
private:
double m_force; //!< magnitude of force (i.e. tension in cable)
vec3d m_forceDir; //!< direction of force at cable's end
bool m_brelative; //!< positions are defined relative w.r.t. rigid body's COM or not
std::vector<FERigidCablePoint*> m_points;
private:
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationScheme.h | .h | 3,372 | 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.*/
#pragma once
#include "FEElasticMaterial.h"
#include "FEElasticFiberMaterial.h"
#include "FEFiberDensityDistribution.h"
#include "febiomech_api.h"
//----------------------------------------------------------------------------------
// This is an iterator class that can be used to loop over all integration points of
// a fiber integration scheme. It must implement the Next functions.
// During the Next call, it should also update the fiber vector and weight.
// Next should return false if there is no more integration point
class FEFiberIntegrationSchemeIterator
{
public:
FEFiberIntegrationSchemeIterator() {}
virtual ~FEFiberIntegrationSchemeIterator() {}
// Move to the next integration point
// This also updates the m_fiber and m_weight members
virtual bool Next() = 0;
// check if the iterator is valid
virtual bool IsValid() = 0;
public:
vec3d m_fiber; // current fiber vector at integration point
double m_weight; // current integration weight
};
//----------------------------------------------------------------------------------
// Base clase for integration schemes for continuous fiber distributions.
// The purpose of this class is mainly to provide an interface to the integration schemes
// for the FEBio input file. The code will use the GetIterator function to create an
// iterator that can be used to loop over all the integration points of the scheme and to
// evaluate the fiber vector and weights at each point.
class FEBIOMECH_API FEFiberIntegrationScheme : public FEMaterialProperty
{
public:
FEFiberIntegrationScheme(FEModel* pfem);
// Creates an iterator for the scheme.
// In general, the integration scheme may depend on the material point.
// The passed material point pointer will be zero when evaluating the integrated fiber density
virtual FEFiberIntegrationSchemeIterator* GetIterator(FEMaterialPoint* mp = 0) = 0;
// returns the number of integration point (returns -1 if scheme does not use a fixed number of integration points.)
virtual int IntegrationPoints() const = 0;
FECORE_BASE_CLASS(FEFiberIntegrationScheme)
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEElasticANSShellDomain.cpp | .cpp | 53,845 | 1,394 | /*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 "FEElasticANSShellDomain.h"
#include "FEElasticMaterial.h"
#include "FEBodyForce.h"
#include <FECore/log.h>
#include <FECore/FEModel.h>
#include <FECore/FEAnalysis.h>
#include <math.h>
#include <FECore/FESolidDomain.h>
#include <FECore/FELinearSystem.h>
#include "FEBioMech.h"
BEGIN_FECORE_CLASS(FEElasticANSShellDomain, FESSIShellDomain)
ADD_PARAMETER(m_secant_stress, "secant_stress");
ADD_PARAMETER(m_secant_tangent, "secant_tangent");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEElasticANSShellDomain::FEElasticANSShellDomain(FEModel* pfem) : FESSIShellDomain(pfem), FEElasticDomain(pfem), m_dofV(pfem), m_dofSV(pfem), m_dofSA(pfem), m_dofR(pfem), m_dof(pfem)
{
m_pMat = nullptr;
m_update_dynamic = true; // default for backward compatibility
m_secant_stress = false;
m_secant_tangent = false;
// TODO: Can this be done in Init, since there is no error checking
if (pfem)
{
m_dofV.AddVariable(FEBioMech::GetVariableName(FEBioMech::VELOCITY));
m_dofSV.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_VELOCITY));
m_dofSA.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_ACCELERATION));
m_dofR.AddVariable(FEBioMech::GetVariableName(FEBioMech::RIGID_ROTATION));
}
}
//-----------------------------------------------------------------------------
FEElasticANSShellDomain& FEElasticANSShellDomain::operator = (FEElasticANSShellDomain& d)
{
m_Elem = d.m_Elem;
m_pMesh = d.m_pMesh;
return (*this);
}
//-----------------------------------------------------------------------------
//! Set flag for update for dynamic quantities
void FEElasticANSShellDomain::SetDynamicUpdateFlag(bool b)
{
m_update_dynamic = b;
}
//-----------------------------------------------------------------------------
//! serialization
void FEElasticANSShellDomain::Serialize(DumpStream& ar)
{
//erialize the base class, which instantiates the elements
FESSIShellDomain::Serialize(ar);
if (ar.IsShallow()) return;
// serialize class variables
ar & m_update_dynamic;
}
//-----------------------------------------------------------------------------
//! get the total dof list
const FEDofList& FEElasticANSShellDomain::GetDOFList() const
{
return m_dof;
}
//-----------------------------------------------------------------------------
void FEElasticANSShellDomain::SetMaterial(FEMaterial* pmat)
{
FEDomain::SetMaterial(pmat);
m_pMat = dynamic_cast<FESolidMaterial*>(pmat);
}
//-----------------------------------------------------------------------------
void FEElasticANSShellDomain::Activate()
{
for (int i=0; i<Nodes(); ++i)
{
FENode& node = Node(i);
if (node.HasFlags(FENode::EXCLUDE) == false)
{
if (node.m_rid < 0)
{
node.set_active(m_dofU[0]);
node.set_active(m_dofU[1]);
node.set_active(m_dofU[2]);
if (node.HasFlags(FENode::SHELL))
{
node.set_active(m_dofSU[0]);
node.set_active(m_dofSU[1]);
node.set_active(m_dofSU[2]);
}
}
}
}
}
//-----------------------------------------------------------------------------
//! Initialize element data
void FEElasticANSShellDomain::PreSolveUpdate(const FETimeInfo& timeInfo)
{
FESSIShellDomain::PreSolveUpdate(timeInfo);
const int NE = FEElement::MAX_NODES;
vec3d x0[NE], xt[NE], r0, rt;
for (size_t i=0; i<m_Elem.size(); ++i)
{
FEShellElementNew& el = m_Elem[i];
el.m_alphai.zero();
int n = el.GaussPoints();
for (int j=0; j<n; ++j)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(j);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
pt.m_Wp = pt.m_Wt;
mp.Update(timeInfo);
}
}
}
//-----------------------------------------------------------------------------
// Calculates the forces due to the stress
void FEElasticANSShellDomain::InternalForces(FEGlobalVector& R)
{
int NS = (int)m_Elem.size();
#pragma omp parallel for shared (NS)
for (int i=0; i<NS; ++i)
{
// element force vector
vector<double> fe;
vector<int> lm;
// get the element
FEShellElementNew& el = m_Elem[i];
// create the element force vector and initialize to zero
int ndof = 6*el.Nodes();
fe.assign(ndof, 0);
// calculate element's internal force
ElementInternalForce(el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble the residual
R.Assemble(el.m_node, lm, fe, true);
}
}
//-----------------------------------------------------------------------------
//! calculates the internal equivalent nodal forces for shell elements
//! Note that we use a one-point gauss integration rule for the thickness
//! integration. This will integrate linear functions exactly.
void FEElasticANSShellDomain::ElementInternalForce(FEShellElementNew& el, vector<double>& fe)
{
int i, n;
// jacobian matrix determinant
double detJt;
int nint = el.GaussPoints();
int neln = el.Nodes();
double* gw = el.GaussWeights();
vec3d Gcnt[3];
// allocate arrays
vector<mat3ds> S(nint);
vector<tens4ds> C(nint);
vector<double> EE;
vector< vector<vec3d>> HU;
vector< vector<vec3d>> HW;
matrix NS(neln,16);
matrix NN(neln,8);
// ANS method: Evaluate collocation strains
CollocationStrainsANS(el, EE, HU, HW, NS, NN);
vector<matrix> hu(neln, matrix(3,6));
vector<matrix> hw(neln, matrix(3,6));
vector<vec3d> Nu(neln);
vector<vec3d> Nw(neln);
matrix Fu(3,1), Fw(3,1);
// repeat for all integration points
for (n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
ContraBaseVectors0(el, n, Gcnt);
EvaluateEh(el, n, Gcnt, el.m_E[n], hu, hw, Nu, Nw);
EvaluateANS(el, n, Gcnt, el.m_E[n], hu, hw, EE, HU, HW);
// evaluate 2nd P-K stress
matrix SC(6,1);
mat3ds S = m_pMat->PK2Stress(mp, el.m_E[n]);
mat3dsCntMat61(S, Gcnt, SC);
// calculate the jacobian and multiply by Gauss weight
detJt = detJ0(el, n)*gw[n];
for (i=0; i<neln; ++i)
{
Fu = hu[i]*SC;
Fw = hw[i]*SC;
// calculate internal force
// the '-' sign is so that the internal forces get subtracted
// from the global residual vector
fe[6*i ] -= Fu(0,0)*detJt;
fe[6*i+1] -= Fu(1,0)*detJt;
fe[6*i+2] -= Fu(2,0)*detJt;
fe[6*i+3] -= Fw(0,0)*detJt;
fe[6*i+4] -= Fw(1,0)*detJt;
fe[6*i+5] -= Fw(2,0)*detJt;
}
}
}
//-----------------------------------------------------------------------------
void FEElasticANSShellDomain::BodyForce(FEGlobalVector& R, FEBodyForce& BF)
{
int NS = (int)m_Elem.size();
#pragma omp parallel for
for (int i=0; i<NS; ++i)
{
// element force vector
vector<double> fe;
vector<int> lm;
// get the element
FEShellElementNew& el = m_Elem[i];
// create the element force vector and initialize to zero
int ndof = 6*el.Nodes();
fe.assign(ndof, 0);
// apply body forces to shells
ElementBodyForce(BF, el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble the residual
R.Assemble(el.m_node, lm, fe, true);
}
}
//-----------------------------------------------------------------------------
//! Calculates element body forces for shells
void FEElasticANSShellDomain::ElementBodyForce(FEBodyForce& BF, FEShellElementNew& el, vector<double>& fe)
{
// integration weights
double* gw = el.GaussWeights();
double eta;
double *M, detJt;
// loop over integration points
int nint = el.GaussPoints();
int neln = el.Nodes();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
double dens = m_pMat->Density(mp);
// calculate the jacobian
detJt = detJ0(el, n)*gw[n];
M = el.H(n);
eta = el.gt(n);
// get the force
vec3d f = BF.force(mp);
for (int i=0; i<neln; ++i)
{
vec3d fu = f*(dens*M[i]*(1+eta)/2*detJt);
vec3d fd = f*(dens*M[i]*(1-eta)/2*detJt);
fe[6*i ] -= fu.x;
fe[6*i+1] -= fu.y;
fe[6*i+2] -= fu.z;
fe[6*i+3] -= fd.x;
fe[6*i+4] -= fd.y;
fe[6*i+5] -= fd.z;
}
}
}
//-----------------------------------------------------------------------------
// Calculate inertial forces
void FEElasticANSShellDomain::InertialForces(FEGlobalVector& R, vector<double>& F)
{
int NE = (int)m_Elem.size();
#pragma omp parallel for shared (NE)
for (int i=0; i<NE; ++i)
{
// element force vector
vector<double> fe;
vector<int> lm;
// get the element
FEShellElementNew& el = m_Elem[i];
// get the element force vector and initialize it to zero
int ndof = 6*el.Nodes();
fe.assign(ndof, 0);
// calculate internal force vector
ElementInertialForce(el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble element 'fe'-vector into global R vector
R.Assemble(el.m_node, lm, fe, true);
}
}
//-----------------------------------------------------------------------------
void FEElasticANSShellDomain::ElementInertialForce(FEShellElementNew& el, vector<double>& fe)
{
const FETimeInfo& tp = GetFEModel()->GetTime();
double alpham = tp.alpham;
int nint = el.GaussPoints();
int neln = el.Nodes();
// evaluate the element inertial force vector
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
double J0 = detJ0(el, n)*el.GaussWeights()[n];
double d = m_pMat->Density(mp);
double* M = el.H(n);
double eta = el.gt(n);
for (int i=0; i<neln; ++i)
{
vec3d fu = pt.m_a*(d*M[i]*(1+eta)/2*J0);
vec3d fd = pt.m_a*(d*M[i]*(1-eta)/2*J0);
fe[6*i ] -= fu.x;
fe[6*i+1] -= fu.y;
fe[6*i+2] -= fu.z;
fe[6*i+3] -= fd.x;
fe[6*i+4] -= fd.y;
fe[6*i+5] -= fd.z;
}
}
}
//-----------------------------------------------------------------------------
//! This function calculates the stiffness due to body forces
void FEElasticANSShellDomain::ElementBodyForceStiffness(FEBodyForce& BF, FEShellElementNew &el, matrix &ke)
{
int i, j, i6, j6;
int neln = el.Nodes();
// jacobian
double detJ;
double *M;
double* gw = el.GaussWeights();
mat3d K;
double Mu[FEElement::MAX_NODES], Md[FEElement::MAX_NODES];
// loop over integration points
int nint = el.GaussPoints();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
detJ = detJ0(el, n)*gw[n];
double dens = m_pMat->Density(mp);
// get the stiffness
K = BF.stiffness(mp)*dens*detJ;
M = el.H(n);
double eta = el.gt(n);
for (i=0; i<neln; ++i)
{
Mu[i] = M[i]*(1+eta)/2;
Md[i] = M[i]*(1-eta)/2;
}
for (i=0, i6=0; i<neln; ++i, i6 += 6)
{
for (j=0, j6 = 0; j<neln; ++j, j6 += 6)
{
mat3d Kuu = K*(Mu[i]*Mu[j]);
mat3d Kud = K*(Mu[i]*Md[j]);
mat3d Kdu = K*(Md[i]*Mu[j]);
mat3d Kdd = K*(Md[i]*Md[j]);
ke[i6 ][j6 ] += Kuu(0,0); ke[i6 ][j6+1] += Kuu(0,1); ke[i6 ][j6+2] += Kuu(0,2);
ke[i6+1][j6 ] += Kuu(1,0); ke[i6+1][j6+1] += Kuu(1,1); ke[i6+1][j6+2] += Kuu(1,2);
ke[i6+2][j6 ] += Kuu(2,0); ke[i6+2][j6+1] += Kuu(2,1); ke[i6+2][j6+2] += Kuu(2,2);
ke[i6 ][j6+3] += Kud(0,0); ke[i6 ][j6+4] += Kud(0,1); ke[i6 ][j6+5] += Kud(0,2);
ke[i6+1][j6+3] += Kud(1,0); ke[i6+1][j6+4] += Kud(1,1); ke[i6+1][j6+5] += Kud(1,2);
ke[i6+2][j6+3] += Kud(2,0); ke[i6+2][j6+4] += Kud(2,1); ke[i6+2][j6+5] += Kud(2,2);
ke[i6+3][j6 ] += Kdu(0,0); ke[i6+3][j6+1] += Kdu(0,1); ke[i6+3][j6+2] += Kdu(0,2);
ke[i6+4][j6 ] += Kdu(1,0); ke[i6+4][j6+1] += Kdu(1,1); ke[i6+4][j6+2] += Kdu(1,2);
ke[i6+5][j6 ] += Kdu(2,0); ke[i6+5][j6+1] += Kdu(2,1); ke[i6+5][j6+2] += Kdu(2,2);
ke[i6+3][j6+3] += Kdd(0,0); ke[i6+3][j6+4] += Kdd(0,1); ke[i6+3][j6+5] += Kdd(0,2);
ke[i6+4][j6+3] += Kdd(1,0); ke[i6+4][j6+4] += Kdd(1,1); ke[i6+4][j6+5] += Kdd(1,2);
ke[i6+5][j6+3] += Kdd(2,0); ke[i6+5][j6+4] += Kdd(2,1); ke[i6+5][j6+5] += Kdd(2,2);
}
}
}
}
//-----------------------------------------------------------------------------
void FEElasticANSShellDomain::StiffnessMatrix(FELinearSystem& LS)
{
// repeat over all shell elements
int NS = (int)m_Elem.size();
#pragma omp parallel for shared (NS)
for (int iel=0; iel<NS; ++iel)
{
FEShellElement& el = m_Elem[iel];
// create the element's stiffness matrix
FEElementMatrix ke(el);
int ndof = 6*el.Nodes();
ke.resize(ndof, ndof);
// calculate the element stiffness matrix
ElementStiffness(iel, ke);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
void FEElasticANSShellDomain::MassMatrix(FELinearSystem& LS, double scale)
{
// repeat over all solid elements
int NE = (int)m_Elem.size();
#pragma omp parallel for shared (NE)
for (int iel=0; iel<NE; ++iel)
{
FEShellElementNew& el = m_Elem[iel];
// create the element's stiffness matrix
FEElementMatrix ke(el);
int ndof = 6*el.Nodes();
ke.resize(ndof, ndof);
ke.zero();
// calculate inertial stiffness
ElementMassMatrix(el, ke, scale);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
void FEElasticANSShellDomain::BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf)
{
// repeat over all shell elements
int NE = (int)m_Elem.size();
#pragma omp parallel for shared (NE)
for (int iel=0; iel<NE; ++iel)
{
FEShellElementNew& el = m_Elem[iel];
// create the element's stiffness matrix
FEElementMatrix ke(el);
int ndof = 6*el.Nodes();
ke.resize(ndof, ndof);
ke.zero();
// calculate inertial stiffness
ElementBodyForceStiffness(bf, el, ke);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
//! Calculates the shell element stiffness matrix
void FEElasticANSShellDomain::ElementStiffness(int iel, matrix& ke)
{
FEShellElementNew& el = ShellElement(iel);
int i, i6, j, j6, n;
// Get the current element's data
const int nint = el.GaussPoints();
const int neln = el.Nodes();
// jacobian matrix determinant
double detJt;
// weights at gauss points
const double *gw = el.GaussWeights();
vec3d Gcnt[3];
// allocate arrays
vector<double> EE;
vector< vector<vec3d>> HU;
vector< vector<vec3d>> HW;
matrix NS(neln,16);
matrix NN(neln,8);
bool ANS = true;
if (ANS) CollocationStrainsANS(el, EE, HU, HW, NS, NN);
// calculate element stiffness matrix
vector<matrix> hu(neln, matrix(3,6));
vector<matrix> hw(neln, matrix(3,6));
vector<vec3d> Nu(neln);
vector<vec3d> Nw(neln);
ke.zero();
matrix KUU(3,3), KUW(3,3), KWU(3,3), KWW(3,3);
for (n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *(el.GetMaterialPoint(n));
ContraBaseVectors0(el, n, Gcnt);
EvaluateEh(el, n, Gcnt, el.m_E[n], hu, hw, Nu, Nw);
if (ANS) EvaluateANS(el, n, Gcnt, el.m_E[n], hu, hw, EE, HU, HW);
// calculate the jacobian
detJt = detJ0(el, n)*gw[n];
// evaluate 2nd P-K stress
matrix SC(6,1);
mat3ds S = m_pMat->PK2Stress(mp, el.m_E[n]);
mat3dsCntMat61(S, Gcnt, SC);
// evaluate the material tangent
matrix CC(6,6);
tens4dmm c = m_pMat->MaterialTangent(mp, el.m_E[n]);
tens4dmmCntMat66(c, Gcnt, CC);
// tens4dsCntMat66(c, Gcnt, CC);
// ------------ constitutive component --------------
for (i=0, i6=0; i<neln; ++i, i6 += 6)
{
for (j=0, j6 = 0; j<neln; ++j, j6 += 6)
{
matrix KUU(3,3), KUW(3,3), KWU(3,3), KWW(3,3);
KUU = hu[i]*CC*hu[j].transpose();
KUW = hu[i]*CC*hw[j].transpose();
KWU = hw[i]*CC*hu[j].transpose();
KWW = hw[i]*CC*hw[j].transpose();
KUU *= detJt; KUW *= detJt; KWU *= detJt; KWW *= detJt;
ke[i6 ][j6 ] += KUU(0,0); ke[i6 ][j6+1] += KUU(0,1); ke[i6 ][j6+2] += KUU(0,2);
ke[i6+1][j6 ] += KUU(1,0); ke[i6+1][j6+1] += KUU(1,1); ke[i6+1][j6+2] += KUU(1,2);
ke[i6+2][j6 ] += KUU(2,0); ke[i6+2][j6+1] += KUU(2,1); ke[i6+2][j6+2] += KUU(2,2);
ke[i6 ][j6+3] += KUW(0,0); ke[i6 ][j6+4] += KUW(0,1); ke[i6 ][j6+5] += KUW(0,2);
ke[i6+1][j6+3] += KUW(1,0); ke[i6+1][j6+4] += KUW(1,1); ke[i6+1][j6+5] += KUW(1,2);
ke[i6+2][j6+3] += KUW(2,0); ke[i6+2][j6+4] += KUW(2,1); ke[i6+2][j6+5] += KUW(2,2);
ke[i6+3][j6 ] += KWU(0,0); ke[i6+3][j6+1] += KWU(0,1); ke[i6+3][j6+2] += KWU(0,2);
ke[i6+4][j6 ] += KWU(1,0); ke[i6+4][j6+1] += KWU(1,1); ke[i6+4][j6+2] += KWU(1,2);
ke[i6+5][j6 ] += KWU(2,0); ke[i6+5][j6+1] += KWU(2,1); ke[i6+5][j6+2] += KWU(2,2);
ke[i6+3][j6+3] += KWW(0,0); ke[i6+3][j6+4] += KWW(0,1); ke[i6+3][j6+5] += KWW(0,2);
ke[i6+4][j6+3] += KWW(1,0); ke[i6+4][j6+4] += KWW(1,1); ke[i6+4][j6+5] += KWW(1,2);
ke[i6+5][j6+3] += KWW(2,0); ke[i6+5][j6+4] += KWW(2,1); ke[i6+5][j6+5] += KWW(2,2);
}
}
// ------------ initial stress component --------------
for (i=0; i<neln; ++i) {
for (j=0; j<neln; ++j)
{
double Kuu, Kuw, Kwu, Kww;
if (ANS) {
double r = el.gr(n);
double s = el.gs(n);
double N13uu = ((NS(i,0)*NS(j,1) + NS(j,0)*NS(i,1))*(1-s)+
(NS(i,8)*NS(j,9) + NS(j,8)*NS(i,9))*(1+s))/2;
double N23uu = ((NS(i,12)*NS(j,13) + NS(j,12)*NS(i,13))*(1-r)+
(NS(i,4)*NS(j,5) + NS(j,4)*NS(i,5))*(1+r))/2;
double N33uu = ((1-r)*(1-s)*NN(i,0)*NN(j,0) +
(1+r)*(1-s)*NN(i,2)*NN(j,2) +
(1+r)*(1+s)*NN(i,4)*NN(j,4) +
(1-r)*(1+s)*NN(i,6)*NN(j,6))/4;
Kuu = (SC(0,0)*Nu[i].x*Nu[j].x+
SC(1,0)*Nu[i].y*Nu[j].y+
SC(2,0)*N33uu+
SC(3,0)*(Nu[i].x*Nu[j].y+Nu[j].x*Nu[i].y)+
SC(4,0)*N23uu+
SC(5,0)*N13uu)*detJt;
double N13uw = ((NS(i,0)*NS(j,3) + NS(j,2)*NS(i,1))*(1-s)+
(NS(i,8)*NS(j,11) + NS(j,10)*NS(i,9))*(1+s))/2;
double N23uw = ((NS(i,12)*NS(j,15) + NS(j,14)*NS(i,13))*(1-r)+
(NS(i,4)*NS(j,7) + NS(j,6)*NS(i,5))*(1+r))/2;
double N33uw = ((1-r)*(1-s)*NN(i,0)*NN(j,1) +
(1+r)*(1-s)*NN(i,2)*NN(j,3) +
(1+r)*(1+s)*NN(i,4)*NN(j,5) +
(1-r)*(1+s)*NN(i,6)*NN(j,7))/4;
Kuw = (SC(0,0)*Nu[i].x*Nw[j].x+
SC(1,0)*Nu[i].y*Nw[j].y+
SC(2,0)*N33uw+
SC(3,0)*(Nu[i].x*Nw[j].y+Nu[j].x*Nw[i].y)+
SC(4,0)*N23uw+
SC(5,0)*N13uw)*detJt;
double N13wu = ((NS(i,2)*NS(j,1) + NS(j,0)*NS(i,3))*(1-s)+
(NS(i,10)*NS(j,9) + NS(j,8)*NS(i,11))*(1+s))/2;
double N23wu = ((NS(i,14)*NS(j,13) + NS(j,12)*NS(i,15))*(1-r)+
(NS(i,6)*NS(j,5) + NS(j,4)*NS(i,7))*(1+r))/2;
double N33wu = ((1-r)*(1-s)*NN(i,1)*NN(j,0) +
(1+r)*(1-s)*NN(i,3)*NN(j,2) +
(1+r)*(1+s)*NN(i,5)*NN(j,4) +
(1-r)*(1+s)*NN(i,7)*NN(j,6))/4;
Kwu = (SC(0,0)*Nw[i].x*Nu[j].x+
SC(1,0)*Nw[i].y*Nu[j].y+
SC(2,0)*N33wu+
SC(3,0)*(Nw[i].x*Nu[j].y+Nw[j].x*Nu[i].y)+
SC(4,0)*N23wu+
SC(5,0)*N13wu)*detJt;
double N13ww = ((NS(i,2)*NS(j,3) + NS(j,2)*NS(i,3))*(1-s)+
(NS(i,10)*NS(j,11) + NS(j,10)*NS(i,11))*(1+s))/2;
double N23ww = ((NS(i,14)*NS(j,15) + NS(j,14)*NS(i,15))*(1-r)+
(NS(i,6)*NS(j,7) + NS(j,6)*NS(i,7))*(1+r))/2;
double N33ww = ((1-r)*(1-s)*NN(i,1)*NN(j,1) +
(1+r)*(1-s)*NN(i,3)*NN(j,3) +
(1+r)*(1+s)*NN(i,5)*NN(j,5) +
(1-r)*(1+s)*NN(i,7)*NN(j,7))/4;
Kww = (SC(0,0)*Nw[i].x*Nw[j].x+
SC(1,0)*Nw[i].y*Nw[j].y+
SC(2,0)*N33ww+
SC(3,0)*(Nw[i].x*Nw[j].y+Nw[j].x*Nw[i].y)+
SC(4,0)*N23ww+
SC(5,0)*N13ww)*detJt;
}
else {
Kuu = (SC(0,0)*Nu[i].x*Nu[j].x+
SC(1,0)*Nu[i].y*Nu[j].y+
SC(2,0)*Nu[i].z*Nu[j].z+
SC(3,0)*(Nu[i].x*Nu[j].y+Nu[j].x*Nu[i].y)+
SC(4,0)*(Nu[i].y*Nu[j].z+Nu[j].y*Nu[i].z)+
SC(5,0)*(Nu[i].z*Nu[j].x+Nu[j].z*Nu[i].x))*detJt;
Kuw = (SC(0,0)*Nu[i].x*Nw[j].x+
SC(1,0)*Nu[i].y*Nw[j].y+
SC(2,0)*Nu[i].z*Nw[j].z+
SC(3,0)*(Nu[i].x*Nw[j].y+Nu[j].x*Nw[i].y)+
SC(4,0)*(Nu[i].y*Nw[j].z+Nu[j].y*Nw[i].z)+
SC(5,0)*(Nu[i].z*Nw[j].x+Nu[j].z*Nw[i].x))*detJt;
Kwu = (SC(0,0)*Nw[i].x*Nu[j].x+
SC(1,0)*Nw[i].y*Nu[j].y+
SC(2,0)*Nw[i].z*Nu[j].z+
SC(3,0)*(Nw[i].x*Nu[j].y+Nw[j].x*Nu[i].y)+
SC(4,0)*(Nw[i].y*Nu[j].z+Nw[j].y*Nu[i].z)+
SC(5,0)*(Nw[i].z*Nu[j].x+Nw[j].z*Nu[i].x))*detJt;
Kww = (SC(0,0)*Nw[i].x*Nw[j].x+
SC(1,0)*Nw[i].y*Nw[j].y+
SC(2,0)*Nw[i].z*Nw[j].z+
SC(3,0)*(Nw[i].x*Nw[j].y+Nw[j].x*Nw[i].y)+
SC(4,0)*(Nw[i].y*Nw[j].z+Nw[j].y*Nw[i].z)+
SC(5,0)*(Nw[i].z*Nw[j].x+Nw[j].z*Nw[i].x))*detJt;
}
// the u-u component
ke[6*i ][6*j ] += Kuu;
ke[6*i+1][6*j+1] += Kuu;
ke[6*i+2][6*j+2] += Kuu;
// the u-w component
ke[6*i ][6*j+3] += Kuw;
ke[6*i+1][6*j+4] += Kuw;
ke[6*i+2][6*j+5] += Kuw;
// the w-u component
ke[6*i+3][6*j ] += Kwu;
ke[6*i+4][6*j+1] += Kwu;
ke[6*i+5][6*j+2] += Kwu;
// the w-w component
ke[6*i+3][6*j+3] += Kww;
ke[6*i+4][6*j+4] += Kww;
ke[6*i+5][6*j+5] += Kww;
}
}
} // end loop over gauss-points
}
//-----------------------------------------------------------------------------
//! calculates element inertial stiffness matrix
void FEElasticANSShellDomain::ElementMassMatrix(FEShellElementNew& el, matrix& ke, double a)
{
// Get the current element's data
const int nint = el.GaussPoints();
const int neln = el.Nodes();
// weights at gauss points
const double *gw = el.GaussWeights();
// calculate element stiffness matrix
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
double D = m_pMat->Density(mp);
// shape functions
double* M = el.H(n);
// Jacobian
double J0 = detJ0(el, n)*gw[n];
// parametric coordinate through thickness
double eta = el.gt(n);
for (int i=0; i<neln; ++i)
for (int j=0; j<neln; ++j)
{
double Kuu = (1+eta)/2*M[i]*(1+eta)/2*M[j]*a*D*J0;
double Kud = (1+eta)/2*M[i]*(1-eta)/2*M[j]*a*D*J0;
double Kdu = (1-eta)/2*M[i]*(1+eta)/2*M[j]*a*D*J0;
double Kdd = (1-eta)/2*M[i]*(1-eta)/2*M[j]*a*D*J0;
// the u-u component
ke[6*i ][6*j ] += Kuu;
ke[6*i+1][6*j+1] += Kuu;
ke[6*i+2][6*j+2] += Kuu;
// the u-d component
ke[6*i ][6*j+3] += Kud;
ke[6*i+1][6*j+4] += Kud;
ke[6*i+2][6*j+5] += Kud;
// the d-u component
ke[6*i+3][6*j ] += Kdu;
ke[6*i+4][6*j+1] += Kdu;
ke[6*i+5][6*j+2] += Kdu;
// the d-d component
ke[6*i+3][6*j+3] += Kdd;
ke[6*i+4][6*j+4] += Kdd;
ke[6*i+5][6*j+5] += Kdd;
}
}
}
//-----------------------------------------------------------------------------
//! Calculates body forces for shells
void FEElasticANSShellDomain::ElementBodyForce(FEModel& fem, FEShellElementNew& el, vector<double>& fe)
{
int NF = fem.ModelLoads();
for (int nf = 0; nf < NF; ++nf)
{
FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(fem.ModelLoad(nf));
if (pbf)
{
// integration weights
double* gw = el.GaussWeights();
double eta;
double *M, detJt;
// loop over integration points
int nint = el.GaussPoints();
int neln = el.Nodes();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double dens0 = m_pMat->Density(mp);
// calculate density in current configuration
double dens = dens0/pt.m_J;
// calculate the jacobian
detJt = detJ(el, n)*gw[n];
M = el.H(n);
eta = el.gt(n);
// get the force
vec3d f = pbf->force(mp);
for (int i=0; i<neln; ++i)
{
vec3d fu = f*(dens*M[i]*(1+eta)/2);
vec3d fd = f*(dens*M[i]*(1-eta)/2);
fe[6*i ] -= fu.x*detJt;
fe[6*i+1] -= fu.y*detJt;
fe[6*i+2] -= fu.z*detJt;
fe[6*i+3] -= fd.x*detJt;
fe[6*i+4] -= fd.y*detJt;
fe[6*i+5] -= fd.z*detJt;
}
}
}
}
}
//-----------------------------------------------------------------------------
void FEElasticANSShellDomain::Update(const FETimeInfo& tp)
{
FESSIShellDomain::Update(tp);
bool berr = false;
int NE = Elements();
#pragma omp parallel for shared(NE, berr)
for (int i=0; i<NE; ++i)
{
try
{
FEShellElement& el = Element(i);
if (el.isActive())
{
UpdateElementStress(i, tp);
}
}
catch (NegativeJacobian e)
{
#pragma omp critical
{
// reset the logfile mode
berr = true;
if (e.DoOutput()) feLogError(e.what());
}
}
}
if (berr) throw NegativeJacobianDetected();
}
//-----------------------------------------------------------------------------
void FEElasticANSShellDomain::UpdateElementStress(int iel, const FETimeInfo& tp)
{
double dt = tp.timeIncrement;
// get the solid element
FEShellElementNew& el = m_Elem[iel];
// get the number of integration points
int nint = el.GaussPoints();
// number of nodes
int neln = el.Nodes();
const int NELN = FEElement::MAX_NODES;
vec3d r0[NELN], s0[NELN], r[NELN], s[NELN];
vec3d v[NELN], w[NELN];
vec3d a[NELN], b[NELN];
// nodal coordinates
GetCurrentNodalCoordinates(el, r, tp.alphaf, false);
GetCurrentNodalCoordinates(el, s, tp.alphaf, true);
GetReferenceNodalCoordinates(el, r0, false);
GetReferenceNodalCoordinates(el, s0, true);
// update dynamic quantities
if (m_update_dynamic)
{
for (int j=0; j<neln; ++j)
{
FENode& node = m_pMesh->Node(el.m_node[j]);
v[j] = node.get_vec3d(m_dofV[0], m_dofV[1], m_dofV[2])*tp.alphaf + node.m_vp*(1-tp.alphaf);
w[j] = node.get_vec3d(m_dofSV[0], m_dofSV[1], m_dofSV[2])*tp.alphaf + node.get_vec3d_prev(m_dofSV[0], m_dofSV[1], m_dofSV[2])*(1-tp.alphaf);
a[j] = node.m_at*tp.alpham + node.m_ap*(1-tp.alpham);
b[j] = node.get_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2])*tp.alpham + node.get_vec3d_prev(m_dofSA[0], m_dofSA[1], m_dofSA[2])*(1-tp.alpham);
}
}
// loop over the integration points and calculate
// the stress at the integration point
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *(el.GetMaterialPoint(n));
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// material point coordinates
// TODO: I'm not entirly happy with this solution
// since the material point coordinates are used by most materials.
mp.m_r0 = evaluate(el, r0, s0, n);
mp.m_rt = evaluate(el, r, s, n);
// get the deformation gradient and determinant at intermediate time
mat3d Ft, Fp;
double Jt = defgrad(el, Ft, n);
double Jp = defgradp(el, Fp, n);
if (tp.alphaf == 1.0)
{
pt.m_F = Ft;
pt.m_J = Jt;
}
else
{
pt.m_F = Ft * tp.alphaf + Fp * (1 - tp.alphaf);
pt.m_J = pt.m_F.det();
}
mat3d Fi = pt.m_F.inverse();
pt.m_L = (Ft - Fp)*Fi/dt;
if (m_update_dynamic)
{
pt.m_v = evaluate(el, v, w, n);
pt.m_a = evaluate(el, a, b, n);
}
// update specialized material points
m_pMat->UpdateSpecializedMaterialPoints(mp, tp);
// calculate the stress at this material point
mat3ds S = m_secant_stress ? m_pMat->SecantStress(mp, true) : m_pMat->PK2Stress(mp, el.m_E[n]);
pt.m_s = (pt.m_F*S*pt.m_F.transpose()).sym()/pt.m_J;
// adjust stress for strain energy conservation
if (tp.alphaf == 0.5)
{
// evaluate strain energy at current time
mat3d Ftmp = pt.m_F;
double Jtmp = pt.m_J;
pt.m_F = Ft;
pt.m_J = Jt;
FEElasticMaterial* pme = dynamic_cast<FEElasticMaterial*>(m_pMat);
pt.m_Wt = pme->StrainEnergyDensity(mp);
pt.m_F = Ftmp;
pt.m_J = Jtmp;
mat3ds D = pt.m_L.sym();
double D2 = D.dotdot(D);
if (D2 > 0)
pt.m_s += D*(((pt.m_Wt-pt.m_Wp)/(dt*pt.m_J) - pt.m_s.dotdot(D))/D2);
}
}
}
//-----------------------------------------------------------------------------
//! Unpack the element. That is, copy element data in traits structure
//! Note that for the shell elements the lm order is different compared
//! to the solid element ordering. This is because for shell elements the
//! nodes have six degrees of freedom each, where for solids they only
//! have 3 dofs.
void FEElasticANSShellDomain::UnpackLM(FEElement& el, vector<int>& lm)
{
int N = el.Nodes();
lm.resize(N*9);
for (int i=0; i<N; ++i)
{
FENode& node = m_pMesh->Node(el.m_node[i]);
vector<int>& id = node.m_ID;
// first the displacement dofs
lm[6*i ] = id[m_dofU[0]];
lm[6*i+1] = id[m_dofU[1]];
lm[6*i+2] = id[m_dofU[2]];
// next the shell displacement dofs
lm[6*i+3] = id[m_dofSU[0]];
lm[6*i+4] = id[m_dofSU[1]];
lm[6*i+5] = id[m_dofSU[2]];
// rigid rotational dofs
lm[6*N + 3*i ] = id[m_dofR[0]];
lm[6*N + 3*i+1] = id[m_dofR[1]];
lm[6*N + 3*i+2] = id[m_dofR[2]];
}
}
//-----------------------------------------------------------------------------
//! Evaluate contravariant components of mat3ds tensor
void FEElasticANSShellDomain::mat3dsCntMat61(const mat3ds s, const vec3d* Gcnt, matrix& S)
{
S.resize(6, 1);
S(0,0) = Gcnt[0]*(s*Gcnt[0]);
S(1,0) = Gcnt[1]*(s*Gcnt[1]);
S(2,0) = Gcnt[2]*(s*Gcnt[2]);
S(3,0) = Gcnt[0]*(s*Gcnt[1]);
S(4,0) = Gcnt[1]*(s*Gcnt[2]);
S(5,0) = Gcnt[0]*(s*Gcnt[2]);
}
//-----------------------------------------------------------------------------
//! Evaluate contravariant components of tens4ds tensor
//! Cijkl = Gj.(Gi.c.Gl).Gk
void FEElasticANSShellDomain::tens4dsCntMat66(const tens4ds c, const vec3d* Gcnt, matrix& C)
{
C.resize(6, 6);
C(0,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[0])*Gcnt[0]); // i=0, j=0, k=0, l=0
C(0,1) = C(1,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[1]); // i=0, j=0, k=1, l=1
C(0,2) = C(2,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[2]); // i=0, j=0, k=2, l=2
C(0,3) = C(3,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[0]); // i=0, j=0, k=0, l=1
C(0,4) = C(4,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[1]); // i=0, j=0, k=1, l=2
C(0,5) = C(5,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=0, k=0, l=2
C(1,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[1])*Gcnt[1]); // i=1, j=1, k=1, l=1
C(1,2) = C(2,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[2]); // i=1, j=1, k=2, l=2
C(1,3) = C(3,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[1])*Gcnt[0]); // i=1, j=1, k=0, l=1
C(1,4) = C(4,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[1]); // i=1, j=1, k=1, l=2
C(1,5) = C(5,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[0]); // i=1, j=1, k=0, l=2
C(2,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[2]); // i=2, j=2, k=2, l=2
C(2,3) = C(3,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[1])*Gcnt[0]); // i=2, j=2, k=0, l=1
C(2,4) = C(4,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[1]); // i=2, j=2, k=1, l=2
C(2,5) = C(5,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[0]); // i=2, j=2, k=0, l=2
C(3,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[0]); // i=0, j=1, k=0, l=1
C(3,4) = C(4,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[1]); // i=0, j=1, k=1, l=2
C(3,5) = C(5,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=1, k=0, l=2
C(4,4) = Gcnt[2]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[1]); // i=1, j=2, k=1, l=2
C(4,5) = C(5,4) = Gcnt[2]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[0]); // i=1, j=2, k=0, l=2
C(5,5) = Gcnt[2]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=2, k=0, l=2
}
//-----------------------------------------------------------------------------
//! Evaluate contravariant components of tens4dm tensor
//! Cijkl = Gj.(Gi.c.Gl).Gk
void FEElasticANSShellDomain::tens4dmmCntMat66(const tens4dmm c, const vec3d* Gcnt, matrix& C)
{
C.resize(6, 6);
C(0,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[0])*Gcnt[0]); // i=0, j=0, k=0, l=0
C(0,1) = C(1,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[1]); // i=0, j=0, k=1, l=1
C(0,2) = C(2,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[2]); // i=0, j=0, k=2, l=2
C(0,3) = C(3,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[0]); // i=0, j=0, k=0, l=1
C(0,4) = C(4,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[1]); // i=0, j=0, k=1, l=2
C(0,5) = C(5,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=0, k=0, l=2
C(1,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[1])*Gcnt[1]); // i=1, j=1, k=1, l=1
C(1,2) = C(2,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[2]); // i=1, j=1, k=2, l=2
C(1,3) = C(3,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[1])*Gcnt[0]); // i=1, j=1, k=0, l=1
C(1,4) = C(4,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[1]); // i=1, j=1, k=1, l=2
C(1,5) = C(5,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[0]); // i=1, j=1, k=0, l=2
C(2,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[2]); // i=2, j=2, k=2, l=2
C(2,3) = C(3,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[1])*Gcnt[0]); // i=2, j=2, k=0, l=1
C(2,4) = C(4,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[1]); // i=2, j=2, k=1, l=2
C(2,5) = C(5,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[0]); // i=2, j=2, k=0, l=2
C(3,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[0]); // i=0, j=1, k=0, l=1
C(3,4) = C(4,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[1]); // i=0, j=1, k=1, l=2
C(3,5) = C(5,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=1, k=0, l=2
C(4,4) = Gcnt[2]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[1]); // i=1, j=2, k=1, l=2
C(4,5) = C(5,4) = Gcnt[2]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[0]); // i=1, j=2, k=0, l=2
C(5,5) = Gcnt[2]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=2, k=0, l=2
}
//-----------------------------------------------------------------------------
//! Evaluate collocation strains for assumed natural strain (ANS) method
void FEElasticANSShellDomain::CollocationStrainsANS(FEShellElementNew& el, vector<double>& E,
vector< vector<vec3d>>& HU, vector< vector<vec3d>>& HW,
matrix& NS, matrix& NN)
{
FETimeInfo& tp = GetFEModel()->GetTime();
// ANS method for 4-node quadrilaterials
if (el.Nodes() == 4) {
vec3d gcov[3], Gcov[3];
double Mr[FEElement::MAX_NODES], Ms[FEElement::MAX_NODES], M[FEElement::MAX_NODES];
double r, s, t;
int neln = el.Nodes();
double Nur, Nus, Nut;
double Nwr, Nws, Nwt;
// Shear strains E13, E23
// point A
r = 0; s = -1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E13A = (gcov[0]*gcov[2] - Gcov[0]*Gcov[2])/2;
vector<vec3d> hu13A(neln);
vector<vec3d> hw13A(neln);
el.shape_fnc(M, r, s);
el.shape_deriv(Mr, Ms, r, s);
for (int i=0; i<neln; ++i) {
NS(i,0) = Nur = (1+t)/2*Mr[i];
NS(i,1) = Nut = M[i]/2;
NS(i,2) = Nwr = (1-t)/2*Mr[i];
NS(i,3) = Nwt = -M[i]/2;
hu13A[i] = gcov[0]*Nut + gcov[2]*Nur;
hw13A[i] = gcov[0]*Nwt + gcov[2]*Nwr;
}
// point B
r = 1; s = 0; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E23B = (gcov[1]*gcov[2] - Gcov[1]*Gcov[2])/2;
vector<vec3d> hu23B(neln);
vector<vec3d> hw23B(neln);
el.shape_fnc(M, r, s);
el.shape_deriv(Mr, Ms, r, s);
for (int i=0; i<neln; ++i) {
NS(i,4) = Nus = (1+t)/2*Ms[i];
NS(i,5) = Nut = M[i]/2;
NS(i,6) = Nws = (1-t)/2*Ms[i];
NS(i,7) = Nwt = -M[i]/2;
hu23B[i] = gcov[2]*Nus + gcov[1]*Nut;
hw23B[i] = gcov[2]*Nws + gcov[1]*Nwt;
}
// point C
r = 0; s = 1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E13C = (gcov[0]*gcov[2] - Gcov[0]*Gcov[2])/2;
vector<vec3d> hu13C(neln);
vector<vec3d> hw13C(neln);
el.shape_fnc(M, r, s);
el.shape_deriv(Mr, Ms, r, s);
for (int i=0; i<neln; ++i) {
NS(i,8) = Nur = (1+t)/2*Mr[i];
NS(i,9) = Nut = M[i]/2;
NS(i,10) = Nwr = (1-t)/2*Mr[i];
NS(i,11) = Nwt = -M[i]/2;
hu13C[i] = gcov[0]*Nut + gcov[2]*Nur;
hw13C[i] = gcov[0]*Nwt + gcov[2]*Nwr;
}
// point D
r = -1; s = 0; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E23D = (gcov[1]*gcov[2] - Gcov[1]*Gcov[2])/2;
vector<vec3d> hu23D(neln);
vector<vec3d> hw23D(neln);
el.shape_fnc(M, r, s);
el.shape_deriv(Mr, Ms, r, s);
for (int i=0; i<neln; ++i) {
NS(i,12) = Nus = (1+t)/2*Ms[i];
NS(i,13) = Nut = M[i]/2;
NS(i,14) = Nws = (1-t)/2*Ms[i];
NS(i,15) = Nwt = -M[i]/2;
hu23D[i] = gcov[2]*Nus + gcov[1]*Nut;
hw23D[i] = gcov[2]*Nws + gcov[1]*Nwt;
}
// normal strain E33
// point E
r = -1; s = -1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E33E = (gcov[2]*gcov[2] - Gcov[2]*Gcov[2])/2;
vector<vec3d> hu33E(neln);
vector<vec3d> hw33E(neln);
el.shape_fnc(M, r, s);
for (int i=0; i<neln; ++i) {
NN(i,0) = Nut = M[i]/2;
NN(i,1) = Nwt = -M[i]/2;
hu33E[i] = gcov[2]*Nut;
hw33E[i] = gcov[2]*Nwt;
}
// point F
r = 1; s = -1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E33F = (gcov[2]*gcov[2] - Gcov[2]*Gcov[2])/2;
vector<vec3d> hu33F(neln);
vector<vec3d> hw33F(neln);
el.shape_fnc(M, r, s);
for (int i=0; i<neln; ++i) {
NN(i,2) = Nut = M[i]/2;
NN(i,3) = Nwt = -M[i]/2;
hu33F[i] = gcov[2]*Nut;
hw33F[i] = gcov[2]*Nwt;
}
// point G
r = 1; s = 1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E33G = (gcov[2]*gcov[2] - Gcov[2]*Gcov[2])/2;
vector<vec3d> hu33G(neln);
vector<vec3d> hw33G(neln);
el.shape_fnc(M, r, s);
for (int i=0; i<neln; ++i) {
NN(i,4) = Nut = M[i]/2;
NN(i,5) = Nwt = -M[i]/2;
hu33G[i] = gcov[2]*Nut;
hw33G[i] = gcov[2]*Nwt;
}
// point H
r = -1; s = 1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E33H = (gcov[2]*gcov[2] - Gcov[2]*Gcov[2])/2;
vector<vec3d> hu33H(neln);
vector<vec3d> hw33H(neln);
el.shape_fnc(M, r, s);
for (int i=0; i<neln; ++i) {
NN(i,6) = Nut = M[i]/2;
NN(i,7) = Nwt = -M[i]/2;
hu33H[i] = gcov[2]*Nut;
hw33H[i] = gcov[2]*Nwt;
}
// return the results in aggregated format
E.resize(8);
E[0] = E13A; E[1] = E23B; E[2] = E13C; E[3] = E23D;
E[4] = E33E; E[5] = E33F; E[6] = E33G; E[7] = E33H;
HU.resize(8,vector<vec3d>(neln)); HW.resize(8,vector<vec3d>(neln));
for (int i=0; i<neln; ++i) {
HU[0] = hu13A; HU[1] = hu23B; HU[2] = hu13C; HU[3] = hu23D;
HU[4] = hu33E; HU[5] = hu33F; HU[6] = hu33G; HU[7] = hu33H;
HW[0] = hw13A; HW[1] = hw23B; HW[2] = hw13C; HW[3] = hw23D;
HW[4] = hw33E; HW[5] = hw33F; HW[6] = hw33G; HW[7] = hw33H;
}
}
}
//-----------------------------------------------------------------------------
//! Evaluate assumed natural strain (ANS)
void FEElasticANSShellDomain::EvaluateANS(FEShellElementNew& el, const int n, const vec3d* Gcnt,
mat3ds& Ec, vector<matrix>& hu, vector<matrix>& hw,
vector<double>& E, vector< vector<vec3d>>& HU, vector< vector<vec3d>>& HW)
{
// ANS method for 4-node quadrilaterials
if (el.Nodes() == 4) {
vec3d Gcov[3];
int neln = el.Nodes();
double E13A = E[0]; double E23B = E[1];
double E13C = E[2]; double E23D = E[3];
double E33E = E[4]; double E33F = E[5];
double E33G = E[6]; double E33H = E[7];
vector<vec3d> hu13A(HU[0]); vector<vec3d> hu23B(HU[1]);
vector<vec3d> hu13C(HU[2]); vector<vec3d> hu23D(HU[3]);
vector<vec3d> hu33E(HU[4]); vector<vec3d> hu33F(HU[5]);
vector<vec3d> hu33G(HU[6]); vector<vec3d> hu33H(HU[7]);
vector<vec3d> hw13A(HW[0]); vector<vec3d> hw23B(HW[1]);
vector<vec3d> hw13C(HW[2]); vector<vec3d> hw23D(HW[3]);
vector<vec3d> hw33E(HW[4]); vector<vec3d> hw33F(HW[5]);
vector<vec3d> hw33G(HW[6]); vector<vec3d> hw33H(HW[7]);
// Evaluate ANS strains
double r = el.gr(n);
double s = el.gs(n);
double E13ANS = ((1-s)*E13A + (1+s)*E13C)/2;
double E23ANS = ((1-r)*E23D + (1+r)*E23B)/2;
double E33ANS = ((1-r)*(1-s)*E33E + (1+r)*(1-s)*E33F +
(1+r)*(1+s)*E33G + (1-r)*(1+s)*E33H)/4;
vector<vec3d> hu13ANS(neln), hu23ANS(neln), hu33ANS(neln);
vector<vec3d> hw13ANS(neln), hw23ANS(neln), hw33ANS(neln);
for (int i=0; i<neln; ++i) {
hu13ANS[i] = (hu13A[i]*(1-s) + hu13C[i]*(1+s))/2;
hw13ANS[i] = (hw13A[i]*(1-s) + hw13C[i]*(1+s))/2;
hu23ANS[i] = (hu23D[i]*(1-r) + hu23B[i]*(1+r))/2;
hw23ANS[i] = (hw23D[i]*(1-r) + hw23B[i]*(1+r))/2;
hu33ANS[i] = (hu33E[i]*(1-r)*(1-s) + hu33F[i]*(1+r)*(1-s) +
hu33G[i]*(1+r)*(1+s) + hu33H[i]*(1-r)*(1+s))/4;
hw33ANS[i] = (hw33E[i]*(1-r)*(1-s) + hw33F[i]*(1+r)*(1-s) +
hw33G[i]*(1+r)*(1+s) + hw33H[i]*(1-r)*(1+s))/4;
}
// Substitute these strain components into Ec
CoBaseVectors0(el, n, Gcov);
double E11c = Gcov[0]*(Ec*Gcov[0]);
double E22c = Gcov[1]*(Ec*Gcov[1]);
double E12c = Gcov[0]*(Ec*Gcov[1]);
Ec = ((Gcnt[0] & Gcnt[0])*E11c + (Gcnt[1] & Gcnt[1])*E22c + (Gcnt[2] & Gcnt[2])*E33ANS +
((Gcnt[0] & Gcnt[1]) + (Gcnt[1] & Gcnt[0]))*E12c +
((Gcnt[1] & Gcnt[2]) + (Gcnt[2] & Gcnt[1]))*E23ANS +
((Gcnt[2] & Gcnt[0]) + (Gcnt[0] & Gcnt[2]))*E13ANS).sym();
for (int i=0; i<neln; ++i) {
hu[i](0,5) = hu13ANS[i].x; hu[i](1,5) = hu13ANS[i].y; hu[i](2,5) = hu13ANS[i].z;
hw[i](0,5) = hw13ANS[i].x; hw[i](1,5) = hw13ANS[i].y; hw[i](2,5) = hw13ANS[i].z;
hu[i](0,4) = hu23ANS[i].x; hu[i](1,4) = hu23ANS[i].y; hu[i](2,4) = hu23ANS[i].z;
hw[i](0,4) = hw23ANS[i].x; hw[i](1,4) = hw23ANS[i].y; hw[i](2,4) = hw23ANS[i].z;
hu[i](0,2) = hu33ANS[i].x; hu[i](1,2) = hu33ANS[i].y; hu[i](2,2) = hu33ANS[i].z;
hw[i](0,2) = hw33ANS[i].x; hw[i](1,2) = hw33ANS[i].y; hw[i](2,2) = hw33ANS[i].z;
}
}
}
//-----------------------------------------------------------------------------
//! Evaluate strain E and matrix hu and hw
void FEElasticANSShellDomain::EvaluateEh(FEShellElementNew& el, const int n, const vec3d* Gcnt, mat3ds& E,
vector<matrix>& hu, vector<matrix>& hw, vector<vec3d>& Nu, vector<vec3d>& Nw)
{
FETimeInfo& tp = GetFEModel()->GetTime();
const double* Mr, *Ms, *M;
vec3d gcov[3];
int neln = el.Nodes();
FEMaterialPoint& mp = *(el.GetMaterialPoint(n));
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
E = pt.Strain();
CoBaseVectors(el, n, gcov, tp.alphaf);
double eta = el.gt(n);
Mr = el.Hr(n);
Ms = el.Hs(n);
M = el.H(n);
for (int i=0; i<neln; ++i)
{
double Nur = Nu[i].x = (1+eta)/2*Mr[i];
double Nus = Nu[i].y = (1+eta)/2*Ms[i];
double Nut = Nu[i].z = M[i]/2;
double Nwr = Nw[i].x = (1-eta)/2*Mr[i];
double Nws = Nw[i].y = (1-eta)/2*Ms[i];
double Nwt = Nw[i].z = -M[i]/2;
hu[i](0,0) = Nur*gcov[0].x; hu[i](1,0) = Nur*gcov[0].y; hu[i](2,0) = Nur*gcov[0].z;
hu[i](0,1) = Nus*gcov[1].x; hu[i](1,1) = Nus*gcov[1].y; hu[i](2,1) = Nus*gcov[1].z;
hu[i](0,2) = Nut*gcov[2].x; hu[i](1,2) = Nut*gcov[2].y; hu[i](2,2) = Nut*gcov[2].z;
hu[i](0,3) = Nur*gcov[1].x + Nus*gcov[0].x; hu[i](1,3) = Nur*gcov[1].y + Nus*gcov[0].y; hu[i](2,3) = Nur*gcov[1].z + Nus*gcov[0].z;
hu[i](0,4) = Nus*gcov[2].x + Nut*gcov[1].x; hu[i](1,4) = Nus*gcov[2].y + Nut*gcov[1].y; hu[i](2,4) = Nus*gcov[2].z + Nut*gcov[1].z;
hu[i](0,5) = Nut*gcov[0].x + Nur*gcov[2].x; hu[i](1,5) = Nut*gcov[0].y + Nur*gcov[2].y; hu[i](2,5) = Nut*gcov[0].z + Nur*gcov[2].z;
hw[i](0,0) = Nwr*gcov[0].x; hw[i](1,0) = Nwr*gcov[0].y; hw[i](2,0) = Nwr*gcov[0].z;
hw[i](0,1) = Nws*gcov[1].x; hw[i](1,1) = Nws*gcov[1].y; hw[i](2,1) = Nws*gcov[1].z;
hw[i](0,2) = Nwt*gcov[2].x; hw[i](1,2) = Nwt*gcov[2].y; hw[i](2,2) = Nwt*gcov[2].z;
hw[i](0,3) = Nwr*gcov[1].x + Nws*gcov[0].x; hw[i](1,3) = Nwr*gcov[1].y + Nws*gcov[0].y; hw[i](2,3) = Nwr*gcov[1].z + Nws*gcov[0].z;
hw[i](0,4) = Nws*gcov[2].x + Nwt*gcov[1].x; hw[i](1,4) = Nws*gcov[2].y + Nwt*gcov[1].y; hw[i](2,4) = Nws*gcov[2].z + Nwt*gcov[1].z;
hw[i](0,5) = Nwt*gcov[0].x + Nwr*gcov[2].x; hw[i](1,5) = Nwt*gcov[0].y + Nwr*gcov[2].y; hw[i](2,5) = Nwt*gcov[0].z + Nwr*gcov[2].z;
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidSystem.cpp | .cpp | 13,218 | 513 | /*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 "FERigidSystem.h"
#include "FERigidBody.h"
#include <FECore/FEModel.h>
#include <FECore/FEMaterial.h>
#include <FECore/FEDomain.h>
#include "RigidBC.h"
#include <FECore/FEGlobalMatrix.h>
#include "FERigidMaterial.h"
//-----------------------------------------------------------------------------
//! constructor
FERigidSystem::FERigidSystem(FEModel* pfem) : m_fem(*pfem)
{
}
//-----------------------------------------------------------------------------
//! Add a rigid body
void FERigidSystem::AddRigidBody(FERigidBody* prb)
{
if (prb) m_RB.push_back(prb);
}
//-----------------------------------------------------------------------------
FERigidSystem::~FERigidSystem()
{
Clear();
}
//-----------------------------------------------------------------------------
int FERigidSystem::Objects() const
{
return (int) m_RB.size();
}
//-----------------------------------------------------------------------------
std::vector<FERigidBody*>& FERigidSystem::RigidBodyList()
{
return m_RB;
}
//-----------------------------------------------------------------------------
//! Get a rigid body
FERigidBody* FERigidSystem::Object(int i)
{
return m_RB[i];
}
//-----------------------------------------------------------------------------
//! delete all rigid bodies
void FERigidSystem::Clear()
{
for (int i=0; i<(int)m_RB.size (); ++i) delete m_RB [i]; m_RB.clear ();
for (int i=0; i<(int)m_RBC.size(); ++i) delete m_RBC[i]; m_RBC.clear();
for (int i=0; i<(int)m_RIC.size(); ++i) delete m_RIC[i]; m_RIC.clear();
}
//-----------------------------------------------------------------------------
void FERigidSystem::Serialize(DumpStream& ar)
{
if (ar.IsShallow())
{
for (int i=0; i<(int) m_RB.size(); ++i) m_RB[i]->Serialize(ar);
}
else
{
if (ar.IsSaving())
{
// rigid body constraints
ar << m_RBC;
// rigid body initial conditions
ar << m_RIC;
// rigid objects
// (Do these last, since they contain references to rbcs)
int nrb = Objects();
ar << nrb;
for (int i = 0; i < nrb; ++i) m_RB[i]->Serialize(ar);
}
else
{
Clear();
// rigid body constraints
ar >> m_RBC;
// rigid body initial conditions
ar >> m_RIC;
// rigid bodies
int nrb = 0;
ar >> nrb;
for (int i=0; i<nrb; ++i)
{
FERigidBody* prb = new FERigidBody(&m_fem);
prb->Serialize(ar);
AddRigidBody(prb);
}
}
}
}
//-----------------------------------------------------------------------------
void FERigidSystem::Activate()
{
// fixed rigid body dofs
for (int i=0; i<(int) m_RBC.size(); ++i)
{
FERigidBC& rc = *m_RBC[i];
if (rc.IsActive()) rc.Activate();
}
// initial rigid conditions
for (int i=0; i<(int) m_RIC.size(); ++i)
{
FERigidIC& ric = *m_RIC[i];
if (ric.IsActive()) ric.Activate();
}
}
//-----------------------------------------------------------------------------
bool FERigidSystem::Init()
{
// create the rigid bodies from the rigid material list
if (CreateObjects() == false) return false;
// the rigid body constraints are still associated with the rigid materials
// so we now associate them with the rigid bodies
// NOTE: This is now done in the Init() member function for each class
FEModel& fem = m_fem;
for (int i=0; i<(int) m_RBC.size(); ++i)
{
FERigidBC& BC = *m_RBC[i];
if (BC.Init() == false) return false;
}
for (int i=0; i<(int) m_RIC.size(); ++i)
{
FERigidIC& IC = *m_RIC[i];
if (IC.Init() == false) return false;
}
return true;
}
//-----------------------------------------------------------------------------
bool FERigidSystem::InitRigidBodies()
{
FEModel& fem = m_fem;
// initialize rigid body COM
// only set the rigid body com if this is the main rigid body material
for (int i = 0; i < m_RB.size(); ++i)
{
FERigidBody& rb = *m_RB[i];
// first, calculate the mass
rb.UpdateMass();
FERigidMaterial* prm = dynamic_cast<FERigidMaterial*>(fem.GetMaterial(rb.m_mat));
assert(prm);
// next, calculate the center of mass, or just set it
if (prm->m_com == false)
{
rb.UpdateCOM();
}
else
{
rb.SetCOM(prm->m_rc);
}
// finally, determine moi
rb.UpdateMOI();
}
return true;
}
//-----------------------------------------------------------------------------
//! In FEBio rigid bodies are defined implicitly through a list of rigid materials.
//! However, a rigid body can be composed of multiple rigid materials, so we can't
//! just create a rigid body for each rigid material. We must look at the connectivity
//! of the materials as well.
bool FERigidSystem::CreateObjects()
{
FEModel& fem = m_fem;
FEMesh& mesh = fem.GetMesh();
// count the number of rigid materials
int NMAT = fem.Materials();
int nrm = 0;
for (int i=0; i<NMAT; ++i)
{
if (dynamic_cast<FERigidMaterial*>(fem.GetMaterial(i))) nrm++;
}
// make sure there are rigid materials
if (nrm == 0) return true;
// First we need to figure out how many rigid bodies there are.
// This is not the same as rigid materials, since a rigid body
// may be composed of different rigid materials (similarly to a deformable
// body that may contain different materials). Although there can
// only be one deformable mesh, there can be several rigid bodies.
// The mrb array will contain an index to the rigid body the material
// is attached to. For now, we assume one rigid body per rigid material.
vector<int> mrb(NMAT);
int n = 0;
for (int i=0; i<NMAT; ++i)
{
if (dynamic_cast<FERigidMaterial*>(fem.GetMaterial(i))) mrb[i] = n++;
else mrb[i] = -1;
}
// Next, we assign to all nodes a rigid node number
// This number is preliminary since rigid materials can be merged
// Note that we do solid domains first. This is to avoid a complication
// with shells on solids.
// solid domains first
for (int nd = 0; nd < mesh.Domains(); ++nd)
{
FEDomain& dom = mesh.Domain(nd);
if (dom.Class() == FE_DOMAIN_SOLID)
{
FERigidMaterial* pmat = dynamic_cast<FERigidMaterial*>(dom.GetMaterial());
if (pmat)
{
for (int i = 0; i < dom.Elements(); ++i)
{
FEElement& el = dom.ElementRef(i);
for (int j = 0; j < el.Nodes(); ++j)
{
int n = el.m_node[j];
FENode& node = mesh.Node(n);
node.m_rid = pmat->GetID() - 1;
}
}
}
}
}
// non-solid domains
for (int nd = 0; nd < mesh.Domains(); ++nd)
{
FEDomain& dom = mesh.Domain(nd);
if (dom.Class() != FE_DOMAIN_SOLID)
{
FERigidMaterial* pmat = dynamic_cast<FERigidMaterial*>(dom.GetMaterial());
if (pmat)
{
for (int i = 0; i < dom.Elements(); ++i)
{
FEElement& el = dom.ElementRef(i);
for (int j = 0; j < el.Nodes(); ++j)
{
int n = el.m_node[j];
FENode& node = mesh.Node(n);
node.m_rid = pmat->GetID() - 1;
}
}
}
}
}
// now we can merge rigid materials
// if a rigid element has two nodes that connect to two different
// rigid materials we need to merge.
bool bdone;
do
{
bdone = true;
for (int nd=0; nd<mesh.Domains(); ++nd)
{
FEDomain& dom = mesh.Domain(nd);
FERigidMaterial* pmat = dynamic_cast<FERigidMaterial*>(dom.GetMaterial());
if (pmat)
{
for (int i=0; i<dom.Elements(); ++i)
{
FEElement& el = dom.ElementRef(i);
int m = mesh.Node(el.m_node[0]).m_rid;
for (int j=1; j<el.Nodes(); ++j)
{
int n = mesh.Node(el.m_node[j]).m_rid;
if (mrb[n] != mrb[m])
{
if (mrb[n]<mrb[m]) mrb[m] = mrb[n]; else mrb[n] = mrb[m];
bdone = false;
}
}
}
}
}
}
while (!bdone);
// since we may have lost a rigid body in the merge process
// we reindex the RB's.
vector<int> mrc; mrc.assign(NMAT, -1);
for (int i=0; i<NMAT; ++i) if (mrb[i] >= 0) mrc[mrb[i]] = 0;
int nrb = 0;
for (int i=0; i<NMAT; ++i)
{
if (mrc[i] == 0) mrc[i] = nrb++;
}
for (int i=0; i<NMAT; ++i)
{
if (mrb[i] >= 0) mrb[i] = mrc[mrb[i]];
}
// set rigid body index for materials
for (int i=0; i<NMAT; ++i)
{
FERigidMaterial* pm = dynamic_cast<FERigidMaterial*>(fem.GetMaterial(i));
if (pm)
{
pm->SetRigidBodyID(mrb[i]);
}
}
// assign rigid body index to nodes
for (int i=0; i<mesh.Nodes(); ++i)
{
FENode& node = mesh.Node(i);
if (node.m_rid >= 0)
{
node.m_rid = mrb[ node.m_rid ];
node.m_ra = node.m_r0;
}
}
// let's clear all rigid bodies
if (m_RB.empty() == false)
{
for (int i=0; i<(int) m_RB.size(); ++i) delete m_RB[i];
m_RB.clear();
}
// Ok, we now know how many rigid bodies there are
// so let's create them
for (int i=0; i<nrb; ++i)
{
// create a new rigid body
FERigidBody* prb = new FERigidBody(&fem);
prb->m_nID = i;
// Since a rigid body may contain several rigid materials
// we find the first material that this body has and use
// that materials data to set up the rigid body data
int j;
FERigidMaterial* pm = 0;
for (j=0; j<NMAT; ++j)
{
pm = dynamic_cast<FERigidMaterial*>(fem.GetMaterial(j));
if (pm && (pm->GetRigidBodyID() == i)) break;
}
if (j >= NMAT) return false;
prb->m_mat = j;
prb->SetName(pm->GetName());
// add it to the pile
m_RB.push_back(prb);
}
return true;
}
//-----------------------------------------------------------------------------
//! Reset rigid system.
bool FERigidSystem::Reset()
{
int nrb = (int)m_RB.size();
for (int i=0; i<nrb; ++i) m_RB[i]->Reset();
return true;
}
//-----------------------------------------------------------------------------
//! Find a parameter
double* FERigidSystem::FindParameter(int nmat, ParamString& sz, int index)
{
// the rigid bodies are dealt with differently
int nrb = (int)m_RB.size();
for (int i=0; i<nrb; ++i)
{
FERigidBody& ob = *m_RB[i];
if (ob.GetMaterialID() == nmat)
{
FEParam* pp = ob.FindParameter(sz);
if (pp) return pp->pvalue<double>(index);
}
}
return 0;
}
//-----------------------------------------------------------------------------
// find a parameter value
FEParamValue FERigidSystem::GetParameterValue(const ParamString& paramString)
{
ParamString next = paramString.next();
if (next == "rigidbody")
{
int NRB = Objects();
if (next.Index() >= 0)
{
int index = next.Index();
if ((index >= 0) && (index < NRB))
{
ParamString paramName = next.next();
FERigidBody* ob = Object(index);
FEParam* pp = ob->FindParameter(paramName);
if (pp) return GetParameterComponent(paramName.last(), pp);
}
}
else
{
FEMaterial* mat = 0;
if (next.IDString()) mat = m_fem.FindMaterial(next.IDString());
if ((mat != 0) && (dynamic_cast<FERigidMaterial*>(mat)))
{
ParamString paramName = next.next();
// the rigid bodies are dealt with differently
int nmat = mat->GetID() - 1;
for (int i = 0; i < NRB; ++i)
{
FERigidBody* ob = Object(i);
if (ob && (ob->GetMaterialID() == nmat))
{
FEParam* pp = ob->FindParameter(paramName);
if (pp) return GetParameterComponent(paramName.last(), pp);
}
}
}
}
}
return FEParamValue();
}
//-----------------------------------------------------------------------------
//! Call this function after the rigid body kinematics are updated to ensure
//! that the mesh (or at least the part of the mesh corresponding to the rigid
//! bodies) is updated.
void FERigidSystem::UpdateMesh()
{
FEMesh& mesh = m_fem.GetMesh();
int N = mesh.Nodes();
#pragma omp parallel for
for (int i = 0; i < N; ++i)
{
FENode& node = mesh.Node(i);
if (node.m_rid >= 0)
{
FERigidBody& RB = *Object(node.m_rid);
vec3d a0 = node.m_ra - RB.m_r0;
vec3d at = RB.GetRotation()*a0;
node.m_rt = RB.m_rt + at;
}
}
}
//-----------------------------------------------------------------------------
void FERigidSystem::BuildMatrixProfile(FEGlobalMatrix& G)
{
if (Objects())
{
vector<int> lm(6);
int nrb = Objects();
for (int i=0; i<nrb; ++i)
{
FERigidBody& rb = *Object(i);
for (int j=0; j<6; ++j) lm[j] = rb.m_LM[j];
G.build_add(lm);
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEGenericHyperelasticUC.cpp | .cpp | 7,004 | 222 | /*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 "FEGenericHyperelasticUC.h"
#include <FECore/MMath.h>
#include <FECore/MObj2String.h>
#include <FECore/log.h>
BEGIN_FECORE_CLASS(FEGenericHyperelasticUC, FEUncoupledMaterial)
ADD_PARAMETER(m_exp, "W")->setUnits(UNIT_ENERGY);
ADD_PARAMETER(m_printDerivs, "print_derivs");
END_FECORE_CLASS();
FEGenericHyperelasticUC::FEGenericHyperelasticUC(FEModel* fem) : FEUncoupledMaterial(fem)
{
m_printDerivs = false;
}
// initialization
bool FEGenericHyperelasticUC::Init()
{
if (BuildMathExpressions() == false) return false;
return FEUncoupledMaterial::Init();
}
bool FEGenericHyperelasticUC::BuildMathExpressions()
{
vector<string> vars = { "I1", "I2", "X", "Y", "Z" };
// 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());
}
}
m_W.AddVariables(vars);
if (m_W.Create(m_exp) == false) return false;
MITEM W1 = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(0), 1));
MITEM W2 = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(1), 1));
m_W1.AddVariables(vars); m_W1.SetExpression(W1);
m_W2.AddVariables(vars); m_W2.SetExpression(W2);
MITEM W11 = MDerive(m_W1.GetExpression(), *m_W1.Variable(0), 1);
MITEM W12 = MDerive(m_W1.GetExpression(), *m_W1.Variable(1), 1);
MITEM W22 = MDerive(m_W2.GetExpression(), *m_W2.Variable(1), 1);
m_W11.AddVariables(vars); m_W11.SetExpression(W11);
m_W12.AddVariables(vars); m_W12.SetExpression(W12);
m_W22.AddVariables(vars); m_W22.SetExpression(W22);
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 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 sW22 = o2s.Convert(m_W22); feLog("W22 = %s\n", sW22.c_str());
}
return true;
}
// serialization
void FEGenericHyperelasticUC::Serialize(DumpStream& ar)
{
FEUncoupledMaterial::Serialize(ar);
if ((ar.IsShallow() == false) && ar.IsLoading())
{
bool b = BuildMathExpressions();
assert(b);
}
}
//! Deviatoric Cauchy stress
mat3ds FEGenericHyperelasticUC::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());
// get strain energy derivatives
vector<double> v = { I1, I2, mp.m_r0.x, mp.m_r0.y, mp.m_r0.z };
for (int i = 0; i < m_param.size(); ++i) v.push_back(*m_param[i]);
double W1 = m_W1.value_s(v);
double W2 = m_W2.value_s(v);
// calculate T = F*dW/dC*Ft
mat3ds T = B*(W1 + W2*I1) - B2*W2;
// return deviatoric Cauchy stress
return T.dev()*(2.0 / J);
}
//! Deviatoric spatial Tangent
tens4ds FEGenericHyperelasticUC::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
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
double I1 = B.tr();
double I2 = 0.5*(I1*I1 - B2.tr());
// get strain energy derivatives
vector<double> v = { I1, I2, mp.m_r0.x, mp.m_r0.y, mp.m_r0.z };
for (int i = 0; i < m_param.size(); ++i) v.push_back(*m_param[i]);
double W1 = m_W1.value_s(v);
double W2 = m_W2.value_s(v);
double W11 = m_W11.value_s(v);
double W22 = m_W22.value_s(v);
double W12 = m_W12.value_s(v);
// define fourth-order tensors
mat3dd I(1.0);
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxB = dyad1s(B);
tens4ds B2xB2 = dyad1s(B2);
tens4ds BoB2 = dyad1s(B, B2);
tens4ds Ib = dyad4s(B);
// deviatoric stress
mat3ds T = (B*(W1 + W2*I1) - B2*W2)*(2.0/J);
mat3ds devT = T.dev();
// isochoric stiffness contribution
tens4ds dw = BxB*(W11 + 2.0*W12*I1 + W22*I1*I1 + W2) - BoB2*(W12 + W22*I1) + B2xB2*W22 - Ib*W2;
double trDw = dw.tr();
mat3ds dwoI = dw.contract();
tens4ds cw = dw - dyad1s(dwoI, I) / 3.0 + IxI*(trDw / 9.0);
// put it all together
tens4ds c = (I4 - IxI/3.0)*(2.0*T.tr()/3.0) - dyad1s(devT, I)*(2.0/3.0) + cw*(4.0/J);
// all done
return c;
}
//! Deviatoric strain energy density
double FEGenericHyperelasticUC::DevStrainEnergyDensity(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());
// evaluate (deviatoric) strain energy
vector<double> v = { I1, I2, mp.m_r0.x, mp.m_r0.y, mp.m_r0.z };
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/FESRIElasticSolidDomain.cpp | .cpp | 4,881 | 150 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FESRIElasticSolidDomain.h"
#include "FEElasticMaterial.h"
#include "FECore/FEElementLibrary.h"
//-----------------------------------------------------------------------------
FESRIElasticSolidDomain::FESRIElasticSolidDomain(FEModel* pfem) : FEElasticSolidDomain(pfem)
{
}
//-----------------------------------------------------------------------------
void FESRIElasticSolidDomain::ElementInternalForce(FESolidElement& el, vector<double>& fe)
{
// jacobian matrix, inverse jacobian matrix and determinants
double Ji[3][3];
// first, evaluate the deviatoric component using the full-integration rule
int nint = el.GaussPoints();
int neln = el.Nodes();
double* gw = el.GaussWeights();
// repeat for all integration points
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// calculate the jacobian
double detJt = invjact(el, Ji, n);
detJt *= gw[n];
// get the stress vector for this integration point
// we only use the deviatoric component
mat3ds s = pt.m_s.dev();
double* Gr = el.Gr(n);
double* Gs = el.Gs(n);
double* Gt = el.Gt(n);
for (int i=0; i<neln; ++i)
{
// calculate global gradient of shape functions
// note that we need the transposed of Ji, not Ji itself !
double Gx = Ji[0][0]*Gr[i]+Ji[1][0]*Gs[i]+Ji[2][0]*Gt[i];
double Gy = Ji[0][1]*Gr[i]+Ji[1][1]*Gs[i]+Ji[2][1]*Gt[i];
double Gz = Ji[0][2]*Gr[i]+Ji[1][2]*Gs[i]+Ji[2][2]*Gt[i];
// calculate internal force
// the '-' sign is so that the internal forces get subtracted
// from the global residual vector
fe[3*i ] -= ( Gx*s.xx() +
Gy*s.xy() +
Gz*s.xz() )*detJt;
fe[3*i+1] -= ( Gy*s.yy() +
Gx*s.xy() +
Gz*s.yz() )*detJt;
fe[3*i+2] -= ( Gz*s.zz() +
Gy*s.yz() +
Gx*s.xz() )*detJt;
}
}
// next, the pressure component is evaluated using the reduced integration rule
const int NME = FEElement::MAX_NODES;
double Gr[NME], Gs[NME], Gt[NME];
FESRISolidElementTraits* prt_ri = dynamic_cast<FESRISolidElementTraits*>(el.GetTraits());
// if this element does not have a reduced rule, we use the full integration rule
FESolidElementTraits* prt = (prt_ri ? prt_ri->m_pTRI : dynamic_cast<FESolidElementTraits*>(el.GetTraits()));
nint = prt->m_nint;
vector<double>& gr = prt->gr;
vector<double>& gs = prt->gs;
vector<double>& gt = prt->gt;
gw = &(prt->gw[0]);
for (int n=0; n<nint; ++n)
{
double r = gr[n];
double s = gs[n];
double t = gt[n];
// setup the material point
FEElasticMaterialPoint pt;
FEMaterialPoint mp(&pt);
pt.m_J = defgrad(el, pt.m_F, r, s, t);
// calculate the jacobian
double detJt = invjact(el, Ji, r, s, t);
// get the shape function derivatives
el.shape_deriv(Gr, Gs, Gt, r, s, t);
// calculate the stress
mat3ds stress = m_pMat->Stress(mp);
// evaluate the pressure
double p = -(stress.tr()/3.0);
detJt *= gw[n];
for (int i=0; i<neln; ++i)
{
// calculate global gradient of shape functions
// note that we need the transposed of Ji, not Ji itself !
double Gx = Ji[0][0]*Gr[i]+Ji[1][0]*Gs[i]+Ji[2][0]*Gt[i];
double Gy = Ji[0][1]*Gr[i]+Ji[1][1]*Gs[i]+Ji[2][1]*Gt[i];
double Gz = Ji[0][2]*Gr[i]+Ji[1][2]*Gs[i]+Ji[2][2]*Gt[i];
// calculate internal force
// the '-' sign is so that the internal forces get subtracted
// from the global residual vector
fe[3*i ] += ( Gx*p )*detJt;
fe[3*i+1] += ( Gy*p )*detJt;
fe[3*i+2] += ( Gz*p )*detJt;
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEDiscreteElasticDomain.cpp | .cpp | 6,884 | 261 | /*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 "FEDiscreteElasticDomain.h"
#include "FEBioMech.h"
#include <FECore/FEMesh.h>
#include <FECore/FELinearSystem.h>
#include <FECore/FEModel.h>
FEDiscreteElasticDomain::FEDiscreteElasticDomain(FEModel* fem) : FEDiscreteDomain(fem), FEElasticDomain(fem), m_dofU(fem), m_dofR(fem), m_dof(fem)
{
m_pMat = nullptr;
// TODO: Can this be done in Init, since there is no error checking
if (fem)
{
m_dofU.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
m_dofR.AddVariable(FEBioMech::GetVariableName(FEBioMech::RIGID_ROTATION));
}
}
//-----------------------------------------------------------------------------
//! get the material (overridden from FEDomain)
FEMaterial* FEDiscreteElasticDomain::GetMaterial()
{
return m_pMat;
}
//-----------------------------------------------------------------------------
//! set the material
void FEDiscreteElasticDomain::SetMaterial(FEMaterial* pmat)
{
m_pMat = dynamic_cast<FEDiscreteElasticMaterial*>(pmat);
assert(m_pMat);
}
//-----------------------------------------------------------------------------
// get the total dofs
const FEDofList& FEDiscreteElasticDomain::GetDOFList() const
{
return m_dof;
}
//-----------------------------------------------------------------------------
void FEDiscreteElasticDomain::UnpackLM(FEElement &el, vector<int>& lm)
{
int N = el.Nodes();
lm.resize(N * 6);
for (int i = 0; i<N; ++i)
{
FENode& node = m_pMesh->Node(el.m_node[i]);
vector<int>& id = node.m_ID;
// first the displacement dofs
lm[3 * i] = id[m_dofU[0]];
lm[3 * i + 1] = id[m_dofU[1]];
lm[3 * i + 2] = id[m_dofU[2]];
// rigid rotational dofs
lm[3 * N + 3 * i] = id[m_dofR[0]];
lm[3 * N + 3 * i + 1] = id[m_dofR[1]];
lm[3 * N + 3 * i + 2] = id[m_dofR[2]];
}
}
//-----------------------------------------------------------------------------
void FEDiscreteElasticDomain::Activate()
{
for (int i = 0; i<Nodes(); ++i)
{
FENode& node = Node(i);
if (node.HasFlags(FENode::EXCLUDE) == false)
{
if (node.m_rid < 0)
{
node.set_active(m_dofU[0]);
node.set_active(m_dofU[1]);
node.set_active(m_dofU[2]);
}
}
}
}
//-----------------------------------------------------------------------------
void FEDiscreteElasticDomain::PreSolveUpdate(const FETimeInfo& timeInfo)
{
FEDiscreteDomain::PreSolveUpdate(timeInfo);
Update(timeInfo);
}
//-----------------------------------------------------------------------------
//! Calculates the forces due to discrete elements (i.e. springs)
void FEDiscreteElasticDomain::InternalForces(FEGlobalVector& R)
{
FEMesh& mesh = *m_pMesh;
vector<double> fe(6);
vec3d u1, u2;
vector<int> en(2), lm(6);
for (size_t i = 0; i<m_Elem.size(); ++i)
{
// get the discrete element
FEDiscreteElement& el = m_Elem[i];
if (el.isActive())
{
// get the material point data
FEMaterialPoint& mp = *el.GetMaterialPoint(0);
FEDiscreteElasticMaterialPoint& ep = *mp.ExtractData<FEDiscreteElasticMaterialPoint>();
// evaluate the force
vec3d F = ep.m_Ft;
// set up the force vector
fe[0] = F.x;
fe[1] = F.y;
fe[2] = F.z;
fe[3] = -F.x;
fe[4] = -F.y;
fe[5] = -F.z;
// setup the node vector
en[0] = el.m_node[0];
en[1] = el.m_node[1];
// set up the LM vector
UnpackLM(el, lm);
// assemble element
R.Assemble(en, lm, fe);
}
}
}
//-----------------------------------------------------------------------------
//! Calculates the discrete element stiffness
void FEDiscreteElasticDomain::StiffnessMatrix(FELinearSystem& LS)
{
FEMesh& mesh = *m_pMesh;
FEElementMatrix ke;
ke.resize(6, 6);
ke.zero();
vector<int> en(2), lm(6);
// loop over all discrete elements
for (size_t i = 0; i<m_Elem.size(); ++i)
{
// get the discrete element
FEDiscreteElement& el = m_Elem[i];
if (el.isActive())
{
// get the material point data
FEDiscreteMaterialPoint& mp = *el.GetMaterialPoint(0)->ExtractData<FEDiscreteMaterialPoint>();
// evaluate the stiffness
mat3d A = m_pMat->Stiffness(mp);
ke.zero();
ke.add(0, 0, A); ke.add(0, 3, -A);
ke.add(3, 0, -A); ke.add(3, 3, A);
// setup the node vector
en[0] = el.m_node[0];
en[1] = el.m_node[1];
// set up the LM vector
UnpackLM(el, lm);
// assemble the element into the global system
ke.SetNodes(en);
ke.SetIndices(lm);
LS.Assemble(ke);
}
}
}
bool FEDiscreteElasticDomain::Init()
{
if (FEDiscreteDomain::Init() == false) return false;
FETimeInfo& tp = GetFEModel()->GetTime();
Update(tp);
return true;
}
//! update domain data
void FEDiscreteElasticDomain::Update(const FETimeInfo& tp)
{
FEMesh& mesh = *m_pMesh;
double dt = tp.timeIncrement;
// loop over all discrete elements
for (size_t i = 0; i < m_Elem.size(); ++i)
{
// get the discrete element
FEDiscreteElement& el = m_Elem[i];
// only process active springs
if (el.isActive())
{
// get the material point data
FEDiscreteElasticMaterialPoint& mp = *el.GetMaterialPoint(0)->ExtractData<FEDiscreteElasticMaterialPoint>();
// get the nodes of the element
FENode& n1 = mesh.Node(el.m_node[0]);
FENode& n2 = mesh.Node(el.m_node[1]);
// get the nodal positions
vec3d& rt1 = n1.m_rt;
vec3d& rt2 = n2.m_rt;
// get the previous nodal positions
vec3d rp1 = n1.m_rp;
vec3d rp2 = n2.m_rp;
// get the initial nodal positions
vec3d ri1 = n1.m_r0;
vec3d ri2 = n2.m_r0;
mp.m_drt = rt2 - rt1;
mp.m_drp = rp2 - rp1;
mp.m_dr0 = ri2 - ri1;
mp.m_dvt = (mp.m_drt - mp.m_drp) / dt;
// evaluate the force
mp.m_Ft = m_pMat->Force(mp);
}
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidNodeSet.h | .h | 1,988 | 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) 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/FENodalBC.h>
#include "febiomech_api.h"
class FENodeSet;
//-----------------------------------------------------------------------------
//! rigid node set
class FEBIOMECH_API FERigidNodeSet : public FENodalBC
{
public:
FERigidNodeSet(FEModel* pfem);
bool Init() override;
void Serialize(DumpStream& ar) override;
void Activate() override;
void Deactivate() override;
void SetRigidMaterialID(int rid);
// copy data from another class
void CopyFrom(FEBoundaryCondition* pbc) override;
private: // parameters
int m_rigidMat; //!< rigid body's material
bool m_bshellBC; //!< flag defining how shells are attached (0=hinged, 1=clamped)
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFixedRotation.h | .h | 1,480 | 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.*/
#pragma once
#include <FECore/FEFixedBC.h>
class FEFixedRotation : public FEFixedBC
{
public:
FEFixedRotation(FEModel* fem);
bool Init() override;
private:
bool m_dof[3];
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEPrescribedActiveContractionIsotropicUC.h | .h | 1,946 | 52 | /*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 a solid mixture material.
class FEPrescribedActiveContractionIsotropicUC : public FEUncoupledMaterial
{
public:
//! constructor
FEPrescribedActiveContractionIsotropicUC(FEModel* pfem);
//! stress
mat3ds DevStress(FEMaterialPoint& pt) override;
//! tangent
tens4ds DevTangent(FEMaterialPoint& pt) override;
public:
FEParamDouble m_T0; // prescribed active stress
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberCDFUncoupled.h | .h | 2,814 | 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) 2023 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticFiberMaterialUC.h"
#include "FEFiberMaterial.h"
#include "FEDamageCDF.h"
class FEElasticFiberCDFUncoupled;
//-----------------------------------------------------------------------------
//! Material class for single fiber, tension only
//! Cumulative distribution
class FEFiberCDFUncoupled : public FEFiberMaterialUncoupled
{
public:
FEFiberCDFUncoupled(FEModel* pfem);
//! Cauchy stress
mat3ds DevFiberStress(FEMaterialPoint& mp, const vec3d& a0) override;
// Spatial tangent
tens4ds DevFiberTangent(FEMaterialPoint& mp, const vec3d& a0) override;
//! Strain energy density
double DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) override;
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
//! Perform integration
void Integrate(FEMaterialPoint& mp, const double In_1);
protected:
FEParamDouble m_E; // fiber modulus
double m_epsf;
FEDamageCDF* m_CDF;
// declare the parameter list
DECLARE_FECORE_CLASS();
friend class FEElasticFiberCDFUncoupled;
};
//-----------------------------------------------------------------------------
class FEElasticFiberCDFUncoupled : public FEElasticFiberMaterialUC_T<FEFiberCDFUncoupled>
{
public:
FEElasticFiberCDFUncoupled(FEModel* fem) : FEElasticFiberMaterialUC_T<FEFiberCDFUncoupled>(fem) {}
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEElasticSolidDomain.cpp | .cpp | 23,082 | 785 | /*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 "FEElasticSolidDomain.h"
#include "FEElasticMaterial.h"
#include "FEBodyForce.h"
#include "FECore/log.h"
#include <FECore/FEModel.h>
#include <FECore/FEAnalysis.h>
#include <FECore/sys.h>
#include "FEBioMech.h"
#include <FECore/FELinearSystem.h>
#include "FEResidualVector.h"
//-----------------------------------------------------------------------------
//! constructor
//! Some derived classes will pass 0 to the pmat, since the pmat variable will be
//! to initialize another material. These derived classes will set the m_pMat variable as well.
FEElasticSolidDomain::FEElasticSolidDomain(FEModel* pfem) : FESolidDomain(pfem), FEElasticDomain(pfem), m_dofU(pfem), m_dofR(pfem), m_dofSU(pfem), m_dofV(pfem), m_dofSV(pfem), m_dofSA(pfem), m_dof(pfem)
{
m_pMat = 0;
m_alphaf = m_beta = 1;
m_alpham = 2;
m_update_dynamic = true; // default for backward compatibility
m_secant_stress = false;
m_secant_tangent = false;
// TODO: Can this be done in Init, since there is no error checking
if (pfem)
{
m_dofU.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
m_dofR.AddVariable(FEBioMech::GetVariableName(FEBioMech::RIGID_ROTATION));
m_dofSU.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_DISPLACEMENT));
m_dofV.AddVariable(FEBioMech::GetVariableName(FEBioMech::VELOCITY));
m_dofSV.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_VELOCITY));
m_dofSA.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_ACCELERATION));
}
}
//-----------------------------------------------------------------------------
// get the total dof list
const FEDofList& FEElasticSolidDomain::GetDOFList() const
{
return m_dof;
}
//-----------------------------------------------------------------------------
// \todo I don't think this is being used
FEElasticSolidDomain& FEElasticSolidDomain::operator = (FEElasticSolidDomain& d)
{
m_Elem = d.m_Elem;
m_pMesh = d.m_pMesh;
return (*this);
}
//-----------------------------------------------------------------------------
//! Set flag for update for dynamic quantities
void FEElasticSolidDomain::SetDynamicUpdateFlag(bool b)
{
m_update_dynamic = b;
}
//-----------------------------------------------------------------------------
//! Assign material
void FEElasticSolidDomain::SetMaterial(FEMaterial* pmat)
{
FEDomain::SetMaterial(pmat);
if (pmat)
{
m_pMat = dynamic_cast<FESolidMaterial*>(pmat);
assert(m_pMat);
}
else m_pMat = 0;
}
//-----------------------------------------------------------------------------
void FEElasticSolidDomain::Activate()
{
for (int i=0; i<Nodes(); ++i)
{
FENode& node = Node(i);
if (node.HasFlags(FENode::EXCLUDE) == false)
{
if (node.m_rid < 0)
{
node.set_active(m_dofU[0]);
node.set_active(m_dofU[1]);
node.set_active(m_dofU[2]);
}
}
}
}
//-----------------------------------------------------------------------------
//! serialization
void FEElasticSolidDomain::Serialize(DumpStream& ar)
{
//erialize the base class, which instantiates the elements
FESolidDomain::Serialize(ar);
if (ar.IsShallow()) return;
// serialize class variables
ar & m_alphaf;
ar & m_alpham;
ar & m_beta;
ar & m_update_dynamic;
}
//-----------------------------------------------------------------------------
//! Initialize element data
void FEElasticSolidDomain::PreSolveUpdate(const FETimeInfo& timeInfo)
{
m_alphaf = timeInfo.alphaf;
m_alpham = timeInfo.alpham;
m_beta = timeInfo.beta;
#pragma omp parallel for
for (int i=0; i<Elements(); ++i)
{
FESolidElement& el = m_Elem[i];
if (el.isActive())
{
int n = el.GaussPoints();
for (int j = 0; j < n; ++j)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(j);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
pt.m_Wp = pt.m_Wt;
mp.Update(timeInfo);
}
}
}
}
//-----------------------------------------------------------------------------
void FEElasticSolidDomain::InternalForces(FEGlobalVector& R)
{
int NE = Elements();
#pragma omp parallel for shared (NE)
for (int i=0; i<NE; ++i)
{
// get the element
FESolidElement& el = m_Elem[i];
if (el.isActive()) {
// element force vector
vector<double> fe;
vector<int> lm;
// get the element force vector and initialize it to zero
int ndof = 3 * el.Nodes();
fe.assign(ndof, 0);
// calculate internal force vector
ElementInternalForce(el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble element 'fe'-vector into global R vector
R.Assemble(el.m_node, lm, fe);
}
}
}
//-----------------------------------------------------------------------------
//! calculates the internal equivalent nodal forces for solid elements
void FEElasticSolidDomain::ElementInternalForce(FESolidElement& el, vector<double>& fe)
{
// jacobian matrix, inverse jacobian matrix and determinants
double Ji[3][3];
int nint = el.GaussPoints();
int neln = el.Nodes();
double* gw = el.GaussWeights();
// repeat for all integration points
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// calculate the jacobian
double detJt = (m_update_dynamic ? invjact(el, Ji, n, m_alphaf) : invjact(el, Ji, n));
detJt *= gw[n];
// get the stress vector for this integration point
const mat3ds& s = pt.m_s;
const double* Gr = el.Gr(n);
const double* Gs = el.Gs(n);
const double* Gt = el.Gt(n);
for (int i=0; i<neln; ++i)
{
// calculate global gradient of shape functions
// note that we need the transposed of Ji, not Ji itself !
double Gx = Ji[0][0]*Gr[i]+Ji[1][0]*Gs[i]+Ji[2][0]*Gt[i];
double Gy = Ji[0][1]*Gr[i]+Ji[1][1]*Gs[i]+Ji[2][1]*Gt[i];
double Gz = Ji[0][2]*Gr[i]+Ji[1][2]*Gs[i]+Ji[2][2]*Gt[i];
// calculate internal force
// the '-' sign is so that the internal forces get subtracted
// from the global residual vector
fe[3*i ] -= ( Gx*s.xx() +
Gy*s.xy() +
Gz*s.xz() )*detJt;
fe[3*i+1] -= ( Gy*s.yy() +
Gx*s.xy() +
Gz*s.yz() )*detJt;
fe[3*i+2] -= ( Gz*s.zz() +
Gy*s.yz() +
Gx*s.xz() )*detJt;
}
}
}
//-----------------------------------------------------------------------------
void FEElasticSolidDomain::BodyForce(FEGlobalVector& R, FEBodyForce& BF)
{
// define some parameters that will be passed to lambda
FEBodyForce* bodyForce = &BF;
// TODO: a remaining issue here is that dofU does not consider the shell displacement
// dofs for interface nodes (see UnpackLM). Is that an issue?
// 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;
});
}
//-----------------------------------------------------------------------------
//! calculates element's geometrical stiffness component for integration point n
void FEElasticSolidDomain::ElementGeometricalStiffness(FESolidElement &el, matrix &ke)
{
// spatial derivatives of shape functions
vec3d G[FEElement::MAX_NODES];
// weights at gauss points
const double *gw = el.GaussWeights();
// calculate geometrical element stiffness matrix
int neln = el.Nodes();
int nint = el.GaussPoints();
for (int n = 0; n<nint; ++n)
{
// calculate shape function gradients and jacobian
double w = ShapeGradient(el, n, G, m_alphaf)*gw[n]*m_alphaf;
// get the material point data
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// element's Cauchy-stress tensor at gauss point n
mat3ds& s = pt.m_s;
for (int i = 0; i<neln; ++i)
for (int j = 0; j<neln; ++j)
{
double kab = (G[i]*(s * G[j]))*w;
ke[3*i ][3*j ] += kab;
ke[3*i+1][3*j+1] += kab;
ke[3*i+2][3*j+2] += kab;
}
}
}
//-----------------------------------------------------------------------------
//! Calculates element material stiffness element matrix
void FEElasticSolidDomain::ElementMaterialStiffness(FESolidElement &el, matrix &ke)
{
// Get the current element's data
const int nint = el.GaussPoints();
const int neln = el.Nodes();
// global derivatives of shape functions
vec3d G[FEElement::MAX_NODES];
double Gxi, Gyi, Gzi;
double Gxj, Gyj, Gzj;
// The 'D' matrix
double D[6][6] = {0}; // The 'D' matrix
// The 'D*BL' matrix
double DBL[6][3];
// jacobian
double detJt;
// weights at gauss points
const double *gw = el.GaussWeights();
// calculate element stiffness matrix
for (int n=0; n<nint; ++n)
{
// calculate jacobian and shape function gradients
detJt = ShapeGradient(el, n, G, m_alphaf)*gw[n]*m_alphaf;
// setup the material point
// NOTE: deformation gradient and determinant have already been evaluated in the stress routine
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
// get the 'D' matrix
// tens4ds C = m_pMat->Tangent(mp);
tens4dmm C = (m_secant_tangent ? m_pMat->SecantTangent(mp) : m_pMat->SolidTangent(mp));
C.extract(D);
// we only calculate the upper triangular part
// since ke is symmetric. The other part is
// determined below using this symmetry.
for (int i=0, i3=0; i<neln; ++i, i3 += 3)
{
Gxi = G[i].x;
Gyi = G[i].y;
Gzi = G[i].z;
for (int j=0, j3 = 0; j<neln; ++j, j3 += 3)
{
Gxj = G[j].x;
Gyj = G[j].y;
Gzj = G[j].z;
// calculate D*BL matrices
DBL[0][0] = (D[0][0]*Gxj+D[0][3]*Gyj+D[0][5]*Gzj);
DBL[0][1] = (D[0][1]*Gyj+D[0][3]*Gxj+D[0][4]*Gzj);
DBL[0][2] = (D[0][2]*Gzj+D[0][4]*Gyj+D[0][5]*Gxj);
DBL[1][0] = (D[1][0]*Gxj+D[1][3]*Gyj+D[1][5]*Gzj);
DBL[1][1] = (D[1][1]*Gyj+D[1][3]*Gxj+D[1][4]*Gzj);
DBL[1][2] = (D[1][2]*Gzj+D[1][4]*Gyj+D[1][5]*Gxj);
DBL[2][0] = (D[2][0]*Gxj+D[2][3]*Gyj+D[2][5]*Gzj);
DBL[2][1] = (D[2][1]*Gyj+D[2][3]*Gxj+D[2][4]*Gzj);
DBL[2][2] = (D[2][2]*Gzj+D[2][4]*Gyj+D[2][5]*Gxj);
DBL[3][0] = (D[3][0]*Gxj+D[3][3]*Gyj+D[3][5]*Gzj);
DBL[3][1] = (D[3][1]*Gyj+D[3][3]*Gxj+D[3][4]*Gzj);
DBL[3][2] = (D[3][2]*Gzj+D[3][4]*Gyj+D[3][5]*Gxj);
DBL[4][0] = (D[4][0]*Gxj+D[4][3]*Gyj+D[4][5]*Gzj);
DBL[4][1] = (D[4][1]*Gyj+D[4][3]*Gxj+D[4][4]*Gzj);
DBL[4][2] = (D[4][2]*Gzj+D[4][4]*Gyj+D[4][5]*Gxj);
DBL[5][0] = (D[5][0]*Gxj+D[5][3]*Gyj+D[5][5]*Gzj);
DBL[5][1] = (D[5][1]*Gyj+D[5][3]*Gxj+D[5][4]*Gzj);
DBL[5][2] = (D[5][2]*Gzj+D[5][4]*Gyj+D[5][5]*Gxj);
ke[i3 ][j3 ] += (Gxi*DBL[0][0] + Gyi*DBL[3][0] + Gzi*DBL[5][0] )*detJt;
ke[i3 ][j3+1] += (Gxi*DBL[0][1] + Gyi*DBL[3][1] + Gzi*DBL[5][1] )*detJt;
ke[i3 ][j3+2] += (Gxi*DBL[0][2] + Gyi*DBL[3][2] + Gzi*DBL[5][2] )*detJt;
ke[i3+1][j3 ] += (Gyi*DBL[1][0] + Gxi*DBL[3][0] + Gzi*DBL[4][0] )*detJt;
ke[i3+1][j3+1] += (Gyi*DBL[1][1] + Gxi*DBL[3][1] + Gzi*DBL[4][1] )*detJt;
ke[i3+1][j3+2] += (Gyi*DBL[1][2] + Gxi*DBL[3][2] + Gzi*DBL[4][2] )*detJt;
ke[i3+2][j3 ] += (Gzi*DBL[2][0] + Gyi*DBL[4][0] + Gxi*DBL[5][0] )*detJt;
ke[i3+2][j3+1] += (Gzi*DBL[2][1] + Gyi*DBL[4][1] + Gxi*DBL[5][1] )*detJt;
ke[i3+2][j3+2] += (Gzi*DBL[2][2] + Gyi*DBL[4][2] + Gxi*DBL[5][2] )*detJt;
}
}
}
}
//-----------------------------------------------------------------------------
void FEElasticSolidDomain::StiffnessMatrix(FELinearSystem& LS)
{
// repeat over all solid elements
int NE = Elements();
#pragma omp parallel for shared (NE)
for (int iel=0; iel<NE; ++iel)
{
FESolidElement& el = m_Elem[iel];
if (el.isActive()) {
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
// element stiffness matrix
FEElementMatrix ke(el, lm);
// create the element's stiffness matrix
int ndof = 3 * el.Nodes();
ke.resize(ndof, ndof);
ke.zero();
// calculate geometrical stiffness
ElementGeometricalStiffness(el, ke);
// calculate material stiffness
ElementMaterialStiffness(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];
*/
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
}
//-----------------------------------------------------------------------------
void FEElasticSolidDomain::MassMatrix(FELinearSystem& LS, double scale)
{
// TODO: a remaining issue here is that dofU does not consider the shell displacement
// dofs for interface nodes (see UnpackLM). Is that an issue?
// evaluate body force stiffness
LoadStiffness(LS, m_dofU, m_dofU, [=](FEMaterialPoint& mp, int node_a, int node_b, matrix& Kab) {
// density
double density = m_pMat->Density(mp);
// shape functions
double* H = mp.m_shape;
// Jacobian
double J0 = mp.m_J0;
// mass
double kab = scale *density*H[node_a] * H[node_b] * J0;
Kab.zero();
Kab[0][0] = kab;
Kab[1][1] = kab;
Kab[2][2] = kab;
});
}
//-----------------------------------------------------------------------------
void FEElasticSolidDomain::BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf)
{
// define some parameters that will be passed to lambda
FESolidMaterial* mat = m_pMat;
FEBodyForce* bodyForce = &bf;
// TODO: a remaining issue here is that dofU does not consider the shell displacement
// dofs for interface nodes (see UnpackLM). Is that an issue?
// evaluate body force stiffness
LoadStiffness(LS, m_dofU, m_dofU, [=](FEMaterialPoint& mp, int node_a, int node_b, matrix& Kab) {
// loop over integration points
double detJ = mp.m_J0 * m_alphaf;
// density
double dens_n = mat->Density(mp);
// get the stiffness
mat3d K = bodyForce->stiffness(mp);
// shape functions
double* H = mp.m_shape;
// put it together
Kab = K*(-H[node_a] * H[node_b] * dens_n*detJ);
});
}
//-----------------------------------------------------------------------------
//! This function calculates the element stiffness matrix. It calls the material
//! stiffness function, the geometrical stiffness function and, if necessary, the
//! dilatational stiffness function. Note that these three functions only calculate
//! the upper diagonal matrix due to the symmetry of the element stiffness matrix
//! The last section of this function fills the rest of the element stiffness matrix.
void FEElasticSolidDomain::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);
// 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();
int i, j;
for (i=0; i<ndof; ++i)
for (j=i+1; j<ndof; ++j)
ke[j][i] = ke[i][j];
}
//-----------------------------------------------------------------------------
void FEElasticSolidDomain::Update(const FETimeInfo& tp)
{
bool berr = false;
int NE = Elements();
#pragma omp parallel for shared(NE, berr)
for (int i=0; i<NE; ++i)
{
try
{
FESolidElement& el = Element(i);
if (el.isActive())
{
UpdateElementStress(i, tp);
}
}
catch (NegativeJacobian e)
{
#pragma omp critical
{
// reset the logfile mode
berr = true;
if (e.DoOutput()) feLogError(e.what());
}
}
}
if (berr) throw NegativeJacobianDetected();
}
//-----------------------------------------------------------------------------
//! Update element state data (mostly stresses, but some other stuff as well)
//! \todo Remove the remodeling solid stuff
void FEElasticSolidDomain::UpdateElementStress(int iel, const FETimeInfo& tp)
{
double dt =tp.timeIncrement;
// get the solid element
FESolidElement& el = m_Elem[iel];
// get the number of integration points
int nint = el.GaussPoints();
// number of nodes
int neln = el.Nodes();
// nodal coordinates
const int NELN = FEElement::MAX_NODES;
vec3d r[NELN], v[NELN], a[NELN];
GetCurrentNodalCoordinates(el, r, m_alphaf);
// update dynamic quantities
if (m_update_dynamic)
{
for (int j = 0; j<neln; ++j)
{
FENode& node = m_pMesh->Node(el.m_node[j]);
v[j] = node.get_vec3d(m_dofV[0], m_dofV[1], m_dofV[2])*m_alphaf + node.m_vp*(1 - m_alphaf);
a[j] = node.m_at*m_alpham + node.m_ap*(1 - m_alpham);
}
}
// loop over the integration points and calculate
// the stress at the integration point
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// material point coordinates
mp.m_rt = el.Evaluate(r, n);
// get the deformation gradient and determinant at intermediate time
double Jt;
mat3d Ft, Fp;
Jt = defgrad(el, Ft, n);
defgradp(el, Fp, n);
if (m_alphaf == 1.0)
{
pt.m_F = Ft;
pt.m_J = Jt;
}
else
{
pt.m_F = Ft*m_alphaf + Fp*(1-m_alphaf);
pt.m_J = pt.m_F.det();
}
mat3d Fi = pt.m_F.inverse();
pt.m_L = (Ft - Fp)*Fi / dt;
if (m_update_dynamic)
{
pt.m_v = el.Evaluate(v, n);
pt.m_a = el.Evaluate(a, n);
}
// update specialized material points
m_pMat->UpdateSpecializedMaterialPoints(mp, tp);
// calculate the stress at this material point
// pt.m_s = m_pMat->Stress(mp);
pt.m_s = (m_secant_stress ? m_pMat->SecantStress(mp) : m_pMat->Stress(mp));
// adjust stress for strain energy conservation
// (Apply only for mid-point rule)
if (m_alphaf == 0.5)
{
FEElasticMaterial* pme = dynamic_cast<FEElasticMaterial*>(m_pMat);
// evaluate strain energy at current time
mat3d Ftmp = pt.m_F;
double Jtmp = pt.m_J;
pt.m_F = Ft;
pt.m_J = Jt;
pt.m_Wt = pme->StrainEnergyDensity(mp);
pt.m_F = Ftmp;
pt.m_J = Jtmp;
mat3ds D = pt.RateOfDeformation();
double D2 = D.dotdot(D);
if (D2 > std::numeric_limits<double>::epsilon())
{
pt.m_s += D * (((pt.m_Wt - pt.m_Wp) / (dt * pt.m_J) - pt.m_s.dotdot(D)) / D2);
}
}
}
}
//-----------------------------------------------------------------------------
//! Unpack the element LM data.
void FEElasticSolidDomain::UnpackLM(FEElement& el, vector<int>& lm)
{
int N = el.Nodes();
lm.resize(N*6);
for (int i=0; i<N; ++i)
{
FENode& node = m_pMesh->Node(el.m_node[i]);
vector<int>& id = node.m_ID;
// first the displacement dofs
lm[3*i ] = id[m_dofU[0]];
lm[3*i+1] = id[m_dofU[1]];
lm[3*i+2] = id[m_dofU[2]];
// rigid rotational dofs
lm[3*N + 3*i ] = id[m_dofR[0]];
lm[3*N + 3*i+1] = id[m_dofR[1]];
lm[3*N + 3*i+2] = id[m_dofR[2]];
}
// substitute interface dofs for solid-shell interfaces
FESolidElement& sel = static_cast<FESolidElement&>(el);
for (int i = 0; i<sel.m_bitfc.size(); ++i)
{
if (sel.m_bitfc[i]) {
FENode& node = m_pMesh->Node(el.m_node[i]);
vector<int>& id = node.m_ID;
// first the displacement dofs
lm[3*i ] = id[m_dofSU[0]];
lm[3*i+1] = id[m_dofSU[1]];
lm[3*i+2] = id[m_dofSU[2]];
}
}
}
//-----------------------------------------------------------------------------
// Calculate inertial forces \todo Why is F no longer needed?
void FEElasticSolidDomain::InertialForces(FEGlobalVector& R, vector<double>& F)
{
int NE = Elements();
#pragma omp parallel for shared(R, F)
for (int i=0; i<NE; ++i)
{
// get the element
FESolidElement& el = m_Elem[i];
if (el.isActive()) {
// element force vector
vector<double> fe;
vector<int> lm;
// get the element force vector and initialize it to zero
int ndof = 3 * el.Nodes();
fe.assign(ndof, 0);
// calculate internal force vector
ElementInertialForce(el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble element 'fe'-vector into global R vector
R.Assemble(el.m_node, lm, fe);
}
}
}
//-----------------------------------------------------------------------------
void FEElasticSolidDomain::ElementInertialForce(FESolidElement& el, vector<double>& fe)
{
int nint = el.GaussPoints();
int neln = el.Nodes();
double* gw = el.GaussWeights();
// repeat for all integration points
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
double dens = m_pMat->Density(mp);
double J0 = detJ0(el, n)*gw[n];
double* H = el.H(n);
for (int i=0; i<neln; ++i)
{
double tmp = H[i]*J0*dens;
fe[3*i ] -= tmp*pt.m_a.x;
fe[3*i+1] -= tmp*pt.m_a.y;
fe[3*i+2] -= tmp*pt.m_a.z;
}
}
}
//=================================================================================================
BEGIN_FECORE_CLASS(FEStandardElasticSolidDomain, FEElasticSolidDomain)
ADD_PARAMETER(m_elemType, "elem_type", FE_PARAM_ATTRIBUTE, "$(solid_element)\0");
ADD_PARAMETER(m_secant_stress, "secant_stress");
ADD_PARAMETER(m_secant_tangent, "secant_tangent");
END_FECORE_CLASS();
FEStandardElasticSolidDomain::FEStandardElasticSolidDomain(FEModel* fem) : FEElasticSolidDomain(fem)
{
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidCylindricalJoint.cpp | .cpp | 30,600 | 980 | /*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 "FERigidCylindricalJoint.h"
#include "FERigidBody.h"
#include "FECore/log.h"
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidCylindricalJoint, 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_e0[0], "joint_axis" );
ADD_PARAMETER(m_e0[1], "transverse_axis");
ADD_PARAMETER(m_naugmin, "minaug" );
ADD_PARAMETER(m_naugmax, "maxaug" );
ADD_PARAMETER(m_bd , "prescribed_translation");
ADD_PARAMETER(m_dp , "translation" );
ADD_PARAMETER(m_Fp , "force" );
ADD_PARAMETER(m_bq , "prescribed_rotation");
ADD_PARAMETER(m_qp , "rotation" );
ADD_PARAMETER(m_Mp , "moment" );
ADD_PARAMETER(m_bautopen, "auto_penalty");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//FERigidCylindricalJoint::FERigidCylindricalJoint(FEModel* pfem) : FENLConstraint(pfem)
FERigidCylindricalJoint::FERigidCylindricalJoint(FEModel* pfem) : FERigidConnector(pfem)
{
m_nID = m_ncount++;
m_atol = 0;
m_gtol = 0;
m_qtol = 0;
m_naugmin = 0;
m_naugmax = 10;
m_dp = 0;
m_Fp = 0;
m_bd = false;
m_qp = 0;
m_Mp = 0;
m_bq = false;
m_bautopen = false;
m_laugon = FECore::AUGLAG_METHOD; // default to augmented Lagrangian
m_eps = m_ups = 1.0;
m_F = vec3d(0, 0, 0);
m_Lp = vec3d(0, 0, 0);
m_u = m_up = 0;
}
//-----------------------------------------------------------------------------
FERigidCylindricalJoint::~FERigidCylindricalJoint()
{
}
//-----------------------------------------------------------------------------
//! initial position
vec3d FERigidCylindricalJoint::InitialPosition() const
{
return m_q0;
}
//-----------------------------------------------------------------------------
//! current position
vec3d FERigidCylindricalJoint::Position() const
{
FERigidBody& RBa = *m_rbA;
vec3d qa = m_qa0;
RBa.GetRotation().RotateVector(qa);
return RBa.m_rt + qa;
}
//-----------------------------------------------------------------------------
//! orientation
quatd FERigidCylindricalJoint::Orientation() const
{
quatd Q0(vec3d(0, 0, 1), m_e0[0]);
FERigidBody& RBa = *m_rbA;
return RBa.GetRotation()*Q0;
}
//-----------------------------------------------------------------------------
//! TODO: This function is called twice: once in the Init and once in the Solve
//! phase. Is that necessary?
bool FERigidCylindricalJoint::Init()
{
if (m_bd && (m_Fp != 0)) {
feLogError("Translation and force cannot be prescribed simultaneously in rigid connector %d (cylindrical joint)\n", m_nID+1);
return false;
}
if (m_bq && (m_Mp != 0)) {
feLogError("Rotation and moment cannot be prescribed simultaneously in rigid connector %d (cylindrical joint)\n", m_nID+1);
return false;
}
// initialize joint basis
m_e0[0].unit();
m_e0[2] = m_e0[0] ^ m_e0[1]; m_e0[2].unit();
m_e0[1] = m_e0[2] ^ m_e0[0]; m_e0[1].unit();
// reset force
m_F = vec3d(0,0,0); m_L = 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_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;
}
//-----------------------------------------------------------------------------
int FERigidCylindricalJoint::InitEquations(int neq)
{
m_EQ.resize(4, -1);
if (m_laugon == FECore::LAGMULT_METHOD)
{
// we allocate three equations
m_EQ[0] = neq;
m_EQ[1] = neq + 1;
m_EQ[2] = neq + 2;
m_EQ[3] = neq + 3;
return 4;
}
else return 0;
}
//-----------------------------------------------------------------------------
// Build the matrix profile
void FERigidCylindricalJoint::BuildMatrixProfile(FEGlobalMatrix& M)
{
vector<int> lm;
UnpackLM(lm);
// add it to the pile
M.build_add(lm);
}
void FERigidCylindricalJoint::PrepStep()
{
m_Lp = m_F;
m_up = m_u;
}
void FERigidCylindricalJoint::Update(const std::vector<double>& Ui, const std::vector<double>& ui)
{
if (m_laugon == FECore::LAGMULT_METHOD)
{
m_F.x = m_Lp.x + Ui[m_EQ[0]] + ui[m_EQ[0]];
m_F.y = m_Lp.y + Ui[m_EQ[1]] + ui[m_EQ[1]];
m_F.z = m_Lp.z + Ui[m_EQ[2]] + ui[m_EQ[2]];
m_u = m_up + Ui[m_EQ[3]] + ui[m_EQ[3]];
}
}
void FERigidCylindricalJoint::UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui)
{
if (m_laugon == FECore::LAGMULT_METHOD)
{
Ui[m_EQ[0]] += ui[m_EQ[0]];
Ui[m_EQ[1]] += ui[m_EQ[1]];
Ui[m_EQ[2]] += ui[m_EQ[2]];
Ui[m_EQ[3]] += ui[m_EQ[3]];
}
}
//-----------------------------------------------------------------------------
void FERigidCylindricalJoint::UnpackLM(vector<int>& lm)
{
// add the dofs of rigid body A
lm.reserve(16);
lm.push_back(m_rbA->m_LM[0]);
lm.push_back(m_rbA->m_LM[1]);
lm.push_back(m_rbA->m_LM[2]);
lm.push_back(m_rbA->m_LM[3]);
lm.push_back(m_rbA->m_LM[4]);
lm.push_back(m_rbA->m_LM[5]);
// add the dofs of rigid body B
lm.push_back(m_rbB->m_LM[0]);
lm.push_back(m_rbB->m_LM[1]);
lm.push_back(m_rbB->m_LM[2]);
lm.push_back(m_rbB->m_LM[3]);
lm.push_back(m_rbB->m_LM[4]);
lm.push_back(m_rbB->m_LM[5]);
// add the LM equations
if (m_laugon == FECore::LAGMULT_METHOD)
{
lm.push_back(m_EQ[0]);
lm.push_back(m_EQ[1]);
lm.push_back(m_EQ[2]);
lm.push_back(m_EQ[3]);
}
}
//-----------------------------------------------------------------------------
void FERigidCylindricalJoint::Serialize(DumpStream& ar)
{
FERigidConnector::Serialize(ar);
ar & m_qa0 & m_qb0;
ar & m_L & m_U;
ar & m_e0;
ar & m_ea0;
ar & m_eb0;
ar & m_F & m_u;
ar & m_Lp & m_up;
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidCylindricalJoint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
if (m_laugon != FECore::LAGMULT_METHOD)
{
// --- Penalty / Augmented Lagrangian ---
vector<double> fa(6);
vector<double> fb(6);
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
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);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0] * alpha + eap[0] * (1 - alpha);
ea[1] = eat[1] * alpha + eap[1] * (1 - alpha);
ea[2] = eat[2] * alpha + eap[2] * (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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0] * alpha + ebp[0] * (1 - alpha);
eb[1] = ebt[1] * alpha + ebp[1] * (1 - alpha);
eb[2] = ebt[2] * alpha + ebp[2] * (1 - alpha);
mat3ds P = m_bd ? mat3dd(1) : mat3dd(1) - dyad(ea[0]);
vec3d p = m_bd ? ea[0] * m_dp : vec3d(0, 0, 0);
vec3d c = P*(rb + zb - ra - za) - p;
m_F = m_L + c*m_eps + ea[0] * m_Fp;
vec3d ksi;
if (m_bq) {
quatd q = (alpha*RBb.GetRotation() + (1 - alpha)*RBb.m_qp)*(alpha*RBa.GetRotation() + (1 - alpha)*RBa.m_qp).Inverse();
quatd a(m_qp, ea[0]);
quatd r = a*q.Inverse();
r.MakeUnit();
ksi = r.GetVector()*r.GetAngle();
}
else
ksi = (ea[0] ^ eb[0]) / 2;
m_M = m_U + ksi*m_ups + ea[0] * m_Mp;
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];
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]);
}
else
{
// --- Lagrange Multipliers ---
vector<double> fe(16);
// current values of Lagrange multipliers
vec3d Lm = m_F; // lagrange multiplier
double mu = m_u;
// rigid body positions
vec3d ra = RBa.m_rt;
vec3d rb = RBb.m_rt;
// rigid body rotations
quatd Qa = RBa.GetRotation();
quatd Qb = RBb.GetRotation();
// current joint offset
vec3d qa = Qa*m_qa0;
vec3d qb = Qb*m_qb0;
// "gap" vector
vec3d g = ra + qa - rb - qb;
// current joint axis
vec3d n0 = m_e0[0];
vec3d ea = Qa*n0;
vec3d eb = Qb*n0;
mat3d N;
N[0][0] = 0; N[0][1] = n0.z; N[0][2] = -n0.y;
N[1][0] = -n0.z; N[1][1] = 0; N[1][2] = n0.x;
N[2][0] = n0.y; N[2][1] = -n0.x; N[2][2] = 0;
mat3d NT = N.transpose();
// projection matrix
mat3d Pa = mat3dd(1.0) - dyad(ea);
// setup skew matrices
mat3d ya;
ya[0][0] = 0; ya[0][1] = qa.z; ya[0][2] = -qa.y;
ya[1][0] = -qa.z; ya[1][1] = 0; ya[1][2] = qa.x;
ya[2][0] = qa.y; ya[2][1] = -qa.x; ya[2][2] = 0;
mat3d yaT = ya.transpose();
mat3d yb;
yb[0][0] = 0; yb[0][1] = qb.z; yb[0][2] = -qb.y;
yb[1][0] = -qb.z; yb[1][1] = 0; yb[1][2] = qb.x;
yb[2][0] = qb.y; yb[2][1] = -qb.x; yb[2][2] = 0;
mat3d ybT = yb.transpose();
mat3d GaT = mat3dd(ea*g) + (g & ea);
// net force
vec3d F = Pa*Lm;
// net moment on A
vec3d Ma = yaT*Pa*Lm - NT*GaT*Lm + NT*eb*mu;
// net moment on B
vec3d Mb = -ybT*Pa*Lm + NT*(ea*mu);
// body A
fe[ 0] = -F.x;
fe[ 1] = -F.y;
fe[ 2] = -F.z;
fe[ 3] = -Ma.x;
fe[ 4] = -Ma.y;
fe[ 5] = -Ma.z;
// body B
fe[ 6] = +F.x;
fe[ 7] = +F.y;
fe[ 8] = +F.z;
fe[ 9] = -Mb.x;
fe[10] = -Mb.y;
fe[11] = -Mb.z;
// constraints
vec3d c = Pa*g;
fe[12] = -c.x;
fe[13] = -c.y;
fe[14] = -c.z;
fe[15] = 1.0 - ea*eb;
// get the equation numbers
vector<int> LM;
UnpackLM(LM);
// assemble it all
R.Assemble(LM, fe);
}
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidCylindricalJoint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
if (m_laugon != FECore::LAGMULT_METHOD)
{
double alpha = tp.alphaf;
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
vector<int> LM(12);
FEElementMatrix ke; ke.resize(12, 12);
ke.zero();
// 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);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0] * alpha + eap[0] * (1 - alpha);
ea[1] = eat[1] * alpha + eap[1] * (1 - alpha);
ea[2] = eat[2] * alpha + eap[2] * (1 - alpha);
mat3d zahat; zahat.skew(za);
mat3d zathat; zathat.skew(zat);
// body b
vec3d rb = RBb.m_rt*alpha + RBb.m_rp*(1 - alpha);
vec3d zbt = m_qb0; RBb.GetRotation().RotateVector(zbt);
vec3d zbp = m_qb0; RBb.m_qp.RotateVector(zbp);
vec3d zb = zbt*alpha + zbp*(1 - alpha);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0] * alpha + ebp[0] * (1 - alpha);
eb[1] = ebt[1] * alpha + ebp[1] * (1 - alpha);
eb[2] = ebt[2] * alpha + ebp[2] * (1 - alpha);
mat3d zbhat; zbhat.skew(zb);
mat3d zbthat; zbthat.skew(zbt);
mat3ds P = m_bd ? mat3dd(1) : mat3dd(1) - dyad(ea[0]);
vec3d p = m_bd ? ea[0] * m_dp : vec3d(0, 0, 0);
vec3d d = rb + zb - ra - za;
vec3d c = P*d - p;
m_F = m_L + c*m_eps + ea[0] * m_Fp;
mat3dd I(1);
vec3d ksi = (ea[0] ^ eb[0]) / 2;
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(m_qp, ea[0]);
r = a*q.Inverse();
r.MakeUnit();
ksi = r.GetVector()*r.GetAngle();
}
m_M = m_U + ksi*m_ups + ea[0] * m_Mp;
mat3d eahat[3], ebhat[3], eathat[3], ebthat[3];
for (int j = 0; j < 3; ++j) {
eahat[j] = skew(ea[j]);
ebhat[j] = skew(eb[j]);
eathat[j] = skew(eat[j]);
ebthat[j] = skew(ebt[j]);
}
mat3d Q = m_bd ? eathat[0] * m_dp : ((ea[0] & d) + mat3dd(1)*(ea[0] * d))*eathat[0];
mat3d K, Wba, Wab;
Wba = (ebhat[0] * eathat[0]) / 2;
Wab = (eahat[0] * ebthat[0]) / 2;
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;
}
mat3da Fhat(m_F);
// (1,1)
K = P*(alpha*m_eps);
ke[0][0] = K[0][0]; ke[0][1] = K[0][1]; ke[0][2] = K[0][2];
ke[1][0] = K[1][0]; ke[1][1] = K[1][1]; ke[1][2] = K[1][2];
ke[2][0] = K[2][0]; ke[2][1] = K[2][1]; ke[2][2] = K[2][2];
// (1,2)
K = (P*zathat + Q)*(-m_eps*alpha)
+ eathat[0] * (m_Fp*alpha);
ke[0][3] = K[0][0]; ke[0][4] = K[0][1]; ke[0][5] = K[0][2];
ke[1][3] = K[1][0]; ke[1][4] = K[1][1]; ke[1][5] = K[1][2];
ke[2][3] = K[2][0]; ke[2][4] = K[2][1]; ke[2][5] = K[2][2];
// (1,3)
K = P*(-alpha*m_eps);
ke[0][6] = K[0][0]; ke[0][7] = K[0][1]; ke[0][8] = K[0][2];
ke[1][6] = K[1][0]; ke[1][7] = K[1][1]; ke[1][8] = K[1][2];
ke[2][6] = K[2][0]; ke[2][7] = K[2][1]; ke[2][8] = K[2][2];
// (1,4)
K = P*zbthat*(alpha*m_eps);
ke[0][9] = K[0][0]; ke[0][10] = K[0][1]; ke[0][11] = K[0][2];
ke[1][9] = K[1][0]; ke[1][10] = K[1][1]; ke[1][11] = K[1][2];
ke[2][9] = K[2][0]; ke[2][10] = K[2][1]; ke[2][11] = K[2][2];
// (2,1)
K = zahat*P*(alpha*m_eps);
ke[3][0] = K[0][0]; ke[3][1] = K[0][1]; ke[3][2] = K[0][2];
ke[4][0] = K[1][0]; ke[4][1] = K[1][1]; ke[4][2] = K[1][2];
ke[5][0] = K[2][0]; ke[5][1] = K[2][1]; ke[5][2] = K[2][2];
// (2,2)
K = (zahat*(P*zathat + Q)*m_eps + Fhat * zathat + Wba*m_ups)*(-alpha)
+ eathat[0] * (m_Mp*alpha);
ke[3][3] = K[0][0]; ke[3][4] = K[0][1]; ke[3][5] = K[0][2];
ke[4][3] = K[1][0]; ke[4][4] = K[1][1]; ke[4][5] = K[1][2];
ke[5][3] = K[2][0]; ke[5][4] = K[2][1]; ke[5][5] = K[2][2];
// (2,3)
K = zahat*P*(-alpha*m_eps);
ke[3][6] = K[0][0]; ke[3][7] = K[0][1]; ke[3][8] = K[0][2];
ke[4][6] = K[1][0]; ke[4][7] = K[1][1]; ke[4][8] = K[1][2];
ke[5][6] = K[2][0]; ke[5][7] = K[2][1]; ke[5][8] = K[2][2];
// (2,4)
K = (zahat*P*zbthat*m_eps + Wab*m_ups)*alpha;
ke[3][9] = K[0][0]; ke[3][10] = K[0][1]; ke[3][11] = K[0][2];
ke[4][9] = K[1][0]; ke[4][10] = K[1][1]; ke[4][11] = K[1][2];
ke[5][9] = K[2][0]; ke[5][10] = K[2][1]; ke[5][11] = K[2][2];
// (3,1)
K = P*(-alpha*m_eps);
ke[6][0] = K[0][0]; ke[6][1] = K[0][1]; ke[6][2] = K[0][2];
ke[7][0] = K[1][0]; ke[7][1] = K[1][1]; ke[7][2] = K[1][2];
ke[8][0] = K[2][0]; ke[8][1] = K[2][1]; ke[8][2] = K[2][2];
// (3,2)
K = (P*zathat + Q)*(m_eps*alpha)
- eathat[0] * (m_Fp*alpha);
ke[6][3] = K[0][0]; ke[6][4] = K[0][1]; ke[6][5] = K[0][2];
ke[7][3] = K[1][0]; ke[7][4] = K[1][1]; ke[7][5] = K[1][2];
ke[8][3] = K[2][0]; ke[8][4] = K[2][1]; ke[8][5] = K[2][2];
// (3,3)
K = P*(alpha*m_eps);
ke[6][6] = K[0][0]; ke[6][7] = K[0][1]; ke[6][8] = K[0][2];
ke[7][6] = K[1][0]; ke[7][7] = K[1][1]; ke[7][8] = K[1][2];
ke[8][6] = K[2][0]; ke[8][7] = K[2][1]; ke[8][8] = K[2][2];
// (3,4)
K = P*zbthat*(-alpha*m_eps);
ke[6][9] = K[0][0]; ke[6][10] = K[0][1]; ke[6][11] = K[0][2];
ke[7][9] = K[1][0]; ke[7][10] = K[1][1]; ke[7][11] = K[1][2];
ke[8][9] = K[2][0]; ke[8][10] = K[2][1]; ke[8][11] = K[2][2];
// (4,1)
K = zbhat*P*(-alpha*m_eps);
ke[9][0] = K[0][0]; ke[9][1] = K[0][1]; ke[9][2] = K[0][2];
ke[10][0] = K[1][0]; ke[10][1] = K[1][1]; ke[10][2] = K[1][2];
ke[11][0] = K[2][0]; ke[11][1] = K[2][1]; ke[11][2] = K[2][2];
// (4,2)
K = (zbhat*(P*zathat + Q)*m_eps + Wba*m_ups)*alpha
- eathat[0] * (m_Mp*alpha);
ke[9][3] = K[0][0]; ke[9][4] = K[0][1]; ke[9][5] = K[0][2];
ke[10][3] = K[1][0]; ke[10][4] = K[1][1]; ke[10][5] = K[1][2];
ke[11][3] = K[2][0]; ke[11][4] = K[2][1]; ke[11][5] = K[2][2];
// (4,3)
K = zbhat*P*(alpha*m_eps);
ke[9][6] = K[0][0]; ke[9][7] = K[0][1]; ke[9][8] = K[0][2];
ke[10][6] = K[1][0]; ke[10][7] = K[1][1]; ke[10][8] = K[1][2];
ke[11][6] = K[2][0]; ke[11][7] = K[2][1]; ke[11][8] = K[2][2];
// (4,4)
K = (zbhat*P*zbthat*m_eps - Fhat * zbthat + Wab*m_ups)*(-alpha);
ke[9][9] = K[0][0]; ke[9][10] = K[0][1]; ke[9][11] = K[0][2];
ke[10][9] = K[1][0]; ke[10][10] = K[1][1]; ke[10][11] = K[1][2];
ke[11][9] = K[2][0]; ke[11][10] = K[2][1]; ke[11][11] = K[2][2];
for (int j = 0; j < 6; ++j)
{
LM[j] = RBa.m_LM[j];
LM[j + 6] = RBb.m_LM[j];
}
ke.SetIndices(LM);
LS.Assemble(ke);
}
else
{
// current values of Lagrange multipliers
vec3d Lm = m_F; // lagrange multiplier
double mu = m_u;
// rigid body positions
vec3d ra = RBa.m_rt;
vec3d rb = RBb.m_rt;
// rigid body rotations
quatd Qa = RBa.GetRotation();
quatd Qb = RBb.GetRotation();
// current joint offset
vec3d qa = Qa*m_qa0;
vec3d qb = Qb*m_qb0;
// "gap" vector
vec3d g = ra + qa - rb - qb;
// current joint axis
vec3d n0 = m_e0[0];
vec3d ea = Qa*n0;
vec3d eb = Qb*n0;
mat3d N;
N[0][0] = 0; N[0][1] = n0.z; N[0][2] = -n0.y;
N[1][0] = -n0.z; N[1][1] = 0; N[1][2] = n0.x;
N[2][0] = n0.y; N[2][1] = -n0.x; N[2][2] = 0;
mat3d NT = N.transpose();
// projection matrix
mat3d Pa = mat3dd(1.0) - dyad(ea);
// setup skew matrices
mat3d ya;
ya[0][0] = 0; ya[0][1] = qa.z; ya[0][2] = -qa.y;
ya[1][0] = -qa.z; ya[1][1] = 0; ya[1][2] = qa.x;
ya[2][0] = qa.y; ya[2][1] = -qa.x; ya[2][2] = 0;
mat3d yaT = ya.transpose();
mat3d yb;
yb[0][0] = 0; yb[0][1] = qb.z; yb[0][2] = -qb.y;
yb[1][0] = -qb.z; yb[1][1] = 0; yb[1][2] = qb.x;
yb[2][0] = qb.y; yb[2][1] = -qb.x; yb[2][2] = 0;
mat3d ybT = yb.transpose();
mat3d GaT = mat3dd(ea*g) + (g & ea);
mat3d La = mat3dd(ea*Lm) + (ea & Lm);
mat3d LaT = La.transpose();
FEElementMatrix ke; ke.resize(16, 16);
ke.zero();
// row 1
ke.add_symm(0, 3, -La*N);
ke.add_symm(0, 12, Pa);
// row 2
ke.add(3, 3, -(yaT*La*N + NT*LaT*ya)-NT*dyads(Lm, g)*N);
ke.add_symm(3, 6, NT*LaT);
ke.add_symm(3, 9, NT*LaT*yb + NT*N*mu);
ke.add_symm(3, 12, yaT*Pa - NT*GaT);
ke.add_symm(3, 15, NT*eb);
// row 3
ke.add_symm(6, 12, -Pa);
// row 4
ke.add_symm(9, 12, -ybT*Pa);
ke.add_symm(9, 15, NT*ea);
double e = 0.0;
for (int i = 0; i < 16; ++i)
for (int j = i + 1; j < 16; ++j) e = ke(i, j) - ke(j, i);
vector<int> LM;
UnpackLM(LM);
ke.SetIndices(LM);
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
bool FERigidCylindricalJoint::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;
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
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);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
mat3ds P = m_bd ? mat3dd(1) : mat3dd(1) - dyad(ea[0]);
vec3d p = m_bd ? ea[0]*m_dp : vec3d(0,0,0);
c = P*(rb + zb - ra - za) - p;
normF0 = sqrt(m_L*m_L);
// calculate trial multiplier
Lm = m_L + c*m_eps;
normF1 = sqrt(Lm*Lm);
ksi = (ea[0] ^ eb[0])/2;
if (m_bq) {
quatd q = (alpha*RBb.GetRotation() + (1 - alpha)*RBb.m_qp)*(alpha*RBa.GetRotation() + (1 - alpha)*RBa.m_qp).Inverse();
quatd a(m_qp,ea[0]);
quatd r = a*q.Inverse();
r.MakeUnit();
ksi = r.GetVector()*r.GetAngle();
}
normM0 = sqrt(m_U*m_U);
// calculate trial multiplier
Um = m_U + ksi*m_ups;
normM1 = sqrt(Um*Um);
// check convergence of constraints
feLog(" rigid connector # %d (cylindrical 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);
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 && ((pctn >= m_atol) || (qctn >= m_atol))) bconv = false;
if (m_gtol && (gap >= m_gtol)) 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 FERigidCylindricalJoint::Update()
{
if (m_laugon == FECore::LAGMULT_METHOD) return;
vec3d ra, rb;
vec3d za, zb;
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
const FETimeInfo& tp = GetTimeInfo();
double alpha = tp.alphaf;
ra = RBa.m_rt*alpha + RBa.m_rp*(1-alpha);
rb = RBb.m_rt*alpha + RBb.m_rp*(1-alpha);
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
za = zat*alpha + zap*(1-alpha);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
mat3ds P = m_bd ? mat3dd(1) : mat3dd(1) - dyad(ea[0]);
vec3d p = m_bd ? ea[0]*m_dp : vec3d(0,0,0);
vec3d c = P*(rb + zb - ra - za) - p;
m_F = m_L + c*m_eps + ea[0]*m_Fp;
vec3d ksi = (ea[0] ^ eb[0])/2;
if (m_bq) {
quatd q = (alpha*RBb.GetRotation() + (1 - alpha)*RBb.m_qp)*(alpha*RBa.GetRotation() + (1 - alpha)*RBa.m_qp).Inverse();
quatd a(m_qp,ea[0]);
quatd r = a*q.Inverse();
r.MakeUnit();
ksi = r.GetVector()*r.GetAngle();
}
m_M = m_U + ksi*m_ups + ea[0]*m_Mp;
}
//-----------------------------------------------------------------------------
void FERigidCylindricalJoint::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;
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];
}
//-----------------------------------------------------------------------------
vec3d FERigidCylindricalJoint::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 FERigidCylindricalJoint::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;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEVonMisesPlasticity.cpp | .cpp | 4,524 | 158 | /*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 "FEVonMisesPlasticity.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEVonMisesPlasticity, FESolidMaterial)
ADD_PARAMETER(m_E, FE_RANGE_GREATER(0.0), "E");
ADD_PARAMETER(m_v, FE_RANGE_RIGHT_OPEN(-1.0, 0.5), "v");
ADD_PARAMETER(m_Y, FE_RANGE_GREATER(0.0), "Y");
ADD_PARAMETER(m_H, FE_RANGE_GREATER_OR_EQUAL(0.0), "H");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEVonMisesPlasticity::FEVonMisesPlasticity(FEModel* pfem) : FESolidMaterial(pfem)
{
m_E = m_v = m_Y = m_H = 0;
m_K = m_G = 0;
AddDomainParameter(new FESolidStress());
}
//-----------------------------------------------------------------------------
bool FEVonMisesPlasticity::Init()
{
if (FESolidMaterial::Init() == false) return false;
m_K = m_E/(3.0*(1.0 - 2*m_v));
m_G = m_E/(2.0*(1.0 + m_v));
return true;
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEVonMisesPlasticity::CreateMaterialPointData()
{
FEJ2PlasticMaterialPoint* pt = new FEJ2PlasticMaterialPoint;
pt->Y0 = m_Y;
return pt;
}
//-----------------------------------------------------------------------------
mat3ds FEVonMisesPlasticity::Stress(FEMaterialPoint &mp)
{
FEJ2PlasticMaterialPoint& pp = *mp.ExtractData<FEJ2PlasticMaterialPoint>();
mat3d& F = pp.m_F;
// get the current strain
mat3ds e = F.sym() - mat3dd(1.0);
// calculate strain increment
mat3ds de = (e - pp.e0);
// get the trial stress
mat3ds strial = pp.sn + (de.dev()*(2.0*m_G) + de.iso()*(3.0*m_K));
mat3ds dev_strial = strial.dev();
double devs_norm = dev_strial.norm();
// get current yield strenght
double Y = pp.Y0;
double k = Y / sqrt(3.0);
double fac = devs_norm / (sqrt(2.0)*k);
mat3ds s;
if (fac<=1)
{
s = strial;
pp.b = false;
}
else
{
// calculate plastic strain rate
double L = (devs_norm - sqrt(2.0/3.0)*Y)/(2*m_G + m_H);
// update yield strength
pp.Y1 = Y + m_H*L/sqrt(2.0/3.0);
// update stress
s = strial.iso() + dev_strial*(1.0 - 2.0*m_G*L/devs_norm);
pp.b = true;
}
// store the current strain measure
pp.e1 = e;
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEVonMisesPlasticity::Tangent(FEMaterialPoint &mp)
{
FEJ2PlasticMaterialPoint& pp = *mp.ExtractData<FEJ2PlasticMaterialPoint>();
// lame parameters
double lam = m_K - m_G*2.0/3.0;
double mu = m_G;
double D[6][6] = {0};
D[0][0] = lam+2.*mu; D[0][1] = lam ; D[0][2] = lam ;
D[1][0] = lam ; D[1][1] = lam+2.*mu; D[1][2] = lam ;
D[2][0] = lam ; D[2][1] = lam ; D[2][2] = lam+2.*mu;
D[3][3] = mu;
D[4][4] = mu;
D[5][5] = mu;
tens4ds C(D);
// see if we are in plastic flow mode
if (pp.b)
{
// get the stress
mat3ds s = pp.m_s;
mat3ds n = s.dev()*2.0;
mat3ds A = C.dot(n);
double G = n.dotdot(A) + m_H;
C -= dyad4s(A)/G;
}
return C;
}
FESolidStress::FESolidStress() : FEDomainParameter("stress") {}
FEParamValue FESolidStress::value(FEMaterialPoint& mp)
{
FEJ2PlasticMaterialPoint& pp = *mp.ExtractData<FEJ2PlasticMaterialPoint>();
return pp.m_s;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEAxialBodyForce.h | .h | 1,787 | 51 | /*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"
//! This class defines a radial body force.
//! The body force depends on the current nodal coordinates
class FEAxialBodyForce : public FEBodyForce
{
public:
FEAxialBodyForce(FEModel* pfem);
vec3d force(FEMaterialPoint& mp) override;
double divforce(FEMaterialPoint& mp) override;
mat3d stiffness(FEMaterialPoint& mp) override;
public:
vec3d c; //!< force center
vec3d n; //!< axis
double p; //!< power
double s; //!< scale factor
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEMRVonMisesFibers.cpp | .cpp | 16,906 | 473 | /*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 "FEMRVonMisesFibers.h"
#include <fstream>
// define the material parameters
BEGIN_FECORE_CLASS(FEMRVonMisesFibers, 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");
// Fiber Concentration Factor
ADD_PARAMETER(kf, "kf");
// Preferred fiber orientation IN RADIANS
ADD_PARAMETER(tp, "tp");
// Number of Gauss Integration Points
ADD_PARAMETER(gipt, "gipt");
// Choice of von Mises distribution; 1: semi-circular von Mises distribution; = 2: constrained von Mises distribution
ADD_PARAMETER(vmc, "vmc");
// Exponent for the constrained von Mises distribution
ADD_PARAMETER(var_n, "var_n");
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//=============================================================================
FEMRVonMisesMaterialPoint::FEMRVonMisesMaterialPoint(FEMaterialPointData* mp) : FEMaterialPointData(mp)
{
}
FEMaterialPointData* FEMRVonMisesMaterialPoint::Copy()
{
FEMRVonMisesMaterialPoint* pt = new FEMRVonMisesMaterialPoint(*this);
if (m_pNext) pt->m_pNext = m_pNext->Copy();
return pt;
}
//-----------------------------------------------------------------------------
void FEMRVonMisesMaterialPoint::Serialize(DumpStream& ar)
{
FEMaterialPointData::Serialize(ar);
ar & m_kf & m_tp;
}
//////////////////////////////////////////////////////////////////////
// FEVonMisesFibers
/////////////////////////////////////////////////////////////////////
//
// This material model has been implemented by Cecile Gouget and Michael Girard
//
// This is a fiber-based model intended to describe the behavior of the sclera - the white coat of the eye - and other thin soft tissues.
// Instead of having a single fiber orientation (Transverse Isotropy), we consider that collagen fiber alignment is
// multi-directional at local material points, confined within the plane tangent to the tissue surface, and described by either:
//
// 1) A semi-circular von Mises distribution function. Such model was originally implemented within Nike3d [1].
// 2) A constrained von Mises distribution function [2]
//
// This latter function is formed as a weighted mixture of the semi-circular uniform distribution and the semi-circular von Mises distribution.
// Such function has been shown to better describe the planar anisotropy of thin soft tissues and was validated using small angle light scattering measurements
// tissue anisotropy. It is therefore the preferred function to use.
//
// REFERENCES
// ------------
// [1] Girard MJA, Downs JC, Burgoyne CF, and Suh JKF, 2009, "Peripapillary and posterior scleral mechanics - Part I:
// Development of an anisotropic hyperelastic constitutive model," ASME J. Biomech. Eng., 131, p. 051011.
// ------------
// [2] Gouget CLM, Girard MJA, Ethier CR, 2012, "A constrained von Mises distribution to describe fiber organization
// in thin soft tissues," Biomechanics And Modeling in Mechanobiolgy, 11(3-4), p. 475-482.
//
//
/////////////////////////////////////////////////////////////////////
// This is the modified Bessel function of the first kind (order zero)
// It is used to compute the probability distribution function
// of the fibers - the semi-circular von-Mises distribution
double bessi0(double X)
{
double Y,P1,P2,P3,P4,P5,P6,P7,Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8,Q9,AX,BX;
P1=1.0; P2=3.5156229; P3=3.0899424; P4=1.2067429;
P5=0.2659732; P6=0.360768e-1; P7=0.45813e-2;
Q1=0.39894228; Q2=0.1328592e-1; Q3=0.225319e-2;
Q4=-0.157565e-2; Q5=0.916281e-2; Q6=-0.2057706e-1;
Q7=0.2635537e-1; Q8=-0.1647633e-1; Q9=0.392377e-2;
if (fabs(X) < 3.75)
{
Y=(X/3.75)*(X/3.75);
return (P1+Y*(P2+Y*(P3+Y*(P4+Y*(P5+Y*(P6+Y*P7))))));
}
else
{
AX=fabs(X);
Y=3.75/AX;
BX=exp(AX)/sqrt(AX);
AX=Q1+Y*(Q2+Y*(Q3+Y*(Q4+Y*(Q5+Y*(Q6+Y*(Q7+Y*(Q8+Y*Q9)))))));
return (AX*BX);
}
}
// This is the modified Bessel function of the first kind (order one)
// It is used to compute the probability distribution function
// of the fibers - the constrained von-Mises distribution
double bessi1(double X)
{
double Y,P1,P2,P3,P4,P5,P6,P7,Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8,Q9,AX,BX;
P1=0.5; P2=0.87890594; P3=0.51498869; P4=0.15084934;
P5=0.2658733e-1; P6=0.301532e-2; P7=0.32411e-3;
Q1=0.39894228; Q2=-0.3988024e-1; Q3=-0.362018e-2;
Q4=0.163801e-2; Q5=-0.1031555e-1; Q6=0.2282967e-1;
Q7=-0.2895312e-1; Q8=0.1787654e-1; Q9=-0.420059e-2;
if (fabs(X) < 3.75)
{
Y=(X/3.75)*(X/3.75);
return(X*(P1+Y*(P2+Y*(P3+Y*(P4+Y*(P5+Y*(P6+Y*P7)))))));
}
else
{
AX=fabs(X);
Y=3.75/AX;
BX=exp(AX)/sqrt(AX);
AX=Q1+Y*(Q2+Y*(Q3+Y*(Q4+Y*(Q5+Y*(Q6+Y*(Q7+Y*(Q8+Y*Q9)))))));
return (AX*BX);
}
}
//-----------------------------------------------------------------------------
FEMRVonMisesFibers::FEMRVonMisesFibers(FEModel* pfem) : FEUncoupledMaterial(pfem), m_fib(pfem)
{
m_fib.SetParent(this);
}
//-----------------------------------------------------------------------------
FEMaterialPointData* FEMRVonMisesFibers::CreateMaterialPointData()
{
FEMRVonMisesMaterialPoint* pt = new FEMRVonMisesMaterialPoint(FEUncoupledMaterial::CreateMaterialPointData());
pt->m_kf = kf;
pt->m_tp = tp;
return pt;
}
//-----------------------------------------------------------------------------
mat3ds FEMRVonMisesFibers::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEMRVonMisesMaterialPoint& vmpt = *mp.ExtractData<FEMRVonMisesMaterialPoint>();
// get some of the material parmaters from the material point
double kf = vmpt.m_kf;
double tp = vmpt.m_tp;
// deformation gradient
mat3d& F = pt.m_F;
double J = pt.m_J;
//// FIRST, WE CALCULATE THE MOONEY RIVLIN PART OF THE STRESS
// 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 ---
// Wi = dW/dIi
double W1 = c1;
double W2 = c2;
// calculate T = F*dW/dC*Ft
mat3ds T = B*(W1 + W2*I1) - B2*W2;
// calculate stress s = 2/J * dev(T)
mat3ds s = T.dev()*(2.0/J);
//NOW, WE CALCULATE THE FIBER COMPONENT OF THE STRESS by the mean of a Gauss integration
const double pi = 3.14159265358979323846;
vec3d a0, b0, c0; // current local material axis
vector<double> pp(gipt), wmg(gipt); //gipt Gauss points and weights
double aa, bb, pas;
int i;
double distribution; //experimental distribution function of fiber orientations
// double sigma;
double beta;
//std::cout << gipt << "\n";
//-=-=- Gauss Points -=-=-
// Compute angles for Gaussian Quadrature
// for a function f, a Gaussian quadrature rule follows
//
// n
// /a -----
// | b - a \ b - a a + b
// | f(t)dt = ------- \ wi * f( ----- xi + ----- )
// | 2 / 2 2
// / b /
// -----
// i = 1
//
// where xi are the points and wi are the weights
//
// For n = 2, we have
// w1 = w2 = 1.0
// x1 = - x2 = 1/sqrt(3.0)
//
// In the following we used "gipt" Gauss points for the numerical integration
//-=-=-=-=-=-=-=-=-=-=-=-=
// step
pas = pi / (gipt/10);
//Gauss Points
for(int j=0; j<gipt; j+=10)
{
aa = tp - pi/2.0 + j/10 * pas;
bb = tp - pi/2.0 + (j/10+1) * pas;
pp[j+0] = pas/2.0 * ( + 0.14887434 ) + (aa+bb)/2.0;
pp[j+1] = pas/2.0 * ( - 0.14887434 ) + (aa+bb)/2.0;
pp[j+2] = pas/2.0 * ( + 0.43339539 ) + (aa+bb)/2.0;
pp[j+3] = pas/2.0 * ( - 0.43339539 ) + (aa+bb)/2.0;
pp[j+4] = pas/2.0 * ( + 0.67940957 ) + (aa+bb)/2.0;
pp[j+5] = pas/2.0 * ( - 0.67940957 ) + (aa+bb)/2.0;
pp[j+6] = pas/2.0 * ( + 0.86506337 ) + (aa+bb)/2.0;
pp[j+7] = pas/2.0 * ( - 0.86506337 ) + (aa+bb)/2.0;
pp[j+8] = pas/2.0 * ( + 0.97390653 ) + (aa+bb)/2.0;
pp[j+9] = pas/2.0 * ( - 0.97390653 ) + (aa+bb)/2.0;
}
//Weights for Gaussian Quadrature
for(int j=0; j<gipt; j+=10)
{
wmg[j+0] = 0.29552422 * pas/2.0;
wmg[j+1] = 0.29552422 * pas/2.0;
wmg[j+2] = 0.26926672 * pas/2.0;
wmg[j+3] = 0.26926672 * pas/2.0;
wmg[j+4] = 0.21908636 * pas/2.0;
wmg[j+5] = 0.21908636 * pas/2.0;
wmg[j+6] = 0.14945135 * pas/2.0;
wmg[j+7] = 0.14945135 * pas/2.0;
wmg[j+8] = 0.06667134 * pas/2.0;
wmg[j+9] = 0.06667134 * pas/2.0;
}
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// get the initial fiber direction : a0 is the fiber direction,
// b0 a vector of the plane of the fibers perpendicular to a0
// (specified in mat_axis : a0 = unit(a) ; b0 = unit((a0^d0)^a0)
a0.x = Q[0][0]; b0.x = Q[0][1]; c0.x = Q[0][2];
a0.y = Q[1][0]; b0.y = Q[1][1]; c0.y = Q[1][2];
a0.z = Q[2][0]; b0.z = Q[2][1]; c0.z = Q[2][2];
// Think of it as #gipt different fiber orientations that are distributed within a plane
// of coordinate system (a0,b0)
for(i=0;i<gipt;++i)
{
// vector describing the fibers which make an angle pp[i] with vector a0 in plane (a0,b0)
vec3d n0;
n0.x = cos(pp[i])*a0.x+sin(pp[i])*b0.x;
n0.y = cos(pp[i])*a0.y+sin(pp[i])*b0.y;
n0.z = cos(pp[i])*a0.z+sin(pp[i])*b0.z;
// probability of having a fiber along this vector
if (vmc==1) // Semi-circular von Mises distribution
{
distribution = 1. / ( pi * bessi0(kf) ) * exp( kf * cos( 2.* (pp[i]-tp) ) );
}
else if (vmc==2) // Constrained von Mises distribution
{
beta = pow(bessi1(kf)/bessi0(kf),var_n); // Weighting factor (isotropic vs anisotropic)
distribution = (1.-beta)/pi + beta / ( pi * bessi0(kf) ) * exp( kf * cos( 2.* (pp[i]-tp) ) );
}
// add the fiber stress by Gauss integration : m_fib.Stress(mp) is the deviatoric stress due to the fibers in direction pp[i],
// distribution is the probability of having a fiber in this direction, and wmg[i] is the Gauss Weight for integration
s += wmg[i]*distribution*m_fib.DevFiberStress(mp, n0);
}
return s;
}
tens4ds FEMRVonMisesFibers::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEMRVonMisesMaterialPoint& vmpt = *mp.ExtractData<FEMRVonMisesMaterialPoint>();
// get some of the material parmaters from the material point
double kf = vmpt.m_kf;
double tp = vmpt.m_tp;
// deformation gradient
mat3d& F = pt.m_F;
double J = pt.m_J;
double Ji = 1.0/J;
//// FIRST, WE CALCULATE THE MOONEY RIVLIN PART OF THE TANGENT
// 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;
mat3dd I(1); // Identity
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
tens4ds BxB = dyad1s(B);
tens4ds B4 = dyad4s(B);
// deviatoric cauchy-stress, trs = trace[s]/3
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;
//NOW, WE CALCULATE THE FIBERS CONTRIBUTION TO THE TANGENT by the mean of a Gauss integration
// current local material axis
const double pi = 3.14159265358979323846;
vec3d a0, b0, c0;
vector<double> pp(gipt), wmg(gipt);
double aa, bb, pas;
int i;
double distribution;
// double sigma;
double beta;
//-=-=- Gauss Points -=-=-
// Compute angles for Gaussian Quadrature
// for a function f, a Gaussian quadrature rule follows
//
// n
// /a -----
// | b - a \ b - a a + b
// | f(t)dt = ------- \ wi * f( ----- xi + ----- )
// | 2 / 2 2
// / b /
// -----
// i = 1
//
// where xi are the points and wi are the weights
//
// For n = 2, we have
// w1 = w2 = 1.0
// x1 = - x2 = 1/sqrt(3.0)
//
// In the following we used "gipt" Gauss points for the numerical integration
//-=-=-=-=-=-=-=-=-=-=-=-=
// step
pas = pi / (gipt/10);
//Gauss Points
for(int j=0; j<gipt; j+=10)
{
aa = tp - pi/2.0 + j/10 * pas;
bb = tp - pi/2.0 + (j/10+1) * pas;
pp[j+0] = pas/2.0 * ( + 0.14887434 ) + (aa+bb)/2.0;
pp[j+1] = pas/2.0 * ( - 0.14887434 ) + (aa+bb)/2.0;
pp[j+2] = pas/2.0 * ( + 0.43339539 ) + (aa+bb)/2.0;
pp[j+3] = pas/2.0 * ( - 0.43339539 ) + (aa+bb)/2.0;
pp[j+4] = pas/2.0 * ( + 0.67940957 ) + (aa+bb)/2.0;
pp[j+5] = pas/2.0 * ( - 0.67940957 ) + (aa+bb)/2.0;
pp[j+6] = pas/2.0 * ( + 0.86506337 ) + (aa+bb)/2.0;
pp[j+7] = pas/2.0 * ( - 0.86506337 ) + (aa+bb)/2.0;
pp[j+8] = pas/2.0 * ( + 0.97390653 ) + (aa+bb)/2.0;
pp[j+9] = pas/2.0 * ( - 0.97390653 ) + (aa+bb)/2.0;
}
//Weights for Gaussian Quadrature
for(int j=0; j<gipt; j+=10)
{
wmg[j+0] = 0.29552422 * pas/2.0;
wmg[j+1] = 0.29552422 * pas/2.0;
wmg[j+2] = 0.26926672 * pas/2.0;
wmg[j+3] = 0.26926672 * pas/2.0;
wmg[j+4] = 0.21908636 * pas/2.0;
wmg[j+5] = 0.21908636 * pas/2.0;
wmg[j+6] = 0.14945135 * pas/2.0;
wmg[j+7] = 0.14945135 * pas/2.0;
wmg[j+8] = 0.06667134 * pas/2.0;
wmg[j+9] = 0.06667134 * pas/2.0;
}
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// get the initial fiber direction
a0.x = Q[0][0]; b0.x = Q[0][1]; c0.x = Q[0][2];
a0.y = Q[1][0]; b0.y = Q[1][1]; c0.y = Q[1][2];
a0.z = Q[2][0]; b0.z = Q[2][1]; c0.z = Q[2][2];
// Think of it as #gipt different fiber orientations that are distributed within a plane of coordinate system (a0,b0)
// and that all contribute to the tangent in proportion with the probability of having a fiber in this orientation
for(i=0;i<gipt;++i)
{
// vector describing the fibers which make an angle pp[i] with vector a0 in plane (a0,b0)
vec3d n0;
n0.x = cos(pp[i])*a0.x+sin(pp[i])*b0.x;
n0.y = cos(pp[i])*a0.y+sin(pp[i])*b0.y;
n0.z = cos(pp[i])*a0.z+sin(pp[i])*b0.z;
// probability of having a fiber along this vector
if (vmc==1) // Semi-circular von Mises distribution
{
distribution = 1. / ( pi * bessi0(kf) ) * exp( kf * cos( 2.* (pp[i]-tp) ) );
}
else if (vmc==2) // Constrained von Mises distribution
{
beta = pow(bessi1(kf)/bessi0(kf),var_n); // Weighting factor (isotropic vs anisotropic)
distribution = (1.-beta)/pi + beta / ( pi * bessi0(kf) ) * exp( kf * cos( 2.* (pp[i]-tp) ) );
}
// add the fiber stress by Gauss integration : m_fib.Tangent(mp) is the contribution to the tangent of the fibers in direction pp[i],
// distribution is the probability of having a fiber in this direction, and wmg[i] is the Gauss Weight for integration
c += wmg[i]*distribution*m_fib.DevFiberTangent(mp, n0);
}
return c;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FERigidSystem.h | .h | 3,549 | 117 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FECoreBase.h>
#include <vector>
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
// forward declarations
class FEModel;
class FERigidBody;
class FEModelComponent;
class FERigidBC;
class FERigidIC;
class FEGlobalMatrix;
//-----------------------------------------------------------------------------
//! The FERigidSystem class manages all rigid body paraphernalia.
class FEBIOMECH_API FERigidSystem
{
public:
//! constructor
FERigidSystem(FEModel* pfem);
//! destructor
~FERigidSystem();
//! Add a rigid body
void AddRigidBody(FERigidBody* prb);
//! return the number of rigid bodies
int Objects() const;
//! get a rigid body
FERigidBody* Object(int i);
//! Activate
void Activate();
//! Clear
void Clear();
//! Initialization
//! This creates the rigid bodies.
//! (This must be called before any rigid materials are initialized!)
bool Init();
//! Initialization of Rigid bodies
//! (Must be called after the mesh domains are initialized!)
bool InitRigidBodies();
//! Reset data
bool Reset();
//! place data on stream for restarts
void Serialize(DumpStream& dmp);
// Find a parameter (from a rigid material index)
double* FindParameter(int nmat, ParamString& sz, int index);
FEParamValue GetParameterValue(const ParamString& paramString);
// update the mesh geometry
void UpdateMesh();
// build the matrix profile for the rigid system
void BuildMatrixProfile(FEGlobalMatrix& G);
public:
int RigidBCs() { return (int) m_RBC.size(); }
FERigidBC* RigidBC(int i) { return m_RBC[i]; }
void AddRigidBC(FERigidBC* pbc) { m_RBC.push_back(pbc); }
void AddInitialCondition(FERigidIC* ric) { m_RIC.push_back(ric); }
std::vector<FERigidBody*>& RigidBodyList();
protected:
bool CreateObjects();
protected:
// Boundary/Initial conditions for rigid bodies
// TODO: I'd like to do something different with this. Perhaps place them in the BC or in some constraint section.
vector<FERigidBC*> m_RBC; //!< rigid body fixed
vector<FERigidIC*> m_RIC; //!< rigid body initial conditions
private:
FEModel& m_fem; //!< the FE model this system is attached to
vector<FERigidBody*> m_RB; //!< the list of rigid bodies in this system
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEContinuousFiberDistributionUC.cpp | .cpp | 6,382 | 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 "FEContinuousFiberDistributionUC.h"
BEGIN_FECORE_CLASS(FEContinuousFiberDistributionUC, FEUncoupledMaterial)
// set material properties
ADD_PROPERTY(m_pFmat, "fibers");
ADD_PROPERTY(m_pFDD , "distribution");
ADD_PROPERTY(m_pFint, "scheme");
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEContinuousFiberDistributionUC::FEContinuousFiberDistributionUC(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_pFmat = 0;
m_pFDD = 0;
m_pFint = 0;
}
//-----------------------------------------------------------------------------
FEContinuousFiberDistributionUC::~FEContinuousFiberDistributionUC() {}
//-----------------------------------------------------------------------------
// returns a pointer to a new material point object
FEMaterialPointData* FEContinuousFiberDistributionUC::CreateMaterialPointData()
{
FEMaterialPointData* mp = FEUncoupledMaterial::CreateMaterialPointData();
mp->SetNext(m_pFmat->CreateMaterialPointData());
return mp;
}
//-----------------------------------------------------------------------------
//! calculate stress at material point
mat3ds FEContinuousFiberDistributionUC::DevStress(FEMaterialPoint& mp)
{
FEFiberMaterialPoint& fp = *mp.ExtractData<FEFiberMaterialPoint>();
// calculate stress
mat3ds s; s.zero();
// get the local coordinate system
mat3d Q = GetLocalCS(mp);
double IFD = IntegratedFiberDensity(mp);
// obtain an integration point iterator
FEFiberIntegrationSchemeIterator* it = m_pFint->GetIterator(&mp);
if (it->IsValid())
{
do
{
// get the fiber direction for that fiber distribution
vec3d& N = it->m_fiber;
// evaluate ellipsoidally distributed material coefficients
double R = m_pFDD->FiberDensity(mp, N);
// convert fiber to global coordinates
vec3d n0 = Q*N;
// calculate the stress
double wn = it->m_weight;
s += m_pFmat->DevFiberStress(mp, fp.FiberPreStretch(n0))*(R*wn);
}
while (it->Next());
}
// don't forget to delete the iterator
delete it;
// divide by IFD
return s / IFD;
}
//-----------------------------------------------------------------------------
//! calculate tangent stiffness at material point
tens4ds FEContinuousFiberDistributionUC::DevTangent(FEMaterialPoint& mp)
{
FEFiberMaterialPoint& fp = *mp.ExtractData<FEFiberMaterialPoint>();
// get the local coordinate system
mat3d Q = GetLocalCS(mp);
// initialize stress tensor
tens4ds c;
c.zero();
double IFD = IntegratedFiberDensity(mp);
FEFiberIntegrationSchemeIterator* it = m_pFint->GetIterator(&mp);
if (it->IsValid())
{
do
{
// get the fiber direction for that fiber distribution
vec3d& N = it->m_fiber;
// evaluate ellipsoidally distributed material coefficients
double R = m_pFDD->FiberDensity(mp, N);
// convert fiber to global coordinates
vec3d n0 = Q*N;
// calculate the tangent
c += m_pFmat->DevFiberTangent(mp, fp.FiberPreStretch(n0))*(R*it->m_weight);
}
while (it->Next());
}
// don't forget to delete the iterator
delete it;
// divide by IFD
return c / IFD;
}
//-----------------------------------------------------------------------------
//! calculate deviatoric strain energy density
double FEContinuousFiberDistributionUC::DevStrainEnergyDensity(FEMaterialPoint& mp)
{
FEFiberMaterialPoint& fp = *mp.ExtractData<FEFiberMaterialPoint>();
// get the local coordinate system
mat3d Q = GetLocalCS(mp);
double IFD = IntegratedFiberDensity(mp);
double sed = 0.0;
FEFiberIntegrationSchemeIterator* it = m_pFint->GetIterator(&mp);
if (it->IsValid())
{
do
{
// get the fiber direction for that fiber distribution
vec3d& N = it->m_fiber;
// evaluate ellipsoidally distributed material coefficients
double R = m_pFDD->FiberDensity(mp, N);
// convert fiber to global coordinates
vec3d n0 = Q*N;
// calculate the stress
sed += m_pFmat->DevFiberStrainEnergyDensity(mp, fp.FiberPreStretch(n0))*(R*it->m_weight);
}
while (it->Next());
}
// don't forget to delete the iterator
delete it;
// divide by IFD
return sed / IFD;
}
//-----------------------------------------------------------------------------
double FEContinuousFiberDistributionUC::IntegratedFiberDensity(FEMaterialPoint& mp)
{
double IFD = 0;
// NOTE: Pass nullptr to GetIterator to avoid issues with GK rule!
FEFiberIntegrationSchemeIterator* it = m_pFint->GetIterator(nullptr);
if (it->IsValid())
{
do
{
// set fiber direction in global coordinate system
vec3d& N = it->m_fiber;
double R = m_pFDD->FiberDensity(mp, N);
// integrate the fiber distribution
IFD += R * it->m_weight;
} while (it->Next());
}
// don't forget to delete the iterator
delete it;
// just in case
if (IFD == 0.0) IFD = 1.0;
return IFD;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberExponentialPowerUC.cpp | .cpp | 6,003 | 195 | /*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 "FEFiberExponentialPowerUC.h"
#include <limits>
#include <FECore/log.h>
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberExponentialPowerUC, FEElasticFiberMaterialUC)
ADD_PARAMETER(m_alpha, FE_RANGE_GREATER_OR_EQUAL(0.0), "alpha");
ADD_PARAMETER(m_beta, FE_RANGE_GREATER_OR_EQUAL(2.0), "beta");
ADD_PARAMETER(m_ksi, "ksi")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_mu, FE_RANGE_GREATER_OR_EQUAL(0.0), "mu");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFiberExponentialPowerUC::FEFiberExponentialPowerUC(FEModel* pfem) : FEElasticFiberMaterialUC(pfem)
{
m_alpha = 0;
m_beta = 2;
m_ksi = 0;
m_mu = 0;
m_epsf = 0.0;
}
//-----------------------------------------------------------------------------
bool FEFiberExponentialPowerUC::Validate()
{
if ((4 * m_ksi + 2 * m_mu) < 0) { feLogError("4*ksi+2*mu must be positive."); return false; }
return FEElasticFiberMaterialUC::Validate();
}
//-----------------------------------------------------------------------------
mat3ds FEFiberExponentialPowerUC::DevFiberStress(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// distortional part of deformation gradient
mat3d F = pt.m_F*pow(J, -1.0 / 3.0);
// loop over all integration points
mat3ds C = pt.DevRightCauchyGreen();
mat3ds s;
// Calculate In = n0*C*n0
double In_1 = n0*(C*n0) - 1.0;
// only take fibers in tension into consideration
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);
// calculate strain energy derivative
double Wl = m_ksi*pow(In_1, m_beta - 1.0)*exp(m_alpha*pow(In_1, m_beta));
// calculate the fiber stress
s = N*(2.0*Wl / J);
// add the contribution from shear
mat3ds BmI = pt.DevLeftCauchyGreen() - mat3dd(1);
s += (N*BmI).sym()*(m_mu / J);
}
else
{
s.zero();
}
return s.dev();
}
//-----------------------------------------------------------------------------
tens4ds FEFiberExponentialPowerUC::DevFiberTangent(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
double J = pt.m_J;
// distortional part of deformation gradient
mat3d F = pt.m_F*pow(J, -1.0 / 3.0);
const double eps = m_epsf*std::numeric_limits<double>::epsilon();
mat3ds C = pt.DevRightCauchyGreen();
mat3ds s;
tens4ds c;
// Calculate In = n0*C*n0
double In_1 = n0*(C*n0) - 1.0;
// only take fibers in tension into consideration
if (In_1 >= eps)
{
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
tens4ds NxN = dyad1s(N);
mat3dd I(1);
tens4ds IxI = dyad1s(I);
tens4ds I4 = dyad4s(I);
// calculate strain energy derivative
double Wl = m_ksi*pow(In_1, m_beta - 1.0)*exp(m_alpha*pow(In_1, m_beta));
// calculate the fiber stress
s = N*(2.0*Wl / J);
// add the contribution from shear
mat3ds B = pt.DevLeftCauchyGreen();
mat3ds BmI = B - I;
s += (N*BmI).sym()*(m_mu / J);
// calculate strain energy 2nd derivative
double tmp = m_alpha*pow(In_1, m_beta);
double Wll = m_ksi*pow(In_1, m_beta - 2.0)*((tmp + 1)*m_beta - 1.0)*exp(tmp);
// calculate the fiber tangent
c = NxN*(4.0*Wll / J);
// add the contribution from shear
c += dyad4s(N, B)*(m_mu / J);
// This is the final value of the elasticity tensor
c += ((I4 + IxI / 3.0)*s.tr() - dyad1s(I, s))*(2. / 3.) - (ddots(IxI, c) - IxI*(c.tr() / 3.)) / 3.;
}
else
{
c.zero();
}
return c;
}
//-----------------------------------------------------------------------------
//! Strain energy density
double FEFiberExponentialPowerUC::DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// loop over all integration points
mat3ds C = pt.DevRightCauchyGreen();
mat3ds C2 = C.sqr();
// Calculate In = n0*C*n0
double In_1 = n0*(C*n0) - 1.0;
// only take fibers in tension into consideration
const double eps = m_epsf*std::numeric_limits<double>::epsilon();
double sed = 0.0;
if (In_1 >= eps)
{
// calculate strain energy density
if (m_alpha > 0)
sed = m_ksi / (m_alpha*m_beta)*(exp(m_alpha*pow(In_1, m_beta)) - 1);
else
sed = m_ksi / m_beta*pow(In_1, m_beta);
// add the contribution from shear
sed += m_mu*(n0*(C2*n0) - 2 * In_1 - 1) / 4.0;
}
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEDiscreteElasticDomain.h | .h | 2,766 | 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 "FEDiscreteElasticMaterial.h"
#include <FECore/FEDiscreteDomain.h>
#include "FEElasticDomain.h"
class FEDiscreteElasticDomain : public FEDiscreteDomain, public FEElasticDomain
{
public:
FEDiscreteElasticDomain(FEModel* fem);
//! Unpack LM data
void UnpackLM(FEElement& el, vector<int>& lm) override;
//! get the material (overridden from FEDomain)
FEMaterial* GetMaterial() override;
//! set the material
void SetMaterial(FEMaterial* pmat) override;
void Activate() override;
// get the total dofs
const FEDofList& GetDOFList() const override;
void PreSolveUpdate(const FETimeInfo& timeInfo) override;
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 { }
//! initialization
bool Init() 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:
FEDiscreteElasticMaterial* m_pMat;
FEDofList m_dofU, m_dofR, m_dof;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidPlanarJoint.cpp | .cpp | 30,701 | 1,004 | /*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 "FERigidPlanarJoint.h"
#include "FERigidBody.h"
#include "FECore/log.h"
#include <FECore/FELinearSystem.h>
#include <FECore/ad.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidPlanarJoint, 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_e0[0], "rotation_axis" );
ADD_PARAMETER(m_e0[1], "translation_axis_1");
ADD_PARAMETER(m_naugmin, "minaug" );
ADD_PARAMETER(m_naugmax, "maxaug" );
ADD_PARAMETER(m_bqx , "prescribed_rotation");
ADD_PARAMETER(m_qpx , "rotation" );
ADD_PARAMETER(m_bdy , "prescribed_translation_1");
ADD_PARAMETER(m_dpy , "translation_1" );
ADD_PARAMETER(m_bdz , "prescribed_translation_2");
ADD_PARAMETER(m_dpz , "translation_2" );
ADD_PARAMETER(m_bautopen, "auto_penalty");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidPlanarJoint::FERigidPlanarJoint(FEModel* pfem) : FERigidConnector(pfem)
{
m_nID = m_ncount++;
m_laugon = FECore::AUGLAG_METHOD; // for backward compatibility
m_atol = 0;
m_gtol = 0;
m_qtol = 0;
m_naugmin = 0;
m_naugmax = 10;
m_qpx = 0;
m_dpy = 0;
m_dpz = 0;
m_bqx = false;
m_bdy = false;
m_bdz = false;
m_bautopen = false;
m_eps = m_ups = 1.0;
}
//-----------------------------------------------------------------------------
//! initial position
vec3d FERigidPlanarJoint::InitialPosition() const
{
return m_q0;
}
//-----------------------------------------------------------------------------
//! current position
vec3d FERigidPlanarJoint::Position() const
{
FERigidBody& RBa = *m_rbA;
vec3d qa = m_qa0;
RBa.GetRotation().RotateVector(qa);
return RBa.m_rt + qa;
}
//-----------------------------------------------------------------------------
//! current orientation
quatd FERigidPlanarJoint::Orientation() const
{
quatd Q0(vec3d(0, 0, 1), m_e0[0]);
FERigidBody& RBa = *m_rbA;
return RBa.GetRotation()*Q0;
}
//-----------------------------------------------------------------------------
//! TODO: This function is called twice: once in the Init and once in the Solve
//! phase. Is that necessary?
bool FERigidPlanarJoint::Init()
{
// initialize joint basis
m_e0[0].unit();
m_e0[2] = m_e0[0] ^ m_e0[1]; m_e0[2].unit();
m_e0[1] = m_e0[2] ^ m_e0[0]; m_e0[1].unit();
// reset force
m_F = vec3d(0,0,0); m_L = vec3d(0,0,0);
m_M = vec3d(0,0,0); m_U = vec3d(0,0,0);
m_Fp = m_Mp = 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_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 FERigidPlanarJoint::Serialize(DumpStream& ar)
{
FERigidConnector::Serialize(ar);
ar & m_qa0 & m_qb0;
ar & m_L & m_U;
ar & m_e0;
ar & m_ea0;
ar & m_eb0;
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidPlanarJoint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
vector<double> fa(6);
vector<double> fb(6);
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
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);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
if (m_laugon != FECore::LAGMULT_METHOD)
{
mat3ds P;
vec3d p;
if (m_bdy && m_bdz) {
P = mat3dd(1);
p = ea[1] * m_dpy + ea[2] * m_dpz;
}
else if (m_bdy) {
P = mat3dd(1) - dyad(ea[2]);
p = ea[1] * m_dpy;
}
else if (m_bdz) {
P = mat3dd(1) - dyad(ea[1]);
p = ea[2] * m_dpz;
}
else {
P = dyad(ea[0]);
p = vec3d(0, 0, 0);
}
vec3d c = P * (rb + zb - ra - za) - p;
m_F = m_L + c * m_eps;
vec3d ksi;
if (m_bqx) {
quatd q = (alpha * RBb.GetRotation() + (1 - alpha) * RBb.m_qp) * (alpha * RBa.GetRotation() + (1 - alpha) * RBa.m_qp).Inverse();
quatd a(m_qpx, ea[0]);
quatd r = a * q.Inverse();
r.MakeUnit();
ksi = r.GetVector() * r.GetAngle();
}
else
{
ksi = (ea[0] ^ eb[0]) / 2;
}
m_M = m_U + ksi * m_ups;
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 d = rb + zb - ra - za;
mat3dd I(1.0);
mat3d P = dyad(ea[0]);
mat3d PdT = I * (ea[0] * d) + (d & ea[0]);
vec3d F = P*m_F;
vec3d Ma = (za ^ F) - (ea[0] ^ (PdT*m_F)) + (ea[0]^m_M);
vec3d Mb = (zb ^ F) + (eb[0] ^ m_M);
fa[0] = -F.x;
fa[1] = -F.y;
fa[2] = -F.z;
fa[3] = -Ma.x;
fa[4] = -Ma.y;
fa[5] = -Ma.z;
fb[0] = F.x;
fb[1] = F.y;
fb[2] = 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 = ea[0]*(d*ea[0]);
R[m_LM[0]] += c.x;
R[m_LM[1]] += c.y;
R[m_LM[2]] += c.z;
// rotational constraint
vec3d ksi = eb[0] - ea[0];
R[m_LM[3]] += ksi.x;
R[m_LM[4]] += ksi.y;
R[m_LM[5]] += ksi.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 FERigidPlanarJoint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
double alpha = tp.alphaf;
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
vector<int> LM(12);
FEElementMatrix ke; ke.resize(12, 12);
ke.zero();
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
// body A
quatd Qat = RBa.GetRotation();
quatd Qap = RBa.m_qp;
vec3d rat = RBa.m_rt;
vec3d rap = RBa.m_rp;
vec3d ra = rat * alpha + rap * (1 - alpha);
vec3d zat = Qat * m_qa0;
vec3d zap = Qap * m_qa0;
vec3d za = zat * alpha + zap * (1 - alpha);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
mat3d zbhat; zbhat.skew(zb);
mat3d zbthat; zbthat.skew(zbt);
mat3d eahat[3], ebhat[3], eathat[3], ebthat[3];
for (int j=0; j<3; ++j) {
eahat[j] = skew(ea[j]);
ebhat[j] = skew(eb[j]);
eathat[j] = skew(eat[j]);
ebthat[j] = skew(ebt[j]);
}
if (m_laugon != FECore::LAGMULT_METHOD)
{
mat3ds P;
vec3d p;
mat3d Q, Wba, Wab;
vec3d d = rb + zb - ra - za;
if (m_bdy && m_bdz) {
P = mat3dd(1);
p = ea[1] * m_dpy + ea[2] * m_dpz;
Q = mat3dd(0);
}
else if (m_bdy) {
P = mat3dd(1) - dyad(ea[2]);
p = ea[1] * m_dpy;
Q = ((ea[2] & d) + mat3dd(1) * (ea[2] * d)) * eathat[2];
}
else if (m_bdz) {
P = mat3dd(1) - dyad(ea[1]);
p = ea[2] * m_dpz;
Q = ((ea[1] & d) + mat3dd(1) * (ea[1] * d)) * eathat[1];
}
else {
P = dyad(ea[0]);
p = vec3d(0, 0, 0);
Q = ((ea[0] & d) + mat3dd(1) * (ea[0] * d)) * eathat[0] * (-1);
}
vec3d c = P * d - p;
m_F = m_L + c * m_eps;
vec3d ksi;
if (m_bqx) {
quatd q = (alpha * RBb.GetRotation() + (1 - alpha) * RBb.m_qp) * (alpha * RBa.GetRotation() + (1 - alpha) * RBa.m_qp).Inverse();
quatd a(m_qpx, ea[0]);
quatd r = a * q.Inverse();
r.MakeUnit();
ksi = r.GetVector() * r.GetAngle();
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;
}
else
{
ksi = (ea[0] ^ eb[0]) / 2;
Wba = (ebhat[0] * eathat[0]) / 2;
Wab = (eahat[0] * ebthat[0]) / 2;
}
m_M = m_U + ksi * m_ups;
mat3da Fhat(m_F);
mat3d K;
// (1,1)
K = P*(alpha*m_eps);
ke[0][0] = K[0][0]; ke[0][1] = K[0][1]; ke[0][2] = K[0][2];
ke[1][0] = K[1][0]; ke[1][1] = K[1][1]; ke[1][2] = K[1][2];
ke[2][0] = K[2][0]; ke[2][1] = K[2][1]; ke[2][2] = K[2][2];
// (1,2)
K = (P*zathat+Q)*(-m_eps*alpha);
ke[0][3] = K[0][0]; ke[0][4] = K[0][1]; ke[0][5] = K[0][2];
ke[1][3] = K[1][0]; ke[1][4] = K[1][1]; ke[1][5] = K[1][2];
ke[2][3] = K[2][0]; ke[2][4] = K[2][1]; ke[2][5] = K[2][2];
// (1,3)
K = P*(-alpha*m_eps);
ke[0][6] = K[0][0]; ke[0][7] = K[0][1]; ke[0][8] = K[0][2];
ke[1][6] = K[1][0]; ke[1][7] = K[1][1]; ke[1][8] = K[1][2];
ke[2][6] = K[2][0]; ke[2][7] = K[2][1]; ke[2][8] = K[2][2];
// (1,4)
K = P*zbthat*(alpha*m_eps);
ke[0][9] = K[0][0]; ke[0][10] = K[0][1]; ke[0][11] = K[0][2];
ke[1][9] = K[1][0]; ke[1][10] = K[1][1]; ke[1][11] = K[1][2];
ke[2][9] = K[2][0]; ke[2][10] = K[2][1]; ke[2][11] = K[2][2];
// (2,1)
K = zahat*P*(alpha*m_eps);
ke[3][0] = K[0][0]; ke[3][1] = K[0][1]; ke[3][2] = K[0][2];
ke[4][0] = K[1][0]; ke[4][1] = K[1][1]; ke[4][2] = K[1][2];
ke[5][0] = K[2][0]; ke[5][1] = K[2][1]; ke[5][2] = K[2][2];
// (2,2)
K = (zahat * (P * zathat + Q) * m_eps + Fhat * zathat + Wba * m_ups) * (-alpha);
ke[3][3] = K[0][0]; ke[3][4] = K[0][1]; ke[3][5] = K[0][2];
ke[4][3] = K[1][0]; ke[4][4] = K[1][1]; ke[4][5] = K[1][2];
ke[5][3] = K[2][0]; ke[5][4] = K[2][1]; ke[5][5] = K[2][2];
// (2,3)
K = zahat*P*(-alpha*m_eps);
ke[3][6] = K[0][0]; ke[3][7] = K[0][1]; ke[3][8] = K[0][2];
ke[4][6] = K[1][0]; ke[4][7] = K[1][1]; ke[4][8] = K[1][2];
ke[5][6] = K[2][0]; ke[5][7] = K[2][1]; ke[5][8] = K[2][2];
// (2,4)
K = (zahat*P*zbthat*m_eps + Wab*m_ups)*alpha;
ke[3][9] = K[0][0]; ke[3][10] = K[0][1]; ke[3][11] = K[0][2];
ke[4][9] = K[1][0]; ke[4][10] = K[1][1]; ke[4][11] = K[1][2];
ke[5][9] = K[2][0]; ke[5][10] = K[2][1]; ke[5][11] = K[2][2];
// (3,1)
K = P*(-alpha*m_eps);
ke[6][0] = K[0][0]; ke[6][1] = K[0][1]; ke[6][2] = K[0][2];
ke[7][0] = K[1][0]; ke[7][1] = K[1][1]; ke[7][2] = K[1][2];
ke[8][0] = K[2][0]; ke[8][1] = K[2][1]; ke[8][2] = K[2][2];
// (3,2)
K = (P*zathat+Q)*(m_eps*alpha);
ke[6][3] = K[0][0]; ke[6][4] = K[0][1]; ke[6][5] = K[0][2];
ke[7][3] = K[1][0]; ke[7][4] = K[1][1]; ke[7][5] = K[1][2];
ke[8][3] = K[2][0]; ke[8][4] = K[2][1]; ke[8][5] = K[2][2];
// (3,3)
K = P*(alpha*m_eps);
ke[6][6] = K[0][0]; ke[6][7] = K[0][1]; ke[6][8] = K[0][2];
ke[7][6] = K[1][0]; ke[7][7] = K[1][1]; ke[7][8] = K[1][2];
ke[8][6] = K[2][0]; ke[8][7] = K[2][1]; ke[8][8] = K[2][2];
// (3,4)
K = P*zbthat*(-alpha*m_eps);
ke[6][9] = K[0][0]; ke[6][10] = K[0][1]; ke[6][11] = K[0][2];
ke[7][9] = K[1][0]; ke[7][10] = K[1][1]; ke[7][11] = K[1][2];
ke[8][9] = K[2][0]; ke[8][10] = K[2][1]; ke[8][11] = K[2][2];
// (4,1)
K = zbhat*P*(-alpha*m_eps);
ke[9 ][0] = K[0][0]; ke[ 9][1] = K[0][1]; ke[ 9][2] = K[0][2];
ke[10][0] = K[1][0]; ke[10][1] = K[1][1]; ke[10][2] = K[1][2];
ke[11][0] = K[2][0]; ke[11][1] = K[2][1]; ke[11][2] = K[2][2];
// (4,2)
K = (zbhat*(P*zathat+Q)*m_eps + Wba*m_ups)*alpha;
ke[9 ][3] = K[0][0]; ke[ 9][4] = K[0][1]; ke[ 9][5] = K[0][2];
ke[10][3] = K[1][0]; ke[10][4] = K[1][1]; ke[10][5] = K[1][2];
ke[11][3] = K[2][0]; ke[11][4] = K[2][1]; ke[11][5] = K[2][2];
// (4,3)
K = zbhat * P * (alpha * m_eps);
ke[9 ][6] = K[0][0]; ke[ 9][7] = K[0][1]; ke[ 9][8] = K[0][2];
ke[10][6] = K[1][0]; ke[10][7] = K[1][1]; ke[10][8] = K[1][2];
ke[11][6] = K[2][0]; ke[11][7] = K[2][1]; ke[11][8] = K[2][2];
// (4,4)
K = (zbhat*P*zbthat*m_eps - Fhat * zbthat + Wab * m_ups) * (-alpha);
ke[9 ][9] = K[0][0]; ke[ 9][10] = K[0][1]; ke[ 9][11] = K[0][2];
ke[10][9] = K[1][0]; ke[10][10] = K[1][1]; ke[10][11] = K[1][2];
ke[11][9] = K[2][0]; ke[11][10] = K[2][1]; ke[11][11] = K[2][2];
for (int j = 0; j < 6; ++j)
{
LM[j] = RBa.m_LM[j];
LM[j + 6] = RBb.m_LM[j];
}
ke.SetIndices(LM);
LS.Assemble(ke);
}
else
{
dd::vec3d pa(ra);
dd::quatd qa(Qat);
dd::vec3d pb(rb);
dd::quatd qb(Qbt);
dd::vec3d lam(m_F);
dd::vec3d mu(m_M);
auto F = [&]() {
dd::vec3d a = qa * m_ea0[0];
return a*(a*lam);
};
auto c = [&]() {
dd::vec3d za = qa * m_qa0;
dd::vec3d zb = qb * m_qb0;
dd::vec3d d = pb + zb - pa - za;
dd::vec3d a = qa * m_ea0[0];
return a * (d * a);
};
auto m1 = [&]() {
dd::vec3d a = qa * m_ea0[0];
dd::vec3d b = qb * m_eb0[0];
return b - a;
};
auto Ma = [&] {
dd::vec3d za = qa * m_qa0;
dd::vec3d ea = qa * m_ea0[0];
dd::vec3d d = pb + zb - pa - za;
dd::vec3d F = ea * (lam * ea);
return (za ^ F) - (ea ^ (d*(ea*lam) + lam*(ea*d))) + (ea ^ mu);
};
auto Mb = [&] {
dd::vec3d zb = qb * m_qb0;
dd::vec3d ea = qa * m_ea0[0];
dd::vec3d eb = qb * m_eb0[0];
dd::vec3d F = ea * (lam * ea);
return (zb ^ F) + (eb ^ mu);
};
mat3d K00 = -dd::D( F, pa);
mat3d K10 = -dd::D(Ma, pa);
mat3d K20 = dd::D( F, pa);
mat3d K30 = dd::D(Mb, pa);
mat3d K40 = dd::D( c, pa);
mat3d K50 = dd::D(m1, pa);
mat3d K01 = -dd::D( F, qa);
mat3d K11 = -dd::D(Ma, qa);
mat3d K21 = dd::D( F, qa);
mat3d K31 = dd::D(Mb, qa);
mat3d K41 = dd::D( c, qa);
mat3d K51 = dd::D(m1, qa);
mat3d K02 = -dd::D( F, pb);
mat3d K12 = -dd::D(Ma, pb);
mat3d K22 = dd::D( F, pb);
mat3d K32 = dd::D(Mb, pb);
mat3d K42 = dd::D( c, pb);
mat3d K52 = dd::D(m1, pb);
mat3d K03 = -dd::D( F, qb);
mat3d K13 = -dd::D(Ma, qb);
mat3d K23 = dd::D( F, qb);
mat3d K33 = dd::D(Mb, qb);
mat3d K43 = dd::D( c, qb);
mat3d K53 = dd::D(m1, qb);
mat3d K04 = -dd::D( F, lam);
mat3d K14 = -dd::D(Ma, lam);
mat3d K24 = dd::D( F, lam);
mat3d K34 = dd::D(Mb, lam);
mat3d K44 = dd::D( c, lam);
mat3d K54 = dd::D(m1, lam);
mat3d K05 = -dd::D( F, mu);
mat3d K15 = -dd::D(Ma, mu);
mat3d K25 = dd::D( F, mu);
mat3d K35 = dd::D(Mb, mu);
mat3d K45 = dd::D( c, mu);
mat3d K55 = dd::D(m1, mu);
matrix kd(18, 18); kd.zero();
kd.sub( 0, 0, K00); kd.sub( 0, 3, K01); kd.sub( 0, 6, K02); kd.sub( 0, 9, K03); kd.sub( 0, 12, K04); kd.sub( 0, 15, K05);
kd.sub( 3, 0, K10); kd.sub( 3, 3, K11); kd.sub( 3, 6, K12); kd.sub( 3, 9, K13); kd.sub( 3, 12, K14); kd.sub( 3, 15, K15);
kd.sub( 6, 0, K20); kd.sub( 6, 3, K21); kd.sub( 6, 6, K22); kd.sub( 6, 9, K23); kd.sub( 6, 12, K24); kd.sub( 6, 15, K25);
kd.sub( 9, 0, K30); kd.sub( 9, 3, K31); kd.sub( 9, 6, K32); kd.sub( 9, 9, K33); kd.sub( 9, 12, K34); kd.sub( 9, 15, K35);
kd.sub(12, 0, K40); kd.sub(12, 3, K41); kd.sub(12, 6, K42); kd.sub(12, 9, K43); kd.sub(12, 12, K44); kd.sub(12, 15, K45);
kd.sub(15, 0, K50); kd.sub(15, 3, K51); kd.sub(15, 6, K52); kd.sub(15, 9, K53); kd.sub(15, 12, K54); kd.sub(15, 15, K55);
FEElementMatrix ke(18, 18);
ke = kd;
vector<int> LM(18);
UnpackLM(LM);
ke.SetIndices(LM);
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
bool FERigidPlanarJoint::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;
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
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);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
mat3ds P;
vec3d p;
if (m_bdy && m_bdz) {
P = mat3dd(1);
p = ea[1]*m_dpy + ea[2]*m_dpz;
}
else if (m_bdy) {
P = mat3dd(1) - dyad(ea[2]);
p = ea[1]*m_dpy;
}
else if (m_bdz) {
P = mat3dd(1) - dyad(ea[1]);
p = ea[2]*m_dpz;
}
else {
P = dyad(ea[0]);
p = vec3d(0, 0, 0);
}
c = P*(rb + zb - ra - za) - p;
if (m_bqx) {
quatd q = (alpha*RBb.GetRotation() + (1 - alpha)*RBb.m_qp)*(alpha*RBa.GetRotation() + (1 - alpha)*RBa.m_qp).Inverse();
quatd a(m_qpx,ea[0]);
quatd r = a*q.Inverse();
r.MakeUnit();
ksi = r.GetVector()*r.GetAngle();
}
else
{
ksi = (ea[0] ^ eb[0])/2;
}
normF0 = sqrt(m_L*m_L);
// calculate trial multiplier
Lm = m_L + c*m_eps;
normF1 = sqrt(Lm*Lm);
normM0 = sqrt(m_U*m_U);
// calculate trial multiplier
Um = m_U + ksi*m_ups;
normM1 = sqrt(Um*Um);
// check convergence of constraints
feLog(" rigid connector # %d (planar 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);
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 && ((pctn >= m_atol) || (qctn >= m_atol))) bconv = false;
if (m_gtol && (gap >= m_gtol)) 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 FERigidPlanarJoint::Update()
{
if (m_laugon == FECore::LAGMULT_METHOD) return;
vec3d ra, rb;
vec3d za, zb;
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
const FETimeInfo& tp = GetTimeInfo();
double alpha = tp.alphaf;
ra = RBa.m_rt*alpha + RBa.m_rp*(1-alpha);
rb = RBb.m_rt*alpha + RBb.m_rp*(1-alpha);
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
za = zat*alpha + zap*(1-alpha);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
mat3ds P;
vec3d p;
if (m_bdy && m_bdz) {
P = mat3dd(1);
p = ea[1]*m_dpy + ea[2]*m_dpz;
}
else if (m_bdy) {
P = mat3dd(1) - dyad(ea[2]);
p = ea[1]*m_dpy;
}
else if (m_bdz) {
P = mat3dd(1) - dyad(ea[1]);
p = ea[2]*m_dpz;
}
else {
P = dyad(ea[0]);
p = vec3d(0, 0, 0);
}
vec3d c = P*(rb + zb - ra - za) - p;
m_F = m_L + c*m_eps;
vec3d ksi;
if (m_bqx) {
quatd q = (alpha*RBb.GetRotation() + (1 - alpha)*RBb.m_qp)*(alpha*RBa.GetRotation() + (1 - alpha)*RBa.m_qp).Inverse();
quatd a(m_qpx,ea[0]);
quatd r = a*q.Inverse();
r.MakeUnit();
ksi = r.GetVector()*r.GetAngle();
}
else
{
ksi = (ea[0] ^ eb[0])/2;
}
m_M = m_U + ksi*m_ups;
}
//-----------------------------------------------------------------------------
void FERigidPlanarJoint::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;
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];
}
//-----------------------------------------------------------------------------
vec3d FERigidPlanarJoint::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 FERigidPlanarJoint::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 FERigidPlanarJoint::InitEquations(int neq)
{
const int LMeq = 6;
m_LM.resize(LMeq, -1);
if (m_laugon == FECore::LAGMULT_METHOD)
{
for (int i = 0; i < LMeq; ++i) m_LM[i] = neq + i;
return LMeq;
}
else return 0;
}
// Build the matrix profile
void FERigidPlanarJoint::BuildMatrixProfile(FEGlobalMatrix& M)
{
vector<int> lm;
UnpackLM(lm);
// add it to the pile
M.build_add(lm);
}
void FERigidPlanarJoint::UnpackLM(vector<int>& lm)
{
// add the dofs of rigid body A
lm.resize(18);
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 FERigidPlanarJoint::PrepStep()
{
m_Fp = m_F;
m_Mp = m_M;
}
void FERigidPlanarJoint::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]];
m_M.x = m_Mp.x + Ui[m_LM[3]] + ui[m_LM[3]];
m_M.y = m_Mp.y + Ui[m_LM[4]] + ui[m_LM[4]];
m_M.z = m_Mp.z + Ui[m_LM[5]] + ui[m_LM[5]];
}
}
void FERigidPlanarJoint::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]];
Ui[m_LM[3]] += ui[m_LM[3]];
Ui[m_LM[4]] += ui[m_LM[4]];
Ui[m_LM[5]] += ui[m_LM[5]];
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FETrussMaterial.cpp | .cpp | 3,151 | 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.*/
#include "stdafx.h"
#include "FETrussMaterial.h"
// define the material parameters
BEGIN_FECORE_CLASS(FETrussMaterial, FEMaterial)
ADD_PARAMETER(m_rho, FE_RANGE_GREATER(0.0), "density");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FETrussMaterial::FETrussMaterial(FEModel* pfem) : FEMaterial(pfem)
{
m_rho = 1.0;
AddDomainParameter(new FETrussStress());
}
//-----------------------------------------------------------------------------
FETrussMaterial::~FETrussMaterial()
{
}
//-----------------------------------------------------------------------------
//! material density
double FETrussMaterial::Density()
{
return m_rho;
}
//=============================================================================
// define the material parameters
BEGIN_FECORE_CLASS(FELinearTrussMaterial, FETrussMaterial)
ADD_PARAMETER(m_E, FE_RANGE_GREATER(0.0), "E")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_v, FE_RANGE_CLOSED(-1, 0.5), "v");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FELinearTrussMaterial::FELinearTrussMaterial(FEModel* fem) : FETrussMaterial(fem)
{
m_E = 0.0;
m_v = 0.5;
}
//-----------------------------------------------------------------------------
// Note that this function returns the Kirchhoff stress!
double FELinearTrussMaterial::Stress(FEMaterialPoint &mp)
{
FETrussMaterialPoint& pt = *mp.ExtractData<FETrussMaterialPoint>();
return m_E*log(pt.m_lam);
}
//-----------------------------------------------------------------------------
double FELinearTrussMaterial::Tangent(FEMaterialPoint &pt)
{
return m_E;
}
FETrussStress::FETrussStress() : FEDomainParameter("stress") {}
FEParamValue FETrussStress::value(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
return pt.m_s;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEEFDDonnanEquilibrium.h | .h | 2,502 | 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 "FECore/FEMaterial.h"
#include "FEDonnanEquilibrium.h"
#include "FEEllipsoidalFiberDistribution.h"
//-----------------------------------------------------------------------------
//! This class implements a material that consists of a continuous ellipsoidal fiber distribution
//! superposed on a charged (swelling) gel described by the equations of Donnan equilibrium
class FEEFDDonnanEquilibrium : public FEElasticMaterial
{
public:
FEEFDDonnanEquilibrium(FEModel* pfem) : FEElasticMaterial(pfem), m_Fib(pfem), m_DEQ(pfem) {}
public:
//! calculate stress at material point
virtual mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
virtual tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
virtual double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! material parameter intialization and checking
bool Init() override;
//! serialization
void Serialize(DumpStream& ar) override;
public:
// FEEllipsoidalFiberDistribution m_Fib;
FEEllipsoidalFiberDistributionOld m_Fib;
FEDonnanEquilibrium m_DEQ;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberExpLinear.h | .h | 2,625 | 69 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticFiberMaterial.h"
#include "FEFiberMaterial.h"
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! This class represents a fiber material with an exponential toe-region
//! and a linear region.
class FEFiberExpLinear : public FEFiberMaterial
{
public:
//! constructor
FEFiberExpLinear(FEModel* pfem);
//! Calculate the fiber stress
mat3ds FiberStress(FEMaterialPoint& mp, const vec3d& a0) override;
//! Calculate the fiber tangent
tens4ds FiberTangent(FEMaterialPoint& mp, const vec3d& a0) override;
//! Calculate the fiber strain energy density
double FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) 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
double m_epsf;
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
class FEElasticFiberExpLinear : public FEElasticFiberMaterial_T<FEFiberExpLinear>
{
public:
FEElasticFiberExpLinear(FEModel* fem) : FEElasticFiberMaterial_T<FEFiberExpLinear>(fem) {}
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEContinuousElasticDamage.cpp | .cpp | 17,577 | 643 | /*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 "FEContinuousElasticDamage.h"
#include <FECore/log.h>
#include <FECore/expint_Ei.h>
// Macauley Bracket
#define MB(a) ((a)>0.0?(a):0.0)
#define SIGN(a) ((a)>0.0?1.0:0.0)
//=========================================================================================
class FEFiberDamagePoint : public FEMaterialPointData
{
public:
FEFiberDamagePoint(FEMaterialPointData* pm) : FEMaterialPointData(pm)
{
m_D = 0.0;
m_D1 = m_D2 = m_D3 = 0.0;
m_P = 0.0;
m_Ds = 0.0;
m_psi_f0_ini = 0.0;
m_psi_f0 = 0.0;
m_psi_f0_prev = 0.0;
m_bt_ini = 0.0;
m_bt = 0.0;
m_bt_prev = 0.0;
m_gamma = 0.0;
m_gamma_prev = 0.0;
m_psf_c = 0.0;
m_init = false;
}
void Init() override
{
m_D = 0.0;
m_D1 = m_D2 = m_D2f = m_D3 = 0.0;
m_P = 0.0;
m_Ds = 0.0;
m_psi_f0_ini = m_psf_c;// we set this to the initial value
m_psi_f0 = m_psf_c; // we set this to the initial value
m_psi_f0_prev = m_psf_c; // we set this to the initial value
m_bt_ini = 0.0;
m_bt = 0.0;
m_bt_prev = 0.0;
m_beta = 0.0;
m_gamma = 0.0;
m_gamma_prev = 0.0;
m_init = false;
FEMaterialPointData::Init();
}
void Update(const FETimeInfo& timeInfo) override
{
m_gamma_prev = m_gamma;
m_bt_prev = m_bt;
m_psi_f0_prev = m_psi_f0;
FEMaterialPointData::Update(timeInfo);
}
public:
bool m_init; // initialization flag
double m_D; // accumulated damage
double m_D1, m_D2, m_D2f, m_D3; // damage components
double m_P, m_Ds;
double m_psi_f0_ini, m_psf_c;
double m_psi_f0, m_psi_f0_prev;
double m_bt_ini;
double m_bt, m_bt_prev, m_beta;
double m_gamma, m_gamma_prev;
};
//=========================================================================================
BEGIN_FECORE_CLASS(FEDamageElasticFiber, FEElasticFiberMaterial)
ADD_PARAMETER(m_tinit, FE_RANGE_GREATER_OR_EQUAL(0.0), "t0");
ADD_PARAMETER(m_Dmax, FE_RANGE_CLOSED(0.0, 1.0), "Dmax");
ADD_PARAMETER(m_beta_s, FE_RANGE_GREATER(0.0), "beta_s");
ADD_PARAMETER(m_gamma_max, FE_RANGE_GREATER_OR_EQUAL(0.0), "gamma_max");
ADD_PARAMETER(m_D2_a, "D2_a");
ADD_PARAMETER(m_D2_b, "D2_b");
ADD_PARAMETER(m_D2_c, "D2_c");
ADD_PARAMETER(m_D2_d, "D2_d");
ADD_PARAMETER(m_D3_inf, "D3_inf");
ADD_PARAMETER(m_D3_g0, "D3_g0");
ADD_PARAMETER(m_D3_rg, "D3_rg");
END_FECORE_CLASS();
FEDamageElasticFiber::FEDamageElasticFiber(FEModel* fem) : FEElasticFiberMaterial(fem)
{
m_tinit = 1e9; // large value so, no damage accumulation by default
m_Dmax = 1.0;
m_beta_s = 0.0;
m_gamma_max = 0.0;
// Looks like these are hard-coded
m_r_s = 0.99;
m_r_inf = 0.99;
// initial values for D2 term
m_D2_a = 0.0;
m_D2_b = 0.0;
m_D2_c = 0.0;
m_D2_d = 0.0;
m_D3_inf = 0.0;
m_D3_g0 = 0.0;
m_D3_rg = 1.0;
}
double FEDamageElasticFiber::Damage(FEMaterialPoint& mp)
{
FEFiberDamagePoint& damagePoint = *mp.ExtractData<FEFiberDamagePoint>();
return damagePoint.m_D;
}
double FEDamageElasticFiber::Damage(FEMaterialPoint& mp, int n)
{
FEFiberDamagePoint& damagePoint = *mp.ExtractData<FEFiberDamagePoint>();
switch (n)
{
case 0: return damagePoint.m_D; break;
case 1: return damagePoint.m_D1; break;
case 2: return damagePoint.m_Ds; break;
case 3: return damagePoint.m_D2; break;
case 4: return damagePoint.m_D3; break;
case 5: return damagePoint.m_P; break;
case 6: return damagePoint.m_psi_f0; break;
case 7: return damagePoint.m_beta; break;
case 8: return damagePoint.m_gamma; break;
case 9: return damagePoint.m_D2f; break;
}
return 0.0;
}
//! Strain energy density
double FEDamageElasticFiber::FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEFiberDamagePoint& damagePoint = *mp.ExtractData<FEFiberDamagePoint>();
double D = damagePoint.m_D;
double psi0 = Psi0(mp, a0);
double P = (1.0 - D)*psi0 - damagePoint.m_psf_c;
if (P < 0) P = 0;
double psi = m(P);
return psi;
}
// calculate stress in fiber direction a0
mat3ds FEDamageElasticFiber::FiberStress(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEFiberDamagePoint& damagePoint = *mp.ExtractData<FEFiberDamagePoint>();
mat3d F = pt.m_F;
// get internal variables
double D = damagePoint.m_D;
double bt_prev = damagePoint.m_bt_prev;
double psi_f0_prev = damagePoint.m_psi_f0_prev;
double gamma_prev = damagePoint.m_gamma_prev;
damagePoint.m_D1 = 0.0;
damagePoint.m_D2 = 0.0;
damagePoint.m_D2f = 0.0;
damagePoint.m_D3 = 0.0;
damagePoint.m_P = 0.0;
damagePoint.m_Ds = 0.0;
// get current simulation time.
double t = CurrentTime();
// (i) compute trans-iso strain energy
double psi_f0 = Psi0(mp, a0);
// (ii) check initial damage state
double eps = 1e-9; // NOTE: should be machine eps
if (t >= (m_tinit - eps))
{
// (b) compute bt
double bt = bt_prev + MB(psi_f0 - psi_f0_prev);
// init damage
if (damagePoint.m_init == false)
{
damagePoint.m_psi_f0_ini = psi_f0;
damagePoint.m_bt_ini = bt;
damagePoint.m_init = true;
}
// (iii) calculate max damage saturation value
// trial criterion
double phi_trial = MB(psi_f0 - damagePoint.m_psi_f0_ini) - gamma_prev;
// check algorithmic saturation criterion
double gamma = 0;
if (phi_trial > eps) gamma = MB(psi_f0 - damagePoint.m_psi_f0_ini);
else gamma = gamma_prev;
assert(gamma >= gamma_prev);
// compute damage saturation value
double Ds = (m_gamma_max == 0.0 ? m_Dmax : m_Dmax * (1.0 - exp(log(1.0 - m_r_inf)*gamma / m_gamma_max)));
// (iv) compute internal variable
double beta = MB(bt - damagePoint.m_bt_ini);
// (v) evaluate damage function
double D1 = Ds * (1.0 - exp(log(1.0 - m_r_s)*beta / m_beta_s));
// D2 term
double D3 = (m_D3_rg != 0 ? m_D3_inf / (1.0 + exp(-(gamma - m_D3_g0) / m_D3_rg)) : m_D3_inf);
double D2f = (m_D2_a*(exp(m_D2_b*beta) - 1) + m_D2_c*(exp(m_D2_d*beta) - 1));
double D2 = D3*D2f;
// Add the damage
D = D1 + D2;
// update internal variables
damagePoint.m_D = D;
damagePoint.m_D1 = D1;
damagePoint.m_Ds = Ds;
damagePoint.m_D2 = D2;
damagePoint.m_D2f = D2f;
damagePoint.m_D3 = D3;
damagePoint.m_bt = bt;
damagePoint.m_psi_f0 = psi_f0;
damagePoint.m_beta = beta;
damagePoint.m_gamma = gamma;
}
double P = (1.0 - D)*(psi_f0) - damagePoint.m_psf_c;
damagePoint.m_P = P;
if (P < 0.0) P = 0.0;
double dm = dm_dP(P);
mat3ds S0 = dPsi0_dC(mp, a0)*2.0;
mat3ds s0 = pt.push_forward(S0);
mat3ds s = s0*(dm*(1.0 - D));
return s;
}
// Spatial tangent
tens4ds FEDamageElasticFiber::FiberTangent(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEFiberDamagePoint& damagePoint = *mp.ExtractData<FEFiberDamagePoint>();
mat3d F = pt.m_F;
double J = pt.m_J;
double D = damagePoint.m_D;
double psi0 = Psi0(mp, a0);
double P = (1.0 - D)*(psi0)-damagePoint.m_psf_c;
if (P < 0) P = 0.0;
double dm = dm_dP(P);
double d2m = d2m_dP(P);
mat3ds S0 = dPsi0_dC(mp, a0)*2.0;
mat3ds s0 = pt.push_forward(S0);
tens4ds sxs = dyad1s(s0);
// elastic stiffness
tens4ds C0 = d2Psi0_dC(mp, a0)*2.0;
tens4ds c0 = pt.push_forward(C0);
tens4ds ceD = sxs * (J*d2m*(1.0 - D)) + c0 * ((1.0 - D)*dm);
tens4ds c = ceD;
// damage stiffness
double bt = damagePoint.m_bt;
double gamma = damagePoint.m_gamma;
double Ds = (m_gamma_max == 0.0 ? m_Dmax : m_Dmax * (1.0 - exp(log(1.0 - m_r_inf)*gamma / m_gamma_max)));
double beta = MB(bt - damagePoint.m_bt_ini);
double psi0_prev = damagePoint.m_psi_f0_prev;
double psi0_ini = damagePoint.m_psi_f0_ini;
double gamma_prev = damagePoint.m_gamma_prev;
double dD1_dbeta = -Ds * (log(1 - m_r_s) / m_beta_s)*exp(log(1 - m_r_s)*beta / m_beta_s);
double D3 = (m_D3_rg != 0 ? m_D3_inf / (1.0 + exp(-(gamma - m_D3_g0) / m_D3_rg)) : m_D3_inf);
double dD2_dD3 = m_D2_a * (exp(m_D2_b * beta) - 1) + m_D2_c * (exp(m_D2_d * beta) - 1);
double dD2_dbeta = D3 * (m_D2_a*m_D2_b*exp(m_D2_b*beta) + m_D2_c * m_D2_d * exp(m_D2_d * beta));
double dD3_dgamma = 0.0;
if (m_D3_rg != 0)
{
double D3_exp = exp(-(gamma - m_D3_g0) / m_D3_rg);
dD3_dgamma = m_D3_inf * (D3_exp / m_D3_rg) / ((1.0 + D3_exp) * (1.0 + D3_exp));
}
double dD_dbeta = dD1_dbeta + dD2_dbeta;
double dDs_dgamma = (m_gamma_max ==0.0 ? 0.0 : -m_Dmax * (log(1 - m_r_inf) / m_gamma_max)*exp(log(1 - m_r_inf)*gamma / m_gamma_max));
double dD_dDs = 1.0 - exp(log(1 - m_r_s)*beta / m_beta_s);
double dbeta_dpsi0 = 0.25*(SIGN(bt - damagePoint.m_bt_ini) + 1)*(SIGN(psi0 - psi0_prev) + 1);
double dgamma_dpsi0 = 0.5*(SIGN(psi0 - psi0_ini) + 1);
double meps = 1e-9; // NOTE: should be machine eps
if (psi0 - psi0_prev > meps)
{
tens4ds Cd = sxs * ((dm + d2m * (1 - D)*psi0)*dD_dbeta*dbeta_dpsi0);
c -= Cd;
}
double phi_trial = MB(psi0 - damagePoint.m_psi_f0_ini) - gamma_prev;
if (phi_trial > meps)
{
tens4ds Cd = sxs * ((dm + d2m * (1 - D)*psi0)*(dD_dDs*dDs_dgamma + dD2_dD3 * dD3_dgamma)*dgamma_dpsi0);
c -= Cd;
}
return c;
}
double FEDamageElasticFiber::Psi0(FEMaterialPoint& mp, const vec3d& a0) { return 0.0; }
mat3ds FEDamageElasticFiber::dPsi0_dC(FEMaterialPoint& mp, const vec3d& a0) { return mat3ds(0.0); }
tens4ds FEDamageElasticFiber::d2Psi0_dC(FEMaterialPoint& mp, const vec3d& a0) { return tens4ds(0.0); }
double FEDamageElasticFiber::m(double P) { return 0.0; }
double FEDamageElasticFiber::dm_dP(double P) { return 0.0; }
double FEDamageElasticFiber::d2m_dP(double P) { return 0.0; }
//=================================================================================================
BEGIN_FECORE_CLASS(FEDamageFiberPower, FEDamageElasticFiber)
ADD_PARAMETER(m_a1, FE_RANGE_GREATER_OR_EQUAL(0.0), "a1");
ADD_PARAMETER(m_a2, FE_RANGE_GREATER(1.0), "a2");
ADD_PARAMETER(m_kappa, FE_RANGE_CLOSED(0.0, 2.0/3.0), "kappa");
END_FECORE_CLASS();
FEDamageFiberPower::FEDamageFiberPower(FEModel* fem) : FEDamageElasticFiber(fem)
{
m_a1 = 0.0;
m_a2 = 0.0;
m_kappa = 0.0;
}
FEMaterialPointData* FEDamageFiberPower::CreateMaterialPointData()
{
FEFiberDamagePoint* mp = new FEFiberDamagePoint(new FEElasticMaterialPoint);
mp->m_psf_c = 2.0;
return mp;
}
double FEDamageFiberPower::Psi0(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds C = pt.RightCauchyGreen();
mat3ds C2 = C.sqr();
double I1 = C.tr();
double I4 = a0 * (C*a0);
double I5 = a0 * (C2*a0);
double K3 = I1 * I4 - I5;
double Psi0 = m_kappa * I1 + (1.0 - 3.0*m_kappa / 2.0)*K3;
return Psi0;
}
mat3ds FEDamageFiberPower::dPsi0_dC(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d F = pt.m_F;
mat3ds C = pt.RightCauchyGreen();
mat3ds C2 = C.sqr();
mat3ds b = pt.LeftCauchyGreen();
double I1 = C.tr();
double I4 = a0 * (C *a0);
double I5 = a0 * (C2*a0);
double K3 = I1 * I4 - I5;
double k = 1.0 - 3.0*m_kappa / 2.0;
mat3dd I(1.0);
mat3ds M = dyad(a0);
mat3ds ACA = dyads(a0, C*a0);
mat3ds T = I * I4 + M * I1 - ACA;
mat3ds S0 = I*m_kappa + T * k;
return S0;
}
tens4ds FEDamageFiberPower::d2Psi0_dC(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEFiberDamagePoint& damagePoint = *mp.ExtractData<FEFiberDamagePoint>();
double k = 1.0 - 3.0*m_kappa / 2.0;
mat3ds M = dyad(a0);
mat3dd I(1.0);
tens4ds AIA = dyad4s(a0, I, a0)*(2.0);
tens4ds IoM = dyad1s(I, M);
tens4ds c0 = (IoM - AIA)*k;
return c0;
}
double FEDamageFiberPower::m(double P)
{
return m_a1 * pow(P, m_a2);
}
double FEDamageFiberPower::dm_dP(double P)
{
return m_a1 * m_a2*pow(P, m_a2 - 1.0);
}
double FEDamageFiberPower::d2m_dP(double P)
{
return m_a1 * m_a2*(m_a2 - 1.0)*pow(P, m_a2 - 2.0);
}
//=================================================================================================
BEGIN_FECORE_CLASS(FEDamageFiberExponential, FEDamageElasticFiber)
ADD_PARAMETER(m_k1, FE_RANGE_GREATER_OR_EQUAL(0.0), "k1");
ADD_PARAMETER(m_k2, FE_RANGE_GREATER(0.0), "k2");
ADD_PARAMETER(m_kappa, FE_RANGE_CLOSED(0.0, 1.0/3.0), "kappa");
END_FECORE_CLASS();
FEDamageFiberExponential::FEDamageFiberExponential(FEModel* fem) : FEDamageElasticFiber(fem)
{
m_k1 = 0.0;
m_k2 = 0.0;
m_kappa = 0.0;
}
FEMaterialPointData* FEDamageFiberExponential::CreateMaterialPointData()
{
FEFiberDamagePoint* mp = new FEFiberDamagePoint(new FEElasticMaterialPoint);
mp->m_psf_c = 1.0;
return mp;
}
//! Strain energy density
double FEDamageFiberExponential::Psi0(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds C = pt.RightCauchyGreen();
double I1 = C.tr();
double I4 = a0 * (C*a0);
double psi0 = m_kappa * I1 + (1.0 - 3.0*m_kappa)*I4;
return psi0;
}
// calculate stress in fiber direction a0
mat3ds FEDamageFiberExponential::dPsi0_dC(FEMaterialPoint& mp, const vec3d& a0)
{
double k = 1.0 - 3.0*m_kappa;
mat3dd I(1.0);
mat3ds M = dyad(a0);
mat3ds S0 = (I*m_kappa + M*k);
return S0;
}
// Spatial tangent
tens4ds FEDamageFiberExponential::d2Psi0_dC(FEMaterialPoint& mp, const vec3d& a0)
{
tens4ds c0(0.0);
return c0;
}
double FEDamageFiberExponential::m(double P)
{
if (P <= 0) return 0;
return (0.5*m_k1 / m_k2)*(exp(m_k2*P*P) - 1);
}
double FEDamageFiberExponential::dm_dP(double P)
{
if (P <= 0) return 0;
return (m_k1 * P)*exp(m_k2*P*P);
}
double FEDamageFiberExponential::d2m_dP(double P)
{
if (P <= 0) return 0;
return m_k1*(1.0 + (2.0 * m_k2 * P * P))*exp(m_k2*P*P);
}
//=================================================================================================
BEGIN_FECORE_CLASS(FEDamageFiberExpLinear, FEDamageElasticFiber)
ADD_PARAMETER(m_c3, FE_RANGE_GREATER_OR_EQUAL(0.0), "c3");
ADD_PARAMETER(m_c4, FE_RANGE_GREATER_OR_EQUAL(0.0), "c4");
ADD_PARAMETER(m_c5, FE_RANGE_GREATER_OR_EQUAL(0.0), "c5");
ADD_PARAMETER(m_lamax, FE_RANGE_GREATER(0.0), "lambda");
END_FECORE_CLASS();
FEDamageFiberExpLinear::FEDamageFiberExpLinear(FEModel* fem) : FEDamageElasticFiber(fem)
{
m_c3 = 0.0;
m_c4 = 0.0;
m_c5 = 0.0;
m_lamax = 0.0;
}
FEMaterialPointData* FEDamageFiberExpLinear::CreateMaterialPointData()
{
FEFiberDamagePoint* mp = new FEFiberDamagePoint(new FEElasticMaterialPoint);
mp->m_psf_c = 1.0;
return mp;
}
double FEDamageFiberExpLinear::Psi0(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds C = pt.RightCauchyGreen();
double I4 = a0 * (C*a0);
double Psi0 = sqrt(I4);
return Psi0;
}
mat3ds FEDamageFiberExpLinear::dPsi0_dC(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds C = pt.RightCauchyGreen();
double I4 = a0 * (C*a0);
double l = sqrt(I4);
mat3ds M = dyad(a0);
mat3ds S0 = M * (0.5 / l);
return S0;
}
tens4ds FEDamageFiberExpLinear::d2Psi0_dC(FEMaterialPoint& mp, const vec3d& a0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds C = pt.RightCauchyGreen();
double I4 = a0 * (C*a0);
double l = sqrt(I4);
mat3ds M = dyad(a0);
tens4ds c0 = dyad1s(M)*( - 1.0 / (4.0*l*l*l));
return c0;
}
inline double Ei(double x) { return expint_Ei(x); }
double FEDamageFiberExpLinear::m(double P)
{
double m = 0.0;
double Pmax = m_lamax - 1.0;
if (P <= Pmax)
{
m = m_c3 * (exp(-m_c4)*(Ei(m_c4*(P+1.0)) - Ei(m_c4)) - log(P + 1));
}
else
{
double c6 = m_c3 * (exp(m_c4*Pmax) - 1) - (Pmax + 1.0) * m_c5;
// constant offset for ensuring continuity of strain-energy
double d0 = m_c3* (exp(-m_c4) * (Ei(m_c4 * (Pmax + 1.0)) - Ei(m_c4)) - log(Pmax + 1)) - m_c5 * Pmax - c6 * log(Pmax + 1.0);
m = m_c5 * P + c6 * log(P + 1.0) + d0;
}
return m;
}
double FEDamageFiberExpLinear::dm_dP(double P)
{
double dm = 0.0;
double Pmax = m_lamax - 1.0;
if (P <= Pmax)
{
dm = m_c3 * (exp(m_c4*P) - 1) / (P+1.0);
}
else
{
double c6 = m_c3 * (exp(m_c4*Pmax) - 1) - (Pmax + 1.0) * m_c5;
dm = m_c5 + c6 / (P + 1.0);
}
return dm;
}
double FEDamageFiberExpLinear::d2m_dP(double P)
{
double d2m = 0.0;
double Pmax = m_lamax - 1.0;
if (P <= Pmax)
{
double expP = exp(m_c4*P);
d2m = m_c3 * m_c4*expP / (P+1) - m_c3*(expP - 1) / ((P+1)*(P+1));
}
else
{
double c6 = m_c3 * (exp(m_c4*Pmax) - 1) - (Pmax + 1.0) * m_c5;
d2m = -c6 / ((P+1)*(P+1));
}
return d2m;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEReactiveFatigue.cpp | .cpp | 8,184 | 241 | /*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 "FEReactiveFatigue.h"
#include "FEDamageCriterion.h"
#include "FEDamageCDF.h"
#include "FEUncoupledMaterial.h"
#include <FECore/FECoreKernel.h>
#include <FECore/DumpStream.h>
#include <FECore/log.h>
#include <FECore/FEAnalysis.h>
#include <FECore/FEModel.h>
//////////////////////////// FATIGUE MATERIAL /////////////////////////////////
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEReactiveFatigue, FEElasticMaterial)
ADD_PARAMETER(m_k0 , FE_RANGE_GREATER_OR_EQUAL(0.0), "k0" );
ADD_PARAMETER(m_beta , FE_RANGE_GREATER_OR_EQUAL(0.0), "beta");
// set material properties
ADD_PROPERTY(m_pBase, "elastic");
ADD_PROPERTY(m_pIdmg, "elastic_damage");
ADD_PROPERTY(m_pFdmg, "fatigue_damage");
ADD_PROPERTY(m_pIcrt, "elastic_criterion");
ADD_PROPERTY(m_pFcrt, "fatigue_criterion");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
//! Constructor.
FEReactiveFatigue::FEReactiveFatigue(FEModel* pfem) : FEElasticMaterial(pfem)
{
m_pBase = 0;
m_pIdmg = 0;
m_pFdmg = 0;
m_pIcrt = 0;
m_pFcrt = 0;
m_k0 = 0;
m_beta = 0;
}
//-----------------------------------------------------------------------------
// returns a pointer to a new material point object
FEMaterialPointData* FEReactiveFatigue::CreateMaterialPointData()
{
return new FEReactiveFatigueMaterialPoint(m_pBase->CreateMaterialPointData());
}
//-----------------------------------------------------------------------------
//! Initialization.
bool FEReactiveFatigue::Init()
{
FEUncoupledMaterial* m_pMat = dynamic_cast<FEUncoupledMaterial*>((FEElasticMaterial*)m_pBase);
if (m_pMat != nullptr)
{
feLogError("Elastic material should not be of type uncoupled");
return false;
}
return FEElasticMaterial::Init();
}
//-----------------------------------------------------------------------------
//! calculate stress at material point
mat3ds FEReactiveFatigue::Stress(FEMaterialPoint& pt)
{
// evaluate the damage
double d = Damage(pt);
// evaluate the stress
mat3ds s = m_pBase->Stress(pt);
// return damaged stress
return s*(1-d);
}
//-----------------------------------------------------------------------------
//! calculate tangent stiffness at material point
tens4ds FEReactiveFatigue::Tangent(FEMaterialPoint& pt)
{
// evaluate the damage
double d = Damage(pt);
// evaluate the tangent
tens4ds c = m_pBase->Tangent(pt);
// return damaged tangent
return c*(1-d);
}
//-----------------------------------------------------------------------------
//! calculate strain energy density at material point
double FEReactiveFatigue::StrainEnergyDensity(FEMaterialPoint& pt)
{
// evaluate the damage
double d = Damage(pt);
// evaluate the strain energy density
double sed = m_pBase->StrainEnergyDensity(pt);
// return damaged sed
return sed*(1-d);
}
//-----------------------------------------------------------------------------
//! calculate damage at material point
double FEReactiveFatigue::Damage(FEMaterialPoint& pt)
{
// get the reactive fatigue material point data
FEReactiveFatigueMaterialPoint& pd = *pt.ExtractData<FEReactiveFatigueMaterialPoint>();
return pd.m_D;
}
//-----------------------------------------------------------------------------
// update fatigue material point at each iteration
void FEReactiveFatigue::UpdateSpecializedMaterialPoints(FEMaterialPoint& pt, const FETimeInfo& tp)
{
double dt = tp.timeIncrement;
double k0 = m_k0(pt);
double beta = m_beta(pt);
// get the fatigue material point data
FEReactiveFatigueMaterialPoint& pd = *pt.ExtractData<FEReactiveFatigueMaterialPoint>();
// get damage criterion for intact bonds at current time
pd.m_Xitrl = m_pIcrt->DamageCriterion(pt);
if (pd.m_Xitrl > pd.m_Ximax)
pd.m_Fit = m_pIdmg->cdf(pt,pd.m_Xitrl);
else
pd.m_Fit = pd.m_Fip;
// get damage criterion for fatigue bonds at current time
double Xftrl = m_pFcrt->DamageCriterion(pt);
for (int ig=0; ig < pd.m_fb.size(); ++ig) {
if (Xftrl > pd.m_fb[ig].m_Xfmax) {
pd.m_fb[ig].m_Xftrl = Xftrl;
pd.m_fb[ig].m_Fft = m_pFdmg->cdf(pt,pd.m_fb[ig].m_Xftrl);
}
else
pd.m_fb[ig].m_Fft = pd.m_fb[ig].m_Ffp;
}
// evaluate time derivative of intact bond criterion
pd.m_aXit = (pd.m_Xitrl - pd.m_Xip)/dt;
// evaluate increment in broken bond mass fraction from breaking of intact bonds
double dwb_ib = (pd.m_Fip < 1) ? (pd.m_Fit-pd.m_Fip)/(1-pd.m_Fip)*pd.m_wip : pd.m_wip;
// kinetics of intact bonds
pd.m_wbt = pd.m_wbp + dwb_ib;
// wit must be properly initialized before evaluating the fatigue reaction
pd.m_wit = pd.m_wip - dwb_ib;
// solve for fatigue bond mass fractions at current iteration
double kt = k0*pow(fabs(pd.m_aXit)*pd.m_wbt,beta);
double kp = k0*pow(fabs(pd.m_aXip)*pd.m_wbp,beta);
// evaluate increment in fatigue bond mass fraction from fatigue of intact bonds
double dwf_if = dt/2*(kt*pd.m_wit+kp*pd.m_wip);
// kinetics of intact bonds
pd.m_wit -= dwf_if;
pd.m_wft = pd.m_wfp + dwf_if;
// add or update new generation
if ((pd.m_fb.size() == 0) || pd.m_fb.back().m_time < tp.currentTime) {
// add generation of fatigued bonds
FatigueBond fb;
fb.m_Ffp = 0;
fb.m_Fft = m_pFdmg->cdf(pt,Xftrl);
fb.m_wfp = 0;
fb.m_wft = dwf_if;
fb.m_Xftrl = Xftrl;
fb.m_time = tp.currentTime;
pd.m_fb.push_back(fb);
}
else {
for (int ig=0; ig < pd.m_fb.size(); ++ig) pd.m_fb[ig].m_wft = pd.m_fb[ig].m_wfp;
pd.m_fb.back().m_Fft = m_pFdmg->cdf(pt,Xftrl);
pd.m_fb.back().m_wft += dwf_if;
pd.m_fb.back().m_Xftrl = Xftrl;
}
// damage kinetics of fatigued bonds
for (int ig=0; ig < pd.m_fb.size(); ++ig) {
double dwb_fb = (pd.m_fb[ig].m_Ffp < 1) ? (pd.m_fb[ig].m_Fft-pd.m_fb[ig].m_Ffp)/(1-pd.m_fb[ig].m_Ffp)*pd.m_fb[ig].m_wfp
: pd.m_fb[ig].m_wft;
pd.m_fb[ig].m_wft -= dwb_fb;
pd.m_wbt += dwb_fb;
pd.m_wft -= dwb_fb;
}
// evaluate fatigue bond fraction
// pd.m_wft = 0;
// for (int ig=0; ig < pd.m_fb.size(); ++ig) pd.m_wft += pd.m_fb[ig].m_wft;
// fix round-off errors
double wbd = 0;
if (pd.m_wbt < pd.m_wbp) {
wbd = pd.m_wbp - pd.m_wbt;
pd.m_wbt = pd.m_wbp;
}
else if (pd.m_wbt > 1) {
pd.m_wbt = 1;
}
double wid = 0;
if (pd.m_wit > pd.m_wip) {
wid = pd.m_wit - pd.m_wip;
pd.m_wit = pd.m_wip;
}
else if (pd.m_wit < 0) {
pd.m_wit = 0;
}
pd.m_wft = 1 - pd.m_wit - pd.m_wbt - wid + wbd;
pd.m_D = pd.m_wbt;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FELungMaterial.h | .h | 1,851 | 53 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include <FEBioMech/FEElasticMaterial.h>
//----------------------------------------------------------------------------
class FELungMaterial : public FEElasticMaterial
{
public:
FELungMaterial(FEModel* pfem);
private:
double m_c, m_c1, m_c3;
double m_d1, m_d3;
double m_b;
double m_E, m_v;
public:
virtual bool Init() override;
double StrainEnergyDensity(FEMaterialPoint& pt) override;
mat3ds Stress(FEMaterialPoint& pt) override;
tens4ds Tangent(FEMaterialPoint& pt) override;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEIsotropicElastic.h | .h | 2,301 | 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"
//-----------------------------------------------------------------------------
class FEIsotropicElastic : public FEElasticMaterial
{
public:
FEIsotropicElastic(FEModel* pfem) : FEElasticMaterial(pfem) {}
public:
FEParamDouble m_E; //!< Young's modulus
FEParamDouble m_v; //!< Poisson's ratio
public:
//! calculate stress at material point
virtual mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
virtual tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
virtual double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! calculate the 2nd Piola-Kirchhoff stress at material point
mat3ds PK2Stress(FEMaterialPoint& pt, const mat3ds E) override;
//! calculate material tangent stiffness at material point
tens4dmm MaterialTangent(FEMaterialPoint& pt, const mat3ds E) override;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FETendonMaterial.cpp | .cpp | 10,208 | 395 | /*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 "FETendonMaterial.h"
#include <FECore/FEConstValueVec3.h>
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
// define the material parameters
BEGIN_FECORE_CLASS(FETendonMaterial, FEUncoupledMaterial)
ADD_PARAMETER(m_G1 , "g1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_G2 , "g2")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_L1 , "l1")->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_L2 , "l2");
ADD_PARAMETER(m_lam1, "lam_max");
ADD_PROPERTY(m_fiber, "fiber");
END_FECORE_CLASS();
//////////////////////////////////////////////////////////////////////
// FETendonMaterial
//////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
FETendonMaterial::FETendonMaterial(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_fiber = nullptr;
}
//-----------------------------------------------------------------------------
//! Calculates the deviatoric stress at a material point.
//!
mat3ds FETendonMaterial::DevStress(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);
// get the initial fiber direction
vec3d a0 = Q * m_fiber->unitVector(mp);
// calculate the current material axis lam*a = F*a0;
vec3d a = F*a0;
// normalize material axis and store fiber stretch
double la = a.unit();
double lat = la*pow(J, -1.0/3.0); // i.e. lambda tilde
// get deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// calculate B*a
vec3d Ba = B*a;
// invariants of B
double I1, I2, I4, I5;
I1 = B.tr();
I2 = 0.5*(I1*I1 - B2.tr());
I4 = lat*lat;
I5 = I4*(a*Ba);
// ----- calculate new invariants b1 and b2 of B ------
// note that we need to be carefull about roundoff errors
// since these functions may create numerical problems
double g = I5/(I4*I4) - 1;
double b1 = (g > 0 ? sqrt(g) : 0);
double b2 = acosh(0.5*(I1*I4 - I5)/lat);
// calculate omage (w)
double w = 0.5*(I1*I4 - I5)/lat;
// set beta and ksi to their limit values
double beta = 1.0;
double ksi = -1.0/3.0;
// if w not equals unity, we can calculate beta and ksi
if (w > 1.0001)
{
beta = b2/sqrt(w*w-1);
ksi = (1.0/(w*w-1))*(1 - w*b2/sqrt(w*w-1));
}
// evaluate parameters
double G1 = m_G1(mp);
double G2 = m_G2(mp);
double L1 = m_L1(mp);
double L2 = m_L2(mp);
double lam1 = m_lam1(mp);
// ----- calculate strain derivatives -----
// We assume that W(I1, I4, I5, alpha) = F1(B1(I4, I5)) + F2(B2(I1,I4,I5)) + F3(lam(I4), alpha)
double W1, W2, W4, W5;
// calculate derivatives for F1
double F1D4 = -2*G1*(I5/(I4*I4*I4));
double F1D5 = G1/(I4*I4);
// calculate derivatives for F2
double F2D1 = G2*beta*lat;
double F2D4 = G2*beta*(I1*I4 + I5)*0.5*pow(I4, -1.5);
double F2D5 = -G2*beta/lat;
// calculate passive fiber force
double Fp;
if (lat <= 1)
{
Fp = 0;
}
else if (lat < lam1)
{
Fp = L1*(exp(L2*(lat - 1)) - 1);
}
else
{
double L3, L4;
L3 = L1*L2*exp(L2*(lam1 - 1));
L4 = L1*(exp(L2*(lam1 - 1)) - 1) - L3*lam1;
Fp = L3*lat + L4;
}
// calculate total fiber force
double FfDl = Fp/lat;
double FfD4 = 0.5*FfDl/lat;
// add all derivatives
W1 = F2D1;
W2 = 0;
W4 = F1D4 + F2D4 + FfD4;
W5 = F1D5 + F2D5;
// ----- calculate stress -----
// dyadic of a
mat3ds AxA = dyad(a);
// symmetric dyad of a and Ba
mat3ds ABA = dyads(a, Ba);
// ----- calculate stress -----
// calculate T
mat3ds T = B*(W1 + W2*I1) - B2*W2 + AxA*(I4*W4) + ABA*(I4*W5);
return T.dev()*(2.0/J);
}
//-----------------------------------------------------------------------------
//! Calculates the spatial deviatoric tangent at a material point
//!
tens4ds FETendonMaterial::DevTangent(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);
// get the initial fiber direction
vec3d a0 = Q * m_fiber->unitVector(mp);
// calculate the current material axis lam*a = F*a0;
vec3d a = F*a0;
// normalize material axis and store fiber stretch
double la = a.unit();
double lat = la*pow(J, -1.0/3.0); // i.e. lambda tilde
// get deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// calculate square of B
mat3ds B2 = B.sqr();
// calculate B*a
vec3d Ba = B*a;
// invariants of B
double I1, I2, I4, I5;
I1 = B.tr();
I2 = 0.5*(I1*I1 - B2.tr());
I4 = lat*lat;
I5 = I4*(a*Ba);
// calculate new invariants
double g = I5/(I4*I4) - 1;
double b1 = (g > 0 ? sqrt(g) : 0);
double b2 = acosh(0.5*(I1*I4 - I5)/lat);
// calculate omage (w)
double w = 0.5*(I1*I4 - I5)/lat;
// set beta and ksi to their limit values
double beta = 1.0;
double ksi = -1.0/3.0;
// if w not equals unity, we can calculate beta and ksi
if (w > 1.0001)
{
beta = b2/sqrt(w*w-1);
ksi = (1.0/(w*w-1))*(1 - w*b2/sqrt(w*w-1));
}
// evaluate parameters
double G1 = m_G1(mp);
double G2 = m_G2(mp);
double L1 = m_L1(mp);
double L2 = m_L2(mp);
double lam1 = m_lam1(mp);
// --- strain energy derivatives ---
// We assume that W(I1, I4, I5, alpha) = F1(B1(I4, I5)) + F2(B2(I1,I4,I5)) + F3(lam(I4), alpha)
double W1, W2, W4, W5;
// -- A. matrix contribution --
// calculate derivatives for F1
double F1D4 = -2*G1*(I5/(I4*I4*I4));
double F1D5 = G1/(I4*I4);
double F1D44 = 6*G1*(I5/(I4*I4*I4*I4));
double F1D45 = -2*G1/(I4*I4*I4);
// calculate derivatives for F2
double F2D1 = G2*beta*lat;
double F2D4 = G2*beta*(I1*I4 + I5)*0.5*pow(I4, -1.5);
double F2D5 = -G2*beta/lat;
double F2D11 = ksi*G2*I4*0.5;
double F2D44 = 2.0*G2*ksi*pow(0.25*(I1*I4+I5)/pow(I4, 1.5), 2) - G2*beta*(0.25*(I1*I4 + 3*I5) / pow(I4, 2.5));
double F2D55 = 0.5*G2*ksi/I4;
double F2D14 = G2*beta*0.5/lat + G2*ksi*(I1*I4+I5)*0.25/I4;
double F2D15 = -0.5*G2*ksi;
double F2D45 = G2*beta*0.5*pow(I4, -1.5) - G2*ksi*0.25*(I1*I4+I5)/(I4*I4);
// -- B. fiber contribution --
// calculate passive fiber force
double Fp, FpDl;
if (lat <= 1)
{
Fp = 0;
FpDl = 0;
}
else if (lat < lam1)
{
Fp = L1*(exp(L2*(lat - 1)) - 1);
FpDl = L1*L2*exp(L2*(lat - 1));
}
else
{
double L3, L4;
L3 = L1*L2*exp(L2*(lam1 - 1));
L4 = L1*(exp(L2*(lam1 - 1)) - 1) - L3*lam1;
Fp = L3*lat + L4;
FpDl = L3;
}
// calculate total fiber force
double FfDl = Fp/lat;
double FfD4 = 0.5*FfDl/lat;
double FfDll = FpDl/lat - Fp/(lat*lat);
double FfD44 = 0.25*(FfDll - FfDl / lat)/I4;
// add all derivatives
W1 = F2D1;
W2 = 0;
W4 = F1D4 + F2D4 + FfD4;
W5 = F1D5 + F2D5;
// calculate second derivatives
double W11, W12, W22, W14, W24, W15, W25, W44, W45, W55;
W11 = F2D11;
W12 = 0;
W22 = 0;
W14 = F2D14;
W24 = 0;
W15 = F2D15;
W25 = 0;
W44 = F1D44 + F2D44 + FfD44;
W45 = F1D45 + F2D45;
W55 = F2D55;
// calculate dWdC:C
double WCC = W1*I1 + 2*W2*I2 + W4*I4 + 2*W5*I5;
// calculate C:d2WdCdC:C
double CW2CCC = (W11*I1 + W12*I1*I1 + W2*I1 + 2*W12*I2 + 2*W22*I1*I2 + W14*I4 + W24*I1*I4 + 2*W15*I5 + 2*W25*I1*I5)*I1
-(W12*I1 + 2*W22*I2 + W2 + W24*I4 + 2*W25*I5)*(I1*I1 - 2*I2)
+(W14*I1 + 2*W24*I2 + W44*I4 + 2*W45*I5)*I4 + (W15*I1 + 2*W25*I2 + W45*I4 + 2*W55*I5)*2*I5
+ 2*W5*I5;
// second order identity tensor
mat3dd ID(1);
// 4th order identity tensors
tens4ds IxI = dyad1s(ID);
tens4ds I = dyad4s(ID);
// dyad of a
mat3ds AxA = dyad(a);
// --- calculate elasticity tensor ---
// calculate push-forward of dI5/dC = I4*(a*Ba + Ba*a)
mat3ds I5C = dyads(a, Ba)*I4;
// calculate push-forward of d2I5/dCdC
tens4ds I5CC = dyad4s(AxA, B)*I4;
// calculate push forward of I
tens4ds Ib = dyad4s(B);
// calculate push forward of dW/dCdC:C
mat3ds WCCC =
B*(W11*I1 + W12*I1*I1 + W2*I1 + 2*W12*I2 + 2*W22*I1*I2 + W14*I4 + W24*I1*I4 + 2*W15*I5 + 2*W25*I1*I5) -
B2*(W12*I1 + 2*W22*I2 + W2 + W24*I4 + 2*W25*I5) +
AxA *((W14*I1 + 2*W24*I2 + W44*I4 + 2*W45*I5)*I4) +
I5C*(W15*I1 + 2*W25*I2 + W45*I4 + 2*W55*I5 + W5);
// calculate push-forward of dW2/dCdC
tens4ds W2CC =
dyad1s(B)*(W11 + 2.0*W12*I1 + W2 + W22*I1*I1) +
dyad1s(B, B2)*(-(W12+W22*I1)) + dyad1s(B2)*W22 - Ib*W2 +
dyad1s(B, AxA)*((W14 + W24*I1)*I4) +
dyad1s(B, I5C)*(W15 + W25*I1) +
dyad1s(B2, AxA)*(-W24*I4) +
dyad1s(AxA)*(W44*I4*I4) +
dyad1s(AxA, I5C)*(W45*I4) +
dyad1s(I5C)*W55 + I5CC*W5;
// let's put it all together
// cw
tens4ds cw = IxI*((4.0/(9.0*J))*(CW2CCC)) + W2CC*(4/J) - dyad1s(WCCC, ID)*(4.0/(3.0*J));
// deviatoric Cauchy stress
mat3ds ABA = dyads(a, Ba);
mat3ds T = B * (W1 + W2 * I1) - B2 * W2 + AxA * (I4 * W4) + ABA * (I4 * W5);
mat3ds devs = T.dev() * (2.0 / J);
// elasticity tensor
return dyad1s(devs, ID)*(-2.0/3.0) + (I - IxI/3.0)*(4.0*WCC/(3.0*J)) + cw;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEContactSurface.h | .h | 3,884 | 133 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FESurface.h>
#include <FECore/vec2d.h>
#include "FEContactInterface.h"
#include "febiomech_api.h"
//-----------------------------------------------------------------------------
// Stores material point data for contact interfaces
class FEBIOMECH_API FEContactMaterialPoint : public FESurfaceMaterialPoint
{
public:
FEContactMaterialPoint()
{
m_gap = 0.0;
m_Ln = 0.0;
m_pme = nullptr;
m_pmep = nullptr;
}
void Init() override
{
FESurfaceMaterialPoint::Init();
m_gap = 0.0;
m_Ln = 0.0;
m_pme = nullptr;
m_pmep = nullptr;
}
void Serialize(DumpStream& ar) override
{
FESurfaceMaterialPoint::Serialize(ar);
ar & m_gap & m_Ln;
}
public:
double m_gap; //!< gap function at integration points
double m_Ln; //!< net contact pressure
FESurfaceElement* m_pme; //!< target element
FESurfaceElement* m_pmep; //!< previous target element
};
//-----------------------------------------------------------------------------
//! This class describes a contact surface
//! this class is used in contact analyses to describe a contacting
//! surface in a contact interface.
class FEBIOMECH_API FEContactSurface : public FESurface
{
public:
//! constructor
FEContactSurface(FEModel* pfem);
//! destructor
~FEContactSurface();
// initialization
bool Init() override;
// serialization
void Serialize(DumpStream& ar) override;
//! Set the sibling of this contact surface
void SetSibling(FEContactSurface* ps);
//! Set the parent of this contact surface
void SetContactInterface(FEContactInterface* ps);
//! Get the parent of this contact surface
FEContactInterface* GetContactInterface() { return m_pContactInterface; }
//! Unpack surface element data
virtual void UnpackLM(FEElement& el, vector<int>& lm);
public:
virtual void GetVectorGap (int nface, vec3d& pg);
virtual void GetContactTraction(int nface, vec3d& pt);
virtual void GetNodalVectorGap (int nface, vec3d* pg);
virtual void GetNodalContactPressure(int nface, double* pg);
virtual void GetNodalContactTraction(int nface, vec3d* pt);
virtual void GetStickStatus(int nface, double& pt);
void GetSurfaceTraction(int nface, vec3d& pt);
void GetNodalSurfaceTraction(int nface, vec3d* pt);
void GetGPSurfaceTraction(int nface, vec3d* pt);
virtual vec3d GetContactForce();
virtual double GetContactArea();
FEModel* GetFEModel() { return m_pfem; }
protected:
FEContactSurface* m_pSibling;
FEContactInterface* m_pContactInterface;
FEModel* m_pfem;
int m_dofX;
int m_dofY;
int m_dofZ;
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/febiomech_api.h | .h | 1,536 | 44 | /*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
#ifdef WIN32
#ifdef FECORE_DLL
#ifdef febiomech_EXPORTS
#define FEBIOMECH_API __declspec(dllexport)
#else
#define FEBIOMECH_API __declspec(dllimport)
#endif
#else
#define FEBIOMECH_API
#endif
#else
#define FEBIOMECH_API
#endif
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEEFDDonnanEquilibrium.cpp | .cpp | 3,673 | 107 | /*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 "FEEFDDonnanEquilibrium.h"
// define the material parameters
BEGIN_FECORE_CLASS(FEEFDDonnanEquilibrium, FEElasticMaterial)
ADD_PARAMETER(m_DEQ.m_phiwr, "phiw0");
ADD_PARAMETER(m_DEQ.m_cFr, "cF0")->setUnits(UNIT_CONCENTRATION);
ADD_PARAMETER(m_DEQ.m_bosm, "bosm")->setUnits(UNIT_CONCENTRATION);
ADD_PARAMETER(m_DEQ.m_Phi, "Phi");
ADD_PARAMETER(m_Fib.m_beta, 3, "beta");
ADD_PARAMETER(m_Fib.m_ksi , 3, "ksi" )->setUnits(UNIT_PRESSURE);
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
// FEEFDDonnanEquilibrium
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool FEEFDDonnanEquilibrium::Init()
{
if (FEElasticMaterial::Init() == false) return false;
if (m_DEQ.Init() == false) return false;
if (m_Fib.Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
void FEEFDDonnanEquilibrium::Serialize(DumpStream& ar)
{
FEElasticMaterial::Serialize(ar);
m_Fib.Serialize(ar);
m_DEQ.Serialize(ar);
}
//-----------------------------------------------------------------------------
mat3ds FEEFDDonnanEquilibrium::Stress(FEMaterialPoint& mp)
{
// --- M A T R I X C O N T R I B U T I O N ---
mat3ds s = m_DEQ.Stress(mp);
// --- F I B E R C O N T R I B U T I O N ---
// evaluate stress and add it to matrix contribution
s += m_Fib.Stress(mp);
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEEFDDonnanEquilibrium::Tangent(FEMaterialPoint& mp)
{
// --- M A T R I X C O N T R I B U T I O N ---
tens4ds c = m_DEQ.Tangent(mp);
// --- F I B E R C O N T R I B U T I O N ---
// evaluate stress and add it to matrix contribution
c += m_Fib.Tangent(mp);
return c;
}
//-----------------------------------------------------------------------------
//! calculate strain energy density at material point
double FEEFDDonnanEquilibrium::StrainEnergyDensity(FEMaterialPoint& mp)
{
// --- M A T R I X C O N T R I B U T I O N ---
double sed = m_DEQ.StrainEnergyDensity(mp);
// --- F I B E R C O N T R I B U T I O N ---
sed += m_Fib.StrainEnergyDensity(mp);
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEMovingFrameLoad.h | .h | 2,161 | 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 "FEBodyForce.h"
//! This body load emulates the effect of a moving frame
class FEMovingFrameLoad : public FEBodyForce
{
public:
FEMovingFrameLoad(FEModel* fem);
void Activate() override;
void PrepStep() override;
vec3d force(FEMaterialPoint& pt) override;
mat3d stiffness(FEMaterialPoint& pt) override;
private:
vec3d m_at; // linear acceleration of moving frame in fixed frame
vec3d m_wi; // angular velocity input
int m_frame; // fixed (=0), or moving (=1) frame for input angular velocity
private:
vec3d m_ap, m_a, m_A;
vec3d m_wp, m_w, m_Wp, m_W;
vec3d m_alt, m_alp, m_al, m_Alt, m_Alp, m_Al;
quatd m_qt, m_qp, m_q;
// output parameters
vec3d m_wt; // angular velocity in fixed frame (output)
vec3d m_Wt; // angular velocity in moving frame (output)
vec3d m_rt; // rotational vector in fixed frame (output)
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERelativeVolumeCriterion.h | .h | 1,583 | 42 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2024 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/FEMeshAdaptorCriterion.h>
#include "FEDamageMaterial.h"
class FERelativeVolumeCriterion : public FEMeshAdaptorCriterion
{
public:
FERelativeVolumeCriterion(FEModel* fem);
bool GetMaterialPointValue(FEMaterialPoint& mp, double& value) override;
DECLARE_FECORE_CLASS()
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERigidLock.cpp | .cpp | 21,890 | 719 | /*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 "FERigidLock.h"
#include "FERigidBody.h"
#include "FECore/log.h"
#include <FECore/FELinearSystem.h>
//-----------------------------------------------------------------------------
BEGIN_FECORE_CLASS(FERigidLock, 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_e0[0] , "first_axis" );
ADD_PARAMETER(m_e0[1] , "second_axis" );
ADD_PARAMETER(m_naugmin , "minaug" );
ADD_PARAMETER(m_naugmax , "maxaug" );
ADD_PARAMETER(m_bautopen, "auto_penalty");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FERigidLock::FERigidLock(FEModel* pfem) : FERigidConnector(pfem)
{
m_eps = 1.0;
m_ups = 1.0;
m_nID = m_ncount++;
m_laugon = FECore::AUGLAG_METHOD; // for backward compatibility
m_atol = 0;
m_gtol = 0;
m_qtol = 0;
m_naugmin = 0;
m_naugmax = 10;
m_bautopen = false;
m_eps = m_ups = 1.0;
}
//-----------------------------------------------------------------------------
//! TODO: This function is called twice: once in the Init and once in the Solve
//! phase. Is that necessary?
bool FERigidLock::Init()
{
// initialize joint basis
m_e0[0].unit();
m_e0[2] = m_e0[0] ^ m_e0[1]; m_e0[2].unit();
m_e0[1] = m_e0[2] ^ m_e0[0]; m_e0[1].unit();
// reset force
m_F = vec3d(0,0,0); m_L = vec3d(0,0,0);
m_M = vec3d(0,0,0); m_U = vec3d(0,0,0);
m_U1 = m_U2 = vec3d(0, 0, 0);
m_Fp = vec3d(0, 0, 0);
m_U1p = m_U2p = 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_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;
}
// allocate equations
int FERigidLock::InitEquations(int neq)
{
const int LMeq = 9;
m_LM.resize(LMeq, -1);
if (m_laugon == FECore::LAGMULT_METHOD)
{
for (int i=0; i< LMeq; ++i) m_LM[i] = neq + i;
return LMeq;
}
else return 0;
}
// Build the matrix profile
void FERigidLock::BuildMatrixProfile(FEGlobalMatrix& M)
{
vector<int> lm;
UnpackLM(lm);
// add it to the pile
M.build_add(lm);
}
void FERigidLock::UnpackLM(vector<int>& lm)
{
// add the dofs of rigid body A
lm.resize(21);
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 FERigidLock::Serialize(DumpStream& ar)
{
FERigidConnector::Serialize(ar);
ar & m_qa0 & m_qb0;
ar & m_L & m_U & m_U1 & m_U2;
ar & m_e0;
ar & m_ea0;
ar & m_eb0;
ar & m_LM;
}
//-----------------------------------------------------------------------------
//! \todo Why is this class not using the FESolver for assembly?
void FERigidLock::LoadVector(FEGlobalVector& R, const FETimeInfo& tp)
{
vector<double> fa(6);
vector<double> fb(6);
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
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);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
// incremental compound rotation of B w.r.t. A
if (m_laugon != FECore::LAGMULT_METHOD)
{
vec3d vth = ((ea[0] ^ eb[0]) + (ea[1] ^ eb[1]) + (ea[2] ^ eb[2])) / 2;
vec3d c = rb + zb - ra - za;
if (m_laugon != FECore::LAGMULT_METHOD) m_F = m_L + c * m_eps;
vec3d ksi = vth;
if (m_laugon != FECore::LAGMULT_METHOD) m_M = m_U + ksi * m_ups;
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) + (ea[0] ^ m_U1) + (ea[1] ^ m_U2);
vec3d Mb = (zb ^ m_F) + (eb[0] ^ m_U1) + (eb[1] ^ m_U2);
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;
// rotational constraint
vec3d ksi1 = eb[0] - ea[0];
vec3d ksi2 = eb[1] - ea[1];
R[m_LM[3]] += ksi1.x;
R[m_LM[4]] += ksi1.y;
R[m_LM[5]] += ksi1.z;
R[m_LM[6]] += ksi2.x;
R[m_LM[7]] += ksi2.y;
R[m_LM[8]] += ksi2.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 FERigidLock::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
double alpha = tp.alphaf;
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
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);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
mat3d zbhat; zbhat.skew(zb);
mat3d zbthat; zbthat.skew(zbt);
mat3d eahat[3], ebhat[3], eathat[3], ebthat[3];
for (int j=0; j<3; ++j) {
eahat[j] = skew(ea[j]);
ebhat[j] = skew(eb[j]);
eathat[j] = skew(eat[j]);
ebthat[j] = skew(ebt[j]);
}
if (m_laugon != FECore::LAGMULT_METHOD)
{
vector<int> LM(12);
FEElementMatrix ke; ke.resize(12, 12);
ke.zero();
vec3d c = rb + zb - ra - za;
m_F = m_L + c * m_eps;
// incremental compound rotation of B w.r.t. A
vec3d vth = ((ea[0] ^ eb[0]) + (ea[1] ^ eb[1]) + (ea[2] ^ eb[2])) / 2;
vec3d ksi = vth;
m_M = m_U + ksi * m_ups;
mat3da Fhat(m_F);
mat3dd I(1);
mat3d Wba = (ebhat[0] * eathat[0] + ebhat[1] * eathat[1] + ebhat[2] * eathat[2]) / 2;
mat3d Wab = (eahat[0] * ebthat[0] + eahat[1] * ebthat[1] + eahat[2] * ebthat[2]) / 2;
// row 1
ke.set(0, 0, I * (-m_eps));
ke.set(0, 3, zathat * (m_eps));
ke.set(0, 6, I * (m_eps));
ke.set(0, 9, zbthat * (-m_eps));
// row 2
ke.set(3, 0, zahat * (-m_eps));
ke.set(3, 3, zahat * zathat * (m_eps)+Fhat * zathat + Wba * m_ups);
ke.set(3, 6, zahat * (m_eps));
ke.set(3, 9, zahat * zbthat * (-m_eps) + Wab * (-m_ups));
// row 3
ke.set(6, 0, I * (m_eps));
ke.set(6, 3, zathat * (-m_eps));
ke.set(6, 6, I * (-m_eps));
ke.set(6, 9, zbthat * (m_eps));
// row 4
ke.set(9, 0, zbhat * (m_eps));
ke.set(9, 3, zbhat * zathat * (-m_eps) + Wba * (-m_ups));
ke.set(9, 6, zbhat * (-m_eps));
ke.set(9, 9, zbhat * zbthat * (m_eps)-Fhat * zbthat + Wab * m_ups);
ke *= -alpha;
for (int j = 0; j < 6; ++j)
{
LM[j] = RBa.m_LM[j];
LM[j + 6] = RBb.m_LM[j];
}
ke.SetIndices(LM);
LS.Assemble(ke);
}
else
{
FEElementMatrix ke; ke.resize(21, 21);
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);
// rotational constraint 1
mat3da U1hat(m_U1);
ke.sub(3, 3, -U1hat*eahat[0]);
ke.sub(9, 9, U1hat*ebhat[0]);
ke.sub(3, 15, -eahat[0]);
ke.sub(9, 15, ebhat[0]);
ke.sub(15, 3, eahat[0]);
ke.sub(15, 9, -ebhat[0]);
// rotational constraint 2
mat3da U2hat(m_U2);
ke.sub(3, 3, -U2hat*eahat[1]);
ke.sub(9, 9, U2hat*ebhat[1]);
ke.sub(3, 18, -eahat[1]);
ke.sub(9, 18, ebhat[1]);
ke.sub(18, 3, eahat[1]);
ke.sub(18, 9, -ebhat[1]);
vector<int> LM;
UnpackLM(LM);
ke.SetIndices(LM);
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
bool FERigidLock::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;
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
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);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
// incremental compound rotation of B w.r.t. A
vec3d vth = ((ea[0] ^ eb[0]) + (ea[1] ^ eb[1]) + (ea[2] ^ eb[2]))/2;
c = rb + zb - ra - za;
normF0 = sqrt(m_L*m_L);
// calculate trial multiplier
Lm = m_L + c*m_eps;
normF1 = sqrt(Lm*Lm);
ksi = vth;
normM0 = sqrt(m_U*m_U);
// calculate trial multiplier
Um = m_U + ksi*m_ups;
normM1 = sqrt(Um*Um);
// check convergence of constraints
feLog(" rigid connector # %d (lock)\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);
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 && ((pctn >= m_atol) || (qctn >= m_atol))) bconv = false;
if (m_gtol && (gap >= m_gtol)) 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;
}
if (m_bautopen)
{
// auto-penalty update (works only with gaptol and angtol)
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 FERigidLock::Update()
{
if (m_laugon == FECore::LAGMULT_METHOD) return;
vec3d ra, rb;
vec3d za, zb;
vec3d eat[3], eap[3], ea[3];
vec3d ebt[3], ebp[3], eb[3];
FERigidBody& RBa = *m_rbA;
FERigidBody& RBb = *m_rbB;
const FETimeInfo& tp = GetTimeInfo();
double alpha = tp.alphaf;
ra = RBa.m_rt*alpha + RBa.m_rp*(1-alpha);
rb = RBb.m_rt*alpha + RBb.m_rp*(1-alpha);
vec3d zat = m_qa0; RBa.GetRotation().RotateVector(zat);
vec3d zap = m_qa0; RBa.m_qp.RotateVector(zap);
za = zat*alpha + zap*(1-alpha);
eat[0] = m_ea0[0]; RBa.GetRotation().RotateVector(eat[0]);
eat[1] = m_ea0[1]; RBa.GetRotation().RotateVector(eat[1]);
eat[2] = m_ea0[2]; RBa.GetRotation().RotateVector(eat[2]);
eap[0] = m_ea0[0]; RBa.m_qp.RotateVector(eap[0]);
eap[1] = m_ea0[1]; RBa.m_qp.RotateVector(eap[1]);
eap[2] = m_ea0[2]; RBa.m_qp.RotateVector(eap[2]);
ea[0] = eat[0]*alpha + eap[0]*(1-alpha);
ea[1] = eat[1]*alpha + eap[1]*(1-alpha);
ea[2] = eat[2]*alpha + eap[2]*(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);
ebt[0] = m_eb0[0]; RBb.GetRotation().RotateVector(ebt[0]);
ebt[1] = m_eb0[1]; RBb.GetRotation().RotateVector(ebt[1]);
ebt[2] = m_eb0[2]; RBb.GetRotation().RotateVector(ebt[2]);
ebp[0] = m_eb0[0]; RBb.m_qp.RotateVector(ebp[0]);
ebp[1] = m_eb0[1]; RBb.m_qp.RotateVector(ebp[1]);
ebp[2] = m_eb0[2]; RBb.m_qp.RotateVector(ebp[2]);
eb[0] = ebt[0]*alpha + ebp[0]*(1-alpha);
eb[1] = ebt[1]*alpha + ebp[1]*(1-alpha);
eb[2] = ebt[2]*alpha + ebp[2]*(1-alpha);
// incremental compound rotation of B w.r.t. A
vec3d vth = ((ea[0] ^ eb[0]) + (ea[1] ^ eb[1]) + (ea[2] ^ eb[2]))/2;
vec3d c = rb + zb - ra - za;
m_F = m_L + c*m_eps;
vec3d ksi = vth;
m_M = m_U + ksi*m_ups;
}
//-----------------------------------------------------------------------------
void FERigidLock::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;
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];
}
//-----------------------------------------------------------------------------
vec3d FERigidLock::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 FERigidLock::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;
}
void FERigidLock::PrepStep()
{
m_Fp = m_F;
m_U1p = m_U1;
m_U2p = m_U2;
}
void FERigidLock::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]];
m_U1.x = m_U1p.x + Ui[m_LM[3]] + ui[m_LM[3]];
m_U1.y = m_U1p.y + Ui[m_LM[4]] + ui[m_LM[4]];
m_U1.z = m_U1p.z + Ui[m_LM[5]] + ui[m_LM[5]];
m_U2.x = m_U2p.x + Ui[m_LM[6]] + ui[m_LM[6]];
m_U2.y = m_U2p.y + Ui[m_LM[7]] + ui[m_LM[7]];
m_U2.z = m_U2p.z + Ui[m_LM[8]] + ui[m_LM[8]];
m_M = m_U1 + m_U2;
}
}
void FERigidLock::UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui)
{
if (m_laugon == FECore::LAGMULT_METHOD)
{
for (int n : m_LM) Ui[n] += ui[n];
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEUDGHexDomain.h | .h | 3,047 | 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 "FEElasticSolidDomain.h"
//-----------------------------------------------------------------------------
//! domain class for uniform-deformation-gradient hex elements (UDG)
class FEBIOMECH_API FEUDGHexDomain : public FEElasticSolidDomain
{
public:
//! constructor
FEUDGHexDomain(FEModel* pfem);
//! Set the hourglass parameter
void SetHourGlassParameter(double hg);
//! allocate elements
bool Create(int nelems, FE_Element_Spec spec) override;
public:
//! calculates the residual
void InternalForces(FEGlobalVector& R) override;
//! calculates the global stiffness matrix for this domain
void StiffnessMatrix(FELinearSystem& LS) override;
// update domain data
void Update(const FETimeInfo& tp) override;
protected: // element residual contributions
//! Calculates the internal stress vector for enhanced strain hex elements
void UDGInternalForces(FESolidElement& el, vector<double>& fe);
//! calculates hourglass forces for the UDG element
void UDGHourglassForces(FESolidElement& el, vector<double>& fe);
protected: // element stiffness contributions
//! hourglass stiffness for UDG hex elements
void UDGHourglassStiffness(FEModel& fem, FESolidElement& el, matrix& ke);
//! geometrical stiffness for UDG hex elements
void UDGGeometricalStiffness(FESolidElement& el, matrix& ke);
//! material stiffness for UDG hex elements
void UDGMaterialStiffness(FESolidElement& el, matrix& ke);
protected:
void AvgCartDerivs(FESolidElement& el, double GX[8], double GY[8], double GZ[8], int state = 0);
void AvgDefGrad(FESolidElement& el, mat3d& F, double GX[8], double GY[8], double GZ[8]);
double HexVolume(FESolidElement& el, int state = 0);
public:
double m_hg; //!< hourglass parameter
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEPressureLoad.h | .h | 2,176 | 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 <FECore/FESurfaceLoad.h>
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! The pressure surface is a surface domain that sustains pressure boundary
//! conditions
//!
class FEPressureLoad : public FESurfaceLoad
{
public:
//! constructor
FEPressureLoad(FEModel* pfem);
//! initialization
bool Init() override;
public:
//! calculate residual
void LoadVector(FEGlobalVector& R) override;
//! calculate stiffness
void StiffnessMatrix(FELinearSystem& LS) override;
protected:
FEParamDouble m_pressure; //!< pressure value
bool m_bsymm; //!< use symmetric formulation
bool m_blinear; //!< is the load linear (i.e. it will be calculated in the reference frame and assummed deformation independent)
bool m_bshellb; //!< flag for prescribing pressure on shell bottom
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FERemodelingElasticMaterial.h | .h | 5,244 | 146 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEElasticMaterial.h"
//-----------------------------------------------------------------------------
//! Base class for solid supply.
//! These materials need to define the solid supply and tangent supply functions.
//! The solid supply has units of mass/(referential volume)/time
//!
class FEBIOMECH_API FESolidSupply : public FEMaterialProperty
{
public:
//! constructor
FESolidSupply(FEModel* pfem) : FEMaterialProperty(pfem) {}
//! solid supply
virtual double Supply(FEMaterialPoint& pt) = 0;
//! tangent of solute supply with respect to strain
virtual mat3ds Tangent_Supply_Strain(FEMaterialPoint& mp) = 0;
//! tangent of solute supply with respect to referential density
virtual double Tangent_Supply_Density(FEMaterialPoint& mp) = 0;
FECORE_BASE_CLASS(FESolidSupply)
};
//-----------------------------------------------------------------------------
//! Material point data for remodeling elastic materials
class FEBIOMECH_API FERemodelingMaterialPoint : public FEMaterialPointData
{
public:
FERemodelingMaterialPoint(FEMaterialPointData*pt) : FEMaterialPointData(pt) {}
FEMaterialPointData* Copy();
void Init();
void Update(const FETimeInfo& timeInfo);
void Serialize(DumpStream& ar);
public:
double m_sed; //!< strain energy density
double m_dsed; //!< derivative of strain energy density with mass density
double m_rhor; //!< current referential mass density
double m_rhorp; //!< referential mass density at previous time step
};
//-----------------------------------------------------------------------------
//! A material that wants to use the remodeling framework needs to implement
//! this additional interface.
class FERemodelingInterface
{
public:
//! calculate strain energy density at material point
virtual double StrainEnergy(FEMaterialPoint& pt) = 0;
//! calculate tangent of strain energy density with solid density at material point
virtual double Tangent_SE_Density(FEMaterialPoint& pt) = 0;
//! calculate tangent of stress with solid density at material point
virtual mat3ds Tangent_Stress_Density(FEMaterialPoint& pt) = 0;
public:
int m_comp; // mixture component to which this material belongs (if applicable)
int m_sbm; // sbm ID associated with this material
};
//-----------------------------------------------------------------------------
//! Material class for remodeling solids
class FEBIOMECH_API FERemodelingElasticMaterial : public FEElasticMaterial, public FERemodelingInterface
{
public:
//! constructor
FERemodelingElasticMaterial(FEModel* pfem);
//! strain energy density function
double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! stress function
mat3ds Stress(FEMaterialPoint& pt) override;
//! tangent function of stress with strain
tens4ds Tangent(FEMaterialPoint& pt) override;
//! evaluate referential mass density
double Density(FEMaterialPoint& pt) override;
//! evaluate strain energy density of remodeling interface
double StrainEnergy(FEMaterialPoint& pt) override { return StrainEnergyDensity(pt); }
//! tangent function of strain energy density with solid mass density
double Tangent_SE_Density(FEMaterialPoint& pt) override;
//! tangent function of stress with solid mass density
mat3ds Tangent_Stress_Density(FEMaterialPoint& pt) override;
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override
{
return new FERemodelingMaterialPoint(m_pBase->CreateMaterialPointData());
}
// get the elastic material
FEElasticMaterial* GetElasticMaterial() override { return m_pBase; }
public:
FEElasticMaterial* m_pBase; //!< pointer to elastic solid material
FESolidSupply* m_pSupp; //!< pointer to solid supply material
double m_rhormin; //!< minimum density
double m_rhormax; //!< maximum density
public:
// declare parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberExponentialPowerUC.h | .h | 2,149 | 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 "FEElasticFiberMaterialUC.h"
//-----------------------------------------------------------------------------
//! Exponential-power law
class FEFiberExponentialPowerUC : public FEElasticFiberMaterialUC
{
public:
FEFiberExponentialPowerUC(FEModel* pfem);
//! Validation
bool Validate() override;
//! Cauchy stress
mat3ds DevFiberStress(FEMaterialPoint& mp, const vec3d& a0) override;
// Spatial tangent
tens4ds DevFiberTangent(FEMaterialPoint& mp, const vec3d& a0) override;
//! Strain energy density
double DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) override;
public:
double m_alpha; // coefficient of (In-1) in exponential
double m_beta; // power of (In-1) in exponential
double m_ksi; // fiber modulus
double m_mu; // shear modulus
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEFiberIntegrationTrapezoidal.cpp | .cpp | 7,718 | 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 "FEFiberIntegrationTrapezoidal.h"
#ifndef SQR
#define SQR(x) ((x)*(x))
#endif
class FEFiberIntegrationTrapezoidal::Iterator : public FEFiberIntegrationSchemeIterator
{
public:
Iterator(FEMaterialPoint* mp, int nth)
{
m_nth = nth;
a0 = vec3d(1,0,0);
a1 = vec3d(0,1,0);
double pi = 4 * atan(1.0);
dth = pi / m_nth; // integrate from 0 to pi
i = -1;
Next();
}
bool IsValid()
{
return (i < m_nth);
}
// move to the next integration point
bool Next()
{
++i;
if (i < m_nth)
{
double theta = i*dth;
m_fiber = a0*cos(theta) + a1*sin(theta);
// Multiply by 2 since fibers along theta+pi have same stress as along theta
m_weight = dth*2.0;
return true;
}
else return false;
}
public:
int m_nth;
double dth;
vec3d a0, a1;
int i;
};
//-----------------------------------------------------------------------------
// FEFiberIntegrationTrapezoidal
//-----------------------------------------------------------------------------
// register the material with the framework
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberIntegrationTrapezoidal, FEFiberIntegrationScheme)
ADD_PARAMETER(m_nth, FE_RANGE_GREATER(0), "nth");
END_FECORE_CLASS();
FEFiberIntegrationTrapezoidal::FEFiberIntegrationTrapezoidal(FEModel* pfem) : FEFiberIntegrationScheme(pfem)
{
m_nth = 12;
}
FEFiberIntegrationTrapezoidal::~FEFiberIntegrationTrapezoidal()
{
}
//-----------------------------------------------------------------------------
FEFiberIntegrationSchemeIterator* FEFiberIntegrationTrapezoidal::GetIterator(FEMaterialPoint* mp)
{
return new Iterator(mp, m_nth);
}
/*
//-----------------------------------------------------------------------------
mat3ds FEFiberIntegrationTrapezoidal::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// initialize stress tensor
mat3ds s;
s.zero();
double theta;
double pi = 4*atan(1.0);
double dth = pi/m_nth; // integrate from 0 to pi
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
vec3d a0(Q(0,0),Q(1,0),Q(2,0)); // local x-direction unit vector
vec3d a1(Q(0,1),Q(1,1),Q(2,1)); // local y-direction unit vector
vec3d n0e, n0a;
// loop over all integration points
for (int i=0; i<m_nth; ++i) {
theta = i*dth;
// set fiber direction in x-y plane of local coordinate system
n0a = a0*cos(theta) + a1*sin(theta);
// evaluate local fiber distribution
double R = m_pFDD->FiberDensity(n0a);
// rotate to global configuration to set fiber direction
n0e = Q*n0a;
m_pFmat->SetFiberDirection(mp, n0e);
// calculate the stress
s += m_pFmat->Stress(mp)*(R*dth);
}
// Multiply by 2 since fibers along theta+pi have same stress as along theta
return s*2;
}
//-----------------------------------------------------------------------------
tens4ds FEFiberIntegrationTrapezoidal::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// initialize stress tensor
tens4ds c;
c.zero();
double theta;
double pi = 4*atan(1.0);
double dth = pi/m_nth; // integrate from 0 to pi
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
vec3d a0(Q(0,0),Q(1,0),Q(2,0)); // local x-direction unit vector
vec3d a1(Q(0,1),Q(1,1),Q(2,1)); // local y-direction unit vector
vec3d n0e, n0a;
// loop over all integration points
for (int i=0; i<m_nth; ++i) {
theta = i*dth;
// set fiber direction in x-y plane of local coordinate system
n0a = a0*cos(theta) + a1*sin(theta);
// evaluate local fiber distribution
double R = m_pFDD->FiberDensity(n0a);
// rotate to global configuration to set fiber direction
n0e = Q*n0a;
m_pFmat->SetFiberDirection(mp, n0e);
// calculate the stress
c += m_pFmat->Tangent(mp)*(R*dth);
}
// Multiply by 2 since fibers along theta+pi have same stress as along theta
return c*2;
}
//-----------------------------------------------------------------------------
double FEFiberIntegrationTrapezoidal::StrainEnergyDensity(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// initialize strain energy density
double sed = 0.0;
double theta;
double pi = 4*atan(1.0);
double dth = pi/m_nth; // integrate from 0 to pi
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
vec3d a0(Q(0,0),Q(1,0),Q(2,0)); // local x-direction unit vector
vec3d a1(Q(0,1),Q(1,1),Q(2,1)); // local y-direction unit vector
vec3d n0e, n0a;
// loop over all integration points
for (int i=0; i<m_nth; ++i) {
theta = i*dth;
// set fiber direction in x-y plane of local coordinate system
n0a = a0*cos(theta) + a1*sin(theta);
// evaluate local fiber distribution
double R = m_pFDD->FiberDensity(n0a);
// rotate to global configuration to set fiber direction
n0e = Q*n0a;
m_pFmat->SetFiberDirection(mp, n0e);
// calculate the stress
sed += m_pFmat->StrainEnergyDensity(mp)*(R*dth);
}
// Multiply by 2 since fibers along theta+pi have same sed as along theta
return sed*2;
}
//-----------------------------------------------------------------------------
double FEFiberIntegrationTrapezoidal::IntegratedFiberDensity()
{
// initialize integrated fiber density distribution
double IFD = 1;
double C = 0;
double theta;
double pi = 4*atan(1.0);
double dth = pi/m_nth; // integrate from 0 to pi
vec3d a0(1,0,0); // local x-direction unit vector
vec3d a1(0,1,0); // local y-direction unit vector
vec3d n0a;
// loop over all integration points
for (int i=0; i<m_nth; ++i) {
theta = i*dth;
// set fiber direction in x-y plane of local coordinate system
n0a = a0*cos(theta) + a1*sin(theta);
// evaluate local fiber distribution
double R = m_pFDD->FiberDensity(n0a);
// integrate the fiber distribution
C += R*dth;
}
// Multiply by 2 to take advantange of symmetry
IFD = C*2;
return IFD;
}
*/
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEBioMechData.cpp | .cpp | 83,592 | 2,661 | /*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 "FEBioMechData.h"
#include "FEElasticMaterial.h"
#include "FEUncoupledMaterial.h"
#include "FEReactiveMaterialPoint.h"
#include "FEDamageMaterialPoint.h"
#include "FEReactivePlasticityMaterialPoint.h"
#include "FEReactivePlasticDamageMaterialPoint.h"
#include "FEElasticMixture.h"
#include "FEElasticMultigeneration.h"
#include "FERigidMaterial.h"
#include "FESolidSolver.h"
#include "FESolidSolver2.h"
#include "FEExplicitSolidSolver.h"
#include "FERigidBody.h"
#include "FECore/FEModel.h"
#include "FECore/FEAnalysis.h"
#include "FERigidConnector.h"
#include "FEVolumeConstraint.h"
#include "FEContactSurface.h"
#include "FEDiscreteElasticMaterial.h"
#include "FESlidingInterface.h"
#include "FEPreStrainElastic.h"
#include <FECore/FESolidDomain.h>
//-----------------------------------------------------------------------------
double FENodeXPos::value(const FENode& node)
{
return node.m_rt.x;
}
//-----------------------------------------------------------------------------
double FENodeYPos::value(const FENode& node)
{
return node.m_rt.y;
}
//-----------------------------------------------------------------------------
double FENodeZPos::value(const FENode& node)
{
return node.m_rt.z;
}
//-----------------------------------------------------------------------------
double FENodeXDisp::value(const FENode& node)
{
const int dof_X = GetFEModel()->GetDOFIndex("x");
return node.get(dof_X);
}
//-----------------------------------------------------------------------------
double FENodeYDisp::value(const FENode& node)
{
const int dof_Y = GetFEModel()->GetDOFIndex("y");
return node.get(dof_Y);
}
//-----------------------------------------------------------------------------
double FENodeZDisp::value(const FENode& node)
{
const int dof_Z = GetFEModel()->GetDOFIndex("z");
return node.get(dof_Z);
}
//-----------------------------------------------------------------------------
double FENodeXVel::value(const FENode& node)
{
const int dof_VX = GetFEModel()->GetDOFIndex("vx");
return node.get(dof_VX);
}
//-----------------------------------------------------------------------------
double FENodeYVel::value(const FENode& node)
{
const int dof_VY = GetFEModel()->GetDOFIndex("vy");
return node.get(dof_VY);
}
//-----------------------------------------------------------------------------
double FENodeZVel::value(const FENode& node)
{
const int dof_VZ = GetFEModel()->GetDOFIndex("vz");
return node.get(dof_VZ);
}
//-----------------------------------------------------------------------------
double FENodeXAcc::value(const FENode& node)
{
return node.m_at.x;
}
//-----------------------------------------------------------------------------
double FENodeYAcc::value(const FENode& node)
{
return node.m_at.y;
}
//-----------------------------------------------------------------------------
double FENodeZAcc::value(const FENode& node)
{
return node.m_at.z;
}
//-----------------------------------------------------------------------------
double FENodeForceX::value(const FENode& node)
{
FESolidSolver2* psolid_solver = dynamic_cast<FESolidSolver2*>(GetFEModel()->GetCurrentStep()->GetFESolver());
if (psolid_solver)
{
vector<double>& Fr = psolid_solver->m_Fr;
const vector<int>& id = node.m_ID;
return (-id[0] - 2 >= 0 ? Fr[-id[0] - 2] : 0);
}
// This code is from the "reaction forces" plot variable
// TODO: Need to check if code above produces the same answer as below. If so,
// just use code below.
FEModel& fem = *GetFEModel();
int dofX = fem.GetDOFIndex("x");
if (dofX >= 0)
{
double Rx = node.get_load(dofX);
return Rx;
}
return 0;
}
//-----------------------------------------------------------------------------
double FENodeForceY::value(const FENode& node)
{
FESolidSolver2* psolid_solver = dynamic_cast<FESolidSolver2*>(GetFEModel()->GetCurrentStep()->GetFESolver());
if (psolid_solver)
{
vector<double>& Fr = psolid_solver->m_Fr;
const vector<int>& id = node.m_ID;
return (-id[1] - 2 >= 0 ? Fr[-id[1]-2] : 0);
}
// This code is from the "reaction forces" plot variable
// TODO: Need to check if code above produces the same answer as below. If so,
// just use code below.
FEModel& fem = *GetFEModel();
int dofY = fem.GetDOFIndex("y");
if (dofY >= 0)
{
double Ry = node.get_load(dofY);
return Ry;
}
return 0;
}
//-----------------------------------------------------------------------------
double FENodeForceZ::value(const FENode& node)
{
FESolver* solver = GetFEModel()->GetCurrentStep()->GetFESolver();
FESolidSolver2* psolid_solver = dynamic_cast<FESolidSolver2*>(solver);
if (psolid_solver)
{
vector<double>& Fr = psolid_solver->m_Fr;
const vector<int>& id = node.m_ID;
return (-id[2] - 2 >= 0 ? Fr[-id[2]-2] : 0);
}
FEExplicitSolidSolver* explicitSolver = dynamic_cast<FEExplicitSolidSolver*>(solver);
if (explicitSolver)
{
vector<double>& Fr = explicitSolver->m_Fr;
const vector<int>& id = node.m_ID;
return (-id[2] - 2 >= 0 ? Fr[-id[2] - 2] : 0);
}
// This code is from the "reaction forces" plot variable
// TODO: Need to check if code above produces the same answer as below. If so,
// just use code below.
FEModel& fem = *GetFEModel();
int dofZ = fem.GetDOFIndex("z");
if (dofZ >= 0)
{
double Rz = node.get_load(dofZ);
return Rz;
}
return 0;
}
//-----------------------------------------------------------------------------
double FELogContactGap::value(FESurfaceElement& el)
{
FEContactSurface* ps = dynamic_cast<FEContactSurface*>(el.GetMeshPartition());
if (ps == nullptr) return 0.0;
// returned contact gap
double g = 0.0;
// NOTE: the sliding surface does not use material points, so we need this little hack.
FESlidingSurface* ss = dynamic_cast<FESlidingSurface*>(ps);
if (ss)
{
for (int j = 0; j < el.Nodes(); ++j)
{
double gj = ss->m_data[el.m_lnode[j]].m_gap;
g += gj;
}
g /= el.Nodes();
return g;
}
else
{
for (int i = 0; i < el.GaussPoints(); ++i)
{
FEMaterialPoint* mp = el.GetMaterialPoint(i);
FEContactMaterialPoint* cp = dynamic_cast<FEContactMaterialPoint*>(mp);
if (cp)
{
g += cp->m_gap;
}
}
g /= (double)el.GaussPoints();
}
return g;
}
//-----------------------------------------------------------------------------
double FELogContactPressure::value(FESurfaceElement& el)
{
FEContactSurface* ps = dynamic_cast<FEContactSurface*>(el.GetMeshPartition());
if (ps == nullptr) return 0.0;
double Lm = 0.0;
// NOTE: the sliding surface does not use material points, so we need this little hack.
FESlidingSurface* ss = dynamic_cast<FESlidingSurface*>(ps);
if (ss)
{
for (int j = 0; j < el.Nodes(); ++j)
{
double Lmj = ss->m_data[el.m_lnode[j]].m_Ln;
Lm += Lmj;
}
Lm /= el.Nodes();
}
else
{
for (int i = 0; i < el.GaussPoints(); ++i)
{
FEMaterialPoint* mp = el.GetMaterialPoint(i);
FEContactMaterialPoint* cp = dynamic_cast<FEContactMaterialPoint*>(mp);
if (cp)
{
Lm += cp->m_Ln;
}
}
Lm /= (double)el.GaussPoints();
}
return Lm;
}
//-----------------------------------------------------------------------------
double FELogContactTractionX::value(FESurfaceElement& el)
{
FEContactSurface* ps = dynamic_cast<FEContactSurface*>(el.GetMeshPartition());
if (ps == nullptr) return 0.0;
FEContactInterface* pci = ps->GetContactInterface(); assert(pci);
if ((pci == 0) || pci->IsActive())
{
vec3d tn;
ps->GetSurfaceTraction(el.m_lid, tn);
return tn.x;
}
return 0.0;
}
//-----------------------------------------------------------------------------
double FELogContactTractionY::value(FESurfaceElement& el)
{
FEContactSurface* ps = dynamic_cast<FEContactSurface*>(el.GetMeshPartition());
if (ps == nullptr) return 0.0;
FEContactInterface* pci = ps->GetContactInterface(); assert(pci);
if ((pci == 0) || pci->IsActive())
{
vec3d tn;
ps->GetSurfaceTraction(el.m_lid, tn);
return tn.y;
}
return 0.0;
}
//-----------------------------------------------------------------------------
double FELogContactTractionZ::value(FESurfaceElement& el)
{
FEContactSurface* ps = dynamic_cast<FEContactSurface*>(el.GetMeshPartition());
if (ps == nullptr) return 0.0;
FEContactInterface* pci = ps->GetContactInterface(); assert(pci);
if ((pci == 0) || pci->IsActive())
{
vec3d tn;
ps->GetSurfaceTraction(el.m_lid, tn);
return tn.z;
}
return 0.0;
}
//-----------------------------------------------------------------------------
double FELogElemPosX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(i);
val += pt.m_rt.x;
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemPosY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(i);
val += pt.m_rt.y;
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemPosZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(i);
val += pt.m_rt.z;
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemJacobian::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_J;
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrainX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
val += E.xx();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrainY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
val += E.yy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrainZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
val += E.zz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrainXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
val += E.xy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrainYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
val += E.yz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrainXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
val += E.xz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrain1::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
E.exact_eigen(l);
val += l[0];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrainEffective::value(FEElement& el)
{
int nint = el.GaussPoints();
mat3ds Eavg; Eavg.zero();
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds C = ep.LeftCauchyGreen();
mat3dd I(1.0);
mat3ds E = (C - I)*0.5;
Eavg += E;
}
Eavg /= (double)nint;
double val = Eavg.effective_norm();
return val;
}
//-----------------------------------------------------------------------------
double FELogElemStrain2::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
E.exact_eigen(l);
val += l[1];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrain3::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds E = pt.Strain();
E.exact_eigen(l);
val += l[2];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemInfStrainX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds e = pt.SmallStrain();
val += e.xx();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemInfStrainY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds e = pt.SmallStrain();
val += e.yy();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemInfStrainZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds e = pt.SmallStrain();
val += e.zz();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemInfStrainXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds e = pt.SmallStrain();
val += e.xy();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemInfStrainYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds e = pt.SmallStrain();
val += e.yz();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemInfStrainXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds e = pt.SmallStrain();
val += e.xz();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretchX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds U = pt.RightStretch();
val += U.xx();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretchY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds U = pt.RightStretch();
val += U.yy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretchZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds U = pt.RightStretch();
val += U.zz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretchXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds U = pt.RightStretch();
val += U.xy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretchYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds U = pt.RightStretch();
val += U.yz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretchXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds U = pt.RightStretch();
val += U.xz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretch1::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds U = pt.RightStretch();
U.exact_eigen(l);
val += l[0];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretch2::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds U = pt.RightStretch();
U.exact_eigen(l);
val += l[1];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretch3::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds U = pt.RightStretch();
U.exact_eigen(l);
val += l[2];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightStretchEffective::value(FEElement& el)
{
int nint = el.GaussPoints();
mat3ds Uavg; Uavg.zero();
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds U = ep.RightStretch();
Uavg += U;
}
Uavg /= (double)nint;
double val = Uavg.effective_norm();
return val;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretchX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds V = pt.LeftStretch();
val += V.xx();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretchY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds V = pt.LeftStretch();
val += V.yy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretchZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds V = pt.LeftStretch();
val += V.zz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretchXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds V = pt.LeftStretch();
val += V.xy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretchYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds V = pt.LeftStretch();
val += V.yz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretchXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds V = pt.LeftStretch();
val += V.xz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretch1::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds V = pt.LeftStretch();
V.exact_eigen(l);
val += l[0];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretch2::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds V = pt.LeftStretch();
V.exact_eigen(l);
val += l[1];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretch3::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds V = pt.LeftStretch();
V.exact_eigen(l);
val += l[2];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftStretchEffective::value(FEElement& el)
{
int nint = el.GaussPoints();
mat3ds Vavg; Vavg.zero();
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds V = ep.LeftStretch();
Vavg += V;
}
Vavg /= (double)nint;
double val = Vavg.effective_norm();
return val;
}
//-----------------------------------------------------------------------------
double FELogElemRightHenckyX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds H = pt.RightHencky();
val += H.xx();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightHenckyY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds H = pt.RightHencky();
val += H.yy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightHenckyZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds H = pt.RightHencky();
val += H.zz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightHenckyXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds H = pt.RightHencky();
val += H.xy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightHenckyYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds H = pt.RightHencky();
val += H.yz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightHenckyXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds H = pt.RightHencky();
val += H.xz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightHencky1::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds H = pt.RightHencky();
H.exact_eigen(l);
val += l[0];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightHencky2::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds H = pt.RightHencky();
H.exact_eigen(l);
val += l[1];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightHencky3::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds H = pt.RightHencky();
H.exact_eigen(l);
val += l[2];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemRightHenckyEffective::value(FEElement& el)
{
int nint = el.GaussPoints();
mat3ds Havg; Havg.zero();
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds H = ep.RightHencky();
Havg += H;
}
Havg /= (double)nint;
double val = Havg.effective_norm();
return val;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHenckyX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
val += h.xx();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHenckyY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
val += h.yy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHenckyZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
val += h.zz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHenckyXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
val += h.xy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHenckyYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
val += h.yz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHenckyXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
val += h.xz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHencky1::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
h.exact_eigen(l);
val += l[0];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHencky2::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
h.exact_eigen(l);
val += l[1];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHencky3::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds h = pt.LeftHencky();
h.exact_eigen(l);
val += l[2];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemLeftHenckyEffective::value(FEElement& el)
{
int nint = el.GaussPoints();
mat3ds havg; havg.zero();
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
mat3ds h = ep.LeftHencky();
havg += h;
}
havg /= (double)nint;
double val = havg.effective_norm();
return val;
}
//-----------------------------------------------------------------------------
double FELogElemStressX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_s.xx();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStressY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_s.yy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStressZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_s.zz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStressXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_s.xy();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStressYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_s.yz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStressXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_s.xz();
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStressEffective::value(FEElement& el)
{
int nint = el.GaussPoints();
mat3ds savg; savg.zero();
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
savg += ep.m_s;
}
savg /= (double)nint;
double val = savg.effective_norm();
return val;
}
//-----------------------------------------------------------------------------
double FELogElemStress1::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
pt.m_s.exact_eigen(l);
val += l[0];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStress2::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
pt.m_s.exact_eigen(l);
val += l[1];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStress3::value(FEElement& el)
{
double l[3];
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
pt.m_s.exact_eigen(l);
val += l[2];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK2StressX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds S = pt.pull_back(pt.m_s);
val += S.xx();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK2StressY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds S = pt.pull_back(pt.m_s);
val += S.yy();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK2StressZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds S = pt.pull_back(pt.m_s);
val += S.zz();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK2StressXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds S = pt.pull_back(pt.m_s);
val += S.xy();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK2StressYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds S = pt.pull_back(pt.m_s);
val += S.yz();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK2StressXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3ds S = pt.pull_back(pt.m_s);
val += S.xz();
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK1StressXX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3d P = pt.m_J*pt.m_s*pt.m_F.transinv();
val += P(0,0);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK1StressYY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3d P = pt.m_J*pt.m_s*pt.m_F.transinv();
val += P(1,1);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK1StressZZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3d P = pt.m_J*pt.m_s*pt.m_F.transinv();
val += P(2,2);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK1StressXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3d P = pt.m_J*pt.m_s*pt.m_F.transinv();
val += P(0,1);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK1StressYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3d P = pt.m_J*pt.m_s*pt.m_F.transinv();
val += P(1,2);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK1StressXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3d P = pt.m_J*pt.m_s*pt.m_F.transinv();
val += P(0,2);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK1StressYX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3d P = pt.m_J*pt.m_s*pt.m_F.transinv();
val += P(1,0);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK1StressZY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3d P = pt.m_J*pt.m_s*pt.m_F.transinv();
val += P(2,1);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemPK1StressZX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
mat3d P = pt.m_J*pt.m_s*pt.m_F.transinv();
val += P(2,0);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemStressEigenVector::value(FEElement& el)
{
assert(m_eigenVector >= 0);
assert(m_component >= 0);
// calculate average stress
mat3ds s(0.0);
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
s += pt.m_s;
}
s /= (double)nint;
// get the eigen vectors
vec3d e[3];
double l[3];
s.eigen(l, e);
// extract component
double v = 0.0;
switch (m_component)
{
case 0: v = e[m_eigenVector].x; break;
case 1: v = e[m_eigenVector].y; break;
case 2: v = e[m_eigenVector].z; break;
}
return v;
}
//-----------------------------------------------------------------------------
double FELogElemDeformationGradientXX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_F(0,0);
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemDeformationGradientXY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_F(0,1);
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemDeformationGradientXZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_F(0,2);
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemDeformationGradientYX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_F(1,0);
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemDeformationGradientYY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_F(1,1);
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemDeformationGradientYZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_F(1,2);
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemDeformationGradientZX::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_F(2,0);
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemDeformationGradientZY::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_F(2,1);
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemDeformationGradientZZ::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEElasticMaterialPoint& pt = *el.GetMaterialPoint(i)->ExtractData<FEElasticMaterialPoint>();
val += pt.m_F(2,2);
}
return val / (double) nint;
}
double FELogTotalDeformationGradient::value(FEElement& el)
{
double val = 0.0;
int nint = el.GaussPoints();
for (int i = 0; i < nint; ++i)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(i);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FEPrestrainMaterialPoint* pp = mp.ExtractData<FEPrestrainMaterialPoint>();
mat3d F = pt.m_F;
if (pp)
{
mat3d Fp = pp->prestrain();
F = F * Fp;
}
val += F(m_r, m_c);
}
return val / (double)nint;
}
//-----------------------------------------------------------------------------
double FELogElemElasticity_::value(FEElement& el, int n)
{
FEElasticMaterial* pme = GetFEModel()->GetMaterial(el.GetMatID())->ExtractProperty<FEElasticMaterial>();
if ((pme == 0) || pme->IsRigid()) return 0;
tens4dmm c;
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(i);
c = pme->SolidTangent(pt);
val += c.d[n];
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemStrainEnergyDensity::value(FEElement& el)
{
FEElasticMaterial* pme = GetFEModel()->GetMaterial(el.GetMatID())->ExtractProperty<FEElasticMaterial>();
if ((pme == 0) || pme->IsRigid()) return 0;
double sed;
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(i);
sed = pme->StrainEnergyDensity(pt);
val += sed;
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemDevStrainEnergyDensity::value(FEElement& el)
{
FEElasticMaterial* pme = GetFEModel()->GetMaterial(el.GetMatID())->ExtractProperty<FEElasticMaterial>();
FEUncoupledMaterial* pmu = dynamic_cast<FEUncoupledMaterial*>(pme);
if ((pme == 0) || pme->IsRigid() || (pmu == 0)) return 0;
double sed;
double val = 0.0;
int nint = el.GaussPoints();
for (int i=0; i<nint; ++i)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(i);
sed = pmu->DevStrainEnergyDensity(pt);
val += sed;
}
return val / (double) nint;
}
//-----------------------------------------------------------------------------
double FELogElemFiberStretch::value(FEElement& el)
{
int matID = el.GetMatID();
FEMaterial* mat = GetFEModel()->GetMaterial(matID);
int n = el.GaussPoints();
double l = 0.0;
for (int j=0; j<n; ++j)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(j);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
mat3d Q = mat->GetLocalCS(mp);
vec3d ri = Q.col(0);
vec3d r = pt.m_F*ri;
l += r.norm();
}
l /= (double) n;
return l;
}
//-----------------------------------------------------------------------------
double FELogElemFiberVector_::value(FEElement& el)
{
int matID = el.GetMatID();
FEMaterial* mat = GetFEModel()->GetMaterial(matID);
FEElasticMaterial* pme = mat->ExtractProperty<FEElasticMaterial>();
if (pme == nullptr) return 0.0;
FEVec3dValuator* vec = dynamic_cast<FEVec3dValuator*>(pme->GetProperty("fiber"));
if (vec == nullptr) return 0.0;
int n = el.GaussPoints();
double l = 0.0;
for (int j = 0; j<n; ++j)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(j);
const FEElasticMaterialPoint* pt = mp.ExtractData<const FEElasticMaterialPoint>();
if (pt)
{
mat3d Q = pme->GetLocalCS(mp);
mat3d F = pt->m_F;
vec3d a0 = vec->unitVector(mp);
vec3d ar = Q * a0;
vec3d a = F * ar; a.unit();
switch (m_comp)
{
case 0: l += a.x; break;
case 1: l += a.y; break;
case 2: l += a.z; break;
}
}
}
l /= (double)n;
return l;
}
//-----------------------------------------------------------------------------
double FELogDamage_::value(FEElement& el)
{
int nint = el.GaussPoints();
double D = 0;
if (m_comp == -1)
{
for (int j = 0; j < nint; ++j)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(j);
FEReactiveMaterialPoint* ppd = pt.ExtractData<FEReactiveMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pt.ExtractData<FEElasticMixtureMaterialPoint>();
FEMultigenerationMaterialPoint* pmg = pt.ExtractData<FEMultigenerationMaterialPoint>();
if (ppd) D += (float)ppd->BrokenBonds();
else if (pem) {
for (int k = 0; k < pem->Components(); ++k)
{
FEReactiveMaterialPoint* ppd = pem->GetPointData(k)->ExtractData<FEReactiveMaterialPoint>();
if (ppd) D += (float)ppd->BrokenBonds();
}
}
else if (pmg) {
for (int k = 0; k < pmg->Components(); ++k)
{
FEReactiveMaterialPoint* ppd = pmg->GetPointData(k)->ExtractData<FEReactiveMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pmg->GetPointData(k)->ExtractData<FEElasticMixtureMaterialPoint>();
if (ppd) D += (float)ppd->BrokenBonds();
else if (pem)
{
for (int l = 0; l < pem->Components(); ++l)
{
FEReactiveMaterialPoint* ppd = pem->GetPointData(l)->ExtractData<FEReactiveMaterialPoint>();
if (ppd) D += (float)ppd->BrokenBonds();
}
}
}
}
}
}
else
{
for (int n = 0; n < el.GaussPoints(); ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMixtureMaterialPoint* mmp = mp.ExtractData< FEElasticMixtureMaterialPoint>();
if (mmp && (m_comp < mmp->Components()))
{
FEReactiveMaterialPoint* dp = mmp->GetPointData(m_comp)->ExtractData<FEReactiveMaterialPoint>();
if (dp) D += dp->BrokenBonds();
}
}
}
D /= (double) nint;
return D;
}
//-----------------------------------------------------------------------------
double FELogIntactBonds::value(FEElement& el)
{
int nint = el.GaussPoints();
double D = 0;
for (int j=0; j<nint; ++j)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(j);
FEReactiveMaterialPoint* ppd = pt.ExtractData<FEReactiveMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pt.ExtractData<FEElasticMixtureMaterialPoint>();
FEMultigenerationMaterialPoint* pmg = pt.ExtractData<FEMultigenerationMaterialPoint>();
if (ppd) D += (float) ppd->IntactBonds();
else if (pem) {
for (int k=0; k<pem->Components(); ++k)
{
FEReactiveMaterialPoint* ppd = pem->GetPointData(k)->ExtractData<FEReactiveMaterialPoint>();
if (ppd) D += (float) ppd->IntactBonds();
}
}
else if (pmg) {
for (int k=0; k<pmg->Components(); ++k)
{
FEReactiveMaterialPoint* ppd = pmg->GetPointData(k)->ExtractData<FEReactiveMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pmg->GetPointData(k)->ExtractData<FEElasticMixtureMaterialPoint>();
if (ppd) D += (float) ppd->IntactBonds();
else if (pem)
{
for (int l=0; l<pem->Components(); ++l)
{
FEReactiveMaterialPoint* ppd = pem->GetPointData(l)->ExtractData<FEReactiveMaterialPoint>();
if (ppd) D += (float) ppd->IntactBonds();
}
}
}
}
}
D /= (double) nint;
return D;
}
//-----------------------------------------------------------------------------
double FELogYieldedBonds::value(FEElement& el)
{
int nint = el.GaussPoints();
double D = 0;
for (int j=0; j<nint; ++j)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(j);
FEReactiveMaterialPoint* ppd = pt.ExtractData<FEReactiveMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pt.ExtractData<FEElasticMixtureMaterialPoint>();
FEMultigenerationMaterialPoint* pmg = pt.ExtractData<FEMultigenerationMaterialPoint>();
if (ppd) D += (float) ppd->YieldedBonds();
else if (pem) {
for (int k=0; k<pem->Components(); ++k)
{
FEReactiveMaterialPoint* ppd = pem->GetPointData(k)->ExtractData<FEReactiveMaterialPoint>();
if (ppd) D += (float) ppd->YieldedBonds();
}
}
else if (pmg) {
for (int k=0; k<pmg->Components(); ++k)
{
FEReactiveMaterialPoint* ppd = pmg->GetPointData(k)->ExtractData<FEReactiveMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pmg->GetPointData(k)->ExtractData<FEElasticMixtureMaterialPoint>();
if (ppd) D += (float) ppd->YieldedBonds();
else if (pem)
{
for (int l=0; l<pem->Components(); ++l)
{
FEReactiveMaterialPoint* ppd = pem->GetPointData(l)->ExtractData<FEReactiveMaterialPoint>();
if (ppd) D += (float) ppd->YieldedBonds();
}
}
}
}
}
D /= (double) nint;
return D;
}
//-----------------------------------------------------------------------------
double FELogFatigueBonds::value(FEElement& el)
{
int nint = el.GaussPoints();
double D = 0;
for (int j=0; j<nint; ++j)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(j);
FEReactiveMaterialPoint* ppd = pt.ExtractData<FEReactiveMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pt.ExtractData<FEElasticMixtureMaterialPoint>();
FEMultigenerationMaterialPoint* pmg = pt.ExtractData<FEMultigenerationMaterialPoint>();
if (ppd) D += (float) ppd->FatigueBonds();
else if (pem) {
for (int k=0; k<pem->Components(); ++k)
{
FEReactiveMaterialPoint* ppd = pem->GetPointData(k)->ExtractData<FEReactiveMaterialPoint>();
if (ppd) D += (float) ppd->FatigueBonds();
}
}
else if (pmg) {
for (int k=0; k<pmg->Components(); ++k)
{
FEReactiveMaterialPoint* ppd = pmg->GetPointData(k)->ExtractData<FEReactiveMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pmg->GetPointData(k)->ExtractData<FEElasticMixtureMaterialPoint>();
if (ppd) D += (float) ppd->FatigueBonds();
else if (pem)
{
for (int l=0; l<pem->Components(); ++l)
{
FEReactiveMaterialPoint* ppd = pem->GetPointData(l)->ExtractData<FEReactiveMaterialPoint>();
if (ppd) D += (float) ppd->FatigueBonds();
}
}
}
}
}
D /= (double) nint;
return D;
}
//-----------------------------------------------------------------------------
double FELogOctahedralPlasticStrain::value(FEElement& el)
{
int nint = el.GaussPoints();
double D = 0;
for (int j=0; j<nint; ++j)
{
FEMaterialPoint& pt = *el.GetMaterialPoint(j);
FEReactivePlasticityMaterialPoint* prp = pt.ExtractData<FEReactivePlasticityMaterialPoint>();
FEReactivePlasticDamageMaterialPoint* prd = pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pt.ExtractData<FEElasticMixtureMaterialPoint>();
FEMultigenerationMaterialPoint* pmg = pt.ExtractData<FEMultigenerationMaterialPoint>();
if (prp) D += (float) prp->m_gp[0];
else if (prd) D += (float) prd->m_gp[0];
else if (pem) {
for (int k=0; k<pem->Components(); ++k)
{
FEReactivePlasticityMaterialPoint* prp = pt.ExtractData<FEReactivePlasticityMaterialPoint>();
FEReactivePlasticDamageMaterialPoint* prd = pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
if (prp) D += (float) prp->m_gp[0];
else if (prd) D += (float) prd->m_gp[0];
}
}
else if (pmg) {
for (int k=0; k<pmg->Components(); ++k)
{
FEReactivePlasticityMaterialPoint* prp = pt.ExtractData<FEReactivePlasticityMaterialPoint>();
FEReactivePlasticDamageMaterialPoint* prd = pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
FEElasticMixtureMaterialPoint* pem = pmg->GetPointData(k)->ExtractData<FEElasticMixtureMaterialPoint>();
if (prp) D += (float) prp->m_gp[0];
else if (prd) D += (float) prd->m_gp[0];
else if (pem)
{
for (int l=0; l<pem->Components(); ++l)
{
FEReactivePlasticityMaterialPoint* prp = pt.ExtractData<FEReactivePlasticityMaterialPoint>();
FEReactivePlasticDamageMaterialPoint* prd = pt.ExtractData<FEReactivePlasticDamageMaterialPoint>();
if (prp) D += (float) prp->m_gp[0];
else if (prd) D += (float) prd->m_gp[0];
}
}
}
}
}
D /= (double) nint;
return D;
}
//-----------------------------------------------------------------------------
double FELogDiscreteElementStretch::value(FEElement& el)
{
if (dynamic_cast<FEDiscreteElement*>(&el) == nullptr) return 0.0;
FEDiscreteElement& del = dynamic_cast<FEDiscreteElement&>(el);
FEMesh& mesh = GetFEModel()->GetMesh();
vec3d ra0 = mesh.Node(del.m_node[0]).m_r0;
vec3d ra1 = mesh.Node(del.m_node[0]).m_rt;
vec3d rb0 = mesh.Node(del.m_node[1]).m_r0;
vec3d rb1 = mesh.Node(del.m_node[1]).m_rt;
double L0 = (rb0 - ra0).norm();
double Lt = (rb1 - ra1).norm();
double l = Lt / L0;
return l;
}
//-----------------------------------------------------------------------------
double FELogDiscreteElementElongation::value(FEElement& el)
{
if (dynamic_cast<FEDiscreteElement*>(&el) == nullptr) return 0.0;
FEDiscreteElement& del = dynamic_cast<FEDiscreteElement&>(el);
FEMesh& mesh = GetFEModel()->GetMesh();
vec3d ra0 = mesh.Node(del.m_node[0]).m_r0;
vec3d ra1 = mesh.Node(del.m_node[0]).m_rt;
vec3d rb0 = mesh.Node(del.m_node[1]).m_r0;
vec3d rb1 = mesh.Node(del.m_node[1]).m_rt;
double L0 = (rb0 - ra0).norm();
double Lt = (rb1 - ra1).norm();
double Dl = Lt - L0;
return Dl;
}
//-----------------------------------------------------------------------------
double FELogDiscreteElementForce::value(FEElement& el)
{
if (dynamic_cast<FEDiscreteElement*>(&el) == nullptr) return 0.0;
FEDiscreteElement& del = dynamic_cast<FEDiscreteElement&>(el);
FEMesh& mesh = GetFEModel()->GetMesh();
vec3d ra1 = mesh.Node(del.m_node[0]).m_rt;
vec3d rb1 = mesh.Node(del.m_node[1]).m_rt;
vec3d e = rb1 - ra1; e.unit();
FEDiscreteElasticMaterialPoint* mp = el.GetMaterialPoint(0)->ExtractData<FEDiscreteElasticMaterialPoint>();
assert(mp);
if (mp)
{
vec3d F = mp->m_Ft;
double Fm = F * e;
return Fm;
}
else return 0.0;
}
//-----------------------------------------------------------------------------
double FELogDiscreteElementForceX::value(FEElement& el)
{
FEDiscreteElasticMaterialPoint* mp = el.GetMaterialPoint(0)->ExtractData<FEDiscreteElasticMaterialPoint>();
if (mp) return mp->m_Ft.x;
else return 0.0;
}
//-----------------------------------------------------------------------------
double FELogDiscreteElementForceY::value(FEElement& el)
{
FEDiscreteElasticMaterialPoint* mp = dynamic_cast<FEDiscreteElasticMaterialPoint*>(el.GetMaterialPoint(0));
if (mp) return mp->m_Ft.y;
else return 0.0;
}
//-----------------------------------------------------------------------------
double FELogDiscreteElementForceZ::value(FEElement& el)
{
FEDiscreteElasticMaterialPoint* mp = dynamic_cast<FEDiscreteElasticMaterialPoint*>(el.GetMaterialPoint(0));
if (mp) return mp->m_Ft.z;
else return 0.0;
}
//-----------------------------------------------------------------------------
double FELogElementMixtureStress::value(FEElement& el)
{
if (m_comp < 0) return 0.0;
double s = 0.0;
for (int n = 0; n < el.GaussPoints(); ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMixtureMaterialPoint* mmp = mp.ExtractData< FEElasticMixtureMaterialPoint>();
if (mmp)
{
if (m_comp < mmp->Components())
{
FEElasticMaterialPoint& ep = *mmp->GetPointData(m_comp)->ExtractData<FEElasticMaterialPoint>();
switch (m_metric)
{
case 0: s += ep.m_s.xx(); break;
case 1: s += ep.m_s.xy(); break;
case 2: s += ep.m_s.yy(); break;
case 3: s += ep.m_s.xz(); break;
case 4: s += ep.m_s.yz(); break;
case 5: s += ep.m_s.zz(); break;
}
}
}
}
s /= (double)el.GaussPoints();
return s;
}
//-----------------------------------------------------------------------------
double FELogRigidBodyR11::value(FERigidBody& rb) { return (rb.GetRotation().RotationMatrix()(0,0)); }
double FELogRigidBodyR12::value(FERigidBody& rb) { return (rb.GetRotation().RotationMatrix()(0, 1)); }
double FELogRigidBodyR13::value(FERigidBody& rb) { return (rb.GetRotation().RotationMatrix()(0, 2)); }
double FELogRigidBodyR21::value(FERigidBody& rb) { return (rb.GetRotation().RotationMatrix()(1, 0)); }
double FELogRigidBodyR22::value(FERigidBody& rb) { return (rb.GetRotation().RotationMatrix()(1, 1)); }
double FELogRigidBodyR23::value(FERigidBody& rb) { return (rb.GetRotation().RotationMatrix()(1, 2)); }
double FELogRigidBodyR31::value(FERigidBody& rb) { return (rb.GetRotation().RotationMatrix()(2, 0)); }
double FELogRigidBodyR32::value(FERigidBody& rb) { return (rb.GetRotation().RotationMatrix()(2, 1)); }
double FELogRigidBodyR33::value(FERigidBody& rb) { return (rb.GetRotation().RotationMatrix()(2, 2)); }
//-----------------------------------------------------------------------------
double FELogRigidBodyEulerX::value(FERigidBody& rb) { double x, y, z; rb.GetRotation().GetEuler(x, y, z); return x; }
double FELogRigidBodyEulerY::value(FERigidBody& rb) { double x, y, z; rb.GetRotation().GetEuler(x, y, z); return y; }
double FELogRigidBodyEulerZ::value(FERigidBody& rb) { double x, y, z; rb.GetRotation().GetEuler(x, y, z); return z; }
//-----------------------------------------------------------------------------
double FELogRigidBodyPosX::value(FERigidBody& rb) { return rb.m_rt.x; }
double FELogRigidBodyPosY::value(FERigidBody& rb) { return rb.m_rt.y; }
double FELogRigidBodyPosZ::value(FERigidBody& rb) { return rb.m_rt.z; }
//-----------------------------------------------------------------------------
double FELogRigidBodyVelX::value(FERigidBody& rb) { return rb.m_vt.x; }
double FELogRigidBodyVelY::value(FERigidBody& rb) { return rb.m_vt.y; }
double FELogRigidBodyVelZ::value(FERigidBody& rb) { return rb.m_vt.z; }
//-----------------------------------------------------------------------------
double FELogRigidBodyAccX::value(FERigidBody& rb) { return rb.m_at.x; }
double FELogRigidBodyAccY::value(FERigidBody& rb) { return rb.m_at.y; }
double FELogRigidBodyAccZ::value(FERigidBody& rb) { return rb.m_at.z; }
//-----------------------------------------------------------------------------
double FELogRigidBodyAngPosX::value(FERigidBody& rb) { return ((rb.GetRotation().GetVector()).x*rb.GetRotation().GetAngle()); }
double FELogRigidBodyAngPosY::value(FERigidBody& rb) { return ((rb.GetRotation().GetVector()).y*rb.GetRotation().GetAngle()); }
double FELogRigidBodyAngPosZ::value(FERigidBody& rb) { return ((rb.GetRotation().GetVector()).z*rb.GetRotation().GetAngle()); }
//-----------------------------------------------------------------------------
double FELogRigidBodyAngVelX::value(FERigidBody& rb) { return rb.m_wt.x; }
double FELogRigidBodyAngVelY::value(FERigidBody& rb) { return rb.m_wt.y; }
double FELogRigidBodyAngVelZ::value(FERigidBody& rb) { return rb.m_wt.z; }
//-----------------------------------------------------------------------------
double FELogRigidBodyAngAccX::value(FERigidBody& rb) { return rb.m_alt.x; }
double FELogRigidBodyAngAccY::value(FERigidBody& rb) { return rb.m_alt.y; }
double FELogRigidBodyAngAccZ::value(FERigidBody& rb) { return rb.m_alt.z; }
//-----------------------------------------------------------------------------
double FELogRigidBodyQuatX::value(FERigidBody& rb) { return rb.GetRotation().x; }
double FELogRigidBodyQuatY::value(FERigidBody& rb) { return rb.GetRotation().y; }
double FELogRigidBodyQuatZ::value(FERigidBody& rb) { return rb.GetRotation().z; }
double FELogRigidBodyQuatW::value(FERigidBody& rb) { return rb.GetRotation().w; }
//-----------------------------------------------------------------------------
double FELogRigidBodyForceX::value(FERigidBody& rb) { return rb.m_Fr.x; }
double FELogRigidBodyForceY::value(FERigidBody& rb) { return rb.m_Fr.y; }
double FELogRigidBodyForceZ::value(FERigidBody& rb) { return rb.m_Fr.z; }
//-----------------------------------------------------------------------------
double FELogRigidBodyTorqueX::value(FERigidBody& rb) { return rb.m_Mr.x; }
double FELogRigidBodyTorqueY::value(FERigidBody& rb) { return rb.m_Mr.y; }
double FELogRigidBodyTorqueZ::value(FERigidBody& rb) { return rb.m_Mr.z; }
//-----------------------------------------------------------------------------
double FELogRigidBodyKineticEnergy::value(FERigidBody& rb) {
FERigidBody&rbl = static_cast<FERigidBody&>(rb);
return (rbl.m_mass*(rbl.m_vt*rbl.m_vt) + rbl.m_wt*(rbl.m_moi*rbl.m_wt))/2;
}
//-----------------------------------------------------------------------------
double FELogRigidBodyIHAwx::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.InstantaneousHelicalAxis(omega, s, tdot); return omega.x; }
double FELogRigidBodyIHAwy::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.InstantaneousHelicalAxis(omega, s, tdot); return omega.y; }
double FELogRigidBodyIHAwz::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.InstantaneousHelicalAxis(omega, s, tdot); return omega.z; }
double FELogRigidBodyIHAwm::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.InstantaneousHelicalAxis(omega, s, tdot); return omega.norm() * 180 / PI; }
double FELogRigidBodyIHAsx::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.InstantaneousHelicalAxis(omega, s, tdot); return s.x; }
double FELogRigidBodyIHAsy::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.InstantaneousHelicalAxis(omega, s, tdot); return s.y; }
double FELogRigidBodyIHAsz::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.InstantaneousHelicalAxis(omega, s, tdot); return s.z; }
double FELogRigidBodyIHAtd::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.InstantaneousHelicalAxis(omega, s, tdot); return tdot; }
//-----------------------------------------------------------------------------
double FELogRigidBodyFHAwx::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.FiniteHelicalAxis(omega, s, tdot); return omega.x; }
double FELogRigidBodyFHAwy::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.FiniteHelicalAxis(omega, s, tdot); return omega.y; }
double FELogRigidBodyFHAwz::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.FiniteHelicalAxis(omega, s, tdot); return omega.z; }
double FELogRigidBodyFHAwm::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.FiniteHelicalAxis(omega, s, tdot); return omega.norm()*180/PI; }
double FELogRigidBodyFHAsx::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.FiniteHelicalAxis(omega, s, tdot); return s.x; }
double FELogRigidBodyFHAsy::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.FiniteHelicalAxis(omega, s, tdot); return s.y; }
double FELogRigidBodyFHAsz::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.FiniteHelicalAxis(omega, s, tdot); return s.z; }
double FELogRigidBodyFHAtd::value(FERigidBody& rb) { vec3d omega; vec3d s; double tdot; rb.FiniteHelicalAxis(omega, s, tdot); return tdot; }
//-----------------------------------------------------------------------------
double FELogRigidConnectorIHAwx::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->InstantaneousHelicalAxis(omega, s, tdot);
return omega.x;
}
double FELogRigidConnectorIHAwy::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->InstantaneousHelicalAxis(omega, s, tdot);
return omega.y;
}
double FELogRigidConnectorIHAwz::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->InstantaneousHelicalAxis(omega, s, tdot);
return omega.z;
}
double FELogRigidConnectorIHAwm::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->InstantaneousHelicalAxis(omega, s, tdot);
return omega.norm()*180/PI;
}
double FELogRigidConnectorIHAsx::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->InstantaneousHelicalAxis(omega, s, tdot);
return s.x;
}
double FELogRigidConnectorIHAsy::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->InstantaneousHelicalAxis(omega, s, tdot);
return s.y;
}
double FELogRigidConnectorIHAsz::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->InstantaneousHelicalAxis(omega, s, tdot);
return s.z;
}
double FELogRigidConnectorIHAtd::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->InstantaneousHelicalAxis(omega, s, tdot);
return tdot;
}
//-----------------------------------------------------------------------------
double FELogRigidConnectorFHAwx::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->FiniteHelicalAxis(omega, s, tdot);
return omega.x;
}
double FELogRigidConnectorFHAwy::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->FiniteHelicalAxis(omega, s, tdot);
return omega.y;
}
double FELogRigidConnectorFHAwz::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->FiniteHelicalAxis(omega, s, tdot);
return omega.z;
}
double FELogRigidConnectorFHAwm::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->FiniteHelicalAxis(omega, s, tdot);
return omega.norm()*180/PI;
}
double FELogRigidConnectorFHAsx::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->FiniteHelicalAxis(omega, s, tdot);
return s.x;
}
double FELogRigidConnectorFHAsy::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->FiniteHelicalAxis(omega, s, tdot);
return s.y;
}
double FELogRigidConnectorFHAsz::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->FiniteHelicalAxis(omega, s, tdot);
return s.z;
}
double FELogRigidConnectorFHAtd::value(FENLConstraint& rc) {
vec3d omega;
vec3d s;
double tdot;
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
prc->FiniteHelicalAxis(omega, s, tdot);
return tdot;
}
//-----------------------------------------------------------------------------
double FELogRigidConnectorForceX::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->m_F.x : 0);
}
double FELogRigidConnectorForceY::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->m_F.y : 0);
}
double FELogRigidConnectorForceZ::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->m_F.z : 0);
}
//-----------------------------------------------------------------------------
double FELogRigidConnectorMomentX::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->m_M.x : 0);
}
double FELogRigidConnectorMomentY::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->m_M.y : 0);
}
double FELogRigidConnectorMomentZ::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->m_M.z : 0);
}
//-----------------------------------------------------------------------------
double FELogRigidConnectorTranslationX::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->RelativeTranslation().x : 0);
}
double FELogRigidConnectorTranslationY::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->RelativeTranslation().y : 0);
}
double FELogRigidConnectorTranslationZ::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->RelativeTranslation().z : 0);
}
//-----------------------------------------------------------------------------
double FELogRigidConnectorRotationX::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->RelativeRotation().x : 0);
}
double FELogRigidConnectorRotationY::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->RelativeRotation().y : 0);
}
double FELogRigidConnectorRotationZ::value(FENLConstraint& rc)
{
FERigidConnector* prc = dynamic_cast<FERigidConnector*>(&rc);
return (prc ? prc->RelativeRotation().z : 0);
}
//-----------------------------------------------------------------------------
double FELogVolumeConstraint::value(FENLConstraint& rc)
{
FEVolumeConstraint* prc = dynamic_cast<FEVolumeConstraint*>(&rc);
return (prc ? prc->EnclosedVolume() : 0);
}
//-----------------------------------------------------------------------------
double FELogVolumePressure::value(FENLConstraint& rc)
{
FEVolumeConstraint* prc = dynamic_cast<FEVolumeConstraint*>(&rc);
return (prc ? prc->Pressure() : 0);
}
//=============================================================================
double FELogContactArea::value(FESurface& surface)
{
FEContactSurface* pcs = dynamic_cast<FEContactSurface*>(&surface);
if (pcs == 0) return 0.0;
// make sure the corresponding contact interface is active
// (in case the parent was not set, we'll proceed regardless)
FEContactInterface* pci = pcs->GetContactInterface(); assert(pci);
if ((pci == 0) || pci->IsActive())
{
double area = pcs->GetContactArea();
return area;
}
return 0.0;
}
double FELogMaxContactGap::value(FESurface& surface)
{
FEContactSurface* pcs = dynamic_cast<FEContactSurface*>(&surface);
if (pcs == 0) return 0.0;
// make sure the corresponding contact interface is active
// (in case the parent was not set, we'll proceed regardless)
FEContactInterface* pci = pcs->GetContactInterface(); assert(pci);
if ((pci == 0) || pci->IsActive())
{
double maxGap = 0;
for (int i = 0; i < pcs->Elements(); ++i)
{
FESurfaceElement& el = pcs->Element(i);
for (int n = 0; n < el.GaussPoints(); ++n)
{
FEContactMaterialPoint* pt = dynamic_cast<FEContactMaterialPoint*>(el.GetMaterialPoint(n));
if (pt)
{
if (pt->m_gap > maxGap) maxGap = pt->m_gap;
}
}
}
return maxGap;
}
return 0.0;
}
double FENormalizedInternalEnergy::value(FEDomain& dom)
{
double sum = 0.0;
double vol = 0.0;
FESolidDomain* solidDomain = dynamic_cast<FESolidDomain*>(&dom);
if (solidDomain == nullptr) return 0.0;
FEModel* fem = GetFEModel();
const FETimeInfo& ti = fem->GetTime();
double dt = ti.timeIncrement;
double P0 = fem->GetGlobalConstant("P");
if (P0 == 0.0) P0 = 1.0;
int NE = solidDomain->Elements();
for (int i = 0; i < NE; ++i)
{
FESolidElement& el = solidDomain->Element(i);
double Ve = solidDomain->Volume(el);
vol += Ve;
mat3ds s(0), D(0);
int nint = el.GaussPoints();
double* gw = el.GaussWeights();
double w = 0.0;
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>();
s += ep.m_s * gw[n];
D += ep.RateOfDeformation();
w += gw[n];
}
s /= w;
D /= w;
double We = s.dotdot(D);
sum += We * dt * Ve;
}
m_sum += sum;
double NTSIE = m_sum / (P0 * vol);
return NTSIE;
}
double FELogTotalEnergy::value(FEDomain& dom)
{
m_sum = 0.0;
if (dom.Class() == FE_DOMAIN_SOLID)
{
FEElasticMaterial* pme = dom.GetMaterial()->ExtractProperty<FEElasticMaterial>();
if (pme == 0) return false;
double E = 0.0;
FESolidDomain& solidDomain = dynamic_cast<FESolidDomain&>(dom);
for (int i = 0; i < solidDomain.Elements(); ++i)
{
FESolidElement& el = solidDomain.Element(i);
int nint = el.GaussPoints();
double* w = el.GaussWeights();
for (int n = 0; n < nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// strain energy
double W = pme->StrainEnergyDensity(mp);
// kinetic energy
double D = pme->Density(mp);
vec3d& v = pt.m_v;
double K = 0.5 * (v * v) * D;
double J0 = solidDomain.detJ0(el, n);
E += (K + W) * J0 * w[n];
}
}
m_sum = E;
}
return m_sum;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberExpPow.cpp | .cpp | 11,866 | 405 | /*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 "FEFiberExpPow.h"
#include <limits>
#include <FECore/log.h>
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberExpPow, FEFiberMaterial)
ADD_PARAMETER(m_alpha, FE_RANGE_GREATER_OR_EQUAL(0.0), "alpha");
ADD_PARAMETER(m_beta , FE_RANGE_GREATER_OR_EQUAL(2.0), "beta");
ADD_PARAMETER(m_ksi , FE_RANGE_GREATER_OR_EQUAL(0.0), "ksi" )->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_mu , FE_RANGE_GREATER_OR_EQUAL(0.0), "mu" )->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_lam0 , FE_RANGE_GREATER_OR_EQUAL(1.0), "lam0");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
// FEFiberExpPow
//-----------------------------------------------------------------------------
FEFiberExpPow::FEFiberExpPow(FEModel* pfem) : FEFiberMaterial(pfem)
{
m_alpha = 0;
m_beta = 2;
m_ksi = 0;
m_mu = 0;
m_lam0 = 1;
m_epsf = 1.0;
}
//-----------------------------------------------------------------------------
mat3ds FEFiberExpPow::FiberStress(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
mat3ds s;
// Calculate In - I0 = n0*C*n0 - I0
double lam0 = m_lam0(mp);
double In_I0 = n0*(C*n0) - lam0*lam0;
double ksi = m_ksi(mp);
double mu = m_mu(mp);
double alpha = m_alpha(mp);
double beta = m_beta(mp);
// only take fibers in tension into consideration
const double eps = m_epsf* std::numeric_limits<double>::epsilon();
if (In_I0 >= eps)
{
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
// calculate strain energy derivative
double Wl = ksi*pow(In_I0, beta-1.0)*exp(alpha*pow(In_I0, beta));
// calculate the fiber stress
s = N*(2.0*Wl/J);
// add the contribution from shear
if (mu != 0.0)
{
mat3ds BmI = pt.LeftCauchyGreen() - mat3dd(1);
s += (N*BmI).sym()*(m_mu(mp) / J);
}
}
else
{
s.zero();
}
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEFiberExpPow::FiberTangent(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
tens4ds c;
// Calculate In - I0 = n0*C*n0 - I0
double lam0 = m_lam0(mp);
double In_I0 = n0*(C*n0) - lam0*lam0;
double ksi = m_ksi(mp);
double mu = m_mu(mp);
double alpha = m_alpha(mp);
double beta = m_beta(mp);
// only take fibers in tension into consideration
const double eps = m_epsf*std::numeric_limits<double>::epsilon();
if (In_I0 >= eps)
{
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
tens4ds NxN = dyad1s(N);
// calculate strain energy 2nd derivative
double tmp = alpha*pow(In_I0, beta);
double Wll = ksi*pow(In_I0, beta-2.0)*((tmp+1)*beta-1.0)*exp(tmp);
// calculate the fiber tangent
c = NxN*(4.0*Wll/J);
// add the contribution from shear
if (mu != 0.0)
{
mat3ds B = pt.LeftCauchyGreen();
c += dyad4s(N, B)*(mu / J);
}
}
else
{
c.zero();
}
return c;
}
//-----------------------------------------------------------------------------
double FEFiberExpPow::FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0)
{
double sed = 0.0;
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
// Calculate In - I0 = n0*C*n0 - I0
double In = n0*(C*n0);
double lam0 = m_lam0(mp);
double In_I0 = In - lam0*lam0;
double ksi = m_ksi(mp);
double mu = m_mu(mp);
double alpha = m_alpha(mp);
double beta = m_beta(mp);
// only take fibers in tension into consideration
const double eps = 0;
if (In_I0 >= eps)
{
// calculate strain energy derivative
if (alpha > 0) {
sed = ksi/(alpha*beta)*(exp(alpha*pow(In_I0, beta))-1);
}
else
sed = ksi/beta*pow(In_I0, beta);
// add the contribution from shear
if (mu != 0.0)
{
mat3ds C2 = C.sqr();
sed += mu * (n0*(C2*n0) - 2 * (In - 1) - 1) / 4.0;
}
}
return sed;
}
// define the material parameters
BEGIN_FECORE_CLASS(FEElasticFiberExpPow, FEElasticFiberMaterial)
ADD_PARAMETER(m_fib.m_alpha, FE_RANGE_GREATER_OR_EQUAL(0.0), "alpha");
ADD_PARAMETER(m_fib.m_beta , FE_RANGE_GREATER_OR_EQUAL(2.0), "beta");
ADD_PARAMETER(m_fib.m_ksi , FE_RANGE_GREATER_OR_EQUAL(0.0), "ksi" )->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_fib.m_mu , FE_RANGE_GREATER_OR_EQUAL(0.0), "mu" )->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_fib.m_lam0 , FE_RANGE_GREATER_OR_EQUAL(1.0), "lam0");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
// FEFiberExponentialPower
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_FECORE_CLASS(FEFiberExponentialPower, FEElasticFiberMaterial)
ADD_PARAMETER(m_alpha, FE_RANGE_GREATER_OR_EQUAL(0.0), "alpha");
ADD_PARAMETER(m_beta , FE_RANGE_GREATER_OR_EQUAL(2.0), "beta" );
ADD_PARAMETER(m_ksi , FE_RANGE_GREATER_OR_EQUAL(0.0), "ksi" )->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_mu , FE_RANGE_GREATER_OR_EQUAL(0.0), "mu" )->setUnits(UNIT_PRESSURE);
ADD_PARAMETER(m_lam0 , FE_RANGE_GREATER_OR_EQUAL(1.0), "lam0");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEFiberExponentialPower::FEFiberExponentialPower(FEModel* pfem) : FEElasticFiberMaterial(pfem)
{
m_alpha = 0;
m_beta = 2;
m_ksi = 0;
m_mu = 0;
m_lam0 = 1;
m_epsf = 1.0; // set to 1 for compatibility with febio 2.10
}
//-----------------------------------------------------------------------------
bool FEFiberExponentialPower::Validate()
{
// TODO: how validate model parameters?
// if ((4 * m_ksi + 2 * m_mu) < 0) {
// feLogError("4*ksi+2*mu must be positive."); return false;
// }
return FEElasticFiberMaterial::Validate();
}
//-----------------------------------------------------------------------------
mat3ds FEFiberExponentialPower::FiberStress(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
mat3ds s;
// Calculate In - I0 = n0*C*n0 - I0
double lam0 = m_lam0(mp);
double In_I0 = n0*(C*n0) - lam0*lam0;
double ksi = m_ksi(mp);
double mu = m_mu(mp);
double alpha = m_alpha(mp);
double beta = m_beta(mp);
// only take fibers in tension into consideration
const double eps = m_epsf* std::numeric_limits<double>::epsilon();
if (In_I0 >= eps)
{
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
// calculate strain energy derivative
double Wl = ksi*pow(In_I0, beta-1.0)*exp(alpha*pow(In_I0, beta));
// calculate the fiber stress
s = N*(2.0*Wl/J);
// add the contribution from shear
if (mu != 0.0)
{
mat3ds BmI = pt.LeftCauchyGreen() - mat3dd(1);
s += (N*BmI).sym()*(m_mu(mp) / J);
}
}
else
{
s.zero();
}
return s;
}
//-----------------------------------------------------------------------------
tens4ds FEFiberExponentialPower::FiberTangent(FEMaterialPoint& mp, const vec3d& n0)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d &F = pt.m_F;
double J = pt.m_J;
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
tens4ds c;
// Calculate In - I0 = n0*C*n0 - I0
double lam0 = m_lam0(mp);
double In_I0 = n0*(C*n0) - lam0*lam0;
double ksi = m_ksi(mp);
double mu = m_mu(mp);
double alpha = m_alpha(mp);
double beta = m_beta(mp);
// only take fibers in tension into consideration
const double eps = m_epsf*std::numeric_limits<double>::epsilon();
if (In_I0 >= eps)
{
// get the global spatial fiber direction in current configuration
vec3d nt = F*n0;
// calculate the outer product of nt
mat3ds N = dyad(nt);
tens4ds NxN = dyad1s(N);
// calculate strain energy 2nd derivative
double tmp = alpha*pow(In_I0, beta);
double Wll = ksi*pow(In_I0, beta-2.0)*((tmp+1)*beta-1.0)*exp(tmp);
// calculate the fiber tangent
c = NxN*(4.0*Wll/J);
// add the contribution from shear
if (mu != 0.0)
{
mat3ds B = pt.LeftCauchyGreen();
c += dyad4s(N, B)*(mu / J);
}
}
else
{
c.zero();
}
return c;
}
//-----------------------------------------------------------------------------
//! Strain energy density
double FEFiberExponentialPower::FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0)
{
double sed = 0.0;
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// loop over all integration points
mat3ds C = pt.RightCauchyGreen();
// Calculate In - I0 = n0*C*n0 - I0
double In = n0*(C*n0);
double lam0 = m_lam0(mp);
double In_I0 = In - lam0*lam0;
double ksi = m_ksi(mp);
double mu = m_mu(mp);
double alpha = m_alpha(mp);
double beta = m_beta(mp);
// only take fibers in tension into consideration
const double eps = 0;
if (In_I0 >= eps)
{
// calculate strain energy derivative
if (alpha > 0) {
sed = ksi/(alpha*beta)*(exp(alpha*pow(In_I0, beta))-1);
}
else
sed = ksi/beta*pow(In_I0, beta);
// add the contribution from shear
if (mu != 0.0)
{
mat3ds C2 = C.sqr();
sed += mu * (n0*(C2*n0) - 2 * (In - 1) - 1) / 4.0;
}
}
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEReactivePlasticDamage.h | .h | 3,890 | 100 | /*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 "FEElasticMaterial.h"
#include "FEDamageCriterion.h"
#include "FEDamageCDF.h"
#include "FEPlasticFlowCurve.h"
#include "FEReactivePlasticDamageMaterialPoint.h"
//-----------------------------------------------------------------------------
// This material models damage in any reactive plastic materials.
class FEReactivePlasticDamage : public FEElasticMaterial
{
public:
FEReactivePlasticDamage(FEModel* pfem);
public:
//! data initialization and checking
bool Init() override;
//! calculate stress at material point
mat3ds Stress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
tens4ds Tangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double StrainEnergyDensity(FEMaterialPoint& pt) override;
//! evaluate elastic deformation gradient
void ElasticDeformationGradient(FEMaterialPoint& pt);
//! damage
double Damage(FEMaterialPoint& pt, int k);
//!< update fatigue material point at each iteration
void UpdateSpecializedMaterialPoints(FEMaterialPoint& pt, const FETimeInfo& tp) override;
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
// get the elastic material
FEElasticMaterial* GetElasticMaterial() override { return m_pBase; }
// get the yield surface normal
mat3ds YieldSurfaceNormal(FEMaterialPoint& mp);
// evaluate octahedral plastic strain
void OctahedralPlasticStrain(FEMaterialPoint& pt);
// evaluate reactive heat supply
void ReactiveHeatSupplyDensity(FEMaterialPoint& pt);
bool UseSecantTangent() override { return m_secant_tangent; }
void Serialize(DumpStream& ar) override;
public:
FEElasticMaterial* m_pBase; // base elastic material
FEDamageCriterion* m_pCrit; // yield criterion
FEPlasticFlowCurve* m_pFlow; // plastic flow curve
FEDamageCDF* m_pYDamg; // yield damage model
FEDamageCriterion* m_pYDCrit; // yield damage criterion
FEDamageCDF* m_pIDamg; // intact damage model
FEDamageCriterion* m_pIDCrit; // intact damage criterion
public:
bool m_isochrc; // flag for constraining plastic def grad to be isochoric
double m_rtol; // user-defined relative tolerance
double m_bias; // biasing factor for intervals in yield measures and bond fractions
bool m_secant_tangent; //!< flag for using secant tangent
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FETCNonlinearOrthotropic.cpp | .cpp | 20,352 | 624 | /*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 "FETCNonlinearOrthotropic.h"
// define the material parameters
BEGIN_FECORE_CLASS(FETCNonlinearOrthotropic, FEUncoupledMaterial)
ADD_PARAMETER(m_c1, "c1");
ADD_PARAMETER(m_c2, "c2");
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" );
ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional);
END_FECORE_CLASS();
//////////////////////////////////////////////////////////////////////
// FETCNonlinearOrthotropic
//////////////////////////////////////////////////////////////////////
FETCNonlinearOrthotropic::FETCNonlinearOrthotropic(FEModel* pfem) : FEUncoupledMaterial(pfem)
{
m_c1 = 0.0;
m_c2 = 0.0;
m_beta[0] = m_beta[1] = m_beta[2] = 0.0;
m_ksi[0] = m_ksi[1] = m_ksi[2] = 0.0;
m_epsf = 0.0;
}
//-----------------------------------------------------------------------------
// Calculate the deviatoric Cauchy stress
mat3ds FETCNonlinearOrthotropic::DevStress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// deformation gradient
mat3d& F = pt.m_F;
double J = pt.m_J;
double Ji = 1.0 / J;
double Jm13 = pow(J, -1.0/3.0);
double Jm23 = Jm13*Jm13;
double twoJi = 2.0*Ji;
// invariants of B
double I1, I2, I4a, I4b, I4c;
// strain energy derivatives
double W1, W2, W4a, W4b, W4c;
// current local material axis
vec3d a0, b0, c0, a, b, c;
double la, lb, lc, lat, lbt, lct;
double w1pw2i1; // = W1 + W2*I1
const double third = 1.0/3.0;
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// get the initial fiber directions
a0.x = Q[0][0]; b0.x = Q[0][1]; c0.x = Q[0][2];
a0.y = Q[1][0]; b0.y = Q[1][1]; c0.y = Q[1][2];
a0.z = Q[2][0]; b0.z = Q[2][1]; c0.z = Q[2][2];
// calculate the current material axes lam*a = F*a0;
a = F*a0;
b = F*b0;
c = F*c0;
// normalize material axis and store fiber stretch
la = a.unit();
lat = la*Jm13; // i.e. lambda tilde
lb = b.unit();
lbt = lb*Jm13;
lc = c.unit();
lct = lc*Jm13;
// get deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// square of B
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
I1 = B.tr();
I2 = 0.5*(I1*I1 - B2.tr());
I4a = lat*lat;
I4b = lbt*lbt;
I4c = lct*lct;
// --- put strain energy derivatives here ---
// Wi = dW/dIi
W1 = m_c1;
W2 = m_c2;
// fiber a
if (lat > 1)
{
double lati = 1.0/lat;
double Wl;
Wl = m_beta[0]*m_ksi[0]*pow((lat - 1.0), m_beta[0]-1.0);
W4a = 0.5*lati*Wl;
}
else
{
W4a = 0;
}
// fiber b
if (lbt > 1)
{
double lbti = 1.0/lbt;
double Wl;
Wl = m_beta[1]*m_ksi[1]*pow((lbt - 1.0), m_beta[1]-1.0);
W4b = 0.5*lbti*Wl;
}
else
{
W4b = 0;
}
// fiber c
if (lct > 1)
{
double lcti = 1.0/lct;
double Wl;
Wl = m_beta[2]*m_ksi[2]*pow((lct - 1.0), m_beta[2]-1.0);
W4c = 0.5*lcti*Wl;
}
else
{
W4c = 0;
}
// ---
// calculate T = F*dW/dC*Ft
// (we commented out the matrix components we do not need)
w1pw2i1 = W1 + W2*I1;
mat3ds AxA = dyad(a);
mat3ds BxB = dyad(b);
mat3ds CxC = dyad(c);
mat3ds T = B*w1pw2i1 - B2*W2 + AxA*(W4a*I4a) + BxB*(W4b*I4b) + CxC*(W4c*I4c);
return T.dev()*(2.0/J);
}
//-----------------------------------------------------------------------------
//! Calculate the deviatoric tangent
tens4ds FETCNonlinearOrthotropic::DevTangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
const double third = 1.0 / 3.0;
// deformation gradient
mat3d& F = pt.m_F;
double J = pt.m_J;
double Jm13 = pow(J, -1.0/3.0);
double Jm23 = Jm13*Jm13;
double Ji = 1.0/J;
// deviatoric cauchy-stress, trs = trace[s]/3
double s[3][3], trs;
mat3ds& es = pt.m_s;
s[0][0] = es.xx();
s[1][1] = es.yy();
s[2][2] = es.zz();
s[0][1] = s[1][0] = es.xy();
s[1][2] = s[2][1] = es.yz();
s[0][2] = s[2][0] = es.xz();
trs = (s[0][0] + s[1][1] + s[2][2])*third;
s[0][0] -= trs;
s[1][1] -= trs;
s[2][2] -= trs;
// current material axis lam*a = F*a0;
vec3d a, b, c, a0, b0, c0;
double la, lb, lc, lat, lbt, lct;
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// get the initial fiber directions
a0.x = Q[0][0]; b0.x = Q[0][1]; c0.x = Q[0][2];
a0.y = Q[1][0]; b0.y = Q[1][1]; c0.y = Q[1][2];
a0.z = Q[2][0]; b0.z = Q[2][1]; c0.z = Q[2][2];
// calculate the current material axes lam*a = F*a0;
a.x = F[0][0]*a0.x + F[0][1]*a0.y + F[0][2]*a0.z;
a.y = F[1][0]*a0.x + F[1][1]*a0.y + F[1][2]*a0.z;
a.z = F[2][0]*a0.x + F[2][1]*a0.y + F[2][2]*a0.z;
b.x = F[0][0]*b0.x + F[0][1]*b0.y + F[0][2]*b0.z;
b.y = F[1][0]*b0.x + F[1][1]*b0.y + F[1][2]*b0.z;
b.z = F[2][0]*b0.x + F[2][1]*b0.y + F[2][2]*b0.z;
c.x = F[0][0]*c0.x + F[0][1]*c0.y + F[0][2]*c0.z;
c.y = F[1][0]*c0.x + F[1][1]*c0.y + F[1][2]*c0.z;
c.z = F[2][0]*c0.x + F[2][1]*c0.y + F[2][2]*c0.z;
la = a.unit();
lb = b.unit();
lc = c.unit();
// deviatoric stretch
lat = la*Jm13;
lbt = lb*Jm13;
lct = lc*Jm13;
// deviatoric right Cauchy-Green tensor: C = Ft*F
double C[3][3];
C[0][0] = Jm23*(F[0][0]*F[0][0]+F[1][0]*F[1][0]+F[2][0]*F[2][0]);
C[0][1] = Jm23*(F[0][0]*F[0][1]+F[1][0]*F[1][1]+F[2][0]*F[2][1]);
C[0][2] = Jm23*(F[0][0]*F[0][2]+F[1][0]*F[1][2]+F[2][0]*F[2][2]);
C[1][0] = Jm23*(F[0][1]*F[0][0]+F[1][1]*F[1][0]+F[2][1]*F[2][0]);
C[1][1] = Jm23*(F[0][1]*F[0][1]+F[1][1]*F[1][1]+F[2][1]*F[2][1]);
C[1][2] = Jm23*(F[0][1]*F[0][2]+F[1][1]*F[1][2]+F[2][1]*F[2][2]);
C[2][0] = Jm23*(F[0][2]*F[0][0]+F[1][2]*F[1][0]+F[2][2]*F[2][0]);
C[2][1] = Jm23*(F[0][2]*F[0][1]+F[1][2]*F[1][1]+F[2][2]*F[2][1]);
C[2][2] = Jm23*(F[0][2]*F[0][2]+F[1][2]*F[1][2]+F[2][2]*F[2][2]);
// square of C
// (we commented out the components we don't need)
double C2[3][3];
C2[0][0] = C[0][0]*C[0][0]+C[0][1]*C[1][0]+C[0][2]*C[2][0];
// C2[0][1] = C[0][0]*C[0][1]+C[0][1]*C[1][1]+C[0][2]*C[2][1];
// C2[0][2] = C[0][0]*C[0][2]+C[0][1]*C[1][2]+C[0][2]*C[2][2];
// C2[1][0] = C[1][0]*C[0][0]+C[1][1]*C[1][0]+C[1][2]*C[2][0];
C2[1][1] = C[1][0]*C[0][1]+C[1][1]*C[1][1]+C[1][2]*C[2][1];
// C2[1][2] = C[1][0]*C[0][2]+C[1][1]*C[1][2]+C[1][2]*C[2][2];
// C2[2][0] = C[2][0]*C[0][0]+C[2][1]*C[1][0]+C[2][2]*C[2][0];
// C2[2][1] = C[2][0]*C[0][1]+C[2][1]*C[1][1]+C[2][2]*C[2][1];
C2[2][2] = C[2][0]*C[0][2]+C[2][1]*C[1][2]+C[2][2]*C[2][2];
// Invariants of C
double I1 = C[0][0] + C[1][1] + C[2][2];
double I2 = 0.5*(I1*I1 - (C2[0][0] + C2[1][1] + C2[2][2]));
double I4a = lat*lat;
double I4b = lbt*lbt;
double I4c = lct*lct;
// calculate left Cauchy-Green tensor: B = F*Ft
double B[3][3];
B[0][0] = Jm23*(F[0][0]*F[0][0]+F[0][1]*F[0][1]+F[0][2]*F[0][2]);
B[0][1] = Jm23*(F[0][0]*F[1][0]+F[0][1]*F[1][1]+F[0][2]*F[1][2]);
B[0][2] = Jm23*(F[0][0]*F[2][0]+F[0][1]*F[2][1]+F[0][2]*F[2][2]);
B[1][0] = Jm23*(F[1][0]*F[0][0]+F[1][1]*F[0][1]+F[1][2]*F[0][2]);
B[1][1] = Jm23*(F[1][0]*F[1][0]+F[1][1]*F[1][1]+F[1][2]*F[1][2]);
B[1][2] = Jm23*(F[1][0]*F[2][0]+F[1][1]*F[2][1]+F[1][2]*F[2][2]);
B[2][0] = Jm23*(F[2][0]*F[0][0]+F[2][1]*F[0][1]+F[2][2]*F[0][2]);
B[2][1] = Jm23*(F[2][0]*F[1][0]+F[2][1]*F[1][1]+F[2][2]*F[1][2]);
B[2][2] = Jm23*(F[2][0]*F[2][0]+F[2][1]*F[2][1]+F[2][2]*F[2][2]);
// calculate square of B
// (we commented out the components we don't need)
double B2[3][3];
B2[0][0] = B[0][0]*B[0][0]+B[0][1]*B[1][0]+B[0][2]*B[2][0];
B2[0][1] = B[0][0]*B[0][1]+B[0][1]*B[1][1]+B[0][2]*B[2][1];
B2[0][2] = B[0][0]*B[0][2]+B[0][1]*B[1][2]+B[0][2]*B[2][2];
// B2[1][0] = B[1][0]*B[0][0]+B[1][1]*B[1][0]+B[1][2]*B[2][0];
B2[1][1] = B[1][0]*B[0][1]+B[1][1]*B[1][1]+B[1][2]*B[2][1];
B2[1][2] = B[1][0]*B[0][2]+B[1][1]*B[1][2]+B[1][2]*B[2][2];
// B2[2][0] = B[2][0]*B[0][0]+B[2][1]*B[1][0]+B[2][2]*B[2][0];
// B2[2][1] = B[2][0]*B[0][1]+B[2][1]*B[1][1]+B[2][2]*B[2][1];
B2[2][2] = B[2][0]*B[0][2]+B[2][1]*B[1][2]+B[2][2]*B[2][2];
// --- put strain energy derivatives here ---
// Wi = dW/dIi
double W1, W2, W4a, W4b, W4c, W44a, W44b, W44c;
W1 = m_c1;
W2 = m_c2;
const double eps = m_epsf*std::numeric_limits<double>::epsilon();
// fiber a
if (lat >= 1 + eps)
{
double lati = 1.0/lat;
double Wl, Wll;
Wl = m_beta[0]*m_ksi[0]*pow((lat - 1.0), m_beta[0]-1.0);
Wll = (m_beta[0]-1.0)*m_beta[0]*m_ksi[0]*pow((lat - 1.0), m_beta[0]-2.0);
W4a = 0.5*lati*Wl;
W44a = 0.25*lati*lati*(Wll - lati*Wl);
}
else
{
W4a = 0;
W44a = 0;
}
// fiber b
if (lbt >= 1 + eps)
{
double lbti = 1.0/lbt;
double Wl, Wll;
Wl = m_beta[1]*m_ksi[1]*pow((lbt - 1.0), m_beta[1]-1.0);
Wll = (m_beta[1]-1.0)*m_beta[1]*m_ksi[1]*pow((lbt - 1.0), m_beta[1]-2.0);
W4b = 0.5*lbti*Wl;
W44b = 0.25*lbti*lbti*(Wll - lbti*Wl);
}
else
{
W4b = 0;
W44b = 0;
}
// fiber c
if (lct >= 1 + eps)
{
double lcti = 1.0/lct;
double Wl, Wll;
Wl = m_beta[2]*m_ksi[2]*pow((lct - 1.0), m_beta[2]-1.0);
Wll = (m_beta[2]-1.0)*m_beta[2]*m_ksi[2]*pow((lct - 1.0), m_beta[2]-2.0);
W4c = 0.5*lcti*Wl;
W44c = 0.25*lcti*lcti*(Wll - lcti*Wl);
}
else
{
W4c = 0;
W44c = 0;
}
// ------------------------------------
double D[6][6] = {0};
// calculate dWdC:C
double WC = W1*I1 + 2*W2*I2 + W4a*I4a + W4b*I4b + W4c*I4c;
// calculate C:d2WdCdC:C
double CWWC = 2*I2*W2 + W44a*I4a*I4a + W44b*I4b*I4b + W44c*I4c*I4c;
// D[0][0] = c(0,0,0,0)
D[0][0] = -(4.0/3.0)*s[0][0] + (8.0/9.0)*Ji*WC;
D[0][0] += 4.0*Ji*W44a*I4a*I4a*a.x*a.x*a.x*a.x;
D[0][0] += 4.0*Ji*W44b*I4b*I4b*b.x*b.x*b.x*b.x;
D[0][0] += 4.0*Ji*W44c*I4c*I4c*c.x*c.x*c.x*c.x;
D[0][0] += (4.0/9.0)*Ji*CWWC;
D[0][0] -= (8.0/3.0)*Ji*(W2*I1*B[0][0] - W2*B2[0][0] + W44a*I4a*I4a*a.x*a.x + W44b*I4b*I4b*b.x*b.x + W44c*I4c*I4c*c.x*c.x);
// D[1][1] = c(1,1,1,1)
D[1][1] = -(4.0/3.0)*s[1][1] + 8.0/9.0*Ji*WC;
D[1][1] += 4.0*Ji*W44a*I4a*I4a*a.y*a.y*a.y*a.y;
D[1][1] += 4.0*Ji*W44b*I4b*I4b*b.y*b.y*b.y*b.y;
D[1][1] += 4.0*Ji*W44c*I4c*I4c*c.y*c.y*c.y*c.y;
D[1][1] += (4.0/9.0)*Ji*CWWC;
D[1][1] -= (8.0/3.0)*Ji*(W2*I1*B[1][1] - W2*B2[1][1] + W44a*I4a*I4a*a.y*a.y + W44b*I4b*I4b*b.y*b.y + W44c*I4c*I4c*c.y*c.y);
// D[2][2] = c(2,2,2,2)
D[2][2] = -(4.0/3.0)*s[2][2] + (8.0/9.0)*Ji*WC;
D[2][2] += 4.0*Ji*W44a*I4a*I4a*a.z*a.z*a.z*a.z;
D[2][2] += 4.0*Ji*W44b*I4b*I4b*b.z*b.z*b.z*b.z;
D[2][2] += 4.0*Ji*W44c*I4c*I4c*c.z*c.z*c.z*c.z;
D[2][2] += (4.0/9.0)*Ji*CWWC;
D[2][2] -= (8.0/3.0)*Ji*(W2*I1*B[2][2] - W2*B2[2][2] + W44a*I4a*I4a*a.z*a.z + W44b*I4b*I4b*b.z*b.z + W44c*I4c*I4c*c.z*c.z);
// D[0][1] = D[1][0] = c(0,0,1,1)
D[0][1] = -(2.0/3.0)*(s[0][0] + s[1][1]) - (4.0/9.0)*Ji*WC;
D[0][1] += 4.0*Ji*W44a*I4a*I4a*a.x*a.x*a.y*a.y;
D[0][1] += 4.0*Ji*W44b*I4b*I4b*b.x*b.x*b.y*b.y;
D[0][1] += 4.0*Ji*W44c*I4c*I4c*c.x*c.x*c.y*c.y;
D[0][1] += 4.0*Ji*W2*(B[0][0]*B[1][1] - B[0][1]*B[0][1]);
D[0][1] += (4.0/9.0)*Ji*CWWC;
D[0][1] -= (4.0/3.0)*Ji*(W2*(I1*B[0][0] - B2[0][0]) + W44a*I4a*I4a*a.x*a.x + W44b*I4b*I4b*b.x*b.x + W44c*I4c*I4c*c.x*c.x);
D[0][1] -= (4.0/3.0)*Ji*(W2*(I1*B[1][1] - B2[1][1]) + W44a*I4a*I4a*a.y*a.y + W44b*I4b*I4b*b.y*b.y + W44c*I4c*I4c*c.y*c.y);
// D[1][2] = D[2][1] = c(1,1,2,2)
D[1][2] = -(2.0/3.0)*(s[1][1] + s[2][2]) - (4.0/9.0)*Ji*WC;
D[1][2] += 4.0*Ji*W44a*I4a*I4a*a.y*a.y*a.z*a.z;
D[1][2] += 4.0*Ji*W44b*I4b*I4b*b.y*b.y*b.z*b.z;
D[1][2] += 4.0*Ji*W44c*I4c*I4c*c.y*c.y*c.z*c.z;
D[1][2] += 4.0*Ji*W2*(B[1][1]*B[2][2] - B[1][2]*B[1][2]);
D[1][2] += (4.0/9.0)*Ji*CWWC;
D[1][2] -= (4.0/3.0)*Ji*(W2*(I1*B[1][1] - B2[1][1]) + W44a*I4a*I4a*a.y*a.y + W44b*I4b*I4b*b.y*b.y + W44c*I4c*I4c*c.y*c.y);
D[1][2] -= (4.0/3.0)*Ji*(W2*(I1*B[2][2] - B2[2][2]) + W44a*I4a*I4a*a.z*a.z + W44b*I4b*I4b*b.z*b.z + W44c*I4c*I4c*c.z*c.z);
// D[0][2] = D[2][0] = c(0,0,2,2)
D[0][2] = -(2.0/3.0)*(s[0][0] + s[2][2]) - (4.0/9.0)*Ji*WC;
D[0][2] += 4.0*Ji*W44a*I4a*I4a*a.x*a.x*a.z*a.z;
D[0][2] += 4.0*Ji*W44b*I4b*I4b*b.x*b.x*b.z*b.z;
D[0][2] += 4.0*Ji*W44c*I4c*I4c*c.x*c.x*c.z*c.z;
D[0][2] += 4.0*Ji*W2*(B[0][0]*B[2][2] - B[0][2]*B[0][2]);
D[0][2] += (4.0/9.0)*Ji*CWWC;
D[0][2] -= (4.0/3.0)*Ji*(W2*(I1*B[0][0] - B2[0][0]) + W44a*I4a*I4a*a.x*a.x + W44b*I4b*I4b*b.x*b.x + W44c*I4c*I4c*c.x*c.x);
D[0][2] -= (4.0/3.0)*Ji*(W2*(I1*B[2][2] - B2[2][2]) + W44a*I4a*I4a*a.z*a.z + W44b*I4b*I4b*b.z*b.z + W44c*I4c*I4c*c.z*c.z);
// D[3][3] = 0.5*(c(0,1,0,1) + c(0,1,1,0))
D[3][3] = (2.0/3.0)*Ji*WC;
D[3][3] += 4.0*Ji*W44a*I4a*I4a*a.x*a.y*a.x*a.y;
D[3][3] += 4.0*Ji*W44b*I4b*I4b*b.x*b.y*b.x*b.y;
D[3][3] += 4.0*Ji*W44c*I4c*I4c*c.x*c.y*c.x*c.y;
D[3][3] += 2.0*Ji*W2*(B[0][1]*B[0][1] - B[0][0]*B[1][1]);
// D[4][4] = 0.5*(c(1,2,1,2) + c(1,2,2,1))
D[4][4] = (2.0/3.0)*Ji*WC;
D[4][4] += 4.0*Ji*W44a*I4a*I4a*a.y*a.z*a.y*a.z;
D[4][4] += 4.0*Ji*W44b*I4b*I4b*b.y*b.z*b.y*b.z;
D[4][4] += 4.0*Ji*W44c*I4c*I4c*c.y*c.z*c.y*c.z;
D[4][4] += 2.0*Ji*W2*(B[1][2]*B[1][2] - B[1][1]*B[2][2]);
// D[5][5] = 0.5*(c(0,2,0,2) + c(0,2,2,0))
D[5][5] = (2.0/3.0)*Ji*WC;
D[5][5] += 4.0*Ji*W44a*I4a*I4a*a.x*a.z*a.x*a.z;
D[5][5] += 4.0*Ji*W44b*I4b*I4b*b.x*b.z*b.x*b.z;
D[5][5] += 4.0*Ji*W44c*I4c*I4c*c.x*c.z*c.x*c.z;
D[5][5] += 2.0*Ji*W2*(B[0][2]*B[0][2] - B[0][0]*B[2][2]);
// D[0][3] = 0.5*(c(0,0,0,1) + c(0,0,1,0))
D[0][3] = -(2.0/3.0)*s[0][1];
D[0][3] += 4.0*Ji*W44a*I4a*I4a*a.x*a.x*a.x*a.y;
D[0][3] += 4.0*Ji*W44b*I4b*I4b*b.x*b.x*b.x*b.y;
D[0][3] += 4.0*Ji*W44c*I4c*I4c*c.x*c.x*c.x*c.y;
D[0][3] -= (4.0/3.0)*Ji*(W2*(I1*B[0][1] - B2[0][1]) + W44a*I4a*I4a*a.x*a.y + W44b*I4b*I4b*b.x*b.y + W44c*I4c*I4c*c.x*c.y);
// D[0][4] = 0.5*(c(0,0,1,2) + c(0,0,2,1))
D[0][4] = -(2.0/3.0)*s[1][2];
D[0][4] += 4.0*Ji*W44a*I4a*I4a*a.x*a.x*a.y*a.z;
D[0][4] += 4.0*Ji*W44b*I4b*I4b*b.x*b.x*b.y*b.z;
D[0][4] += 4.0*Ji*W44c*I4c*I4c*c.x*c.x*c.y*c.z;
D[0][4] += 4.0*Ji*W2*(B[0][0]*B[1][2] - B[0][1]*B[0][2]);
D[0][4] -= (4.0/3.0)*Ji*(W2*(I1*B[1][2] - B2[1][2]) + W44a*I4a*I4a*a.y*a.z + W44b*I4b*I4b*b.y*b.z + W44c*I4c*I4c*c.y*c.z);
// D[0][5] = 0.5*(c(0,0,0,2) + c(0,0,2,0))
D[0][5] = -(2.0/3.0)*s[0][2];
D[0][5] += 4.0*Ji*W44a*I4a*I4a*a.x*a.x*a.x*a.z;
D[0][5] += 4.0*Ji*W44b*I4b*I4b*b.x*b.x*b.x*b.z;
D[0][5] += 4.0*Ji*W44c*I4c*I4c*c.x*c.x*c.x*c.z;
D[0][5] -= (4.0/3.0)*Ji*(W2*(I1*B[0][2] - B2[0][2]) + W44a*I4a*I4a*a.x*a.z + W44b*I4b*I4b*b.x*b.z + W44c*I4c*I4c*c.x*c.z);
// D[1][3] = 0.5*(c(1,1,0,1) + c(1,1,1,0))
D[1][3] = -(2.0/3.0)*s[0][1];
D[1][3] += 4.0*Ji*W44a*I4a*I4a*a.y*a.y*a.x*a.y;
D[1][3] += 4.0*Ji*W44b*I4b*I4b*b.y*b.y*b.x*b.y;
D[1][3] += 4.0*Ji*W44c*I4c*I4c*c.y*c.y*c.x*c.y;
D[1][3] -= (4.0/3.0)*Ji*(W2*(I1*B[0][1] - B2[0][1]) + W44a*I4a*I4a*a.x*a.y + W44b*I4b*I4b*b.x*b.y + W44c*I4c*I4c*c.x*c.y);
// D[1][4] = 0.5*(c(1,1,1,2) + c(1,1,2,1))
D[1][4] = -(2.0/3.0)*s[1][2];
D[1][4] += 4.0*Ji*W44a*I4a*I4a*a.y*a.y*a.y*a.z;
D[1][4] += 4.0*Ji*W44b*I4b*I4b*b.y*b.y*b.y*b.z;
D[1][4] += 4.0*Ji*W44c*I4c*I4c*c.y*c.y*c.y*c.z;
D[1][4] -= (4.0/3.0)*Ji*(W2*(I1*B[1][2] - B2[1][2]) + W44a*I4a*I4a*a.y*a.z + W44b*I4b*I4b*b.y*b.z + W44c*I4c*I4c*c.y*c.z);
// D[1][5] = 0.5*(c(1,1,0,2) + c(1,1,2,0))
D[1][5] = -(2.0/3.0)*s[0][2];
D[1][5] += 4.0*Ji*W44a*I4a*I4a*a.y*a.y*a.x*a.z;
D[1][5] += 4.0*Ji*W44b*I4b*I4b*b.y*b.y*b.x*b.z;
D[1][5] += 4.0*Ji*W44c*I4c*I4c*c.y*c.y*c.x*c.z;
D[1][5] += 4.0*Ji*W2*(B[1][1]*B[0][2] - B[0][1]*B[1][2]);
D[1][5] -= (4.0/3.0)*Ji*(W2*(I1*B[0][2] - B2[0][2]) + W44a*I4a*I4a*a.x*a.z + W44b*I4b*I4b*b.x*b.z + W44c*I4c*I4c*c.x*c.z);
// D[2][3] = 0.5*(c(2,2,0,1) + c(2,2,1,0))
D[2][3] = -(2.0/3.0)*s[0][1];
D[2][3] += 4.0*Ji*W44a*I4a*I4a*a.z*a.z*a.x*a.y;
D[2][3] += 4.0*Ji*W44b*I4b*I4b*b.z*b.z*b.x*b.y;
D[2][3] += 4.0*Ji*W44c*I4c*I4c*c.z*c.z*c.x*c.y;
D[2][3] += 4.0*Ji*W2*(B[2][2]*B[0][1] - B[0][2]*B[1][2]);
D[2][3] -= (4.0/3.0)*Ji*(W2*(I1*B[0][1] - B2[0][1]) + W44a*I4a*I4a*a.x*a.y + W44b*I4b*I4b*b.x*b.y + W44c*I4c*I4c*c.x*c.y);
// D[2][4] = 0.5*(c(2,2,1,2) + c(2,2,2,1))
D[2][4] = -(2.0/3.0)*s[1][2];
D[2][4] += 4.0*Ji*W44a*I4a*I4a*a.z*a.z*a.y*a.z;
D[2][4] += 4.0*Ji*W44b*I4b*I4b*b.z*b.z*b.y*b.z;
D[2][4] += 4.0*Ji*W44c*I4c*I4c*c.z*c.z*c.y*c.z;
D[2][4] -= (4.0/3.0)*Ji*(W2*(I1*B[1][2] - B2[1][2]) + W44a*I4a*I4a*a.y*a.z + W44b*I4b*I4b*b.y*b.z + W44c*I4c*I4c*c.y*c.z);
// D[2][5] = 0.5*(c(2,2,0,2) + c(2,2,2,0))
D[2][5] = -(2.0/3.0)*s[0][2];
D[2][5] += 4.0*Ji*W44a*I4a*I4a*a.z*a.z*a.x*a.z;
D[2][5] += 4.0*Ji*W44b*I4b*I4b*b.z*b.z*b.x*b.z;
D[2][5] += 4.0*Ji*W44c*I4c*I4c*c.z*c.z*c.x*c.z;
D[2][5] -= (4.0/3.0)*Ji*(W2*(I1*B[0][2] - B2[0][2]) + W44a*I4a*I4a*a.x*a.z + W44b*I4b*I4b*b.x*b.z + W44c*I4c*I4c*c.x*c.z);
// D[3][4] = 0.5*(c(0,1,1,2) + c(0,1,2,1))
D[3][4] = 4.0*Ji*W44a*I4a*I4a*a.x*a.y*a.y*a.z;
D[3][4] = 4.0*Ji*W44b*I4b*I4b*b.x*b.y*b.y*b.z;
D[3][4] = 4.0*Ji*W44c*I4c*I4c*c.x*c.y*c.y*c.z;
D[3][4] += 2.0*Ji*W2*(B[0][1]*B[1][2] - B[0][2]*B[1][1]);
// D[3][5] = 0.5*(c(0,1,0,2) + c(0,1,2,0))
D[3][5] = 4.0*Ji*W44a*I4a*I4a*a.x*a.y*a.x*a.z;
D[3][5] = 4.0*Ji*W44b*I4b*I4b*b.x*b.y*b.x*b.z;
D[3][5] = 4.0*Ji*W44c*I4c*I4c*c.x*c.y*c.x*c.z;
D[3][5] += 2.0*Ji*W2*(B[0][1]*B[0][2] - B[0][0]*B[1][2]);
// D[4][5] = 0.5*(c(1,2,0,2) + c(1,2,2,0))
D[4][5] = 4.0*Ji*W44a*I4a*I4a*a.y*a.z*a.x*a.z;
D[4][5] = 4.0*Ji*W44b*I4b*I4b*b.y*b.z*b.x*b.z;
D[4][5] = 4.0*Ji*W44c*I4c*I4c*c.y*c.z*c.x*c.z;
D[4][5] += 2.0*Ji*W2*(B[1][2]*B[0][2] - B[0][1]*B[2][2]);
// set symmetric components
D[1][0] = D[0][1]; D[2][0] = D[0][2]; D[3][0] = D[0][3]; D[4][0] = D[0][4]; D[5][0] = D[0][5];
D[2][1] = D[1][2]; D[3][1] = D[1][3]; D[4][1] = D[1][4]; D[5][1] = D[1][5];
D[3][2] = D[2][3]; D[4][2] = D[2][4]; D[5][2] = D[2][5];
D[4][3] = D[3][4]; D[5][3] = D[3][5];
D[5][4] = D[4][5];
return tens4ds(D);
}
//-----------------------------------------------------------------------------
// Calculate the deviatoric strain energy density
double FETCNonlinearOrthotropic::DevStrainEnergyDensity(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);
// invariants of B
double I1, I2;
// current local material axis
vec3d a0, b0, c0, a, b, c;
double la, lb, lc, lat, lbt, lct;
// get the local coordinate systems
mat3d Q = GetLocalCS(mp);
// get the initial fiber directions
a0.x = Q[0][0]; b0.x = Q[0][1]; c0.x = Q[0][2];
a0.y = Q[1][0]; b0.y = Q[1][1]; c0.y = Q[1][2];
a0.z = Q[2][0]; b0.z = Q[2][1]; c0.z = Q[2][2];
// calculate the current material axes lam*a = F*a0;
a = F*a0;
b = F*b0;
c = F*c0;
// normalize material axis and store fiber stretch
la = a.unit();
lat = la*Jm13; // i.e. lambda tilde
lb = b.unit();
lbt = lb*Jm13;
lc = c.unit();
lct = lc*Jm13;
// get deviatoric left Cauchy-Green tensor
mat3ds B = pt.DevLeftCauchyGreen();
// square of B
mat3ds B2 = B.sqr();
// Invariants of B (= invariants of C)
// Note that these are the invariants of Btilde, not of B!
I1 = B.tr();
I2 = 0.5*(I1*I1 - B2.tr());
double sed = m_c1*(I1-3) + m_c2*(I2-3);
// fiber a
if (lat > 1)
sed += m_ksi[0]*pow((lat - 1.0), m_beta[0]);
// fiber b
if (lbt > 1)
sed += m_ksi[1]*pow((lbt - 1.0), m_beta[1]);
// fiber c
if (lct > 1)
sed += m_ksi[2]*pow((lct - 1.0), m_beta[2]);
return sed;
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FESymmetryPlane.h | .h | 2,938 | 89 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FECore/FEAugLagLinearConstraint.h>
#include <FECore/FESurface.h>
//-----------------------------------------------------------------------------
//! The FESymmetryPlane class implements a symmetry plane
//! as a linear constraint on the components of the solid displacement.
class FESymmetryPlane : public FESurfaceConstraint
{
public:
//! constructor
FESymmetryPlane(FEModel* pfem);
//! destructor
~FESymmetryPlane() {}
//! Activation
void Activate() override;
//! initialization
bool Init() override;
//! Get the surface
FESurface* GetSurface() override { return &m_surf; }
// allocate equations
int InitEquations(int neq) override;
protected:
void Update(const std::vector<double>& Ui, const std::vector<double>& ui) override;
void UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) override;
void PrepStep() override;
public:
//! serialize data to archive
void Serialize(DumpStream& ar) override;
//! add the linear constraint contributions to the residual
void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override;
//! add the linear constraint contributions to the stiffness matrix
void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override;
//! do the augmentation
bool Augment(int naug, const FETimeInfo& tp) override;
//! build connectivity for matrix profile
void BuildMatrixProfile(FEGlobalMatrix& M) override;
protected:
FESurface m_surf;
bool m_binit;
private:
FELinearConstraintSet m_lc;
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEMortarTiedContact.cpp | .cpp | 10,119 | 375 | /*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 "FEMortarTiedContact.h"
#include "FECore/mortar.h"
#include "FECore/FEGlobalMatrix.h"
#include "FECore/log.h"
#include <FECore/FELinearSystem.h>
//=============================================================================
// FEMortarTiedSurface
//=============================================================================
//-----------------------------------------------------------------------------
FEMortarTiedSurface::FEMortarTiedSurface(FEModel* pfem) : FEMortarContactSurface(pfem) {}
//-----------------------------------------------------------------------------
bool FEMortarTiedSurface::Init()
{
// always intialize base class first!
if (FEMortarContactSurface::Init() == false) return false;
// get the number of nodes
int NN = Nodes();
// allocate data structures
m_L.resize(NN, vec3d(0,0,0));
return true;
}
//=============================================================================
// FEMortarTiedContact
//=============================================================================
//-----------------------------------------------------------------------------
// Define sliding interface parameters
BEGIN_FECORE_CLASS(FEMortarTiedContact, FEMortarInterface)
ADD_PARAMETER(m_atol , "tolerance" );
ADD_PARAMETER(m_eps , "penalty" );
ADD_PARAMETER(m_naugmin, "minaug" );
ADD_PARAMETER(m_naugmax, "maxaug" );
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEMortarTiedContact::FEMortarTiedContact(FEModel* pfem) : FEMortarInterface(pfem), m_ss(pfem), m_ms(pfem)
{
m_dofX = GetDOFIndex("x");
m_dofY = GetDOFIndex("y");
m_dofZ = GetDOFIndex("z");
}
//-----------------------------------------------------------------------------
bool FEMortarTiedContact::Init()
{
// initialize surfaces
if (m_ms.Init() == false) return false;
if (m_ss.Init() == false) return false;
return true;
}
//-----------------------------------------------------------------------------
void FEMortarTiedContact::Activate()
{
//! don't forget the base class
FEContactInterface::Activate();
m_ss.UpdateNodalAreas();
// update the mortar weights
// For tied interfaces, this is only done once, during activation
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 FEMortarTiedContact::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 FEMortarTiedContact::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)
{
double eps = m_eps*m_ss.m_A[A];
vec3d gA = m_ss.m_gap[A];
vec3d tA = m_ss.m_L[A] + gA*eps;
// 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 FEMortarTiedContact::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
int NS = m_ss.Nodes();
int NM = m_ms.Nodes();
// A. Linearization of the gap function
vector<int> lmi(3), lmj(3);
FEElementMatrix ke;
ke.resize(3, 3);
for (int A=0; A<NS; ++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]*eps;
if (nAB != 0.0)
{
// 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]*nAB;
if (nAC != 0.0)
{
ke[0][0] = nAC; ke[0][1] = 0.0; ke[0][2] = 0.0;
ke[1][0] = 0.0; ke[1][1] = nAC; ke[1][2] = 0.0;
ke[2][0] = 0.0; ke[2][1] = 0.0; ke[2][2] = nAC;
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]*nAB;
if (nAC != 0.0)
{
ke[0][0] = nAC; ke[0][1] = 0.0; ke[0][2] = 0.0;
ke[1][0] = 0.0; ke[1][1] = nAC; ke[1][2] = 0.0;
ke[2][0] = 0.0; ke[2][1] = 0.0; ke[2][2] = nAC;
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]*eps;
if (nAB != 0.0)
{
// 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]*nAB;
if (nAC != 0.0)
{
ke[0][0] = nAC; ke[0][1] = 0.0; ke[0][2] = 0.0;
ke[1][0] = 0.0; ke[1][1] = nAC; ke[1][2] = 0.0;
ke[2][0] = 0.0; ke[2][1] = 0.0; ke[2][2] = nAC;
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]*nAB;
if (nAC != 0.0)
{
ke[0][0] = nAC; ke[0][1] = 0.0; ke[0][2] = 0.0;
ke[1][0] = 0.0; ke[1][1] = nAC; ke[1][2] = 0.0;
ke[2][0] = 0.0; ke[2][1] = 0.0; ke[2][2] = nAC;
ke.SetIndices(lmi, lmj);
LS.Assemble(ke);
}
}
}
}
}
}
//-----------------------------------------------------------------------------
//! calculate Lagrangian augmentations
bool FEMortarTiedContact::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)
{
double eps = m_eps*m_ss.m_A[A];
vec3d gA = m_ss.m_gap[A];
vec3d Lold = m_ss.m_L[A];
vec3d Lnew = Lold + gA*eps;
double uold = Lold.norm();
double unew = Lnew.norm();
double err = fabs((uold - unew)/(uold + unew));
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)
{
double eps = m_eps*m_ss.m_A[A];
vec3d gA = m_ss.m_gap[A];
vec3d Lold = m_ss.m_L[A];
vec3d Lnew = Lold + gA*eps;
m_ss.m_L[A] = Lnew;
}
}
return bconv;
}
//-----------------------------------------------------------------------------
//! update interface data
void FEMortarTiedContact::Update()
{
UpdateNodalGaps(m_ss, m_ms);
}
//-----------------------------------------------------------------------------
//! serialize data to archive
void FEMortarTiedContact::Serialize(DumpStream& ar)
{
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEFiberPowLinear.h | .h | 3,549 | 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 "FEElasticFiberMaterial.h"
#include "FEFiberMaterial.h"
//-----------------------------------------------------------------------------
//! Material class for single fiber, tension only
//! Power law - linear
class FEFiberPowLinear : public FEFiberMaterial
{
public:
FEFiberPowLinear(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;
// declare the parameter list
DECLARE_FECORE_CLASS();
public:
FEParamDouble m_E; // fiber modulus
FEParamDouble m_lam0; // stretch ratio at end of toe region
FEParamDouble m_beta; // power law exponent in toe region
double m_epsf;
bool m_tension_only;
};
class FEElasticFiberPowLinear : public FEElasticFiberMaterial_T<FEFiberPowLinear>
{
public:
FEElasticFiberPowLinear(FEModel* fem) : FEElasticFiberMaterial_T<FEFiberPowLinear>(fem) {}
DECLARE_FECORE_CLASS();
};
//-----------------------------------------------------------------------------
//! Exponential-Power law toe region - linear
class FEFiberExpPowLinear : public FEFiberMaterial
{
public:
FEFiberExpPowLinear(FEModel* pfem);
//! Initialization
bool Validate() override;
//! 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:
FEParamDouble m_E; // fiber modulus
FEParamDouble m_lam0; // stretch ratio at end of toe region
FEParamDouble m_alpha; // exponential coefficient
FEParamDouble m_beta; // power law exponent in toe region
double m_epsf;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
class FEElasticFiberExpPowLinear : public FEElasticFiberMaterial_T<FEFiberExpPowLinear>
{
public:
FEElasticFiberExpPowLinear(FEModel* fem) : FEElasticFiberMaterial_T<FEFiberExpPowLinear>(fem) {}
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEMooneyRivlin.h | .h | 2,104 | 58 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEUncoupledMaterial.h"
#include <FECore/FEModelParam.h>
//-----------------------------------------------------------------------------
//! Mooney-Rivlin material
class FEMooneyRivlin : public FEUncoupledMaterial
{
public:
FEMooneyRivlin(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;
// declare the parameter list
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEElasticEASShellDomain.cpp | .cpp | 66,455 | 1,747 | /*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 "FEElasticEASShellDomain.h"
#include "FEElasticMaterial.h"
#include "FEBodyForce.h"
#include <FECore/log.h>
#include <FECore/FEModel.h>
#include <FECore/FEAnalysis.h>
#include <math.h>
#include <FECore/FESolidDomain.h>
#include <FECore/FELinearSystem.h>
#include "FEBioMech.h"
BEGIN_FECORE_CLASS(FEElasticEASShellDomain, FESSIShellDomain)
ADD_PARAMETER(m_secant_stress, "secant_stress");
ADD_PARAMETER(m_secant_tangent, "secant_tangent");
END_FECORE_CLASS();
//-----------------------------------------------------------------------------
FEElasticEASShellDomain::FEElasticEASShellDomain(FEModel* pfem) : FESSIShellDomain(pfem), FEElasticDomain(pfem), m_dofV(pfem), m_dofSV(pfem), m_dofSA(pfem), m_dofR(pfem), m_dof(pfem)
{
m_pMat = nullptr;
m_update_dynamic = true; // default for backward compatibility
m_secant_stress = false;
m_secant_tangent = false;
// TODO: Can this be done in Init, since there is no error checking
if (pfem)
{
m_dofV.AddVariable(FEBioMech::GetVariableName(FEBioMech::VELOCITY));
m_dofSV.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_VELOCITY));
m_dofSA.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_ACCELERATION));
m_dofR.AddVariable(FEBioMech::GetVariableName(FEBioMech::RIGID_ROTATION));
}
}
//-----------------------------------------------------------------------------
FEElasticEASShellDomain& FEElasticEASShellDomain::operator = (FEElasticEASShellDomain& d)
{
m_Elem = d.m_Elem;
m_pMesh = d.m_pMesh;
return (*this);
}
//-----------------------------------------------------------------------------
//! Set flag for update for dynamic quantities
void FEElasticEASShellDomain::SetDynamicUpdateFlag(bool b)
{
m_update_dynamic = b;
}
//-----------------------------------------------------------------------------
//! serialization
void FEElasticEASShellDomain::Serialize(DumpStream& ar)
{
//erialize the base class, which instantiates the elements
FESSIShellDomain::Serialize(ar);
if (ar.IsShallow()) return;
// serialize class variables
ar & m_update_dynamic;
}
//-----------------------------------------------------------------------------
// get the total dof list
const FEDofList& FEElasticEASShellDomain::GetDOFList() const
{
return m_dof;
}
//-----------------------------------------------------------------------------
void FEElasticEASShellDomain::SetMaterial(FEMaterial* pmat)
{
FEDomain::SetMaterial(pmat);
m_pMat = dynamic_cast<FESolidMaterial*>(pmat);
}
//-----------------------------------------------------------------------------
bool FEElasticEASShellDomain::Init()
{
// initialize base class
FESSIShellDomain::Init();
// set up EAS arrays
m_nEAS = 7;
for (int i=0; i<Elements(); ++i)
{
FEShellElementNew& el = ShellElement(i);
int neln = el.Nodes();
int nint = el.GaussPoints();
el.m_Kaai.resize(m_nEAS, m_nEAS);
el.m_fa.resize(m_nEAS, 1);
el.m_alpha.resize(m_nEAS, 1); el.m_alpha.zero();
el.m_alphat.resize(m_nEAS, 1); el.m_alphat.zero();
el.m_alphai.resize(m_nEAS, 1); el.m_alphai.zero();
el.m_Kua.resize(neln,matrix(3, m_nEAS));
el.m_Kwa.resize(neln,matrix(3, m_nEAS));
el.m_E.resize(nint, mat3ds(0, 0, 0, 0, 0, 0));
}
return true;
}
//-----------------------------------------------------------------------------
void FEElasticEASShellDomain::Activate()
{
for (int i=0; i<Nodes(); ++i)
{
FENode& node = Node(i);
if (node.HasFlags(FENode::EXCLUDE) == false)
{
if (node.m_rid < 0)
{
node.set_active(m_dofU[0]);
node.set_active(m_dofU[1]);
node.set_active(m_dofU[2]);
if (node.HasFlags(FENode::SHELL))
{
node.set_active(m_dofSU[0]);
node.set_active(m_dofSU[1]);
node.set_active(m_dofSU[2]);
}
}
}
}
}
//-----------------------------------------------------------------------------
//! Initialize element data
void FEElasticEASShellDomain::PreSolveUpdate(const FETimeInfo& timeInfo)
{
FESSIShellDomain::PreSolveUpdate(timeInfo);
const int NE = FEElement::MAX_NODES;
vec3d x0[NE], xt[NE], r0, rt;
for (size_t i=0; i<m_Elem.size(); ++i)
{
FEShellElementNew& el = m_Elem[i];
el.m_alphai.zero();
int n = el.GaussPoints();
for (int j=0; j<n; ++j)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(j);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
pt.m_Wp = pt.m_Wt;
mp.Update(timeInfo);
}
}
}
//-----------------------------------------------------------------------------
// Calculates the forces due to the stress
void FEElasticEASShellDomain::InternalForces(FEGlobalVector& R)
{
int NS = (int)m_Elem.size();
#pragma omp parallel for shared (NS)
for (int i=0; i<NS; ++i)
{
// element force vector
vector<double> fe;
vector<int> lm;
// get the element
FEShellElementNew& el = m_Elem[i];
// create the element force vector and initialize to zero
int ndof = 6*el.Nodes();
fe.assign(ndof, 0);
// calculate element's internal force
ElementInternalForce(el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble the residual
R.Assemble(el.m_node, lm, fe, true);
}
}
//-----------------------------------------------------------------------------
//! calculates the internal equivalent nodal forces for shell elements
//! Note that we use a one-point gauss integration rule for the thickness
//! integration. This will integrate linear functions exactly.
void FEElasticEASShellDomain::ElementInternalForce(FEShellElementNew& el, vector<double>& fe)
{
int i, n;
// jacobian matrix determinant
double detJt;
int nint = el.GaussPoints();
int neln = el.Nodes();
double* gw = el.GaussWeights();
vec3d Gcnt[3];
// allocate arrays
vector<mat3ds> S(nint);
vector<tens4dmm> C(nint);
vector<double> EE;
vector< vector<vec3d>> HU;
vector< vector<vec3d>> HW;
matrix NS(neln,16);
matrix NN(neln,8);
// ANS method: Evaluate collocation strains
CollocationStrainsANS(el, EE, HU, HW, NS, NN);
// EAS method: Evaluate Kua, Kwa, and Kaa
// Also evaluate PK2 stress and material tangent using enhanced strain
EvaluateEAS(el, EE, HU, HW, S, C);
matrix Kif(7,1);
Kif = el.m_Kaai*el.m_fa;
vector<matrix> hu(neln, matrix(3,6));
vector<matrix> hw(neln, matrix(3,6));
vector<vec3d> Nu(neln);
vector<vec3d> Nw(neln);
// EAS contribution
matrix Fu(3,1), Fw(3,1);
for (i=0; i<neln; ++i)
{
Fu = el.m_Kua[i]*Kif;
Fw = el.m_Kwa[i]*Kif;
// calculate internal force
// the '-' sign is so that the internal forces get subtracted
// from the global residual vector
fe[6*i ] += Fu(0,0);
fe[6*i+1] += Fu(1,0);
fe[6*i+2] += Fu(2,0);
fe[6*i+3] += Fw(0,0);
fe[6*i+4] += Fw(1,0);
fe[6*i+5] += Fw(2,0);
}
// repeat for all integration points
for (n=0; n<nint; ++n)
{
ContraBaseVectors0(el, n, Gcnt);
mat3ds E;
EvaluateEh(el, n, Gcnt, E, hu, hw, Nu, Nw);
EvaluateANS(el, n, Gcnt, E, hu, hw, EE, HU, HW);
// evaluate 2nd P-K stress
matrix SC(6,1);
mat3dsCntMat61(S[n], Gcnt, SC);
// mat3ds S = m_pMat->PK2Stress(E);
// mat3dsCntMat61(S, Gcnt, SC);
// calculate the jacobian and multiply by Gauss weight
detJt = detJ0(el, n)*gw[n];
for (i=0; i<neln; ++i)
{
Fu = hu[i]*SC;
Fw = hw[i]*SC;
// calculate internal force
// the '-' sign is so that the internal forces get subtracted
// from the global residual vector
fe[6*i ] -= Fu(0,0)*detJt;
fe[6*i+1] -= Fu(1,0)*detJt;
fe[6*i+2] -= Fu(2,0)*detJt;
fe[6*i+3] -= Fw(0,0)*detJt;
fe[6*i+4] -= Fw(1,0)*detJt;
fe[6*i+5] -= Fw(2,0)*detJt;
}
}
}
//-----------------------------------------------------------------------------
void FEElasticEASShellDomain::BodyForce(FEGlobalVector& R, FEBodyForce& BF)
{
int NS = (int)m_Elem.size();
#pragma omp parallel for
for (int i=0; i<NS; ++i)
{
// element force vector
vector<double> fe;
vector<int> lm;
// get the element
FEShellElementNew& el = m_Elem[i];
// create the element force vector and initialize to zero
int ndof = 6*el.Nodes();
fe.assign(ndof, 0);
// apply body forces to shells
ElementBodyForce(BF, el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble the residual
R.Assemble(el.m_node, lm, fe, true);
}
}
//-----------------------------------------------------------------------------
//! Calculates element body forces for shells
void FEElasticEASShellDomain::ElementBodyForce(FEBodyForce& BF, FEShellElementNew& el, vector<double>& fe)
{
// integration weights
double* gw = el.GaussWeights();
double eta;
double *M, detJt;
// loop over integration points
int nint = el.GaussPoints();
int neln = el.Nodes();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
double dens = m_pMat->Density(mp);
// calculate the jacobian
detJt = detJ0(el, n)*gw[n];
M = el.H(n);
eta = el.gt(n);
// get the force
vec3d f = BF.force(mp);
for (int i=0; i<neln; ++i)
{
vec3d fu = f*(dens*M[i]*(1+eta)/2*detJt);
vec3d fd = f*(dens*M[i]*(1-eta)/2*detJt);
fe[6*i ] -= fu.x;
fe[6*i+1] -= fu.y;
fe[6*i+2] -= fu.z;
fe[6*i+3] -= fd.x;
fe[6*i+4] -= fd.y;
fe[6*i+5] -= fd.z;
}
}
}
//-----------------------------------------------------------------------------
// Calculate inertial forces \todo Why is F no longer needed?
void FEElasticEASShellDomain::InertialForces(FEGlobalVector& R, vector<double>& F)
{
int NE = (int)m_Elem.size();
#pragma omp parallel for shared (NE)
for (int i=0; i<NE; ++i)
{
// element force vector
vector<double> fe;
vector<int> lm;
// get the element
FEShellElementNew& el = m_Elem[i];
// get the element force vector and initialize it to zero
int ndof = 6*el.Nodes();
fe.assign(ndof, 0);
// calculate internal force vector
ElementInertialForce(el, fe);
// get the element's LM vector
UnpackLM(el, lm);
// assemble element 'fe'-vector into global R vector
R.Assemble(el.m_node, lm, fe, true);
}
}
//-----------------------------------------------------------------------------
void FEElasticEASShellDomain::ElementInertialForce(FEShellElementNew& el, vector<double>& fe)
{
const FETimeInfo& tp = GetFEModel()->GetTime();
double alpham = tp.alpham;
int nint = el.GaussPoints();
int neln = el.Nodes();
// evaluate the element inertial force vector
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
double J0 = detJ0(el, n)*el.GaussWeights()[n];
double d = m_pMat->Density(mp);
double* M = el.H(n);
double eta = el.gt(n);
for (int i=0; i<neln; ++i)
{
vec3d fu = pt.m_a*(d*M[i]*(1+eta)/2*J0);
vec3d fd = pt.m_a*(d*M[i]*(1-eta)/2*J0);
fe[6*i ] -= fu.x;
fe[6*i+1] -= fu.y;
fe[6*i+2] -= fu.z;
fe[6*i+3] -= fd.x;
fe[6*i+4] -= fd.y;
fe[6*i+5] -= fd.z;
}
}
}
//-----------------------------------------------------------------------------
//! This function calculates the stiffness due to body forces
void FEElasticEASShellDomain::ElementBodyForceStiffness(FEBodyForce& BF, FEShellElementNew &el, matrix &ke)
{
int i, j, i6, j6;
int neln = el.Nodes();
// jacobian
double detJ;
double *M;
double* gw = el.GaussWeights();
mat3d K;
double Mu[FEElement::MAX_NODES], Md[FEElement::MAX_NODES];
// loop over integration points
int nint = el.GaussPoints();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
detJ = detJ0(el, n)*gw[n];
double dens = m_pMat->Density(mp);
// get the stiffness
K = BF.stiffness(mp)*dens*detJ;
M = el.H(n);
double eta = el.gt(n);
for (i=0; i<neln; ++i)
{
Mu[i] = M[i]*(1+eta)/2;
Md[i] = M[i]*(1-eta)/2;
}
for (i=0, i6=0; i<neln; ++i, i6 += 6)
{
for (j=0, j6 = 0; j<neln; ++j, j6 += 6)
{
mat3d Kuu = K*(Mu[i]*Mu[j]);
mat3d Kud = K*(Mu[i]*Md[j]);
mat3d Kdu = K*(Md[i]*Mu[j]);
mat3d Kdd = K*(Md[i]*Md[j]);
ke[i6 ][j6 ] += Kuu(0,0); ke[i6 ][j6+1] += Kuu(0,1); ke[i6 ][j6+2] += Kuu(0,2);
ke[i6+1][j6 ] += Kuu(1,0); ke[i6+1][j6+1] += Kuu(1,1); ke[i6+1][j6+2] += Kuu(1,2);
ke[i6+2][j6 ] += Kuu(2,0); ke[i6+2][j6+1] += Kuu(2,1); ke[i6+2][j6+2] += Kuu(2,2);
ke[i6 ][j6+3] += Kud(0,0); ke[i6 ][j6+4] += Kud(0,1); ke[i6 ][j6+5] += Kud(0,2);
ke[i6+1][j6+3] += Kud(1,0); ke[i6+1][j6+4] += Kud(1,1); ke[i6+1][j6+5] += Kud(1,2);
ke[i6+2][j6+3] += Kud(2,0); ke[i6+2][j6+4] += Kud(2,1); ke[i6+2][j6+5] += Kud(2,2);
ke[i6+3][j6 ] += Kdu(0,0); ke[i6+3][j6+1] += Kdu(0,1); ke[i6+3][j6+2] += Kdu(0,2);
ke[i6+4][j6 ] += Kdu(1,0); ke[i6+4][j6+1] += Kdu(1,1); ke[i6+4][j6+2] += Kdu(1,2);
ke[i6+5][j6 ] += Kdu(2,0); ke[i6+5][j6+1] += Kdu(2,1); ke[i6+5][j6+2] += Kdu(2,2);
ke[i6+3][j6+3] += Kdd(0,0); ke[i6+3][j6+4] += Kdd(0,1); ke[i6+3][j6+5] += Kdd(0,2);
ke[i6+4][j6+3] += Kdd(1,0); ke[i6+4][j6+4] += Kdd(1,1); ke[i6+4][j6+5] += Kdd(1,2);
ke[i6+5][j6+3] += Kdd(2,0); ke[i6+5][j6+4] += Kdd(2,1); ke[i6+5][j6+5] += Kdd(2,2);
}
}
}
}
//-----------------------------------------------------------------------------
void FEElasticEASShellDomain::StiffnessMatrix(FELinearSystem& LS)
{
// repeat over all shell elements
int NS = (int)m_Elem.size();
#pragma omp parallel for shared (NS)
for (int iel=0; iel<NS; ++iel)
{
FEShellElement& el = m_Elem[iel];
// create the element's stiffness matrix
FEElementMatrix ke(el);
int ndof = 6*el.Nodes();
ke.resize(ndof, ndof);
// calculate the element stiffness matrix
ElementStiffness(iel, ke);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
void FEElasticEASShellDomain::MassMatrix(FELinearSystem& LS, double scale)
{
// repeat over all solid elements
int NE = (int)m_Elem.size();
#pragma omp parallel for shared (NE)
for (int iel=0; iel<NE; ++iel)
{
FEShellElementNew& el = m_Elem[iel];
// create the element's stiffness matrix
FEElementMatrix ke(el);
int ndof = 6*el.Nodes();
ke.resize(ndof, ndof);
ke.zero();
// calculate inertial stiffness
ElementMassMatrix(el, ke, scale);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
void FEElasticEASShellDomain::BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf)
{
// repeat over all shell elements
int NE = (int)m_Elem.size();
#pragma omp parallel for shared (NE)
for (int iel=0; iel<NE; ++iel)
{
FEShellElementNew& el = m_Elem[iel];
// create the element's stiffness matrix
FEElementMatrix ke(el);
int ndof = 6*el.Nodes();
ke.resize(ndof, ndof);
ke.zero();
// calculate inertial stiffness
ElementBodyForceStiffness(bf, el, ke);
// get the element's LM vector
vector<int> lm;
UnpackLM(el, lm);
ke.SetIndices(lm);
// assemble element matrix in global stiffness matrix
LS.Assemble(ke);
}
}
//-----------------------------------------------------------------------------
//! Calculates the shell element stiffness matrix
void FEElasticEASShellDomain::ElementStiffness(int iel, matrix& ke)
{
FEShellElementNew& el = ShellElement(iel);
int i, i6, j, j6, n;
// Get the current element's data
const int nint = el.GaussPoints();
const int neln = el.Nodes();
// jacobian matrix determinant
double detJt;
// weights at gauss points
const double *gw = el.GaussWeights();
vec3d Gcnt[3];
// allocate arrays
vector<mat3ds> S(nint);
vector<tens4dmm> C(nint);
vector<double> EE;
vector< vector<vec3d>> HU;
vector< vector<vec3d>> HW;
matrix NS(neln,16);
matrix NN(neln,8);
bool ANS = true;
// bool ANS = false;
if (ANS) CollocationStrainsANS(el, EE, HU, HW, NS, NN);
// EAS method: Evaluate Kua, Kwa, and Kaa
// Also evaluate PK2 stress and material tangent using enhanced strain
EvaluateEAS(el, EE, HU, HW, S, C);
// calculate element stiffness matrix
vector<matrix> hu(neln, matrix(3,6));
vector<matrix> hw(neln, matrix(3,6));
vector<vec3d> Nu(neln);
vector<vec3d> Nw(neln);
ke.zero();
matrix KUU(3,3), KUW(3,3), KWU(3,3), KWW(3,3);
for (i=0, i6=0; i<neln; ++i, i6 += 6)
{
for (j=0, j6 = 0; j<neln; ++j, j6 += 6)
{
KUU = (el.m_Kua[i]*el.m_Kaai*el.m_Kua[j].transpose());
KUW = (el.m_Kua[i]*el.m_Kaai*el.m_Kwa[j].transpose());
KWU = (el.m_Kwa[i]*el.m_Kaai*el.m_Kua[j].transpose());
KWW = (el.m_Kwa[i]*el.m_Kaai*el.m_Kwa[j].transpose());
ke[i6 ][j6 ] -= KUU(0,0); ke[i6 ][j6+1] -= KUU(0,1); ke[i6 ][j6+2] -= KUU(0,2);
ke[i6+1][j6 ] -= KUU(1,0); ke[i6+1][j6+1] -= KUU(1,1); ke[i6+1][j6+2] -= KUU(1,2);
ke[i6+2][j6 ] -= KUU(2,0); ke[i6+2][j6+1] -= KUU(2,1); ke[i6+2][j6+2] -= KUU(2,2);
ke[i6 ][j6+3] -= KUW(0,0); ke[i6 ][j6+4] -= KUW(0,1); ke[i6 ][j6+5] -= KUW(0,2);
ke[i6+1][j6+3] -= KUW(1,0); ke[i6+1][j6+4] -= KUW(1,1); ke[i6+1][j6+5] -= KUW(1,2);
ke[i6+2][j6+3] -= KUW(2,0); ke[i6+2][j6+4] -= KUW(2,1); ke[i6+2][j6+5] -= KUW(2,2);
ke[i6+3][j6 ] -= KWU(0,0); ke[i6+3][j6+1] -= KWU(0,1); ke[i6+3][j6+2] -= KWU(0,2);
ke[i6+4][j6 ] -= KWU(1,0); ke[i6+4][j6+1] -= KWU(1,1); ke[i6+4][j6+2] -= KWU(1,2);
ke[i6+5][j6 ] -= KWU(2,0); ke[i6+5][j6+1] -= KWU(2,1); ke[i6+5][j6+2] -= KWU(2,2);
ke[i6+3][j6+3] -= KWW(0,0); ke[i6+3][j6+4] -= KWW(0,1); ke[i6+3][j6+5] -= KWW(0,2);
ke[i6+4][j6+3] -= KWW(1,0); ke[i6+4][j6+4] -= KWW(1,1); ke[i6+4][j6+5] -= KWW(1,2);
ke[i6+5][j6+3] -= KWW(2,0); ke[i6+5][j6+4] -= KWW(2,1); ke[i6+5][j6+5] -= KWW(2,2);
}
}
for (n=0; n<nint; ++n)
{
ContraBaseVectors0(el, n, Gcnt);
mat3ds E;
EvaluateEh(el, n, Gcnt, E, hu, hw, Nu, Nw);
if (ANS) EvaluateANS(el, n, Gcnt, E, hu, hw, EE, HU, HW);
// calculate the jacobian
detJt = detJ0(el, n)*gw[n];
// evaluate 2nd P-K stress
matrix SC(6,1);
mat3dsCntMat61(S[n], Gcnt, SC);
// mat3ds S = m_pMat->PK2Stress(E);
// mat3dsCntMat61(S, Gcnt, SC);
// evaluate the material tangent
matrix CC(6,6);
tens4dmmCntMat66(C[n], Gcnt, CC);
// tens4dsCntMat66(C[n], Gcnt, CC);
// tens4ds c = m_pMat->MaterialTangent(E);
// tens4dsCntMat66(c, Gcnt, CC);
// ------------ constitutive component --------------
for (i=0, i6=0; i<neln; ++i, i6 += 6)
{
for (j=0, j6 = 0; j<neln; ++j, j6 += 6)
{
matrix KUU(3,3), KUW(3,3), KWU(3,3), KWW(3,3);
KUU = hu[i]*CC*hu[j].transpose();
KUW = hu[i]*CC*hw[j].transpose();
KWU = hw[i]*CC*hu[j].transpose();
KWW = hw[i]*CC*hw[j].transpose();
KUU *= detJt; KUW *= detJt; KWU *= detJt; KWW *= detJt;
ke[i6 ][j6 ] += KUU(0,0); ke[i6 ][j6+1] += KUU(0,1); ke[i6 ][j6+2] += KUU(0,2);
ke[i6+1][j6 ] += KUU(1,0); ke[i6+1][j6+1] += KUU(1,1); ke[i6+1][j6+2] += KUU(1,2);
ke[i6+2][j6 ] += KUU(2,0); ke[i6+2][j6+1] += KUU(2,1); ke[i6+2][j6+2] += KUU(2,2);
ke[i6 ][j6+3] += KUW(0,0); ke[i6 ][j6+4] += KUW(0,1); ke[i6 ][j6+5] += KUW(0,2);
ke[i6+1][j6+3] += KUW(1,0); ke[i6+1][j6+4] += KUW(1,1); ke[i6+1][j6+5] += KUW(1,2);
ke[i6+2][j6+3] += KUW(2,0); ke[i6+2][j6+4] += KUW(2,1); ke[i6+2][j6+5] += KUW(2,2);
ke[i6+3][j6 ] += KWU(0,0); ke[i6+3][j6+1] += KWU(0,1); ke[i6+3][j6+2] += KWU(0,2);
ke[i6+4][j6 ] += KWU(1,0); ke[i6+4][j6+1] += KWU(1,1); ke[i6+4][j6+2] += KWU(1,2);
ke[i6+5][j6 ] += KWU(2,0); ke[i6+5][j6+1] += KWU(2,1); ke[i6+5][j6+2] += KWU(2,2);
ke[i6+3][j6+3] += KWW(0,0); ke[i6+3][j6+4] += KWW(0,1); ke[i6+3][j6+5] += KWW(0,2);
ke[i6+4][j6+3] += KWW(1,0); ke[i6+4][j6+4] += KWW(1,1); ke[i6+4][j6+5] += KWW(1,2);
ke[i6+5][j6+3] += KWW(2,0); ke[i6+5][j6+4] += KWW(2,1); ke[i6+5][j6+5] += KWW(2,2);
}
}
// ------------ initial stress component --------------
for (i=0; i<neln; ++i) {
for (j=0; j<neln; ++j)
{
double Kuu, Kuw, Kwu, Kww;
if (ANS) {
double r = el.gr(n);
double s = el.gs(n);
double N13uu = ((NS(i,0)*NS(j,1) + NS(j,0)*NS(i,1))*(1-s)+
(NS(i,8)*NS(j,9) + NS(j,8)*NS(i,9))*(1+s))/2;
double N23uu = ((NS(i,12)*NS(j,13) + NS(j,12)*NS(i,13))*(1-r)+
(NS(i,4)*NS(j,5) + NS(j,4)*NS(i,5))*(1+r))/2;
double N33uu = ((1-r)*(1-s)*NN(i,0)*NN(j,0) +
(1+r)*(1-s)*NN(i,2)*NN(j,2) +
(1+r)*(1+s)*NN(i,4)*NN(j,4) +
(1-r)*(1+s)*NN(i,6)*NN(j,6))/4;
Kuu = (SC(0,0)*Nu[i].x*Nu[j].x+
SC(1,0)*Nu[i].y*Nu[j].y+
SC(2,0)*N33uu+
SC(3,0)*(Nu[i].x*Nu[j].y+Nu[j].x*Nu[i].y)+
SC(4,0)*N23uu+
SC(5,0)*N13uu)*detJt;
double N13uw = ((NS(i,0)*NS(j,3) + NS(j,2)*NS(i,1))*(1-s)+
(NS(i,8)*NS(j,11) + NS(j,10)*NS(i,9))*(1+s))/2;
double N23uw = ((NS(i,12)*NS(j,15) + NS(j,14)*NS(i,13))*(1-r)+
(NS(i,4)*NS(j,7) + NS(j,6)*NS(i,5))*(1+r))/2;
double N33uw = ((1-r)*(1-s)*NN(i,0)*NN(j,1) +
(1+r)*(1-s)*NN(i,2)*NN(j,3) +
(1+r)*(1+s)*NN(i,4)*NN(j,5) +
(1-r)*(1+s)*NN(i,6)*NN(j,7))/4;
Kuw = (SC(0,0)*Nu[i].x*Nw[j].x+
SC(1,0)*Nu[i].y*Nw[j].y+
SC(2,0)*N33uw+
SC(3,0)*(Nu[i].x*Nw[j].y+Nu[j].x*Nw[i].y)+
SC(4,0)*N23uw+
SC(5,0)*N13uw)*detJt;
double N13wu = ((NS(i,2)*NS(j,1) + NS(j,0)*NS(i,3))*(1-s)+
(NS(i,10)*NS(j,9) + NS(j,8)*NS(i,11))*(1+s))/2;
double N23wu = ((NS(i,14)*NS(j,13) + NS(j,12)*NS(i,15))*(1-r)+
(NS(i,6)*NS(j,5) + NS(j,4)*NS(i,7))*(1+r))/2;
double N33wu = ((1-r)*(1-s)*NN(i,1)*NN(j,0) +
(1+r)*(1-s)*NN(i,3)*NN(j,2) +
(1+r)*(1+s)*NN(i,5)*NN(j,4) +
(1-r)*(1+s)*NN(i,7)*NN(j,6))/4;
Kwu = (SC(0,0)*Nw[i].x*Nu[j].x+
SC(1,0)*Nw[i].y*Nu[j].y+
SC(2,0)*N33wu+
SC(3,0)*(Nw[i].x*Nu[j].y+Nw[j].x*Nu[i].y)+
SC(4,0)*N23wu+
SC(5,0)*N13wu)*detJt;
double N13ww = ((NS(i,2)*NS(j,3) + NS(j,2)*NS(i,3))*(1-s)+
(NS(i,10)*NS(j,11) + NS(j,10)*NS(i,11))*(1+s))/2;
double N23ww = ((NS(i,14)*NS(j,15) + NS(j,14)*NS(i,15))*(1-r)+
(NS(i,6)*NS(j,7) + NS(j,6)*NS(i,7))*(1+r))/2;
double N33ww = ((1-r)*(1-s)*NN(i,1)*NN(j,1) +
(1+r)*(1-s)*NN(i,3)*NN(j,3) +
(1+r)*(1+s)*NN(i,5)*NN(j,5) +
(1-r)*(1+s)*NN(i,7)*NN(j,7))/4;
Kww = (SC(0,0)*Nw[i].x*Nw[j].x+
SC(1,0)*Nw[i].y*Nw[j].y+
SC(2,0)*N33ww+
SC(3,0)*(Nw[i].x*Nw[j].y+Nw[j].x*Nw[i].y)+
SC(4,0)*N23ww+
SC(5,0)*N13ww)*detJt;
}
else {
Kuu = (SC(0,0)*Nu[i].x*Nu[j].x+
SC(1,0)*Nu[i].y*Nu[j].y+
SC(2,0)*Nu[i].z*Nu[j].z+
SC(3,0)*(Nu[i].x*Nu[j].y+Nu[j].x*Nu[i].y)+
SC(4,0)*(Nu[i].y*Nu[j].z+Nu[j].y*Nu[i].z)+
SC(5,0)*(Nu[i].z*Nu[j].x+Nu[j].z*Nu[i].x))*detJt;
Kuw = (SC(0,0)*Nu[i].x*Nw[j].x+
SC(1,0)*Nu[i].y*Nw[j].y+
SC(2,0)*Nu[i].z*Nw[j].z+
SC(3,0)*(Nu[i].x*Nw[j].y+Nu[j].x*Nw[i].y)+
SC(4,0)*(Nu[i].y*Nw[j].z+Nu[j].y*Nw[i].z)+
SC(5,0)*(Nu[i].z*Nw[j].x+Nu[j].z*Nw[i].x))*detJt;
Kwu = (SC(0,0)*Nw[i].x*Nu[j].x+
SC(1,0)*Nw[i].y*Nu[j].y+
SC(2,0)*Nw[i].z*Nu[j].z+
SC(3,0)*(Nw[i].x*Nu[j].y+Nw[j].x*Nu[i].y)+
SC(4,0)*(Nw[i].y*Nu[j].z+Nw[j].y*Nu[i].z)+
SC(5,0)*(Nw[i].z*Nu[j].x+Nw[j].z*Nu[i].x))*detJt;
Kww = (SC(0,0)*Nw[i].x*Nw[j].x+
SC(1,0)*Nw[i].y*Nw[j].y+
SC(2,0)*Nw[i].z*Nw[j].z+
SC(3,0)*(Nw[i].x*Nw[j].y+Nw[j].x*Nw[i].y)+
SC(4,0)*(Nw[i].y*Nw[j].z+Nw[j].y*Nw[i].z)+
SC(5,0)*(Nw[i].z*Nw[j].x+Nw[j].z*Nw[i].x))*detJt;
}
// the u-u component
ke[6*i ][6*j ] += Kuu;
ke[6*i+1][6*j+1] += Kuu;
ke[6*i+2][6*j+2] += Kuu;
// the u-w component
ke[6*i ][6*j+3] += Kuw;
ke[6*i+1][6*j+4] += Kuw;
ke[6*i+2][6*j+5] += Kuw;
// the w-u component
ke[6*i+3][6*j ] += Kwu;
ke[6*i+4][6*j+1] += Kwu;
ke[6*i+5][6*j+2] += Kwu;
// the w-w component
ke[6*i+3][6*j+3] += Kww;
ke[6*i+4][6*j+4] += Kww;
ke[6*i+5][6*j+5] += Kww;
}
}
} // end loop over gauss-points
}
//-----------------------------------------------------------------------------
//! calculates element inertial stiffness matrix
void FEElasticEASShellDomain::ElementMassMatrix(FEShellElementNew& el, matrix& ke, double a)
{
// Get the current element's data
const int nint = el.GaussPoints();
const int neln = el.Nodes();
// weights at gauss points
const double *gw = el.GaussWeights();
// calculate element stiffness matrix
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
double D = m_pMat->Density(mp);
// shape functions
double* M = el.H(n);
// Jacobian
double J0 = detJ0(el, n)*gw[n];
// parametric coordinate through thickness
double eta = el.gt(n);
for (int i=0; i<neln; ++i)
for (int j=0; j<neln; ++j)
{
double Kuu = (1+eta)/2*M[i]*(1+eta)/2*M[j]*a*D*J0;
double Kud = (1+eta)/2*M[i]*(1-eta)/2*M[j]*a*D*J0;
double Kdu = (1-eta)/2*M[i]*(1+eta)/2*M[j]*a*D*J0;
double Kdd = (1-eta)/2*M[i]*(1-eta)/2*M[j]*a*D*J0;
// the u-u component
ke[6*i ][6*j ] += Kuu;
ke[6*i+1][6*j+1] += Kuu;
ke[6*i+2][6*j+2] += Kuu;
// the u-d component
ke[6*i ][6*j+3] += Kud;
ke[6*i+1][6*j+4] += Kud;
ke[6*i+2][6*j+5] += Kud;
// the d-u component
ke[6*i+3][6*j ] += Kdu;
ke[6*i+4][6*j+1] += Kdu;
ke[6*i+5][6*j+2] += Kdu;
// the d-d component
ke[6*i+3][6*j+3] += Kdd;
ke[6*i+4][6*j+4] += Kdd;
ke[6*i+5][6*j+5] += Kdd;
}
}
}
//-----------------------------------------------------------------------------
//! Calculates body forces for shells
void FEElasticEASShellDomain::ElementBodyForce(FEModel& fem, FEShellElementNew& el, vector<double>& fe)
{
int NF = fem.ModelLoads();
for (int nf = 0; nf < NF; ++nf)
{
FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(fem.ModelLoad(nf));
if (pbf)
{
// integration weights
double* gw = el.GaussWeights();
double eta;
double *M, detJt;
// loop over integration points
int nint = el.GaussPoints();
int neln = el.Nodes();
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
// calculate density in current configuration
double dens0 = m_pMat->Density(mp);
double dens = dens0/pt.m_J;
// calculate the jacobian
detJt = detJ(el, n)*gw[n];
M = el.H(n);
eta = el.gt(n);
// get the force
vec3d f = pbf->force(mp);
for (int i=0; i<neln; ++i)
{
vec3d fu = f*(dens*M[i]*(1+eta)/2);
vec3d fd = f*(dens*M[i]*(1-eta)/2);
fe[6*i ] -= fu.x*detJt;
fe[6*i+1] -= fu.y*detJt;
fe[6*i+2] -= fu.z*detJt;
fe[6*i+3] -= fd.x*detJt;
fe[6*i+4] -= fd.y*detJt;
fe[6*i+5] -= fd.z*detJt;
}
}
}
}
}
//-----------------------------------------------------------------------------
// Update alpha in EAS method
void FEElasticEASShellDomain::UpdateEAS(vector<double>& ui)
{
FEMesh& mesh = *GetMesh();
for (int i=0; i<(int) m_Elem.size(); ++i)
{
// get the solid element
FEShellElementNew& el = m_Elem[i];
// number of nodes
int neln = el.Nodes();
// allocate arrays
matrix dalpha(m_nEAS,1);
matrix Du(3,1), Dw(3,1);
// nodal coordinates and EAS vector alpha update
dalpha = el.m_fa;
for (int j=0; j<neln; ++j)
{
FENode& nj = mesh.Node(el.m_node[j]);
Du(0,0) = (nj.m_ID[m_dofU[0]] >=0) ? ui[nj.m_ID[m_dofU[0]]] : 0;
Du(1,0) = (nj.m_ID[m_dofU[1]] >=0) ? ui[nj.m_ID[m_dofU[1]]] : 0;
Du(2,0) = (nj.m_ID[m_dofU[2]] >=0) ? ui[nj.m_ID[m_dofU[2]]] : 0;
Dw(0,0) = (nj.m_ID[m_dofSU[0]] >=0) ? ui[nj.m_ID[m_dofSU[0]]] : 0;
Dw(1,0) = (nj.m_ID[m_dofSU[1]] >=0) ? ui[nj.m_ID[m_dofSU[1]]] : 0;
Dw(2,0) = (nj.m_ID[m_dofSU[2]] >=0) ? ui[nj.m_ID[m_dofSU[2]]] : 0;
dalpha += el.m_Kua[j].transpose()*Du + el.m_Kwa[j].transpose()*Dw;
}
dalpha = el.m_Kaai*dalpha;
el.m_alpha = el.m_alphat + el.m_alphai - dalpha;
}
}
//-----------------------------------------------------------------------------
// Update alpha in EAS method
void FEElasticEASShellDomain::UpdateIncrementsEAS(vector<double>& ui, const bool binc)
{
FEMesh& mesh = *GetMesh();
for (int i=0; i<(int) m_Elem.size(); ++i)
{
// get the solid element
FEShellElementNew& el = m_Elem[i];
if (binc) {
// number of nodes
int neln = el.Nodes();
// allocate arrays
matrix dalpha(m_nEAS,1);
matrix Du(3,1), Dw(3,1);
// nodal coordinates and EAS vector alpha update
dalpha = el.m_fa;
for (int j=0; j<neln; ++j)
{
FENode& nj = mesh.Node(el.m_node[j]);
Du(0,0) = (nj.m_ID[m_dofU[0]] >=0) ? ui[nj.m_ID[m_dofU[0]]] : 0;
Du(1,0) = (nj.m_ID[m_dofU[1]] >=0) ? ui[nj.m_ID[m_dofU[1]]] : 0;
Du(2,0) = (nj.m_ID[m_dofU[2]] >=0) ? ui[nj.m_ID[m_dofU[2]]] : 0;
Dw(0,0) = (nj.m_ID[m_dofSU[0]] >=0) ? ui[nj.m_ID[m_dofSU[0]]] : 0;
Dw(1,0) = (nj.m_ID[m_dofSU[1]] >=0) ? ui[nj.m_ID[m_dofSU[1]]] : 0;
Dw(2,0) = (nj.m_ID[m_dofSU[2]] >=0) ? ui[nj.m_ID[m_dofSU[2]]] : 0;
dalpha += el.m_Kua[j].transpose()*Du + el.m_Kwa[j].transpose()*Dw;
}
dalpha = el.m_Kaai*dalpha;
el.m_alphai -= dalpha;
}
else el.m_alphat += el.m_alphai;
}
}
//-----------------------------------------------------------------------------
void FEElasticEASShellDomain::Update(const FETimeInfo& tp)
{
FESSIShellDomain::Update(tp);
bool berr = false;
int NE = Elements();
#pragma omp parallel for shared(NE, berr)
for (int i=0; i<NE; ++i)
{
try
{
FEShellElement& el = Element(i);
if (el.isActive())
{
UpdateElementStress(i, tp);
}
}
catch (NegativeJacobian e)
{
#pragma omp critical
{
// reset the logfile mode
berr = true;
if (e.DoOutput()) feLogError(e.what());
}
}
}
if (berr) throw NegativeJacobianDetected();
}
//-----------------------------------------------------------------------------
void FEElasticEASShellDomain::UpdateElementStress(int iel, const FETimeInfo& tp)
{
double dt = tp.timeIncrement;
// get the solid element
FEShellElementNew& el = m_Elem[iel];
// get the number of integration points
int nint = el.GaussPoints();
// number of nodes
int neln = el.Nodes();
const int NELN = FEElement::MAX_NODES;
vec3d r0[NELN], s0[NELN], r[NELN], s[NELN];
vec3d v[NELN], w[NELN];
vec3d a[NELN], b[NELN];
// nodal coordinates
GetCurrentNodalCoordinates(el, r, tp.alphaf, false);
GetCurrentNodalCoordinates(el, s, tp.alphaf, true);
GetReferenceNodalCoordinates(el, r0, false);
GetReferenceNodalCoordinates(el, s0, true);
// update dynamic quantities
if (m_update_dynamic)
{
for (int j=0; j<neln; ++j)
{
FENode& node = m_pMesh->Node(el.m_node[j]);
v[j] = node.get_vec3d(m_dofV[0], m_dofV[1], m_dofV[2])*tp.alphaf + node.m_vp*(1-tp.alphaf);
w[j] = node.get_vec3d(m_dofSV[0], m_dofSV[1], m_dofSV[2])*tp.alphaf + node.get_vec3d_prev(m_dofSV[0], m_dofSV[1], m_dofSV[2])*(1-tp.alphaf);
a[j] = node.m_at*tp.alpham + node.m_ap*(1-tp.alpham);
b[j] = node.get_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2])*tp.alpham + node.get_vec3d_prev(m_dofSA[0], m_dofSA[1], m_dofSA[2])*(1-tp.alpham);
}
}
// loop over the integration points and calculate
// the stress at the integration point
for (int n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *(el.GetMaterialPoint(n));
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
// material point coordinates
// TODO: I'm not entirly happy with this solution
// since the material point coordinates are used by most materials.
mp.m_r0 = evaluate(el, r0, s0, n);
mp.m_rt = evaluate(el, r, s, n);
// get the deformation gradient and determinant at intermediate time
mat3d Ft, Fp;
double Jt = defgrad(el, Ft, n);
double Jp = defgradp(el, Fp, n);
if (tp.alphaf == 1.0)
{
pt.m_F = Ft;
pt.m_J = Jt;
}
else
{
pt.m_F = Ft * tp.alphaf + Fp * (1 - tp.alphaf);
pt.m_J = pt.m_F.det();
}
mat3d Fi = pt.m_F.inverse();
pt.m_L = (Ft - Fp)*Fi/dt;
if (m_update_dynamic)
{
pt.m_v = evaluate(el, v, w, n);
pt.m_a = evaluate(el, a, b, n);
}
// update specialized material points
m_pMat->UpdateSpecializedMaterialPoints(mp, tp);
// calculate the stress at this material point
mat3ds S = m_secant_stress ? m_pMat->SecantStress(mp, true) : m_pMat->PK2Stress(mp, el.m_E[n]);
pt.m_s = (pt.m_F*S*pt.m_F.transpose()).sym()/pt.m_J;
// adjust stress for strain energy conservation
if (tp.alphaf == 0.5)
{
// evaluate strain energy at current time
mat3d Ftmp = pt.m_F;
double Jtmp = pt.m_J;
pt.m_F = Ft;
pt.m_J = Jt;
FEElasticMaterial* pme = dynamic_cast<FEElasticMaterial*>(m_pMat);
pt.m_Wt = pme->StrainEnergyDensity(mp);
pt.m_F = Ftmp;
pt.m_J = Jtmp;
mat3ds D = pt.m_L.sym();
double D2 = D.dotdot(D);
if (D2 > 0)
pt.m_s += D*(((pt.m_Wt-pt.m_Wp)/(dt*pt.m_J) - pt.m_s.dotdot(D))/D2);
}
}
}
//-----------------------------------------------------------------------------
//! Unpack the element. That is, copy element data in traits structure
//! Note that for the shell elements the lm order is different compared
//! to the solid element ordering. This is because for shell elements the
//! nodes have six degrees of freedom each, where for solids they only
//! have 3 dofs.
void FEElasticEASShellDomain::UnpackLM(FEElement& el, vector<int>& lm)
{
int N = el.Nodes();
lm.resize(N*9);
for (int i=0; i<N; ++i)
{
FENode& node = m_pMesh->Node(el.m_node[i]);
vector<int>& id = node.m_ID;
// first the displacement dofs
lm[6*i ] = id[m_dofU[0]];
lm[6*i+1] = id[m_dofU[1]];
lm[6*i+2] = id[m_dofU[2]];
// next the shell displacement dofs
lm[6*i+3] = id[m_dofSU[0]];
lm[6*i+4] = id[m_dofSU[1]];
lm[6*i+5] = id[m_dofSU[2]];
// rigid rotational dofs
lm[6*N + 3*i ] = id[m_dofR[0]];
lm[6*N + 3*i+1] = id[m_dofR[1]];
lm[6*N + 3*i+2] = id[m_dofR[2]];
}
}
//-----------------------------------------------------------------------------
//! Generate the G matrix for EAS method
void FEElasticEASShellDomain::GenerateGMatrix(FEShellElementNew& el, const int n, const double Jeta, matrix& G)
{
vec3d Gcnt[3], Gcov[3];
CoBaseVectors0(el, n, Gcov);
ContraBaseVectors0(el, 0, 0, 0, Gcnt);
double J0 = detJ0(el, 0, 0, 0);
double Jr = J0/Jeta;
double G00 = Gcov[0]*Gcnt[0];
double G01 = Gcov[0]*Gcnt[1];
double G02 = Gcov[0]*Gcnt[2];
double G10 = Gcov[1]*Gcnt[0];
double G11 = Gcov[1]*Gcnt[1];
double G12 = Gcov[1]*Gcnt[2];
double G20 = Gcov[2]*Gcnt[0];
double G21 = Gcov[2]*Gcnt[1];
double G22 = Gcov[2]*Gcnt[2];
matrix T0(6,6);
T0(0,0) = G00*G00; T0(0,1) = G01*G01; T0(0,2) = G02*G02; T0(0,3) = G00*G01; T0(0,4) = G01*G02; T0(0,5) = G00*G02;
T0(1,0) = G10*G10; T0(1,1) = G11*G11; T0(1,2) = G12*G12; T0(1,3) = G10*G11; T0(1,4) = G11*G12; T0(1,5) = G10*G12;
T0(2,0) = G20*G20; T0(2,1) = G21*G21; T0(2,2) = G22*G22; T0(2,3) = G20*G21; T0(2,4) = G21*G22; T0(2,5) = G20*G22;
T0(3,0) = 2*G00*G10; T0(3,1) = 2*G01*G11; T0(3,2) = 2*G02*G12; T0(3,3) = G00*G11+G01*G10; T0(3,4) = G01*G12+G02*G11; T0(3,5) = G00*G12+G02*G10;
T0(4,0) = 2*G10*G20; T0(4,1) = 2*G11*G21; T0(4,2) = 2*G12*G22; T0(4,3) = G10*G21+G11*G20; T0(4,4) = G11*G22+G12*G21; T0(4,5) = G10*G22+G12*G20;
T0(5,0) = 2*G00*G20; T0(5,1) = 2*G01*G21; T0(5,2) = 2*G02*G22; T0(5,3) = G00*G21+G01*G20; T0(5,4) = G01*G22+G02*G21; T0(5,5) = G00*G22+G02*G20;
G.resize(6, m_nEAS);
double r = el.gr(n);
double s = el.gs(n);
double t = el.gt(n);
G(0,0) = r*T0(0,0)*Jr;
G(1,0) = r*T0(1,0)*Jr;
G(2,0) = r*T0(2,0)*Jr;
G(3,0) = r*T0(3,0)*Jr;
G(4,0) = r*T0(4,0)*Jr;
G(5,0) = r*T0(5,0)*Jr;
G(0,1) = s*T0(0,1)*Jr;
G(1,1) = s*T0(1,1)*Jr;
G(2,1) = s*T0(2,1)*Jr;
G(3,1) = s*T0(3,1)*Jr;
G(4,1) = s*T0(4,1)*Jr;
G(5,1) = s*T0(5,1)*Jr;
G(0,2) = t*T0(0,2)*Jr;
G(1,2) = t*T0(1,2)*Jr;
G(2,2) = t*T0(2,2)*Jr;
G(3,2) = t*T0(3,2)*Jr;
G(4,2) = t*T0(4,2)*Jr;
G(5,2) = t*T0(5,2)*Jr;
G(0,3) = r*t*T0(0,2)*Jr;
G(1,3) = r*t*T0(1,2)*Jr;
G(2,3) = r*t*T0(2,2)*Jr;
G(3,3) = r*t*T0(3,2)*Jr;
G(4,3) = r*t*T0(4,2)*Jr;
G(5,3) = r*t*T0(5,2)*Jr;
G(0,4) = s*t*T0(0,2)*Jr;
G(1,4) = s*t*T0(1,2)*Jr;
G(2,4) = s*t*T0(2,2)*Jr;
G(3,4) = s*t*T0(3,2)*Jr;
G(4,4) = s*t*T0(4,2)*Jr;
G(5,4) = s*t*T0(5,2)*Jr;
G(0,5) = r*T0(0,3)*Jr;
G(1,5) = r*T0(1,3)*Jr;
G(2,5) = r*T0(2,3)*Jr;
G(3,5) = r*T0(3,3)*Jr;
G(4,5) = r*T0(4,3)*Jr;
G(5,5) = r*T0(5,3)*Jr;
G(0,6) = s*T0(0,3)*Jr;
G(1,6) = s*T0(1,3)*Jr;
G(2,6) = s*T0(2,3)*Jr;
G(3,6) = s*T0(3,3)*Jr;
G(4,6) = s*T0(4,3)*Jr;
G(5,6) = s*T0(5,3)*Jr;
}
//-----------------------------------------------------------------------------
//! Evaluate contravariant components of mat3ds tensor
void FEElasticEASShellDomain::mat3dsCntMat61(const mat3ds s, const vec3d* Gcnt, matrix& S)
{
S.resize(6, 1);
S(0,0) = Gcnt[0]*(s*Gcnt[0]);
S(1,0) = Gcnt[1]*(s*Gcnt[1]);
S(2,0) = Gcnt[2]*(s*Gcnt[2]);
S(3,0) = Gcnt[0]*(s*Gcnt[1]);
S(4,0) = Gcnt[1]*(s*Gcnt[2]);
S(5,0) = Gcnt[0]*(s*Gcnt[2]);
}
//-----------------------------------------------------------------------------
//! Evaluate contravariant components of tens4ds tensor
//! Cijkl = Gj.(Gi.c.Gl).Gk
void FEElasticEASShellDomain::tens4dsCntMat66(const tens4ds c, const vec3d* Gcnt, matrix& C)
{
C.resize(6, 6);
C(0,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[0])*Gcnt[0]); // i=0, j=0, k=0, l=0
C(0,1) = C(1,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[1]); // i=0, j=0, k=1, l=1
C(0,2) = C(2,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[2]); // i=0, j=0, k=2, l=2
C(0,3) = C(3,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[0]); // i=0, j=0, k=0, l=1
C(0,4) = C(4,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[1]); // i=0, j=0, k=1, l=2
C(0,5) = C(5,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=0, k=0, l=2
C(1,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[1])*Gcnt[1]); // i=1, j=1, k=1, l=1
C(1,2) = C(2,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[2]); // i=1, j=1, k=2, l=2
C(1,3) = C(3,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[1])*Gcnt[0]); // i=1, j=1, k=0, l=1
C(1,4) = C(4,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[1]); // i=1, j=1, k=1, l=2
C(1,5) = C(5,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[0]); // i=1, j=1, k=0, l=2
C(2,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[2]); // i=2, j=2, k=2, l=2
C(2,3) = C(3,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[1])*Gcnt[0]); // i=2, j=2, k=0, l=1
C(2,4) = C(4,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[1]); // i=2, j=2, k=1, l=2
C(2,5) = C(5,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[0]); // i=2, j=2, k=0, l=2
C(3,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[0]); // i=0, j=1, k=0, l=1
C(3,4) = C(4,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[1]); // i=0, j=1, k=1, l=2
C(3,5) = C(5,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=1, k=0, l=2
C(4,4) = Gcnt[2]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[1]); // i=1, j=2, k=1, l=2
C(4,5) = C(5,4) = Gcnt[2]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[0]); // i=1, j=2, k=0, l=2
C(5,5) = Gcnt[2]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=2, k=0, l=2
}
//-----------------------------------------------------------------------------
//! Evaluate contravariant components of tens4dmm tensor
//! Cijkl = Gj.(Gi.c.Gl).Gk
void FEElasticEASShellDomain::tens4dmmCntMat66(const tens4dmm c, const vec3d* Gcnt, matrix& C)
{
C.resize(6, 6);
C(0,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[0])*Gcnt[0]); // i=0, j=0, k=0, l=0
C(0,1) = C(1,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[1]); // i=0, j=0, k=1, l=1
C(0,2) = C(2,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[2]); // i=0, j=0, k=2, l=2
C(0,3) = C(3,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[0]); // i=0, j=0, k=0, l=1
C(0,4) = C(4,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[1]); // i=0, j=0, k=1, l=2
C(0,5) = C(5,0) = Gcnt[0]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=0, k=0, l=2
C(1,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[1])*Gcnt[1]); // i=1, j=1, k=1, l=1
C(1,2) = C(2,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[2]); // i=1, j=1, k=2, l=2
C(1,3) = C(3,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[1])*Gcnt[0]); // i=1, j=1, k=0, l=1
C(1,4) = C(4,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[1]); // i=1, j=1, k=1, l=2
C(1,5) = C(5,1) = Gcnt[1]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[0]); // i=1, j=1, k=0, l=2
C(2,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[2]); // i=2, j=2, k=2, l=2
C(2,3) = C(3,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[1])*Gcnt[0]); // i=2, j=2, k=0, l=1
C(2,4) = C(4,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[1]); // i=2, j=2, k=1, l=2
C(2,5) = C(5,2) = Gcnt[2]*(vdotTdotv(Gcnt[2], c, Gcnt[2])*Gcnt[0]); // i=2, j=2, k=0, l=2
C(3,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[1])*Gcnt[0]); // i=0, j=1, k=0, l=1
C(3,4) = C(4,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[1]); // i=0, j=1, k=1, l=2
C(3,5) = C(5,3) = Gcnt[1]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=1, k=0, l=2
C(4,4) = Gcnt[2]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[1]); // i=1, j=2, k=1, l=2
C(4,5) = C(5,4) = Gcnt[2]*(vdotTdotv(Gcnt[1], c, Gcnt[2])*Gcnt[0]); // i=1, j=2, k=0, l=2
C(5,5) = Gcnt[2]*(vdotTdotv(Gcnt[0], c, Gcnt[2])*Gcnt[0]); // i=0, j=2, k=0, l=2
}
//-----------------------------------------------------------------------------
//! Evaluate the matrices and vectors relevant to the EAS method
void FEElasticEASShellDomain::EvaluateEAS(FEShellElementNew& el, vector<double>& EE,
vector< vector<vec3d>>& HU, vector< vector<vec3d>>& HW,
vector<mat3ds>& S, vector<tens4dmm>& c)
{
int i, n;
// jacobian matrix determinant
double detJt;
const double* Mr, *Ms, *M;
int nint = el.GaussPoints();
int neln = el.Nodes();
vector<matrix> hu(neln, matrix(3,6));
vector<matrix> hw(neln, matrix(3,6));
vector<vec3d> Nu(neln);
vector<vec3d> Nw(neln);
matrix NS(neln,16);
matrix NN(neln,8);
double* gw = el.GaussWeights();
double eta;
vec3d Gcnt[3];
// Evaluate fa, Kua, Kwa, and Kaa by integrating over the element
el.m_fa.zero();
el.m_Kaai.zero();
for (i=0; i< neln; ++i) {
el.m_Kua[i].zero();
el.m_Kwa[i].zero();
}
// repeat for all integration points
for (n=0; n<nint; ++n)
{
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
ContraBaseVectors0(el, n, Gcnt);
mat3ds Ec;
// Evaluate compatible strain tensor
EvaluateEh(el, n, Gcnt, Ec, hu, hw, Nu, Nw);
// Evaluate assumed natural strain (ANS) and substitute it into Ec
EvaluateANS(el, n, Gcnt, Ec, hu, hw, EE, HU, HW);
// calculate the jacobian
detJt = detJ0(el, n);
// generate G matrix for EAS method
matrix G;
GenerateGMatrix(el, n, detJt, G);
detJt *= gw[n];
// Evaluate enhancing strain ES (covariant components)
matrix ES(6,1);
ES = G*el.m_alpha;
// Evaluate the tensor form of ES
mat3ds Es = ((Gcnt[0] & Gcnt[0])*ES(0,0) + (Gcnt[1] & Gcnt[1])*ES(1,0) + (Gcnt[2] & Gcnt[2])*ES(2,0) +
((Gcnt[0] & Gcnt[1]) + (Gcnt[1] & Gcnt[0]))*(ES(3,0)/2) +
((Gcnt[1] & Gcnt[2]) + (Gcnt[2] & Gcnt[1]))*(ES(4,0)/2) +
((Gcnt[2] & Gcnt[0]) + (Gcnt[0] & Gcnt[2]))*(ES(5,0)/2)).sym();
// Evaluate enhanced strain
el.m_E[n] = Ec + Es;
// get the stress tensor for this integration point and evaluate its contravariant components
S[n] = m_pMat->PK2Stress(mp, el.m_E[n]);
matrix SM;
mat3dsCntMat61(S[n], Gcnt, SM);
// get the material tangent
c[n] = m_pMat->MaterialTangent(mp, el.m_E[n]);
// get contravariant components of material tangent
matrix CC;
tens4dmmCntMat66(c[n], Gcnt, CC);
// tens4dsCntMat66(c[n], Gcnt, CC);
// Evaluate fa
matrix tmp(m_nEAS,1);
tmp = G.transpose()*SM;
tmp *= detJt;
el.m_fa += tmp;
// Evaluate Kaa
matrix Tmpa(m_nEAS,m_nEAS);
Tmpa = G.transpose()*CC*G;
Tmpa *= detJt;
el.m_Kaai += Tmpa;
eta = el.gt(n);
Mr = el.Hr(n);
Ms = el.Hs(n);
M = el.H(n);
// Evaluate Kua and Kwa
matrix Tmp(3,m_nEAS);
for (i=0; i<neln; ++i)
{
Tmp = hu[i]*CC*G;
Tmp *= detJt;
el.m_Kua[i] += Tmp;
Tmp = hw[i]*CC*G;
Tmp *= detJt;
el.m_Kwa[i] += Tmp;
}
}
// invert Kaa
el.m_Kaai = el.m_Kaai.inverse();
}
//-----------------------------------------------------------------------------
//! Evaluate collocation strains for assumed natural strain (ANS) method
void FEElasticEASShellDomain::CollocationStrainsANS(FEShellElementNew& el, vector<double>& E,
vector< vector<vec3d>>& HU, vector< vector<vec3d>>& HW,
matrix& NS, matrix& NN)
{
FETimeInfo& tp = GetFEModel()->GetTime();
// ANS method for 4-node quadrilaterials
if (el.Nodes() == 4) {
vec3d gcov[3], Gcov[3];
double Mr[FEElement::MAX_NODES], Ms[FEElement::MAX_NODES], M[FEElement::MAX_NODES];
double r, s, t;
int neln = el.Nodes();
double Nur, Nus, Nut;
double Nwr, Nws, Nwt;
// Shear strains E13, E23
// point A
r = 0; s = -1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E13A = (gcov[0]*gcov[2] - Gcov[0]*Gcov[2])/2;
vector<vec3d> hu13A(neln);
vector<vec3d> hw13A(neln);
el.shape_fnc(M, r, s);
el.shape_deriv(Mr, Ms, r, s);
for (int i=0; i<neln; ++i) {
NS(i,0) = Nur = (1+t)/2*Mr[i];
NS(i,1) = Nut = M[i]/2;
NS(i,2) = Nwr = (1-t)/2*Mr[i];
NS(i,3) = Nwt = -M[i]/2;
hu13A[i] = gcov[0]*Nut + gcov[2]*Nur;
hw13A[i] = gcov[0]*Nwt + gcov[2]*Nwr;
}
// point B
r = 1; s = 0; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E23B = (gcov[1]*gcov[2] - Gcov[1]*Gcov[2])/2;
vector<vec3d> hu23B(neln);
vector<vec3d> hw23B(neln);
el.shape_fnc(M, r, s);
el.shape_deriv(Mr, Ms, r, s);
for (int i=0; i<neln; ++i) {
NS(i,4) = Nus = (1+t)/2*Ms[i];
NS(i,5) = Nut = M[i]/2;
NS(i,6) = Nws = (1-t)/2*Ms[i];
NS(i,7) = Nwt = -M[i]/2;
hu23B[i] = gcov[2]*Nus + gcov[1]*Nut;
hw23B[i] = gcov[2]*Nws + gcov[1]*Nwt;
}
// point C
r = 0; s = 1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E13C = (gcov[0]*gcov[2] - Gcov[0]*Gcov[2])/2;
vector<vec3d> hu13C(neln);
vector<vec3d> hw13C(neln);
el.shape_fnc(M, r, s);
el.shape_deriv(Mr, Ms, r, s);
for (int i=0; i<neln; ++i) {
NS(i,8) = Nur = (1+t)/2*Mr[i];
NS(i,9) = Nut = M[i]/2;
NS(i,10) = Nwr = (1-t)/2*Mr[i];
NS(i,11) = Nwt = -M[i]/2;
hu13C[i] = gcov[0]*Nut + gcov[2]*Nur;
hw13C[i] = gcov[0]*Nwt + gcov[2]*Nwr;
}
// point D
r = -1; s = 0; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E23D = (gcov[1]*gcov[2] - Gcov[1]*Gcov[2])/2;
vector<vec3d> hu23D(neln);
vector<vec3d> hw23D(neln);
el.shape_fnc(M, r, s);
el.shape_deriv(Mr, Ms, r, s);
for (int i=0; i<neln; ++i) {
NS(i,12) = Nus = (1+t)/2*Ms[i];
NS(i,13) = Nut = M[i]/2;
NS(i,14) = Nws = (1-t)/2*Ms[i];
NS(i,15) = Nwt = -M[i]/2;
hu23D[i] = gcov[2]*Nus + gcov[1]*Nut;
hw23D[i] = gcov[2]*Nws + gcov[1]*Nwt;
}
// normal strain E33
// point E
r = -1; s = -1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E33E = (gcov[2]*gcov[2] - Gcov[2]*Gcov[2])/2;
vector<vec3d> hu33E(neln);
vector<vec3d> hw33E(neln);
el.shape_fnc(M, r, s);
for (int i=0; i<neln; ++i) {
NN(i,0) = Nut = M[i]/2;
NN(i,1) = Nwt = -M[i]/2;
hu33E[i] = gcov[2]*Nut;
hw33E[i] = gcov[2]*Nwt;
}
// point F
r = 1; s = -1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E33F = (gcov[2]*gcov[2] - Gcov[2]*Gcov[2])/2;
vector<vec3d> hu33F(neln);
vector<vec3d> hw33F(neln);
el.shape_fnc(M, r, s);
for (int i=0; i<neln; ++i) {
NN(i,2) = Nut = M[i]/2;
NN(i,3) = Nwt = -M[i]/2;
hu33F[i] = gcov[2]*Nut;
hw33F[i] = gcov[2]*Nwt;
}
// point G
r = 1; s = 1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E33G = (gcov[2]*gcov[2] - Gcov[2]*Gcov[2])/2;
vector<vec3d> hu33G(neln);
vector<vec3d> hw33G(neln);
el.shape_fnc(M, r, s);
for (int i=0; i<neln; ++i) {
NN(i,4) = Nut = M[i]/2;
NN(i,5) = Nwt = -M[i]/2;
hu33G[i] = gcov[2]*Nut;
hw33G[i] = gcov[2]*Nwt;
}
// point H
r = -1; s = 1; t = 0;
CoBaseVectors(el, r, s, t, gcov, tp.alphaf);
CoBaseVectors0(el, r, s, t, Gcov);
double E33H = (gcov[2]*gcov[2] - Gcov[2]*Gcov[2])/2;
vector<vec3d> hu33H(neln);
vector<vec3d> hw33H(neln);
el.shape_fnc(M, r, s);
for (int i=0; i<neln; ++i) {
NN(i,6) = Nut = M[i]/2;
NN(i,7) = Nwt = -M[i]/2;
hu33H[i] = gcov[2]*Nut;
hw33H[i] = gcov[2]*Nwt;
}
// return the results in aggregated format
E.resize(8);
E[0] = E13A; E[1] = E23B; E[2] = E13C; E[3] = E23D;
E[4] = E33E; E[5] = E33F; E[6] = E33G; E[7] = E33H;
HU.resize(8,vector<vec3d>(neln)); HW.resize(8,vector<vec3d>(neln));
for (int i=0; i<neln; ++i) {
HU[0] = hu13A; HU[1] = hu23B; HU[2] = hu13C; HU[3] = hu23D;
HU[4] = hu33E; HU[5] = hu33F; HU[6] = hu33G; HU[7] = hu33H;
HW[0] = hw13A; HW[1] = hw23B; HW[2] = hw13C; HW[3] = hw23D;
HW[4] = hw33E; HW[5] = hw33F; HW[6] = hw33G; HW[7] = hw33H;
}
}
}
//-----------------------------------------------------------------------------
//! Evaluate assumed natural strain (ANS)
void FEElasticEASShellDomain::EvaluateANS(FEShellElementNew& el, const int n, const vec3d* Gcnt,
mat3ds& Ec, vector<matrix>& hu, vector<matrix>& hw,
vector<double>& E, vector< vector<vec3d>>& HU, vector< vector<vec3d>>& HW)
{
// ANS method for 4-node quadrilaterials
if (el.Nodes() == 4) {
vec3d Gcov[3];
int neln = el.Nodes();
double E13A = E[0]; double E23B = E[1];
double E13C = E[2]; double E23D = E[3];
double E33E = E[4]; double E33F = E[5];
double E33G = E[6]; double E33H = E[7];
vector<vec3d> hu13A(HU[0]); vector<vec3d> hu23B(HU[1]);
vector<vec3d> hu13C(HU[2]); vector<vec3d> hu23D(HU[3]);
vector<vec3d> hu33E(HU[4]); vector<vec3d> hu33F(HU[5]);
vector<vec3d> hu33G(HU[6]); vector<vec3d> hu33H(HU[7]);
vector<vec3d> hw13A(HW[0]); vector<vec3d> hw23B(HW[1]);
vector<vec3d> hw13C(HW[2]); vector<vec3d> hw23D(HW[3]);
vector<vec3d> hw33E(HW[4]); vector<vec3d> hw33F(HW[5]);
vector<vec3d> hw33G(HW[6]); vector<vec3d> hw33H(HW[7]);
// Evaluate ANS strains
double r = el.gr(n);
double s = el.gs(n);
double E13ANS = ((1-s)*E13A + (1+s)*E13C)/2;
double E23ANS = ((1-r)*E23D + (1+r)*E23B)/2;
double E33ANS = ((1-r)*(1-s)*E33E + (1+r)*(1-s)*E33F +
(1+r)*(1+s)*E33G + (1-r)*(1+s)*E33H)/4;
vector<vec3d> hu13ANS(neln), hu23ANS(neln), hu33ANS(neln);
vector<vec3d> hw13ANS(neln), hw23ANS(neln), hw33ANS(neln);
for (int i=0; i<neln; ++i) {
hu13ANS[i] = (hu13A[i]*(1-s) + hu13C[i]*(1+s))/2;
hw13ANS[i] = (hw13A[i]*(1-s) + hw13C[i]*(1+s))/2;
hu23ANS[i] = (hu23D[i]*(1-r) + hu23B[i]*(1+r))/2;
hw23ANS[i] = (hw23D[i]*(1-r) + hw23B[i]*(1+r))/2;
hu33ANS[i] = (hu33E[i]*(1-r)*(1-s) + hu33F[i]*(1+r)*(1-s) +
hu33G[i]*(1+r)*(1+s) + hu33H[i]*(1-r)*(1+s))/4;
hw33ANS[i] = (hw33E[i]*(1-r)*(1-s) + hw33F[i]*(1+r)*(1-s) +
hw33G[i]*(1+r)*(1+s) + hw33H[i]*(1-r)*(1+s))/4;
}
// Substitute these strain components into Ec
CoBaseVectors0(el, n, Gcov);
double E11c = Gcov[0]*(Ec*Gcov[0]);
double E22c = Gcov[1]*(Ec*Gcov[1]);
double E12c = Gcov[0]*(Ec*Gcov[1]);
Ec = ((Gcnt[0] & Gcnt[0])*E11c + (Gcnt[1] & Gcnt[1])*E22c + (Gcnt[2] & Gcnt[2])*E33ANS +
((Gcnt[0] & Gcnt[1]) + (Gcnt[1] & Gcnt[0]))*E12c +
((Gcnt[1] & Gcnt[2]) + (Gcnt[2] & Gcnt[1]))*E23ANS +
((Gcnt[2] & Gcnt[0]) + (Gcnt[0] & Gcnt[2]))*E13ANS).sym();
for (int i=0; i<neln; ++i) {
hu[i](0,5) = hu13ANS[i].x; hu[i](1,5) = hu13ANS[i].y; hu[i](2,5) = hu13ANS[i].z;
hw[i](0,5) = hw13ANS[i].x; hw[i](1,5) = hw13ANS[i].y; hw[i](2,5) = hw13ANS[i].z;
hu[i](0,4) = hu23ANS[i].x; hu[i](1,4) = hu23ANS[i].y; hu[i](2,4) = hu23ANS[i].z;
hw[i](0,4) = hw23ANS[i].x; hw[i](1,4) = hw23ANS[i].y; hw[i](2,4) = hw23ANS[i].z;
hu[i](0,2) = hu33ANS[i].x; hu[i](1,2) = hu33ANS[i].y; hu[i](2,2) = hu33ANS[i].z;
hw[i](0,2) = hw33ANS[i].x; hw[i](1,2) = hw33ANS[i].y; hw[i](2,2) = hw33ANS[i].z;
}
}
}
//-----------------------------------------------------------------------------
//! Evaluate strain E and matrix hu and hw
void FEElasticEASShellDomain::EvaluateEh(FEShellElementNew& el, const int n, const vec3d* Gcnt, mat3ds& E,
vector<matrix>& hu, vector<matrix>& hw, vector<vec3d>& Nu, vector<vec3d>& Nw)
{
FETimeInfo& tp = GetFEModel()->GetTime();
const double* Mr, *Ms, *M;
vec3d gcov[3];
int neln = el.Nodes();
FEMaterialPoint& mp = *(el.GetMaterialPoint(n));
FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>());
E = pt.Strain();
CoBaseVectors(el, n, gcov, tp.alphaf);
double eta = el.gt(n);
Mr = el.Hr(n);
Ms = el.Hs(n);
M = el.H(n);
for (int i=0; i<neln; ++i)
{
double Nur = Nu[i].x = (1+eta)/2*Mr[i];
double Nus = Nu[i].y = (1+eta)/2*Ms[i];
double Nut = Nu[i].z = M[i]/2;
double Nwr = Nw[i].x = (1-eta)/2*Mr[i];
double Nws = Nw[i].y = (1-eta)/2*Ms[i];
double Nwt = Nw[i].z = -M[i]/2;
hu[i](0,0) = Nur*gcov[0].x; hu[i](1,0) = Nur*gcov[0].y; hu[i](2,0) = Nur*gcov[0].z;
hu[i](0,1) = Nus*gcov[1].x; hu[i](1,1) = Nus*gcov[1].y; hu[i](2,1) = Nus*gcov[1].z;
hu[i](0,2) = Nut*gcov[2].x; hu[i](1,2) = Nut*gcov[2].y; hu[i](2,2) = Nut*gcov[2].z;
hu[i](0,3) = Nur*gcov[1].x + Nus*gcov[0].x; hu[i](1,3) = Nur*gcov[1].y + Nus*gcov[0].y; hu[i](2,3) = Nur*gcov[1].z + Nus*gcov[0].z;
hu[i](0,4) = Nus*gcov[2].x + Nut*gcov[1].x; hu[i](1,4) = Nus*gcov[2].y + Nut*gcov[1].y; hu[i](2,4) = Nus*gcov[2].z + Nut*gcov[1].z;
hu[i](0,5) = Nut*gcov[0].x + Nur*gcov[2].x; hu[i](1,5) = Nut*gcov[0].y + Nur*gcov[2].y; hu[i](2,5) = Nut*gcov[0].z + Nur*gcov[2].z;
hw[i](0,0) = Nwr*gcov[0].x; hw[i](1,0) = Nwr*gcov[0].y; hw[i](2,0) = Nwr*gcov[0].z;
hw[i](0,1) = Nws*gcov[1].x; hw[i](1,1) = Nws*gcov[1].y; hw[i](2,1) = Nws*gcov[1].z;
hw[i](0,2) = Nwt*gcov[2].x; hw[i](1,2) = Nwt*gcov[2].y; hw[i](2,2) = Nwt*gcov[2].z;
hw[i](0,3) = Nwr*gcov[1].x + Nws*gcov[0].x; hw[i](1,3) = Nwr*gcov[1].y + Nws*gcov[0].y; hw[i](2,3) = Nwr*gcov[1].z + Nws*gcov[0].z;
hw[i](0,4) = Nws*gcov[2].x + Nwt*gcov[1].x; hw[i](1,4) = Nws*gcov[2].y + Nwt*gcov[1].y; hw[i](2,4) = Nws*gcov[2].z + Nwt*gcov[1].z;
hw[i](0,5) = Nwt*gcov[0].x + Nwr*gcov[2].x; hw[i](1,5) = Nwt*gcov[0].y + Nwr*gcov[2].y; hw[i](2,5) = Nwt*gcov[0].z + Nwr*gcov[2].z;
}
}
| C++ |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledElasticMixture.h | .h | 3,405 | 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.*/
#pragma once
#include "FEUncoupledMaterial.h"
#include "FEElasticMixture.h"
//-----------------------------------------------------------------------------
//! Uncoupled elastic mixtures
//! This class describes a mixture of uncoupled elastic solids. The user must declare
//! uncoupled elastic solids that can be combined within this class. The stress and
//! tangent tensors evaluated in this class represent the sum of the respective
//! tensors of all the solids forming the mixture.
//! \todo This class defines two accessor interfaces. Modify to use the FEMaterial interface only.
class FEUncoupledElasticMixture : public FEUncoupledMaterial
{
public:
FEUncoupledElasticMixture(FEModel* pfem);
// returns a pointer to a new material point object
FEMaterialPointData* CreateMaterialPointData() override;
// return number of materials
int Materials() { return (int)m_pMat.size(); }
// return a material component
FEElasticMaterial* GetMaterial(int i) { return m_pMat[i]; }
// Add a material component
void AddMaterial(FEElasticMaterial* pm);
//! specialized material points
void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override;
public:
//! data initialization
bool Init() override;
//! calculate stress at material point
mat3ds DevStress(FEMaterialPoint& pt) override;
//! calculate tangent stiffness at material point
tens4ds DevTangent(FEMaterialPoint& pt) override;
//! calculate strain energy density at material point
double DevStrainEnergyDensity(FEMaterialPoint& pt) override;
public:
double StrongBondDevSED(FEMaterialPoint& pt) override;
double WeakBondDevSED(FEMaterialPoint& pt) override;
private:
// TODO: temporarily reverted back to uncoupled materials. This was needed to make sure that
// FEBio Studio displays the uncoupled materials as options.
// Need to figure out a way to allow elastic materials again.
std::vector<FEUncoupledMaterial*> m_pMat; //!< pointers to elastic materials
// std::vector<FEElasticMaterial*> m_pMat; //!< pointers to elastic materials
DECLARE_FECORE_CLASS();
};
| Unknown |
3D | febiosoftware/FEBio | FEBioMech/FEUncoupledActiveFiberContraction.h | .h | 2,220 | 55 | /*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "FEActiveContractionMaterial.h"
//! A material class describing the active fiber contraction for use in uncoupled materials
class FEUncoupledActiveFiberContraction : public FEActiveContractionMaterial
{
public:
FEUncoupledActiveFiberContraction(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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.