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/FEDistanceConstraint.h
.h
2,641
72
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FENLConstraint.h> #include <FECore/FEDofList.h> //----------------------------------------------------------------------------- // This class implements a constraint that enforces the distance between two nodes class FEDistanceConstraint : public FENLConstraint { public: //! constructor FEDistanceConstraint(FEModel* pfem); bool Init() override; void Activate() override; void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override; void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override; bool Augment(int naug, const FETimeInfo& tp) override; void Serialize(DumpStream& ar) override; //! build connectivity for matrix profile void BuildMatrixProfile(FEGlobalMatrix& M) override; // update state void Reset() override; public: double m_eps; //!< penalty parameter double m_atol; //!< augmented Lagrangian tolerance bool m_blaugon; //!< augmentation flag int m_nodeID[2]; //!< the IDs of the two nodes that are connected int m_nminaug; //!< min number of augmentations int m_nmaxaug; //!< max number of augmentations double m_target; //!< target distance bool m_brelative; //!< relative to initial distance? double m_l0; //!< reference length double m_Lm; //!< Lagrange multiplier int m_node[2]; //!< nodal indices into mesh FEDofList m_dofU; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEElasticShellDomain.h
.h
4,783
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 "FESSIShellDomain.h" #include "FEElasticDomain.h" #include "FESolidMaterial.h" #include "febiomech_api.h" //----------------------------------------------------------------------------- //! Domain described by 3D shell elements class FEBIOMECH_API FEElasticShellDomain : public FESSIShellDomain, public FEElasticDomain { public: FEElasticShellDomain(FEModel* pfem); //! \todo do I really need this? FEElasticShellDomain& operator = (FEElasticShellDomain& d); //! Activate the domain void Activate() override; //! initialize elements void PreSolveUpdate(const FETimeInfo& timeInfo) override; //! Unpack shell element data void UnpackLM(FEElement& el, vector<int>& lm) override; //! Set flag for update for dynamic quantities void SetDynamicUpdateFlag(bool b); //! serialization void Serialize(DumpStream& ar) override; //! get the material (overridden from FEDomain) FEMaterial* GetMaterial() override { return m_pMat; } //! set the material void SetMaterial(FEMaterial* pmat) override; //! get the total dofs const FEDofList& GetDOFList() const override; public: // overrides from FEElasticDomain //! calculates the residual // void Residual(FESolver* psolver, vector<double>& R); //! internal stress forces void InternalForces(FEGlobalVector& R) override; //! Calculates inertial forces for dynamic problems void InertialForces(FEGlobalVector& R, vector<double>& F) override; //! calculate body force void BodyForce(FEGlobalVector& R, FEBodyForce& bf) override; // update stresses void Update(const FETimeInfo& tp) override; // update the element stress void UpdateElementStress(int iel, const FETimeInfo& tp); //! calculates the global stiffness matrix for this domain void StiffnessMatrix(FELinearSystem& LS) override; // inertial stiffness void MassMatrix(FELinearSystem& LS, double scale) override; // body force stiffness void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override; public: // --- S T I F F N E S S --- //! calculates the shell element stiffness matrix void ElementStiffness(int iel, matrix& ke); //! calculates the solid element mass matrix void ElementMassMatrix(FEShellElement& el, matrix& ke, double a); //! calculates the stiffness matrix due to body forces void ElementBodyForceStiffness(FEBodyForce& bf, FEShellElement& el, matrix& ke); // --- R E S I D U A L --- //! Calculates the internal stress vector for shell elements void ElementInternalForce(FEShellElement& el, vector<double>& fe); //! Calculate extenral body forces for shell elements void ElementBodyForce(FEModel& fem, FEShellElement& el, vector<double>& fe); //! Calculate extenral body forces for shell elements void ElementBodyForce(FEBodyForce& BF, FEShellElement& el, vector<double>& fe); //! Calculates the inertial force for shell elements void ElementInertialForce(FEShellElement& el, vector<double>& fe); protected: FESolidMaterial* m_pMat; double m_alphaf; double m_alpham; double m_beta; bool m_update_dynamic; //!< flag for updating quantities only used in dynamic analysis bool m_secant_stress; //!< use secant approximation to stress bool m_secant_tangent; //!< flag for using secant tangent protected: FEDofList m_dofV; FEDofList m_dofSV; FEDofList m_dofSA; FEDofList m_dofR; FEDofList m_dof; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEDiscreteElasticMaterial.h
.h
2,875
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 <FECore/FEDiscreteMaterial.h> #include "febiomech_api.h" class FEBIOMECH_API FEDiscreteElasticMaterialPoint : public FEDiscreteMaterialPoint { public: FEMaterialPointData* Copy() override; public: vec3d m_Ft; // current force }; //----------------------------------------------------------------------------- //! material class for discrete elements class FEBIOMECH_API FEDiscreteElasticMaterial : public FEDiscreteMaterial { public: FEDiscreteElasticMaterial(FEModel* pfem); FEMaterialPointData* CreateMaterialPointData() override; // evaluate the force at a discrete element virtual vec3d Force(FEDiscreteMaterialPoint& mp) = 0; // evaluate the stiffness at a discrete element (= dF / dr) virtual mat3d Stiffness(FEDiscreteMaterialPoint& mp) = 0; // evaluate the strain energy at a discrete element virtual double StrainEnergy(FEDiscreteMaterialPoint& mp) {return 0.0;} }; //----------------------------------------------------------------------------- //! composite material class for discrete elements class FEBIOMECH_API FECompositeDiscreteMaterial : public FEDiscreteElasticMaterial { public: FECompositeDiscreteMaterial(FEModel* pfem); // 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 strain energy at a discrete element double StrainEnergy(FEDiscreteMaterialPoint& mp) override; private: std::vector<FEDiscreteElasticMaterial*> m_mats; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FECoupledVerondaWestmann.h
.h
2,115
57
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticMaterial.h" //----------------------------------------------------------------------------- //! This material describes a coupled Veronda-Westmann formulation class FECoupledVerondaWestmann : public FEElasticMaterial { public: //! constructor FECoupledVerondaWestmann(FEModel* pfem) : FEElasticMaterial(pfem){} public: //! calculate stress at material point mat3ds Stress(FEMaterialPoint& pt) override; //! calculate tangent at material point tens4ds Tangent(FEMaterialPoint& pt) override; //! calculate strain energy density at material point double StrainEnergyDensity(FEMaterialPoint& pt) override; protected: double m_c1; //!< Veronda-Westmann material parameter c1 double m_c2; //!< Veronda-Westmann material parameter c2 double m_k; //!< bulk-modulus DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEFiberExpPow.h
.h
3,668
109
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticFiberMaterial.h" #include "FEFiberMaterial.h" class FEElasticFiberExpPow; //----------------------------------------------------------------------------- //! Material class for single fiber, tension only //! Exponential-power law class FEFiberExpPow : public FEFiberMaterial { public: FEFiberExpPow(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; protected: FEParamDouble m_alpha; // coefficient of (In-I0) in exponential FEParamDouble m_beta; // power of (In-I0) in exponential FEParamDouble m_ksi; // fiber modulus FEParamDouble m_mu; // shear modulus FEParamDouble m_lam0; // stretch threshold for tensile response double m_epsf; // declare the parameter list DECLARE_FECORE_CLASS(); friend class FEElasticFiberExpPow; }; //----------------------------------------------------------------------------- class FEElasticFiberExpPow : public FEElasticFiberMaterial_T<FEFiberExpPow> { public: FEElasticFiberExpPow(FEModel* fem) : FEElasticFiberMaterial_T<FEFiberExpPow>(fem) {} DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- //! Exponential-power law //! (Variation that includes a shear term) //! TODO: I want to delete one of these two formulations. class FEFiberExponentialPower : public FEElasticFiberMaterial { public: FEFiberExponentialPower(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_alpha; // coefficient of (In-I0) in exponential FEParamDouble m_beta; // power of (In-I0) in exponential FEParamDouble m_ksi; // measure of fiber modulus FEParamDouble m_mu; // shear modulus FEParamDouble m_lam0; // stretch threshold for tensile response double m_epsf; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEPrescribedActiveContractionUniaxial.h
.h
2,814
82
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticMaterial.h" //----------------------------------------------------------------------------- // This material implements an active contraction model which can be used // as a component of a solid mixture material. class FEPrescribedActiveContractionUniaxial : public FEElasticMaterial { public: //! constructor FEPrescribedActiveContractionUniaxial(FEModel* pfem); //! validation bool Validate() override; //! serialization void Serialize(DumpStream& ar) override; //! stress mat3ds Stress(FEMaterialPoint& pt) override; //! tangent tens4ds Tangent(FEMaterialPoint& pt) override; public: FEParamDouble m_T0; // prescribed active stress private: vec3d m_n0; // unit vector along fiber direction (local coordinate system) DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- // This material implements an active contraction model which can be used // as a component of a solid mixture material. class FEPrescribedActiveContractionFiber : public FEElasticMaterial { public: //! constructor FEPrescribedActiveContractionFiber(FEModel* pfem); //! stress mat3ds Stress(FEMaterialPoint& pt) override; //! tangent tens4ds Tangent(FEMaterialPoint& pt) override; private: FEParamDouble m_T0; // prescribed active stress FEVec3dValuator* m_fiber; // unit vector along fiber direction (local coordinate system) DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEElasticMultigeneration.cpp
.cpp
13,270
433
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FECore/tens4d.h" #include "FECore/log.h" #include "FECore/FECoreKernel.h" #include "FEElasticMultigeneration.h" //============================================================================= FEGenerationBase::FEGenerationBase(FEModel* fem) : FEMaterialProperty(fem) { btime = 0; m_pMat = 0; } //----------------------------------------------------------------------------- FEMaterialPointData* FEGenerationBase::CreateMaterialPointData() { return m_pMat->CreateMaterialPointData(); } //----------------------------------------------------------------------------- //! calculate stress at material point mat3ds FEGenerationBase::Stress(FEMaterialPoint& pt) { return m_pMat->Stress(pt); } //----------------------------------------------------------------------------- //! calculate tangent stiffness at material point tens4ds FEGenerationBase::Tangent(FEMaterialPoint& pt) { return m_pMat->Tangent(pt); } //----------------------------------------------------------------------------- //! calculate strain energy density at material point double FEGenerationBase::StrainEnergyDensity(FEMaterialPoint& pt) { return m_pMat->StrainEnergyDensity(pt); } //============================================================================= // define the material parameters BEGIN_FECORE_CLASS(FEGenerationMaterial, FEGenerationBase) // material parameters ADD_PARAMETER(btime, "start_time"); // the solid property ADD_PROPERTY(m_pMat, "solid"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEGenerationMaterial::FEGenerationMaterial(FEModel* pfem) : FEGenerationBase(pfem) { } //============================================================================= FEMultigenerationMaterialPoint::FEMultigenerationMaterialPoint() : FEMaterialPointArray(new FEElasticMaterialPoint) { m_tgen = 0.0; m_ngen = 1; // the first generation is always active } //----------------------------------------------------------------------------- FEMaterialPointData* FEMultigenerationMaterialPoint::Copy() { FEMultigenerationMaterialPoint* pt = new FEMultigenerationMaterialPoint(*this); pt->m_mp = m_mp; pt->m_pmat = m_pmat; pt->m_tgen = m_tgen; if (m_pNext) pt->m_pNext = m_pNext->Copy(); return pt; } //----------------------------------------------------------------------------- void FEMultigenerationMaterialPoint::Serialize(DumpStream& ar) { FEMaterialPointArray::Serialize(ar); if (ar.IsShallow()) { ar & m_tgen & m_ngen; for (int i=0; i < (int)m_mp.size(); i++) m_mp[i]->Serialize(ar); // TODO: shallow copy m_pmat } else { if (ar.IsSaving()) { ar << m_tgen << m_ngen; ar << (int)m_mp.size(); for (int i=0; i < (int)m_mp.size(); i++) m_mp[i]->Serialize(ar); } else { ar >> m_tgen >> m_ngen; int mp_size; ar >> mp_size; m_mp.resize(mp_size); for (int i=0; i < mp_size; i++) { m_mp[i] = new FEMaterialPoint(new FEElasticMaterialPoint); m_mp[i]->Serialize(ar); } } } } //----------------------------------------------------------------------------- void FEMultigenerationMaterialPoint::Init() { FEMaterialPointArray::Init(); for (int i=0; i<(int)m_mp.size(); ++i) m_mp[i]->Init(); m_tgen = 0.0; m_ngen = 1; } //----------------------------------------------------------------------------- void FEMultigenerationMaterialPoint::Update(const FETimeInfo& timeInfo) { FEMaterialPointArray::Update(timeInfo); // get the time double t = timeInfo.currentTime; // Check if this constitutes a new generation int igen = m_pmat->CheckGeneration(t); t = m_pmat->m_MG[igen]->btime; if (t>m_tgen) { FEElasticMaterialPoint& pt = *((*this).ExtractData<FEElasticMaterialPoint>()); // push back F and J to define relative deformation gradient of this generation mat3d F = pt.m_F; double J = pt.m_J; FEElasticMaterialPoint& pe = *(m_mp[m_ngen]->ExtractData<FEElasticMaterialPoint>()); pe.m_F = F.inverse(); pe.m_J = 1.0/J; m_tgen = t; ++m_ngen; } } //============================================================================= BEGIN_FECORE_CLASS(FEElasticMultigeneration, FEElasticMaterial) ADD_PROPERTY(m_MG, "generation"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEElasticMultigeneration::FEElasticMultigeneration(FEModel* pfem) : FEElasticMaterial(pfem) { } //----------------------------------------------------------------------------- // returns a pointer to a new material point object FEMaterialPointData* FEElasticMultigeneration::CreateMaterialPointData() { // use the zero-th generation material point as the base elastic material point FEMultigenerationMaterialPoint* pt = new FEMultigenerationMaterialPoint(); pt->m_pmat = this; int NMAT = Materials(); for (int i=0; i<NMAT; ++i) pt->AddMaterialPoint(new FEMaterialPoint(m_MG[i]->CreateMaterialPointData())); return pt; } //-------------------------------------------------------------------------------- // Check if time t constitutes a new generation and return that generation int FEElasticMultigeneration::CheckGeneration(const double t) { int ngen = (int)m_MG.size(); for (int igen=1; igen<ngen; ++igen) { if (t < m_MG[igen]->btime) return igen - 1; } return ngen - 1; } //----------------------------------------------------------------------------- mat3ds FEElasticMultigeneration::Stress(FEMaterialPoint& mp) { FEMultigenerationMaterialPoint& pt = *mp.ExtractData<FEMultigenerationMaterialPoint>(); FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>(); mat3ds s; // calculate stress s.zero(); // extract deformation gradient mat3d Fs = ep.m_F; double Js = ep.m_J; for (int i=0; i < pt.m_ngen; ++i) { FEMaterialPoint& mpi = *pt.GetPointData(i); // evaluate deformation gradient for this generation FEElasticMaterialPoint& epi = *mpi.ExtractData<FEElasticMaterialPoint>(); // copy the material point data to the components mpi.m_elem = mp.m_elem; mpi.m_index = mp.m_index; mpi.m_rt = mp.m_rt; mpi.m_r0 = mp.m_r0; // store safe copies of Fi and Ji for this generation mat3d Fi = epi.m_F; double Ji = epi.m_J; // evaluate relative deformation gradient epi.m_F = Fs*Fi; epi.m_J = Js*Ji; // evaluate stress for this generation s += epi.m_s = m_MG[i]->Stress(mpi); // restore the material point deformation gradient epi.m_F = Fi; epi.m_J = Ji; } return s; } //----------------------------------------------------------------------------- tens4ds FEElasticMultigeneration::Tangent(FEMaterialPoint& mp) { FEMultigenerationMaterialPoint& pt = *mp.ExtractData<FEMultigenerationMaterialPoint>(); FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>(); tens4ds c(0.); // extract deformation gradient mat3d Fs = ep.m_F; double Js = ep.m_J; for (int i=0; i < pt.m_ngen; ++i) { FEMaterialPoint& mpi = *pt.GetPointData(i); // evaluate deformation gradient for this generation FEElasticMaterialPoint& epi = *mpi.ExtractData<FEElasticMaterialPoint>(); // store safe copies of Fi and Ji for this generation mat3d Fi = epi.m_F; double Ji = epi.m_J; // copy the elastic material point data to the components mpi.m_elem = mp.m_elem; mpi.m_index = mp.m_index; mpi.m_rt = mp.m_rt; mpi.m_r0 = mp.m_r0; // evaluate relative deformation gradient epi.m_F = Fs*Fi; epi.m_J = Js*Ji; // evaluate tangent for this generation c += m_MG[i]->Tangent(mpi); // restore the material point deformation gradient epi.m_F = Fi; epi.m_J = Ji; } return c; } //----------------------------------------------------------------------------- double FEElasticMultigeneration::StrainEnergyDensity(FEMaterialPoint& mp) { FEMultigenerationMaterialPoint& pt = *mp.ExtractData<FEMultigenerationMaterialPoint>(); FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>(); double sed = 0.0; // extract deformation gradient mat3d Fs = ep.m_F; double Js = ep.m_J; for (int i=0; i < pt.m_ngen; ++i) { FEMaterialPoint& mpi = *pt.GetPointData(i); // evaluate deformation gradient for this generation FEElasticMaterialPoint& epi = *mpi.ExtractData<FEElasticMaterialPoint>(); // store safe copies of Fi and Ji for this generation mat3d Fi = epi.m_F; double Ji = epi.m_J; // copy the elastic material point data to the components mpi.m_elem = mp.m_elem; mpi.m_index = mp.m_index; mpi.m_rt = mp.m_rt; mpi.m_r0 = mp.m_r0; // evaluate relative deformation gradient epi.m_F = Fs*Fi; epi.m_J = Js*Ji; // evaluate strain energy density for this generation double dsed = m_MG[i]->StrainEnergyDensity(mpi)/Ji; sed += dsed; // restore the material point deformation gradient epi.m_F = Fi; epi.m_J = Ji; } return sed; } //----------------------------------------------------------------------------- double FEElasticMultigeneration::StrongBondSED(FEMaterialPoint& mp) { FEMultigenerationMaterialPoint& pt = *mp.ExtractData<FEMultigenerationMaterialPoint>(); FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>(); double sed = 0.0; // extract deformation gradient mat3d Fs = ep.m_F; double Js = ep.m_J; for (int i=0; i < pt.m_ngen; ++i) { FEMaterialPoint& mpi = *pt.GetPointData(i); // evaluate deformation gradient for this generation FEElasticMaterialPoint& epi = *mpi.ExtractData<FEElasticMaterialPoint>(); // store safe copies of Fi and Ji for this generation mat3d Fi = epi.m_F; double Ji = epi.m_J; // copy the elastic material point data to the components mpi.m_elem = mp.m_elem; mpi.m_index = mp.m_index; mpi.m_rt = mp.m_rt; mpi.m_r0 = mp.m_r0; // evaluate relative deformation gradient epi.m_F = Fs*Fi; epi.m_J = Js*Ji; // evaluate strain energy density for this generation double dsed = m_MG[i]->m_pMat->StrongBondSED(mpi)/Ji; sed += dsed; // restore the material point deformation gradient epi.m_F = Fi; epi.m_J = Ji; } return sed; } //----------------------------------------------------------------------------- double FEElasticMultigeneration::WeakBondSED(FEMaterialPoint& mp) { FEMultigenerationMaterialPoint& pt = *mp.ExtractData<FEMultigenerationMaterialPoint>(); FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>(); double sed = 0.0; // extract deformation gradient mat3d Fs = ep.m_F; double Js = ep.m_J; for (int i=0; i < pt.m_ngen; ++i) { FEMaterialPoint& mpi = *pt.GetPointData(i); // evaluate deformation gradient for this generation FEElasticMaterialPoint& epi = *mpi.ExtractData<FEElasticMaterialPoint>(); // store safe copies of Fi and Ji for this generation mat3d Fi = epi.m_F; double Ji = epi.m_J; // copy the elastic material point data to the components mpi.m_elem = mp.m_elem; mpi.m_index = mp.m_index; mpi.m_rt = mp.m_rt; mpi.m_r0 = mp.m_r0; // evaluate relative deformation gradient epi.m_F = Fs*Fi; epi.m_J = Js*Ji; // evaluate strain energy density for this generation double dsed = m_MG[i]->m_pMat->WeakBondSED(mpi)/Ji; sed += dsed; // restore the material point deformation gradient epi.m_F = Fi; epi.m_J = Ji; } return sed; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEDonnanEquilibrium.h
.h
3,990
110
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticMaterial.h" #include <FECore/FEMaterialPoint.h> //----------------------------------------------------------------------------- // Define a material point that stores the Donnan equilibrium variables. class FEDonnanEquilibriumMaterialPoint : public FEMaterialPointData { public: FEDonnanEquilibriumMaterialPoint(FEMaterialPointData*pt) : FEMaterialPointData(pt) {} FEMaterialPointData* Copy(); void Init(); void Serialize(DumpStream& ar); public: double m_cFr; //!< referential fixed-charge density double m_cF; //!< fixed-charge density double m_osm; //!< osmolarity double m_p; //!< osmotic pressure double m_bpi; //!< osmotic pressure tangent }; //----------------------------------------------------------------------------- //! Material class that implements Donnan equilibrium. //! When used on its own (not in a solid mixture), this materials //! is intrinsically unstable class FEDonnanEquilibrium : public FEElasticMaterial { public: // constructor FEDonnanEquilibrium(FEModel* pfem); //! Initialization routine bool Init() override; void Serialize(DumpStream& ar) override; //! Returns the Cauchy stress mat3ds Stress(FEMaterialPoint& mp) override; //! Returs the spatial tangent tens4ds Tangent(FEMaterialPoint& mp) override; //! Return the fixed-charge density double FixedChargeDensity(FEMaterialPoint& mp); //! Return the osmotic pressure double OsmoticPressure(FEMaterialPoint& mp); //! Return the osmotic pressure tangent double OsmoticPressureTangent(FEMaterialPoint& mp); //! Return the osmolarity double Osmolarity(FEMaterialPoint& mp); // returns a pointer to a new material point object FEMaterialPointData* CreateMaterialPointData() override { return new FEDonnanEquilibriumMaterialPoint(new FEElasticMaterialPoint); } // update fatigue material point at each iteration void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override; // declare the parameter list DECLARE_FECORE_CLASS(); public: double m_phiwr; //!< fluid volume fraction in reference configuration double m_phisr; //!< referential solid volume fraction (may evolve with time) FEParamDouble m_cFr; //!< fixed charge density in reference configuration double m_Rgas; //!< universal gas constant double m_Tabs; //!< absolute temperature double m_bosm; //!< bath osmolarity double m_Phi; //!< osmotic coefficient bool m_bnew; //!< flag for using old or new method bool m_binit; //!< initialization flag };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEVerondaWestmann.cpp
.cpp
4,826
164
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEVerondaWestmann.h" //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEVerondaWestmann, FEUncoupledMaterial) ADD_PARAMETER(m_c1, FE_RANGE_GREATER(0.0), "c1")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_c2, FE_RANGE_GREATER(0.0), "c2")->setUnits(UNIT_NONE); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Calculate deviatoric stress mat3ds FEVerondaWestmann::DevStress(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient and its determinant mat3d &F = pt.m_F; double J = pt.m_J; // calculate deviatoric left Cauchy-Green tensor mat3ds B = pt.DevLeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // material parameters double c1 = m_c1(mp); double c2 = m_c2(mp); // Invariants of B (= invariants of C) // Note that these are the invariants of Btilde, not of B! double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); // --- TODO: put strain energy derivatives here --- // // W = C1*(exp(C2*(I1-3)-1)-0.5*C1*C2*(I2 - 3) // // Wi = dW/dIi double W1 = c1*c2*exp(c2*(I1-3)); double W2 = -0.5*c1*c2; // --- // calculate T = F*dW/dC*Ft mat3ds T = B*(W1 + W2*I1) - B2*W2; return T.dev()*(2.0/J); } //----------------------------------------------------------------------------- //! Calculate deviatoric tangent tens4ds FEVerondaWestmann::DevTangent(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient mat3d &F = pt.m_F; double J = pt.m_J; double Ji = 1.0/J; // calculate deviatoric left Cauchy-Green tensor: B = F*Ft mat3ds B = pt.DevLeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // Invariants of B (= invariants of C) double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); // material parameters double c1 = m_c1(mp); double c2 = m_c2(mp); // --- TODO: put strain energy derivatives here --- // Wi = dW/dIi double W1, W2, W11; W1 = c1*c2*exp(c2*(I1-3)); W2 = -0.5*c1*c2; W11 = c2*W1; // --- // calculate dWdC:C double WC = W1*I1 + 2*W2*I2; // calculate C:d2WdCdC:C double CWWC = W11*I1*I1+2*I2*W2; // deviatoric cauchy-stress, trs = trace[s]/3 mat3ds T = B * (W1 + W2 * I1) - B2 * W2; mat3ds devs = T.dev() * (2.0 / J); mat3ds I(1,1,1,0,0,0); // Identity tens4ds IxI = dyad1s(I); tens4ds I4 = dyad4s(I); tens4ds BxB = dyad1s(B); tens4ds B4 = dyad4s(B); // d2W/dCdC:C mat3ds WCCxC = B*(I1*(W11 + W2)) - B2*W2; tens4ds cw = BxB*((W11 + W2)*4.0*Ji) - B4*(W2*4.0*Ji) - dyad1s(WCCxC, I)*(4.0/3.0*Ji) + IxI*(4.0/9.0*Ji*CWWC); tens4ds c = dyad1s(devs, I)*(-2.0/3.0) + (I4 - IxI/3.0)*(4.0/3.0*Ji*WC) + cw; return c; } //----------------------------------------------------------------------------- //! calculate strain energy density at material point double FEVerondaWestmann::DevStrainEnergyDensity(FEMaterialPoint& mp) { // get the elastic material point data FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // calculate left Cauchy-Green tensor mat3ds B = pt.DevLeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // material parameters double c1 = m_c1(mp); double c2 = m_c2(mp); // Invariants of B (= invariants of C) double I1 = B.tr(); double I2 = (I1*I1 - B2.tr())/2.0; double sed = c1*(exp(c2*(I1-3))-1) - c1*c2*(I2-3)/2; return sed; }
C++
3D
febiosoftware/FEBio
FEBioMech/FERigidConnector.h
.h
3,151
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.*/ #pragma once #include <FECore/FENLConstraint.h> #include "febiomech_api.h" //----------------------------------------------------------------------------- class FERigidBody; //----------------------------------------------------------------------------- //! This is a virtual class for all rigid connectors, including //! spherical, revolute, prismatic and cylindrical joints, as well //! as springs and dampers that connect rigid bodies. class FEBIOMECH_API FERigidConnector : public FENLConstraint { FECORE_BASE_CLASS(FERigidConnector) public: //! constructor FERigidConnector(FEModel* pfem); //! destructor virtual ~FERigidConnector(); //! initialization bool Init() override; int GetConnectorID() { return m_nID; } //! build connectivity for matrix profile void BuildMatrixProfile(FEGlobalMatrix& M) override; //! serialization void Serialize(DumpStream& ar) override; //! evaluate relative translation virtual vec3d RelativeTranslation(const bool global = false) { return vec3d(0,0,0); } //! evaluate relative rotation virtual vec3d RelativeRotation(const bool global = false) { return vec3d(0,0,0); } public: int m_nRBa; //!< rigid body A that the connector connects int m_nRBb; //!< rigid body B that the connector connects vec3d m_F; //! constraining force vec3d m_M; //! constraining moment protected: int m_nID; //!< ID of rigid connector bool m_binit; //!< initialization flag FERigidBody* m_rbA; FERigidBody* m_rbB; static int m_ncount; //!< used to create unique ID's for the nonlinear constraints public: // return the helical axis of Body b relative to Body a void InstantaneousHelicalAxis(vec3d& omega, vec3d& s, double& tdot); void FiniteHelicalAxis(vec3d& omega, vec3d& s, double& tdot); DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEODFFiberDistribution.h
.h
3,581
122
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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/FECoreClass.h> #include "FEElasticMaterial.h" #include "FEFiberMaterial.h" #include "FEFiberDensityDistribution.h" #include "FEFiberIntegrationScheme.h" #include "FEFiberMaterialPoint.h" #include <unordered_map> class FEODFFiberDistribution; class FEBaseODF { public: FEBaseODF() : m_pos(0,0,0) {} virtual ~FEBaseODF() {} public: vec3d m_pos; //!< position std::vector<double> m_ODF; //!< ODF values std::vector<vec3d> m_nodePos; //!< node positions }; class FEFiberODF : public FECoreClass, public FEBaseODF { public: FEFiberODF(FEModel* fem) : FECoreClass(fem) {} public: std::vector<double> m_shpHar; //!< spherical harmonics Values DECLARE_FECORE_CLASS(); FECORE_BASE_CLASS(FEFiberODF); }; class FEElementODF : public FEBaseODF { public: FEElementODF(int weightsSize) : m_weights(weightsSize) {} void calcODF(std::vector<std::vector<double>>& ODFs); public: std::vector<double> m_weights; //!< weights for interpolation }; class FEODFFiberDistribution : public FEElasticMaterial { public: FEODFFiberDistribution(FEModel* pfem); ~FEODFFiberDistribution(); // 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; protected: FEFiberMaterial* m_pFmat; // pointer to fiber material std::vector<FEFiberODF*> m_ODF; // ODF objects std::unordered_map<int, FEElementODF*> m_ElODF; // element ODF objects DECLARE_FECORE_CLASS(); private: void reduceODF(FEBaseODF* ODF, matrix& B, double* time); private: bool m_interpolate; // whether or not we're interpolating at each element int m_order; // Spherical Harmonic Order std::unique_ptr<matrix> m_T; std::vector<double> m_theta; std::vector<double> m_phi; double m_lengthScale; double m_hausd; double m_grad; };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FERigidSpring.h
.h
3,125
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/vec3d.h" #include "FERigidConnector.h" //----------------------------------------------------------------------------- //! The FERigidSpring class implements a linear spring that connects //! two rigid bodies at arbitrary points (not necessarily nodes). class FERigidSpring : public FERigidConnector { public: //! constructor FERigidSpring(FEModel* pfem); //! destructor ~FERigidSpring() {} //! initialization bool Init() override; //! calculates the joint forces void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override; //! calculates the joint stiffness void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override; //! calculate Lagrangian augmentation bool Augment(int naug, const FETimeInfo& tp) override; //! serialize data to archive void Serialize(DumpStream& ar) override; //! update state void Update() override; //! Reset data void Reset() override; //! evaluate relative translation vec3d RelativeTranslation(const bool global) override; //! evaluate relative rotation vec3d RelativeRotation(const bool global) override; public: // parameters vec3d m_a0; //! initial absolute position vector of spring on body A vec3d m_b0; //! initial absolute position vector of spring on body B double m_k; //! spring constant // output parameters vec3d m_at; //!< current absolute position of spring on body A vec3d m_bt; //!< current absolute position of spring on body B protected: double m_L0; //! spring free length vec3d m_qa0; //! initial relative position vector of spring on body A vec3d m_qb0; //! initial relative position vector of spring on body B DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEDeformableSpringDomain.cpp
.cpp
22,148
906
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEDeformableSpringDomain.h" #include <FECore/FEModel.h> #include <FECore/FEGlobalMatrix.h> #include <FECore/FELinearSystem.h> #include "FEBioMech.h" BEGIN_FECORE_CLASS(FEDeformableSpringDomain, FEDiscreteDomain) ADD_PARAMETER(m_kbend, "k_bend"); ADD_PARAMETER(m_kstab, "k_stab"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEDeformableSpringDomain::FEDeformableSpringDomain(FEModel* pfem) : FEDiscreteDomain(pfem), FEElasticDomain(pfem), m_dofU(pfem), m_dofR(pfem), m_dof(pfem) { m_pMat = 0; m_kbend = 0.0; m_kstab = 0.0; // 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)); } } //----------------------------------------------------------------------------- //! get the total dofs const FEDofList& FEDeformableSpringDomain::GetDOFList() const { return m_dof; } //----------------------------------------------------------------------------- void FEDeformableSpringDomain::SetMaterial(FEMaterial* pmat) { FEDomain::SetMaterial(pmat); m_pMat = dynamic_cast<FESpringMaterial*>(pmat); assert(m_pMat); } //----------------------------------------------------------------------------- void FEDeformableSpringDomain::BuildMatrixProfile(FEGlobalMatrix& K) { // we connect each node to its two neighbors int NN = Nodes(); for (int i=1; i<NN-1; ++i) { vector<int> lm(3*6, -1); for (int j=0; j<3; ++j) { int n = i-1+j; vector<int>& id = Node(n).m_ID; // first the displacement dofs lm[6 * j ] = id[m_dofU[0]]; lm[6 * j + 1] = id[m_dofU[1]]; lm[6 * j + 2] = id[m_dofU[2]]; // rigid rotational dofs lm[6 * j + 3] = id[m_dofR[0]]; lm[6 * j + 4] = id[m_dofR[1]]; lm[6 * j + 5] = id[m_dofR[2]]; } K.build_add(lm); } } //----------------------------------------------------------------------------- void FEDeformableSpringDomain::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 FEDeformableSpringDomain::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]); } } } // calculate the intitial spring length m_L0 = InitialLength(); } //----------------------------------------------------------------------------- double FEDeformableSpringDomain::InitialLength() { FEMesh& mesh = *m_pMesh; double L = 0.0; for (size_t i = 0; i<m_Elem.size(); ++i) { // get the discrete element FEDiscreteElement& el = m_Elem[i]; // get the nodes FENode& n1 = mesh.Node(el.m_node[0]); FENode& n2 = mesh.Node(el.m_node[1]); // get the nodal positions vec3d& r1 = n1.m_r0; vec3d& r2 = n2.m_r0; L += (r2 - r1).norm(); } return L; } //----------------------------------------------------------------------------- double FEDeformableSpringDomain::CurrentLength() { FEMesh& mesh = *m_pMesh; double L = 0.0; for (size_t i = 0; i<m_Elem.size(); ++i) { // get the discrete element FEDiscreteElement& el = m_Elem[i]; // get the nodes FENode& n1 = mesh.Node(el.m_node[0]); FENode& n2 = mesh.Node(el.m_node[1]); // get the nodal positions vec3d& r1 = n1.m_rt; vec3d& r2 = n2.m_rt; L += (r2 - r1).norm(); } return L; } //----------------------------------------------------------------------------- //! Calculates the forces due to discrete elements (i.e. springs) void FEDeformableSpringDomain::InternalForces(FEGlobalVector& R) { FEMesh& mesh = *m_pMesh; vector<double> fe(6); vec3d u1, u2; vector<int> en(2), lm(6); // calculate current length double L = CurrentLength(); double DL = L - m_L0; // calculate force double F = m_pMat->force(DL); for (size_t i = 0; i<m_Elem.size(); ++i) { // get the discrete element FEDiscreteElement& el = m_Elem[i]; // get the nodes FENode& n1 = mesh.Node(el.m_node[0]); FENode& n2 = mesh.Node(el.m_node[1]); // get the nodal positions vec3d& r01 = n1.m_r0; vec3d& r02 = n2.m_r0; vec3d& rt1 = n1.m_rt; vec3d& rt2 = n2.m_rt; vec3d e = rt2 - rt1; e.unit(); // calculate spring lengths double L0 = (r02 - r01).norm(); double Lt = (rt2 - rt1).norm(); double DL = Lt - L0; // set up the force vector fe[0] = F*e.x; fe[1] = F*e.y; fe[2] = F*e.z; fe[3] = -F*e.x; fe[4] = -F*e.y; fe[5] = -F*e.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); } if (m_kbend > 0) { /* double eps = m_kbend; lm.resize(3); en.resize(1); fe.resize(3); int NN = Nodes(); for (int i = 1; i<NN - 1; ++i) { int i0 = i - 1; int i1 = i + 1; vec3d xi = Node(i).m_rt; vec3d x0 = Node(i0).m_rt; vec3d x1 = Node(i1).m_rt; vec3d r = xi - x0; vec3d s = x1 - x0; s.unit(); vec3d d = r - s*(r*s); fe[0] = -eps*d.x; fe[1] = -eps*d.y; fe[2] = -eps*d.z; en[0] = m_Node[i]; lm[0] = Node(i).m_ID[m_dofX]; lm[1] = Node(i).m_ID[m_dofY]; lm[2] = Node(i).m_ID[m_dofZ]; R.Assemble(en, lm, fe); } */ double eps = m_kbend; lm.resize(3); en.resize(1); fe.resize(3); int NN = Nodes(); for (int i = 1; i<NN - 1; ++i) { int i0 = i - 1; int i1 = i + 1; vec3d xi = Node(i).m_rt; vec3d x0 = Node(i0).m_rt; vec3d x1 = Node(i1).m_rt; vec3d d = xi - (x0 + x1)*0.5; fe[0] = -eps*d.x; fe[1] = -eps*d.y; fe[2] = -eps*d.z; en[0] = m_Node[i]; lm[0] = Node(i).m_ID[m_dofU[0]]; lm[1] = Node(i).m_ID[m_dofU[1]]; lm[2] = Node(i).m_ID[m_dofU[2]]; R.Assemble(en, lm, fe); } } if (m_kstab > 0) { double eps = m_kstab; lm.resize(6); en.resize(2); fe.resize(6); int NE = Elements(); for (int i=0; i<NE; ++i) { FEDiscreteElement& el = Element(i); en[0] = el.m_node[0]; en[1] = el.m_node[1]; // get the nodes FENode& n0 = mesh.Node(en[0]); FENode& n1 = mesh.Node(en[1]); lm[0] = n0.m_ID[m_dofU[0]]; lm[1] = n0.m_ID[m_dofU[1]]; lm[2] = n0.m_ID[m_dofU[2]]; lm[3] = n1.m_ID[m_dofU[0]]; lm[4] = n1.m_ID[m_dofU[1]]; lm[5] = n1.m_ID[m_dofU[2]]; vec3d ei = n1.m_rt - n0.m_rt; fe[0] = eps*ei.x; fe[1] = eps*ei.y; fe[2] = eps*ei.z; fe[3] = -eps*ei.x; fe[4] = -eps*ei.y; fe[5] = -eps*ei.z; R.Assemble(en, lm, fe); } } } //----------------------------------------------------------------------------- //! Calculates the discrete element stiffness void FEDeformableSpringDomain::StiffnessMatrix(FELinearSystem& LS) { FEMesh& mesh = *m_pMesh; // calculate current length double L = CurrentLength(); double DL = L - m_L0; // evaluate the stiffness double F = m_pMat->force(DL); double E = m_pMat->stiffness(DL); 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]; // 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& r01 = n1.m_r0; vec3d& r02 = n2.m_r0; vec3d& rt1 = n1.m_rt; vec3d& rt2 = n2.m_rt; vec3d e = rt2 - rt1; e.unit(); // calculate nodal displacements vec3d u1 = rt1 - r01; vec3d u2 = rt2 - r02; // calculate spring lengths double L0 = (r02 - r01).norm(); double Lt = (rt2 - rt1).norm(); double DL = Lt - L0; if (Lt == 0) { F = 0; Lt = 1; e = vec3d(1, 1, 1); } double A[3][3] = { 0 }; A[0][0] = ((E - F / Lt)*e.x*e.x + F / Lt); A[1][1] = ((E - F / Lt)*e.y*e.y + F / Lt); A[2][2] = ((E - F / Lt)*e.z*e.z + F / Lt); A[0][1] = A[1][0] = (E - F / Lt)*e.x*e.y; A[1][2] = A[2][1] = (E - F / Lt)*e.y*e.z; A[0][2] = A[2][0] = (E - F / Lt)*e.x*e.z; ke[0][0] = A[0][0]; ke[0][1] = A[0][1]; ke[0][2] = A[0][2]; ke[1][0] = A[1][0]; ke[1][1] = A[1][1]; ke[1][2] = A[1][2]; ke[2][0] = A[2][0]; ke[2][1] = A[2][1]; ke[2][2] = A[2][2]; ke[0][3] = -A[0][0]; ke[0][4] = -A[0][1]; ke[0][5] = -A[0][2]; ke[1][3] = -A[1][0]; ke[1][4] = -A[1][1]; ke[1][5] = -A[1][2]; ke[2][3] = -A[2][0]; ke[2][4] = -A[2][1]; ke[2][5] = -A[2][2]; ke[3][0] = -A[0][0]; ke[3][1] = -A[0][1]; ke[3][2] = -A[0][2]; ke[4][0] = -A[1][0]; ke[4][1] = -A[1][1]; ke[4][2] = -A[1][2]; ke[5][0] = -A[2][0]; ke[5][1] = -A[2][1]; ke[5][2] = -A[2][2]; ke[3][3] = A[0][0]; ke[3][4] = A[0][1]; ke[3][5] = A[0][2]; ke[4][3] = A[1][0]; ke[4][4] = A[1][1]; ke[4][5] = A[1][2]; ke[5][3] = A[2][0]; ke[5][4] = A[2][1]; ke[5][5] = A[2][2]; // 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); } // Add Bending stiffness if (m_kbend > 0) { double eps = m_kbend; vector<int> lmi(3); vector<int> lmj(9); en.resize(3); int NN = Nodes(); for (int i = 1; i<NN - 1; ++i) { int i0 = i - 1; int i1 = i + 1; ke.resize(3, 9); ke.zero(); ke[0][0] = -eps; ke[0][3] = 0.5*eps; ke[0][6] = 0.5*eps; ke[1][1] = -eps; ke[1][4] = 0.5*eps; ke[1][7] = 0.5*eps; ke[2][2] = -eps; ke[2][5] = 0.5*eps; ke[2][8] = 0.5*eps; vector<int>& IDi = Node(i).m_ID; vector<int>& ID0 = Node(i0).m_ID; vector<int>& ID1 = Node(i1).m_ID; lmi[0] = IDi[m_dofU[0]]; lmi[1] = IDi[m_dofU[1]]; lmi[2] = IDi[m_dofU[2]]; lmj[0] = IDi[m_dofU[0]]; lmj[1] = IDi[m_dofU[1]]; lmj[2] = IDi[m_dofU[2]]; lmj[3] = ID0[m_dofU[0]]; lmj[4] = ID0[m_dofU[1]]; lmj[5] = ID0[m_dofU[2]]; lmj[6] = ID1[m_dofU[0]]; lmj[7] = ID1[m_dofU[1]]; lmj[8] = ID1[m_dofU[2]]; ke.SetNodes(en); ke.SetIndices(lmi, lmj); LS.Assemble(ke); } } if (m_kstab > 0) { double eps = m_kstab; lm.resize(6); en.resize(2); ke.resize(6,6); ke.zero(); ke[0][0] = ke[1][1] = ke[2][2] = eps; ke[3][0] = ke[4][1] = ke[5][2] = -eps; ke[0][3] = ke[1][4] = ke[2][5] = -eps; ke[3][3] = ke[4][4] = ke[5][5] = eps; int NE = Elements(); for (int i = 0; i<NE; ++i) { FEDiscreteElement& el = Element(i); en[0] = el.m_node[0]; en[1] = el.m_node[1]; // get the nodes FENode& n0 = mesh.Node(en[0]); FENode& n1 = mesh.Node(en[1]); lm[0] = n0.m_ID[m_dofU[0]]; lm[1] = n0.m_ID[m_dofU[1]]; lm[2] = n0.m_ID[m_dofU[2]]; lm[3] = n1.m_ID[m_dofU[0]]; lm[4] = n1.m_ID[m_dofU[1]]; lm[5] = n1.m_ID[m_dofU[2]]; // assemble the element into the global system ke.SetNodes(en); ke.SetIndices(lm); LS.Assemble(ke); } } } //============================================================================= //----------------------------------------------------------------------------- FEDeformableSpringDomain2::FEDeformableSpringDomain2(FEModel* pfem) : FEDiscreteDomain(pfem), FEElasticDomain(pfem), m_dofU(pfem), m_dofR(pfem), m_dof(pfem) { m_pMat = 0; m_dofU.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT)); m_dofR.AddVariable(FEBioMech::GetVariableName(FEBioMech::RIGID_ROTATION)); } //----------------------------------------------------------------------------- //! get the total dofs const FEDofList& FEDeformableSpringDomain2::GetDOFList() const { return m_dof; } //----------------------------------------------------------------------------- void FEDeformableSpringDomain2::SetMaterial(FEMaterial* pmat) { FEDomain::SetMaterial(pmat); m_pMat = dynamic_cast<FESpringMaterial*>(pmat); assert(m_pMat); } //----------------------------------------------------------------------------- // Only two nodes contribute to this spring void FEDeformableSpringDomain2::UnpackLM(FEElement &el, vector<int>& lm) { int N = Nodes(); lm.resize(2 * 6); for (int i = 0; i<2; ++i) { int n = (i==0? 0 : N-1); FENode& node = Node(n); 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 + 3 * i ] = id[m_dofR[0]]; lm[3 + 3 * i + 1] = id[m_dofR[1]]; lm[3 + 3 * i + 2] = id[m_dofR[2]]; } } //----------------------------------------------------------------------------- bool FEDeformableSpringDomain2::Init() { if (FEDiscreteDomain::Init() == false) return false; // initialize node data int NN = Nodes(); m_nodeData.resize(NN); for (int i=0; i<NN; ++i) m_nodeData[i].banchor = false; // anchor first and last m_nodeData[0].banchor = true; m_nodeData[NN-1].banchor = true; return true; } //----------------------------------------------------------------------------- void FEDeformableSpringDomain2::Activate() { int N = Nodes(); for (int i = 0; i<2; ++i) { int n = (i == 0 ? 0 : N - 1); FENode& node = Node(n); 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]); } } } // Not sure if this necessary, but let's just do it to be sure UpdateNodes(); // calculate the spring lengths m_L0 = InitialLength(); m_Lt = CurrentLength(); } //----------------------------------------------------------------------------- double FEDeformableSpringDomain2::InitialLength() { FEMesh& mesh = *m_pMesh; double L = 0.0; for (size_t i = 0; i<m_Elem.size(); ++i) { // get the discrete element FEDiscreteElement& el = m_Elem[i]; // get the nodes FENode& n1 = mesh.Node(el.m_node[0]); FENode& n2 = mesh.Node(el.m_node[1]); // get the nodal positions vec3d& r1 = n1.m_r0; vec3d& r2 = n2.m_r0; double DL = (r2 - r1).norm(); L += DL; } return L; } //----------------------------------------------------------------------------- double FEDeformableSpringDomain2::CurrentLength() { FEMesh& mesh = *m_pMesh; double L = 0.0; for (size_t i = 0; i<m_Elem.size(); ++i) { // get the discrete element FEDiscreteElement& el = m_Elem[i]; // get the nodes FENode& n1 = mesh.Node(el.m_node[0]); FENode& n2 = mesh.Node(el.m_node[1]); // get the nodal positions vec3d& r1 = n1.m_rt; vec3d& r2 = n2.m_rt; double DL = (r2 - r1).norm(); L += DL; } return L; } //----------------------------------------------------------------------------- //! Calculates the forces due to discrete elements (i.e. springs) void FEDeformableSpringDomain2::InternalForces(FEGlobalVector& R) { FEMesh& mesh = *m_pMesh; vector<double> fe(6); vec3d u1, u2; vector<int> en(2), lm(6); // calculate length increment double DL = m_Lt - m_L0; // calculate force double F = m_pMat->force(DL); int N = Elements(); for (size_t i = 0; i<2; ++i) { int n = (i==0? 0 : N-1); double sign = (i == 0 ? 1 : -1); // get the discrete element FEDiscreteElement& el = Element(n); // get the nodes FENode& n1 = mesh.Node(el.m_node[0]); FENode& n2 = mesh.Node(el.m_node[1]); // get the nodal positions vec3d& r01 = n1.m_r0; vec3d& r02 = n2.m_r0; vec3d& rt1 = n1.m_rt; vec3d& rt2 = n2.m_rt; vec3d e = rt2 - rt1; e.unit(); // set up the force vector fe[i*3 ] = sign*F*e.x; fe[i*3 + 1] = sign*F*e.y; fe[i*3 + 2] = sign*F*e.z; // setup the node vector en[i] = el.m_node[i]; // set up the LM vector if (i==0) UnpackLM(el, lm); } // assemble element R.Assemble(en, lm, fe); } //----------------------------------------------------------------------------- //! Calculates the discrete element stiffness void FEDeformableSpringDomain2::StiffnessMatrix(FELinearSystem& LS) { FEMesh& mesh = *m_pMesh; FEElementMatrix ke; ke.resize(6, 6); ke.zero(); vector<int> en(2), lm(6); // get the nodes of the element int NN = Nodes(); FENode& n1 = Node(0); FENode& n2 = Node(NN-1); // get the nodal positions vec3d& r01 = n1.m_r0; vec3d& r02 = n2.m_r0; vec3d& rt1 = n1.m_rt; vec3d& rt2 = n2.m_rt; vec3d e = rt2 - rt1; e.unit(); // calculate spring lengths double L0 = (r02 - r01).norm(); double Lt = (rt2 - rt1).norm(); double DL = Lt - L0; // evaluate the stiffness double F = m_pMat->force(DL); double E = m_pMat->stiffness(DL); if (Lt == 0) { F = 0; Lt = 1; e = vec3d(1, 1, 1); } double A[3][3] = { 0 }; A[0][0] = ((E - F / Lt)*e.x*e.x + F / Lt); A[1][1] = ((E - F / Lt)*e.y*e.y + F / Lt); A[2][2] = ((E - F / Lt)*e.z*e.z + F / Lt); A[0][1] = A[1][0] = (E - F / Lt)*e.x*e.y; A[1][2] = A[2][1] = (E - F / Lt)*e.y*e.z; A[0][2] = A[2][0] = (E - F / Lt)*e.x*e.z; ke[0][0] = A[0][0]; ke[0][1] = A[0][1]; ke[0][2] = A[0][2]; ke[1][0] = A[1][0]; ke[1][1] = A[1][1]; ke[1][2] = A[1][2]; ke[2][0] = A[2][0]; ke[2][1] = A[2][1]; ke[2][2] = A[2][2]; ke[0][3] = -A[0][0]; ke[0][4] = -A[0][1]; ke[0][5] = -A[0][2]; ke[1][3] = -A[1][0]; ke[1][4] = -A[1][1]; ke[1][5] = -A[1][2]; ke[2][3] = -A[2][0]; ke[2][4] = -A[2][1]; ke[2][5] = -A[2][2]; ke[3][0] = -A[0][0]; ke[3][1] = -A[0][1]; ke[3][2] = -A[0][2]; ke[4][0] = -A[1][0]; ke[4][1] = -A[1][1]; ke[4][2] = -A[1][2]; ke[5][0] = -A[2][0]; ke[5][1] = -A[2][1]; ke[5][2] = -A[2][2]; ke[3][3] = A[0][0]; ke[3][4] = A[0][1]; ke[3][5] = A[0][2]; ke[4][3] = A[1][0]; ke[4][4] = A[1][1]; ke[4][5] = A[1][2]; ke[5][3] = A[2][0]; ke[5][4] = A[2][1]; ke[5][5] = A[2][2]; // setup the node vector en[0] = m_Node[0]; en[1] = m_Node[NN-1]; // set up the LM vector UnpackLM(Element(0), lm); // assemble the element into the global system ke.SetNodes(en); ke.SetIndices(lm); LS.Assemble(ke); } //----------------------------------------------------------------------------- void FEDeformableSpringDomain2::Update(const FETimeInfo& tp) { // update wire partition and nodal positions UpdateNodes(); } //----------------------------------------------------------------------------- void FEDeformableSpringDomain2::SetNodePosition(int node, const vec3d& r) { FENode& nd = Node(node); nd.m_rt = r; vec3d u = nd.m_rt - nd.m_r0; nd.set_vec3d(m_dofU[0], m_dofU[1], m_dofU[2], u); } //----------------------------------------------------------------------------- // This functions distributes the nodes that are not anchored evenly between anchor // points. void FEDeformableSpringDomain2::UpdateNodes() { // make sure we have enough nodes // We need more than 2 nodes since the outer nodes are always anchored. int NN = Nodes(); if (NN <= 2) return; // find wire segments int n0 = 0, n1 = 1; while (n0 < NN-1) { if (m_nodeData[n1].banchor) { vec3d r0 = Node(n0).m_rt; vec3d r1 = Node(n1).m_rt; for (int n = n0+1; n<=n1-1; ++n) { assert(m_nodeData[n].banchor == false); double w = (double) (n - n0) / (double)(n1 - n0); FENode& nd = Node(n); nd.m_rt = r0 + (r1 - r0)*w; vec3d u = nd.m_rt - nd.m_r0; nd.set_vec3d(m_dofU[0], m_dofU[1], m_dofU[2], u); } n0 = n1; } n1++; } // re-calculate current length m_Lt = CurrentLength(); } //----------------------------------------------------------------------------- //! Anchor (or release) a node void FEDeformableSpringDomain2::AnchorNode(int node, bool banchor) { m_nodeData[node].banchor = banchor; } //----------------------------------------------------------------------------- vec3d FEDeformableSpringDomain2::NodalForce(int node) { int NN = Nodes(); if ((node <= 0) || (node >= NN -1)) return vec3d(0,0,0); vec3d r = Node(node).m_rt; vec3d rm = Node(node-1).m_rt; vec3d rp = Node(node+1).m_rt; double F = SpringForce(); vec3d A = rm - r; A.unit(); A *= F; vec3d B = rp - r; B.unit(); B *= F; vec3d D = A + B; return D; } //----------------------------------------------------------------------------- //! get net spring force double FEDeformableSpringDomain2::SpringForce() { return m_pMat->force(m_Lt - m_L0); } //----------------------------------------------------------------------------- //! tangent vec3d FEDeformableSpringDomain2::Tangent(int node) { int NN = Nodes(); if (NN < 2) return vec3d(0,0,0); if (node == 0) { vec3d t = Node(node+1).m_rt - Node(node).m_rt; t.unit(); return t; } else if (node == NN-1) { vec3d t = Node(node).m_rt - Node(node - 1).m_rt; t.unit(); return t; } else { vec3d t = Node(node + 1).m_rt - Node(node - 1).m_rt; t.unit(); return t; } }
C++
3D
febiosoftware/FEBio
FEBioMech/FETiedLineConstraint.cpp
.cpp
15,307
619
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FETiedLineConstraint.h" #include <FECore/FEClosestPointProjection.h> #include <FECore/FELinearSystem.h> #include <FECore/log.h> FETiedLine::FETiedLine(FEModel* fem) : FEEdge(fem) { } FEMaterialPoint* FETiedLine::CreateMaterialPoint() { return new FELineMaterialPoint; } void FETiedLine::Update() { } bool FETiedLine::Create(FESegmentSet& eset) { return FEEdge::Create(eset, FE_LINE2NI); // TODO: Does this assume linear edges? } bool FETiedLine::Init() { if (FEEdge::Init() == false) return false; int NN = Nodes(); m_data.resize(NN); return true; } FETiedLine::Projection FETiedLine::ClosestProjection(const vec3d& x) { FETiedLine::Projection P; int NE = Elements(); double L2min = 0; const double eps = 1e-5; for (int i = 0; i < NE; ++i) { FELineElement& el = Element(i); vec3d a = Node(el.m_lnode[0]).m_rt; vec3d b = Node(el.m_lnode[1]).m_rt; vec3d e = (b - a); double D2 = e.norm2(); if (D2 != 0) { double l = ((x-a)*e)/D2; if ((l >= -eps) && (l <= 1.0 + eps)) { vec3d q = a + e * l; double L2 = (x - q).norm2(); if ((P.pe == nullptr) || (L2 < L2min)) { P.pe = &el; P.r = 2.0 * l - 1; P.q = q; L2min = L2; } } } } assert(P.pe); return P; } BEGIN_FECORE_CLASS(FETiedLineConstraint, FENLConstraint) ADD_PARAMETER(m_laugon , "laugon" )->setLongName("Enforcement method")->setEnums("PENALTY\0AUGLAG\0"); ADD_PARAMETER(m_atol , "tolerance" ); ADD_PARAMETER(m_eps , "penalty" ); ADD_PARAMETER(m_naugmin , "minaug" ); ADD_PARAMETER(m_naugmax , "maxaug" ); ADD_PARAMETER(m_Dmax , "max_distance" ); ADD_PROPERTY(pl, "primary")->AddFlag(FEProperty::Reference); ADD_PROPERTY(sl, "secondary")->AddFlag(FEProperty::Reference); END_FECORE_CLASS(); FETiedLineConstraint::FETiedLineConstraint(FEModel* pfem) : FENLConstraint(pfem), pl(pfem), sl(pfem) { static int count = 1; SetID(count++); // initial parameter values m_laugon = FECore::PENALTY_METHOD; m_atol = 0.01; m_eps = 1.0; m_naugmin = 0; m_naugmax = 10; m_Dmax = 0.0; } bool FETiedLineConstraint::Init() { if (pl.Init() == false) return false; if (sl.Init() == false) return false; return true; } void FETiedLineConstraint::BuildMatrixProfile(FEGlobalMatrix& K) { FEMesh& mesh = GetMesh(); // get the DOFS const int dof_X = GetDOFIndex("x"); const int dof_Y = GetDOFIndex("y"); const int dof_Z = GetDOFIndex("z"); const int dof_RU = GetDOFIndex("Ru"); const int dof_RV = GetDOFIndex("Rv"); const int dof_RW = GetDOFIndex("Rw"); const int LMSIZE = 6 * (FEElement::MAX_NODES + 1); vector<int> lm(LMSIZE); for (int j = 0; j < pl.Nodes(); ++j) { FENode& nj = pl.Node(j); FELineElement* pe = pl.m_data[j].me; if (pe != 0) { FELineElement& me = *pe; int* en = &me.m_lnode[0]; int n = me.Nodes(); lm.assign(LMSIZE, -1); lm[0] = nj.m_ID[dof_X]; lm[1] = nj.m_ID[dof_Y]; lm[2] = nj.m_ID[dof_Z]; lm[3] = nj.m_ID[dof_RU]; lm[4] = nj.m_ID[dof_RV]; lm[5] = nj.m_ID[dof_RW]; for (int k = 0; k < n; ++k) { vector<int>& id = sl.Node(en[k]).m_ID; lm[6 * (k + 1) ] = id[dof_X]; lm[6 * (k + 1) + 1] = id[dof_Y]; lm[6 * (k + 1) + 2] = id[dof_Z]; lm[6 * (k + 1) + 3] = id[dof_RU]; lm[6 * (k + 1) + 4] = id[dof_RV]; lm[6 * (k + 1) + 5] = id[dof_RW]; } K.build_add(lm); } } } void FETiedLineConstraint::Activate() { // Don't forget to call base member! FENLConstraint::Activate(); // project primary surface onto secondary surface ProjectLines(pl, sl); } void FETiedLineConstraint::Update() { // get the mesh FEMesh& mesh = GetMesh(); // loop over all primary nodes for (int i=0; i<pl.Nodes(); ++i) { FELineElement* pme = pl.m_data[i].me; if (pme) { // get the current primary nodal position vec3d rt = pl.Node(i).m_rt; // get the natural coordinates of the primary projection // onto the secondary element double r = pl.m_data[i].r; // get the nodal coordinates int ne = pme->Nodes(); vec3d y[FEElement::MAX_NODES]; for (int l=0; l<ne; ++l) y[l] = sl.Node( pme->m_lnode[l] ).m_rt; // calculate the primary node projection vec3d q; double H[FEElement::MAX_NODES]; pme->shape(H, r); for (int n = 0; n < ne; ++n) q += y[n] * H[n]; // calculate the gap function pl.m_data[i].vgap = (rt - q); // calculate force pl.m_data[i].Tc = pl.m_data[i].Lm + pl.m_data[i].vgap*m_eps; } } } void FETiedLineConstraint::ProjectLines(FETiedLine& pl, FETiedLine& sl) { // let's count contact pairs int contacts = 0; // loop over all primary nodes for (int i=0; i< pl.Nodes(); ++i) { // get the next node FENode& node = pl.Node(i); pl.m_data[i].me = nullptr; // get the nodal position of this primary node vec3d x = node.m_rt; // find the secondary element FETiedLine::Projection P = sl.ClosestProjection(x); if (P.pe) { // make sure we are within the max distance double D = (x - P.q).norm(); if ((m_Dmax == 0.0) || (D <= m_Dmax)) { // store the secondary element pl.m_data[i].me = P.pe; // store the natural coordinates of the projection on the secondary element pl.m_data[i].r = P.r; // calculate vector gap pl.m_data[i].vgap = (x - P.q); // calculate force pl.m_data[i].Tc = pl.m_data[i].Lm + pl.m_data[i].vgap*m_eps; contacts++; } } } // if we found no contact pairs, let's report this since this is probably not the user's intention if (contacts == 0) { std::string name = GetName(); feLogWarning("No contact pairs found for 1D slide line\"%s\".\nThis contact interface may not have any effect.", name.c_str()); } } void FETiedLineConstraint::LoadVector(FEGlobalVector& R, const FETimeInfo& 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 = pl.Elements(); for (int j = 0; j < NE; ++j) { // get the primary element FELineElement& sel = pl.Element(j); int nseln = sel.Nodes(); // get the element's LM vector // TODO: This assumes dofs are indexed at (0,1,2)! sLM.resize(3 * nseln); for (int a = 0; a < nseln; ++a) { FENode& node = pl.Node(sel.m_lnode[a]); sLM[3 * a ] = node.m_ID[0]; sLM[3 * a + 1] = node.m_ID[1]; sLM[3 * a + 2] = node.m_ID[2]; } vec3d a = pl.Node(sel.m_lnode[0]).m_r0; vec3d b = pl.Node(sel.m_lnode[1]).m_r0; double L = (b - a).norm(); 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]; // 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 (pl.m_data[m].me != 0) { // calculate jacobian and weight double Jw = w[n] * (L / 2); // get nodal contact force vec3d tc = pl.m_data[m].Lm; // add penalty contribution for penalty and aug lag method tc += pl.m_data[m].vgap*m_eps; // get the secondary element FELineElement& mel = *pl.m_data[m].me; int nmeln = mel.Nodes(); mLM.resize(3 * nmeln); for (int b = 0; b < nmeln; ++b) { FENode& node = sl.Node(mel.m_lnode[b]); mLM[3 * b ] = node.m_ID[0]; mLM[3 * b + 1] = node.m_ID[1]; mLM[3 * b + 2] = node.m_ID[2]; } // isoparametric coordinates of the projected primary node // onto the secondary element double r = pl.m_data[m].r; // get the secondary shape function values at this primary node mel.shape(N, r); // allocate "element" force vector fe.resize(3 * (nmeln + 1)); // calculate contribution to force vector from nodes fe[0] = -Jw * tc.x; fe[1] = -Jw * tc.y; fe[2] = -Jw * tc.z; for (int l = 0; l < nmeln; ++l) { fe[3 * (l + 1) ] = Jw * tc.x*N[l]; fe[3 * (l + 1) + 1] = Jw * tc.y*N[l]; fe[3 * (l + 1) + 2] = Jw * tc.z*N[l]; } // setup lm vector lm.resize(3 * (nmeln + 1)); // fill the lm array 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]; } en.resize(nmeln + 1); // fill the en array 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 FETiedLineConstraint::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 = pl.Elements(); for (int i = 0; i < NE; ++i) { FELineElement& se = pl.Element(i); int nseln = se.Nodes(); // get the element's LM vector // TODO: This assumes dofs are indexed at (0,1,2)! sLM.resize(3 * nseln); for (int a = 0; a < nseln; ++a) { FENode& node = pl.Node(se.m_lnode[a]); sLM[3 * a ] = node.m_ID[0]; sLM[3 * a + 1] = node.m_ID[1]; sLM[3 * a + 2] = node.m_ID[2]; } double* w = se.GaussWeights(); vec3d a = pl.Node(se.m_lnode[0]).m_r0; vec3d b = pl.Node(se.m_lnode[1]).m_r0; double L = (b - a).norm(); // loop over all integration points (that is nodes) for (int n = 0; n < nseln; ++n) { int m = se.m_lnode[n]; // get the secondary element FELineElement* pme = pl.m_data[m].me; if (pme) { // get the secondary element FELineElement& me = *pme; int nmeln = me.Nodes(); mLM.resize(3 * nmeln); for (int b = 0; b < nmeln; ++b) { FENode& node = sl.Node(me.m_lnode[b]); mLM[3 * b ] = node.m_ID[0]; mLM[3 * b + 1] = node.m_ID[1]; mLM[3 * b + 2] = node.m_ID[2]; } // calculate jacobian double Jw = w[n]*(L/2); // primary node natural coordinates in secondary element double r = pl.m_data[m].r; // get the secondary shape function values at this primary node me.shape(H, r); // number of degrees of freedom int ndof = 3 * (1 + nmeln); // fill stiffness matrix ke.resize(ndof, ndof); ke.zero(); ke[0][0] = Jw*m_eps; ke[1][1] = Jw*m_eps; ke[2][2] = Jw*m_eps; for (int k = 0; k < nmeln; ++k) { ke[0][3 + 3 * k ] = -Jw*m_eps*H[k]; ke[1][3 + 3 * k + 1] = -Jw*m_eps*H[k]; ke[2][3 + 3 * k + 2] = -Jw*m_eps*H[k]; ke[3 + 3 * k ][0] = -Jw*m_eps*H[k]; ke[3 + 3 * k + 1][1] = -Jw*m_eps*H[k]; ke[3 + 3 * k + 2][2] = -Jw*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 ] = Jw*m_eps*H[k] * H[l]; ke[3 + 3 * k + 1][3 + 3 * l + 1] = Jw*m_eps*H[k] * H[l]; ke[3 + 3 * k + 2][3 + 3 * l + 2] = Jw*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); } } } } bool FETiedLineConstraint::Augment(int naug, const FETimeInfo& tp) { // make sure we need to augment if (m_laugon != FECore::AUGLAG_METHOD) return true; // calculate initial norms double normL0 = 0; for (int i=0; i< pl.Nodes(); ++i) { vec3d lm = pl.m_data[i].Lm; normL0 += lm*lm; } normL0 = sqrt(normL0); // update Lagrange multipliers and calculate current norms double normL1 = 0; double normgc = 0; int N = 0; for (int i=0; i<pl.Nodes(); ++i) { vec3d lm = pl.m_data[i].Lm + pl.m_data[i].vgap*m_eps; normL1 += lm*lm; if (pl.m_data[i].me != 0) { double g2 = pl.m_data[i].vgap.norm2(); normgc += g2; ++N; } } if (N == 0) N=1; normL1 = sqrt(normL1); normgc = sqrt(normgc / N); // check convergence of constraints const std::string& name = GetName(); if (name.empty()) feLog(" tied-line # %d\n", GetID()); else feLog(" %s [tied-line]\n", name.c_str()); feLog(" CURRENT REQUIRED\n"); double pctn = 0; if (fabs(normL1) > 1e-10) pctn = fabs((normL1 - normL0)/normL1); feLog(" normal force : %15le %15le\n", pctn, m_atol); feLog(" gap function : %15le ***\n", normgc); // check convergence bool bconv = true; if (pctn >= m_atol) bconv = false; if (naug < m_naugmin ) bconv = false; if (naug >= m_naugmax) bconv = true; if (bconv == false) { for (int i=0; i<pl.Nodes(); ++i) { // update Lagrange multipliers pl.m_data[i].Lm = pl.m_data[i].Lm + pl.m_data[i].vgap*m_eps; } } return bconv; } void FETiedLineConstraint::Serialize(DumpStream &ar) { // store contact data FENLConstraint::Serialize(ar); // store contact surface data pl.Serialize(ar); sl.Serialize(ar); // serialize pointers if (ar.IsShallow() == false) { if (ar.IsSaving()) { int NN = pl.Nodes(); ar << NN; for (int i=0; i<NN; ++i) { FELineElement* pe = pl.m_data[i].me; if (pe) ar << pe->GetLocalID(); else ar << -1; } } else { int NN, lid; ar >> NN; for (int i=0; i<NN; ++i) { ar >> lid; if (lid < 0) pl.m_data[i].me = nullptr; else pl.m_data[i].me = &sl.Element(lid); } } } }
C++
3D
febiosoftware/FEBio
FEBioMech/FEElasticDomain.cpp
.cpp
1,459
36
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEElasticDomain.h" //----------------------------------------------------------------------------- FEElasticDomain::FEElasticDomain(FEModel* pfem) { }
C++
3D
febiosoftware/FEBio
FEBioMech/FEMaxStressCriterion.h
.h
1,561
42
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMeshAdaptorCriterion.h> class FEStressCriterion : public FEMeshAdaptorCriterion { public: FEStressCriterion(FEModel* fem); bool GetMaterialPointValue(FEMaterialPoint& mp, double& value) override; private: int m_metric; DECLARE_FECORE_CLASS() };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEMooneyRivlin.cpp
.cpp
4,701
166
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEMooneyRivlin.h" //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEMooneyRivlin, FEUncoupledMaterial) ADD_PARAMETER(m_c1, "c1")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_c2, "c2")->setUnits(UNIT_PRESSURE); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Calculate the deviatoric stress mat3ds FEMooneyRivlin::DevStress(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // get material parameters double c1 = m_c1(mp); double c2 = m_c2(mp); // determinant of deformation gradient double J = pt.m_J; // calculate deviatoric left Cauchy-Green tensor mat3ds B = pt.DevLeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // Invariants of B (= invariants of C) // Note that these are the invariants of Btilde, not of B! double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); // --- TODO: put strain energy derivatives here --- // // W = C1*(I1 - 3) + C2*(I2 - 3) // // Wi = dW/dIi double W1 = c1; double W2 = c2; // --- // calculate T = F*dW/dC*Ft // T = F*dW/dC*Ft mat3ds T = B*(W1 + W2*I1) - B2*W2; return T.dev()*(2.0/J); } //----------------------------------------------------------------------------- //! Calculate the deviatoric tangent tens4ds FEMooneyRivlin::DevTangent(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // get material parameters double c1 = m_c1(mp); double c2 = m_c2(mp); // determinant of deformation gradient double J = pt.m_J; double Ji = 1.0/J; // calculate deviatoric left Cauchy-Green tensor: B = F*Ft mat3ds B = pt.DevLeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // Invariants of B (= invariants of C) double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); // --- TODO: put strain energy derivatives here --- // Wi = dW/dIi double W1, W2; W1 = c1; W2 = c2; // --- // calculate dWdC:C double WC = W1*I1 + 2*W2*I2; // calculate C:d2WdCdC:C double CWWC = 2*I2*W2; // deviatoric cauchy-stress, trs = trace[s]/3 mat3ds T = B*(W1 + W2*I1) - B2*W2; mat3ds devs = T.dev()*(2.0/J); // Identity tensor mat3ds I(1,1,1,0,0,0); tens4ds IxI = dyad1s(I); tens4ds I4 = dyad4s(I); tens4ds BxB = dyad1s(B); tens4ds B4 = dyad4s(B); // d2W/dCdC:C mat3ds WCCxC = B*(W2*I1) - B2*W2; tens4ds cw = (BxB - B4)*(W2*4.0*Ji) - dyad1s(WCCxC, I)*(4.0/3.0*Ji) + IxI*(4.0/9.0*Ji*CWWC); tens4ds c = dyad1s(devs, I)*(-2.0/3.0) + (I4 - IxI/3.0)*(4.0/3.0*Ji*WC) + cw; return c; } //----------------------------------------------------------------------------- //! calculate deviatoric strain energy density double FEMooneyRivlin::DevStrainEnergyDensity(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // get material parameters double c1 = m_c1(mp); double c2 = m_c2(mp); // calculate deviatoric left Cauchy-Green tensor mat3ds B = pt.DevLeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // Invariants of B (= invariants of C) // Note that these are the invariants of Btilde, not of B! double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); // // W = C1*(I1 - 3) + C2*(I2 - 3) // double sed = c1*(I1-3) + c2*(I2-3); return sed; }
C++
3D
febiosoftware/FEBio
FEBioMech/FENaturalNeoHookean.h
.h
2,339
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 "FEElasticMaterial.h" #include <FECore/FEModelParam.h> //----------------------------------------------------------------------------- //! Natural neo Hookean //! Implementation of a neo-Hookean hyperelastic material //! using natural strain (Criscione et al. JMPS 2000) class FEBIOMECH_API FENaturalNeoHookean : public FEElasticMaterial { public: FENaturalNeoHookean(FEModel* pfem) : FEElasticMaterial(pfem) {} public: FEParamDouble m_E; //!< bulk modulus FEParamDouble m_v; //!< shear modulus public: //! calculate stress at material point mat3ds Stress(FEMaterialPoint& pt) override; //! calculate tangent stiffness at material point tens4ds Tangent(FEMaterialPoint& pt) override; //! calculate strain energy density at material point double StrainEnergyDensity(FEMaterialPoint& pt) override; protected: void EigenValues(mat3ds& A, double l[3], vec3d r[3], const double eps = 0); // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEStVenantKirchhoff.h
.h
2,096
60
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticMaterial.h" //----------------------------------------------------------------------------- //! Linear elatic material for large deformations //! This material can be used when a body undergoes large rotations //! but small strains. class FEStVenantKirchhoff : public FEElasticMaterial { public: FEStVenantKirchhoff(FEModel* pfem); public: double m_E; //!< Young's modulus double m_v; //!< Poisson's ratio public: //! calculate stress at material point mat3ds Stress(FEMaterialPoint& pt) override; //! calculate tangent stiffness at material point tens4ds Tangent(FEMaterialPoint& pt) override; //! calculate strain energy density at material point double StrainEnergyDensity(FEMaterialPoint& pt) override; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEFiberPow.h
.h
2,189
63
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticFiberMaterial.h" #include "FEFiberMaterial.h" //! Material class for single fiber, tension only //! Power law class FEFiberPow : public FEFiberMaterial { public: FEFiberPow(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_ksi; // fiber modulus FEParamDouble m_beta; // power law exponent in toe region double m_epsf; bool m_tension_only; }; class FEElasticFiberPow : public FEElasticFiberMaterial_T<FEFiberPow> { public: FEElasticFiberPow(FEModel* fem) : FEElasticFiberMaterial_T<FEFiberPow>(fem) {} DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FESolidSolver.cpp
.cpp
23,486
787
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FESolidSolver.h" #include "FE3FieldElasticSolidDomain.h" #include "FE3FieldElasticShellDomain.h" #include "FEResidualVector.h" #include "FEUncoupledMaterial.h" #include "FEContactInterface.h" #include "FESolidLinearSystem.h" #include <FECore/sys.h> #include <FECore/log.h> #include <FECore/DOFS.h> #include <FECore/FEModel.h> #include <FECore/FEAnalysis.h> #include <FECore/FEBoundaryCondition.h> #include <FECore/FENodalLoad.h> #include <FECore/FEModelLoad.h> #include <FECore/FELinearConstraintManager.h> #include <FECore/FENLConstraint.h> #include <FECore/FESurfaceLoad.h> #include <FECore/FEBodyLoad.h> #include <assert.h> #include "FEBioMech.h" #include "FESolidAnalysis.h" //----------------------------------------------------------------------------- // define the parameter list BEGIN_FECORE_CLASS(FESolidSolver, 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_beta , "beta" ); ADD_PARAMETER(m_gamma , "gamma" ); ADD_PARAMETER(m_bnew_update , "use_new_rigid_update"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! FESolidSolver Construction // FESolidSolver::FESolidSolver(FEModel* pfem) : FENewtonSolver(pfem), m_rigidSolver(pfem),\ m_dofU(pfem), m_dofV(pfem), m_dofSU(pfem), m_dofRQ(pfem) { // default values m_Rtol = 0; // deactivate residual convergence m_Dtol = 0.001; m_Etol = 0.01; m_Rmin = 1.0e-20; m_niter = 0; m_nreq = 0; // default Newmark parameters for unconditionally stable time integration m_beta = 0.25; m_gamma = 0.5; m_bnew_update = false; m_rigidSolver.AllowMixedBCs(true); // 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_dofV.AddVariable(FEBioMech::GetVariableName(FEBioMech::VELOCITY)); m_dofSU.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_DISPLACEMENT)); m_dofRQ.AddVariable(FEBioMech::GetVariableName(FEBioMech::RIGID_ROTATION)); } } //----------------------------------------------------------------------------- FESolidSolver::~FESolidSolver() { } //----------------------------------------------------------------------------- //! Allocates and initializes the data structures used by the FESolidSolver // bool FESolidSolver::Init() { // initialize base class if (FENewtonSolver::Init() == false) return false; // allocate vectors int neq = m_neq; // m_Fn.assign(neq, 0); m_Fr.assign(neq, 0); m_Ui.assign(neq, 0); m_Ut.assign(neq, 0); // we need to fill the total displacement vector m_Ut FEModel& fem = *GetFEModel(); 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_dofSU[0]); gather(m_Ut, mesh, m_dofSU[1]); gather(m_Ut, mesh, m_dofSU[2]); // 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)); if (d) d->SetDynamicUpdateFlag(b); } return true; } //----------------------------------------------------------------------------- //! Save data to dump file void FESolidSolver::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; if (ar.IsLoading()) { // re-initialize data Init(); } m_rigidSolver.Serialize(ar); } //----------------------------------------------------------------------------- //! Determine the number of linear equations and assign equation numbers //! This function initializes the equation system. //! It is assumed that all free dofs up until now have been given an ID >= 0 //! and the fixed or rigid dofs an ID < 0. //! After this operation the nodal ID array will contain the equation //! number assigned to the corresponding degree of freedom. To distinguish //! between free or unconstrained dofs and constrained ones the following rules //! apply to the ID array: //! //! / //! | >= 0 --> dof j of node i is a free dof //! ID[i][j] < == -1 --> dof j of node i is a fixed (no equation assigned too) //! | < -1 --> dof j of node i is constrained and has equation nr = -ID[i][j]-2 //! \ //! bool FESolidSolver::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; // All initialization is done return true; } //----------------------------------------------------------------------------- //! Update the kinematics of the model, such as nodal positions, velocities, //! accelerations, etc. void FESolidSolver::UpdateKinematics(vector<double>& ui) { // get the mesh FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); // update rigid bodies // (this also updates the kinematics of rigid nodes) m_rigidSolver.UpdateRigidBodies(m_Ui, ui, m_bnew_update); // 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 flexible nodes // translational dofs scatter(U, mesh, m_dofU[0]); scatter(U, mesh, m_dofU[1]); scatter(U, mesh, m_dofU[2]); // rotational dofs scatter(U, mesh, m_dofSU[0]); scatter(U, mesh, m_dofSU[1]); scatter(U, mesh, 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 for (int i = 0; i<mesh.Nodes(); ++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]); } // update velocity and accelerations // for dynamic simulations FEAnalysis* pstep = fem.GetCurrentStep(); if (pstep->m_nanalysis == FESolidAnalysis::DYNAMIC) { int N = mesh.Nodes(); double dt = fem.GetTime().timeIncrement; double a = 1.0 / (m_beta*dt); double b = a / dt; double c = 1.0 - 0.5/m_beta; for (int i = 0; i<N; ++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); } // update the rigid body kinematics m_rigidSolver.UpdateRigidKinematics(); } } //----------------------------------------------------------------------------- //! Updates the current state of the model void FESolidSolver::Update(vector<double>& ui) { FEModel& fem = *GetFEModel(); // update kinematics UpdateKinematics(ui); // update element stresses fem.Update(); } //----------------------------------------------------------------------------- //! Prepares the data for the first BFGS-iteration. void FESolidSolver::PrepStep() { // zero total displacements zero(m_Ui); const FETimeInfo& tp = GetFEModel()->GetTime(); double dt = tp.timeIncrement; // store previous mesh state // we need them for velocity and acceleration calculations FEModel& fem = *GetFEModel(); 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; // initial guess at start of new time step 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); } // 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); } // 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) mesh.Domain(i).PreSolveUpdate(tp); // update stresses fem.Update(); // 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 for (int i=0; i<fem.NonlinearConstraints(); ++i) { FENLConstraint& ci = *fem.NonlinearConstraint(i); if (ci.IsActive()) m_baugment = true; } } //----------------------------------------------------------------------------- //! Implements the BFGS algorithm to solve the nonlinear FE equations. bool FESolidSolver::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 // Get the current step FEModel& fem = *GetFEModel(); FEAnalysis* pstep = fem.GetCurrentStep(); const FETimeInfo& tp = fem.GetTime(); // prepare for the first iteration PrepStep(); // Init 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 (returns line search; solution stored in m_ui) double s = QNSolve(); // 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; } // calculate norms normR1 = m_R1*m_R1; normu = (m_ui*m_ui)*(s*s); normE1 = s*fabs(m_ui*m_R1); // check for nans if (ISNAN(normR1)) throw NANInResidualDetected(); if (ISNAN(normu)) throw NANInSolutionDetected(); // update total displacements int neq = (int)m_Ui.size(); for (int i = 0; i<neq; ++i) m_Ui[i] += s*m_ui[i]; normU = m_Ui*m_Ui; // 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; } // check if we have converged. // If not, calculate the BFGS update vectors if (bconv == false) { 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 augmentations bconv = DoAugmentations(); } // increase iteration number m_niter++; // do minor iterations callbacks fem.DoCallback(CB_MINOR_ITERS); } while (bconv == false); // if converged we update the total displacements if (bconv) { m_Ut += m_Ui; } return bconv; } //----------------------------------------------------------------------------- //! Calculates global stiffness matrix. bool FESolidSolver::StiffnessMatrix() { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); // setup the linear syster FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), 1.0, m_nreq); // get the mesh FEMesh& mesh = fem.GetMesh(); // calculate the stiffness matrix for each domain for (int i=0; i<mesh.Domains(); ++i) { FEElasticDomain& dom = dynamic_cast<FEElasticDomain&>(mesh.Domain(i)); dom.StiffnessMatrix(LS); } // calculate the model load stiffness matrix int NML = fem.ModelLoads(); for (int j = 0; j<NML; ++j) { FEModelLoad* pml = fem.ModelLoad(j); if (pml->IsActive()) pml->StiffnessMatrix(LS); } // Add mass matrix for dynamic problems FEAnalysis* pstep = fem.GetCurrentStep(); if (pstep->m_nanalysis == FESolidAnalysis::DYNAMIC) { // scale factor double dt = tp.timeIncrement; double a = 1.0 / (m_beta*dt*dt); // loop over all domains for (int i = 0; i<mesh.Domains(); ++i) { FEElasticDomain& dom = dynamic_cast<FEElasticDomain&>(mesh.Domain(i)); dom.MassMatrix(LS, a); } } // calculate contact stiffness if (fem.SurfacePairConstraints() > 0) { ContactStiffness(LS); } // calculate stiffness matrices for surface loads /* int nsl = fem.SurfaceLoads(); for (int i = 0; i<nsl; ++i) { FESurfaceLoad* psl = fem.SurfaceLoad(i); if (psl->IsActive()) { psl->StiffnessMatrix(LS, tp); } } */ // calculate nonlinear constraint stiffness // note that this is the contribution of the // constrainst enforced with augmented lagrangian NonLinearConstraintStiffness(LS, tp); // calculate the stiffness contributions for the rigid forces for (int i = 0; i<fem.ModelLoads(); ++i) fem.ModelLoad(i)->StiffnessMatrix(LS); // we still need to set the diagonal elements to 1 // for the prescribed rigid body dofs. m_rigidSolver.StiffnessMatrix(*m_pK, tp); return true; } //----------------------------------------------------------------------------- //! Calculate the stiffness contribution due to nonlinear constraints void FESolidSolver::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 FESolidSolver::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 FESolidSolver::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 FESolidSolver::Residual(vector<double>& R) { // get the time information FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); // initialize residual with concentrated nodal loads zero(R);// = m_Fn; // zero nodal reaction forces zero(m_Fr); // setup the global vector FEResidualVector RHS(fem, R, m_Fr); // zero rigid body reaction forces m_rigidSolver.Residual(); // get the mesh FEMesh& mesh = fem.GetMesh(); // calculate the internal (stress) forces for (int i=0; i<mesh.Domains(); ++i) { FEElasticDomain& dom = dynamic_cast<FEElasticDomain&>(mesh.Domain(i)); dom.InternalForces(RHS); } // calculate the body forces 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) InertialForces(RHS); // 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); // add model loads /* int NML = fem.ModelLoads(); for (int i=0; i<NML; ++i) { FEModelLoad& mli = *fem.ModelLoad(i); if (mli.IsActive()) { mli.LoadVector(RHS, tp); } } */ // 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]] - 2) >= 0) node.set_load(m_dofU[0], -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]] - 2) >= 0) node.set_load(m_dofU[2], -m_Fr[n]); } // increase RHS counter m_nrhs++; return true; } //----------------------------------------------------------------------------- //! calculate the nonlinear constraint forces void FESolidSolver::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); } } //----------------------------------------------------------------------------- //! This function calculates the inertial forces for dynamic problems void FESolidSolver::InertialForces(FEGlobalVector& R) { // get the mesh FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); // allocate F vector<double> F(3*mesh.Nodes()); zero(F); // get the time information const FETimeInfo& tp = fem.GetTime(); // calculate F double dt = tp.timeIncrement; double a = 1.0 / (m_beta*dt); double b = a / dt; double c = 1.0 - 0.5/m_beta; for (int i=0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); vec3d& rt = node.m_rt; vec3d& rp = node.m_rp; vec3d& vp = node.m_vp; vec3d& ap = node.m_ap; F[3*i ] = b*(rt.x - rp.x) - a*vp.x + c * ap.x; F[3*i+1] = b*(rt.y - rp.y) - a*vp.y + c * ap.y; F[3*i+2] = b*(rt.z - rp.z) - a*vp.z + c * ap.z; } // now multiply F with the mass matrix for (int nd = 0; nd < mesh.Domains(); ++nd) { FEElasticDomain& dom = dynamic_cast<FEElasticDomain&>(mesh.Domain(nd)); dom.InertialForces(R, F); } }
C++
3D
febiosoftware/FEBio
FEBioMech/FECoupledMooneyRivlin.h
.h
2,067
56
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticMaterial.h" //----------------------------------------------------------------------------- //! This is a coupled formulation for the Mooney-Rivlin material. class FECoupledMooneyRivlin : public FEElasticMaterial { public: FECoupledMooneyRivlin(FEModel* pfem) : FEElasticMaterial(pfem){} protected: double m_c1; //!< Mooney-Rivlin parameter c1 double m_c2; //!< Mooney-Rivlin parameter c2 double m_K; //!< bulk modulus public: //! calculate stress at material point mat3ds Stress(FEMaterialPoint& pt) override; //! calculate tangent at material point tens4ds Tangent(FEMaterialPoint& pt) override; //! calculate strain energy density at material point double StrainEnergyDensity(FEMaterialPoint& pt) override; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEUncoupledReactiveFatigue.h
.h
3,138
81
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEUncoupledMaterial.h" #include "FEDamageCriterion.h" #include "FEDamageCDF.h" #include "FEReactiveFatigueMaterialPoint.h" //----------------------------------------------------------------------------- // This material models fatigue and damage in any hyper-elastic materials. class FEUncoupledReactiveFatigue : public FEUncoupledMaterial { public: FEUncoupledReactiveFatigue(FEModel* pfem); public: //! calculate stress at material point mat3ds DevStress(FEMaterialPoint& pt) override; //! calculate tangent stiffness at material point tens4ds DevTangent(FEMaterialPoint& pt) override; //! calculate strain energy density at material point double DevStrainEnergyDensity(FEMaterialPoint& pt) override; //! damage double Damage(FEMaterialPoint& pt); //! data initialization and checking bool Init() override; // returns a pointer to a new material point object FEMaterialPointData* CreateMaterialPointData() override; // get the elastic material FEElasticMaterial* GetElasticMaterial() override { return m_pBase; } // update fatigue material point at each iteration void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override; public: FEUncoupledMaterial* m_pBase; // base uncoupled material FEDamageCDF* m_pIdmg; // damage model for intact bonds FEDamageCDF* m_pFdmg; // damage model for fatigued bonds FEDamageCriterion* m_pIcrt; // damage criterion FEDamageCriterion* m_pFcrt; // fatigue criterion public: FEParamDouble m_k0; // reaction rate for fatigue reaction FEParamDouble m_beta; // power exponent for fatigue reaction DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEOrthoElastic.cpp
.cpp
9,220
263
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEOrthoElastic.h" #include <FECore/log.h> //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEOrthoElastic, FEElasticMaterial) ADD_PARAMETER(m_E1 , FE_RANGE_GREATER(0.0), "E1")->setLongName("E1 modulus")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_E2 , FE_RANGE_GREATER(0.0), "E2")->setLongName("E2 modulus")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_E3 , FE_RANGE_GREATER(0.0), "E3")->setLongName("E3 modulus")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_G12, FE_RANGE_GREATER_OR_EQUAL(0.0), "G12")->setLongName("G12 shear modulus")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_G23, FE_RANGE_GREATER_OR_EQUAL(0.0), "G23")->setLongName("G23 shear modulus")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_G31, FE_RANGE_GREATER_OR_EQUAL(0.0), "G31")->setLongName("G31 shear modulus")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_v12, "v12"); ADD_PARAMETER(m_v23, "v23"); ADD_PARAMETER(m_v31, "v31"); ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEOrthoElastic::FEOrthoElastic(FEModel* pfem) : FEElasticMaterial(pfem) {} //----------------------------------------------------------------------------- //! Material initialization. bool FEOrthoElastic::Validate() { if (FEElasticMaterial::Validate() == false) return false; // do some sanity checks if (m_v12.isConst() && m_E1.isConst() && m_E2.isConst()) { double v12 = m_v12.constValue(); double E1 = m_E1.constValue(); double E2 = m_E2.constValue(); if (v12 > sqrt(E1 / E2)) { feLogError("Invalid value for v12. Let v12 <= sqrt(E1/E2)"); return false; } } if (m_v23.isConst() && m_E2.isConst() && m_E3.isConst()) { double v23 = m_v23.constValue(); double E2 = m_E2.constValue(); double E3 = m_E3.constValue(); if (v23 > sqrt(E2 / E3)) { feLogError("Invalid value for v23. Let v23 <= sqrt(E2/E3)"); return false; } } if (m_v31.isConst() && m_E1.isConst() && m_E3.isConst()) { double v31 = m_v31.constValue(); double E1 = m_E1.constValue(); double E3 = m_E3.constValue(); if (v31 > sqrt(E3 / E1)) { feLogError("Invalid value for v31. Let v31 <= sqrt(E3/E1)"); return false; } } return true; } //----------------------------------------------------------------------------- bool FEOrthoElastic::EvaluateLameCoefficients(FEMaterialPoint& mp, double lam[3][3], double mu[3]) { double E1 = m_E1 (mp); double E2 = m_E2 (mp); double E3 = m_E3 (mp); double v12 = m_v12(mp); double v23 = m_v23(mp); double v31 = m_v31(mp); double G12 = m_G12(mp); double G23 = m_G23(mp); double G31 = m_G31(mp); // 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; // check that compliance matrix is positive definite mat3ds c(lam[0][0], lam[1][1], lam[2][2], lam[0][1], lam[1][2], lam[0][2]); double l[3]; c.exact_eigen(l); if ((l[0] < 0) || (l[1] < 0) || (l[2] < 0)) { feLogError("Stiffness matrix is not positive definite."); assert(false); return false; } // evaluate stiffness matrix and extract Lame constants 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 for a linear orthotropic material mat3ds FEOrthoElastic::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 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 the Lame coefficients double lam[3][3] = { 0 }; double mu[3] = { 0 }; EvaluateLameCoefficients(mp, lam, mu); // 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 /= 2.0*J; return s; } //----------------------------------------------------------------------------- tens4ds FEOrthoElastic::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 // 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(); 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]); 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 the Lame coefficients double lam[3][3] = { 0 }; double mu[3] = { 0 }; EvaluateLameCoefficients(mp, lam, mu); tens4ds C(0.0); for (i=0; i<3; i++) { 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.; } // Elasticity tensor C /= J; return C; } //----------------------------------------------------------------------------- double FEOrthoElastic::StrainEnergyDensity(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); mat3ds E = (pt.RightCauchyGreen() - mat3dd(1))/2; mat3ds E2 = E.sqr(); vec3d a0[3]; // texture direction in reference configuration mat3ds A0[3]; // texture tensor in current configuration double AE[3], AE2[3]; // get the local coordinate systems mat3d Q = GetLocalCS(mp); for (int i=0; i<3; i++) { // 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 the Lame coefficients double lam[3][3] = { 0 }; double mu[3] = { 0 }; EvaluateLameCoefficients(mp, lam, mu); // calculate strain energy double sed = mu[0]*AE2[0] + mu[1]*AE2[1] + mu[2]*AE2[2] +0.5*(lam[0][0]*AE[0]*AE[0]+lam[1][1]*AE[1]*AE[1]+lam[2][2]*AE[2]*AE[2]) +lam[0][1]*AE[0]*AE[1]+lam[1][2]*AE[1]*AE[2]+lam[2][0]*AE[2]*AE[0]; return sed; }
C++
3D
febiosoftware/FEBio
FEBioMech/FE2DFiberNeoHookean.h
.h
2,090
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 "FEElasticMaterial.h" //----------------------------------------------------------------------------- class FE2DFiberNeoHookean : public FEElasticMaterial { enum { NSTEPS = 12 }; // nr of integration steps public: FE2DFiberNeoHookean(FEModel* pfem); public: FEParamDouble m_E; //!< Young's modulus FEParamDouble m_v; //!< Poisson's ratio //--- active contraction stuff --- double m_a[2]; double m_ac; // ------------------------------- public: //! calculate stress at material point virtual mat3ds Stress(FEMaterialPoint& pt) override; //! calculate tangent stiffness at material point virtual tens4ds Tangent(FEMaterialPoint& pt) override; // declare the parameter list DECLARE_FECORE_CLASS(); protected: static double m_cth[NSTEPS]; static double m_sth[NSTEPS]; };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEInitialVelocity.cpp
.cpp
3,328
120
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEInitialVelocity.h" #include "FEBioMech.h" #include <FECore/FEMaterialPoint.h> #include <FECore/FENode.h> BEGIN_FECORE_CLASS(FEInitialVelocity, FENodalIC) ADD_PARAMETER(m_v0, "value")->setUnits(UNIT_VELOCITY); END_FECORE_CLASS(); FEInitialVelocity::FEInitialVelocity(FEModel* fem) : FENodalIC(fem) { m_v0 = vec3d(0, 0, 0); } // set the initial value void FEInitialVelocity::SetValue(const vec3d& v0) { m_v0 = v0; } // initialization bool FEInitialVelocity::Init() { FEDofList dofs(GetFEModel()); if (dofs.AddVariable(FEBioMech::GetVariableName(FEBioMech::VELOCITY)) == false) return false; SetDOFList(dofs); return FENodalIC::Init(); } // return the values for node i void FEInitialVelocity::GetNodalValues(int inode, std::vector<double>& values) { assert(values.size() == 3); const FENodeSet& nset = *GetNodeSet(); const FENode& node = *nset.Node(inode); FEMaterialPoint mp; mp.m_r0 = node.m_r0; mp.m_index = inode; vec3d v0 = m_v0(mp); values[0] = v0.x; values[1] = v0.y; values[2] = v0.z; } //========================================================================= BEGIN_FECORE_CLASS(FEInitialShellVelocity, FENodalIC) ADD_PARAMETER(m_v0, "value"); END_FECORE_CLASS(); FEInitialShellVelocity::FEInitialShellVelocity(FEModel* fem) : FENodalIC(fem) { m_v0 = vec3d(0, 0, 0); } // set the initial value void FEInitialShellVelocity::SetValue(const vec3d& v0) { m_v0 = v0; } // initialization bool FEInitialShellVelocity::Init() { FEDofList dofs(GetFEModel()); if (dofs.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_VELOCITY)) == false) return false; SetDOFList(dofs); return FENodalIC::Init(); } // return the values for node i void FEInitialShellVelocity::GetNodalValues(int inode, std::vector<double>& values) { assert(values.size() == 3); const FENodeSet& nset = *GetNodeSet(); const FENode& node = *nset.Node(inode); FEMaterialPoint mp; mp.m_r0 = node.m_r0; mp.m_index = inode; vec3d v0 = m_v0(mp); values[0] = v0.x; values[1] = v0.y; values[2] = v0.z; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEFiberCDFMaterialPoint.cpp
.cpp
3,513
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) 2023 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEFiberCDFMaterialPoint.h" #include <FECore/DumpStream.h> //----------------------------------------------------------------------------- // FEFiberCDFMaterialPoint //----------------------------------------------------------------------------- FEFiberCDFMaterialPoint::FEFiberCDFMaterialPoint(FEMaterialPointData* pt) : FEMaterialPointData(pt) { m_In_1_p = m_In_1_t = 0; m_sed_t = m_sed_p = 0; m_ds_t = m_ds_p = 0; m_d2s_p = m_d2s_t = 0; } //----------------------------------------------------------------------------- FEMaterialPointData* FEFiberCDFMaterialPoint::Copy() { FEFiberCDFMaterialPoint* pt = new FEFiberCDFMaterialPoint(*this); if (m_pNext) pt->m_pNext = m_pNext->Copy(); return pt; } //----------------------------------------------------------------------------- void FEFiberCDFMaterialPoint::Init() { // initialize data m_In_1_p = m_In_1_t = 0; m_sed_t = m_sed_p = 0; m_ds_t = m_ds_p = 0; m_d2s_p = m_d2s_t = 0; // don't forget to intialize the nested data FEMaterialPointData::Init(); } //----------------------------------------------------------------------------- void FEFiberCDFMaterialPoint::Update(const FETimeInfo& timeInfo) { m_In_1_p = m_In_1_t; m_sed_p = m_sed_t; m_ds_p = m_ds_t; m_d2s_p = m_d2s_t; } //----------------------------------------------------------------------------- void FEFiberCDFMaterialPoint::Serialize(DumpStream& ar) { FEMaterialPointData::Serialize(ar); ar & m_In_1_t & m_In_1_p; ar & m_sed_t & m_sed_p; ar & m_ds_t & m_ds_p; ar & m_d2s_t & m_d2s_p; } //----------------------------------------------------------------------------- // Perform integration in one step void FEFiberCDFMaterialPoint::Integrate(const double cdf) { m_d2s_t = (cdf > 0) ? cdf : 0; double dIn = m_In_1_t - m_In_1_p; m_sed_t = m_sed_p + m_ds_p*dIn + 0.25*dIn*dIn*(m_d2s_t + m_d2s_p); m_ds_t = m_ds_p + 0.5*dIn*(m_d2s_t + m_d2s_p); } //----------------------------------------------------------------------------- void FEFiberCDFMaterialPoint::SetFiberStrain(const double In_1) { m_In_1_t = In_1; if (m_In_1_t <= 0) { m_d2s_t = 0; } }
C++
3D
febiosoftware/FEBio
FEBioMech/FEBondRecruitment.h
.h
7,013
221
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMaterial.h> #include <FECore/FEFunction1D.h> #include "febiomech_api.h" //----------------------------------------------------------------------------- // Virtual base class for damage bond recruitment functions class FEBIOMECH_API FEBondRecruitment : public FEMaterialProperty { public: FEBondRecruitment(FEModel* pfem) : FEMaterialProperty(pfem) {} //! bond recruitment function virtual double brf(FEMaterialPoint& mp, const double X) = 0; public: FECORE_BASE_CLASS(FEBondRecruitment) }; //----------------------------------------------------------------------------- // User-specified load curve for damage bond recruitment function class FEBondRecruitmentUser : public FEBondRecruitment { public: FEBondRecruitmentUser(FEModel* pfem); ~FEBondRecruitmentUser() {} //! bond recruitment function double brf(FEMaterialPoint& mp, const double X) override; public: FEFunction1D* m_brf; //!< user-defined BRF // declare parameter list DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- // Power law bond recruitment function class FEBondRecruitmentPower : public FEBondRecruitment { public: FEBondRecruitmentPower(FEModel* pfem); ~FEBondRecruitmentPower() {} //! bond recruitment function double brf(FEMaterialPoint& mp, const double X) override; public: FEParamDouble m_alpha; //!< power exponent alpha FEParamDouble m_mu0; //!< constant coeff FEParamDouble m_mu1; //!< coeff of power FEParamDouble m_s; //!< scale factor for argument // declare parameter list DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- // Exponential law bond recruitment function class FEBondRecruitmentExp : public FEBondRecruitment { public: FEBondRecruitmentExp(FEModel* pfem); ~FEBondRecruitmentExp() {} //! bond recruitment function double brf(FEMaterialPoint& mp, const double X) override; public: FEParamDouble m_alpha; //!< power exponent alpha FEParamDouble m_mu0; //!< constant coeff FEParamDouble m_mu1; //!< coeff of power FEParamDouble m_s; //!< scale factor for argument // declare parameter list DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- // Quadratic polynomial bond recruitment function class FEBondRecruitmentPoly : public FEBondRecruitment { public: FEBondRecruitmentPoly(FEModel* pfem); ~FEBondRecruitmentPoly() {} //! bond recruitment function double brf(FEMaterialPoint& mp, const double X) override; public: FEParamDouble m_mu0; //!< constant coeff FEParamDouble m_mu1; //!< coeff of linear term FEParamDouble m_mu2; //!< coeff of quadratic term // declare parameter list DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- // Log-normal damage bond recruitment function class FEBondRecruitmentLogNormal : public FEBondRecruitment { public: FEBondRecruitmentLogNormal(FEModel* pfem); ~FEBondRecruitmentLogNormal() {} //! bond recruitment function double brf(FEMaterialPoint& mp, const double X) override; public: FEParamDouble m_mu; //!< mean on log scale FEParamDouble m_sigma; //!< standard deviation on log scale FEParamDouble m_max; //!< maximum increase in recruitment // declare parameter list DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- // Weibull damage bond recruitment function class FEBondRecruitmentWeibull : public FEBondRecruitment { public: FEBondRecruitmentWeibull(FEModel* pfem); ~FEBondRecruitmentWeibull() {} //! bond recruitment function double brf(FEMaterialPoint& mp, const double X) override; public: FEParamDouble m_alpha; //!< exponent alpha FEParamDouble m_mu; //!< mean mu FEParamDouble m_ploc; //!< location parameter FEParamDouble m_max; //!< maximum increase in recruitment // declare parameter list DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- // Piecewise S-shaped quintic polynomial bond recruitment function class FEBondRecruitmentPQP : public FEBondRecruitment { public: FEBondRecruitmentPQP(FEModel* pfem); ~FEBondRecruitmentPQP() {} //! bond recruitment function double brf(FEMaterialPoint& mp, const double X) override; bool Validate() override; public: FEParamDouble m_mumin; //!< mu threshold FEParamDouble m_mumax; //!< mu cap FEParamDouble m_max; //!< maximum increase in recruitment // declare parameter list DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- // Gamma damage bond recruitment function class FEBondRecruitmentGamma : public FEBondRecruitment { public: FEBondRecruitmentGamma(FEModel* pfem); ~FEBondRecruitmentGamma() {} //! bond recruitment function double brf(FEMaterialPoint& mp, const double X) override; public: FEParamDouble m_alpha; //!< exponent alpha FEParamDouble m_mu; //!< pdf expected mean mu FEParamDouble m_max; //!< maximum increase in recruitment // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEResidualVector.h
.h
2,107
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 <FECore/FEGlobalVector.h> #include <vector> #include "febiomech_api.h" //----------------------------------------------------------------------------- class FEMechModel; //----------------------------------------------------------------------------- //! The FEResidualVector implements a global vector that stores the residual. class FEBIOMECH_API FEResidualVector : public FEGlobalVector { public: //! constructor FEResidualVector(FEModel& fem, std::vector<double>& R, std::vector<double>& Fr); //! destructor ~FEResidualVector(); //! Assemble the element vector into this global vector void Assemble(std::vector<int>& en, std::vector<int>& elm, std::vector<double>& fe, bool bdom = false) override; //! Assemble into this global vector void Assemble(int node, int dof, double f) override; };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FESurfaceForceUniform.h
.h
2,368
65
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 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 <FECore/FESurfaceLoad.h> #include <FECore/FEModelParam.h> //----------------------------------------------------------------------------- //! FESurfaceForceUniform is a surface that has a constant (deformation independant) //! force on it, distributed as a uniform traction //! class FESurfaceForceUniform : public FESurfaceLoad { public: //! constructor FESurfaceForceUniform(FEModel* pfem); //! Set the surface to apply the load to void SetSurface(FESurface* ps) override; // initialization bool Init() override; public: //! calculate contact forces void LoadVector(FEGlobalVector& R) override; //! calculate stiffness void StiffnessMatrix(FELinearSystem& LS) override; protected: double m_scale; //!< scale factor for traction vec3d m_force; //!< vector force bool m_bshellb; //!< flag to apply force on shell bottom private: vec3d m_traction; //!< calculated uniform traction DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEArrudaBoyce.h
.h
2,031
57
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEUncoupledMaterial.h" //----------------------------------------------------------------------------- //! Arruda-Boyce material class FEArrudaBoyce : public FEUncoupledMaterial { public: FEArrudaBoyce(FEModel* pfem); public: FEParamDouble m_mu; //!< shear modulus double m_N; //!< Nr of links in chain public: //! calculate deviatoric stress at material point virtual mat3ds DevStress(FEMaterialPoint& pt) override; //! calculate deviatoric tangent stiffness at material point virtual tens4ds DevTangent(FEMaterialPoint& pt) override; //! calculate deviatoric strain energy density virtual double DevStrainEnergyDensity(FEMaterialPoint& mp) override; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FE2DFiberNeoHookean.cpp
.cpp
7,927
252
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FE2DFiberNeoHookean.h" // define the material parameters BEGIN_FECORE_CLASS(FE2DFiberNeoHookean, FEElasticMaterial) ADD_PARAMETER(m_E, "E")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_v, FE_RANGE_RIGHT_OPEN(-1.0, 0.5), "v"); ADD_PARAMETER(m_a, 2, "a"); ADD_PARAMETER(m_ac, "active_contraction")->setUnits(UNIT_PRESSURE); ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional); END_FECORE_CLASS(); double FE2DFiberNeoHookean::m_cth[FE2DFiberNeoHookean::NSTEPS]; double FE2DFiberNeoHookean::m_sth[FE2DFiberNeoHookean::NSTEPS]; ////////////////////////////////////////////////////////////////////// // FE2DFiberNeoHookean ////////////////////////////////////////////////////////////////////// FE2DFiberNeoHookean::FE2DFiberNeoHookean(FEModel* pfem) : FEElasticMaterial(pfem) { static bool bfirst = true; if (bfirst) { double ph; for (int n=0; n<NSTEPS; ++n) { ph = 2.0*PI*n / (double) NSTEPS; m_cth[n] = cos(ph); m_sth[n] = sin(ph); } bfirst = false; } m_ac = 0; m_a[0] = m_a[1] = 0; } mat3ds FE2DFiberNeoHookean::Stress(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); mat3d &F = pt.m_F; double detF = pt.m_J; double detFi = 1.0/detF; double lndetF = log(detF); // get the local coordinate systems mat3d Q = GetLocalCS(mp); // calculate left Cauchy-Green tensor // (we commented out the matrix components we do not need) double b[3][3]; b[0][0] = F[0][0]*F[0][0]+F[0][1]*F[0][1]+F[0][2]*F[0][2]; b[0][1] = F[0][0]*F[1][0]+F[0][1]*F[1][1]+F[0][2]*F[1][2]; b[0][2] = F[0][0]*F[2][0]+F[0][1]*F[2][1]+F[0][2]*F[2][2]; // b[1][0] = F[1][0]*F[0][0]+F[1][1]*F[0][1]+F[1][2]*F[0][2]; b[1][1] = F[1][0]*F[1][0]+F[1][1]*F[1][1]+F[1][2]*F[1][2]; b[1][2] = F[1][0]*F[2][0]+F[1][1]*F[2][1]+F[1][2]*F[2][2]; // b[2][0] = F[2][0]*F[0][0]+F[2][1]*F[0][1]+F[2][2]*F[0][2]; // b[2][1] = F[2][0]*F[1][0]+F[2][1]*F[1][1]+F[2][2]*F[1][2]; b[2][2] = F[2][0]*F[2][0]+F[2][1]*F[2][1]+F[2][2]*F[2][2]; // material parameters double E = m_E(mp); double v = m_v(mp); // lame parameters double lam = v*E/((1+v)*(1-2*v)); double mu = 0.5*E/(1+v); // calculate stress mat3ds s; // --- M A T R I X C O N T R I B U T I O N --- s.xx() = (mu*(b[0][0] - 1) + lam*lndetF)*detFi; s.yy() = (mu*(b[1][1] - 1) + lam*lndetF)*detFi; s.zz() = (mu*(b[2][2] - 1) + lam*lndetF)*detFi; s.xy() = mu*b[0][1]*detFi; s.yz() = mu*b[1][2]*detFi; s.xz() = mu*b[0][2]*detFi; // --- F I B E R C O N T R I B U T I O N --- // NOTE: we have only implemented the active contraction model for this material // There is no passive fiber stress. if (m_ac > 0) { double wa = 1.0 / (double) NSTEPS; vec3d a0, a, v; double at; for (int n=0; n<NSTEPS; ++n) { // calculate the local material fiber vector v.x = m_cth[n]; v.y = m_sth[n]; v.z = 0; // calculate the global material fiber vector a0 = Q*v; // calculate the global spatial fiber vector a.x = F[0][0]*a0.x + F[0][1]*a0.y + F[0][2]*a0.z; a.y = F[1][0]*a0.x + F[1][1]*a0.y + F[1][2]*a0.z; a.z = F[2][0]*a0.x + F[2][1]*a0.y + F[2][2]*a0.z; // normalize material axis and store fiber stretch a.unit(); // add active contraction stuff at = wa*m_ac *sqrt((m_a[0]*v.x)*(m_a[0]*v.x) + (m_a[1]*v.y)*(m_a[1]*v.y)); s.xx() += at*a.x*a.x; s.yy() += at*a.y*a.y; s.zz() += at*a.z*a.z; s.xy() += at*a.x*a.y; s.yz() += at*a.y*a.z; s.xz() += at*a.x*a.z; } } return s; } tens4ds FE2DFiberNeoHookean::Tangent(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient mat3d &F = pt.m_F; double detF = pt.m_J; // material parameters double E = m_E(mp); double v = m_v(mp); // lame parameters double lam = v*E/((1+v)*(1-2*v)); double mu = 0.5*E/(1+v); double lam1 = lam / detF; double mu1 = (mu - lam*log(detF)) / detF; // --- M A T R I X C O N T R I B U T I O N --- double D[6][6] = {0}; D[0][0] = lam1+2.*mu1; D[0][1] = lam1 ; D[0][2] = lam1 ; D[1][0] = lam1 ; D[1][1] = lam1+2.*mu1; D[1][2] = lam1 ; D[2][0] = lam1 ; D[2][1] = lam1 ; D[2][2] = lam1+2.*mu1; D[3][3] = mu1; D[4][4] = mu1; D[5][5] = mu1; // --- F I B E R C O N T R I B U T I O N --- // NOTE: I commented the fiber stiffness out since I think it will lead to // a nonsymmetric D matrix and I can't deal with that yet. Besides, most // problems seem to be running just fine without this contribution. /* if (m_ac) { // Next, we add the fiber contribution. Since the fibers lie // randomly perpendicular to the transverse axis, we need // to integrate over that plane const double PI = 4.0*atan(1.0); double lam, at, In; vec3d a0, a, v; double wa = 1.0 / (double) NSTEPS; for (int n=0; n<NSTEPS; ++n) { // calculate the local material fiber vector v.x = m_cth[n]; v.y = m_sth[n]; v.z = 0; // calculate the global material fiber vector a0 = pt.Q*v; // calculate the global spatial fiber vector a.x = F[0][0]*a0.x + F[0][1]*a0.y + F[0][2]*a0.z; a.y = F[1][0]*a0.x + F[1][1]*a0.y + F[1][2]*a0.z; a.z = F[2][0]*a0.x + F[2][1]*a0.y + F[2][2]*a0.z; // normalize material axis and store fiber stretch lam = a.unit(); // add active contraction stuff at = wa*m_ac *sqrt((m_a[0]*v.x)*(m_a[0]*v.x) + (m_a[1]*v.y)*(m_a[1]*v.y)); In = lam*lam; D[0][0] += at*(a.x*a.x - 2.0*a.x*a.x*a.x*a.x); // c(0,0,0,0) D[0][1] += at*(a.x*a.x - 2.0*a.x*a.x*a.y*a.y); // c(0,0,1,1) D[0][2] += at*(a.x*a.x - 2.0*a.x*a.x*a.z*a.z); // c(0,0,2,2) D[0][3] -= at*(2.0*a.x*a.x*a.x*a.y); // c(0,0,0,1) D[0][4] -= at*(2.0*a.x*a.x*a.y*a.z); // c(0,0,1,2) D[0][5] -= at*(2.0*a.x*a.x*a.x*a.z); // c(0,0,0,2) D[1][1] += at*(a.y*a.y - 2.0*a.y*a.y*a.y*a.y); // c(1,1,1,1) D[1][2] += at*(a.y*a.y - 2.0*a.y*a.y*a.z*a.z); // c(1,1,2,2) D[1][3] -= at*(2.0*a.y*a.y*a.x*a.y); // c(1,1,0,1) D[1][4] -= at*(2.0*a.y*a.y*a.y*a.z); // c(1,1,1,2) D[1][5] -= at*(2.0*a.y*a.y*a.x*a.z); // c(1,1,0,2) D[2][2] += at*(a.z*a.z - 2.0*a.z*a.z*a.z*a.z); // c(2,2,2,2) D[2][3] -= at*(2.0*a.z*a.z*a.x*a.y); // c(2,2,0,1) D[2][4] -= at*(2.0*a.z*a.z*a.y*a.z); // c(2,2,1,2) D[2][5] -= at*(2.0*a.z*a.z*a.x*a.z); // c(2,2,0,2) D[3][3] -= at*(2.0*a.x*a.y*a.x*a.y); // c(0,1,0,1) D[3][4] -= at*(2.0*a.x*a.y*a.y*a.z); // c(0,1,1,2) D[3][5] -= at*(2.0*a.x*a.y*a.x*a.z); // c(0,1,0,2) D[4][4] -= at*(2.0*a.y*a.z*a.y*a.z); // c(1,2,1,2) D[4][5] -= at*(2.0*a.y*a.z*a.x*a.z); // c(1,2,0,2) D[5][5] -= at*(2.0*a.x*a.z*a.x*a.z); // c(0,2,0,2) } } */ return tens4ds(D); }
C++
3D
febiosoftware/FEBio
FEBioMech/FEFiberCDFMaterialPoint.h
.h
2,349
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) 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 <FECore/FEMaterialPoint.h> //----------------------------------------------------------------------------- // Define a material point that stores fiber CDF data and integrates it class FEFiberCDFMaterialPoint : public FEMaterialPointData { public: FEFiberCDFMaterialPoint(FEMaterialPointData* pt); FEMaterialPointData* Copy() override; void Init() override; void Serialize(DumpStream& ar) override; void Update(const FETimeInfo& timeInfo) override; public: void SetFiberStrain(const double In_1); void Integrate(const double cdf); public: double m_In_1_t, m_In_1_p; //!< In - 1 (square of stretch ratio along fiber - 1) at current and previous time double m_sed_t, m_sed_p; //!< normalized sed at current and previous time double m_ds_t, m_ds_p; //!< first derivative of normalized sed w.r.t. In at current and previous time double m_d2s_t, m_d2s_p; //!< second derivative of normalized sed w.r.t. In at current and previous time };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FERigidShellDomain.cpp
.cpp
11,687
459
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FERigidShellDomain.h" #include "FEBodyForce.h" #include "FERigidMaterial.h" #include <FECore/FELinearSystem.h> #include <FECore/FEModel.h> #include "FEBioMech.h" //----------------------------------------------------------------------------- FERigidShellDomainOld::FERigidShellDomainOld(FEModel* pfem) : FEElasticShellDomainOld(pfem) {} //----------------------------------------------------------------------------- // NOTE: Although this function doesn't do anything, we need it since // for rigid shell domains we don't want to call the FEElasticShellDomain::Initialize member. bool FERigidShellDomainOld::Init() { // just call the base class return FEShellDomainOld::Init(); } //----------------------------------------------------------------------------- // We need to override it since the base class version will not work for rigid domains. void FERigidShellDomainOld::Reset() { // nothing here } //----------------------------------------------------------------------------- //! Calculate stiffness contributions for rigid shells. //! Since rigid elements don't generate stress, we don't need to do //! anything here. void FERigidShellDomainOld::StiffnessMatrix(FELinearSystem& LS) { // Caught you looking! } //----------------------------------------------------------------------------- //! calculate residual forces for rigid shells //! void FERigidShellDomainOld::InternalForces(FEGlobalVector& R) { // Nothing to do. } //----------------------------------------------------------------------------- //! update stresses for rigid shells. //! void FERigidShellDomainOld::Update(const FETimeInfo& tp) { // Nothing to see here. Please move on. } //----------------------------------------------------------------------------- void FERigidShellDomainOld::MassMatrix(FELinearSystem& LS, double scale) { // Only crickets here ... } //----------------------------------------------------------------------------- void FERigidShellDomainOld::InertialForces(FEGlobalVector& R, std::vector<double>& F) { // chirp, chirp ... } //======================================================================= BEGIN_FECORE_CLASS(FERigidShellDomain, FEShellDomain) ADD_PARAMETER(m_h0, "shell_thickness"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FERigidShellDomain::FERigidShellDomain(FEModel* fem) : FEShellDomain(fem), FEElasticDomain(fem), m_dof(fem) { m_h0 = 0.0; m_pMat = nullptr; // TODO: Can this be done in Init, since there is no error checking if (fem) { m_dof.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT)); } } bool FERigidShellDomain::Create(int nelems, FE_Element_Spec espec) { m_Elem.resize(nelems); for (int i = 0; i < nelems; ++i) { FEShellElement& el = m_Elem[i]; el.SetLocalID(i); el.SetMeshPartition(this); } if (espec.etype != FE_ELEM_INVALID_TYPE) for (int i = 0; i < nelems; ++i) m_Elem[i].SetType(espec.etype); return true; } //----------------------------------------------------------------------------- void FERigidShellDomain::Activate() { // don't need to do anything here } //----------------------------------------------------------------------------- void FERigidShellDomain::AssignDefaultShellThickness() { double h0 = m_h0; if (h0 <= 0.0) return; for (int j = 0; j < Elements(); ++j) { FEShellElement& el = Element(j); int ne = el.Nodes(); for (int n = 0; n < ne; ++n) el.m_ht[n] = el.m_h0[n] = h0; } } void FERigidShellDomain::SetMaterial(FEMaterial* pm) { m_pMat = dynamic_cast<FERigidMaterial*>(pm); assert(m_pMat); FEShellDomain::SetMaterial(pm); } FEMaterial* FERigidShellDomain::GetMaterial() { return m_pMat; } void FERigidShellDomain::Update(const FETimeInfo& tp) { // nothing to do } void FERigidShellDomain::Reset() { // nothing to do } void FERigidShellDomain::InternalForces(FEGlobalVector& R) { // nothing to do } void FERigidShellDomain::BodyForce(FEGlobalVector& R, FEBodyForce& bf) { int NS = (int)m_Elem.size(); #pragma omp parallel for for (int i = 0; i < NS; ++i) { // element force vector vector<double> fe; vector<int> lm; // get the element FEShellElement& el = m_Elem[i]; // create the element force vector and initialize to zero int ndof = 3 * 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 // NOTE: Setting bdom parameter to false to avoid crash, but // need to look further what effect this really has. R.Assemble(el.m_node, lm, fe, false); } } //----------------------------------------------------------------------------- //! Calculates element body forces for shells void FERigidShellDomain::ElementBodyForce(FEBodyForce& BF, FEShellElement& el, vector<double>& fe) { // integration weights double* gw = el.GaussWeights(); // 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 double Jw = detJ0(el, n) * gw[n]; double* M = el.H(n); // get the force vec3d f = BF.force(mp); for (int i = 0; i < neln; ++i) { vec3d fi = f * dens * M[i] * Jw; fe[3 * i ] -= fi.x; fe[3 * i + 1] -= fi.y; fe[3 * i + 2] -= fi.z; } } } void FERigidShellDomain::InertialForces(FEGlobalVector& R, std::vector<double>& F) { // nothing to do } void FERigidShellDomain::StiffnessMatrix(FELinearSystem& LS) { // nothing to do } void FERigidShellDomain::BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) { // repeat over all shell elements int NE = (int)m_Elem.size(); #pragma omp parallel for shared (NE) for (int iel = 0; iel < NE; ++iel) { FEShellElement& el = m_Elem[iel]; // create the element's stiffness matrix FEElementMatrix ke(el); int ndof = 3 * 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); } } //----------------------------------------------------------------------------- //! This function calculates the stiffness due to body forces void FERigidShellDomain::ElementBodyForceStiffness(FEBodyForce& BF, FEShellElement &el, matrix &ke) { int neln = el.Nodes(); double* gw = el.GaussWeights(); double alphaf = GetFEModel()->GetTime().alphaf; // loop over integration points int nint = el.GaussPoints(); for (int n=0; n<nint; ++n) { FEMaterialPoint& mp = *el.GetMaterialPoint(n); double Jw = detJ0(el, n) * gw[n] * alphaf; // get the stiffness mat3d K = BF.stiffness(mp)*(m_pMat->Density(mp)*Jw); double* M = el.H(n); for (int i=0, i3=0; i<neln; ++i, i3 += 3) { for (int j=0, j3 = 0; j<neln; ++j, j3 += 3) { mat3d Kij = K*(M[i]*M[j]); ke[i3 ][j3 ] += Kij(0,0); ke[i3 ][j3+1] += Kij(0,1); ke[i3 ][j3+2] += Kij(0,2); ke[i3+1][j3 ] += Kij(1,0); ke[i3+1][j3+1] += Kij(1,1); ke[i3+1][j3+2] += Kij(1,2); ke[i3+2][j3 ] += Kij(2,0); ke[i3+2][j3+1] += Kij(2,1); ke[i3+2][j3+2] += Kij(2,2); } } } } void FERigidShellDomain::MassMatrix(FELinearSystem& LS, double scale) { // nothing to do here } double FERigidShellDomain::detJ0(FEShellElement& el, int n) { vector<vec3d> X(FEElement::MAX_NODES); for (int i = 0; i < el.Nodes(); ++i) X[i] = Node(el.m_lnode[i]).m_r0; double* Gr = el.Hr(n); double* Gs = el.Hs(n); vec3d dr = vec3d(0, 0, 0); vec3d ds = vec3d(0, 0, 0); for (int i = 0; i < el.Nodes(); ++i) { dr += X[i] * Gr[i]; ds += X[i] * Gs[i]; } double J0 = (dr ^ ds).norm(); // multiply with shell thickness double h = 0.0; double* H = el.H(n); for (int i = 0; i < el.Nodes(); ++i) h += H[i] * el.m_h0[i]; return J0*h; } mat3d FERigidShellDomain::CalculateMOI() { mat3d moi; moi.zero(); FEMesh* pm = GetMesh(); vector<vec3d> r0(FEElement::MAX_NODES); mat3dd I(1); // identity tensor // loop over all elements for (int iel = 0; iel < Elements(); ++iel) { FEShellElement& el = Element(iel); // initial coordinates int neln = el.Nodes(); for (int i = 0; i < neln; ++i) r0[i] = pm->Node(el.m_node[i]).m_r0; // loop over integration points double* gw = el.GaussWeights(); int nint = el.GaussPoints(); for (int n = 0; n < nint; ++n) { FEMaterialPoint& mp = *el.GetMaterialPoint(n); // calculate jacobian double Jw = detJ0(el, n) * gw[n]; // shape functions at integration point double* H = el.H(n); double dens = m_pMat->Density(mp); // add to moi for (int i = 0; i < neln; ++i) { for (int j = 0; j < neln; ++j) { mat3d Iij = (r0[i] * r0[j]) * I - (r0[i] & r0[j]); moi += Iij * (H[i] * H[j] * Jw * dens); } } } } return moi; } double FERigidShellDomain::CalculateMass() { double mass = 0.0; // loop over all elements for (int iel = 0; iel < Elements(); ++iel) { FEShellElement& el = Element(iel); // loop over integration points int nint = el.GaussPoints(); double* gw = el.GaussWeights(); for (int n = 0; n < nint; ++n) { FEMaterialPoint& mp = *el.GetMaterialPoint(n); // calculate jacobian double detJ = detJ0(el, n); // add to total mass mass += m_pMat->Density(mp) * detJ * gw[n]; } } return mass; } vec3d FERigidShellDomain::CalculateCOM() { vector<vec3d> r0(FEElement::MAX_NODES); vec3d rc(0, 0, 0); // loop over all elements for (int iel = 0; iel < Elements(); ++iel) { FEShellElement& el = Element(iel); // nr of integration points int nint = el.GaussPoints(); // number of nodes int neln = el.Nodes(); // initial coordinates for (int i = 0; i < neln; ++i) r0[i] = GetMesh()->Node(el.m_node[i]).m_r0; // integration weights double* gw = el.GaussWeights(); // loop over integration points for (int n = 0; n < nint; ++n) { FEMaterialPoint& mp = *el.GetMaterialPoint(n); // calculate jacobian double detJ = detJ0(el, n); // shape functions at integration point double* H = el.H(n); double dens = m_pMat->Density(mp); // add to com for (int i = 0; i < el.Nodes(); ++i) { rc += r0[i] * H[i] * detJ * gw[n] * dens; } } } return rc; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEUncoupledViscoElasticMaterial.cpp
.cpp
9,132
260
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEUncoupledViscoElasticMaterial.h" #include <FECore/FECoreKernel.h> #include <stdexcept> //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEUncoupledViscoElasticMaterial, FEUncoupledMaterial) ADD_PARAMETER(m_t[0], "t1")->setUnits(UNIT_TIME); ADD_PARAMETER(m_t[1], "t2")->setUnits(UNIT_TIME); ADD_PARAMETER(m_t[2], "t3")->setUnits(UNIT_TIME); ADD_PARAMETER(m_t[3], "t4")->setUnits(UNIT_TIME); ADD_PARAMETER(m_t[4], "t5")->setUnits(UNIT_TIME); ADD_PARAMETER(m_t[5], "t6")->setUnits(UNIT_TIME); ADD_PARAMETER(m_g0 , "g0"); ADD_PARAMETER(m_g[0], "g1"); ADD_PARAMETER(m_g[1], "g2"); ADD_PARAMETER(m_g[2], "g3"); ADD_PARAMETER(m_g[3], "g4"); ADD_PARAMETER(m_g[4], "g5"); ADD_PARAMETER(m_g[5], "g6"); ADD_PROPERTY(m_pBase, "elastic"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! constructor FEUncoupledViscoElasticMaterial::FEUncoupledViscoElasticMaterial(FEModel* pfem) : FEUncoupledMaterial(pfem) { m_g0 = 1; for (int i=0; i<MAX_TERMS; ++i) { m_t[i] = 1; m_g[i] = 0; } m_binit = false; m_pBase = 0; } //----------------------------------------------------------------------------- //! data initialization and checking bool FEUncoupledViscoElasticMaterial::Init() { // combine bulk modulus from base material and uncoupled viscoelastic material if (m_binit == false) m_K += m_pBase->m_K; if (FEUncoupledMaterial::Init() == false) return false; m_binit = true; return true; } //----------------------------------------------------------------------------- //! Create material point data FEMaterialPointData* FEUncoupledViscoElasticMaterial::CreateMaterialPointData() { return new FEViscoElasticMaterialPoint(m_pBase->CreateMaterialPointData()); } //----------------------------------------------------------------------------- //! Stress function mat3ds FEUncoupledViscoElasticMaterial::DevStress(FEMaterialPoint& mp) { double dt = CurrentTimeIncrement(); if (dt == 0) return mat3ds(0, 0, 0, 0, 0, 0); // get the elastic part FEElasticMaterialPoint& ep = *mp.ExtractData<FEElasticMaterialPoint>(); // get the viscoelastic point data FEViscoElasticMaterialPoint& pt = *mp.ExtractData<FEViscoElasticMaterialPoint>(); // Calculate the new elastic Cauchy stress mat3ds se = m_pBase->DevStress(mp); // pull-back to get PK2 stress mat3ds Se = pt.m_Se = ep.pull_back(se); // get elastic PK2 stress of previous timestep mat3ds Sep = pt.m_Sep; // calculate new history variables // terms are accumulated in S, the total PK2-stress mat3ds S = Se*m_g0; double g, h; for (int i=0; i<MAX_TERMS; ++i) { g = exp(-dt/m_t[i]); h = (1 - g)/(dt/m_t[i]); pt.m_H[i] = pt.m_Hp[i]*g + (Se - Sep)*h; S += pt.m_H[i]*m_g[i]; } // return the total Cauchy stress, // which is the push-forward of S return ep.push_forward(S); } //----------------------------------------------------------------------------- //! Material tangent tens4ds FEUncoupledViscoElasticMaterial::DevTangent(FEMaterialPoint& pt) { double dt = CurrentTimeIncrement(); // calculate the spatial elastic tangent tens4ds C = m_pBase->DevTangent(pt); if (dt == 0.0) return C; // calculate the visco scale factor double f = m_g0, g, h; for (int i=0; i<MAX_TERMS; ++i) { g = exp(-dt/m_t[i]); h = ( 1 - exp(-dt/m_t[i]) )/( dt/m_t[i] ); f += m_g[i]*h; } // multiply tangent with visco-factor return C*f; } //----------------------------------------------------------------------------- //! Strain energy density function double FEUncoupledViscoElasticMaterial::DevStrainEnergyDensity(FEMaterialPoint& mp) { // get the viscoelastic point data FEViscoElasticMaterialPoint& pt = *mp.ExtractData<FEViscoElasticMaterialPoint>(); FEElasticMaterialPoint& et = *mp.ExtractData<FEElasticMaterialPoint>(); mat3d Fsafe = et.m_F; double Jsafe = et.m_J; // Calculate the new elastic strain energy density pt.m_sed = m_pBase->DevStrainEnergyDensity(mp); double sed = pt.m_sed; double sedt = sed*m_g0; if (SeriesStretchExponent(mp)) { // get the elastic point data and evaluate the right-stretch tensor for (int i=0; i<MAX_TERMS; ++i) { if (m_g[i] > 0) { mat3ds C = et.RightCauchyGreen(); double l2[3], l[3]; vec3d v[3]; C.eigen2(l2, v); l[0] = sqrt(l2[0]); l[1] = sqrt(l2[1]); l[2] = sqrt(l2[2]); mat3ds Ua = dyad(v[0])*pow(l[0],pt.m_alpha[i]) + dyad(v[1])*pow(l[1],pt.m_alpha[i]) + dyad(v[2])*pow(l[2],pt.m_alpha[i]); et.m_F = Ua; et.m_J = Ua.det(); sedt += m_g[i]*m_pBase->DevStrainEnergyDensity(mp); } } } else throw std::runtime_error("FEUncoupledViscoElasticMaterial::deviatoric strain energy density calculation did not converge!"); et.m_F = Fsafe; et.m_J = Jsafe; // return the total strain energy density return sedt; } //----------------------------------------------------------------------------- //! calculate exponent of right-stretch tensor in series spring bool FEUncoupledViscoElasticMaterial::SeriesStretchExponent(FEMaterialPoint& mp) { const double errrel = 1e-6; const double almin = 0.001; const int maxiter = 50; // get the elastic point data and evaluate the right-stretch tensor FEElasticMaterialPoint& et = *mp.ExtractData<FEElasticMaterialPoint>(); // get the right stretch tensor mat3ds C = et.DevRightCauchyGreen(); double l2[3], l[3]; vec3d v[3]; C.eigen2(l2, v); l[0] = sqrt(l2[0]); l[1] = sqrt(l2[1]); l[2] = sqrt(l2[2]); mat3ds U = dyad(v[0])*l[0] + dyad(v[1])*l[1] + dyad(v[2])*l[2]; double gamma = 0; for (int i=0; i<MAX_TERMS; ++i) gamma += m_g[i]; // get the viscoelastic point data FEViscoElasticMaterialPoint& pt = *mp.ExtractData<FEViscoElasticMaterialPoint>(); // use previous time solution as initial guess for the exponent mat3ds Se = pt.m_Se; mat3ds S = et.pull_back(et.m_s); double fmag = Se.dotdot(U); mat3d Fsafe = et.m_F; double Jsafe = et.m_J; for (int i=0; i<MAX_TERMS; ++i) { if (m_g[i] > 0) { double alpha = pt.m_alphap[i]; bool done = false; int iter = 0; do { mat3ds Ua = dyad(v[0])*pow(l[0],alpha) + dyad(v[1])*pow(l[1],alpha) + dyad(v[2])*pow(l[2],alpha); et.m_F = Ua; et.m_J = Ua.det(); mat3ds Sea = et.pull_back(m_pBase->DevStress(mp)); double f = (Sea*m_g[i] - S + Se).dotdot(U); tens4ds Cea = et.pull_back(m_pBase->DevTangent(mp)); mat3ds U2ap = dyad(v[0])*(pow(l[0],2*alpha)*log(l[0])) + dyad(v[1])*(pow(l[1],2*alpha)*log(l[1])) + dyad(v[2])*(pow(l[2],2*alpha)*log(l[2])); double fprime = (Cea.dot(U2ap)).dotdot(U)*m_g[i]; if (fprime != 0) { double dalpha = -f/fprime; alpha += dalpha; if (fabs(f) < errrel*fmag) done = true; else if (fabs(dalpha) < errrel*fabs(alpha)) done = true; else if (alpha > 1) { alpha = 1; done = true; } else if (alpha < almin) { alpha = 0; done = true; } else if (++iter > maxiter) done = true; } else done = true; } while (!done); if (iter > maxiter) { et.m_F = Fsafe; et.m_J = Jsafe; return false; } pt.m_alpha[i] = alpha; } } et.m_F = Fsafe; et.m_J = Jsafe; return true; }
C++
3D
febiosoftware/FEBio
FEBioMech/FETractionRobinBC.h
.h
2,174
65
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESurfaceLoad.h> #include <FECore/FEModelParam.h> //----------------------------------------------------------------------------- //! FETractionRobinBC is a surface that has a traction proportional to the surface displacement and velocity //! class FETractionRobinBC : public FESurfaceLoad { public: //! constructor FETractionRobinBC(FEModel* pfem); //! Set the surface to apply the load to void SetSurface(FESurface* ps) override; // initialization bool Init() override; //! update void Update() override; public: //! calculate contact forces void LoadVector(FEGlobalVector& R) override; //! calculate stiffness void StiffnessMatrix(FELinearSystem& LS) override; protected: FEParamDouble m_epsk; //!< displacement penalty FEParamDouble m_epsc; //!< velocity penalty bool m_bshellb; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEFiberPowLinearUncoupled.cpp
.cpp
6,671
201
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEFiberPowLinearUncoupled.h" // define the material parameters BEGIN_FECORE_CLASS(FEFiberPowLinearUC, FEFiberMaterialUncoupled) ADD_PARAMETER(m_E , FE_RANGE_GREATER(0.0), "E" )->setUnits(UNIT_PRESSURE)->setLongName("fiber modulus"); ADD_PARAMETER(m_lam0 , FE_RANGE_GREATER(1.0), "lam0" )->setLongName("toe stretch ratio"); ADD_PARAMETER(m_beta , FE_RANGE_GREATER_OR_EQUAL(2.0), "beta" )->setLongName("toe power exponent"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEFiberPowLinearUC::FEFiberPowLinearUC(FEModel* pfem) : FEFiberMaterialUncoupled(pfem) { m_E = 0.0; m_lam0 = 1.0; m_beta = 2.0; } //----------------------------------------------------------------------------- mat3ds FEFiberPowLinearUC::DevFiberStress(FEMaterialPoint& mp, const vec3d& n0) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient double J = pt.m_J; mat3d F = pt.m_F*pow(J, -1./3.); // loop over all integration points mat3ds C = pt.DevRightCauchyGreen(); mat3ds s; // Calculate In double In = n0*(C*n0); // initialize material constants double E = m_E(mp); double lam0 = m_lam0(mp); double beta = m_beta(mp); double I0 = lam0*lam0; double ksi = E / 4.0 / (beta - 1)*pow(I0, -3.0 / 2.0)*pow(I0 - 1.0, 2.0 - beta); double b = ksi*pow(I0 - 1.0, beta - 1.0) + E / 2.0 / sqrt(I0); // only take fibers in tension into consideration const double eps = 0; if (In - 1 >= eps) { // get the global spatial fiber direction in current configuration vec3d nt = F*n0/sqrt(In); // calculate the outer product of nt mat3ds N = dyad(nt); // calculate the fiber stress magnitude double sn = (In < I0) ? 2*In*ksi*pow(In-1, beta-1) : 2*b*In - E*sqrt(In); // calculate the fiber stress s = N*(sn/J); } else { s.zero(); } return s.dev(); } //----------------------------------------------------------------------------- tens4ds FEFiberPowLinearUC::DevFiberTangent(FEMaterialPoint& mp, const vec3d& n0) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient double J = pt.m_J; mat3d F = pt.m_F*pow(J, -1./3.); // loop over all integration points const double eps = 0; mat3ds C = pt.DevRightCauchyGreen(); mat3ds s; tens4ds c; // Calculate In double In = n0*(C*n0); // only take fibers in tension into consideration if (In - 1 >= eps) { // get the global spatial fiber direction in current configuration vec3d nt = F*n0/sqrt(In); // calculate the outer product of nt mat3ds N = dyad(nt); tens4ds NxN = dyad1s(N); // initialize material constants double E = m_E(mp); double lam0 = m_lam0(mp); double beta = m_beta(mp); double I0 = lam0*lam0; double ksi = E / 4.0 / (beta - 1)*pow(I0, -3.0 / 2.0)*pow(I0 - 1.0, 2.0 - beta); double b = ksi*pow(I0 - 1.0, beta - 1.0) + E / 2.0 / sqrt(I0); // calculate the fiber stress magnitude double sn = (In < I0) ? 2*In*ksi*pow(In-1, beta-1) : 2*b*In - E*sqrt(In); // calculate the fiber stress s = N*(sn/J); // calculate modulus double cn = (In < I0) ? 4*In*In*ksi*(beta-1)*pow(In-1, beta-2) : E*sqrt(In); // calculate the fiber tangent c = NxN*(cn/J); // This is the final value of the elasticity tensor mat3dd I(1); tens4ds IxI = dyad1s(I); tens4ds I4 = dyad4s(I); c += ((I4+IxI/3.0)*s.tr() - dyad1s(I,s))*(2./3.) - (ddots(IxI, c)-IxI*(c.tr()/3.))/3.; } else { c.zero(); } return c; } //----------------------------------------------------------------------------- double FEFiberPowLinearUC::DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // loop over all integration points const double eps = 0; mat3ds C = pt.DevRightCauchyGreen(); // Calculate In = n0*C*n0 double In = n0*(C*n0); // only take fibers in tension into consideration double sed = 0.0; if (In - 1 >= eps) { // initialize material constants double E = m_E(mp); double lam0 = m_lam0(mp); double beta = m_beta(mp); double I0 = lam0*lam0; double ksi = E / 4.0 / (beta - 1)*pow(I0, -3.0 / 2.0)*pow(I0 - 1.0, 2.0 - beta); double b = ksi*pow(I0 - 1.0, beta - 1.0) + E / 2.0 / sqrt(I0); // calculate strain energy density sed = (In < I0) ? ksi/beta*pow(In-1, beta) : b*(In-I0) - E*(sqrt(In) - sqrt(I0)) + ksi/beta*pow(I0-1, beta); } return sed; } // define the material parameters BEGIN_FECORE_CLASS(FEUncoupledFiberPowLinear, FEElasticFiberMaterialUC) ADD_PARAMETER(m_fib.m_E , FE_RANGE_GREATER(0.0), "E" )->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_fib.m_lam0 , FE_RANGE_GREATER(1.0), "lam0" ); ADD_PARAMETER(m_fib.m_beta , FE_RANGE_GREATER_OR_EQUAL(2.0), "beta" ); END_FECORE_CLASS();
C++
3D
febiosoftware/FEBio
FEBioMech/FEBCPrescribedDeformation.cpp
.cpp
5,495
178
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEBCPrescribedDeformation.h" #include <FECore/FEMesh.h> #include "FEBioMech.h" BEGIN_FECORE_CLASS(FEBCPrescribedDeformation, FEPrescribedNodeSet) ADD_PARAMETER(m_scale, "scale"); ADD_PARAMETER(m_F , "F"); END_FECORE_CLASS(); FEBCPrescribedDeformation::FEBCPrescribedDeformation(FEModel* pfem) : FEPrescribedNodeSet(pfem) { m_scale = 1.0; m_F.unit(); // TODO: Can this be done in Init, since there is no error checking if (pfem) { FEDofList dof(pfem); dof.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT)); SetDOFList(dof); } } //----------------------------------------------------------------------------- void FEBCPrescribedDeformation::CopyFrom(FEBoundaryCondition* pbc) { FEBCPrescribedDeformation* ps = dynamic_cast<FEBCPrescribedDeformation*>(pbc); assert(ps); m_scale = ps->m_scale; m_F = ps->m_F; // copy the node set const FENodeSet* src = ps->GetNodeSet(); FENodeList nodeList = src->GetNodeList(); vector<int> nodes; for (int i = 0; i < nodeList.Size(); ++i) nodes.push_back(nodeList[i]); FENodeSet* ns = new FENodeSet(GetFEModel()); ns->Add(nodes); SetNodeSet(ns); // copy parameter list CopyParameterListState(ps->GetParameterList()); } //----------------------------------------------------------------------------- void FEBCPrescribedDeformation::SetDeformationGradient(const mat3d& F) { m_F = F; } //----------------------------------------------------------------------------- void FEBCPrescribedDeformation::GetNodalValues(int nodelid, std::vector<double>& val) { vec3d X = GetNodeSet()->Node(nodelid)->m_r0; mat3ds XX = dyad(X); vec3d x = m_F*X; vec3d u = (x - X)*m_scale; val[0] = u.x; val[1] = u.y; val[2] = u.z; } //============================================================================= BEGIN_FECORE_CLASS(FEBCPrescribedDeformation2O, FEPrescribedNodeSet) ADD_PARAMETER(m_scale, "scale"); ADD_PARAMETER(m_F , "F"); ADD_PARAMETER(m_G , "G"); ADD_PARAMETER(m_refNode, "reference"); END_FECORE_CLASS(); FEBCPrescribedDeformation2O::FEBCPrescribedDeformation2O(FEModel* pfem) : FEPrescribedNodeSet(pfem) { m_scale = 1.0; m_F.unit(); m_G.zero(); m_refNode = -1; FEDofList dofs(pfem); dofs.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT)); SetDOFList(dofs); } //----------------------------------------------------------------------------- bool FEBCPrescribedDeformation2O::Init() { if (m_refNode < 0) return false; return FEPrescribedNodeSet::Init(); } //----------------------------------------------------------------------------- // Sets the displacement scale factor. An optional load curve index can be given // of the load curve that will control the scale factor. void FEBCPrescribedDeformation2O::SetScale(double s, int lc) { m_scale = s; if (lc >= 0) AttachLoadController(&m_scale, lc); } //----------------------------------------------------------------------------- void FEBCPrescribedDeformation2O::CopyFrom(FEBoundaryCondition* pbc) { FEBCPrescribedDeformation2O* ps = dynamic_cast<FEBCPrescribedDeformation2O*>(pbc); assert(ps); m_scale = ps->m_scale; m_F = ps->m_F; m_G = ps->m_G; m_refNode = ps->m_refNode; CopyParameterListState(ps->GetParameterList()); } //----------------------------------------------------------------------------- void FEBCPrescribedDeformation2O::SetReferenceNode(int n) { m_refNode = n; } //----------------------------------------------------------------------------- void FEBCPrescribedDeformation2O::SetDeformationGradient(const mat3d& F) { m_F = F; } //----------------------------------------------------------------------------- void FEBCPrescribedDeformation2O::SetDeformationHessian(const tens3drs& G) { m_G = G; } //----------------------------------------------------------------------------- void FEBCPrescribedDeformation2O::GetNodalValues(int nodelid, std::vector<double>& val) { FEMesh& mesh = GetMesh(); vec3d X1 = mesh.Node(m_refNode).m_r0; vec3d X = GetNodeSet()->Node(nodelid)->m_r0; mat3ds XX = dyad(X); mat3ds XX1 = dyad(X1); mat3d U = m_F - mat3dd(1.0); vec3d u = U*(X - X1) + m_G.contract2s(XX - XX1)*0.5; u*=m_scale; val[0] = u.x; val[1] = u.y; val[2] = u.z; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEUT4Domain.cpp
.cpp
36,841
1,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.*/ #include "stdafx.h" #include "FEUT4Domain.h" #include "FECore/FEMesh.h" #include "FECore/FEModel.h" #include "FECore/FEGlobalMatrix.h" //----------------------------------------------------------------------------- // This function converts the Cauchy stress to a 2nd-PK stress mat3ds cauchy_to_pk2(mat3ds& s, mat3d& F) { mat3d Fi = F.inverse(); mat3d Fit = Fi.transpose(); double J = F.det(); mat3d S = (Fi*s*Fit)*J; return S.sym(); } //----------------------------------------------------------------------------- // This function converts the 2nd-PK stress to a Cauchy stress mat3ds pk2_to_cauchy(mat3ds& S, mat3d& F) { mat3d Ft = F.transpose(); double Ji = 1/F.det(); mat3d s = (F*S*Ft)*Ji; return s.sym(); } //----------------------------------------------------------------------------- // This function converts the spatial tangent to the material tangent tens4ds spatial_to_material(tens4ds& c, mat3d& F) { mat3d Fi = F.inverse(); double J = F.det(); double C[6][6] = {0}; for (int i=0; i<3; ++i) for (int j=0; j<3; ++j) for (int k=0; k<3; ++k) for (int l=0; l<3; ++l) { C[0][0] += J*Fi[0][i]*Fi[0][j]*Fi[0][k]*Fi[0][l]*c(i,j,k,l); C[0][1] += J*Fi[0][i]*Fi[0][j]*Fi[1][k]*Fi[1][l]*c(i,j,k,l); C[0][2] += J*Fi[0][i]*Fi[0][j]*Fi[2][k]*Fi[2][l]*c(i,j,k,l); C[0][3] += J*Fi[0][i]*Fi[0][j]*Fi[0][k]*Fi[1][l]*c(i,j,k,l); C[0][4] += J*Fi[0][i]*Fi[0][j]*Fi[1][k]*Fi[2][l]*c(i,j,k,l); C[0][5] += J*Fi[0][i]*Fi[0][j]*Fi[0][k]*Fi[2][l]*c(i,j,k,l); C[1][1] += J*Fi[1][i]*Fi[1][j]*Fi[1][k]*Fi[1][l]*c(i,j,k,l); C[1][2] += J*Fi[1][i]*Fi[1][j]*Fi[2][k]*Fi[2][l]*c(i,j,k,l); C[1][3] += J*Fi[1][i]*Fi[1][j]*Fi[0][k]*Fi[1][l]*c(i,j,k,l); C[1][4] += J*Fi[1][i]*Fi[1][j]*Fi[1][k]*Fi[2][l]*c(i,j,k,l); C[1][5] += J*Fi[1][i]*Fi[1][j]*Fi[0][k]*Fi[2][l]*c(i,j,k,l); C[2][2] += J*Fi[2][i]*Fi[2][j]*Fi[2][k]*Fi[2][l]*c(i,j,k,l); C[2][3] += J*Fi[2][i]*Fi[2][j]*Fi[0][k]*Fi[1][l]*c(i,j,k,l); C[2][4] += J*Fi[2][i]*Fi[2][j]*Fi[1][k]*Fi[2][l]*c(i,j,k,l); C[2][5] += J*Fi[2][i]*Fi[2][j]*Fi[0][k]*Fi[2][l]*c(i,j,k,l); C[3][3] += J*Fi[0][i]*Fi[1][j]*Fi[0][k]*Fi[1][l]*c(i,j,k,l); C[3][4] += J*Fi[0][i]*Fi[1][j]*Fi[1][k]*Fi[2][l]*c(i,j,k,l); C[3][5] += J*Fi[0][i]*Fi[1][j]*Fi[0][k]*Fi[2][l]*c(i,j,k,l); C[4][4] += J*Fi[1][i]*Fi[2][j]*Fi[1][k]*Fi[2][l]*c(i,j,k,l); C[4][5] += J*Fi[1][i]*Fi[2][j]*Fi[0][k]*Fi[2][l]*c(i,j,k,l); C[5][5] += J*Fi[0][i]*Fi[2][j]*Fi[0][k]*Fi[2][l]*c(i,j,k,l); } return tens4ds(C); } //----------------------------------------------------------------------------- // This function converts the material tangent to the spatial tangent tens4ds material_to_spatial(tens4ds& C, mat3d& F) { double Ji = 1/F.det(); double c[6][6] = {0}; for (int i=0; i<3; ++i) for (int j=0; j<3; ++j) for (int k=0; k<3; ++k) for (int l=0; l<3; ++l) { c[0][0] += Ji*F[0][i]*F[0][j]*F[0][k]*F[0][l]*C(i,j,k,l); c[0][1] += Ji*F[0][i]*F[0][j]*F[1][k]*F[1][l]*C(i,j,k,l); c[0][2] += Ji*F[0][i]*F[0][j]*F[2][k]*F[2][l]*C(i,j,k,l); c[0][3] += Ji*F[0][i]*F[0][j]*F[0][k]*F[1][l]*C(i,j,k,l); c[0][4] += Ji*F[0][i]*F[0][j]*F[1][k]*F[2][l]*C(i,j,k,l); c[0][5] += Ji*F[0][i]*F[0][j]*F[0][k]*F[2][l]*C(i,j,k,l); c[1][1] += Ji*F[1][i]*F[1][j]*F[1][k]*F[1][l]*C(i,j,k,l); c[1][2] += Ji*F[1][i]*F[1][j]*F[2][k]*F[2][l]*C(i,j,k,l); c[1][3] += Ji*F[1][i]*F[1][j]*F[0][k]*F[1][l]*C(i,j,k,l); c[1][4] += Ji*F[1][i]*F[1][j]*F[1][k]*F[2][l]*C(i,j,k,l); c[1][5] += Ji*F[1][i]*F[1][j]*F[0][k]*F[2][l]*C(i,j,k,l); c[2][2] += Ji*F[2][i]*F[2][j]*F[2][k]*F[2][l]*C(i,j,k,l); c[2][3] += Ji*F[2][i]*F[2][j]*F[0][k]*F[1][l]*C(i,j,k,l); c[2][4] += Ji*F[2][i]*F[2][j]*F[1][k]*F[2][l]*C(i,j,k,l); c[2][5] += Ji*F[2][i]*F[2][j]*F[0][k]*F[2][l]*C(i,j,k,l); c[3][3] += Ji*F[0][i]*F[1][j]*F[0][k]*F[1][l]*C(i,j,k,l); c[3][4] += Ji*F[0][i]*F[1][j]*F[1][k]*F[2][l]*C(i,j,k,l); c[3][5] += Ji*F[0][i]*F[1][j]*F[0][k]*F[2][l]*C(i,j,k,l); c[4][4] += Ji*F[1][i]*F[2][j]*F[1][k]*F[2][l]*C(i,j,k,l); c[4][5] += Ji*F[1][i]*F[2][j]*F[0][k]*F[2][l]*C(i,j,k,l); c[5][5] += Ji*F[0][i]*F[2][j]*F[0][k]*F[2][l]*C(i,j,k,l); } return tens4ds(c); } //----------------------------------------------------------------------------- void FEUT4Domain::UT4NODE::Serialize(DumpStream& ar) { ar & inode; ar & Vi & vi; ar & Fi & si; } //----------------------------------------------------------------------------- BEGIN_FECORE_CLASS(FEUT4Domain, FEElasticSolidDomain) ADD_PARAMETER(m_alpha, "alpha"); ADD_PARAMETER(m_bdev, "iso_stab"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor for the UT4Domain FEUT4Domain::FEUT4Domain(FEModel* pfem) : FEElasticSolidDomain(pfem) { m_alpha = 0.05; m_bdev = false; m_Be = 0; m_DB = 0; m_Ge = 0; } //----------------------------------------------------------------------------- void FEUT4Domain::Serialize(DumpStream& ar) { FEElasticSolidDomain::Serialize(ar); ar & m_alpha & m_bdev; ar & m_tag; ar & m_NODE; ar & m_Ve0; if (ar.IsLoading()) { // create the node-element list m_NEL.Create(*this); // find the largest valence int Nmax = m_NEL.MaxValence(); // allocate buffers m_Ge = new double[Nmax*4][4][3]; m_Be = new double[Nmax*4][6][3]; m_DB = new double[Nmax*4][6][3]; } } //----------------------------------------------------------------------------- FEUT4Domain::~FEUT4Domain() { if (m_DB) delete [] m_DB; if (m_Be) delete [] m_Be; if (m_Ge) delete [] m_Ge; } //----------------------------------------------------------------------------- void FEUT4Domain::BuildMatrixProfile(FEGlobalMatrix& M) { FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); DOFS& fedofs = fem.GetDOFS(); int MAX_NDOFS = fedofs.GetTotalDOFS(); // we'll need the node-element list FENodeElemList& NEL = GetNodeElemList(); assert(NEL.Size() > 0); vector<int> LM, elm; for (int i=0; i<mesh.Nodes(); ++i) { int NE = NEL.Valence(i); if (NE > 0) { LM.assign(NE*4*MAX_NDOFS, -1); FEElement** ppe = NEL.ElementList(i); for (int n=0; n<NE; ++n) { UnpackLM(*ppe[n], elm); for (int j=0; j<(int)elm.size(); ++j) LM[n*4*MAX_NDOFS + j] = elm[j]; } M.build_add(LM); } } } //----------------------------------------------------------------------------- //! Set UT4 parameters void FEUT4Domain::SetUT4Parameters(double alpha, bool bdev) { m_alpha = alpha; m_bdev = bdev; } //----------------------------------------------------------------------------- //! override Create so we can grab the ut4 parameters bool FEUT4Domain::Create(int nelems, FE_Element_Spec espec) { // NOTE: Commented this out, since during restart the espec is a dummy variable. // some sanity checks first // if (espec.eclass != FE_Element_Class::FE_ELEM_SOLID) return false; // if (espec.eshape != FE_Element_Shape::ET_TET4) return false; m_alpha = espec.m_ut4_alpha; m_bdev = espec.m_ut4_bdev; espec.m_but4 = true; return FEElasticSolidDomain::Create(nelems, espec); } //----------------------------------------------------------------------------- //! Initialization for the UT4Domain. //! Note that we first initialize the base class before initializing the domain. bool FEUT4Domain::Init() { // first call the base class if (FEElasticSolidDomain::Init() == false) return false; // next, we need to identify all the nodes that belong to this domain // we do this by looping over all the elements and tagging the nodes int NN = m_pMesh->Nodes(); m_tag.assign(NN, -1); int i, j; int N = (int)m_Node.size(); for (i=0; i<N; ++i) m_tag[m_Node[i]] = i; // allocate node structure m_NODE.resize(N); // initialize nodes for (i=0; i<N; ++i) { UT4NODE& n = m_NODE[i]; n.inode = m_Node[i]; n.Vi = n.vi = 0.0; n.si.zero(); } // calculate the reference nodal volume // we do this here since this volume never changes int NE = Elements(); m_Ve0.resize(NE); double Ve; vec3d r0[4]; for (i=0; i<NE; ++i) { FESolidElement& el = m_Elem[i]; // get the current element coordinates for (j=0; j<4; ++j) r0[j] = m_pMesh->Node(el.m_node[j]).m_r0; // calculate the initial volume m_Ve0[i] = Ve = TetVolume(r0); // now assign one-quart to each node for (int j=0; j<4; ++j) m_NODE[ m_tag[el.m_node[j]]].Vi += 0.25*Ve; } // create the node-element list m_NEL.Create(*this); // find the largest valence int Nmax = m_NEL.MaxValence(); // allocate buffers m_Ge = new double[Nmax*4][4][3]; m_Be = new double[Nmax*4][6][3]; m_DB = new double[Nmax*4][6][3]; return true; } //----------------------------------------------------------------------------- //! Update the nodal and element stresses void FEUT4Domain::Update(const FETimeInfo& tp) { // updating the element stresses is easy, since we only // need to call the base class FEElasticSolidDomain::Update(tp); // next we update the nodal data int i, j, NE = Elements(); for (i=0; i<(int) m_NODE.size(); ++i) { m_NODE[i].vi = 0; m_NODE[i].Fi.zero(); } double Ve, ve; mat3d Fe; vec3d rt[4]; for (i=0; i<NE; ++i) { FESolidElement& el = m_Elem[i]; // nodal coordinates for (j=0; j<4; ++j) rt[j] = m_pMesh->Node(el.m_node[j]).m_rt; // calculate the volume Ve = m_Ve0[i]; ve = TetVolume(rt); // calculate the deformation gradient defgrad(el, Fe, 0); // now assign one-quart to each node for (j=0; j<4; ++j) { UT4NODE& n = m_NODE[ m_tag[el.m_node[j]]]; n.vi += 0.25*ve; n.Fi += Fe*(0.25*Ve / n.Vi); } } // create a material point // TODO: this will set the Q variable to a unit-matrix // in other words, we loose the material axis orientation // For now, I solve this by copying the Q parameter // from the first element that the node connects to FEElasticMaterialPoint* ep = new FEElasticMaterialPoint(); FEMaterialPoint mp(ep); mp.Init(); // loop over all the nodes for (i=0; i<(int) m_NODE.size(); ++i) { UT4NODE& node = m_NODE[i]; // set the material point data mp.m_r0 = m_pMesh->Node(node.inode).m_r0; mp.m_rt = m_pMesh->Node(node.inode).m_rt; ep->m_F = node.Fi; ep->m_J = ep->m_F.det(); // calculate the stress node.si = m_pMat->Stress(mp); } } //----------------------------------------------------------------------------- //! Calculate volume for tets using the determinant rule double FEUT4Domain::TetVolume(vec3d* r) { double A[4][4]; A[0][0] = r[0].x; A[0][1] = r[1].x; A[0][2] = r[2].x; A[0][3] = r[3].x; A[1][0] = r[0].y; A[1][1] = r[1].y; A[1][2] = r[2].y; A[1][3] = r[3].y; A[2][0] = r[0].z; A[2][1] = r[1].z; A[2][2] = r[2].z; A[2][3] = r[3].z; A[3][0] = 1.0; A[3][1] = 1.0; A[3][2] = 1.0; A[3][3] = 1.0; double V = 0; V += mat3d(A[0][1], A[0][2], A[0][3], A[1][1], A[1][2], A[1][3], A[2][1], A[2][2], A[2][3]).det(); V -= mat3d(A[0][0], A[0][2], A[0][3], A[1][0], A[1][2], A[1][3], A[2][0], A[2][2], A[2][3]).det(); V += mat3d(A[0][0], A[0][1], A[0][3], A[1][0], A[1][1], A[1][3], A[2][0], A[2][1], A[2][3]).det(); V -= mat3d(A[0][0], A[0][1], A[0][2], A[1][0], A[1][1], A[1][2], A[2][0], A[2][1], A[2][2]).det(); return V/6.0; } //----------------------------------------------------------------------------- //! The residual is defined as the sum of the nodal residual and the //! element residual void FEUT4Domain::InternalForces(FEGlobalVector& R) { // Calculate the nodal contribution NodalInternalForces(R); // Calculate the element contribution ElementInternalForces(R); } //----------------------------------------------------------------------------- //! This function calculates the nodal contribution to the residual void FEUT4Domain::NodalInternalForces(FEGlobalVector& R) { // inverse jacobian matrix double Ji[3][3]; // shape function derivatives double Gx[4], Gy[4], Gz[4]; // B-matrix double Be[6][3] = {0}; int i, j, n; double Ve; vector<int> elm; vector<int> LM(3); vector<int> en(1); vector<double> fe(3); // loop over all the nodes int NN = (int) m_NODE.size(); for (i=0; i<NN; ++i) { UT4NODE& node = m_NODE[i]; // get the elements that belong to this list int NE = m_NEL.Valence(node.inode); FEElement** ppel = m_NEL.ElementList(node.inode); int* peli = m_NEL.ElementIndexList(node.inode); // get the nodal deformation gradient mat3d FI = node.Fi; mat3ds S; if (m_bdev) { S = node.si - node.si.dev()*m_alpha; } else { S = node.si*(1 - m_alpha); } // convert the Cauchy stress to a PK2-stress S = cauchy_to_pk2(S, FI); // loop over all elements that belong to this node for (n=0; n<NE; ++n) { FESolidElement& el = dynamic_cast<FESolidElement&>(*ppel[n]); UnpackLM(el, elm); // calculate element volume // TODO: we should store this somewhere instead of recalculating it Ve = m_Ve0[peli[n]]; // The '-' sign is so that the internal forces get subtracted from the residual (R = Fext - Fint) double w = -0.25* Ve; // calculate the jacobian invjac0(el, Ji, 0); // get the shape function derivatives const double* Gr, *Gs, *Gt; Gr = el.Gr(0); Gs = el.Gs(0); Gt = el.Gt(0); for (j=0; j<4; ++j) { // calculate global gradient of shape functions // note that we need the transposed of Ji, not Ji itself ! Gx[j] = Ji[0][0]*Gr[j]+Ji[1][0]*Gs[j]+Ji[2][0]*Gt[j]; Gy[j] = Ji[0][1]*Gr[j]+Ji[1][1]*Gs[j]+Ji[2][1]*Gt[j]; Gz[j] = Ji[0][2]*Gr[j]+Ji[1][2]*Gs[j]+Ji[2][2]*Gt[j]; } // get the element deformation gradient mat3d Fe = FI; // loop over element nodes for (j=0; j<4; ++j) { // setup nonlinear element B-matrix Be[0][0] = Fe[0][0]*Gx[j]; Be[0][1] = Fe[1][0]*Gx[j]; Be[0][2] = Fe[2][0]*Gx[j]; Be[1][0] = Fe[0][1]*Gy[j]; Be[1][1] = Fe[1][1]*Gy[j]; Be[1][2] = Fe[2][1]*Gy[j]; Be[2][0] = Fe[0][2]*Gz[j]; Be[2][1] = Fe[1][2]*Gz[j]; Be[2][2] = Fe[2][2]*Gz[j]; Be[3][0] = Fe[0][0]*Gy[j] + Fe[0][1]*Gx[j]; Be[3][1] = Fe[1][0]*Gy[j] + Fe[1][1]*Gx[j]; Be[3][2] = Fe[2][0]*Gy[j] + Fe[2][1]*Gx[j]; Be[4][0] = Fe[0][1]*Gz[j] + Fe[0][2]*Gy[j]; Be[4][1] = Fe[1][1]*Gz[j] + Fe[1][2]*Gy[j]; Be[4][2] = Fe[2][1]*Gz[j] + Fe[2][2]*Gy[j]; Be[5][0] = Fe[0][2]*Gx[j] + Fe[0][0]*Gz[j]; Be[5][1] = Fe[1][2]*Gx[j] + Fe[1][0]*Gz[j]; Be[5][2] = Fe[2][2]*Gx[j] + Fe[2][0]*Gz[j]; LM[0] = elm[3*j ]; LM[1] = elm[3*j+1]; LM[2] = elm[3*j+2]; en[0] = el.m_node[j]; // calculate nodal force fe[0] = w*(Be[0][0]*S.xx() + Be[1][0]*S.yy() + Be[2][0]*S.zz() + Be[3][0]*S.xy() + Be[4][0]*S.yz() + Be[5][0]*S.xz()); fe[1] = w*(Be[0][1]*S.xx() + Be[1][1]*S.yy() + Be[2][1]*S.zz() + Be[3][1]*S.xy() + Be[4][1]*S.yz() + Be[5][1]*S.xz()); fe[2] = w*(Be[0][2]*S.xx() + Be[1][2]*S.yy() + Be[2][2]*S.zz() + Be[3][2]*S.xy() + Be[4][2]*S.yz() + Be[5][2]*S.xz()); // assemble in global residual R.Assemble(en, LM, fe); } } } } //----------------------------------------------------------------------------- //! This function calculates the element contribution to the residual void FEUT4Domain::ElementInternalForces(FEGlobalVector& R) { // element force vector vector<double> fe; vector<int> lm; int NE = (int)m_Elem.size(); for (int i=0; i<NE; ++i) { // get the element FESolidElement& el = m_Elem[i]; // get the element force vector and initialize it to zero int ndof = 3*el.Nodes(); fe.assign(ndof, 0); // calculate internal force vector ElementInternalForces(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 FEUT4Domain::ElementInternalForces(FESolidElement& el, vector<double>& fe) { int i, n; // jacobian matrix, inverse jacobian matrix and determinants double Ji[3][3], detJt; double Gx, Gy, Gz; const double* Gr, *Gs, *Gt; int nint = el.GaussPoints(); int neln = el.Nodes(); double* gw = el.GaussWeights(); // repeat for all integration points for (n=0; n<nint; ++n) { FEMaterialPoint& mp = *el.GetMaterialPoint(n); FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>()); // calculate the jacobian detJt = invjact(el, Ji, n); detJt *= gw[n]; // get the stress vector for this integration point mat3ds s = pt.m_s; // take the deviatoric component and multiply it // with the stabilization factor if (m_bdev) { s = s.dev()*m_alpha; } else { s = s*m_alpha; } Gr = el.Gr(n); Gs = el.Gs(n); Gt = el.Gt(n); for (i=0; i<neln; ++i) { // calculate global gradient of shape functions // note that we need the transposed of Ji, not Ji itself ! Gx = Ji[0][0]*Gr[i]+Ji[1][0]*Gs[i]+Ji[2][0]*Gt[i]; Gy = Ji[0][1]*Gr[i]+Ji[1][1]*Gs[i]+Ji[2][1]*Gt[i]; 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; } } } //----------------------------------------------------------------------------- //! Calculates the stiffness matrix. The stiffness matrix is a sum of the //! nodal and element stiffness matrices void FEUT4Domain::StiffnessMatrix(FELinearSystem& LS) { // calculate nodal stiffness matrix NodalStiffnessMatrix(LS); // calculate element stiffness matrix ElementalStiffnessMatrix(LS); } //----------------------------------------------------------------------------- //! Calculates the nodal contribution to the global stiffness matrix void FEUT4Domain::NodalStiffnessMatrix(FELinearSystem& LS) { vector<int> elm; vector<int> LM; vector<int> en; // loop over all the nodes int NN = (int) m_NODE.size(), ni, nj; for (int i=0; i<NN; ++i) { // get the next node UT4NODE& node = m_NODE[i]; FEElement** ppe = m_NEL.ElementList(node.inode); // get its valence int NE = m_NEL.Valence(node.inode); // allocate an element stiffness matrix FEElementMatrix ke(NE*4*3, NE*4*3); ke.zero(); // calculate the geometry stiffness for this node NodalGeometryStiffness(node, ke); // calculate the material stiffness for this node NodalMaterialStiffness(node, ke, m_pMat); // it is assumed that the previous function only build the upper-triangular part // so now we build the lower-triangular by copying it from the upper-triangular part for (ni=0; ni<NE*12; ++ni) { for (nj=0; nj<ni; ++nj) { ke[ni][nj] = ke[nj][ni]; } } // create the LM and the en array LM.resize(NE*4*3); en.resize(NE*4 ); for (ni=0; ni<NE; ++ni) { FEElement& el = *ppe[ni]; UnpackLM(el, elm); for (int i=0; i<4; ++i) { LM[ni*4*3+3*i ] = elm[3*i ]; LM[ni*4*3+3*i+1] = elm[3*i+1]; LM[ni*4*3+3*i+2] = elm[3*i+2]; en[ni*4+i] = el.m_node[i]; } } // assemble the stiffness ke.SetNodes(en); ke.SetIndices(LM); LS.Assemble(ke); } } //----------------------------------------------------------------------------- //! calculates the nodal geometry stiffness contribution void FEUT4Domain::NodalGeometryStiffness(UT4NODE& node, matrix& ke) { int i, j, ni, nj; // get the element list int NE = m_NEL.Valence(node.inode); FEElement** ppe = m_NEL.ElementList(node.inode); int* peli = m_NEL.ElementIndexList(node.inode); // get the nodal stress mat3ds S; if (m_bdev) { S = node.si - node.si.dev()*m_alpha; } else { S = node.si*(1 - m_alpha); } // convert Cauchy stress to PK2 stress S = cauchy_to_pk2(S, node.Fi); // calculate the gradN matrices for (ni=0; ni<NE; ++ni) { FESolidElement& ei = dynamic_cast<FESolidElement&>(*ppe[ni]); // calculate the jacobian double Ji[3][3]; invjac0(ei, Ji, 0); // get the shape function derivatives const double* Gr, *Gs, *Gt; Gr = ei.Gr(0); Gs = ei.Gs(0); Gt = ei.Gt(0); for (j=0; j<4; ++j) { // calculate global gradient of shape functions // note that we need the transposed of Ji, not Ji itself ! m_Ge[ni][j][0] = Ji[0][0]*Gr[j]+Ji[1][0]*Gs[j]+Ji[2][0]*Gt[j]; m_Ge[ni][j][1] = Ji[0][1]*Gr[j]+Ji[1][1]*Gs[j]+Ji[2][1]*Gt[j]; m_Ge[ni][j][2] = Ji[0][2]*Gr[j]+Ji[1][2]*Gs[j]+Ji[2][2]*Gt[j]; } } // stiffness matrices double kij; // loop over all the elements for (ni=0; ni<NE; ++ni) { FESolidElement& ei = dynamic_cast<FESolidElement&>(*ppe[ni]); // calculate element volume double Vi = m_Ve0[peli[ni]]; double wi = 0.25* Vi*node.Vi/ node.Vi; // loop over the elements again for (nj=ni; nj<NE; ++nj) { FESolidElement& ej = dynamic_cast<FESolidElement&>(*ppe[nj]); // calculate element volume double Vj = m_Ve0[peli[nj]]; double wj = 0.25* Vj / node.Vi; // We're ready to rock and roll! double sg[3]; for (i=0; i<4; ++i) { double (&Gi)[3] = *(m_Ge[ni] + i); int mi = ni*12+i*3; int j0 = (ni==nj?i:0); for (j=j0; j<4; ++j) { double (&Gj)[3] = *(m_Ge[nj] + j); int mj = nj*12+j*3; sg[0] = S.xx()*Gj[0] + S.xy()*Gj[1] + S.xz()*Gj[2]; sg[1] = S.xy()*Gj[0] + S.yy()*Gj[1] + S.yz()*Gj[2]; sg[2] = S.xz()*Gj[0] + S.yz()*Gj[1] + S.zz()*Gj[2]; kij = wi*wj*(Gi[0]*sg[0]+Gi[1]*sg[1]+Gi[2]*sg[2]); // copy to element stiffness matrix ke[mi ][mj ] += kij; ke[mi+1][mj+1] += kij; ke[mi+2][mj+2] += kij; } } } } } //----------------------------------------------------------------------------- //! Calculate the volumetric contribution of the spatial tangent stiffness //! tens4ds FEUT4Domain::Cvol(const tens4ds& C, const mat3ds& S) { double p = -S.tr()/3.0; mat3dd I(1); // Identity tens4ds I4 = dyad4s(I); // Note the slightly different form than in the paper. // This is because Cvol needs to have the proper symmetries return I4*(2*p) + dyad1s(I, S)/3.0 + dyad1s(I, C.dot(I))/6.0; } //----------------------------------------------------------------------------- //! Calculates the nodal material stiffness contribution void FEUT4Domain::NodalMaterialStiffness(UT4NODE& node, matrix& ke, FESolidMaterial* pme) { // get the number of elements this nodes connects int NE = m_NEL.Valence(node.inode); FEElement** ppe = m_NEL.ElementList(node.inode); int* peli = m_NEL.ElementIndexList(node.inode); // create a material point FEElasticMaterialPoint* ep = new FEElasticMaterialPoint; FEMaterialPoint mp(ep); mp.Init(); // set the material point data mp.m_r0 = m_pMesh->Node(node.inode).m_r0; mp.m_rt = m_pMesh->Node(node.inode).m_rt; ep->m_F = node.Fi; ep->m_J = ep->m_F.det(); // set the Cauchy-stress ep->m_s = node.si; // Calculate the spatial tangent tens4ds C = pme->Tangent(mp); // Next, we need to subtract the volumetric contribution Cvol if (m_bdev) { // subtract the isochoric component from C; // C = C - a*Ciso = C - (a*(C - Cvol)) = (1-a)*C + a*Cvol C = C*(1 - m_alpha) + Cvol(C, ep->m_s)*m_alpha; } else { C = C*(1 - m_alpha); } // convert spatial matrix to material C = spatial_to_material(C, ep->m_F); // extract the 'D' matrix double D[6][6] = {0}; C.extract(D); // loop over all the elements int i, j, ni, nj; // calculate B-matrices for (ni=0; ni<NE; ++ni) { FESolidElement& el = dynamic_cast<FESolidElement&>(*ppe[ni]); // calculate the jacobian double Ji[3][3]; invjac0(el, Ji, 0); // get the shape function derivatives const double* Gr, *Gs, *Gt; Gr = el.Gr(0); Gs = el.Gs(0); Gt = el.Gt(0); // get element deformation gradient mat3d Fe = node.Fi; double Gx, Gy, Gz; for (j=0; j<4; ++j) { // calculate global gradient of shape functions // note that we need the transposed of Ji, not Ji itself ! Gx = Ji[0][0]*Gr[j]+Ji[1][0]*Gs[j]+Ji[2][0]*Gt[j]; Gy = Ji[0][1]*Gr[j]+Ji[1][1]*Gs[j]+Ji[2][1]*Gt[j]; Gz = Ji[0][2]*Gr[j]+Ji[1][2]*Gs[j]+Ji[2][2]*Gt[j]; double (&Bi)[6][3] = *(m_Be+(4*ni+j)); Bi[0][0] = Fe[0][0]*Gx; Bi[0][1] = Fe[1][0]*Gx; Bi[0][2] = Fe[2][0]*Gx; Bi[1][0] = Fe[0][1]*Gy; Bi[1][1] = Fe[1][1]*Gy; Bi[1][2] = Fe[2][1]*Gy; Bi[2][0] = Fe[0][2]*Gz; Bi[2][1] = Fe[1][2]*Gz; Bi[2][2] = Fe[2][2]*Gz; Bi[3][0] = Fe[0][0]*Gy + Fe[0][1]*Gx; Bi[3][1] = Fe[1][0]*Gy + Fe[1][1]*Gx; Bi[3][2] = Fe[2][0]*Gy + Fe[2][1]*Gx; Bi[4][0] = Fe[0][1]*Gz + Fe[0][2]*Gy; Bi[4][1] = Fe[1][1]*Gz + Fe[1][2]*Gy; Bi[4][2] = Fe[2][1]*Gz + Fe[2][2]*Gy; Bi[5][0] = Fe[0][2]*Gx + Fe[0][0]*Gz; Bi[5][1] = Fe[1][2]*Gx + Fe[1][0]*Gz; Bi[5][2] = Fe[2][2]*Gx + Fe[2][0]*Gz; double (&DBi)[6][3] = *(m_DB+(4*ni+j)); DBi[0][0] = (D[0][0]*Bi[0][0]+D[0][1]*Bi[1][0]+D[0][2]*Bi[2][0]+D[0][3]*Bi[3][0]+D[0][4]*Bi[4][0]+D[0][5]*Bi[5][0]); DBi[0][1] = (D[0][0]*Bi[0][1]+D[0][1]*Bi[1][1]+D[0][2]*Bi[2][1]+D[0][3]*Bi[3][1]+D[0][4]*Bi[4][1]+D[0][5]*Bi[5][1]); DBi[0][2] = (D[0][0]*Bi[0][2]+D[0][1]*Bi[1][2]+D[0][2]*Bi[2][2]+D[0][3]*Bi[3][2]+D[0][4]*Bi[4][2]+D[0][5]*Bi[5][2]); DBi[1][0] = (D[1][0]*Bi[0][0]+D[1][1]*Bi[1][0]+D[1][2]*Bi[2][0]+D[1][3]*Bi[3][0]+D[1][4]*Bi[4][0]+D[1][5]*Bi[5][0]); DBi[1][1] = (D[1][0]*Bi[0][1]+D[1][1]*Bi[1][1]+D[1][2]*Bi[2][1]+D[1][3]*Bi[3][1]+D[1][4]*Bi[4][1]+D[1][5]*Bi[5][1]); DBi[1][2] = (D[1][0]*Bi[0][2]+D[1][1]*Bi[1][2]+D[1][2]*Bi[2][2]+D[1][3]*Bi[3][2]+D[1][4]*Bi[4][2]+D[1][5]*Bi[5][2]); DBi[2][0] = (D[2][0]*Bi[0][0]+D[2][1]*Bi[1][0]+D[2][2]*Bi[2][0]+D[2][3]*Bi[3][0]+D[2][4]*Bi[4][0]+D[2][5]*Bi[5][0]); DBi[2][1] = (D[2][0]*Bi[0][1]+D[2][1]*Bi[1][1]+D[2][2]*Bi[2][1]+D[2][3]*Bi[3][1]+D[2][4]*Bi[4][1]+D[2][5]*Bi[5][1]); DBi[2][2] = (D[2][0]*Bi[0][2]+D[2][1]*Bi[1][2]+D[2][2]*Bi[2][2]+D[2][3]*Bi[3][2]+D[2][4]*Bi[4][2]+D[2][5]*Bi[5][2]); DBi[3][0] = (D[3][0]*Bi[0][0]+D[3][1]*Bi[1][0]+D[3][2]*Bi[2][0]+D[3][3]*Bi[3][0]+D[3][4]*Bi[4][0]+D[3][5]*Bi[5][0]); DBi[3][1] = (D[3][0]*Bi[0][1]+D[3][1]*Bi[1][1]+D[3][2]*Bi[2][1]+D[3][3]*Bi[3][1]+D[3][4]*Bi[4][1]+D[3][5]*Bi[5][1]); DBi[3][2] = (D[3][0]*Bi[0][2]+D[3][1]*Bi[1][2]+D[3][2]*Bi[2][2]+D[3][3]*Bi[3][2]+D[3][4]*Bi[4][2]+D[3][5]*Bi[5][2]); DBi[4][0] = (D[4][0]*Bi[0][0]+D[4][1]*Bi[1][0]+D[4][2]*Bi[2][0]+D[4][3]*Bi[3][0]+D[4][4]*Bi[4][0]+D[4][5]*Bi[5][0]); DBi[4][1] = (D[4][0]*Bi[0][1]+D[4][1]*Bi[1][1]+D[4][2]*Bi[2][1]+D[4][3]*Bi[3][1]+D[4][4]*Bi[4][1]+D[4][5]*Bi[5][1]); DBi[4][2] = (D[4][0]*Bi[0][2]+D[4][1]*Bi[1][2]+D[4][2]*Bi[2][2]+D[4][3]*Bi[3][2]+D[4][4]*Bi[4][2]+D[4][5]*Bi[5][2]); DBi[5][0] = (D[5][0]*Bi[0][0]+D[5][1]*Bi[1][0]+D[5][2]*Bi[2][0]+D[5][3]*Bi[3][0]+D[5][4]*Bi[4][0]+D[5][5]*Bi[5][0]); DBi[5][1] = (D[5][0]*Bi[0][1]+D[5][1]*Bi[1][1]+D[5][2]*Bi[2][1]+D[5][3]*Bi[3][1]+D[5][4]*Bi[4][1]+D[5][5]*Bi[5][1]); DBi[5][2] = (D[5][0]*Bi[0][2]+D[5][1]*Bi[1][2]+D[5][2]*Bi[2][2]+D[5][3]*Bi[3][2]+D[5][4]*Bi[4][2]+D[5][5]*Bi[5][2]); } } // loop over the elements again // (we only build the upper-triangular (block) matrix for (ni=0; ni<NE; ++ni) { // calculate element volume double Vi = m_Ve0[peli[ni]]; double wi = 0.25* Vi*node.Vi/ node.Vi; for (nj=ni; nj<NE; ++nj) { // calculate element volume double Vj = m_Ve0[peli[nj]]; double wj = 0.25* Vj / node.Vi; double wij = wi*wj; // We're ready to rock and roll! for (i=0; i<4; ++i) { double (&Bi)[6][3] = *(m_Be+(ni*4 + i)); int mi = ni*12+i*3; int j0 = (nj==ni?i:0); for (j=j0; j<4; ++j) { // calculate the Bi*D*Bj term double (&DBj)[6][3] = *(m_DB+(nj*4 + j)); int mj = nj*12+j*3; ke[mi ][mj ] += wij*(Bi[0][0]*DBj[0][0]+Bi[1][0]*DBj[1][0]+Bi[2][0]*DBj[2][0]+Bi[3][0]*DBj[3][0]+Bi[4][0]*DBj[4][0]+Bi[5][0]*DBj[5][0]); ke[mi ][mj+1] += wij*(Bi[0][0]*DBj[0][1]+Bi[1][0]*DBj[1][1]+Bi[2][0]*DBj[2][1]+Bi[3][0]*DBj[3][1]+Bi[4][0]*DBj[4][1]+Bi[5][0]*DBj[5][1]); ke[mi ][mj+2] += wij*(Bi[0][0]*DBj[0][2]+Bi[1][0]*DBj[1][2]+Bi[2][0]*DBj[2][2]+Bi[3][0]*DBj[3][2]+Bi[4][0]*DBj[4][2]+Bi[5][0]*DBj[5][2]); ke[mi+1][mj ] += wij*(Bi[0][1]*DBj[0][0]+Bi[1][1]*DBj[1][0]+Bi[2][1]*DBj[2][0]+Bi[3][1]*DBj[3][0]+Bi[4][1]*DBj[4][0]+Bi[5][1]*DBj[5][0]); ke[mi+1][mj+1] += wij*(Bi[0][1]*DBj[0][1]+Bi[1][1]*DBj[1][1]+Bi[2][1]*DBj[2][1]+Bi[3][1]*DBj[3][1]+Bi[4][1]*DBj[4][1]+Bi[5][1]*DBj[5][1]); ke[mi+1][mj+2] += wij*(Bi[0][1]*DBj[0][2]+Bi[1][1]*DBj[1][2]+Bi[2][1]*DBj[2][2]+Bi[3][1]*DBj[3][2]+Bi[4][1]*DBj[4][2]+Bi[5][1]*DBj[5][2]); ke[mi+2][mj ] += wij*(Bi[0][2]*DBj[0][0]+Bi[1][2]*DBj[1][0]+Bi[2][2]*DBj[2][0]+Bi[3][2]*DBj[3][0]+Bi[4][2]*DBj[4][0]+Bi[5][2]*DBj[5][0]); ke[mi+2][mj+1] += wij*(Bi[0][2]*DBj[0][1]+Bi[1][2]*DBj[1][1]+Bi[2][2]*DBj[2][1]+Bi[3][2]*DBj[3][1]+Bi[4][2]*DBj[4][1]+Bi[5][2]*DBj[5][1]); ke[mi+2][mj+2] += wij*(Bi[0][2]*DBj[0][2]+Bi[1][2]*DBj[1][2]+Bi[2][2]*DBj[2][2]+Bi[3][2]*DBj[3][2]+Bi[4][2]*DBj[4][2]+Bi[5][2]*DBj[5][2]); } } } } } //----------------------------------------------------------------------------- //! Calculates the element contribution to the global stiffness matrix void FEUT4Domain::ElementalStiffnessMatrix(FELinearSystem& LS) { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); // element stiffness matrix FEElementMatrix ke; vector<int> elm; // repeat over all solid elements int NE = (int)m_Elem.size(); for (int iel=0; iel<NE; ++iel) { FESolidElement& el = m_Elem[iel]; // create the element's stiffness matrix int ndof = 3*el.Nodes(); ke.resize(ndof, ndof); ke.zero(); // calculate the element stiffness matrix ElementStiffness(tp, iel, ke); // get the element equation numbers UnpackLM(el, elm); // assemble element matrix in global stiffness matrix ke.SetNodes(el.m_node); ke.SetIndices(elm); LS.Assemble(ke); } } //----------------------------------------------------------------------------- void FEUT4Domain::ElementStiffness(const FETimeInfo& tp, int iel, matrix &ke) { FESolidElement& el = Element(iel); // TODO: I need to figure out how to deal with incompressible materials // Incompressible materials require an additional dilatational // stiffness which is calculated differently from the geometric and // material stiffnesses. // TODO: I don't know if the comment above applies anymore // 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]; } //----------------------------------------------------------------------------- //! calculates element's geometrical stiffness component for integration point n void FEUT4Domain::ElementGeometricalStiffness(FESolidElement &el, matrix &ke) { vec3d G[FEElement::MAX_NODES]; // nr of nodes int neln = el.Nodes(); // nr of integration points int nint = el.GaussPoints(); // weights at gauss points const double *gw = el.GaussWeights(); // stiffness component for the initial stress component of stiffness matrix double kab; // calculate geometrical element stiffness matrix for (int n=0; n<nint; ++n) { // calculate jacobian double detJt = ShapeGradient(el, n, G)*gw[n]; // get the material point data FEMaterialPoint& mp = *el.GetMaterialPoint(n); FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>()); // element's Cauchy-stress tensor at gauss point n // s is the voight vector mat3ds s = pt.m_s; // we work with the deviatoric component only if (m_bdev) { s = s.dev()*m_alpha; } else { s = s*m_alpha; } for (int i = 0; i<neln; ++i) for (int j = i; j<neln; ++j) { kab = (G[i]*( s*G[j]) )*detJt; 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 FEUT4Domain::ElementMaterialStiffness(FESolidElement &el, matrix &ke) { // Get the current element's data const int nint = el.GaussPoints(); const int neln = el.Nodes(); const int ndof = 3*neln; // 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]; // 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 double detJt = ShapeGradient(el, n, G)*gw[n]; // setup the material point // NOTE: deformation gradient and determinant have already been evaluated in the stress routine FEMaterialPoint& mp = *el.GetMaterialPoint(n); FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>()); // Calculate the tangent tens4ds C = m_pMat->Tangent(mp); // Next, we need to subtract the volumetric contribution Cvol if (m_bdev) { // subtract the volumetric tensor from C; C = (C - Cvol(C, pt.m_s))*m_alpha; } else { C = C*m_alpha; } // extract the 'D' matrix 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 = i, j3 = i3; 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; } } } }
C++
3D
febiosoftware/FEBio
FEBioMech/FEElasticShellDomainOld.cpp
.cpp
24,136
819
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEElasticShellDomainOld.h" #include "FEElasticMaterial.h" #include "FEBodyForce.h" #include <FECore/log.h> #include <FECore/FEModel.h> #include <FECore/FEAnalysis.h> #include <FECore/FELinearSystem.h> #include <math.h> #include "FEBioMech.h" //----------------------------------------------------------------------------- FEElasticShellDomainOld::FEElasticShellDomainOld(FEModel* pfem) : FEShellDomainOld(pfem), FEElasticDomain(pfem), m_dofSU(pfem), m_dofSR(pfem), m_dofR(pfem), m_dof(pfem) { m_pMat = nullptr; // TODO: Can this be done in Init, since there is no error checking if (pfem) { m_dofSU.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT)); m_dofSR.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_DISPLACEMENT)); m_dofR.AddVariable(FEBioMech::GetVariableName(FEBioMech::RIGID_ROTATION)); } } //----------------------------------------------------------------------------- //! \todo do I really need this? FEElasticShellDomainOld& FEElasticShellDomainOld::operator = (FEElasticShellDomainOld& d) { m_Elem = d.m_Elem; m_pMesh = d.m_pMesh; return (*this); } //----------------------------------------------------------------------------- //! get total dof list const FEDofList& FEElasticShellDomainOld::GetDOFList() const { return m_dof; } //----------------------------------------------------------------------------- void FEElasticShellDomainOld::SetMaterial(FEMaterial* pmat) { FEDomain::SetMaterial(pmat); m_pMat = dynamic_cast<FESolidMaterial*>(pmat); } //----------------------------------------------------------------------------- bool FEElasticShellDomainOld::Init() { // initialize base class FEShellDomain::Init(); // error flag (set true on error) bool bmerr = false; // check for initially inverted shells for (int i=0; i<Elements(); ++i) { FEShellElementOld& el = ShellElement(i); int nint = el.GaussPoints(); for (int n=0; n<nint; ++n) { double J0 = detJ0(el, n); if (J0 <= 0) { feLog("**************************** E R R O R ****************************\n"); feLog("Negative jacobian detected at integration point %d of element %d\n", n+1, el.GetID()); feLog("Jacobian = %lg\n", J0); feLog("Did you use the right node numbering?\n"); feLog("Nodes:"); for (int l=0; l<el.Nodes(); ++l) { feLog("%d", el.m_node[l]+1); if (l+1 != el.Nodes()) feLog(","); else feLog("\n"); } feLog("*******************************************************************\n\n"); bmerr = true; } } } return (bmerr == false); } //----------------------------------------------------------------------------- void FEElasticShellDomainOld::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_dofSU[0]); node.set_active(m_dofSU[1]); node.set_active(m_dofSU[2]); } if (node.HasFlags(FENode::SHELL)) { node.set_active(m_dofSR[0]); node.set_active(m_dofSR[1]); node.set_active(m_dofSR[2]); } } } } //----------------------------------------------------------------------------- //! calculates covariant basis vectors at an integration point void FEElasticShellDomainOld::CoBaseVectors0(FEShellElementOld& el, int n, vec3d g[3]) { int i; int neln = el.Nodes(); // current nodal coordinates and directors vec3d r[FEElement::MAX_NODES], D[FEElement::MAX_NODES]; for (i = 0; i<neln; ++i) { FENode& ni = m_pMesh->Node(el.m_node[i]); r[i] = ni.m_r0; D[i] = el.m_D0[i]; } double eta = el.gt(n); double* Mr = el.Hr(n); double* Ms = el.Hs(n); double* M = el.H(n); // initialize covariant basis vectors g[0] = g[1] = g[2] = vec3d(0, 0, 0); for (i = 0; i<neln; ++i) { g[0] += (r[i] + D[i] * eta / 2)*Mr[i]; g[1] += (r[i] + D[i] * eta / 2)*Ms[i]; g[2] += D[i] * (M[i] / 2); } } //----------------------------------------------------------------------------- //! calculates contravariant basis vectors at an integration point void FEElasticShellDomainOld::ContraBaseVectors0(FEShellElementOld& el, int n, vec3d gcnt[3]) { vec3d gcov[3]; CoBaseVectors0(el, n, gcov); mat3d J = mat3d(gcov[0].x, gcov[1].x, gcov[2].x, gcov[0].y, gcov[1].y, gcov[2].y, gcov[0].z, gcov[1].z, gcov[2].z); mat3d Ji = J.inverse(); gcnt[0] = vec3d(Ji(0, 0), Ji(0, 1), Ji(0, 2)); gcnt[1] = vec3d(Ji(1, 0), Ji(1, 1), Ji(1, 2)); gcnt[2] = vec3d(Ji(2, 0), Ji(2, 1), Ji(2, 2)); } //----------------------------------------------------------------------------- double FEElasticShellDomainOld::invjac0(FEShellElementOld& el, double Ji[3][3], int n) { vec3d gcov[3]; CoBaseVectors0(el, n, gcov); mat3d J = mat3d(gcov[0].x, gcov[1].x, gcov[2].x, gcov[0].y, gcov[1].y, gcov[2].y, gcov[0].z, gcov[1].z, gcov[2].z); double det = J.det(); // make sure the determinant is positive if (det <= 0) throw NegativeJacobian(el.GetID(), n + 1, det); // calculate the inverse of the jacobian double deti = 1.0 / det; Ji[0][0] = deti*(J[1][1] * J[2][2] - J[1][2] * J[2][1]); Ji[1][0] = deti*(J[1][2] * J[2][0] - J[1][0] * J[2][2]); Ji[2][0] = deti*(J[1][0] * J[2][1] - J[1][1] * J[2][0]); Ji[0][1] = deti*(J[0][2] * J[2][1] - J[0][1] * J[2][2]); Ji[1][1] = deti*(J[0][0] * J[2][2] - J[0][2] * J[2][0]); Ji[2][1] = deti*(J[0][1] * J[2][0] - J[0][0] * J[2][1]); Ji[0][2] = deti*(J[0][1] * J[1][2] - J[1][1] * J[0][2]); Ji[1][2] = deti*(J[0][2] * J[1][0] - J[0][0] * J[1][2]); Ji[2][2] = deti*(J[0][0] * J[1][1] - J[0][1] * J[1][0]); return det; } //----------------------------------------------------------------------------- //! Calculate jacobian with respect to reference frame double FEElasticShellDomainOld::detJ0(FEShellElementOld &el, int n) { vec3d gcov[3]; CoBaseVectors0(el, n, gcov); mat3d J = mat3d(gcov[0].x, gcov[1].x, gcov[2].x, gcov[0].y, gcov[1].y, gcov[2].y, gcov[0].z, gcov[1].z, gcov[2].z); return J.det(); } //----------------------------------------------------------------------------- //! calculates covariant basis vectors at an integration point void FEElasticShellDomainOld::CoBaseVectors(FEShellElementOld& el, int n, vec3d g[3]) { int i; int neln = el.Nodes(); // current nodal coordinates and directors vec3d r[FEElement::MAX_NODES], D[FEElement::MAX_NODES]; for (i=0; i<neln; ++i) { FENode& ni = m_pMesh->Node(el.m_node[i]); r[i] = ni.m_rt; D[i] = el.m_D0[i] + ni.get_vec3d(m_dofSR[0], m_dofSR[1], m_dofSR[2]); } double eta = el.gt(n); double* Mr = el.Hr(n); double* Ms = el.Hs(n); double* M = el.H(n); // initialize covariant basis vectors g[0] = g[1] = g[2] = vec3d(0,0,0); for (i=0; i<neln; ++i) { g[0] += (r[i] + D[i]*eta/2)*Mr[i]; g[1] += (r[i] + D[i]*eta/2)*Ms[i]; g[2] += D[i]*(M[i]/2); } } //----------------------------------------------------------------------------- //! calculates contravariant basis vectors at an integration point void FEElasticShellDomainOld::ContraBaseVectors(FEShellElementOld& el, int n, vec3d gcnt[3]) { vec3d gcov[3]; CoBaseVectors(el, n, gcov); mat3d J = mat3d(gcov[0].x, gcov[1].x, gcov[2].x, gcov[0].y, gcov[1].y, gcov[2].y, gcov[0].z, gcov[1].z, gcov[2].z); mat3d Ji = J.inverse(); gcnt[0] = vec3d(Ji(0,0),Ji(0,1),Ji(0,2)); gcnt[1] = vec3d(Ji(1,0),Ji(1,1),Ji(1,2)); gcnt[2] = vec3d(Ji(2,0),Ji(2,1),Ji(2,2)); } //----------------------------------------------------------------------------- // jacobian with respect to current frame double FEElasticShellDomainOld::detJ(FEShellElementOld& el, int n) { vec3d gcov[3]; CoBaseVectors(el, n, gcov); mat3d J = mat3d(gcov[0].x, gcov[1].x, gcov[2].x, gcov[0].y, gcov[1].y, gcov[2].y, gcov[0].z, gcov[1].z, gcov[2].z); return J.det(); } //----------------------------------------------------------------------------- double FEElasticShellDomainOld::defgrad(FEShellElementOld& el, mat3d& F, int n) { vec3d gcov[3], Gcnt[3]; CoBaseVectors(el, n, gcov); ContraBaseVectors0(el, n, Gcnt); F = (gcov[0] & Gcnt[0]) + (gcov[1] & Gcnt[1]) + (gcov[2] & Gcnt[2]); double J = F.det(); if (J <= 0) throw NegativeJacobian(el.GetID(), n, J, &el); return J; } //----------------------------------------------------------------------------- //! Calculate the inverse jacobian with respect to the current frame at //! integration point n. The inverse jacobian is return in Ji. The return value //! is the determinant of the jacobian (not the inverse!) double FEElasticShellDomainOld::invjact(FEShellElementOld& el, double Ji[3][3], int n) { vec3d gcov[3]; CoBaseVectors(el, n, gcov); mat3d J = mat3d(gcov[0].x, gcov[1].x, gcov[2].x, gcov[0].y, gcov[1].y, gcov[2].y, gcov[0].z, gcov[1].z, gcov[2].z); double det = J.det(); // make sure the determinant is positive if (det <= 0) throw NegativeJacobian(el.GetID(), n+1, det); // calculate the inverse of the jacobian double deti = 1.0 / det; Ji[0][0] = deti*(J[1][1]*J[2][2] - J[1][2]*J[2][1]); Ji[1][0] = deti*(J[1][2]*J[2][0] - J[1][0]*J[2][2]); Ji[2][0] = deti*(J[1][0]*J[2][1] - J[1][1]*J[2][0]); Ji[0][1] = deti*(J[0][2]*J[2][1] - J[0][1]*J[2][2]); Ji[1][1] = deti*(J[0][0]*J[2][2] - J[0][2]*J[2][0]); Ji[2][1] = deti*(J[0][1]*J[2][0] - J[0][0]*J[2][1]); Ji[0][2] = deti*(J[0][1]*J[1][2] - J[1][1]*J[0][2]); Ji[1][2] = deti*(J[0][2]*J[1][0] - J[0][0]*J[1][2]); Ji[2][2] = deti*(J[0][0]*J[1][1] - J[0][1]*J[1][0]); return det; } //----------------------------------------------------------------------------- // Calculates the forces due to the stress void FEElasticShellDomainOld::InternalForces(FEGlobalVector& R) { // element force vector vector<double> fe; vector<int> lm; int NS = (int)m_Elem.size(); for (int i=0; i<NS; ++i) { // get the element FEShellElementOld& 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); } } //----------------------------------------------------------------------------- //! 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 FEElasticShellDomainOld::ElementInternalForce(FEShellElementOld& el, vector<double>& fe) { int i, n; // jacobian matrix determinant double detJt; const double* Mr, *Ms, *M; int nint = el.GaussPoints(); int neln = el.Nodes(); double* gw = el.GaussWeights(); double eta; vec3d gcnt[3]; // repeat for all integration points for (n=0; n<nint; ++n) { FEElasticMaterialPoint& pt = *(el.GetMaterialPoint(n)->ExtractData<FEElasticMaterialPoint>()); // calculate the jacobian detJt = detJ(el, n); detJt *= gw[n]; // get the stress vector for this integration point mat3ds& s = pt.m_s; eta = el.gt(n); Mr = el.Hr(n); Ms = el.Hs(n); M = el.H(n); ContraBaseVectors(el, n, gcnt); for (i=0; i<neln; ++i) { vec3d gradM = gcnt[0]*Mr[i] + gcnt[1]*Ms[i]; vec3d gradP = (gradM*eta + gcnt[2]*M[i])/2; vec3d fu = s*gradM; vec3d fd = s*gradP; // calculate internal force // the '-' sign is so that the internal forces get subtracted // from the global residual vector fe[6*i ] -= fu.x*detJt; fe[6*i+1] -= fu.y*detJt; fe[6*i+2] -= fu.z*detJt; fe[6*i+3] -= fd.x*detJt; fe[6*i+4] -= fd.y*detJt; fe[6*i+5] -= fd.z*detJt; } } } //----------------------------------------------------------------------------- void FEElasticShellDomainOld::BodyForce(FEGlobalVector& R, FEBodyForce& BF) { // element force vector vector<double> fe; vector<int> lm; int NS = (int)m_Elem.size(); for (int i=0; i<NS; ++i) { // get the element FEShellElementOld& 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); } } //----------------------------------------------------------------------------- //! Calculates element body forces for shells void FEElasticShellDomainOld::ElementBodyForce(FEBodyForce& BF, FEShellElementOld& 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); FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // calculate density in current configuration double dens = m_pMat->Density(mp)/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 = BF.force(mp); for (int i=0; i<neln; ++i) { vec3d fu = f*(dens*M[i]); vec3d fd = fu*(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 FEElasticShellDomainOld::StiffnessMatrix(FELinearSystem& LS) { int NS = (int)m_Elem.size(); for (int iel=0; iel<NS; ++iel) { FEShellElement& el = m_Elem[iel]; // get the elements material FEMaterial* pmat = m_pMat; // 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); } } //----------------------------------------------------------------------------- //! Calculates the shell element stiffness matrix void FEElasticShellDomainOld::ElementStiffness(int iel, matrix& ke) { FEShellElementOld& 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(); const double* Mr, *Ms, *M; vec3d gradM[FEElement::MAX_NODES], gradP[FEElement::MAX_NODES]; // jacobian matrix determinant double detJt; // weights at gauss points const double *gw = el.GaussWeights(); double eta; vec3d gcnt[3]; // calculate element stiffness matrix ke.zero(); for (n=0; n<nint; ++n) { FEMaterialPoint& mp = *(el.GetMaterialPoint(n)); FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>()); // calculate the jacobian detJt = detJ(el, n); detJt *= gw[n]; // get the stress and elasticity for this integration point mat3ds s = pt.m_s; tens4ds C = m_pMat->Tangent(mp); eta = el.gt(n); Mr = el.Hr(n); Ms = el.Hs(n); M = el.H(n); ContraBaseVectors(el, n, gcnt); // ------------ constitutive component -------------- // setup the material point for (i=0; i<neln; ++i) { gradM[i] = gcnt[0]*Mr[i] + gcnt[1]*Ms[i]; gradP[i] = (gradM[i]*eta + gcnt[2]*M[i])/2; } for (i=0, i6=0; i<neln; ++i, i6 += 6) { for (j=0, j6 = 0; j<neln; ++j, j6 += 6) { mat3d Kuu = vdotTdotv(gradM[i], C, gradM[j]); mat3d Kud = vdotTdotv(gradM[i], C, gradP[j]); mat3d Kdu = vdotTdotv(gradP[i], C, gradM[j]); mat3d Kdd = vdotTdotv(gradP[i], C, gradP[j]); ke[i6 ][j6 ] += Kuu(0,0)*detJt; ke[i6 ][j6+1] += Kuu(0,1)*detJt; ke[i6 ][j6+2] += Kuu(0,2)*detJt; ke[i6+1][j6 ] += Kuu(1,0)*detJt; ke[i6+1][j6+1] += Kuu(1,1)*detJt; ke[i6+1][j6+2] += Kuu(1,2)*detJt; ke[i6+2][j6 ] += Kuu(2,0)*detJt; ke[i6+2][j6+1] += Kuu(2,1)*detJt; ke[i6+2][j6+2] += Kuu(2,2)*detJt; ke[i6 ][j6+3] += Kud(0,0)*detJt; ke[i6 ][j6+4] += Kud(0,1)*detJt; ke[i6 ][j6+5] += Kud(0,2)*detJt; ke[i6+1][j6+3] += Kud(1,0)*detJt; ke[i6+1][j6+4] += Kud(1,1)*detJt; ke[i6+1][j6+5] += Kud(1,2)*detJt; ke[i6+2][j6+3] += Kud(2,0)*detJt; ke[i6+2][j6+4] += Kud(2,1)*detJt; ke[i6+2][j6+5] += Kud(2,2)*detJt; ke[i6+3][j6 ] += Kdu(0,0)*detJt; ke[i6+3][j6+1] += Kdu(0,1)*detJt; ke[i6+3][j6+2] += Kdu(0,2)*detJt; ke[i6+4][j6 ] += Kdu(1,0)*detJt; ke[i6+4][j6+1] += Kdu(1,1)*detJt; ke[i6+4][j6+2] += Kdu(1,2)*detJt; ke[i6+5][j6 ] += Kdu(2,0)*detJt; ke[i6+5][j6+1] += Kdu(2,1)*detJt; ke[i6+5][j6+2] += Kdu(2,2)*detJt; ke[i6+3][j6+3] += Kdd(0,0)*detJt; ke[i6+3][j6+4] += Kdd(0,1)*detJt; ke[i6+3][j6+5] += Kdd(0,2)*detJt; ke[i6+4][j6+3] += Kdd(1,0)*detJt; ke[i6+4][j6+4] += Kdd(1,1)*detJt; ke[i6+4][j6+5] += Kdd(1,2)*detJt; ke[i6+5][j6+3] += Kdd(2,0)*detJt; ke[i6+5][j6+4] += Kdd(2,1)*detJt; ke[i6+5][j6+5] += Kdd(2,2)*detJt; } } // ------------ initial stress component -------------- for (i=0; i<neln; ++i) for (j=0; j<neln; ++j) { double Kuu = gradM[i]*(s*gradM[j]); double Kud = gradM[i]*(s*gradP[j]); double Kdu = gradP[i]*(s*gradM[j]); double Kdd = gradP[i]*(s*gradP[j]); // the u-u component ke[6*i ][6*j ] += Kuu*detJt; ke[6*i+1][6*j+1] += Kuu*detJt; ke[6*i+2][6*j+2] += Kuu*detJt; // the u-d component ke[6*i ][6*j+3] += Kud*detJt; ke[6*i+1][6*j+4] += Kud*detJt; ke[6*i+2][6*j+5] += Kud*detJt; // the d-u component ke[6*i+3][6*j ] += Kdu*detJt; ke[6*i+4][6*j+1] += Kdu*detJt; ke[6*i+5][6*j+2] += Kdu*detJt; // the d-d component ke[6*i+3][6*j+3] += Kdd*detJt; ke[6*i+4][6*j+4] += Kdd*detJt; ke[6*i+5][6*j+5] += Kdd*detJt; } } // end loop over gauss-points } //----------------------------------------------------------------------------- //! Calculates body forces for shells void FEElasticShellDomainOld::ElementBodyForce(FEModel& fem, FEShellElementOld& 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 dens = m_pMat->Density(mp)/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]); vec3d fd = fu*(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 FEElasticShellDomainOld::Update(const FETimeInfo& tp) { FEMesh& mesh = *GetMesh(); vec3d r0[FEElement::MAX_NODES], rt[FEElement::MAX_NODES]; int n; for (int i=0; i<(int) m_Elem.size(); ++i) { // get the solid element FEShellElementOld& el = m_Elem[i]; // get the number of integration points int nint = el.GaussPoints(); // number of nodes int neln = el.Nodes(); // nodal coordinates for (int j=0; j<neln; ++j) { r0[j] = mesh.Node(el.m_node[j]).m_r0; rt[j] = mesh.Node(el.m_node[j]).m_rt; } // update shell thickness for (int j=0; j<neln; ++j) { FENode& nj = mesh.Node(el.m_node[j]); vec3d D = el.m_D0[j] + nj.get_vec3d(m_dofSU[0], m_dofSU[1], m_dofSU[2]); double h = D.norm(); el.m_ht[j] = h; } // loop over the integration points and calculate // the stress at the integration point for (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 = el.Evaluate(r0, n); mp.m_rt = el.Evaluate(rt, n); // get the deformation gradient and determinant pt.m_J = defgrad(el, pt.m_F, n); // calculate the stress at this material point pt.m_s = m_pMat->Stress(mp); } } } //----------------------------------------------------------------------------- //! 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 FEElasticShellDomainOld::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_dofSU[0]]; lm[6*i+1] = id[m_dofSU[1]]; lm[6*i+2] = id[m_dofSU[2]]; // next the rotational dofs lm[6*i+3] = id[m_dofSR[0]]; lm[6*i+4] = id[m_dofSR[1]]; lm[6*i+5] = id[m_dofSR[2]]; // rigid rotational dofs lm[6*N + 3*i ] = id[m_dofR[0]]; lm[6*N + 3*i+1] = id[m_dofR[1]]; lm[6*N + 3*i+2] = id[m_dofR[2]]; } }
C++
3D
febiosoftware/FEBio
FEBioMech/FEUDGHexDomain.cpp
.cpp
25,609
743
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEUDGHexDomain.h" #include "FEElasticMaterial.h" #include <FECore/FEModel.h> #include <FECore/FELinearSystem.h> //----------------------------------------------------------------------------- BEGIN_FECORE_CLASS(FEUDGHexDomain, FEElasticSolidDomain) ADD_PARAMETER(m_hg, "hg"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEUDGHexDomain::FEUDGHexDomain(FEModel* pfem) : FEElasticSolidDomain(pfem) { m_hg = 1.0; } //----------------------------------------------------------------------------- //! Set the hourglass parameter void FEUDGHexDomain::SetHourGlassParameter(double hg) { m_hg = hg; } //----------------------------------------------------------------------------- bool FEUDGHexDomain::Create(int nelems, FE_Element_Spec spec) { // make sure these solid, hex8 elements are requested if (spec.eclass == FE_Element_Class::FE_ELEM_INVALID_CLASS) spec.eclass = FE_Element_Class::FE_ELEM_SOLID; else if (spec.eclass != FE_Element_Class::FE_ELEM_SOLID) return false; if (spec.eshape == FE_Element_Shape::FE_ELEM_INVALID_SHAPE) spec.eshape = FE_Element_Shape::ET_HEX8; else if (spec.eshape != FE_Element_Shape::ET_HEX8) return false; // we need to enforce HEX8G1 integration rule spec.etype = FE_HEX8G1; // now allocate the domain return FESolidDomain::Create(nelems, spec); } //----------------------------------------------------------------------------- void FEUDGHexDomain::InternalForces(FEGlobalVector& R) { int NE = (int)m_Elem.size(); #pragma omp parallel for for (int i=0; i<NE; ++i) { // get the element FESolidElement& el = m_Elem[i]; // get the element force vector and initialize it to zero int ndof = 3*el.Nodes(); // element force vector vector<double> fe; fe.assign(ndof, 0); // calculate internal force vector UDGInternalForces(el, fe); // get the element's LM vector vector<int> lm; 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 enhanced strain //! solid elements. void FEUDGHexDomain::UDGInternalForces(FESolidElement& el, vector<double>& fe) { // get the stress data FEMaterialPoint& mp = *el.GetMaterialPoint(0); FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>()); mat3ds& s = pt.m_s; // calculate the average cartesian derivatives double GX[8], GY[8], GZ[8]; AvgCartDerivs(el, GX, GY, GZ); // calculate average deformation gradient Fbar mat3d Fb; AvgDefGrad(el, Fb, GX, GY, GZ); // calculate the transposed inverse of Fbar mat3d Fti = Fb.transinv(); // calculate current element volume double ve = HexVolume(el, 1); // current averaged shape derivatives double Gx, Gy, Gz; // calculate the internal force for (int i=0; i<8; ++i) { Gx = Fti(0,0)*GX[i]+Fti(0,1)*GY[i]+Fti(0,2)*GZ[i]; Gy = Fti(1,0)*GX[i]+Fti(1,1)*GY[i]+Fti(1,2)*GZ[i]; Gz = Fti(2,0)*GX[i]+Fti(2,1)*GY[i]+Fti(2,2)*GZ[i]; fe[3*i ] -= ve*(Gx*s.xx() + Gy*s.xy() + Gz*s.xz()); fe[3*i+1] -= ve*(Gx*s.xy() + Gy*s.yy() + Gz*s.yz()); fe[3*i+2] -= ve*(Gx*s.xz() + Gy*s.yz() + Gz*s.zz()); } // add hourglass forces UDGHourglassForces(el, fe); } //----------------------------------------------------------------------------- //! calculates the hourglass forces void FEUDGHexDomain::UDGHourglassForces(FESolidElement &el, vector<double> &fe) { int i; const double h4[8] = { 1,-1, 1,-1, 1,-1, 1,-1 }; const double h5[8] = { 1,-1,-1, 1,-1, 1, 1,-1 }; const double h6[8] = { 1, 1,-1,-1,-1,-1, 1, 1 }; const double h7[8] = {-1, 1,-1, 1, 1,-1, 1,-1 }; int neln = el.Nodes(); vec3d r0[8], rt[8]; for (i=0; i<neln; ++i) { r0[i] = m_pMesh->Node(el.m_node[i]).m_r0; rt[i] = m_pMesh->Node(el.m_node[i]).m_rt; } double x4 = 0, x5 = 0, x6 = 0, x7 = 0; double y4 = 0, y5 = 0, y6 = 0, y7 = 0; double z4 = 0, z5 = 0, z6 = 0, z7 = 0; double X4 = 0, X5 = 0, X6 = 0, X7 = 0; double Y4 = 0, Y5 = 0, Y6 = 0, Y7 = 0; double Z4 = 0, Z5 = 0, Z6 = 0, Z7 = 0; for (i=0; i<8; ++i) { X4 += h4[i]*r0[i].x; Y4 += h4[i]*r0[i].y; Z4 += h4[i]*r0[i].z; X5 += h5[i]*r0[i].x; Y5 += h5[i]*r0[i].y; Z5 += h5[i]*r0[i].z; X6 += h6[i]*r0[i].x; Y6 += h6[i]*r0[i].y; Z6 += h6[i]*r0[i].z; X7 += h7[i]*r0[i].x; Y7 += h7[i]*r0[i].y; Z7 += h7[i]*r0[i].z; x4 += h4[i]*rt[i].x; y4 += h4[i]*rt[i].y; z4 += h4[i]*rt[i].z; x5 += h5[i]*rt[i].x; y5 += h5[i]*rt[i].y; z5 += h5[i]*rt[i].z; x6 += h6[i]*rt[i].x; y6 += h6[i]*rt[i].y; z6 += h6[i]*rt[i].z; x7 += h7[i]*rt[i].x; y7 += h7[i]*rt[i].y; z7 += h7[i]*rt[i].z; } double GX[8], GY[8], GZ[8]; AvgCartDerivs(el, GX, GY, GZ); mat3d F; AvgDefGrad(el, F, GX, GY, GZ); double u4 = 0, u5 = 0, u6 = 0, u7 = 0; double v4 = 0, v5 = 0, v6 = 0, v7 = 0; double w4 = 0, w5 = 0, w6 = 0, w7 = 0; u4 = x4 - (F[0][0]*X4 + F[0][1]*Y4 + F[0][2]*Z4); v4 = y4 - (F[1][0]*X4 + F[1][1]*Y4 + F[1][2]*Z4); w4 = z4 - (F[2][0]*X4 + F[2][1]*Y4 + F[2][2]*Z4); u5 = x5 - (F[0][0]*X5 + F[0][1]*Y5 + F[0][2]*Z5); v5 = y5 - (F[1][0]*X5 + F[1][1]*Y5 + F[1][2]*Z5); w5 = z5 - (F[2][0]*X5 + F[2][1]*Y5 + F[2][2]*Z5); u6 = x6 - (F[0][0]*X6 + F[0][1]*Y6 + F[0][2]*Z6); v6 = y6 - (F[1][0]*X6 + F[1][1]*Y6 + F[1][2]*Z6); w6 = z6 - (F[2][0]*X6 + F[2][1]*Y6 + F[2][2]*Z6); u7 = x7 - (F[0][0]*X7 + F[0][1]*Y7 + F[0][2]*Z7); v7 = y7 - (F[1][0]*X7 + F[1][1]*Y7 + F[1][2]*Z7); w7 = z7 - (F[2][0]*X7 + F[2][1]*Y7 + F[2][2]*Z7); double g4[8] = {0}, g5[8] = {0}, g6[8] = {0}, g7[8] = {0}; for (i=0; i<8; ++i) { g4[i] = h4[i] - (GX[i]*X4 + GY[i]*Y4 + GZ[i]*Z4); g5[i] = h5[i] - (GX[i]*X5 + GY[i]*Y5 + GZ[i]*Z5); g6[i] = h6[i] - (GX[i]*X6 + GY[i]*Y6 + GZ[i]*Z6); g7[i] = h7[i] - (GX[i]*X7 + GY[i]*Y7 + GZ[i]*Z7); } // calculate hourglass forces for (i=0; i<8; ++i) { fe[3*i ] -= m_hg*(g4[i]*u4 + g5[i]*u5 + g6[i]*u6 + g7[i]*u7); fe[3*i+1] -= m_hg*(g4[i]*v4 + g5[i]*v5 + g6[i]*v6 + g7[i]*v7); fe[3*i+2] -= m_hg*(g4[i]*w4 + g5[i]*w5 + g6[i]*w6 + g7[i]*w7); } } void FEUDGHexDomain::StiffnessMatrix(FELinearSystem& LS) { FEModel& fem = *GetFEModel(); vector<int> lm; // repeat over all solid elements int NE = (int)m_Elem.size(); for (int iel=0; iel<NE; ++iel) { FESolidElement& el = m_Elem[iel]; // element stiffness matrix FEElementMatrix ke(el); // create the element's stiffness matrix int ndof = 3*el.Nodes(); ke.resize(ndof, ndof); ke.zero(); // calculate material stiffness UDGMaterialStiffness(el, ke); // calculate geometrical stiffness UDGGeometricalStiffness(el, ke); // add hourglass stiffness UDGHourglassStiffness(fem, el, ke); // assign symmetic parts // TODO: Can this be omitted by changing the Assemble routine so that it only // grabs elements from the upper diagonal matrix? for (int i=0; i<ndof; ++i) for (int j=i+1; j<ndof; ++j) ke[j][i] = ke[i][j]; // get the element's LM vector UnpackLM(el, lm); ke.SetIndices(lm); // assemble element matrix in global stiffness matrix LS.Assemble(ke); } } //----------------------------------------------------------------------------- //! calculates the hourglass stiffness for UDG hex elements void FEUDGHexDomain::UDGHourglassStiffness(FEModel& fem, FESolidElement& el, matrix& ke) { int i, j; const double h4[8] = { 1,-1, 1,-1, 1,-1, 1,-1 }; const double h5[8] = { 1,-1,-1, 1,-1, 1, 1,-1 }; const double h6[8] = { 1, 1,-1,-1,-1,-1, 1, 1 }; const double h7[8] = {-1, 1,-1, 1, 1,-1, 1,-1 }; int neln = el.Nodes(); vec3d r0[8], rt[8]; for (i=0; i<neln; ++i) { r0[i] = m_pMesh->Node(el.m_node[i]).m_r0; rt[i] = m_pMesh->Node(el.m_node[i]).m_rt; } double x4 = 0, x5 = 0, x6 = 0, x7 = 0; double y4 = 0, y5 = 0, y6 = 0, y7 = 0; double z4 = 0, z5 = 0, z6 = 0, z7 = 0; double X4 = 0, X5 = 0, X6 = 0, X7 = 0; double Y4 = 0, Y5 = 0, Y6 = 0, Y7 = 0; double Z4 = 0, Z5 = 0, Z6 = 0, Z7 = 0; for (i=0; i<8; ++i) { X4 += h4[i]*r0[i].x; Y4 += h4[i]*r0[i].y; Z4 += h4[i]*r0[i].z; X5 += h5[i]*r0[i].x; Y5 += h5[i]*r0[i].y; Z5 += h5[i]*r0[i].z; X6 += h6[i]*r0[i].x; Y6 += h6[i]*r0[i].y; Z6 += h6[i]*r0[i].z; X7 += h7[i]*r0[i].x; Y7 += h7[i]*r0[i].y; Z7 += h7[i]*r0[i].z; x4 += h4[i]*rt[i].x; y4 += h4[i]*rt[i].y; z4 += h4[i]*rt[i].z; x5 += h5[i]*rt[i].x; y5 += h5[i]*rt[i].y; z5 += h5[i]*rt[i].z; x6 += h6[i]*rt[i].x; y6 += h6[i]*rt[i].y; z6 += h6[i]*rt[i].z; x7 += h7[i]*rt[i].x; y7 += h7[i]*rt[i].y; z7 += h7[i]*rt[i].z; } FEMesh& mesh = *GetMesh(); double GX[8], GY[8], GZ[8]; AvgCartDerivs(el, GX, GY, GZ); double g4[8] = {0}, g5[8] = {0}, g6[8] = {0}, g7[8] = {0}; for (i=0; i<8; ++i) { g4[i] = h4[i] - (GX[i]*X4 + GY[i]*Y4 + GZ[i]*Z4); g5[i] = h5[i] - (GX[i]*X5 + GY[i]*Y5 + GZ[i]*Z5); g6[i] = h6[i] - (GX[i]*X6 + GY[i]*Y6 + GZ[i]*Z6); g7[i] = h7[i] - (GX[i]*X7 + GY[i]*Y7 + GZ[i]*Z7); } // calculate hourglass stiffness for (i=0; i<8; ++i) { for (j=i; j<8; ++j) { double kab = m_hg*(g4[i]*g4[j] + g5[i]*g5[j] + g6[i]*g6[j] + g7[i]*g7[j]); ke[3*i ][3*j ] += kab; ke[3*i+1][3*j+1] += kab; ke[3*i+2][3*j+2] += kab; } } } //----------------------------------------------------------------------------- void FEUDGHexDomain::UDGGeometricalStiffness(FESolidElement& el, matrix& ke) { int i, j; // stiffness component for the initial stress component of stiffness matrix double kab; // get the material point data FEMaterialPoint& mp = *el.GetMaterialPoint(0); FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>()); // element's Cauchy-stress tensor at gauss point n // s is the voight vector mat3ds& s = pt.m_s; FEMesh& mesh = *GetMesh(); // calculate the average cartesian derivatives double GX[8], GY[8], GZ[8]; AvgCartDerivs(el, GX, GY, GZ); // calculate average deformation gradient Fbar mat3d Fb; AvgDefGrad(el, Fb, GX, GY, GZ); // calculate the transposed inverse of Fbar mat3d Fti = Fb.transinv(); // calculate current element volume double ve = HexVolume(el, 1); // current averaged shape derivatives double Gx[8], Gy[8], Gz[8]; for (i=0; i<8; ++i) { Gx[i] = Fti(0,0)*GX[i]+Fti(0,1)*GY[i]+Fti(0,2)*GZ[i]; Gy[i] = Fti(1,0)*GX[i]+Fti(1,1)*GY[i]+Fti(1,2)*GZ[i]; Gz[i] = Fti(2,0)*GX[i]+Fti(2,1)*GY[i]+Fti(2,2)*GZ[i]; } for (i=0; i<8; ++i) for (j=i; j<8; ++j) { kab = (Gx[i]*(s.xx()*Gx[j]+s.xy()*Gy[j]+s.xz()*Gz[j]) + Gy[i]*(s.xy()*Gx[j]+s.yy()*Gy[j]+s.yz()*Gz[j]) + Gz[i]*(s.xz()*Gx[j]+s.yz()*Gy[j]+s.zz()*Gz[j]))*ve; ke[3*i ][3*j ] += kab; ke[3*i+1][3*j+1] += kab; ke[3*i+2][3*j+2] += kab; } } //----------------------------------------------------------------------------- void FEUDGHexDomain::UDGMaterialStiffness(FESolidElement &el, matrix &ke) { // make sure we have the right element type assert(el.Type() == FE_HEX8G1); int i, i3, j, j3; // Get the current element's data const int neln = el.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]; FEMesh& mesh = *GetMesh(); // calculate the average cartesian derivatives double GX[8], GY[8], GZ[8]; AvgCartDerivs(el, GX, GY, GZ); // calculate average deformation gradient Fbar mat3d Fb; AvgDefGrad(el, Fb, GX, GY, GZ); // calculate the transposed inverse of Fbar mat3d Fti = Fb.transinv(); // calculate current element volume double ve = HexVolume(el, 1); // current averaged shape derivatives double Gx[8], Gy[8], Gz[8]; for (i=0; i<8; ++i) { Gx[i] = Fti(0,0)*GX[i]+Fti(0,1)*GY[i]+Fti(0,2)*GZ[i]; Gy[i] = Fti(1,0)*GX[i]+Fti(1,1)*GY[i]+Fti(1,2)*GZ[i]; Gz[i] = Fti(2,0)*GX[i]+Fti(2,1)*GY[i]+Fti(2,2)*GZ[i]; } // setup the material point // NOTE: deformation gradient and determinant have already been evaluated in the stress routine FEMaterialPoint& mp = *el.GetMaterialPoint(0); FEElasticMaterialPoint& pt = *(mp.ExtractData<FEElasticMaterialPoint>()); // get the 'D' matrix tens4ds C = m_pMat->Tangent(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 (i=0, i3=0; i<neln; ++i, i3 += 3) { Gxi = Gx[i]; Gyi = Gy[i]; Gzi = Gz[i]; for (j=i, j3 = i3; j<neln; ++j, j3 += 3) { Gxj = Gx[j]; Gyj = Gy[j]; Gzj = Gz[j]; // 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] )*ve; ke[i3 ][j3+1] += (Gxi*DBL[0][1] + Gyi*DBL[3][1] + Gzi*DBL[5][1] )*ve; ke[i3 ][j3+2] += (Gxi*DBL[0][2] + Gyi*DBL[3][2] + Gzi*DBL[5][2] )*ve; ke[i3+1][j3 ] += (Gyi*DBL[1][0] + Gxi*DBL[3][0] + Gzi*DBL[4][0] )*ve; ke[i3+1][j3+1] += (Gyi*DBL[1][1] + Gxi*DBL[3][1] + Gzi*DBL[4][1] )*ve; ke[i3+1][j3+2] += (Gyi*DBL[1][2] + Gxi*DBL[3][2] + Gzi*DBL[4][2] )*ve; ke[i3+2][j3 ] += (Gzi*DBL[2][0] + Gyi*DBL[4][0] + Gxi*DBL[5][0] )*ve; ke[i3+2][j3+1] += (Gzi*DBL[2][1] + Gyi*DBL[4][1] + Gxi*DBL[5][1] )*ve; ke[i3+2][j3+2] += (Gzi*DBL[2][2] + Gyi*DBL[4][2] + Gxi*DBL[5][2] )*ve; } } } //----------------------------------------------------------------------------- void FEUDGHexDomain::Update(const FETimeInfo& tp) { int nint, neln; double* gw; vec3d r0[8], rt[8]; for (int i=0; i<(int) m_Elem.size(); ++i) { // get the solid element FESolidElement& el = m_Elem[i]; // get the number of integration points nint = el.GaussPoints(); // number of nodes neln = el.Nodes(); // nodal coordinates for (int j=0; j<neln; ++j) { r0[j] = m_pMesh->Node(el.m_node[j]).m_r0; rt[j] = m_pMesh->Node(el.m_node[j]).m_rt; } // get the integration weights gw = el.GaussWeights(); // for the enhanced strain hex we need a slightly different procedure // for calculating the element's stress. For this element, the stress // is evaluated using an average deformation gradient. // get the material point data FEMaterialPoint& mp = *el.GetMaterialPoint(0); 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 = el.Evaluate(r0, 0); mp.m_rt = el.Evaluate(rt, 0); // get the average cartesian derivatives double GX[8], GY[8], GZ[8]; AvgCartDerivs(el, GX, GY, GZ); // get the average deformation gradient and determinant AvgDefGrad(el, pt.m_F, GX, GY, GZ); pt.m_J = pt.m_F.det(); // calculate the stress at this material point pt.m_s = m_pMat->Stress(mp); } } //----------------------------------------------------------------------------- //! Calculates the average Cartesian derivatives //! Note that we assume that the GX, GY and GX contain the averaged //! Cartesian derivatives void FEUDGHexDomain::AvgDefGrad(FESolidElement& el, mat3d& F, double GX[8], double GY[8], double GZ[8]) { vec3d rt[8]; for (int j=0; j<8; ++j) rt[j] = m_pMesh->Node(el.m_node[j]).m_rt; F.zero(); for (int i=0; i<8; ++i) { F[0][0] += rt[i].x*GX[i]; F[0][1] += rt[i].x*GY[i]; F[0][2] += rt[i].x*GZ[i]; F[1][0] += rt[i].y*GX[i]; F[1][1] += rt[i].y*GY[i]; F[1][2] += rt[i].y*GZ[i]; F[2][0] += rt[i].z*GX[i]; F[2][1] += rt[i].z*GY[i]; F[2][2] += rt[i].z*GZ[i]; } } //----------------------------------------------------------------------------- //! Calculates the average Cartesian derivatives void FEUDGHexDomain::AvgCartDerivs(FESolidElement& el, double GX[8], double GY[8], double GZ[8], int nstate) { // get the nodal coordinates int neln = el.Nodes(); vec3d r[8]; if (nstate == 0) { for (int i=0; i<neln; ++i) r[i] = m_pMesh->Node(el.m_node[i]).m_r0; } else { for (int i=0; i<neln; ++i) r[i] = m_pMesh->Node(el.m_node[i]).m_rt; } double x1 = r[0].x, y1 = r[0].y, z1 = r[0].z; double x2 = r[1].x, y2 = r[1].y, z2 = r[1].z; double x3 = r[2].x, y3 = r[2].y, z3 = r[2].z; double x4 = r[3].x, y4 = r[3].y, z4 = r[3].z; double x5 = r[4].x, y5 = r[4].y, z5 = r[4].z; double x6 = r[5].x, y6 = r[5].y, z6 = r[5].z; double x7 = r[6].x, y7 = r[6].y, z7 = r[6].z; double x8 = r[7].x, y8 = r[7].y, z8 = r[7].z; const double f12 = 1.0/12.0; // set up the B-matrix // we use the G arrays to store the B-matrix GX[0] = f12*(y2*((z6-z3)-(z4-z5))+y3*(z2-z4)+y4*((z3-z8)-(z5-z2))+y5*((z8-z6)-(z2-z4))+y6*(z5-z2)+y8*(z4-z5)); GY[0] = f12*(z2*((x6-x3)-(x4-x5))+z3*(x2-x4)+z4*((x3-x8)-(x5-x2))+z5*((x8-x6)-(x2-x4))+z6*(x5-x2)+z8*(x4-x5)); GZ[0] = f12*(x2*((y6-y3)-(y4-y5))+x3*(y2-y4)+x4*((y3-y8)-(y5-y2))+x5*((y8-y6)-(y2-y4))+x6*(y5-y2)+x8*(y4-y5)); GX[1] = f12*(y3*((z7-z4)-(z1-z6))+y4*(z3-z1)+y1*((z4-z5)-(z6-z3))+y6*((z5-z7)-(z3-z1))+y7*(z6-z3)+y5*(z1-z6)); GY[1] = f12*(z3*((x7-x4)-(x1-x6))+z4*(x3-x1)+z1*((x4-x5)-(x6-x3))+z6*((x5-x7)-(x3-x1))+z7*(x6-x3)+z5*(x1-x6)); GZ[1] = f12*(x3*((y7-y4)-(y1-y6))+x4*(y3-y1)+x1*((y4-y5)-(y6-y3))+x6*((y5-y7)-(y3-y1))+x7*(y6-y3)+x5*(y1-y6)); GX[2] = f12*(y4*((z8-z1)-(z2-z7))+y1*(z4-z2)+y2*((z1-z6)-(z7-z4))+y7*((z6-z8)-(z4-z2))+y8*(z7-z4)+y6*(z2-z7)); GY[2] = f12*(z4*((x8-x1)-(x2-x7))+z1*(x4-x2)+z2*((x1-x6)-(x7-x4))+z7*((x6-x8)-(x4-x2))+z8*(x7-x4)+z6*(x2-x7)); GZ[2] = f12*(x4*((y8-y1)-(y2-y7))+x1*(y4-y2)+x2*((y1-y6)-(y7-y4))+x7*((y6-y8)-(y4-y2))+x8*(y7-y4)+x6*(y2-y7)); GX[3] = f12*(y1*((z5-z2)-(z3-z8))+y2*(z1-z3)+y3*((z2-z7)-(z8-z1))+y8*((z7-z5)-(z1-z3))+y5*(z8-z1)+y7*(z3-z8)); GY[3] = f12*(z1*((x5-x2)-(x3-x8))+z2*(x1-x3)+z3*((x2-x7)-(x8-x1))+z8*((x7-x5)-(x1-x3))+z5*(x8-x1)+z7*(x3-x8)); GZ[3] = f12*(x1*((y5-y2)-(y3-y8))+x2*(y1-y3)+x3*((y2-y7)-(y8-y1))+x8*((y7-y5)-(y1-y3))+x5*(y8-y1)+x7*(y3-y8)); GX[4] = f12*(y8*((z4-z7)-(z6-z1))+y7*(z8-z6)+y6*((z7-z2)-(z1-z8))+y1*((z2-z4)-(z8-z6))+y4*(z1-z8)+y2*(z6-z1)); GY[4] = f12*(z8*((x4-x7)-(x6-x1))+z7*(x8-x6)+z6*((x7-x2)-(x1-x8))+z1*((x2-x4)-(x8-x6))+z4*(x1-x8)+z2*(x6-x1)); GZ[4] = f12*(x8*((y4-y7)-(y6-y1))+x7*(y8-y6)+x6*((y7-y2)-(y1-y8))+x1*((y2-y4)-(y8-y6))+x4*(y1-y8)+x2*(y6-y1)); GX[5] = f12*(y5*((z1-z8)-(z7-z2))+y8*(z5-z7)+y7*((z8-z3)-(z2-z5))+y2*((z3-z1)-(z5-z7))+y1*(z2-z5)+y3*(z7-z2)); GY[5] = f12*(z5*((x1-x8)-(x7-x2))+z8*(x5-x7)+z7*((x8-x3)-(x2-x5))+z2*((x3-x1)-(x5-x7))+z1*(x2-x5)+z3*(x7-x2)); GZ[5] = f12*(x5*((y1-y8)-(y7-y2))+x8*(y5-y7)+x7*((y8-y3)-(y2-y5))+x2*((y3-y1)-(y5-y7))+x1*(y2-y5)+x3*(y7-y2)); GX[6] = f12*(y6*((z2-z5)-(z8-z3))+y5*(z6-z8)+y8*((z5-z4)-(z3-z6))+y3*((z4-z2)-(z6-z8))+y2*(z3-z6)+y4*(z8-z3)); GY[6] = f12*(z6*((x2-x5)-(x8-x3))+z5*(x6-x8)+z8*((x5-x4)-(x3-x6))+z3*((x4-x2)-(x6-x8))+z2*(x3-x6)+z4*(x8-x3)); GZ[6] = f12*(x6*((y2-y5)-(y8-y3))+x5*(y6-y8)+x8*((y5-y4)-(y3-y6))+x3*((y4-y2)-(y6-y8))+x2*(y3-y6)+x4*(y8-y3)); GX[7] = f12*(y7*((z3-z6)-(z5-z4))+y6*(z7-z5)+y5*((z6-z1)-(z4-z7))+y4*((z1-z3)-(z7-z5))+y3*(z4-z7)+y1*(z5-z4)); GY[7] = f12*(z7*((x3-x6)-(x5-x4))+z6*(x7-x5)+z5*((x6-x1)-(x4-x7))+z4*((x1-x3)-(x7-x5))+z3*(x4-x7)+z1*(x5-x4)); GZ[7] = f12*(x7*((y3-y6)-(y5-y4))+x6*(y7-y5)+x5*((y6-y1)-(y4-y7))+x4*((y1-y3)-(y7-y5))+x3*(y4-y7)+x1*(y5-y4)); // calculate the volume double Vi = 1./(x1*GX[0]+x2*GX[1]+x3*GX[2]+x4*GX[3]+x5*GX[4]+x6*GX[5]+x7*GX[6]+x8*GX[7]); // divide the B-matrix by the volume GX[0] *= Vi; GY[0] *= Vi; GZ[0] *= Vi; GX[1] *= Vi; GY[1] *= Vi; GZ[1] *= Vi; GX[2] *= Vi; GY[2] *= Vi; GZ[2] *= Vi; GX[3] *= Vi; GY[3] *= Vi; GZ[3] *= Vi; GX[4] *= Vi; GY[4] *= Vi; GZ[4] *= Vi; GX[5] *= Vi; GY[5] *= Vi; GZ[5] *= Vi; GX[6] *= Vi; GY[6] *= Vi; GZ[6] *= Vi; GX[7] *= Vi; GY[7] *= Vi; GZ[7] *= Vi; } //----------------------------------------------------------------------------- //! Calculates the exact volume of a hexahedral element double FEUDGHexDomain::HexVolume(FESolidElement& el, int state) { // let's make sure this is indeed a hex element // assert(el.Type() == FE_HEX8G8); int neln = el.Nodes(); vec3d r[8]; if (state == 0) { for (int i=0; i<neln; ++i) r[i] = m_pMesh->Node(el.m_node[i]).m_r0; } else { for (int i=0; i<neln; ++i) r[i] = m_pMesh->Node(el.m_node[i]).m_rt; } // get the nodal coordinates double x1 = r[0].x, y1 = r[0].y, z1 = r[0].z; double x2 = r[1].x, y2 = r[1].y, z2 = r[1].z; double x3 = r[2].x, y3 = r[2].y, z3 = r[2].z; double x4 = r[3].x, y4 = r[3].y, z4 = r[3].z; double x5 = r[4].x, y5 = r[4].y, z5 = r[4].z; double x6 = r[5].x, y6 = r[5].y, z6 = r[5].z; double x7 = r[6].x, y7 = r[6].y, z7 = r[6].z; double x8 = r[7].x, y8 = r[7].y, z8 = r[7].z; // set up the B-matrix double B1[8]; // double B2[8]; // double B3[8]; const double f12 = 1.0/12.0; B1[0] = f12*(y2*((z6-z3)-(z4-z5))+y3*(z2-z4)+y4*((z3-z8)-(z5-z2))+y5*((z8-z6)-(z2-z4))+y6*(z5-z2)+y8*(z4-z5)); // B2[0] = f12*(z2*((x6-x3)-(x4-x5))+z3*(x2-x4)+z4*((x3-x8)-(x5-x2))+z5*((x8-x6)-(x2-x4))+z6*(x5-x2)+z8*(x4-x5)); // B3[0] = f12*(x2*((y6-y3)-(y4-y5))+x3*(y2-y4)+x4*((y3-y8)-(y5-y2))+x5*((y8-y6)-(y2-y4))+x6*(y5-y2)+x8*(y4-y5)); B1[1] = f12*(y3*((z7-z4)-(z1-z6))+y4*(z3-z1)+y1*((z4-z5)-(z6-z3))+y6*((z5-z7)-(z3-z1))+y7*(z6-z3)+y5*(z1-z6)); // B2[1] = f12*(z3*((x7-x4)-(x1-x6))+z4*(x3-x1)+z1*((x4-x5)-(x6-x3))+z6*((x5-x7)-(x3-x1))+z7*(x6-x3)+z5*(x1-x6)); // B3[1] = f12*(x3*((y7-y4)-(y1-y6))+x4*(y3-y1)+x1*((y4-y5)-(y6-y3))+x6*((y5-y7)-(y3-y1))+x7*(y6-y3)+x5*(y1-y6)); B1[2] = f12*(y4*((z8-z1)-(z2-z7))+y1*(z4-z2)+y2*((z1-z6)-(z7-z4))+y7*((z6-z8)-(z4-z2))+y8*(z7-z4)+y6*(z2-z7)); // B2[2] = f12*(z4*((x8-x1)-(x2-x7))+z1*(x4-x2)+z2*((x1-x6)-(x7-x4))+z7*((x6-x8)-(x4-x2))+z8*(x7-x4)+z6*(x2-x7)); // B3[2] = f12*(x4*((y8-y1)-(y2-y7))+x1*(y4-y2)+x2*((y1-y6)-(y7-y4))+x7*((y6-y8)-(y4-y2))+x8*(y7-y4)+x6*(y2-y7)); B1[3] = f12*(y1*((z5-z2)-(z3-z8))+y2*(z1-z3)+y3*((z2-z7)-(z8-z1))+y8*((z7-z5)-(z1-z3))+y5*(z8-z1)+y7*(z3-z8)); // B2[3] = f12*(z1*((x5-x2)-(x3-x8))+z2*(x1-x3)+z3*((x2-x7)-(x8-x1))+z8*((x7-x5)-(x1-x3))+z5*(x8-x1)+z7*(x3-x8)); // B3[3] = f12*(x1*((y5-y2)-(y3-y8))+x2*(y1-y3)+x3*((y2-y7)-(y8-y1))+x8*((y7-y5)-(y1-y3))+x5*(y8-y1)+x7*(y3-y8)); B1[4] = f12*(y8*((z4-z7)-(z6-z1))+y7*(z8-z6)+y6*((z7-z2)-(z1-z8))+y1*((z2-z4)-(z8-z6))+y4*(z1-z8)+y2*(z6-z1)); // B2[4] = f12*(z8*((x4-x7)-(x6-x1))+z7*(x8-x6)+z6*((x7-x2)-(x1-x8))+z1*((x2-x4)-(x8-x6))+z4*(x1-x8)+z2*(x6-x1)); // B3[4] = f12*(x8*((y4-y7)-(y6-y1))+x7*(y8-y6)+x6*((y7-y2)-(y1-y8))+x1*((y2-y4)-(y8-y6))+x4*(y1-y8)+x2*(y6-y1)); B1[5] = f12*(y5*((z1-z8)-(z7-z2))+y8*(z5-z7)+y7*((z8-z3)-(z2-z5))+y2*((z3-z1)-(z5-z7))+y1*(z2-z5)+y3*(z7-z2)); // B2[5] = f12*(z5*((x1-x8)-(x7-x2))+z8*(x5-x7)+z7*((x8-x3)-(x2-x5))+z2*((x3-x1)-(x5-x7))+z1*(x2-x5)+z3*(x7-x2)); // B3[5] = f12*(x5*((y1-y8)-(y7-y2))+x8*(y5-y7)+x7*((y8-y3)-(y2-y5))+x2*((y3-y1)-(y5-y7))+x1*(y2-y5)+x3*(y7-y2)); B1[6] = f12*(y6*((z2-z5)-(z8-z3))+y5*(z6-z8)+y8*((z5-z4)-(z3-z6))+y3*((z4-z2)-(z6-z8))+y2*(z3-z6)+y4*(z8-z3)); // B2[6] = f12*(z6*((x2-x5)-(x8-x3))+z5*(x6-x8)+z8*((x5-x4)-(x3-x6))+z3*((x4-x2)-(x6-x8))+z2*(x3-x6)+z4*(x8-x3)); // B3[6] = f12*(x6*((y2-y5)-(y8-y3))+x5*(y6-y8)+x8*((y5-y4)-(y3-y6))+x3*((y4-y2)-(y6-y8))+x2*(y3-y6)+x4*(y8-y3)); B1[7] = f12*(y7*((z3-z6)-(z5-z4))+y6*(z7-z5)+y5*((z6-z1)-(z4-z7))+y4*((z1-z3)-(z7-z5))+y3*(z4-z7)+y1*(z5-z4)); // B2[7] = f12*(z7*((x3-x6)-(x5-x4))+z6*(x7-x5)+z5*((x6-x1)-(x4-x7))+z4*((x1-x3)-(x7-x5))+z3*(x4-x7)+z1*(x5-x4)); // B3[7] = f12*(x7*((y3-y6)-(y5-y4))+x6*(y7-y5)+x5*((y6-y1)-(y4-y7))+x4*((y1-y3)-(y7-y5))+x3*(y4-y7)+x1*(y5-y4)); // calculate the volume V= xi*B1[i] = yi*B2[i] = zi*B3[i] (sum over i) return (x1*B1[0]+x2*B1[1]+x3*B1[2]+x4*B1[3]+x5*B1[4]+x6*B1[5]+x7*B1[6]+x8*B1[7]); }
C++
3D
febiosoftware/FEBio
FEBioMech/FEPrescribedActiveContractionIsotropic.cpp
.cpp
2,425
67
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEPrescribedActiveContractionIsotropic.h" //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEPrescribedActiveContractionIsotropic, FEElasticMaterial) ADD_PARAMETER(m_T0 , "T0" ); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEPrescribedActiveContractionIsotropic::FEPrescribedActiveContractionIsotropic(FEModel* pfem) : FEElasticMaterial(pfem) { m_T0 = 0.0; } //----------------------------------------------------------------------------- mat3ds FEPrescribedActiveContractionIsotropic::Stress(FEMaterialPoint &mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); double J = pt.m_J; mat3ds b = pt.LeftCauchyGreen(); // evaluate the active stress double T0 = m_T0(mp); mat3ds s = b*(T0/J); return s; } //----------------------------------------------------------------------------- tens4ds FEPrescribedActiveContractionIsotropic::Tangent(FEMaterialPoint &mp) { tens4ds c; c.zero(); return c; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEReactiveMaterialPoint.h
.h
1,960
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) 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 <FECore/FEMaterialPoint.h> #include "febiomech_api.h" #ifdef WIN32 #define max(a,b) ((a)>(b)?(a):(b)) #endif //----------------------------------------------------------------------------- // Define a reactive material point that defines various virtual functions. class FEBIOMECH_API FEReactiveMaterialPoint : public FEMaterialPointData { public: FEReactiveMaterialPoint(FEMaterialPointData*pt) : FEMaterialPointData(pt) {} virtual double BrokenBonds() const { return 0.0; } virtual double IntactBonds() const { return 1.0; } virtual double YieldedBonds() const { return 0.0; } virtual double FatigueBonds() const { return 0.0; } };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FERigidRotationVector.cpp
.cpp
3,143
104
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FERigidRotationVector.h" BEGIN_FECORE_CLASS(FERigidRotationVector, FERigidBC) ADD_PARAMETER(m_rigidMat, "rb")->setEnums("$(rigid_materials)")->setLongName("Rigid material"); ADD_PARAMETER(m_vx, "vx")->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE)->setUnits(UNIT_RADIAN); ADD_PARAMETER(m_vy, "vy")->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE)->setUnits(UNIT_RADIAN); ADD_PARAMETER(m_vz, "vz")->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE)->setUnits(UNIT_RADIAN); END_FECORE_CLASS(); FERigidRotationVector::FERigidRotationVector(FEModel* fem) : FERigidBC(fem) { m_vx = m_vy = m_vz = 0.0; m_rc[0] = new FERigidPrescribedBC(fem); m_rc[0]->SetBC(3); m_rc[1] = new FERigidPrescribedBC(fem); m_rc[1]->SetBC(4); m_rc[2] = new FERigidPrescribedBC(fem); m_rc[2]->SetBC(5); } FERigidRotationVector::~FERigidRotationVector() { delete m_rc[0]; delete m_rc[1]; delete m_rc[2]; } bool FERigidRotationVector::Init() { for (int i = 0; i < 3; ++i) { m_rc[i]->SetRigidMaterial(m_rigidMat); if (m_rc[i]->Init() == false) return false; } return true; } void FERigidRotationVector::Activate() { FERigidBC::Activate(); m_rc[0]->Activate(); m_rc[1]->Activate(); m_rc[2]->Activate(); m_rc[0]->SetValue(m_vx); m_rc[1]->SetValue(m_vy); m_rc[2]->SetValue(m_vz); } void FERigidRotationVector::Deactivate() { FERigidBC::Deactivate(); m_rc[0]->Deactivate(); m_rc[1]->Deactivate(); m_rc[2]->Deactivate(); } void FERigidRotationVector::InitTimeStep() { m_rc[0]->SetValue(m_vx); m_rc[1]->SetValue(m_vy); m_rc[2]->SetValue(m_vz); } void FERigidRotationVector::Serialize(DumpStream& ar) { FERigidBC::Serialize(ar); if (ar.IsShallow() == false) { for (int j = 0; j < 3; ++j) { // We need to serialize a reference to avoid that // restart will try to allocate the m_rc variables FERigidPrescribedBC& rc = *m_rc[j]; ar & rc; } } }
C++
3D
febiosoftware/FEBio
FEBioMech/FESurfaceAttractionBodyForce.cpp
.cpp
4,764
152
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FESurfaceAttractionBodyForce.h" #include "FEElasticMaterial.h" #include <FECore/FEMesh.h> #include <FECore/FEClosestPointProjection.h> #include <FECore/log.h> BEGIN_FECORE_CLASS(FESurfaceAttractionBodyForce, FEBodyForce); ADD_PARAMETER(m_blt , "blt" )->setUnits(UNIT_LENGTH); ADD_PARAMETER(m_bsf , "bsf" ); ADD_PARAMETER(m_stol , "search_tol" ); ADD_PARAMETER(m_sradius , "search_radius")->setUnits(UNIT_LENGTH); ADD_PROPERTY(m_s, "surface", FEProperty::Reference); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! constructor FESurfaceAttractionBodyForce::FESurfaceAttractionBodyForce(FEModel* pfem) : FEBodyForce(pfem) { m_blt = 1; m_bsf = 0; m_stol = 0.01; m_sradius = 0; // no search radius limitation m_s = nullptr; } //----------------------------------------------------------------------------- //! initialize bool FESurfaceAttractionBodyForce::Init() { if (m_s == nullptr) return false; if (!m_s->Init()) return false; FEBodyLoad::Init(); FEClosestPointProjection cpp(*m_s); cpp.SetTolerance(m_stol); cpp.SetSearchRadius(m_sradius); cpp.HandleSpecialCases(true); cpp.Init(); // allocate projection point vector array int nel = GetMesh().Elements(); m_q.resize(nel); const char s[] = "%%"; feLog("Initializing projections to attractive surface...\n"); // evaluate projection of integration points to attractive surface for (int i=0; i<Domains(); ++i) { FEDomain* dom = Domain(i); int nde = dom->Elements(); feLog("Domain %d: %d elements\n",i+1,nde); int pcp = 0; feLog("\r%d %s done",pcp,s); for (int j=0; j<nde; ++j) { int pc = 100*(j+1)/nde; if (pc > pcp) { feLog("\r%d %s done",pc,s); pcp = pc; } FEElement& el = dom->ElementRef(j); int nint = el.GaussPoints(); int eid = el.GetID() - 1; m_q[eid].resize(nint); for (int k=0; k<nint; ++k) { FEMaterialPoint* mp = el.GetMaterialPoint(k); vec3d x = mp->m_r0; vec2d rs(0, 0); FESurfaceElement* pme = nullptr; pme = cpp.Project(x, m_q[eid][k], rs); if (pme == nullptr) m_q[eid][k] = x + vec3d(100*m_blt,100*m_blt,100*m_blt); } } } return true; } //----------------------------------------------------------------------------- vec3d FESurfaceAttractionBodyForce::force(FEMaterialPoint& mp) { // get element number for this material point int eid = mp.m_elem->GetID() - 1; vec3d q = m_q[eid][mp.m_index]; // initialize net force vec3d f(0,0,0); // calculate net force vec3d g = mp.m_r0 - q; double r = g.unit(); f = g*(m_bsf*exp(-r/m_blt)); return f; } //----------------------------------------------------------------------------- double FESurfaceAttractionBodyForce::divforce(FEMaterialPoint& mp) { // get element number for this material point int eid = mp.m_elem->GetID() - 1; vec3d q = m_q[eid][mp.m_index]; // calculate net force vec3d g = mp.m_r0 - q; double r = g.unit(); return (3-r/m_blt)*(m_bsf*exp(-r/m_blt)); } mat3d FESurfaceAttractionBodyForce::stiffness(FEMaterialPoint& mp) { return mat3ds(0,0,0,0,0,0); }
C++
3D
febiosoftware/FEBio
FEBioMech/FEMortarInterface.cpp
.cpp
5,993
207
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEMortarInterface.h" #include "FECore/mortar.h" #include "FECore/log.h" #include <FECore/FEMesh.h> //----------------------------------------------------------------------------- FEMortarInterface::FEMortarInterface(FEModel* pfem) : FEContactInterface(pfem) { // set the integration rule m_pT = dynamic_cast<FESurfaceElementTraits*>(FEElementLibrary::GetElementTraits(FE_TRI3G7)); } //----------------------------------------------------------------------------- void FEMortarInterface::UpdateMortarWeights(FESurface& ss, FESurface& ms) { // allocate sturcture for the integration weights int NS = ss.Nodes(); int NM = ms.Nodes(); m_n1.resize(NS,NS); m_n2.resize(NS,NM); // clear weights m_n1.zero(); m_n2.zero(); // number of integration points const int MAX_INT = 11; const int nint = m_pT->m_nint; vector<double>& gw = m_pT->gw; vector<double>& gr = m_pT->gr; vector<double>& gs = m_pT->gs; // calculate the mortar surface MortarSurface mortar; CalculateMortarSurface(ss, ms, mortar); // These arrays will store the shape function values of the projection points // on the primary and secondary side when evaluating the integral over a pallet double Ns[MAX_INT][4], Nm[MAX_INT][4]; // loop over the mortar patches int NP = mortar.Patches(); for (int i=0; i<NP; ++i) { // get the next patch Patch& pi = mortar.GetPatch(i); // get the facet ID's that generated this patch int k = pi.GetPrimaryFacetID(); int l = pi.GetSecondaryFacetID(); // get the non-mortar surface element FESurfaceElement& se = ss.Element(k); // get the mortar surface element FESurfaceElement& me = ms.Element(l); // loop over all patch triangles int np = pi.Size(); for (int j=0; j<np; ++j) { // get the next facet Patch::FACET& fj = pi.Facet(j); // calculate the patch area // (We multiply by two because the sum of the integration weights in FEBio sum up to the area // of the triangle in natural coordinates (=0.5)). double Area = fj.Area()*2.0; if (Area > 1e-15) { // loop over integration points for (int n=0; n<nint; ++n) { // evaluate the spatial position of the integration point on the patch vec3d xp = fj.Position(gr[n], gs[n]); // evaluate the integration points on the primary and secondary surfaces // i.e. determine rs, rm double r1 = 0, s1 = 0, r2 = 0, s2 = 0; vec3d xs = ss.ProjectToSurface(se, xp, r1, s1); vec3d xm = ms.ProjectToSurface(me, xp, r2, s2); // assert((r1>=0.0)&&(s1>=0)&&(r1+s1<1.0)); // assert((r2>=0.0)&&(s2>=0)&&(r2+s2<1.0)); // evaluate shape functions se.shape_fnc(Ns[n], r1, s1); me.shape_fnc(Nm[n], r2, s2); } // Evaluate the contributions to the integrals int ns = se.Nodes(); int nm = me.Nodes(); for (int A=0; A<ns; ++A) { int a = se.m_lnode[A]; // loop over all the nodes on the primary facet for (int B=0; B<ns; ++B) { double n1 = 0; for (int n=0; n<nint; ++n) { n1 += gw[n]*Ns[n][A]*Ns[n][B]; } n1 *= Area; int b = se.m_lnode[B]; m_n1[a][b] += n1; } // loop over all the nodes on the secondary facet for (int C = 0; C<nm; ++C) { double n2 = 0; for (int n=0; n<nint; ++n) { n2 += gw[n]*Ns[n][A]*Nm[n][C]; } n2 *= Area; int c = me.m_lnode[C]; m_n2[a][c] += n2; } } } } } #ifndef NDEBUG // Sanity check: sum should add up to contact area // This is for a hardcoded problem. Remove or generalize this! double sum1 = 0.0; for (int A=0; A<NS; ++A) for (int B=0; B<NS; ++B) sum1 += m_n1[A][B]; double sum2 = 0.0; for (int A=0; A<NS; ++A) for (int C=0; C<NM; ++C) sum2 += m_n2[A][C]; if (fabs(sum1 - 1.0) > 1e-5) feLog("WARNING: Mortar weights are not correct (%lg).\n", sum1); if (fabs(sum2 - 1.0) > 1e-5) feLog("WARNING: Mortar weights are not correct (%lg).\n", sum2); #endif } //----------------------------------------------------------------------------- //! Update the nodal gaps void FEMortarInterface::UpdateNodalGaps(FEMortarContactSurface& ss, FEMortarContactSurface& ms) { // reset nodal gaps vector<vec3d>& gap = ss.m_gap; zero(ss.m_gap); int NS = ss.Nodes(); int NM = ms.Nodes(); // loop over all primary nodes for (int A=0; A<NS; ++A) { // loop over all primary nodes for (int B=0; B<NS; ++B) { FENode& nodeB = ss.Node(B); vec3d& xB = nodeB.m_rt; double nAB = m_n1[A][B]; gap[A] += xB*nAB; } // loop over secondary side for (int C=0; C<NM; ++C) { FENode& nodeC = ms.Node(C); vec3d& xC = nodeC.m_rt; double nAC = m_n2[A][C]; gap[A] -= xC*nAC; } } }
C++
3D
febiosoftware/FEBio
FEBioMech/FEFiberNaturalNeoHookean.h
.h
2,347
65
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticFiberMaterial.h" #include "FEFiberMaterial.h" //----------------------------------------------------------------------------- //! Neo-Hookean law class FEFiberNaturalNH : public FEFiberMaterial { public: FEFiberNaturalNH(FEModel* pfem); //! Cauchy stress mat3ds FiberStress(FEMaterialPoint& mp, const vec3d& a0) override; // Spatial tangent tens4ds FiberTangent(FEMaterialPoint& mp, const vec3d& a0) override; //! Strain energy density double FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& a0) override; public: FEParamDouble m_ksi; // fiber modulus FEParamDouble m_lam0; // stretch threshold for tensile response double m_epsf; // declare the parameter list DECLARE_FECORE_CLASS(); }; class FEElasticFiberNaturalNH : public FEElasticFiberMaterial_T<FEFiberNaturalNH> { public: FEElasticFiberNaturalNH(FEModel* fem) : FEElasticFiberMaterial_T<FEFiberNaturalNH>(fem) {} DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FESphericalFiberDistribution.h
.h
2,075
58
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticMaterial.h" //----------------------------------------------------------------------------- //! Material class for the spherical fiber distribution //! class FESphericalFiberDistribution : public FEElasticMaterial { public: FESphericalFiberDistribution(FEModel* pfem); //! Cauchy stress mat3ds Stress(FEMaterialPoint& mp) override; // Spatial tangent tens4ds Tangent(FEMaterialPoint& mp) override; // Strain energy density virtual double StrainEnergyDensity(FEMaterialPoint& mp) override; // declare the parameter list DECLARE_FECORE_CLASS(); public: FEParamDouble m_beta; // power in power-law relation FEParamDouble m_ksi; // coefficient in power-law relation FEParamDouble m_alpha; // coefficient of exponential argument };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FERigidJoint.h
.h
3,138
98
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 FERigidJoint class implements a rigid joint. The rigid joint allows the //! user to connect two rigid bodies at a point in space. class FERigidJoint : public FERigidConnector { public: //! constructor FERigidJoint(FEModel* pfem); //! destructor ~FERigidJoint(); //! 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; protected: void UnpackLM(vector<int>& lm); // Build the matrix profile void BuildMatrixProfile(FEGlobalMatrix& M) override; void PrepStep(); void Update(const std::vector<double>& Ui, const std::vector<double>& ui) override; void UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) override; public: vec3d m_q0; //! initial position of joint 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_F, m_Fp; //!< constraining force vec3d m_L; //!< Lagrange multiplier double m_eps; //!< penalty factor double m_atol; //!< augmented Lagrangian tolerance int m_laugon; //!< enforcement method protected: int m_nID; //!< ID of rigid joint vector<int> m_LM; // Lagrange multiplier equation numbers DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEUncoupledActiveFiberContraction.cpp
.cpp
4,727
172
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEUncoupledActiveFiberContraction.h" #include "FEElasticMaterial.h" #include <FECore/log.h> BEGIN_FECORE_CLASS(FEUncoupledActiveFiberContraction, FEActiveContractionMaterial); ADD_PARAMETER(m_ascl, "ascl"); ADD_PARAMETER(m_Tmax, "Tmax"); ADD_PARAMETER(m_ca0, "ca0"); ADD_PARAMETER(m_camax, "camax"); ADD_PARAMETER(m_beta, "beta"); ADD_PARAMETER(m_l0, "l0"); ADD_PARAMETER(m_refl, "refl"); END_FECORE_CLASS(); FEUncoupledActiveFiberContraction::FEUncoupledActiveFiberContraction(FEModel* pfem) : FEActiveContractionMaterial(pfem) { m_ascl = 0; m_Tmax = 1.0; m_ca0 = 1.0; m_camax = 0.0; m_beta = 1; m_l0 = 1; m_refl = 1; } bool FEUncoupledActiveFiberContraction::Init() { if (FEActiveContractionMaterial::Init() == false) return false; // for backward compatibility we set m_camax to m_ca0 if it is not defined if (m_camax == 0.0) m_camax = m_ca0; if (m_camax <= 0.0) { feLogError("camax must be larger than zero"); return false; } return true; } mat3ds FEUncoupledActiveFiberContraction::ActiveStress(FEMaterialPoint& mp, const vec3d& a0) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // get the deformation gradient mat3d F = pt.m_F; double J = pt.m_J; double Jm13 = pow(J, -1.0 / 3.0); // calculate the current material axis lam*a = F*a0; vec3d a = F * a0; // normalize material axis and store fiber stretch double lam, lamd; lam = a.unit(); lamd = lam * Jm13; // i.e. lambda tilde // calculate dyad of a: AxA = (a x a) mat3ds AxA = dyad(a); // get the activation double s = 0.0; if (m_ascl > 0) { // current sarcomere length double strl = m_refl * lamd; // sarcomere length change double dl = strl - m_l0; if (dl >= 0) { // calcium sensitivity double eca50i = (exp(m_beta * dl) - 1); // ratio of Camax/Ca0 double rca = m_camax / m_ca0; // active fiber stress s = m_Tmax * (eca50i / (eca50i + rca * rca)) * m_ascl; } } mat3ds sa = (AxA * (s / J)); return sa.dev(); } tens4ds FEUncoupledActiveFiberContraction::ActiveStiffness(FEMaterialPoint& mp, const vec3d& a0) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // get the deformation gradient mat3d F = pt.m_F; double J = pt.m_J; double Jm13 = pow(J, -1.0 / 3.0); // calculate the current material axis lam*a = F*a0; vec3d a = F * a0; // normalize material axis and store fiber stretch double lam, lamd; lam = a.unit(); lamd = lam * Jm13; // i.e. lambda tilde double lamd2 = lamd * lamd; double lamd3 = lamd2 * lamd; // calculate dyad of a: AxA = (a x a) mat3dd I(1.0); mat3ds A = dyad(a); tens4ds AxA = dyad1s(A); tens4ds IxI = dyad1s(I); tens4ds Ax1 = dyad1s(A, I); tens4ds i4 = dyad4s(I); double sa = 0; double dsa = 0; if (m_ascl > 0) { // current sarcomere length double strl = m_refl * lamd; // sarcomere length change double dl = strl - m_l0; if (dl >= 0) { // calcium sensitivity double eca50i = (exp(m_beta * dl) - 1); // ratio of Camax/Ca0 double rca = m_camax / m_ca0; double r2 = rca * rca; // active fiber stress double D = eca50i + r2; sa = m_Tmax * (eca50i / D) * m_ascl; dsa = -2.0 * sa / lamd3 + (1.0 / lamd2) * m_Tmax * m_ascl * m_beta * m_refl * r2 * (eca50i + 1.0) / (D * D); } } tens4ds Jc = Ax1 * (-(2.0 / 3.0) * sa) + (i4 + IxI / 3.0) * (2.0 * sa / 3.0) + (AxA - Ax1 / 3.0 + IxI / 9.0) * (lamd3 * dsa); return Jc / J; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEDamageMaterialUC.cpp
.cpp
4,039
124
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEDamageMaterialUC.h" #include "FEDamageCDF.h" #include "FEUncoupledMaterial.h" #include "FECore/FECoreKernel.h" BEGIN_FECORE_CLASS(FEDamageMaterialUC, FEUncoupledMaterial) // set material properties ADD_PROPERTY(m_pBase, "elastic"); ADD_PROPERTY(m_pDamg, "damage"); ADD_PROPERTY(m_pCrit, "criterion"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FEDamageMaterialUC::FEDamageMaterialUC(FEModel* pfem) : FEUncoupledMaterial(pfem) { m_pBase = 0; m_pDamg = 0; m_pCrit = 0; } //----------------------------------------------------------------------------- // returns a pointer to a new material point object FEMaterialPointData* FEDamageMaterialUC::CreateMaterialPointData() { return new FEDamageMaterialPoint(m_pBase->CreateMaterialPointData()); } //----------------------------------------------------------------------------- //! Initialization. bool FEDamageMaterialUC::Init() { return FEUncoupledMaterial::Init(); } //----------------------------------------------------------------------------- //! calculate stress at material point mat3ds FEDamageMaterialUC::DevStress(FEMaterialPoint& pt) { // evaluate the damage double d = Damage(pt); // evaluate the stress mat3ds s = m_pBase->DevStress(pt); // return the damaged stress return s*(1-d); } //----------------------------------------------------------------------------- //! calculate tangent stiffness at material point tens4ds FEDamageMaterialUC::DevTangent(FEMaterialPoint& pt) { // evaluate the damage double d = Damage(pt); // evaluate the tangent tens4ds c = m_pBase->DevTangent(pt); // return the damaged tangent return c*(1-d); } //----------------------------------------------------------------------------- //! calculate strain energy density at material point double FEDamageMaterialUC::DevStrainEnergyDensity(FEMaterialPoint& pt) { // evaluate the damage double d = Damage(pt); // evaluate the strain energy density double sed = m_pBase->DevStrainEnergyDensity(pt); // return the damaged sed return sed*(1-d); } //----------------------------------------------------------------------------- //! calculate damage at material point double FEDamageMaterialUC::Damage(FEMaterialPoint& pt) { // get the damage material point data FEDamageMaterialPoint& pd = *pt.ExtractData<FEDamageMaterialPoint>(); // evaluate the trial value of the damage criterion // this must be done before evaluating the damage pd.m_Etrial = m_pCrit->DamageCriterion(pt); // evaluate the damage double d = m_pDamg->Damage(pt); pd.m_D = d; return d; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEFiberCDF.h
.h
2,654
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) 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 "FEElasticFiberMaterial.h" #include "FEFiberMaterial.h" #include "FEDamageCDF.h" //----------------------------------------------------------------------------- //! Material class for single fiber, tension only //! Cumulative distribution class FEFiberCDF : public FEFiberMaterial { public: FEFiberCDF(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; // 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; // Young's modulus when all fibers are engaged double m_epsf; FEDamageCDF* m_CDF; // declare the parameter list DECLARE_FECORE_CLASS(); friend class FEElasticFiberCDF; }; //----------------------------------------------------------------------------- class FEElasticFiberCDF : public FEElasticFiberMaterial_T<FEFiberCDF> { public: FEElasticFiberCDF(FEModel* fem) : FEElasticFiberMaterial_T<FEFiberCDF>(fem) {} DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEPrescribedActiveContractionTransIso.h
.h
2,126
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" //----------------------------------------------------------------------------- // This material implements an active contraction model which can be used // as a component of a solid mixture material. class FEPrescribedActiveContractionTransIso : public FEElasticMaterial { public: //! constructor FEPrescribedActiveContractionTransIso(FEModel* pfem); //! Validation bool Validate() override; //! serialization void Serialize(DumpStream& ar) override; //! stress mat3ds Stress(FEMaterialPoint& pt) override; //! tangent tens4ds Tangent(FEMaterialPoint& pt) override; public: FEParamDouble m_T0; // prescribed active stress vec3d m_n0; // unit vector along fiber direction (local coordinate system) DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FERigidCylindricalJoint.h
.h
4,583
132
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FECore/vec3d.h" #include "FERigidConnector.h" #include "febiomech_api.h" //----------------------------------------------------------------------------- //! The FERigidCylindricalJoint class implements a cylindrical joint. The rigid joint //! allows the user to connect two rigid bodies at a point in space //! and allow rotation about, and translation along, a single prescribed axis. class FEBIOMECH_API FERigidCylindricalJoint : public FERigidConnector { public: //! constructor FERigidCylindricalJoint(FEModel* pfem); //! destructor ~FERigidCylindricalJoint(); //! initialization bool Init() override; //! calculates the joint forces void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override; //! calculates the joint stiffness void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override; //! calculate Lagrangian augmentation bool Augment(int naug, const FETimeInfo& tp) override; //! serialize data to archive void Serialize(DumpStream& ar) override; //! update state void Update() override; //! Reset data void Reset() override; //! evaluate relative translation vec3d RelativeTranslation(const bool global = false) override; //! evaluate relative rotation vec3d RelativeRotation(const bool global = false) override; //! initial position vec3d InitialPosition() const; //! current position vec3d Position() const; //! orientation quatd Orientation() const; protected: int InitEquations(int neq) override; void BuildMatrixProfile(FEGlobalMatrix& M) override; void PrepStep(); void Update(const std::vector<double>& Ui, const std::vector<double>& ui) override; void UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) override; void UnpackLM(vector<int>& lm); public: // parameters 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 double m_eps; //! penalty factor for constraining force double m_ups; //! penalty factor for constraining moment vec3d m_q0; //! initial position of joint double m_dp; //! prescribed translation double m_qp; //! prescribed rotation bool m_bd; //! flag for prescribing translation bool m_bq; //! flag for prescribing rotation double m_Fp; //! prescribed force double m_Mp; //! prescribed moment bool m_bautopen; //!< auto-penalty for gap and ang tolerance int m_laugon; //!< Lagrange multiplier option 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 double m_u; vec3d m_Lp; double m_up; vector<int> m_EQ; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEContactPotential.cpp
.cpp
26,720
1,094
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEContactPotential.h" #include <FECore/FENode.h> #include <FECore/FEGlobalMatrix.h> #include <FECore/FELinearSystem.h> #include <FECore/FEBox.h> #include <stdexcept> #include <FECore/FENodeNodeList.h> #include <FECore/FEMesh.h> #include <FECore/log.h> #include <omp.h> void FEContactPotential::UpdateSurface(FESurface& surface) { // This assumes we are inside a omp parallel region! #pragma omp for for (int i = 0; i < surface.Elements(); ++i) { FESurfaceElement& el = surface.Element(i); if (el.isActive()) { vec3d re[FEElement::MAX_NODES]; surface.GetNodalCoordinates(el, re); for (int n = 0; n < el.GaussPoints(); ++n) { FECPContactPoint& mp = static_cast<FECPContactPoint&>(*el.GetMaterialPoint(n)); mp.m_rt = surface.Position(el, n); // kinematics at integration points mp.dxr = el.eval_deriv1(re, n); mp.dxs = el.eval_deriv2(re, n); mp.m_Jt = (mp.dxr ^ mp.dxs).norm(); } } } } FEContactPotentialSurface::FEContactPotentialSurface(FEModel* fem) : FEContactSurface(fem) { } void FEContactPotentialSurface::InitSurface() { FEContactPotential* pci = dynamic_cast<FEContactPotential*>(GetContactInterface()); if (pci && (pci->IntegrationRule() == 1)) { FEFacetSet& fs = *m_surf; int elems = Elements(); for (int i = 0; i < elems; ++i) { FESurfaceElement& el = Element(i); FEFacetSet::FACET& fi = fs.Face(i); if (fi.ntype == 4) el.SetType(FE_QUAD4G16); else if (fi.ntype == 3) el.SetType(FE_TRI3G7); else assert(false); int N = el.Nodes(); assert(N == fi.ntype); for (int j = 0; j < N; ++j) el.m_node[j] = fi.node[j]; } CreateMaterialPointData(); } FEContactSurface::InitSurface(); } FEMaterialPoint* FEContactPotentialSurface::CreateMaterialPoint() { return new FECPContactPoint; } void FEContactPotentialSurface::GetContactTraction(int nelem, vec3d& tc) { FESurfaceElement& el = Element(nelem); tc = vec3d(0, 0, 0); for (int n = 0; n < el.GaussPoints(); ++n) { FECPContactPoint& mp = static_cast<FECPContactPoint&>(*el.GetMaterialPoint(n)); tc += mp.m_tc; } tc /= (double)el.GaussPoints(); } vec3d FEContactPotentialSurface::GetContactForce() { vec3d F(0, 0, 0); for (int i = 0; i < Elements(); ++i) { FESurfaceElement& el = Element(i); if (el.isActive()) { double* gw = el.GaussWeights(); for (int n = 0; n < el.GaussPoints(); ++n) { FECPContactPoint& mp = static_cast<FECPContactPoint&>(*el.GetMaterialPoint(n)); vec3d dA = mp.dxr ^ mp.dxs; double da = dA.norm(); F += mp.m_tc * (da * gw[n]); } } } return F; } double FEContactPotentialSurface::GetContactArea() { double area = 0.0; for (int i = 0; i < Elements(); ++i) { FESurfaceElement& el = Element(i); if (el.isActive()) { double* gw = el.GaussWeights(); for (int n = 0; n < el.GaussPoints(); ++n) { FECPContactPoint& mp = static_cast<FECPContactPoint&>(*el.GetMaterialPoint(n)); if (mp.m_tc.norm2() != 0.0) { vec3d dA = mp.dxr ^ mp.dxs; double da = dA.norm(); area += da * gw[n]; } } } } return area; } BEGIN_FECORE_CLASS(FEContactPotential, FEContactInterface) // just adding this parameter for backward compatibility. ADD_PARAMETER(m_laugon, "laugon")->SetFlags(FEParamFlag::FE_PARAM_HIDDEN); ADD_PARAMETER(m_kc, "kc"); ADD_PARAMETER(m_p, "p"); ADD_PARAMETER(m_Rin, "R_in"); ADD_PARAMETER(m_Rout, "R_out"); ADD_PARAMETER(m_Rmin, "R0_min"); ADD_PARAMETER(m_wtol, "w_tol"); ADD_PARAMETER(m_checkIntersections, "check_intersections"); ADD_PARAMETER(m_integrationRule, "integration_rule")->setEnums("default\0higher-order\0"); END_FECORE_CLASS(); FEContactPotential::FEContactPotential(FEModel* fem) : FEContactInterface(fem), m_surf1(fem), m_surf2(fem) { m_surf1.SetContactInterface(this); m_surf2.SetContactInterface(this); m_kc = 0.0; m_p = 4; m_Rin = 1.0; m_Rout = 2.0; m_Rmin = 0.0; m_wtol = 0.0; m_checkIntersections = false; m_integrationRule = 0; } //! return the primary surface FESurface* FEContactPotential::GetPrimarySurface() { return &m_surf1; } //! return the secondary surface FESurface* FEContactPotential::GetSecondarySurface() { return &m_surf2; } //! temporary construct to determine if contact interface uses nodal integration rule (or facet) bool FEContactPotential::UseNodalIntegration() { return false; } static bool is_neighbor(FESurfaceElement& e1, FESurfaceElement& e2) { int n1 = e1.Nodes(); int n2 = e2.Nodes(); for (int i = 0; i < n1; ++i) for (int j = 0; j < n2; ++j) { if (e1.m_node[i] == e2.m_node[j]) return true; } return false; } struct BOX { public: vec3d r0, r1; public: BOX() {} BOX(const vec3d& p0, const vec3d& p1) : r0(p0), r1(p1) {} void add(const vec3d& r) { if (r.x < r0.x) r0.x = r.x; if (r.y < r0.y) r0.y = r.y; if (r.z < r0.z) r0.z = r.z; if (r.x > r1.x) r1.x = r.x; if (r.y > r1.y) r1.y = r.y; if (r.z > r1.z) r1.z = r.z; } void inflate(double l) { r0.x -= l; r0.y -= l; r0.z -= l; r1.x += l; r1.y += l; r1.z += l; } bool isInside(const vec3d& r) const { return ( (r.x >= r0.x) && (r.x <= r1.x) && (r.y >= r0.y) && (r.y <= r1.y) && (r.z >= r0.z) && (r.z <= r1.z)); } double MaxExtent() const { double sx = r1.x - r0.x; double sy = r1.y - r0.y; double sz = r1.z - r0.z; if ((sx >= sy) && (sx >= sz)) return sx; if ((sy >= sx) && (sy >= sz)) return sy; if ((sz >= sx) && (sz >= sy)) return sz; // we should never reach here return 0; } double width () const { return r1.x - r0.x; } double height() const { return r1.y - r0.y; } double depth () const { return r1.z - r0.z; } }; class FEContactPotential::Grid { public: class Cell { public: Cell() {} Cell(const Cell& c) : m_box(c.m_box), m_elemList(c.m_elemList), m_nbr(c.m_nbr) {} void operator = (const Cell& c) { m_box = c.m_box; m_elemList = c.m_elemList; m_nbr = c.m_nbr; } void add(FESurfaceElement* el) { m_elemList.insert(el); } bool empty() const { return m_elemList.empty(); } public: BOX m_box; set<FESurfaceElement*> m_elemList; vector<Cell*> m_nbr; int id = -1; }; Cell* FindCell(const vec3d& r) { if (box.isInside(r) == false) return nullptr; int ix = (int)(m_nx * (r.x - box.r0.x) / box.width()); int iy = (int)(m_ny * (r.y - box.r0.y) / box.height()); int iz = (int)(m_nz * (r.z - box.r0.z) / box.depth()); if (ix == m_nx) ix--; if (iy == m_ny) iy--; if (iz == m_nz) iz--; int icell = iz * (m_nx * m_ny) + iy * m_nx + ix; Cell* c = m_cell + icell; assert(c->m_box.isInside(r)); return m_cell + icell; } int GetCellNeighborHood(const vec3d& r, Cell** cellList) { Cell* c = FindCell(r); if (c == nullptr) return 0; int n = 0; for (int i = 0; i < 27; ++i) { Cell* ci = c->m_nbr[i]; if ((ci != nullptr) && (ci->empty() == false)) cellList[n++] = ci; } return n; } public: enum { MAX_OMP_LOCKS = 256 }; Grid() { m_nx = m_ny = m_nz = 0; m_cell = nullptr; if (lock == nullptr) init_locks(); } bool Build(FESurface& s, int boxDivs, double minBoxSize) { // update the bounding box for (int i = 0; i < s.Nodes(); ++i) { FENode& node = s.Node(i); vec3d ri = node.m_rt; if (i == 0) box.r0 = box.r1 = ri; else box.add(ri); } // inflate a little, just to be sure double R = box.MaxExtent(); box.inflate(minBoxSize); // determine the sizes double W = box.width(); double H = box.height(); double D = box.depth(); double boxSize = box.MaxExtent() / boxDivs; if (boxSize < minBoxSize) boxSize = minBoxSize; m_nx = (int)(W / boxSize); if (m_nx < 1) m_nx = 1; m_ny = (int)(H / boxSize); if (m_ny < 1) m_ny = 1; m_nz = (int)(D / boxSize); if (m_nz < 1) m_nz = 1; // allocate the grid int ncells = m_nx * m_ny * m_nz; m_cell = new Cell[ncells]; // helper lookup-table for cell neighbors const int LUT[27][3] = { {-1,-1,-1},{ 0,-1,-1},{1,-1,-1}, {-1, 0,-1},{ 0, 0,-1},{1, 0,-1}, {-1, 1,-1},{ 0, 1,-1},{1, 1,-1}, {-1,-1, 0},{ 0,-1, 0},{1,-1, 0}, {-1, 0, 0},{ 0, 0, 0},{1, 0, 0}, {-1, 1, 0},{ 0, 1, 0},{1, 1, 0}, {-1,-1, 1},{ 0,-1, 1},{1,-1, 1}, {-1, 0, 1},{ 0, 0, 1},{1, 0, 1}, {-1, 1, 1},{ 0, 1, 1},{1, 1, 1} }; // construct cells Cell* c = m_cell; double X0 = box.r0.x; double Y0 = box.r0.y; double Z0 = box.r0.z; for (int k = 0; k < m_nz; ++k) { double z0 = Z0 + k * D / m_nz; double z1 = Z0 + (k+1) * D / m_nz; for (int j = 0; j < m_ny; ++j) { double y0 = Y0 + j * H / m_ny; double y1 = Y0 + (j + 1) * H / m_ny; for (int i = 0; i < m_nx; ++i, ++c) { double x0 = X0 + i * W / m_nx; double x1 = X0 + (i + 1) * W / m_nx; c->m_box = BOX(vec3d(x0, y0, z0), vec3d(x1, y1, z1)); double R = c->m_box.MaxExtent(); c->m_box.inflate(R * 1e-4); // assign neighbors c->m_nbr.assign(27, nullptr); for (int n = 0; n < 27; ++n) { const int* l = LUT[n]; c->m_nbr[n] = GetCell(i + l[0], j + l[1], k + l[2]); } } } } for (int i = 0; i < ncells; ++i) m_cell[i].id = (i% MAX_OMP_LOCKS); // assign elements to grid cells #pragma omp parallel for for (int i = 0; i < s.Elements(); ++i) { FESurfaceElement& el = s.Element(i); if (el.isActive()) { int nint = el.GaussPoints(); for (int n = 0; n < nint; ++n) { FECPContactPoint& mp = static_cast<FECPContactPoint&>(*el.GetMaterialPoint(n)); Cell* c = FindCell(mp.m_rt); assert(c); // if (c == nullptr) return false; omp_set_lock(lock + c->id); c->add(&el); omp_unset_lock(lock + c->id); } } } return true; } Cell* GetCell(int i, int j, int k) const { if ((i < 0) || (i >= m_nx)) return nullptr; if ((j < 0) || (j >= m_ny)) return nullptr; if ((k < 0) || (k >= m_nz)) return nullptr; return m_cell + (k * (m_nx * m_ny) + j * m_nx + i); } ~Grid() { delete [] m_cell; } protected: BOX box; int m_nx, m_ny, m_nz; Cell* m_cell; public: static omp_lock_t* lock; static void init_locks() { lock = new omp_lock_t[MAX_OMP_LOCKS]; for (int i = 0; i < MAX_OMP_LOCKS; ++i) omp_init_lock(lock + i); } static void delete_locks() { if (lock) { for (int i = 0; i < MAX_OMP_LOCKS; ++i) omp_destroy_lock(lock + i); delete[] lock; lock = nullptr; } } }; omp_lock_t* FEContactPotential::Grid::lock = nullptr; // initialization bool FEContactPotential::Init() { if (FEContactInterface::Init() == false) return false; BuildNeighborTable(); m_activeElements.resize(m_surf1.Elements()); m_NNL.Create(m_surf1); return true; } FEContactPotential::~FEContactPotential() { Grid::delete_locks(); } void FEContactPotential::BuildNeighborTable() { m_elemNeighbors.resize(m_surf1.Elements()); for (int i = 0; i < m_surf1.Elements(); ++i) { FESurfaceElement& el1 = m_surf1.Element(i); if (el1.isActive()) { set<FESurfaceElement*>& nbrList = m_elemNeighbors[i]; nbrList.clear(); for (int j = 0; j < m_surf2.Elements(); ++j) { FESurfaceElement& el2 = m_surf2.Element(j); if (el2.isActive() && is_neighbor(el1, el2)) { nbrList.insert(&el2); } } } } } // update void FEContactPotential::Update() { FEContactInterface::Update(); // update the constants m_c1 = 0.5 * m_p * m_kc / ((m_Rout - m_Rin) * pow(m_Rin, m_p + 1.0)); m_c2 = m_kc / pow(m_Rin, m_p) - m_c1 * (m_Rin - m_Rout) * (m_Rin - m_Rout); // Update the surfaces #pragma omp parallel { UpdateSurface(m_surf1); UpdateSurface(m_surf2); } // build the grid int ndivs = (int)pow(m_surf2.Elements(), 0.33333); if (ndivs < 2) ndivs = 2; Grid g; if (g.Build(m_surf2, ndivs, m_Rout) == false) { throw std::runtime_error("Failed to build grid in FEContactPotential::Update"); } if (m_checkIntersections) { feLog("Checking intersections ..."); if (CheckIntersections(g)) { feLog("FOUND!\n"); throw NegativeJacobianDetected(); } else feLog("all good.\n"); } // build the list of active elements #pragma omp parallel for shared(g) schedule(dynamic, 5) for (int i = 0; i < m_surf1.Elements(); ++i) { FESurfaceElement& el1 = m_surf1.Element(i); if (el1.isActive()) { set<FESurfaceElement*>& activeElems = m_activeElements[i]; activeElems.clear(); // list of elements to exclude. This will be neighbors and elements // already processed set<FESurfaceElement*> excludeList = m_elemNeighbors[i]; for (int n = 0; n < el1.GaussPoints(); ++n) { FECPContactPoint& mp1 = static_cast<FECPContactPoint&>(*el1.GetMaterialPoint(n)); mp1.m_gap = 0.0; vec3d r1 = mp1.m_rt; vec3d R1 = mp1.m_r0; vec3d n1 = mp1.dxr ^ mp1.dxs; n1.unit(); // find the grid cell this point is in and loop over the cell's neighborhood Grid::Cell* c[27] = { nullptr }; int nc = g.GetCellNeighborHood(r1, &c[0]); for (int l = 0; l < nc; ++l) { Grid::Cell* cl = c[l]; for (FESurfaceElement* el2 : cl->m_elemList) { // make sure we did not process this element yet // and the element is not a neighbor (which can be the case for self-contact) if (el2->isActive() && (excludeList.find(el2) == excludeList.end())) { // Next, we see if any integration point of el2 is close to the current // integration point of el1. vec3d r12; for (int m = 0; m < el2->GaussPoints(); ++m) { FEMaterialPoint* mp2 = el2->GetMaterialPoint(m); vec3d r2 = mp2->m_rt; vec3d R2 = mp2->m_r0; r12.x = r1.x - r2.x; r12.y = r1.y - r2.y; r12.z = r1.z - r2.z; // vec3d r12 = r1 - mp2.m_rt; if ((r12.x < m_Rout) && (r12.x > -m_Rout) && (r12.y < m_Rout) && (r12.y > -m_Rout) && (r12.z < m_Rout) && (r12.z > -m_Rout) && (r12.norm2() < m_Rout * m_Rout)) { double L12 = (R2 - R1).norm2(); double l12 = r12.unit(); if ((fabs(r12 * n1) >= m_wtol) && (L12 >= m_Rmin)) { // we found one, so insert it to the list of active elements activeElems.insert(el2); // also insert it to the exclude list excludeList.insert(el2); // fprintf(stderr, "r12: %lg, %lg, %lg\n", r12.x, r12.y, r12.z); // fprintf(stderr, "n1 : %lg, %lg, %lg\n", n1.x, n1.y, n1.z); // fprintf(stderr, "l12 = %lg\n", l12); if ((mp1.m_gap == 0.0) || (l12 < mp1.m_gap)) { mp1.m_gap = l12; } break; } } } } } } } } } } // Build the matrix profile void FEContactPotential::BuildMatrixProfile(FEGlobalMatrix& M) { 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"); // connect every element of surface 1 to surface 2 for (int i = 0; i < m_surf1.Elements(); ++i) { FESurfaceElement& el1 = m_surf1.Element(i); if (el1.isActive()) { // add the dofs of element 1 vector<int> lm; for (int j = 0; j < el1.Nodes(); ++j) { FENode& node = m_surf1.Node(el1.m_lnode[j]); lm.push_back(node.m_ID[dof_X]); lm.push_back(node.m_ID[dof_Y]); lm.push_back(node.m_ID[dof_Z]); lm.push_back(node.m_ID[dof_RU]); lm.push_back(node.m_ID[dof_RV]); lm.push_back(node.m_ID[dof_RW]); } // add all active dofs of surface 2 set<FESurfaceElement*>& activeElems = m_activeElements[i]; for (FESurfaceElement* el2 : activeElems) { for (int j = 0; j < el2->Nodes(); ++j) { FENode& node = m_surf2.Node(el2->m_lnode[j]); lm.push_back(node.m_ID[dof_X]); lm.push_back(node.m_ID[dof_Y]); lm.push_back(node.m_ID[dof_Z]); lm.push_back(node.m_ID[dof_RU]); lm.push_back(node.m_ID[dof_RV]); lm.push_back(node.m_ID[dof_RW]); } } M.build_add(lm); } } } double FEContactPotential::PotentialDerive(double r) { double f = 0.0; if (r < m_Rin) { f = (m_kc / pow(r, m_p)) - m_c2; } else if (r < m_Rout) { f = m_c1 * (r - m_Rout) * (r - m_Rout); } return f; } double FEContactPotential::PotentialDerive2(double r) { double f = 0.0; if (r < m_Rin) { f = -m_p*m_kc / pow(r, m_p + 1.0); } else if (r < m_Rout) { f = 2.0*m_c1 * (r - m_Rout); } return f; } // The LoadVector function evaluates the "forces" that contribute to the residual of the system void FEContactPotential::LoadVector(FEGlobalVector& R, const FETimeInfo& tp) { const int ndof = 3; // don't bother if kc is zero if (m_kc <= 0) return; // clear all contact tractions #pragma omp parallel { #pragma omp for for (int i = 0; i < m_surf1.Elements(); ++i) { FESurfaceElement& el = m_surf1.Element(i); if (el.isActive()) { for (int n = 0; n < el.GaussPoints(); ++n) { FECPContactPoint& cp = static_cast<FECPContactPoint&>(*el.GetMaterialPoint(n)); cp.m_Ln = 0.0; cp.m_tc = vec3d(0, 0, 0); } } } #pragma omp for for (int i = 0; i < m_surf2.Elements(); ++i) { FESurfaceElement& el = m_surf2.Element(i); if (el.isActive()) { for (int n = 0; n < el.GaussPoints(); ++n) { FECPContactPoint& cp = static_cast<FECPContactPoint&>(*el.GetMaterialPoint(n)); cp.m_Ln = 0.0; cp.m_tc = vec3d(0, 0, 0); } } } } // loop over all elements of surf 1 #pragma omp parallel for shared(R) for (int i = 0; i < m_surf1.Elements(); ++i) { FESurfaceElement& eli = m_surf1.Element(i); if (eli.isActive()) { int na = eli.Nodes(); vector<double> fe; vector<int> lm; // loop over all elements of surf 2 set<FESurfaceElement*>& activeElems = m_activeElements[i]; for (FESurfaceElement* elj : activeElems) { int nb = elj->Nodes(); // evaluate contribution to force vector fe.assign((na + nb) * ndof, 0.0); ElementForce(eli, *elj, fe); // setup the lm vector lm.resize(3 * (na + nb)); for (int a = 0; a < na; ++a) { FENode& node = m_surf1.Node(eli.m_lnode[a]); lm[3 * a] = node.m_ID[0]; lm[3 * a + 1] = node.m_ID[1]; lm[3 * a + 2] = node.m_ID[2]; } for (int b = 0; b < nb; ++b) { FENode& node = m_surf2.Node(elj->m_lnode[b]); lm[3 * na + 3 * b] = node.m_ID[0]; lm[3 * na + 3 * b + 1] = node.m_ID[1]; lm[3 * na + 3 * b + 2] = node.m_ID[2]; } // assemble R.Assemble(lm, fe); } } } // update contact pressures (only needed for plot output) #pragma omp parallel { #pragma omp for for (int i = 0; i < m_surf1.Elements(); ++i) { FESurfaceElement& el = m_surf1.Element(i); if (el.isActive()) { for (int n = 0; n < el.GaussPoints(); ++n) { FECPContactPoint& cp = static_cast<FECPContactPoint&>(*el.GetMaterialPoint(n)); cp.m_Ln = cp.m_tc.norm(); } } } #pragma omp for for (int i = 0; i < m_surf2.Elements(); ++i) { FESurfaceElement& el = m_surf2.Element(i); if (el.isActive()) { for (int n = 0; n < el.GaussPoints(); ++n) { FECPContactPoint& cp = static_cast<FECPContactPoint&>(*el.GetMaterialPoint(n)); cp.m_Ln = cp.m_tc.norm(); } } } } } void FEContactPotential::ElementForce(FESurfaceElement& el1, FESurfaceElement& el2, vector<double>& fe) { int na = el1.Nodes(); int nb = el2.Nodes(); double* w1 = el1.GaussWeights(); double* w2 = el2.GaussWeights(); for (int n = 0; n < el1.GaussPoints(); ++n) { const double* H1 = el1.H(n); FECPContactPoint& mp1 = static_cast<FECPContactPoint&>(*el1.GetMaterialPoint(n)); double Jw1 = mp1.m_Jt*w1[n]; vec3d r1 = mp1.m_rt; for (int m = 0; m < el2.GaussPoints(); ++m) { const double* H2 = el2.H(m); FECPContactPoint& mp2 = static_cast<FECPContactPoint&>(*el2.GetMaterialPoint(m)); double Jw2 = mp2.m_Jt*w2[m]; double Jw12 = Jw1 * Jw2; // get the position of the integration point vec3d r2 = mp2.m_rt; // get the normalized direction vector vec3d e12 = r1 - r2; double r12 = e12.unit(); // calculate the potential derivative double df = PotentialDerive(r12); // add to the force if (df != 0.0) { vec3d F = e12 * df; mp1.m_tc += F * Jw2; mp2.m_tc -= F * Jw1; for (int a = 0; a < na; ++a) { fe[3 * a ] += F.x * (H1[a] * Jw12); fe[3 * a + 1] += F.y * (H1[a] * Jw12); fe[3 * a + 2] += F.z * (H1[a] * Jw12); } for (int b = 0; b < nb; ++b) { fe[3 * (na + b) ] -= F.x * (H2[b] * Jw12); fe[3 * (na + b) + 1] -= F.y * (H2[b] * Jw12); fe[3 * (na + b) + 2] -= F.z * (H2[b] * Jw12); } } } } } // Evaluates the contriubtion to the stiffness matrix void FEContactPotential::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) { const int ndof = 3; // don't bother if kc is zero if (m_kc <= 0) return; // loop over all elements of surf 1 #pragma omp parallel for shared(LS) for (int i = 0; i < m_surf1.Elements(); ++i) { FESurfaceElement& eli = m_surf1.Element(i); if (eli.isActive()) { int na = eli.Nodes(); set<FESurfaceElement*>& activeElems = m_activeElements[i]; for (FESurfaceElement* elj : activeElems) { int nb = elj->Nodes(); FEElementMatrix ke((na + nb) * ndof, (na + nb) * ndof); ke.zero(); ElementStiffness(eli, *elj, ke); vector<int> lm(3 * (na + nb)); vector<int> en(na + nb); for (int a = 0; a < na; ++a) { FENode& node = m_surf1.Node(eli.m_lnode[a]); lm[3 * a] = node.m_ID[0]; lm[3 * a + 1] = node.m_ID[1]; lm[3 * a + 2] = node.m_ID[2]; en[a] = eli.m_node[a]; } for (int b = 0; b < nb; ++b) { FENode& node = m_surf2.Node(elj->m_lnode[b]); lm[3 * na + 3 * b] = node.m_ID[0]; lm[3 * na + 3 * b + 1] = node.m_ID[1]; lm[3 * na + 3 * b + 2] = node.m_ID[2]; en[na + b] = elj->m_node[b]; } ke.SetIndices(lm); ke.SetNodes(en); LS.Assemble(ke); } } } } void FEContactPotential::ElementStiffness(FESurfaceElement& el1, FESurfaceElement& el2, matrix& ke) { double* w1 = el1.GaussWeights(); double* w2 = el2.GaussWeights(); int na = el1.Nodes(); int nb = el2.Nodes(); for (int n = 0; n < el1.GaussPoints(); ++n) { const double* H1 = el1.H(n); FECPContactPoint& mp1 = static_cast<FECPContactPoint&>(*el1.GetMaterialPoint(n)); double Jw1 = mp1.m_Jt*w1[n]; vec3d r1 = mp1.m_rt; for (int m = 0; m < el2.GaussPoints(); ++m) { const double* H2 = el2.H(m); FECPContactPoint& mp2 = static_cast<FECPContactPoint&>(*el2.GetMaterialPoint(m)); double Jw2 = mp2.m_Jt*w2[m]; vec3d r2 = mp2.m_rt; // get the normalized direction vector vec3d e12 = r1 - r2; double r12 = e12.unit(); // calculate the potential's derivatives double df = PotentialDerive(r12); double d2f = PotentialDerive2(r12); // add to the stiffness mat3dd I(1.0); mat3d ExE = dyad(e12); mat3d P = (I - ExE) / r12; mat3d M = ExE * d2f + P * df; // 1-1 contribution for (int a = 0; a < na; ++a) { for (int b = 0; b < na; ++b) { mat3d K2 = M * Jw2; ke.add(3 * a, 3 * b, K2 * (H1[a] * H1[b])*Jw1); } } // 1-2 contribution for (int a = 0; a < na; ++a) { for (int b = 0; b < nb; ++b) { mat3d K2b = M * (H2[b] * Jw2); ke.sub(3 * a, 3 * na + 3 * b, K2b * (H1[a] * Jw1)); } } // 2-1 contribution for (int b = 0; b < nb; ++b) { for (int a = 0; a < na; ++a) { mat3d K1a = M * (H1[a] * Jw1); ke.sub(3 * na + 3*b, 3 * a, K1a * (H2[b] * Jw2)); } } // 2-2 contribution for (int a = 0; a < nb; ++a) { for (int b = 0; b < nb; ++b) { mat3d K1 = M * Jw1; ke.add(3*na + 3 * a, 3*na + 3 * b, K1 * (H2[a] * H2[b]) * Jw2); } } } } ke *= -1.0; } void FEContactPotential::Serialize(DumpStream& ar) { FEContactInterface::Serialize(ar); m_surf1.Serialize(ar); m_surf2.Serialize(ar); if (!ar.IsShallow() && ar.IsLoading()) { BuildNeighborTable(); m_activeElements.resize(m_surf1.Elements()); m_NNL.Create(m_surf1); } } bool FEContactPotential::CheckIntersections(FEContactPotential::Grid& g) { int intersectionCount = 0; #pragma omp parallel for shared(g, intersectionCount) schedule(dynamic) for (int i = 0; i < m_surf1.Nodes(); ++i) { int n0 = m_surf1.NodeIndex(i); int nval = m_NNL.Valence(i); int* nnl = m_NNL.NodeList(i); vec3d r0 = m_surf1.Node(i).m_rt; Grid::Cell* c[27] = { nullptr }; int nc = g.GetCellNeighborHood(r0, &c[0]); for (int j = 0; j < nval; ++j) { if (nnl[j] > i) { int n1 = m_surf1.NodeIndex(nnl[j]); vec3d r1 = m_surf1.Node(nnl[j]).m_rt; vec3d e = r1 - r0; double l = e.unit(); for (int k = 0; k < nc; ++k) { Grid::Cell* cl = c[k]; for (FESurfaceElement* el2 : cl->m_elemList) { FESurfaceElement& el = *el2; if (!el.HasNode(n0) && !el.HasNode(n1)) { double rs[2] = { 0 }, g(0); if (m_surf2.Intersect(el, r0, e, rs, g, 1e-7, false)) { if ((g >= 0) && (g <= l)) { /* int nid0 = m_surf1.Node(i).GetID(); int nid1 = m_surf1.Node(nnl[j]).GetID(); feLog("\nNode : %d, %d\n", nid0, nid1); int eid = el.m_elem[0].pe->GetID(); feLog("\nElement : %d\n", eid); */ # pragma omp atomic intersectionCount++; } } } } } } } } return (intersectionCount != 0); }
C++
3D
febiosoftware/FEBio
FEBioMech/FEAxialBodyForce.cpp
.cpp
2,730
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.*/ #include "stdafx.h" #include "FEAxialBodyForce.h" #include "FEElasticMaterial.h" BEGIN_FECORE_CLASS(FEAxialBodyForce, FEBodyForce); ADD_PARAMETER(s, "scale"); ADD_PARAMETER(p, "p"); ADD_PARAMETER(c, "c"); ADD_PARAMETER(n, "axis"); END_FECORE_CLASS(); FEAxialBodyForce::FEAxialBodyForce(FEModel* pfem) : FEBodyForce(pfem) { p = 0; c = vec3d(0, 0, 0); n = vec3d(0, 0, 1); s = 1; } vec3d FEAxialBodyForce::force(FEMaterialPoint& mp) { vec3d x = mp.m_rt; vec3d q = x - c; vec3d r = q - n*((q*n)/(n*n)); if (p == 0) { vec3d f = r * s; return f; } else { double R = r.norm(); double Rp = pow(R, p); vec3d f = r *(s*Rp); return f; } } mat3d FEAxialBodyForce::stiffness(FEMaterialPoint& mp) { mat3d K; K.zero(); if (p == 0) { K[0][0] = -s; K[1][1] = -s; K[2][2] = -s; } else { vec3d x = mp.m_rt; vec3d q = x - c; vec3d r = q - n * ((q * n) / (n * n)); double R = x.norm(); double Rp = pow(R, p); double Rpm2 = pow(R, p-2 ); K[0][0] = -s*(p * Rpm2 * r.x*r.x + Rp); K[0][1] = -s*(p * Rpm2 * r.x*r.y); K[0][2] = -s*(p * Rpm2 * r.x*r.z); K[1][0] = -s*(p * Rpm2 * r.y*r.x); K[1][1] = -s*(p * Rpm2 * r.y*r.y + Rp); K[1][2] = -s*(p * Rpm2 * r.y*r.z); K[2][0] = -s*(p * Rpm2 * r.z*r.x); K[2][1] = -s*(p * Rpm2 * r.z*r.y); K[2][2] = -s*(p * Rpm2 * r.z*r.z + Rp); } return K; } double FEAxialBodyForce::divforce(FEMaterialPoint& mp) { // TODO: implement this assert(false); return 0; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEFiberEntropyChainUC.h
.h
2,559
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 "FEElasticFiberMaterialUC.h" #include "FEFiberMaterial.h" //----------------------------------------------------------------------------- //! Exponential-power law //! (Variation that includes a shear term) class FEFiberEntropyChainUC : public FEFiberMaterialUncoupled { public: FEFiberEntropyChainUC(FEModel* pfem); /*//! Initialization 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_N; // coefficient of micro-combination number FEParamDouble mm_ksi; // measure of fiber modulus which equals to nkT int m_term; // double m_epsf; // declare the parameter list DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- class FEUncoupledFiberEntropyChainUC : public FEElasticFiberMaterialUC_T<FEFiberEntropyChainUC> { public: FEUncoupledFiberEntropyChainUC(FEModel* fem) : FEElasticFiberMaterialUC_T<FEFiberEntropyChainUC>(fem) {} DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEPreStrainUncoupledElastic.h
.h
2,562
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 "FEUncoupledMaterial.h" #include "FEPreStrainElastic.h" //----------------------------------------------------------------------------- //! This material applies a user-defined prestrain deformation gradient //! before evaluating the stress and tangents. class FEPreStrainUncoupledElastic : public FEUncoupledMaterial, public FEPrestrainMaterial { public: //! constructor FEPreStrainUncoupledElastic(FEModel* pfem); // returns a pointer to a new material point object FEMaterialPointData* CreateMaterialPointData() override; //! return the pre-strain gradient property FEPrestrainGradient* PrestrainGradientProperty() override { return m_Fp; } //! return the elastic material property FEElasticMaterial* GetElasticMaterial() override { return m_mat; } //! calculate (pre-strained) density double Density(FEMaterialPoint& mp) override; public: //! Cauchy stress mat3ds DevStress(FEMaterialPoint& mp) override; //! spatial tangent tens4ds DevTangent(FEMaterialPoint& mp) override; protected: //! calculate prestrain deformation gradient mat3d PrestrainGradient(FEMaterialPoint& mp); private: FEUncoupledMaterial* m_mat; //!< uncoupled elastic base material FEPrestrainGradient* m_Fp; //!< pre-strain gradient DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEMechModel.cpp
.cpp
7,221
253
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEMechModel.h" #include "FERigidSystem.h" #include <FECore/FEMaterial.h> #include <FECore/FEDomain.h> #include "FERigidBody.h" #include "FESolidMaterial.h" #include "FERigidMaterial.h" //----------------------------------------------------------------------------- BEGIN_FECORE_CLASS(FEMechModel, FEModel) ADD_PROPERTY(m_prs->RigidBodyList(), "rigid_body"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEMechModel::FEMechModel() { // create a rigid system m_prs = new FERigidSystem(this); } //----------------------------------------------------------------------------- // get the rigid system FERigidSystem* FEMechModel::GetRigidSystem() { return m_prs; } //----------------------------------------------------------------------------- // clear all model data void FEMechModel::Clear() { m_prs->Clear(); FEModel::Clear(); } //----------------------------------------------------------------------------- bool FEMechModel::Init() { // create and initialize the rigid bodies if (InitRigidSystem() == false) return false; // initialize the rest of the model return FEModel::Init(); } //----------------------------------------------------------------------------- // number of rigid bodies int FEMechModel::RigidBodies() const { return m_prs->Objects(); } //----------------------------------------------------------------------------- bool FEMechModel::InitRigidSystem() { return m_prs->Init(); } //----------------------------------------------------------------------------- // get a rigid body FERigidBody* FEMechModel::GetRigidBody(int n) { return m_prs->Object(n); } //----------------------------------------------------------------------------- // find a rigid body from a material ID int FEMechModel::FindRigidbodyFromMaterialID(int matId) { int NRB = RigidBodies(); for (int i = 0; i<NRB; ++i) { FERigidBody& rb = *GetRigidBody(i); if (rb.GetMaterialID() == matId) return i; } return -1; } //----------------------------------------------------------------------------- // return number or rigid BCs int FEMechModel::RigidBCs() const { return m_prs->RigidBCs(); } //----------------------------------------------------------------------------- // return the rigid displacement FERigidBC* FEMechModel::GetRigidBC(int i) { return m_prs->RigidBC(i); } //----------------------------------------------------------------------------- // add a rigid presribed BC void FEMechModel::AddRigidBC(FERigidBC* pDC) { m_prs->AddRigidBC(pDC); } //----------------------------------------------------------------------------- // add a rigid initial condition void FEMechModel::AddRigidInitialCondition(FERigidIC* pIC) { m_prs->AddInitialCondition(pIC); } //----------------------------------------------------------------------------- // model activation void FEMechModel::Activate() { // activate rigid components m_prs->Activate(); FEModel::Activate(); } //----------------------------------------------------------------------------- void FEMechModel::Reactivate() { FEModel::Reactivate(); m_prs->Activate(); } //----------------------------------------------------------------------------- bool FEMechModel::Reset() { if (m_prs->Reset() == false) return false; return FEModel::Reset(); } //----------------------------------------------------------------------------- bool FEMechModel::InitMesh() { if (FEModel::InitMesh() == false) return false; return m_prs->InitRigidBodies(); } //----------------------------------------------------------------------------- //! Initialize shells bool FEMechModel::InitShells() { // Base class does most of the work if (!FEModel::InitShells()) return false; // NOTE: This was moved here because I wanted to FEMaterial::IsRigid to FESolidMaterial::IsRigid // This was part of the move to rid the FECore library of rigid stuff // Find the nodes that are on a non-rigid shell. // These nodes will be assigned rotational degrees of freedom // TODO: Perhaps I should let the domains do this instead FEMesh& mesh = GetMesh(); for (int i = 0; i<mesh.Nodes(); ++i) mesh.Node(i).m_nstate &= ~FENode::SHELL; for (int nd = 0; nd<mesh.Domains(); ++nd) { FEDomain& dom = mesh.Domain(nd); if (dom.Class() == FE_DOMAIN_SHELL) { FESolidMaterial* pmat = dynamic_cast<FESolidMaterial*>(dom.GetMaterial()); if ((pmat == 0) || (pmat->IsRigid() == false)) { int N = dom.Elements(); for (int i = 0; i<N; ++i) { FEElement& el = dom.ElementRef(i); int n = el.Nodes(); for (int j = 0; j < n; ++j) { mesh.Node(el.m_node[j]).m_nstate |= FENode::SHELL; // TODO: Not sure why, but it looks like this is needed otherwise // the rigid bodies lock. mesh.Node(el.m_node[j]).m_nstate |= FENode::RIGID_CLAMP; } } } } } return true; } //----------------------------------------------------------------------------- // find a parameter value FEParamValue FEMechModel::GetParameterValue(const ParamString& paramString) { FEParamValue val = FEModel::GetParameterValue(paramString); if (val.isValid() == false) { return m_prs->GetParameterValue(paramString); } return val; } //----------------------------------------------------------------------------- void FEMechModel::SerializeGeometry(DumpStream& ar) { FEModel::SerializeGeometry(ar); m_prs->Serialize(ar); } //----------------------------------------------------------------------------- //! Build the matrix profile for this model void FEMechModel::BuildMatrixProfile(FEGlobalMatrix& G, bool breset) { FEModel::BuildMatrixProfile(G, breset); if (breset) { // Add rigid bodies to the profile m_prs->BuildMatrixProfile(G); } } //----------------------------------------------------------------------------- // update rigid part of mesh void FEMechModel::UpdateRigidMesh() { m_prs->UpdateMesh(); }
C++
3D
febiosoftware/FEBio
FEBioMech/FEHolmesMow.h
.h
2,237
62
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticMaterial.h" //----------------------------------------------------------------------------- class FEHolmesMow : public FEElasticMaterial { public: FEHolmesMow(FEModel* pfem) : FEElasticMaterial(pfem) {} public: double m_E; //!< Young's modulus double m_v; //!< Poisson's ratio double m_b; //!< Exponential stiffening coefficient double lam; //!< first Lame coefficient double mu; //!< second Lame coefficient double Ha; //!< aggregate modulus public: //! calculate stress at material point virtual mat3ds Stress(FEMaterialPoint& pt) override; //! calculate tangent stiffness at material point virtual tens4ds Tangent(FEMaterialPoint& pt) override; //! calculate strain energy density at material point virtual double StrainEnergyDensity(FEMaterialPoint& pt) override; //! data initialization and checking bool Validate() override; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEBCRigidDeformation.h
.h
1,720
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 <FECore/FEPrescribedBC.h> class FEBCRigidDeformation : public FEPrescribedNodeSet { public: FEBCRigidDeformation(FEModel* fem); void Activate() override; void CopyFrom(FEBoundaryCondition* pbc) override; protected: void GetNodalValues(int nodelid, std::vector<double>& val) override; private: vec3d m_r0; vec3d m_rt; // rigid body position vec3d m_qt; // rigid body rotation vector DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEInitialPreStrain.h
.h
1,716
45
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEInitialCondition.h> //----------------------------------------------------------------------------- // This initial condition grabs the fiber stretch and initializes the pre_stretch // variable with that value. class FEInitialPreStrain : public FEInitialCondition { public: FEInitialPreStrain(FEModel* pfem); void Activate() override; private: bool m_binit; bool m_breset; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEMembraneMaterial.cpp
.cpp
3,806
123
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEMembraneMaterial.h" //----------------------------------------------------------------------------- // convet the displacement gradient to a strain void FEMembraneMaterialPoint::strain(double e[3]) { const double h1[6] = {1, 0, 0, 0, 0, 0}; const double h2[6] = {0, 0, 0, 0, 1, 0}; const double h3[6] = {0, 1, 0, 1, 0, 0}; const double H1[6][6] = { {1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}}; const double H2[6][6] = { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 1}}; const double H3[6][6] = { {0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0}}; e[0] = e[1] = e[2] = 0.0; for (int i=0; i<6; ++i) { e[0] += h1[i]*g[i]; e[1] += h2[i]*g[i]; e[2] += h3[i]*g[i]; for (int j=0; j<6; ++j) { e[0] += 0.5*g[i]*H1[i][j]*g[j]; e[1] += 0.5*g[i]*H2[i][j]*g[j]; e[2] += 0.5*g[i]*H3[i][j]*g[j]; } } } //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEElasticMembrane, FEMembraneMaterial) ADD_PARAMETER(m_E, FE_RANGE_GREATER(0.0), "E"); ADD_PARAMETER(m_v, FE_RANGE_RIGHT_OPEN(-1.0, 0.5), "v"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- void FEElasticMembrane::Stress(FEMaterialPoint &mp, double s[]) { FEMembraneMaterialPoint& pt = *mp.ExtractData<FEMembraneMaterialPoint>(); // get the material point strain double e[3]; pt.strain(e); // elasticity tangent double E = 1.0; double v = 0.35; double d = 1.0/(1.0 - v*v); double D[3][3] = { {d*E, d*v*E, 0}, {d*v*E, d*E, 0}, {0, 0, d*E*(1.0-v)*0.5}}; // calculate 2D PK2-stress s[0] = D[0][0]*e[0] + D[0][1]*e[1] + D[0][2]*e[2]; s[1] = D[1][0]*e[0] + D[1][1]*e[1] + D[1][2]*e[2]; s[2] = D[2][0]*e[0] + D[2][1]*e[1] + D[2][2]*e[2]; } //----------------------------------------------------------------------------- void FEElasticMembrane::Tangent(FEMaterialPoint &mp, double D[][3]) { FEMembraneMaterialPoint& pt = *mp.ExtractData<FEMembraneMaterialPoint>(); // elasticity tangent double E = 1.0; double v = 0.35; double d = 1.0/(1.0 - v*v); D[0][0] = d*E; D[0][1] = d*v*E; D[0][2] = 0; D[1][0] = d*v*E; D[1][1] = d*E; D[1][2] = 0; D[2][0] = 0; D[2][1] = 0; D[2][2] = d*E*(1.0-v)*0.5; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEFiberEFDNeoHookean.h
.h
2,422
76
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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" // The following file contains the integration points and weights // for the integration over a unit sphere in spherical coordinates #include "geodesic.h" class FEFiberEFDNeoHookean : public FEElasticMaterial { public: FEFiberEFDNeoHookean(FEModel* 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& mp) override; //! material parameter intialization and checking bool Init() override; public: double m_E; //!< Young's modulus double m_v; //!< Poisson's ratio //--- active contraction stuff --- double m_a[3]; double m_ac; // ------------------------------- // numerical quadrature stuff int m_nres; // integration rule double m_cth[NSTH]; double m_sth[NSTH]; double m_cph[NSTH]; double m_sph[NSTH]; double m_w[NSTH]; bool m_bfirst; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEHolzapfelUnconstrained.cpp
.cpp
7,697
219
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEHolzapfelUnconstrained.h" // define the material parameters BEGIN_FECORE_CLASS(FEHolzapfelUnconstrained, FEElasticMaterial) ADD_PARAMETER(m_c , FE_RANGE_GREATER_OR_EQUAL(0.0), "c")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_k1 , FE_RANGE_GREATER_OR_EQUAL(0.0), "k1")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_k2 , FE_RANGE_GREATER_OR_EQUAL(0.0), "k2")->setUnits(UNIT_NONE); ADD_PARAMETER(m_kappa, FE_RANGE_CLOSED(0.0, 1.0/3.0), "kappa")->setUnits(UNIT_NONE); ADD_PARAMETER(m_gdeg , "gamma")->setUnits(UNIT_DEGREE); ADD_PARAMETER(m_k , FE_RANGE_GREATER_OR_EQUAL(0.0), "k")->setUnits(UNIT_PRESSURE); ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Calculates the stress mat3ds FEHolzapfelUnconstrained::Stress(FEMaterialPoint& mp) { double c = m_c(mp); double k1 = m_k1(mp); double k2 = m_k2(mp); double kappa = m_kappa(mp); double g = m_gdeg(mp)*PI/180; double k = m_k(mp); FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // determinant of deformation gradient double J = pt.m_J; // calculate left Cauchy-Green tensor: b = F*Ft mat3ds b = pt.LeftCauchyGreen(); mat3ds C = pt.RightCauchyGreen(); double I1 = C.tr(); // get the local coordinate systems mat3d Q = GetLocalCS(mp); // Copy the local element basis directions to n vec3d n[2]; n[0].x = Q[0][0]; n[0].y = Q[1][0]; n[0].z = Q[2][0]; n[1].x = Q[0][1]; n[1].y = Q[1][1]; n[1].z = Q[2][1]; // Evaluate the structural direction in the current configuration double cg = cos(g); double sg = sin(g); vec3d ar[2],a[2]; ar[0] = n[0]*cg + n[1]*sg; a[0] = pt.m_F*ar[0]; ar[1] = n[0]*cg - n[1]*sg; a[1] = pt.m_F*ar[1]; // Evaluate the ground matrix stress mat3dd I(1.0); mat3ds s = c*(b-I) + I*((J*J-1.0)*(k*0.5)); // Evaluate the structural tensors in the current configuration // and the fiber strains and stress contributions double I40 = ar[0]*(C*ar[0]); double E0 = kappa*(I1-3) + (1-3*kappa)*(I40-1); if (E0 >= 0) { mat3ds h0 = kappa*b + (1-3*kappa)*dyad(a[0]); s += h0*(2.*k1*E0*exp(k2*E0*E0)); } double I41 = ar[1]*(C*ar[1]); double E1 = kappa*(I1-3) + (1-3*kappa)*(I41-1); if (E1 >= 0) { mat3ds h1 = kappa*b + (1-3*kappa)*dyad(a[1]); s += h1*(2.*k1*E1*exp(k2*E1*E1)); } return s / J; } //----------------------------------------------------------------------------- //! Calculates the tangent tens4ds FEHolzapfelUnconstrained::Tangent(FEMaterialPoint& mp) { double c = m_c(mp); double k1 = m_k1(mp); double k2 = m_k2(mp); double kappa = m_kappa(mp); double g = m_gdeg(mp)*PI/180; double k = m_k(mp); FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // determinant of deformation gradient double J = pt.m_J; // calculate left Cauchy-Green tensor: b = F*Ft mat3ds b = pt.LeftCauchyGreen(); mat3ds C = pt.RightCauchyGreen(); double I1 = C.tr(); // get the local coordinate systems mat3d Q = GetLocalCS(mp); // Copy the local element basis directions to n vec3d n[2]; n[0].x = Q[0][0]; n[0].y = Q[1][0]; n[0].z = Q[2][0]; n[1].x = Q[0][1]; n[1].y = Q[1][1]; n[1].z = Q[2][1]; // Evaluate the structural direction in the current configuration double cg = cos(g); double sg = sin(g); vec3d ar[2],a[2]; ar[0] = n[0]*cg + n[1]*sg; a[0] = pt.m_F*ar[0]; ar[1] = n[0]*cg - n[1]*sg; a[1] = pt.m_F*ar[1]; // Evaluate the structural tensors in the current configuration // and the fiber strains and stress contributions double I40 = ar[0]*(C*ar[0]); double E0 = kappa*(I1-3) + (1-3*kappa)*(I40-1); mat3ds h0; if (E0 >= 0) { h0 = kappa*b + (1-3*kappa)*dyad(a[0]); } double I41 = ar[1]*(C*ar[1]); double E1 = kappa*(I1-3) + (1-3*kappa)*(I41-1); mat3ds h1; if (E1 >= 0) { h1 = kappa*b + (1-3*kappa)*dyad(a[1]); } // Evaluate the elasticity tensor mat3dd I(1); tens4ds IoI = dyad4s(I); tens4ds IxI = dyad1s(I); tens4ds ce = IoI*(2*c-(J*J-1.0)*k) + IxI*(J*J*k); if (E0 >= 0) ce += dyad1s(h0)*(4.*k1*(1 + 2 * k2*E0*E0)*exp(k2*E0*E0)); if (E1 >= 0) ce += dyad1s(h1)*(4.*k1*(1 + 2 * k2*E1*E1)*exp(k2*E1*E1)); return ce / J; } //----------------------------------------------------------------------------- //! Calculates the strain energy density double FEHolzapfelUnconstrained::StrainEnergyDensity(FEMaterialPoint& mp) { double c = m_c(mp); double k1 = m_k1(mp); double k2 = m_k2(mp); double kappa = m_kappa(mp); double g = m_gdeg(mp)*PI/180; double k = m_k(mp); FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // determinant of deformation gradient double J = pt.m_J; vec3d n[3]; // local element basis directions mat3ds h[2]; // structural tensor in current configuration double E[2]; // fiber strain // calculate right Cauchy-Green tensor mat3ds C = pt.RightCauchyGreen(); double I1 = C.tr(); // get the local coordinate systems mat3d Q = GetLocalCS(mp); // Copy the local element basis directions to n n[0].x = Q[0][0]; n[0].y = Q[1][0]; n[0].z = Q[2][0]; n[1].x = Q[0][1]; n[1].y = Q[1][1]; n[1].z = Q[2][1]; // Evaluate the structural direction in the current configuration double cg = cos(g); double sg = sin(g); vec3d ar[2]; ar[0] = n[0]*cg + n[1]*sg; ar[1] = n[0]*cg - n[1]*sg; // Evaluate the ground matrix strain energy density double sed = 0.5*c*(I1 - 3) - c*log(J) + (k/2)*((J*J-1)/2 - log(J)); // Evaluate the structural tensors in the current configuration // and the fiber strains and stress contributions double I40 = ar[0]*(C*ar[0]); E[0] = kappa*(I1-3) + (1-3*kappa)*(I40-1); if (E[0] >= 0) sed += 0.5*k1/k2*(exp(k2*E[0]*E[0])-1); double I41 = ar[1]*(C*ar[1]); E[1] = kappa*(I1-3) + (1-3*kappa)*(I41-1); if (E[1] >= 0) sed += 0.5*k1/k2*(exp(k2*E[1]*E[1])-1); return sed; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEPrescribedNormalDisplacement.h
.h
2,072
62
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEPrescribedBC.h> #include "febiomech_api.h" class FEBIOMECH_API FEPrescribedNormalDisplacement : public FEPrescribedSurface { public: // constructor FEPrescribedNormalDisplacement(FEModel* fem); // activation void Activate() override; public: // return the value for node i, dof j void GetNodalValues(int nodelid, std::vector<double>& val) override; // copy data from another class void CopyFrom(FEBoundaryCondition* pbc) override; void Serialize(DumpStream& ar) override; private: vector<vec3d> m_normals; double m_scale; // hint parameter helps to identify the surface geometry // 0 : no hint (default) // 1 : sphere with center at origin int m_hint; //!< hint parameter helps to identify the surface geometry DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEPrescribedActiveContractionIsotropic.h
.h
1,932
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 "FEElasticMaterial.h" //----------------------------------------------------------------------------- // This material implements an active contraction model which can be used // as a component of a solid mixture material. class FEPrescribedActiveContractionIsotropic : public FEElasticMaterial { public: //! constructor FEPrescribedActiveContractionIsotropic(FEModel* pfem); //! stress mat3ds Stress(FEMaterialPoint& pt) override; //! tangent tens4ds Tangent(FEMaterialPoint& pt) override; public: FEParamDouble m_T0; // prescribed active stress DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FERigidNodeSet.cpp
.cpp
4,195
130
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FERigidNodeSet.h" #include <FECore/FEModel.h> #include "FERigidMaterial.h" #include "FEMechModel.h" #include "FERigidBody.h" BEGIN_FECORE_CLASS(FERigidNodeSet, FENodalBC) ADD_PARAMETER(m_rigidMat, "rb")->setEnums("$(rigid_materials)"); ADD_PARAMETER(m_bshellBC, "clamp_shells")->SetFlags(FEParamFlag::FE_PARAM_HIDDEN); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FERigidNodeSet::FERigidNodeSet(FEModel* pfem) : FENodalBC(pfem) { m_rigidMat = -1; m_bshellBC = true; } //----------------------------------------------------------------------------- void FERigidNodeSet::CopyFrom(FEBoundaryCondition* pbc) { assert(false); } //----------------------------------------------------------------------------- bool FERigidNodeSet::Init() { // Make sure the rigid material exists FEModel& fem = *GetFEModel(); if (m_rigidMat <= 0) return false; FERigidMaterial* pm = dynamic_cast<FERigidMaterial*>(fem.GetMaterial(m_rigidMat - 1)); if (pm == 0) return false; if (pm->GetRigidBodyID() < 0) return false; return FENodalBC::Init(); } //----------------------------------------------------------------------------- void FERigidNodeSet::Activate() { FENodalBC::Activate(); // get the rigid body's ID FEMechModel& fem = dynamic_cast<FEMechModel&>(*GetFEModel()); FERigidMaterial* pm = dynamic_cast<FERigidMaterial*>(fem.GetMaterial(m_rigidMat - 1)); int rid = pm->GetRigidBodyID(); assert(rid >= 0); FERigidBody& rb = *fem.GetRigidBody(rid); // assign the rigid body ID FEStepComponent::Activate(); FEMesh& mesh = fem.GetMesh(); FENodeSet& nset = *GetNodeSet(); for (size_t i=0; i<nset.Size(); ++i) { FENode& node = mesh.Node(nset[i]); if (m_bshellBC) { if (node.HasFlags(FENode::SHELL)) node.SetFlags(FENode::RIGID_CLAMP); } node.m_rid = rid; // we need to take the current position of the node // and transform it into the reference configuration of the rigid body. vec3d dr = node.m_rt - rb.m_rt; quatd q = rb.GetRotation().Inverse(); q.RotateVector(dr); node.m_ra = rb.m_r0 + dr; } } //----------------------------------------------------------------------------- void FERigidNodeSet::SetRigidMaterialID(int rid) { m_rigidMat = rid; } //----------------------------------------------------------------------------- void FERigidNodeSet::Deactivate() { FENodalBC::Deactivate(); FEMesh& mesh = GetFEModel()->GetMesh(); FENodeSet& nset = *GetNodeSet(); for (size_t i=0; i<nset.Size(); ++i) { FENode& node = mesh.Node(nset[i]); if (m_bshellBC) { if (node.HasFlags(FENode::SHELL)) node.UnsetFlags(FENode::RIGID_CLAMP); } node.m_rid = -1; } } //----------------------------------------------------------------------------- void FERigidNodeSet::Serialize(DumpStream& ar) { FENodalBC::Serialize(ar); if (ar.IsShallow()) return; ar & m_rigidMat & m_bshellBC; }
C++
3D
febiosoftware/FEBio
FEBioMech/FECoupledTransIsoVerondaWestmann.cpp
.cpp
6,849
248
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FECoupledTransIsoVerondaWestmann.h" #include <FECore/log.h> #include <FECore/expint_Ei.h> #include <FECore/FEConstValueVec3.h> //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FECoupledTransIsoVerondaWestmann, FEElasticMaterial) ADD_PARAMETER(m_c1 , FE_RANGE_GREATER(0.0), "c1")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_c2 , "c2"); ADD_PARAMETER(m_c3 , "c3")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_c4 , "c4"); ADD_PARAMETER(m_c5 , "c5")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_flam, FE_RANGE_GREATER_OR_EQUAL(1.0), "lambda"); ADD_PARAMETER(m_K , FE_RANGE_GREATER(0.0), "k")->setUnits(UNIT_PRESSURE); ADD_PROPERTY(m_fiber, "fiber"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FECoupledTransIsoVerondaWestmann::FECoupledTransIsoVerondaWestmann(FEModel* pfem) : FEElasticMaterial(pfem) { m_c1 = 0.0; m_c2 = 0.0; m_c3 = 0.0; m_c4 = 0.0; m_c5 = 0.0; m_flam = 1.0; m_K = 0.0; m_fiber = nullptr; } //----------------------------------------------------------------------------- //! Calculate the Cauchy stress mat3ds FECoupledTransIsoVerondaWestmann::Stress(FEMaterialPoint& mp) { // get the material point data FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // calculate left Cauchy-Green tensor mat3ds B = pt.LeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // get the material fiber axis vec3d a0 = m_fiber->unitVector(mp); // get the spatial fiber axis vec3d a = pt.m_F*a0; double l = a.unit(); // Invariants of B (= invariants of C) double I1 = B.tr(); double J = pt.m_J; // some useful tensors mat3dd I(1.0); mat3ds A = dyad(a); // a. define the matrix stress //----------------------------- // W = C1*(exp(C2*(I1-3)-1)-0.5*C1*C2*(I2 - 3) // Wi = dW/dIi double W1 = m_c1*m_c2*exp(m_c2*(I1-3)); double W2 = -0.5*m_c1*m_c2; mat3ds s = (B*(W1 + I1*W2) - B2*W2)*(2.0/J); // b. define fiber stress //------------------------- if (l > 1.0) { double Wl = 0.0; if (l < m_flam) { Wl = m_c3*(exp(m_c4*(l - 1.0)) - 1.0); } else { double c6 = m_c3*(exp(m_c4*(m_flam - 1.0)) - 1.0) - m_c5*m_flam; Wl = m_c5*l + c6; } s += A*(Wl/J); } // c. define dilational stress //------------------------------ // U(J) = 1/2*k*(lnJ)^2 double UJ = m_K*log(J)/J; s += I*UJ; return s; } //----------------------------------------------------------------------------- //! Calculate the spatial elasticity tangent tens4ds FECoupledTransIsoVerondaWestmann::Tangent(FEMaterialPoint& mp) { // get material point data FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // calculate left Cauchy-Green tensor: B = F*Ft mat3ds B = pt.LeftCauchyGreen(); // get the material fiber axis vec3d a0 = m_fiber->unitVector(mp); // get the spatial fiber axis vec3d a = pt.m_F*a0; double l = a.unit(); // Invariants of B (= invariants of C) double I1 = B.tr(); double J = pt.m_J; double I4 = l*l; // some useful tensors mat3dd I(1.0); mat3ds A = dyad(a); tens4ds IxI = dyad1s(I); tens4ds IoI = dyad4s(I); tens4ds BxB = dyad1s(B); tens4ds BoB = dyad4s(B); tens4ds AxA = dyad1s(A); // a. matrix tangent //---------------------------------- double W1 = m_c1*m_c2*exp(m_c2*(I1-3)); double W11 = m_c2*W1; double W2 = -0.5*m_c1*m_c2; tens4ds c = BxB*(4.0*(W11+W2)/J) - BoB*(4.0*W2/J); // b. fiber tangent // --------------------------------- if (l > 1.0) { double Fl = 0.0, Fll = 0.0; if (l < m_flam) { Fl = m_c3*(exp(m_c4*(l - 1.0)) - 1.0)/l; Fll = -m_c3*(exp(m_c4*(l-1.0)) - 1.0)/(l*l) + m_c3*m_c4*exp(m_c4*(l-1.0))/l; } else { double c6 = m_c3*(exp(m_c4*(m_flam - 1.0)) - 1.0) - m_c5*m_flam; Fl = m_c5 + c6 / l; Fll = -c6/(l*l); } double W44 = (Fll - Fl/l)/(4*l*l); c += AxA*(4.0*W44*I4*I4/J); } // c. dilational tangent // --------------------------------- double UJ = m_K*log(J)/J; double UJJ = m_K*(1 - log(J))/(J*J); c += IxI*(UJ + J*UJJ) - IoI*(2.0*UJ); return c; } //----------------------------------------------------------------------------- //! calculate strain energy density at material point double FECoupledTransIsoVerondaWestmann::StrainEnergyDensity(FEMaterialPoint& mp) { // get the material point data FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // calculate left Cauchy-Green tensor mat3ds B = pt.LeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // get the material fiber axis vec3d a0 = m_fiber->unitVector(mp); // get the spatial fiber axis vec3d a = pt.m_F*a0; double l = a.unit(); // Invariants of B (= invariants of C) double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); double J = pt.m_J; double lnJ = log(J); // a. define the matrix strain energy density //----------------------------- // W = C1*(exp(C2*(I1-3)-1)-0.5*C1*C2*(I2 - 3) double sed = m_c1*(exp(m_c2*(I1-3))-1) - m_c1*m_c2*(I2-3)/2; // b. define fiber strain energy density //------------------------- if (l > 1.0) { if (l < m_flam) { sed += m_c3*(exp(-m_c4)*(expint_Ei(m_c4*l) - expint_Ei(m_c4))-log(l)); } else { double c6 = m_c3*(exp(m_c4*(m_flam - 1.0)) - 1.0) - m_c5*m_flam; sed += m_c5*(l-1) +c6*log(l); } } // c. add dilational strain energy density //------------------------------ // U(J) = 1/2*k*(lnJ)^2 sed += m_K*lnJ*lnJ/2; return sed; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEUncoupledReactiveViscoelastic.h
.h
5,171
130
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEBondRelaxation.h" #include "FEBondRecruitment.h" #include "FEReactiveVEMaterialPoint.h" #include "FEDamageMaterialUC.h" #include "FEUncoupledReactiveFatigue.h" #include <FECore/FEFunction1D.h> //----------------------------------------------------------------------------- //! This class implements a large deformation reactive viscoelastic material //! with uncoupled strain energy density formulation // class FEUncoupledReactiveViscoelasticMaterial : public FEUncoupledMaterial { public: //! default constructor FEUncoupledReactiveViscoelasticMaterial(FEModel* pfem); //! get the elastic base material FEUncoupledMaterial* GetBaseMaterial() { return m_pBase; } //! Set the base material void SetBaseMaterial(FEUncoupledMaterial* pbase) { m_pBase = pbase; } //! get the elastic bond material FEUncoupledMaterial* GetBondMaterial() { return m_pBond; } //! Set the base material void SetBondMaterial(FEUncoupledMaterial* pbond) { m_pBond = pbond; } public: //! data initialization bool Init() override; //! stress function mat3ds DevStress(FEMaterialPoint& pt) override; mat3ds DevStressStrongBonds(FEMaterialPoint& pt); mat3ds DevStressWeakBonds(FEMaterialPoint& pt); //! tangent function tens4ds DevTangent(FEMaterialPoint& pt) override; tens4ds DevTangentStrongBonds(FEMaterialPoint& pt); tens4ds DevTangentWeakBonds(FEMaterialPoint& pt); //! strain energy density function double DevStrainEnergyDensity(FEMaterialPoint& pt) override; double StrongBondDevSED(FEMaterialPoint& pt) override; double WeakBondDevSED(FEMaterialPoint& pt) override; //! cull generations void CullGenerations(FEMaterialPoint& pt); //! evaluate bond mass fraction for a given generation double BreakingBondMassFraction(FEMaterialPoint& pt, const int ig, const mat3ds D); //! evaluate bond mass fraction of reforming generation double ReformingBondMassFraction(FEMaterialPoint& pt); //! detect new generation bool NewGeneration(FEMaterialPoint& pt); //! return number of generations int RVEGenerations(FEMaterialPoint& pt); //! returns a pointer to a new material point object FEMaterialPointData* CreateMaterialPointData() override; //! specialized material points void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override; //! get base material point FEMaterialPoint* GetBaseMaterialPoint(FEMaterialPoint& mp); //! get bond material point FEMaterialPoint* GetBondMaterialPoint(FEMaterialPoint& mp); //! evaluate scalar strain measure (same type as trigger strain for bond breaking) double ScalarStrain(FEMaterialPoint& mp); private: FEUncoupledMaterial* m_pBase; //!< pointer to elastic solid material for strong bonds FEUncoupledMaterial* m_pBond; //!< pointer to elastic solid material for reactive bonds FEBondRelaxation* m_pRelx; //!< pointer to bond relaxation material for reactive bonds FEBondRecruitment* m_pWCDF; //!< pointer to weak bond recruitment function private: FEDamageMaterialUC* m_pDmg; //!< pointer to base material if it is a FEDamageMaterialUC FEUncoupledReactiveFatigue* m_pFtg; //!< pointer to base material if it is a FEUncoupledReactiveFatigue double Damage(FEMaterialPoint& mp); //!< return damage in the base material public: double m_wmin; //!< minimum value of relaxation int m_btype; //!< bond kinetics type int m_ttype; //!< bond breaking trigger type double m_emin; //!< strain threshold for triggering new generation int m_nmax; //!< highest number of generations achieved in analysis DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FETCNonlinearOrthotropic.h
.h
2,280
66
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEUncoupledMaterial.h" //----------------------------------------------------------------------------- //! Tension-compression nonlinear orthrotropic //! This is Gerard's material model for articular cartilage. //! \todo Make an orthotropic material base class where we //! can derive this material from. class FETCNonlinearOrthotropic : public FEUncoupledMaterial { public: FETCNonlinearOrthotropic(FEModel* pfem); public: //! calculate deviatoric stress at material point virtual mat3ds DevStress(FEMaterialPoint& pt) override; //! calculate deviatoric tangent stiffness at material point virtual tens4ds DevTangent(FEMaterialPoint& pt) override; //! Strain energy density double DevStrainEnergyDensity(FEMaterialPoint& mp) override; public: double m_beta[3]; double m_ksi[3]; double m_c1; //!< Mooney-Rivlin coefficient c1 double m_c2; //!< Mooney-Rivlin coefficient c2 double m_epsf; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEEllipsoidalFiberDistribution.h
.h
3,361
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 "FEElasticMaterial.h" // The following file contains the integration points and weights // for the integration over a unit sphere in spherical coordinates #include "geodesic.h" //----------------------------------------------------------------------------- //! Material class for the ellipsoidal fiber distribution //! class FEEllipsoidalFiberDistribution : public FEElasticMaterial { enum { MAX_INT = 45 }; public: FEEllipsoidalFiberDistribution(FEModel* pfem) : FEElasticMaterial(pfem) {} //! Cauchy stress virtual mat3ds Stress(FEMaterialPoint& mp) override; // Spatial tangent virtual tens4ds Tangent(FEMaterialPoint& mp) override; //! calculate strain energy density at material point virtual double StrainEnergyDensity(FEMaterialPoint& pt) override; public: FEParamDouble m_beta[3]; // power in power-law relation FEParamDouble m_ksi[3]; // coefficient in power-law relation // declare the parameter list DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- //! Material class for the ellipsoidal fiber distribution //! (this is the old, obsolete implementation) class FEEllipsoidalFiberDistributionOld : public FEElasticMaterial { public: FEEllipsoidalFiberDistributionOld(FEModel* pfem); //! Initialization bool Init() override; //! Serialization void Serialize(DumpStream& ar) override; //! Cauchy stress virtual mat3ds Stress(FEMaterialPoint& mp) override; // Spatial tangent virtual tens4ds Tangent(FEMaterialPoint& mp) override; //! calculate strain energy density at material point virtual double StrainEnergyDensity(FEMaterialPoint& pt) override; protected: void InitIntegrationRule(); public: // parameters FEParamDouble m_beta[3]; // power in power-law relation FEParamDouble m_ksi[3]; // coefficient in power-law relation private: int m_nres; // integration rule double m_cth[NSTH]; double m_sth[NSTH]; double m_cph[NSTH]; double m_sph[NSTH]; double m_w[NSTH]; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEPlasticFlowCurve.cpp
.cpp
10,510
304
// // FEPlasticFlowCurve.cpp // FEBioMech // // Created by Gerard Ateshian on 9/6/21. // Copyright © 2021 febio.org. All rights reserved. // #include "FEPlasticFlowCurve.h" #include <FECore/log.h> //----------------------------------------------------------------------------- // F E P L A S T I C F L O W C U R V E M A T E R I A L P O I N T //----------------------------------------------------------------------------- //! Create a shallow copy of the material point data FEMaterialPointData* FEPlasticFlowCurveMaterialPoint::Copy() { FEPlasticFlowCurveMaterialPoint* pt = new FEPlasticFlowCurveMaterialPoint(*this); if (m_pNext) pt->m_pNext = m_pNext->Copy(); return pt; } //----------------------------------------------------------------------------- //! Initializes material point data. void FEPlasticFlowCurveMaterialPoint::Init() { // don't forget to initialize the base class FEMaterialPointData::Init(); } //----------------------------------------------------------------------------- void FEPlasticFlowCurveMaterialPoint::Serialize(DumpStream& ar) { FEMaterialPointData::Serialize(ar); ar & m_Ky & m_w; ar & m_binit; } //----------------------------------------------------------------------------- // F E P L A S T I C F L O W C U R V E //----------------------------------------------------------------------------- vector<double> FEPlasticFlowCurve::BondYieldMeasures(FEMaterialPoint& mp) { FEPlasticFlowCurveMaterialPoint& fp = *mp.ExtractData<FEPlasticFlowCurveMaterialPoint>(); return fp.m_Ky; } //----------------------------------------------------------------------------- vector<double> FEPlasticFlowCurve::BondMassFractions(FEMaterialPoint& mp) { FEPlasticFlowCurveMaterialPoint& fp = *mp.ExtractData<FEPlasticFlowCurveMaterialPoint>(); return fp.m_w; } //----------------------------------------------------------------------------- size_t FEPlasticFlowCurve::BondFamilies(FEMaterialPoint& mp) { FEPlasticFlowCurveMaterialPoint& fp = *mp.ExtractData<FEPlasticFlowCurveMaterialPoint>(); return fp.m_Ky.size(); } //----------------------------------------------------------------------------- //! Create material point data for this material FEMaterialPointData* FEPlasticFlowCurve::CreateMaterialPointData() { return new FEPlasticFlowCurveMaterialPoint(new FEMaterialPointData()); } //----------------------------------------------------------------------------- // F E P L A S T I C F L O W C U R V E P A P E R //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEPlasticFlowCurvePaper, FEPlasticFlowCurve) ADD_PARAMETER(m_Ymin , FE_RANGE_GREATER_OR_EQUAL(0.0), "Y0" ); ADD_PARAMETER(m_Ymax , FE_RANGE_GREATER_OR_EQUAL(0.0), "Ymax"); ADD_PARAMETER(m_wmin , FE_RANGE_CLOSED(0.0, 1.0) , "w0" ); ADD_PARAMETER(m_we , FE_RANGE_CLOSED(0.0, 1.0) , "we" ); ADD_PARAMETER(m_n , FE_RANGE_GREATER(0) , "nf" ); ADD_PARAMETER(m_bias , FE_RANGE_LEFT_OPEN(0.0, 1.0) , "r" ); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FEPlasticFlowCurvePaper::FEPlasticFlowCurvePaper(FEModel* pfem) : FEPlasticFlowCurve(pfem) { m_n = 1; m_wmin = 1; m_wmax = 1; m_we = 0; m_Ymin = 0; m_Ymax = 0; m_bias = 0.9; } //----------------------------------------------------------------------------- //! Initialization. bool FEPlasticFlowCurvePaper::InitFlowCurve(FEMaterialPoint& mp) { FEPlasticFlowCurveMaterialPoint& fp = *mp.ExtractData<FEPlasticFlowCurveMaterialPoint>(); if (fp.m_binit == false) { double wmin = m_wmin(mp); double wmax = m_wmax(mp); double we = m_we(mp); double Ymin = m_Ymin(mp); double Ymax = m_Ymax(mp); double bias = m_bias(mp); wmax = 1 - we; if (wmax < wmin) { if (m_n ==1) feLogError("w0 + we = 1 must be satisfied"); else feLogError("w0 + we < 1 must be satisfied"); return false; } fp.m_Ky.assign(m_n,0); fp.m_w.assign(m_n+1,0); vector<double> Kp(m_n,0); if (m_n == 1) { fp.m_Ky[0] = Ymin; fp.m_w[0] = wmin; } else { // use bias r to reduce intervals in Ky and w as they increase proportionally double r = bias; // r= 1 uses uniform intervals if (r == 1) { fp.m_w[0] = wmin; Kp[0] = Ymin; fp.m_Ky[0] = Kp[0]; double sw = fp.m_w[0]; for (int i=1; i<m_n; ++i) { fp.m_w[i] = (wmax - wmin)/(m_n-1); Kp[i] = Ymin + (Ymax - Ymin)*i/(m_n-1); fp.m_Ky[i] = fp.m_Ky[i-1] + (Kp[i]-Kp[i-1])/(1-sw); sw += fp.m_w[i]; } } else { double c = (1-r)/(1-pow(r, m_n-1)); fp.m_w[0] = wmin; fp.m_w[1] = c*(wmax-wmin); Kp[0] = Ymin; Kp[1] = Kp[0] + c*(Ymax - Ymin); double sw = fp.m_w[0]; fp.m_Ky[0] = Kp[0]; fp.m_Ky[1] = fp.m_Ky[0] + (Kp[1]-Kp[0])/(1-sw); sw += fp.m_w[1]; for (int i=2; i<m_n; ++i) { fp.m_w[i] = fp.m_w[i-1]*r; Kp[i] = Kp[i-1] + (Kp[i-1]-Kp[i-2])*r; fp.m_Ky[i] = fp.m_Ky[i-1] + (Kp[i]-Kp[i-1])/(1-sw); sw += fp.m_w[i]; } } } fp.m_w[m_n] = we; fp.m_binit = true; return true; } return false; } //----------------------------------------------------------------------------- // F E P L A S T I C F L O W C U R V E U S E R //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEPlasticFlowCurveUser, FEPlasticFlowCurve) ADD_PROPERTY(m_Y , "plastic_response"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FEPlasticFlowCurveUser::FEPlasticFlowCurveUser(FEModel* pfem) : FEPlasticFlowCurve(pfem) { m_Y = nullptr; } //----------------------------------------------------------------------------- //! Initialization. bool FEPlasticFlowCurveUser::InitFlowCurve(FEMaterialPoint& mp) { FEPlasticFlowCurveMaterialPoint& fp = *mp.ExtractData<FEPlasticFlowCurveMaterialPoint>(); if (fp.m_binit == false) { m_Y->Init(); // get number of points on flow curve int m_n = m_Y->Points(); fp.m_Ky.assign(m_n,0); fp.m_w.assign(m_n+1,0); vector<double> Kp(m_n,0); // get first point on assumption that it represents the yield point // and extract Young's modulus LOADPOINT p = m_Y->LoadPoint(0); double Ey = p.value/p.time; for (int i=0; i<m_n; ++i) { LOADPOINT p = m_Y->LoadPoint(i); Kp[i] = p.value; fp.m_Ky[i] = Ey*p.time; } double sw = 0; if (m_n == 1) { fp.m_w[0] = 1; fp.m_w[m_n] = 0; } else { for (int i=0; i<m_n-1; ++i) { fp.m_w[i] = 1 - (Kp[i+1]-Kp[i])/(fp.m_Ky[i+1]-fp.m_Ky[i]) - sw; sw += fp.m_w[i]; } fp.m_w[m_n-1] = 1 - sw; fp.m_w[m_n] = 0; } fp.m_binit = true; return true; } return false; } //----------------------------------------------------------------------------- // F E P L A S T I C F L O W C U R V E M A T H //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEPlasticFlowCurveMath, FEPlasticFlowCurve) ADD_PARAMETER(m_n , FE_RANGE_GREATER(0) , "nf" ); ADD_PARAMETER(m_emin , FE_RANGE_GREATER(0) , "e0" ); ADD_PARAMETER(m_emax , FE_RANGE_GREATER(0) , "emax"); ADD_PARAMETER(m_Ymath, "plastic_response")->setLongName("plastic flow curve"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FEPlasticFlowCurveMath::FEPlasticFlowCurveMath(FEModel* pfem) : FEPlasticFlowCurve(pfem) { m_n = 1; m_emin = 0; m_emax = 1; } //----------------------------------------------------------------------------- //! Initialization. bool FEPlasticFlowCurveMath::InitFlowCurve(FEMaterialPoint& mp) { FEPlasticFlowCurveMaterialPoint& fp = *mp.ExtractData<FEPlasticFlowCurveMaterialPoint>(); if (fp.m_binit == false) { FEMathFunction Y(GetFEModel()); Y.SetMathString(m_Ymath); if (Y.Init() == false) return false; fp.m_Ky.assign(m_n,0); fp.m_w.assign(m_n+1,0); vector<double> Kp(m_n,0); if (m_n == 1) { fp.m_w[0] = 1; fp.m_w[m_n] = 0; Kp[0] = fp.m_Ky[0] = Y.value(m_emin); } else { // set uniform increments in Kp and find corresponding strains // then evaluate Ky at those strains Kp[0] = fp.m_Ky[0] = Y.value(m_emin); Kp[m_n-1] = Y.value(m_emax); // Extract Young's modulus double Ey = Kp[0]/m_emin; double dKp = (Kp[m_n-1] - Kp[0])/(m_n-1); double e = m_emin; vector<double> enat(m_n,0); enat[0] = m_emin; for (int i=1; i<m_n; ++i) { Kp[i] = Kp[0] + i*dKp; if (Y.invert(Kp[i], e) == false) return false; fp.m_Ky[i] = Ey*e; enat[i] = e; } // evaluate bond mass fractions fp.m_w[0] = (fp.m_Ky[1] - Kp[1])/(fp.m_Ky[1] - Kp[0]); double sw = fp.m_w[0]; for (int i=2; i<m_n; ++i) { fp.m_w[i-1] = 1 - sw - (Kp[i] - Kp[i-1])/(fp.m_Ky[i] - fp.m_Ky[i-1]); sw += fp.m_w[i-1]; } fp.m_w[m_n-1] = 1 - sw; fp.m_w[m_n] = 0; } fp.m_binit = true; return FEPlasticFlowCurve::Init(); } return false; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEFiberEntropyChainUC.cpp
.cpp
13,564
278
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2019 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FECore/stdafx.h" #include "FEFiberEntropyChainUC.h" #include <iostream> #include "triangle_sphere.h" #include <limits> #include <FECore/log.h> //----------------------------------------------------------------------------- // FEFiberEntropyChainUC //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEFiberEntropyChainUC, FEFiberMaterialUncoupled) ADD_PARAMETER(m_N, FE_RANGE_GREATER_OR_EQUAL(0.0), "N"); ADD_PARAMETER(mm_ksi, FE_RANGE_GREATER_OR_EQUAL(0.0), "ksi"); ADD_PARAMETER(m_term, FE_RANGE_GREATER(3), "n_term"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEFiberEntropyChainUC::FEFiberEntropyChainUC(FEModel* pfem) : FEFiberMaterialUncoupled(pfem) { m_term = 30; m_epsf = 1.0; } //----------------------------------------------------------------------------- mat3ds FEFiberEntropyChainUC::DevFiberStress(FEMaterialPoint& mp, const vec3d& n0) { double m_ksi = mm_ksi(mp); //double m_mu = mm_mu(mp); FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient double J = pt.m_J; mat3d F = pt.m_F * pow(J, -1.0 / 3.0); // loop over all integration points mat3ds C = pt.DevRightCauchyGreen(); mat3ds s; const double f_a[] = { 3.0, 9.0 / 5.0, 297.0 / 175.0, 1539.0 / 875.0, 126117.0 / 67373.0, 43733439.0 / 21896875.0, \ 231321177.0 / 109484375.0, 20495009043.0 / 9306171875.0, 1073585186448381.0 / 476522530859375.0, 4387445039583.0 / 1944989921875.0, \ 1000263375846831627.0 / 453346207767578125.0, 280865021365240713.0 / 133337119931640625.0, 148014872740758343473.0 / 75350125192138671875.0, 137372931237386537808993.0 / 76480377070020751953125.0, \ 41722474198742657618857192737.0 / 25674386102028896409912109375.0, 12348948373636682700768301125723.0 / 8344175483159391333221435546875.0, 5001286000741585238340074032091091.0 / 3590449627018291035442047119140625.0, \ 185364329915163811141785118512534489.0 / 132846636199676768311355743408203125.0, 6292216384025878939310787532157558451.0 / 4160197291516193533960877227783203125.0, 299869254759556271677902570230858640837.0 / 170568088952163934892395966339111328125.0, \ 316689568216860631885141475537178451746044283.0 / 148810301691076651811854156590061187744140625.0, 670194310437429598283653289122392937145371137.0 / 258140319260030926612400067554187774658203125.0, 19697015384373759058671314622426656486031717197919.0 / 6332687088594936951180328352888571262359619140625.0, \ 178793788985653424246012689916144867915861856840849.0 / 49756827124674504616416865629838774204254150390625.0, 323844166067349737493036492206152479344269351967043143667.0 / 82039106319990447886052744467343800746748447418212890625.0, 200808116689754604893460969866238617668631975356485302537199.0 / 49409916306357883385918130190559334540655314922332763671875.0, \ 27506481209689719715275759452624078040221544551995885750037973.0 / 7164437864421893090958128877631103508395020663738250732421875.0, 16356939619211770477227805130221533318985185730316048281126247721.0 / 5122573073061653560035062147506239008502439774572849273681640625.0, 30976199222209837888906735596203249520053107250807132769871859115868101.0 / 14801698741072505317694781203956860833766632412399612367153167724609375.0, \ 519588001407316958447129785511020819131555326399179970047767492196701159.0 / 902903623205422824379381653441368510859764577156376354396343231201171875.0 }; // fiber direction in global coordinate system //vec3d n0 = GetFiberVector(mp); // Calculate In = n0*C*n0 double In = n0*(C*n0); // only take fibers in tension into consideration const double eps = m_epsf * std::numeric_limits<double>::epsilon(); if ((In - 1.0) > eps) { // define the distribution double R, Ra = 0.0; // get the global spatial fiber direction in current configuration vec3d nt = F*n0; // calculate the outer product of nt mat3ds N = dyad(nt); // calculate strain energy derivative double alpha = sqrt(In) / sqrt(m_N); double alpha0 = 1 / sqrt(m_N); double alphaI = 1 / sqrt(In) / (2.0 * sqrt(m_N)); /////////////////////////////////////////////////////////////////////////////////////// double beta = 0, beta0 = 0, alpha2 = alpha * alpha, alpha02 = alpha0 * alpha0; int num_fa = sizeof(f_a) / sizeof(f_a[0]); if (m_term > num_fa) { m_term = num_fa; } beta = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha2; beta0 = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha02; for (int i = 2; i < m_term; i++) { beta = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha2 * beta; beta0 = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha02 * beta0; //cout << num_fa - i << endl; }; beta = f_a[0] * alpha * beta; beta0 = f_a[0] * alpha0 * beta0; //////////////////////////////////////////////////////////////////////////////////////////// double Wl = m_ksi * m_N * alphaI * beta - m_ksi*sqrt(m_N) / 2 * beta0; // calculate the fiber stress s = N*(2.0*Wl / J); } else { s.zero(); } return s.dev(); } //----------------------------------------------------------------------------- tens4ds FEFiberEntropyChainUC::DevFiberTangent(FEMaterialPoint& mp, const vec3d& n0) { double m_ksi = mm_ksi(mp); //double m_mu = mm_mu(mp); FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient double J = pt.m_J; mat3d F = pt.m_F * pow(J, -1.0 / 3.0); // loop over all integration points mat3ds C = pt.DevRightCauchyGreen(); mat3ds s; tens4ds c; // fiber direction in global coordinate system //vec3d n0 = GetFiberVector(mp); // Calculate In = n0*C*n0 double In = n0*(C*n0); // only take fibers in tension into consideration const double eps = m_epsf * std::numeric_limits<double>::epsilon(); if ((In - 1.0) > eps) { // get the global spatial fiber direction in current configuration vec3d nt = F*n0; // calculate the outer product of nt mat3ds N = dyad(nt); tens4ds NxN = dyad1s(N); // calculate strain energy 2nd derivative const double f_a[] = { 3.0, 9.0 / 5.0, 297.0 / 175.0, 1539.0 / 875.0, 126117.0 / 67373.0, 43733439.0 / 21896875.0, \ 231321177.0 / 109484375.0, 20495009043.0 / 9306171875.0, 1073585186448381.0 / 476522530859375.0, 4387445039583.0 / 1944989921875.0, \ 1000263375846831627.0 / 453346207767578125.0, 280865021365240713.0 / 133337119931640625.0, 148014872740758343473.0 / 75350125192138671875.0, 137372931237386537808993.0 / 76480377070020751953125.0, \ 41722474198742657618857192737.0 / 25674386102028896409912109375.0, 12348948373636682700768301125723.0 / 8344175483159391333221435546875.0, 5001286000741585238340074032091091.0 / 3590449627018291035442047119140625.0, \ 185364329915163811141785118512534489.0 / 132846636199676768311355743408203125.0, 6292216384025878939310787532157558451.0 / 4160197291516193533960877227783203125.0, 299869254759556271677902570230858640837.0 / 170568088952163934892395966339111328125.0, \ 316689568216860631885141475537178451746044283.0 / 148810301691076651811854156590061187744140625.0, 670194310437429598283653289122392937145371137.0 / 258140319260030926612400067554187774658203125.0, 19697015384373759058671314622426656486031717197919.0 / 6332687088594936951180328352888571262359619140625.0, \ 178793788985653424246012689916144867915861856840849.0 / 49756827124674504616416865629838774204254150390625.0, 323844166067349737493036492206152479344269351967043143667.0 / 82039106319990447886052744467343800746748447418212890625.0, 200808116689754604893460969866238617668631975356485302537199.0 / 49409916306357883385918130190559334540655314922332763671875.0, \ 27506481209689719715275759452624078040221544551995885750037973.0 / 7164437864421893090958128877631103508395020663738250732421875.0, 16356939619211770477227805130221533318985185730316048281126247721.0 / 5122573073061653560035062147506239008502439774572849273681640625.0, 30976199222209837888906735596203249520053107250807132769871859115868101.0 / 14801698741072505317694781203956860833766632412399612367153167724609375.0, \ 519588001407316958447129785511020819131555326399179970047767492196701159.0 / 902903623205422824379381653441368510859764577156376354396343231201171875.0 }; double alpha = sqrt(In) / sqrt(m_N); double alpha0 = 1 / sqrt(m_N); double alphaI = 1.0 / sqrt(In) / (2.0 * sqrt(m_N)); double alphaII = -pow(In, (-3.0 / 2.0)) / (4.0 * sqrt(m_N)); ///////////////////////////////////////////////////////////////////////////////// double beta = 0, beta0 = 0, beta_alpha = 0, alpha2 = alpha * alpha, alpha02 = alpha0 * alpha0; int num_fa = sizeof(f_a) / sizeof(f_a[0]); if (m_term > num_fa) { m_term = num_fa; } beta = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha2; beta0 = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha02; beta_alpha = 1 + f_a[m_term - 1] / f_a[m_term - 2] * alpha2 * (2 * m_term - 1) / (2 * m_term - 3); for (int i = 2; i < m_term; i++) { beta = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha2 * beta; beta0 = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha02 * beta0; beta_alpha = 1 + f_a[m_term - i] / f_a[m_term - i - 1] * alpha2 * beta_alpha * (2 * m_term - 2 * i + 1) / (2 * m_term - 2 * i - 1); }; beta = f_a[0] * alpha * beta; beta0 = f_a[0] * alpha0 * beta0; beta_alpha = f_a[0] * beta_alpha; ////////////////////////////////////////////////////////////////////////////////////// double Wl = m_ksi * m_N * alphaI * beta - m_ksi * sqrt(m_N) / 2 * beta0; double Wll = m_ksi * m_N * (beta_alpha*alphaI*alphaI + beta*alphaII); // calculate the fiber stress s = N * (2.0 * Wl / J); // calculate the fiber tangent c = NxN*(4.0*Wll / J); // This is the final value of the elasticity tensor mat3dd I(1); tens4ds IxI = dyad1s(I); tens4ds I4 = dyad4s(I); c += ((I4 + IxI / 3.0) * s.tr() - dyad1s(I, s)) * (2. / 3.) - (ddots(IxI, c) - IxI * (c.tr() / 3.)) / 3.; } else { c.zero(); } return c; } //----------------------------------------------------------------------------- //! Strain energy density double FEFiberEntropyChainUC::DevFiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0) { double m_ksi = mm_ksi(mp); //double m_mu = mm_mu(mp); double sed = 0.0; FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // loop over all integration points mat3ds C = pt.RightCauchyGreen(); mat3ds C2 = C.sqr(); // fiber direction in global coordinate system //vec3d n0 = GetFiberVector(mp); // Calculate In = n0*C*n0 double In = n0*(C*n0); // only take fibers in tension into consideration const double eps = m_epsf * std::numeric_limits<double>::epsilon(); if ((In - 1.0) > eps) { // calculate strain energy density double alpha = sqrt(In) / sqrt(m_N); double beta = alpha * (3.0 - alpha * alpha) / (1.0 - alpha * alpha) - 0.5 * pow(alpha, (10.0 / 3.0)) + 3.0 * pow(alpha, 5.0)*(alpha - 0.76)*(alpha - 1.0); double alpha0 = 1 / sqrt(m_N); double beta0 = alpha0 * (3.0 - alpha0 * alpha0) / (1.0 - alpha0 * alpha0) - 0.5 * pow(alpha0, (10.0 / 3.0)) + 3.0 * pow(alpha0, 5.0)*(alpha0 - 0.76)*(alpha0 - 1.0); double alpha00 = m_ksi* sqrt(m_N) / 2 * beta0 + m_ksi*m_N*log(beta0 / sinh(beta0)); sed = m_ksi*m_N * (alpha*beta + log(beta / (sinh(beta)))) - m_ksi*sqrt(m_N)/2 * beta0 * In - alpha00; // add the contribution from shear } else { sed = 0; } return sed; } //----------------------------------------------------------------------------- // FEUncoupledFiberEntropyChainUC //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEUncoupledFiberEntropyChainUC, FEElasticFiberMaterialUC) ADD_PARAMETER(m_fib.m_N, FE_RANGE_GREATER_OR_EQUAL(0.0), "N"); ADD_PARAMETER(m_fib.mm_ksi, FE_RANGE_GREATER_OR_EQUAL(0.0), "ksi"); ADD_PARAMETER(m_fib.m_term, FE_RANGE_GREATER(3), "n_term"); END_FECORE_CLASS();
C++
3D
febiosoftware/FEBio
FEBioMech/FEElasticBeamDomain.h
.h
3,975
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/FEBeamDomain.h> #include "FEElasticDomain.h" #include "febiomech_api.h" class FEElementMatrix; class FEElasticBeamMaterial; class FEBIOMECH_API FEElasticBeamDomain : public FEBeamDomain, public FEElasticDomain { public: FEElasticBeamDomain(FEModel* fem); public: // from FEDomain // create function bool Create(int elements, FE_Element_Spec espec) override; // initialize bool Init() override; //! Get the list of dofs on this domain const FEDofList& GetDOFList() const override; void SetMaterial(FEMaterial* pm) override; FEMaterial* GetMaterial() override; public: // from FEMeshPartition // return number of beam elements int Elements() const override; //! return a reference to an element FEElement& ElementRef(int i) override; const FEElement& ElementRef(int i) const override; // update internal domain variables void Update(const FETimeInfo& tp) override; // update data that depends on the incremental solution update void IncrementalUpdate(std::vector<double>& ui, bool finalFlag) override; // update material point data void PreSolveUpdate(const FETimeInfo& tp) override; public: //! return a beam element FEBeamElement& Element(int i); public: // from FEElasticDomain //! calculate the internal forces void InternalForces(FEGlobalVector& R) override; //! Calculate the body force vector void BodyForce(FEGlobalVector& R, FEBodyForce& bf) override; //! calculate the interial forces (for dynamic problems) void InertialForces(FEGlobalVector& R, std::vector<double>& F) override; //! Calculate global stiffness matrix (only contribution from internal force derivative) //! \todo maybe I should rename this the InternalStiffness matrix? void StiffnessMatrix(FELinearSystem& LS) override; //! Calculate stiffness contribution of body forces void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override; //! calculate the mass matrix (for dynamic problems) void MassMatrix(FELinearSystem& LS, double scale) override; private: void ElementInternalForces(FEBeamElement& el, std::vector<double>& fe); void ElementStiffnessMatrix(FEBeamElement& el, FEElementMatrix& ke); void ElementInertialForce(FEBeamElement& el, std::vector<double>& fe); void ElementBodyForce(FEBeamElement& el, std::vector<double>& fe, FEBodyForce& f); void ElementBodyForceStiffness(FEBeamElement& el, FEElementMatrix& ke, FEBodyForce& f); void ElementMassMatrix(FEBeamElement& el, FEElementMatrix& ke); void UpdateElement(FEBeamElement& el); private: FEDofList m_dofs; FEDofList m_dofQ; FEDofList m_dofV; FEDofList m_dofW; FEDofList m_dofA; FEElasticBeamMaterial* m_mat; std::vector<FEBeamElement> m_Elem; };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEIsotropicLeeSacks.h
.h
1,889
54
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 FEIsotropicLeeSacks : public FEElasticMaterial { public: FEIsotropicLeeSacks(FEModel* pfem); //! calculate deviatoric stress at material point mat3ds Stress(FEMaterialPoint& pt) override; //! calculate deviatoric tangent stiffness at material point tens4ds Tangent(FEMaterialPoint& pt) override; //! calculate strain energy density at material point double StrainEnergyDensity(FEMaterialPoint& pt) override; public: double m_c0; double m_c1; double m_c2; double m_k; double m_tangent_scale; // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FETiedContactSurface.cpp
.cpp
4,369
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 "FETiedContactSurface.h" #include "FECore/FEShellDomain.h" #include "FECore/vector.h" #include <FECore/FEMesh.h> FETiedContactSurface::Data::Data() { m_vgap = vec3d(0, 0, 0); m_rs = vec2d(0, 0); m_Lm = vec3d(0, 0, 0); m_Lp = vec3d(0, 0, 0); m_Tc = vec3d(0, 0, 0); m_off = 0.0; } void FETiedContactSurface::Data::Init() { FEContactMaterialPoint::Init(); m_vgap = vec3d(0, 0, 0); m_rs = vec2d(0, 0); m_Lm = vec3d(0, 0, 0); m_Lp = vec3d(0, 0, 0); m_Tc = vec3d(0, 0, 0); m_off = 0.0; } void FETiedContactSurface::Data::Serialize(DumpStream& ar) { FEContactMaterialPoint::Serialize(ar); ar & m_vgap; ar & m_rs; ar & m_Lm & m_Lp; ar & m_Tc; ar & m_off; } //----------------------------------------------------------------------------- FETiedContactSurface::FETiedContactSurface(FEModel* pfem) : FEContactSurface(pfem) { m_boffset = false; } //----------------------------------------------------------------------------- //! 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 FETiedContactSurface::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); // we calculate the gap offset values // This value is used to take the shell thickness into account if (m_boffset) { FEMesh& m = *m_pMesh; vector<double> tag(m.Nodes()); zero(tag); for (int nd = 0; nd<m.Domains(); ++nd) { FEShellDomain* psd = dynamic_cast<FEShellDomain*>(&m.Domain(nd)); if (psd) { for (int i = 0; i<psd->Elements(); ++i) { FEShellElement& el = psd->Element(i); int n = el.Nodes(); for (int j = 0; j<n; ++j) tag[el.m_node[j]] = 0.5*el.m_h0[j]; } } } for (int i = 0; i<nn; ++i) m_data[i].m_off = tag[NodeIndex(i)]; } return true; } //----------------------------------------------------------------------------- void FETiedContactSurface::Serialize(DumpStream &ar) { FEContactSurface::Serialize(ar); ar & m_data; } //----------------------------------------------------------------------------- void FETiedContactSurface::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]].m_Tc; pt /= ne; } //----------------------------------------------------------------------------- void FETiedContactSurface::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]].m_Tc.norm(); } //----------------------------------------------------------------------------- void FETiedContactSurface::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]].m_Tc; } }
C++
3D
febiosoftware/FEBio
FEBioMech/gausskronrod.h
.h
5,221
120
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 kronrod const int nint7 = 7; const double gp7[nint7] = { -0.960491268708,-0.774596669241,-0.434243749347,0,0.434243749347,0.774596669241,0.960491268708 }; const double gw7[nint7] = { 0.104656226026,0.268488089868,0.401397414776,0.450916538658,0.401397414776,0.268488089868,0.104656226026 }; const int nint11 = 11; const double gp11[nint11] = { 0.984085360095,0.906179845939,0.754166726571,0.538469310106,0.279630413162,0,-0.279630413162,-0.538469310106,-0.754166726571,-0.906179845939,-0.984085360095 }; const double gw11[nint11] = { 0.0425820367511,0.115233316622,0.186800796556,0.241040339229,0.272849801913,0.282987417857,0.272849801913,0.241040339229,0.186800796556,0.115233316622,0.0425820367511 }; const int nint15 = 15; const double gp15[nint15] = { -0.9914553711208126, -0.9491079123427585, -0.8648644233597691, -0.7415311855993944, -0.5860872354676911, -0.4058451513773972, -0.2077849550078985, 0, 0.2077849550078985, 0.4058451513773972, 0.5860872354676911, 0.7415311855993944, 0.8648644233597691, 0.9491079123427585, 0.9914553711208126 }; const double gw15[nint15] = { 0.02293532201052922, 0.06309209262997855, 0.1047900103222502, 0.1406532597155259, 0.1690047266392679, 0.1903505780647854, 0.2044329400752989, 0.2094821410847278, 0.2044329400752989, 0.1903505780647854, 0.1690047266392679, 0.1406532597155259, 0.1047900103222502, 0.06309209262997855, 0.02293532201052922 }; const int nint19 = 19; const double gp19[nint19] = { 0.994678160677,0.968160239508,0.91496350725,0.836031107327,0.734486765184,0.613371432701,0.475462479112,0.324253423404,0.164223563615,0,-0.164223563615,-0.324253423404,-0.475462479112,-0.613371432701,-0.734486765184,-0.836031107327,-0.91496350725,-0.968160239508,-0.994678160677 }; const double gw19[nint19] = { 0.0143047756438,0.0396318951603,0.0665181559403,0.0907906816887,0.111789134684,0.130001406855,0.145239588384,0.156413527788,0.16286282744,0.164896012828,0.16286282744,0.156413527788,0.145239588384,0.130001406855,0.111789134684,0.0907906816887,0.0665181559403,0.0396318951603,0.0143047756438 }; const int nint23 = 23; const double gp23[nint23] = { 0.99636961389,0.978228658146,0.941677108578,0.887062599768,0.816057456656,0.730152005574,0.630599520162,0.519096129207,0.397944140952,0.269543155952,0.136113000799,0,-0.136113000799,-0.269543155952,-0.397944140952,-0.519096129207,-0.630599520162,-0.730152005574,-0.816057456656,-0.887062599768,-0.941677108578,-0.978228658146,-0.99636961389 }; const double gw23[nint23] = { 0.00976544104596,0.0271565546821,0.0458293785644,0.0630974247504,0.0786645719322,0.0929530985969,0.105872074481,0.116739502461,0.1251587991,0.13128068423,0.1351935728,0.136577794711,0.1351935728,0.13128068423,0.1251587991,0.116739502461,0.105872074481,0.0929530985969,0.0786645719322,0.0630974247504,0.0458293785644,0.0271565546821,0.00976544104596 }; const int nint27 = 27; const double gp27[nint27] = { 0.997366176995,0.984183054719,0.957552468386,0.917598399223,0.865333160266,0.801578090733,0.726948849321,0.64234933944,0.549079957957,0.448492751036,0.341832463022,0.230458315955,0.115971089745,0,-0.115971089745,-0.230458315955,-0.341832463022,-0.448492751036,-0.549079957957,-0.64234933944,-0.726948849321,-0.801578090733,-0.865333160266,-0.917598399223,-0.957552468386,-0.984183054719,-0.997366176995 }; const double gw27[nint27] = { 0.00708784635125,0.0197537463827,0.0334435899896,0.0462790179738,0.0581152104231,0.0693036332478,0.0798059621695,0.0891684418775,0.0971417348761,0.103830601169,0.109266351095,0.113210259172,0.115488799091,0.116209612363,0.115488799091,0.113210259172,0.109266351095,0.103830601169,0.0971417348761,0.0891684418775,0.0798059621695,0.0693036332478,0.0581152104231,0.0462790179738,0.0334435899896,0.0197537463827,0.00708784635125 };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FETransIsoVerondaWestmann.cpp
.cpp
7,300
247
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FETransIsoVerondaWestmann.h" // define the material parameters BEGIN_FECORE_CLASS(FETransIsoVerondaWestmann, FEUncoupledMaterial) ADD_PARAMETER( m_c1 , "c1")->setUnits(UNIT_PRESSURE); ADD_PARAMETER( m_c2 , "c2")->setUnits(UNIT_NONE); ADD_PARAMETER(m_fib.m_c3 , "c3")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_fib.m_c4 , "c4")->setUnits(UNIT_NONE); ADD_PARAMETER(m_fib.m_c5 , "c5")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_fib.m_lam1, "lam_max"); ADD_PROPERTY(m_fiber, "fiber"); ADD_PROPERTY(m_ac, "active_contraction", FEProperty::Optional); END_FECORE_CLASS(); ////////////////////////////////////////////////////////////////////// // FETransIsoVerondaWestmann ////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- FETransIsoVerondaWestmann::FETransIsoVerondaWestmann(FEModel* pfem) : FEUncoupledMaterial(pfem), m_fib(pfem) { m_c1 = 0.0; m_c2 = 0.0; m_ac = nullptr; m_fib.SetParent(this); m_fiber = nullptr; } //----------------------------------------------------------------------------- //! create material point data FEMaterialPointData* FETransIsoVerondaWestmann::CreateMaterialPointData() { // create the elastic solid material point FEMaterialPointData* ep = new FEElasticMaterialPoint; // create the material point from the active contraction material if (m_ac) ep->Append(m_ac->CreateMaterialPointData()); return ep; } //----------------------------------------------------------------------------- mat3ds FETransIsoVerondaWestmann::DevStress(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient mat3d& F = pt.m_F; double J = pt.m_J; // calculate deviatoric left Cauchy-Green tensor mat3ds B = pt.DevLeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // material axes mat3d Q = GetLocalCS(mp); // get the fiber vector in local coordinates vec3d fiber = m_fiber->unitVector(mp); // convert to global coordinates vec3d a0 = Q * fiber; // Invariants of B (= invariants of C) // Note that these are the invariants of Btilde, not of B! double I1 = B.tr(); double c1 = m_c1(mp); double c2 = m_c2(mp); // --- TODO: put strain energy derivatives here --- // Wi = dW/dIi double W1 = c1*c2*exp(c2*(I1-3)); double W2 = -0.5*c1*c2; // ------------------------------------------------ // calculate T = F*dW/dC*Ft mat3ds T = B*(W1 + W2*I1) - B2*W2; // calculate stress s = pI + 2/J * dev(T) mat3ds s = T.dev()*(2.0/J); // add the passive fiber stress s += m_fib.DevFiberStress(mp, a0); // calculate the active fiber stress (if provided) if (m_ac) s += m_ac->ActiveStress(mp, a0); return s; } //----------------------------------------------------------------------------- //! Calculate deviatoric tangent tens4ds FETransIsoVerondaWestmann::DevTangent(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient double J = pt.m_J; double Ji = 1.0/J; // calculate deviatoric left Cauchy-Green tensor: B = F*Ft mat3ds B = pt.DevLeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // Invariants of B (= invariants of C) double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); double c1 = m_c1(mp); double c2 = m_c2(mp); // --- TODO: put strain energy derivatives here --- // Wi = dW/dIi double W1, W2, W11; W1 = c1*c2*exp(c2*(I1-3)); W2 = -0.5*c1*c2; W11 = c2*W1; // --- // material axes mat3d Q = GetLocalCS(mp); // get the fiber vector in local coordinates vec3d fiber = m_fiber->unitVector(mp); // convert to global coordinates vec3d a0 = Q * fiber; // calculate dWdC:C double WC = W1*I1 + 2*W2*I2; // calculate C:d2WdCdC:C double CWWC = W11*I1*I1+2*I2*W2; // deviatoric cauchy-stress mat3ds T = B * (W1 + W2 * I1) - B2 * W2; mat3ds devs = T.dev() * (2.0 / J); mat3dd I(1); // Identity tens4ds IxI = dyad1s(I); tens4ds I4 = dyad4s(I); tens4ds BxB = dyad1s(B); tens4ds B4 = dyad4s(B); // d2W/dCdC:C mat3ds WCCxC = B*(I1*(W11 + W2)) - B2*W2; tens4ds cw = BxB*((W11 + W2)*4.0*Ji) - B4*(W2*4.0*Ji) - dyad1s(WCCxC, I)*(4.0/3.0*Ji) + IxI*(4.0/9.0*Ji*CWWC); tens4ds c = dyad1s(devs, I)*(-2.0/3.0) + (I4 - IxI/3.0)*(4.0/3.0*Ji*WC) + cw; // add the active fiber stiffness if (m_ac) c += m_ac->ActiveStiffness(mp, a0); return c + m_fib.DevFiberTangent(mp, a0); } //----------------------------------------------------------------------------- double FETransIsoVerondaWestmann::DevStrainEnergyDensity(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // calculate deviatoric left Cauchy-Green tensor mat3ds B = pt.DevLeftCauchyGreen(); // calculate square of B mat3ds B2 = B.sqr(); // material axes mat3d Q = GetLocalCS(mp); // get the fiber vector in local coordinates vec3d fiber = m_fiber->unitVector(mp); // convert to global coordinates vec3d a0 = Q * fiber; // Invariants of B (= invariants of C) // Note that these are the invariants of Btilde, not of B! double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); double c1 = m_c1(mp); double c2 = m_c2(mp); // calculate sed double sed = c1*(exp(c2*(I1-3))-1) - c1*c2*(I2-3)/2; // add the fiber strain energy density sed += m_fib.DevFiberStrainEnergyDensity(mp, a0); return sed; } //----------------------------------------------------------------------------- // update force-velocity material point void FETransIsoVerondaWestmann::UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& timeInfo) { // material axes mat3d Q = GetLocalCS(mp); // get the fiber vector in local coordinates vec3d fiber = m_fiber->unitVector(mp); // convert to global coordinates vec3d a0 = Q * fiber; if (m_ac) m_ac->UpdateSpecializedMaterialPoints(mp, timeInfo, a0); }
C++
3D
febiosoftware/FEBio
FEBioMech/FEFiberPowLinear.cpp
.cpp
11,950
385
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEFiberPowLinear.h" // define the material parameters BEGIN_FECORE_CLASS(FEFiberPowLinear, FEFiberMaterial) ADD_PARAMETER(m_E , FE_RANGE_GREATER(0.0), "E" )->setUnits(UNIT_PRESSURE)->setLongName("fiber modulus E"); ADD_PARAMETER(m_lam0 , FE_RANGE_GREATER(1.0), "lam0" )->setLongName("toe stretch ratio"); ADD_PARAMETER(m_beta , FE_RANGE_GREATER_OR_EQUAL(2.0), "beta" )->setLongName("toe power exponent"); ADD_PARAMETER(m_tension_only, "tension_only"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- // FEFiberPowLinear //----------------------------------------------------------------------------- FEFiberPowLinear::FEFiberPowLinear(FEModel* pfem) : FEFiberMaterial(pfem) { m_E = 0.0; m_lam0 = 1.0; m_beta = 2.0; m_epsf = 0.0; m_tension_only = true; } //----------------------------------------------------------------------------- mat3ds FEFiberPowLinear::FiberStress(FEMaterialPoint& mp, const vec3d& n0) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // initialize material constants double E = m_E(mp); double lam0 = m_lam0(mp); double beta = m_beta(mp); double I0 = lam0*lam0; double ksi = E/4/(beta-1)*pow(I0, -3./2.)*pow(I0-1, 2-beta); double b = ksi*pow(I0-1, beta-1) + E/2/sqrt(I0); // deformation gradient mat3d &F = pt.m_F; double J = pt.m_J; // loop over all integration points const double eps = 0; mat3ds C = pt.RightCauchyGreen(); mat3ds s; // Calculate In double In = n0*(C*n0); // only take fibers in tension into consideration if (!m_tension_only || (In - 1 >= eps)) { // get the global spatial fiber direction in current configuration vec3d nt = F*n0/sqrt(In); // calculate the outer product of nt mat3ds N = dyad(nt); // calculate the fiber stress magnitude double sn = (In < I0) ? 2*In*ksi*pow(In-1, beta-1) : 2*b*In - E*sqrt(In); // calculate the fiber stress s = N*(sn/J); } else { s.zero(); } return s; } //----------------------------------------------------------------------------- tens4ds FEFiberPowLinear::FiberTangent(FEMaterialPoint& mp, const vec3d& n0) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // initialize material constants double E = m_E(mp); double lam0 = m_lam0(mp); double beta = m_beta(mp); double I0 = lam0*lam0; double ksi = E/4/(beta-1)*pow(I0, -3./2.)*pow(I0-1, 2-beta); // deformation gradient mat3d &F = pt.m_F; double J = pt.m_J; // loop over all integration points mat3ds C = pt.RightCauchyGreen(); tens4ds c; // Calculate In double In = n0*(C*n0); // only take fibers in tension into consideration const double eps = m_epsf * std::numeric_limits<double>::epsilon(); if (!m_tension_only || (In >= 1 + eps)) { // get the global spatial fiber direction in current configuration vec3d nt = F*n0/sqrt(In); // calculate the outer product of nt mat3ds N = dyad(nt); tens4ds NxN = dyad1s(N); // calculate modulus double cn = (In < I0) ? 4*In*In*ksi*(beta-1)*pow(In-1, beta-2) : E*sqrt(In); // calculate the fiber tangent c = NxN*(cn/J); } else { c.zero(); } return c; } //----------------------------------------------------------------------------- double FEFiberPowLinear::FiberStrainEnergyDensity(FEMaterialPoint& mp, const vec3d& n0) { double sed = 0.0; FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // initialize material constants double E = m_E(mp); double lam0 = m_lam0(mp); double beta = m_beta(mp); double I0 = lam0*lam0; double ksi = E/4/(beta-1)*pow(I0, -3./2.)*pow(I0-1, 2-beta); double b = ksi*pow(I0-1, beta-1) + E/2/sqrt(I0); // loop over all integration points const double eps = 0; mat3ds C = pt.RightCauchyGreen(); // Calculate In = n0*C*n0 double In = n0*(C*n0); // only take fibers in tension into consideration if (!m_tension_only || (In - 1 >= eps)) { // calculate strain energy density sed = (In < I0) ? ksi/beta*pow(In-1, beta) : b*(In-I0) - E*(sqrt(In)-sqrt(I0)) + ksi/beta*pow(I0-1, beta); } return sed; } // define the material parameters BEGIN_FECORE_CLASS(FEElasticFiberPowLinear, FEElasticFiberMaterial) ADD_PARAMETER(m_fib.m_E , FE_RANGE_GREATER(0.0), "E" )->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_fib.m_lam0 , FE_RANGE_GREATER(1.0), "lam0" ); ADD_PARAMETER(m_fib.m_beta , FE_RANGE_GREATER_OR_EQUAL(2.0), "beta" ); ADD_PARAMETER(m_fib.m_tension_only, "tension_only"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- // FEFiberExpPowLinear //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEFiberExpPowLinear, FEFiberMaterial) ADD_PARAMETER(m_E , FE_RANGE_GREATER_OR_EQUAL(0.0), "E"); 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_lam0, FE_RANGE_GREATER(1.0), "lam0"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEFiberExpPowLinear::FEFiberExpPowLinear(FEModel* pfem) : FEFiberMaterial(pfem) { m_E = 0; m_lam0 = 1; m_alpha = 0; m_beta = 3; m_epsf = 0.0; } //----------------------------------------------------------------------------- bool FEFiberExpPowLinear::Validate() { if (FEFiberMaterial::Validate() == false) return false; return true; } //----------------------------------------------------------------------------- mat3ds FEFiberExpPowLinear::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 double In = n0*(C*n0); // only take fibers in tension into consideration const double eps = 0; if (In - 1 >= eps) { // initialize material constants double E = m_E(mp); double lam0 = m_lam0(mp); double alpha = m_alpha(mp); double beta = m_beta(mp); double I0 = lam0*lam0; double ksi = E*pow(I0-1,2-beta)*exp(-alpha*pow(I0-1,beta)) /(4*pow(I0,1.5)*(beta-1+alpha*beta*pow(I0-1,beta))); double b = E*(2*I0*(beta-0.5+alpha*beta*pow(I0-1,beta))-1) /(4*pow(I0,1.5)*(beta-1+alpha*beta*pow(I0-1,beta))); // get the global spatial fiber direction in current configuration vec3d nt = F*n0 / sqrt(In); // calculate the outer product of nt mat3ds N = dyad(nt); // calculate the fiber stress magnitude double sn = (In < I0) ? 2 * In*exp(alpha*pow(In-1,beta))*ksi*pow(In - 1, beta - 1) : 2 * b*In - E*sqrt(In); // calculate the fiber stress s = N*(sn / J); } else { s.zero(); } return s; } //----------------------------------------------------------------------------- tens4ds FEFiberExpPowLinear::FiberTangent(FEMaterialPoint& mp, const vec3d& n0) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // deformation gradient mat3d &F = pt.m_F; double J = pt.m_J; mat3ds C = pt.RightCauchyGreen(); tens4ds c; // Calculate In double In = n0*(C*n0); // only take fibers in tension into consideration const double eps = m_epsf * std::numeric_limits<double>::epsilon(); if (In >= 1 + eps) { // initialize material constants double E = m_E(mp); double lam0 = m_lam0(mp); double alpha = m_alpha(mp); double beta = m_beta(mp); double I0 = lam0*lam0; double ksi = E*pow(I0-1,2-beta)*exp(-alpha*pow(I0-1,beta)) /(4*pow(I0,1.5)*(beta-1+alpha*beta*pow(I0-1,beta))); double b = E*(2*I0*(beta-0.5+alpha*beta*pow(I0-1,beta))-1) /(4*pow(I0,1.5)*(beta-1+alpha*beta*pow(I0-1,beta))); // get the global spatial fiber direction in current configuration vec3d nt = F*n0 / sqrt(In); // calculate the outer product of nt mat3ds N = dyad(nt); tens4ds NxN = dyad1s(N); // calculate modulus double cn = (In < I0) ? 4*ksi*In*In*exp(alpha*pow(In-1,beta))*pow(In-1,beta-2)*(beta-1+alpha*beta*pow(In-1,beta)) : E*sqrt(In); // calculate the fiber tangent c = NxN*(cn / J); } else { c.zero(); } return c; } //----------------------------------------------------------------------------- //! Strain energy density double FEFiberExpPowLinear::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 = n0*C*n0 double In = n0*(C*n0); // only take fibers in tension into consideration const double eps = 0; if (In - 1 >= eps) { // initialize material constants double E = m_E(mp); double lam0 = m_lam0(mp); double alpha = m_alpha(mp); double beta = m_beta(mp); double I0 = lam0*lam0; double ksi = E*pow(I0-1,2-beta)*exp(-alpha*pow(I0-1,beta)) /(4*pow(I0,1.5)*(beta-1+alpha*beta*pow(I0-1,beta))); double b = E*(2*I0*(beta-0.5+alpha*beta*pow(I0-1,beta))-1) /(4*pow(I0,1.5)*(beta-1+alpha*beta*pow(I0-1,beta))); // calculate strain energy density if (alpha == 0) { sed = (In < I0) ? ksi / beta*pow(In - 1, beta) : b*(In - I0) - E*(sqrt(In) - sqrt(I0)) + ksi / beta*pow(I0 - 1, beta); } else { sed = (In < I0) ? ksi / (alpha*beta)*(exp(alpha*pow(In - 1, beta))-1) : b*(In - I0) - E*(sqrt(In) - sqrt(I0)) + ksi / (alpha*beta)*(exp(alpha*pow(I0 - 1, beta))-1); } } return sed; } // define the material parameters BEGIN_FECORE_CLASS(FEElasticFiberExpPowLinear, FEElasticFiberMaterial) ADD_PARAMETER(m_fib.m_E , FE_RANGE_GREATER_OR_EQUAL(0.0), "E"); 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_lam0, FE_RANGE_GREATER(1.0), "lam0"); END_FECORE_CLASS();
C++
3D
febiosoftware/FEBio
FEBioMech/FEReactivePlasticityMaterialPoint.cpp
.cpp
4,169
126
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEReactivePlasticityMaterialPoint.h" #include "FEElasticMaterial.h" ////////////////////// PLASTICITY MATERIAL POINT ////////////////////////////// //----------------------------------------------------------------------------- FEMaterialPointData* FEReactivePlasticityMaterialPoint::Copy() { FEReactivePlasticityMaterialPoint* pt = new FEReactivePlasticityMaterialPoint(*this); if (m_pNext) pt->m_pNext = m_pNext->Copy(); pt->m_Fusi = m_Fusi; pt->m_Fvsi = m_Fvsi; pt->m_Ku = m_Ku; pt->m_Kv = m_Kv; pt->m_w = m_w; pt->m_gp = m_gp; pt->m_gpp = m_gpp; pt->m_gc = m_gc; pt->m_byld = m_byld; return pt; } //----------------------------------------------------------------------------- void FEReactivePlasticityMaterialPoint::Init() { FEPlasticFlowCurveMaterialPoint& fp = *ExtractData<FEPlasticFlowCurveMaterialPoint>(); if (fp.m_binit) { size_t n = fp.m_Ky.size(); // intialize data m_Fusi.assign(n, mat3d(1,0,0, 0,1,0, 0,0,1)); m_Fvsi.assign(n, mat3d(1,0,0, 0,1,0, 0,0,1)); m_Fp = mat3dd(1); m_Ku.assign(n, 0); m_Kv.assign(n, 0); m_w.assign(n,0); m_gp.assign(n, 0); m_gpp.assign(n, 0); m_gc.assign(n, 0); m_byld.assign(n,false); m_Rhat = 0; // don't forget to initialize the base class FEMaterialPointData::Init(); } } //----------------------------------------------------------------------------- void FEReactivePlasticityMaterialPoint::Update(const FETimeInfo& timeInfo) { FEElasticMaterialPoint& pt = *m_pNext->ExtractData<FEElasticMaterialPoint>(); for (int i=0; i<m_Fusi.size(); ++i) { m_Fusi[i] = m_Fvsi[i]; m_Ku[i] = m_Kv[i]; m_gc[i] += fabs(m_gp[i] - m_gpp[i]); m_gpp[i] = m_gp[i]; if (m_w[i] > 0) m_byld[i] = true; } m_Fp = pt.m_F; // don't forget to update the base class FEMaterialPointData::Update(timeInfo); } //----------------------------------------------------------------------------- void FEReactivePlasticityMaterialPoint::Serialize(DumpStream& ar) { FEMaterialPointData::Serialize(ar); if (ar.IsSaving()) { ar << m_Rhat << m_Fp; ar << m_w << m_Fusi << m_Fvsi << m_Ku << m_Kv << m_gp << m_gpp << m_gc; ar << m_byld; } else { ar >> m_Rhat >> m_Fp; ar >> m_w >> m_Fusi >> m_Fvsi >> m_Ku >> m_Kv >> m_gp >> m_gpp >> m_gc; ar >> m_byld; } } //----------------------------------------------------------------------------- //! Evaluate net mass fraction of yielded bonds double FEReactivePlasticityMaterialPoint::YieldedBonds() const { double w = 0; for (int i=0; i<m_w.size(); ++i) w += m_w[i]; return w; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEMaxDamageCriterion.h
.h
1,581
42
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMeshAdaptorCriterion.h> #include "FEDamageMaterial.h" class FEDamageAdaptorCriterion : public FEMeshAdaptorCriterion { public: FEDamageAdaptorCriterion(FEModel* fem); bool GetMaterialPointValue(FEMaterialPoint& mp, double& value) override; DECLARE_FECORE_CLASS() };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEHolzapfelGasserOgden.cpp
.cpp
7,936
232
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEHolzapfelGasserOgden.h" // define the material parameters BEGIN_FECORE_CLASS(FEHolzapfelGasserOgden, FEUncoupledMaterial) ADD_PARAMETER(m_c , FE_RANGE_GREATER_OR_EQUAL(0.0), "c")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_k1 , FE_RANGE_GREATER_OR_EQUAL(0.0), "k1")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_k2 , FE_RANGE_GREATER_OR_EQUAL(0.0), "k2")->setUnits(UNIT_NONE); ADD_PARAMETER(m_kappa, FE_RANGE_CLOSED(0.0, 1.0/3.0), "kappa")->setUnits(UNIT_NONE); ADD_PARAMETER(m_gdeg , "gamma")->setUnits(UNIT_DEGREE); ADD_PROPERTY(m_Q, "mat_axis")->SetFlags(FEProperty::Optional); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEHolzapfelGasserOgden::FEHolzapfelGasserOgden(FEModel* pfem) : FEUncoupledMaterial(pfem) { m_npmodel = 3; } //----------------------------------------------------------------------------- //! Calculates the deviatoric stress mat3ds FEHolzapfelGasserOgden::DevStress(FEMaterialPoint& mp) { double c = m_c(mp); double k1 = m_k1(mp); double k2 = m_k2(mp); double kappa = m_kappa(mp); double g = m_gdeg(mp)*PI/180; FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // determinant of deformation gradient double J = pt.m_J; // Evaluate the distortional deformation gradient double Jm13 = pow(J, -1. / 3.); mat3d F = pt.m_F*Jm13; // calculate deviatoric left Cauchy-Green tensor: b = F*Ft mat3ds b = pt.DevLeftCauchyGreen(); mat3ds C = pt.DevRightCauchyGreen(); double I1 = C.tr(); // get the local coordinate systems mat3d Q = GetLocalCS(mp); // Copy the local element basis directions to n vec3d n[2]; n[0].x = Q[0][0]; n[0].y = Q[1][0]; n[0].z = Q[2][0]; n[1].x = Q[0][1]; n[1].y = Q[1][1]; n[1].z = Q[2][1]; // Evaluate the structural direction in the current configuration double cg = cos(g); double sg = sin(g); vec3d ar[2],a[2]; ar[0] = n[0]*cg + n[1]*sg; a[0] = F*ar[0]; ar[1] = n[0]*cg - n[1]*sg; a[1] = F*ar[1]; // Evaluate the ground matrix stress mat3ds s = c*b; // Evaluate the structural tensors in the current configuration // and the fiber strains and stress contributions double I40 = ar[0]*(C*ar[0]); double E0 = kappa*(I1-3) + (1-3*kappa)*(I40-1); if (E0 >= 0) { mat3ds h0 = kappa*b + (1-3*kappa)*dyad(a[0]); s += h0*(2.*k1*E0*exp(k2*E0*E0)); } double I41 = ar[1]*(C*ar[1]); double E1 = kappa*(I1-3) + (1-3*kappa)*(I41-1); if (E1 >= 0) { mat3ds h1 = kappa*b + (1-3*kappa)*dyad(a[1]); s += h1*(2.*k1*E1*exp(k2*E1*E1)); } return s.dev() / J; } //----------------------------------------------------------------------------- //! Calculates the deviatoric tangent tens4ds FEHolzapfelGasserOgden::DevTangent(FEMaterialPoint& mp) { double c = m_c(mp); double k1 = m_k1(mp); double k2 = m_k2(mp); double kappa = m_kappa(mp); double g = m_gdeg(mp)*PI/180; FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); // determinant of deformation gradient double J = pt.m_J; // Evaluate the distortional deformation gradient double Jm13 = pow(J, -1. / 3.); mat3d F = pt.m_F*Jm13; // calculate deviatoric left Cauchy-Green tensor: b = F*Ft mat3ds b = pt.DevLeftCauchyGreen(); mat3ds C = pt.DevRightCauchyGreen(); double I1 = C.tr(); // get the local coordinate systems mat3d Q = GetLocalCS(mp); // Copy the local element basis directions to n vec3d n[2]; n[0].x = Q[0][0]; n[0].y = Q[1][0]; n[0].z = Q[2][0]; n[1].x = Q[0][1]; n[1].y = Q[1][1]; n[1].z = Q[2][1]; // Evaluate the structural direction in the current configuration double cg = cos(g); double sg = sin(g); vec3d ar[2],a[2]; ar[0] = n[0]*cg + n[1]*sg; a[0] = F*ar[0]; ar[1] = n[0]*cg - n[1]*sg; a[1] = F*ar[1]; // Evaluate the ground matrix stress mat3ds s = c*b; // Evaluate the structural tensors in the current configuration // and the fiber strains and stress contributions double I40 = ar[0]*(C*ar[0]); double E0 = kappa*(I1-3) + (1-3*kappa)*(I40-1); mat3ds h0; if (E0 >= 0) { h0 = kappa*b + (1-3*kappa)*dyad(a[0]); s += h0*(2.*k1*E0*exp(k2*E0*E0)); } double I41 = ar[1]*(C*ar[1]); double E1 = kappa*(I1-3) + (1-3*kappa)*(I41-1); mat3ds h1; if (E1 >= 0) { h1 = kappa*b + (1-3*kappa)*dyad(a[1]); s += h1*(2.*k1*E1*exp(k2*E1*E1)); } mat3ds sbar = s.dev(); // Evaluate the elasticity tensor mat3dd I(1); tens4ds IxI = dyad1s(I); tens4ds I4 = dyad4s(I); tens4ds ce = ((I4 - IxI/3.)*s.tr()-dyad1s(sbar,I))*(2./3.); if (E0 >= 0) ce += dyad1s(h0.dev())*(4.*k1*(1 + 2 * k2*E0*E0)*exp(k2*E0*E0)); if (E1 >= 0) ce += dyad1s(h1.dev())*(4.*k1*(1 + 2 * k2*E1*E1)*exp(k2*E1*E1)); return ce / J; } //----------------------------------------------------------------------------- //! Calculates the deviatoric stress double FEHolzapfelGasserOgden::DevStrainEnergyDensity(FEMaterialPoint& mp) { double c = m_c(mp); double k1 = m_k1(mp); double k2 = m_k2(mp); double kappa = m_kappa(mp); double g = m_gdeg(mp)*PI/180; FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); vec3d n[3]; // local element basis directions mat3ds h[2]; // structural tensor in current configuration double E[2]; // fiber strain // calculate deviatoric right Cauchy-Green tensor mat3ds C = pt.DevRightCauchyGreen(); double I1 = C.tr(); // get the local coordinate systems mat3d Q = GetLocalCS(mp); // Copy the local element basis directions to n n[0].x = Q[0][0]; n[0].y = Q[1][0]; n[0].z = Q[2][0]; n[1].x = Q[0][1]; n[1].y = Q[1][1]; n[1].z = Q[2][1]; // Evaluate the structural direction in the current configuration double cg = cos(g); double sg = sin(g); vec3d ar[2]; ar[0] = n[0]*cg + n[1]*sg; ar[1] = n[0]*cg - n[1]*sg; // Evaluate the ground matrix strain energy density double sed = 0.5*c*(I1 - 3); // Evaluate the structural tensors in the current configuration // and the fiber strains and stress contributions double I40 = ar[0]*(C*ar[0]); E[0] = kappa*(I1-3) + (1-3*kappa)*(I40-1); if (E[0] >= 0) sed += 0.5*k1/k2*(exp(k2*E[0]*E[0])-1); double I41 = ar[1]*(C*ar[1]); E[1] = kappa*(I1-3) + (1-3*kappa)*(I41-1); if (E[1] >= 0) sed += 0.5*k1/k2*(exp(k2*E[1]*E[1])-1); return sed; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEPointConstraint.cpp
.cpp
6,156
208
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEPointConstraint.h" #include "FECore/FEMesh.h" #include "FEBioMech.h" #include <FECore/FELinearSystem.h> //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEPointConstraint, FENLConstraint) ADD_PARAMETER(m_eps , "penalty"); ADD_PARAMETER(m_node_id, "node" ); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEPointConstraint::FEPointConstraint(FEModel* pfem) : FENLConstraint(pfem), m_dofU(pfem) { m_node_id = -1; m_eps = 0.0; m_node = -1; m_pel = 0; // TODO: Can this be done in Init, since there is no error checking if (pfem) { m_dofU.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT)); } } //----------------------------------------------------------------------------- bool FEPointConstraint::Init() { FEMesh& m = GetMesh(); if ((m_node_id <= 0)||(m_node_id > m.Nodes())) return false; // get the nodal position in the reference state m_node = m_node_id - 1; vec3d r = m.Node(m_node).m_r0; // find the element in which this node lies m_pel = m.FindSolidElement(r, m_rs); if (m_pel == 0) return false; return true; } //----------------------------------------------------------------------------- void FEPointConstraint::Serialize(DumpStream& ar) { FENLConstraint::Serialize(ar); // TODO: implement this } //----------------------------------------------------------------------------- void FEPointConstraint::BuildMatrixProfile(FEGlobalMatrix& M) { FEMesh& mesh = GetMesh(); vector<int> lm(3*9); FENode& n0 = mesh.Node(m_node); lm[0] = n0.m_ID[m_dofU[0]]; lm[1] = n0.m_ID[m_dofU[1]]; lm[2] = n0.m_ID[m_dofU[2]]; for (int i=0; i<8; ++i) { FENode& ni = mesh.Node(m_pel->m_node[i]); lm[3*(i+1) ] = ni.m_ID[m_dofU[0]]; lm[3*(i+1)+1] = ni.m_ID[m_dofU[1]]; lm[3*(i+1)+2] = ni.m_ID[m_dofU[2]]; } M.build_add(lm); } //----------------------------------------------------------------------------- void FEPointConstraint::LoadVector(FEGlobalVector& R, const FETimeInfo& tp) { int i; FEMesh& m = GetMesh(); // calculate H matrix double H[9], *r = m_rs; H[0] = 1.0; H[1] = -0.125*(1 - r[0])*(1 - r[1])*(1 - r[2]); H[2] = -0.125*(1 + r[0])*(1 - r[1])*(1 - r[2]); H[3] = -0.125*(1 + r[0])*(1 + r[1])*(1 - r[2]); H[4] = -0.125*(1 - r[0])*(1 + r[1])*(1 - r[2]); H[5] = -0.125*(1 - r[0])*(1 - r[1])*(1 + r[2]); H[6] = -0.125*(1 + r[0])*(1 - r[1])*(1 + r[2]); H[7] = -0.125*(1 + r[0])*(1 + r[1])*(1 + r[2]); H[8] = -0.125*(1 - r[0])*(1 + r[1])*(1 + r[2]); // get the nodal position vec3d x[9]; x[0] = m.Node(m_node).m_rt; for (i=0; i<8; ++i) x[i+1] = m.Node(m_pel->m_node[i]).m_rt; // calculate the constraint vec3d c(0,0,0); for (i=0; i<9; ++i) c += x[i]*H[i]; // calculate the force vec3d T = c*m_eps; // setup the LM matrix vector<int> LM(3*9), en(9); en[0] = m_node; LM[0] = m.Node(m_node).m_ID[m_dofU[0]]; LM[1] = m.Node(m_node).m_ID[m_dofU[1]]; LM[2] = m.Node(m_node).m_ID[m_dofU[2]]; for (i=0; i<8; ++i) { en[i+1] = m_pel->m_node[i]; FENode& node = m.Node(en[i+1]); LM[(i+1)*3 ] = node.m_ID[m_dofU[0]]; LM[(i+1)*3+1] = node.m_ID[m_dofU[1]]; LM[(i+1)*3+2] = node.m_ID[m_dofU[2]]; } // set up nodal force vector vector<double> fe(3*9); for (int i=0; i<9; ++i) { fe[3*i ] = -T.x*H[i]; fe[3*i+1] = -T.y*H[i]; fe[3*i+2] = -T.z*H[i]; } // assemble residual R.Assemble(en, LM, fe); } //----------------------------------------------------------------------------- void FEPointConstraint::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) { FEMesh& m = GetMesh(); // calculate H matrix double H[9], *r = m_rs; H[0] = 1.0; H[1] = -0.125*(1 - r[0])*(1 - r[1])*(1 - r[2]); H[2] = -0.125*(1 + r[0])*(1 - r[1])*(1 - r[2]); H[3] = -0.125*(1 + r[0])*(1 + r[1])*(1 - r[2]); H[4] = -0.125*(1 - r[0])*(1 + r[1])*(1 - r[2]); H[5] = -0.125*(1 - r[0])*(1 - r[1])*(1 + r[2]); H[6] = -0.125*(1 + r[0])*(1 - r[1])*(1 + r[2]); H[7] = -0.125*(1 + r[0])*(1 + r[1])*(1 + r[2]); H[8] = -0.125*(1 - r[0])*(1 + r[1])*(1 + r[2]); // setup the LM matrix vector<int> LM(3*9), en(9); en[0] = m_node; LM[0] = m.Node(m_node).m_ID[m_dofU[0]]; LM[1] = m.Node(m_node).m_ID[m_dofU[1]]; LM[2] = m.Node(m_node).m_ID[m_dofU[2]]; for (int i=0; i<8; ++i) { en[i+1] = m_pel->m_node[i]; FENode& node = m.Node(en[i+1]); LM[(i+1)*3 ] = node.m_ID[m_dofU[0]]; LM[(i+1)*3+1] = node.m_ID[m_dofU[1]]; LM[(i+1)*3+2] = node.m_ID[m_dofU[2]]; } // setup stiffness matrix int ndof = 3*9; FEElementMatrix ke(ndof, ndof); ke.zero(); for (int i=0; i<9; ++i) for (int j=0; j<9; ++j) { ke[3*i ][3*j ] = m_eps*H[i]*H[j]; ke[3*i+1][3*j+1] = m_eps*H[i]*H[j]; ke[3*i+2][3*j+2] = m_eps*H[i]*H[j]; } ke.SetIndices(LM); ke.SetNodes(en); // assemble stiffness matrix LS.Assemble(ke); }
C++
3D
febiosoftware/FEBio
FEBioMech/FEMortarSlidingContact.h
.h
3,804
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 "FEMortarInterface.h" #include "FEMortarContactSurface.h" //----------------------------------------------------------------------------- //! This class represents a surface used by the mortar contact interface. class FEMortarSlidingSurface : public FEMortarContactSurface { public: FEMortarSlidingSurface(FEModel* pfem); //! Initializes data structures bool Init(); //! update the normals void UpdateNormals(bool binit); public: vector<double> m_p; //!< nodal contact pressures vector<double> m_L; //!< Lagrange multipliers vector<vec3d> m_nu; //!< nodal normals vector<double> m_norm0; //!< initial (inverse) normal lenghts }; //----------------------------------------------------------------------------- //! This class implements a mortar contact formulation for frictionless, sliding contact class FEMortarSlidingContact : public FEMortarInterface { public: //! constructor FEMortarSlidingContact(FEModel* pfem); //! destructor ~FEMortarSlidingContact(); //! return the primary and secondary surface FESurface* GetPrimarySurface() override { return &m_ss; } FESurface* GetSecondarySurface() override { return &m_ms; } public: //! temporary construct to determine if contact interface uses nodal integration rule (or facet) bool UseNodalIntegration() override { return false; } //! interface activation void Activate() override; //! one-time initialization bool Init() override; //! calculate contact forces void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override; //! calculate contact stiffness void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override; //! calculate Lagrangian augmentations bool Augment(int naug, const FETimeInfo& tp) override; //! serialize data to archive void Serialize(DumpStream& ar) override; //! build the matrix profile for use in the stiffness matrix void BuildMatrixProfile(FEGlobalMatrix& K) override; //! update interface data void Update() override; protected: // contact stiffness contributions void ContactGapStiffness(FELinearSystem& LS); void ContactNormalStiffness(FELinearSystem& LS); private: double m_atol; //!< augmented Lagrangian tolerance double m_eps; //!< penalty factor int m_naugmin; //!< minimum number of augmentations int m_naugmax; //!< maximum number of augmentations private: FEMortarSlidingSurface m_ms; //!< mortar surface FEMortarSlidingSurface m_ss; //!< non-mortar surface int m_dofX; int m_dofY; int m_dofZ; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEReactiveFatigue.h
.h
3,093
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) 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 "FEElasticMaterial.h" #include "FEDamageCriterion.h" #include "FEDamageCDF.h" #include "FEReactiveFatigueMaterialPoint.h" #include <FECore/FEMaterial.h> //----------------------------------------------------------------------------- // This material models fatigue and damage in any hyper-elastic materials. class FEReactiveFatigue : public FEElasticMaterial { public: FEReactiveFatigue(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; } // update fatigue material point at each iteration void UpdateSpecializedMaterialPoints(FEMaterialPoint& mp, const FETimeInfo& tp) override; public: FEElasticMaterial* m_pBase; // base elastic material FEDamageCDF* m_pIdmg; // damage model for intact bonds FEDamageCDF* m_pFdmg; // damage model for fatigued bonds FEDamageCriterion* m_pIcrt; // damage criterion FEDamageCriterion* m_pFcrt; // fatigue criterion public: FEParamDouble m_k0; // reaction rate for fatigue reaction FEParamDouble m_beta; // power exponent for fatigue reaction DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FESolidLinearSystem.cpp
.cpp
4,020
128
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FESolidLinearSystem.h" #include "FESolidSolver.h" #include <FECore/FELinearConstraintManager.h> #include <FECore/FEModel.h> FESolidLinearSystem::FESolidLinearSystem(FEModel* fem, FERigidSolver* rigidSolver, FEGlobalMatrix& K, std::vector<double>& F, std::vector<double>& u, bool bsymm, double alpha, int nreq) : FELinearSystem(fem, K, F, u, bsymm) { m_fem = fem; m_rigidSolver = rigidSolver; m_alpha = alpha; m_nreq = nreq; m_stiffnessScale = 1.0; } // scale factor for stiffness matrix void FESolidLinearSystem::StiffnessAssemblyScaleFactor(double a) { m_stiffnessScale = a; } void FESolidLinearSystem::Assemble(const FEElementMatrix& ke) { // Rigid joints require a different assembly approach in that we can do // a direct assembly as defined by the base class. // Currently, we assume that if the node list of the element matrix is not // defined, then we are dealing with rigid joints. if (ke.Nodes().empty()) { FELinearSystem::Assemble(ke); } else { // assemble into global stiffness matrix if (m_stiffnessScale == 1.0) { m_K.Assemble(ke); } else { // NOTE: What is doing here? FEElementMatrix kes(ke, m_stiffnessScale); m_K.Assemble(kes); } // get the vector that stores the prescribed BC values vector<double>& ui = m_u; // adjust for linear constraints FELinearConstraintManager& LCM = m_fem->GetLinearConstraintManager(); if (LCM.LinearConstraints() > 0) { #pragma omp critical (LCM_assemble) LCM.AssembleStiffness(m_K, m_F, m_u, ke.Nodes(), ke.RowIndices(), ke.ColumnsIndices(), ke); } // adjust stiffness matrix for prescribed degrees of freedom // NOTE: I had to comment this if statement out since otherwise // poroelastic DOF's that are set as free-draining in the // sliding2 contact code are skipt and zeroes will appear // on the diagonal of the stiffness matrix. // if (m_fem.m_DC.size() > 0) { SparseMatrix& K = m_K; int N = ke.rows(); // loop over columns const vector<int>& elmi = ke.RowIndices(); const vector<int>& elmj = ke.ColumnsIndices(); for (int j = 0; j < N; ++j) { int J = -elmj[j] - 2; if ((J >= 0) && (J < m_nreq)) { // dof j is a prescribed degree of freedom // loop over rows for (int i = 0; i < N; ++i) { int I = elmi[i]; if (I >= 0) { // dof i is not a prescribed degree of freedom #pragma omp atomic m_F[I] -= ke[i][j] * ui[J]; } } // set the diagonal element of K to 1 K.set(J, J, 1); } } } // see if there are any rigid body dofs here #pragma omp critical (rigidStiffness) m_rigidSolver->RigidStiffness(m_K, m_u, m_F, ke, m_alpha); } }
C++
3D
febiosoftware/FEBio
FEBioMech/FEBioMechModule.cpp
.cpp
70,493
1,277
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEBioMech.h" #include "FEBioMechModule.h" #include "FE2DFiberNeoHookean.h" #include "FE2DTransIsoMooneyRivlin.h" #include "FE2DTransIsoVerondaWestmann.h" #include "FEABUnconstrained.h" #include "FEActiveFiberContraction.h" #include "FEUncoupledActiveFiberContraction.h" #include "FEArrudaBoyce.h" #include "FECarreauYasudaViscousSolid.h" #include "FECarterHayesOld.h" #include "FECellGrowth.h" #include "FECubicCLE.h" #include "FEDamageMooneyRivlin.h" #include "FEDamageNeoHookean.h" #include "FEDamageTransIsoMooneyRivlin.h" #include "FESpringMaterial.h" #include "FETorsionalSpring.h" #include "FEDonnanEquilibrium.h" #include "FEEFDDonnanEquilibrium.h" #include "FEEFDMooneyRivlin.h" #include "FEEFDNeoHookean.h" #include "FEEFDUncoupled.h" #include "FEEFDVerondaWestmann.h" #include "FEElasticMixture.h" #include "FEElasticMultigeneration.h" #include "FEEllipsoidalFiberDistribution.h" #include "FEFiberCDF.h" #include "FEFiberCDFUncoupled.h" #include "FEFiberEntropyChain.h" #include "FEFiberEntropyChainUC.h" #include "FEFiberExpPow.h" #include "FEFiberExpPowUncoupled.h" #include "FEFiberNaturalNeoHookean.h" #include "FEFiberNeoHookean.h" #include "FEFiberPow.h" #include "FEFiberPowLinear.h" #include "FEFiberPowLinearUncoupled.h" #include "FEFiberEFDNeoHookean.h" #include "FEFiberExponentialPowerUC.h" #include "FEFiberNHUC.h" #include "FEFiberKiousisUncoupled.h" #include "FEForceVelocityContraction.h" #include "FEFungOrthoCompressible.h" #include "FEFungOrthotropic.h" #include "FEHolmesMow.h" #include "FEHolmesMowUC.h" #include "FEHolzapfelGasserOgden.h" #include "FEHolzapfelUnconstrained.h" #include "FEHuiskesSupply.h" #include "FEIncompNeoHookean.h" #include "FEIsotropicElastic.h" #include "FEIsoHencky.h" #include "FEMooneyRivlin.h" #include "FEMooneyRivlinAD.h" #include "FEMRVonMisesFibers.h" #include "FEMuscleMaterial.h" #include "FENaturalNeoHookean.h" #include "FENeoHookean.h" #include "FENeoHookeanAD.h" #include "FENeoHookeanTransIso.h" #include "FENewtonianViscousSolid.h" #include "FENewtonianViscousSolidUC.h" #include "FEOgdenMaterial.h" #include "FEOgdenUnconstrained.h" #include "FEOrthoElastic.h" #include "FEOrthotropicCLE.h" #include "FEOsmoticVirialExpansion.h" #include "FEPerfectOsmometer.h" #include "FEReactiveFatigue.h" #include "FEUncoupledReactiveFatigue.h" #include "FERemodelingElasticMaterial.h" #include "FERigidMaterial.h" #include "FESphericalFiberDistribution.h" #include "FEStVenantKirchhoff.h" #include "FETCNonlinearOrthotropic.h" #include "FETendonMaterial.h" #include "FETraceFreeNeoHookean.h" #include "FETransIsoMooneyRivlin.h" #include "FETransIsoMREstrada.h" #include "FETransIsoVerondaWestmann.h" #include "FETrussMaterial.h" #include "FEUncoupledActiveContraction.h" #include "FEUncoupledElasticMixture.h" #include "FEUncoupledViscoElasticMaterial.h" #include "FEUncoupledViscoElasticDamage.h" #include "FEVerondaWestmann.h" #include "FEViscoElasticDamage.h" #include "FEViscoElasticMaterial.h" #include "FEVonMisesPlasticity.h" #include "FEElasticFiberMaterial.h" #include "FEElasticFiberMaterialUC.h" #include "FEFiberDensityDistribution.h" #include "FEContinuousFiberDistribution.h" #include "FEContinuousFiberDistributionUC.h" #include "FEODFFiberDistribution.h" #include "FEFiberIntegrationGauss.h" #include "FEFiberIntegrationTrapezoidal.h" #include "FEFiberIntegrationGeodesic.h" #include "FEFiberIntegrationGaussKronrod.h" #include "FEFiberIntegrationTriangle.h" #include "FECoupledTransIsoMooneyRivlin.h" #include "FECoupledTransIsoVerondaWestmann.h" #include "FEHGOCoronary.h" #include "FENonlinearSpring.h" #include "FEDiscreteElementMaterial.h" #include "FEPRLig.h" #include "FECoupledMooneyRivlin.h" #include "FECoupledVerondaWestmann.h" #include "FEReactivePlasticity.h" #include "FEReactivePlasticDamage.h" #include "FEReactiveViscoelastic.h" #include "FEUncoupledReactiveViscoelastic.h" #include "FEBondRelaxation.h" #include "FEBondRecruitment.h" #include "FEDamageMaterial.h" #include "FEDamageMaterialUC.h" #include "FERVEDamageMaterial.h" #include "FERVEFatigueMaterial.h" #include "FEDamageCDF.h" #include "FEDamageCriterion.h" #include "FERelativeVolumeCriterion.h" #include "FEPlasticFlowCurve.h" #include "FEFiberExpLinear.h" #include "FEUncoupledFiberExpLinear.h" #include "FEPrescribedActiveContractionUniaxial.h" #include "FEPrescribedActiveContractionUniaxialUC.h" #include "FEPrescribedActiveContractionTransIso.h" #include "FEPrescribedActiveContractionTransIsoUC.h" #include "FEPrescribedActiveContractionIsotropic.h" #include "FEPrescribedActiveContractionIsotropicUC.h" #include "FEGentMaterial.h" #include "FEWrinkleOgdenMaterial.h" #include "FEGenericHyperelastic.h" #include "FEGenericHyperelasticUC.h" #include "FEGenericTransIsoHyperelastic.h" #include "FEGenericTransIsoHyperelasticUC.h" #include "FEActiveFiberStress.h" #include "FEActiveFiberStressUC.h" #include "FEContinuousElasticDamage.h" #include "FEIsotropicLeeSacks.h" #include "FEIsotropicLeeSacksUncoupled.h" #include "FEPolynomialHyperElastic.h" #include "FEShenoyMaterial.h" #include "FELungMaterial.h" #include "FEGrowthTensor.h" #include "FEKinematicGrowth.h" #include "FEYeoh.h" #include "FEScaledElasticMaterial.h" #include "FEScaledUncoupledMaterial.h" #include "FEPressureLoad.h" #include "FEPressureRobinBC.h" #include "FETractionLoad.h" #include "FETractionRobinBC.h" #include "FESurfaceForceUniform.h" #include "FEBearingLoad.h" #include "FEIdealGasPressure.h" #include "FEGenericBodyForce.h" #include "FECentrifugalBodyForce.h" #include "FEPointBodyForce.h" #include "FESurfaceAttractionBodyForce.h" #include "FEMassDamping.h" #include "FEMovingFrameLoad.h" #include "FERadialBodyForce.h" #include "FEAxialBodyForce.h" #include "FEFacet2FacetSliding.h" #include "FEPeriodicBoundary.h" #include "FERigidWallInterface.h" #include "FESlidingInterface.h" #include "FESlidingElasticInterface.h" #include "FEPeriodicSurfaceConstraint.h" #include "FETiedInterface.h" #include "FETiedElasticInterface.h" #include "FEStickyInterface.h" #include "FEPointConstraint.h" #include "FEAzimuthConstraint.h" #include "FEFacet2FacetTied.h" #include "FEVolumeConstraint.h" #include "FEDistanceConstraint.h" #include "FEMortarSlidingContact.h" #include "FEMortarTiedContact.h" #include "FEContactPotential.h" #include "FEEdgeToSurfaceContactPotential.h" #include "FEEdgeToSurfaceSlidingContact.h" #include "FEPipetteAspiration.h" #include "FESymmetryPlane.h" #include "FERigidJoint.h" #include "FEGenericRigidJoint.h" #include "FERigidSphericalJoint.h" #include "FERigidRevoluteJoint.h" #include "FERigidPrismaticJoint.h" #include "FERigidCylindricalJoint.h" #include "FERigidPlanarJoint.h" #include "FERigidLock.h" #include "FERigidSpring.h" #include "FERigidDamper.h" #include "FERigidAngularDamper.h" #include "FERigidContractileForce.h" #include "FERigidForce.h" #include "FERigidCable.h" #include "FEDiscreteContact.h" #include "FERigidFollowerForce.h" #include "FERigidFollowerMoment.h" #include "FEFixedNormalDisplacement.h" #include "FESolidSolver.h" #include "FESolidSolver2.h" #include "FEExplicitSolidSolver.h" #include "FECGSolidSolver.h" #include "FEBioMechPlot.h" #include "FEBioMechData.h" #include "FESolidDomainFactory.h" #include "FEElasticSolidDomain.h" #include "FEElasticShellDomain.h" #include "FEElasticShellDomainOld.h" #include "FEElasticEASShellDomain.h" #include "FEElasticANSShellDomain.h" #include "FEElasticTrussDomain.h" #include "FELinearTrussDomain.h" #include "FERigidSolidDomain.h" #include "FERigidShellDomain.h" #include "FEElasticBeamDomain.h" #include "FERemodelingElasticDomain.h" #include "FEUDGHexDomain.h" #include "FEUT4Domain.h" #include "FESRIElasticSolidDomain.h" #include "FE3FieldElasticSolidDomain.h" #include "FE3FieldElasticShellDomain.h" #include "FEDiscreteElasticDomain.h" #include "FEDeformableSpringDomain.h" #include "RigidBC.h" #include "FERigidNodeSet.h" #include "FERigidRotationVector.h" #include "FERigidEulerAngles.h" #include "FEFixedDisplacement.h" #include "FEFixedShellDisplacement.h" #include "FEFixedRotation.h" #include "FEPrescribedDisplacement.h" #include "FEPrescribedShellDisplacement.h" #include "FEPrescribedRotation.h" #include "FEBCPrescribedDeformation.h" #include "FEBCRigidDeformation.h" #include "FEPrescribedNormalDisplacement.h" #include "FEMaxStressCriterion.h" #include "FEMaxDamageCriterion.h" #include "FESpringRuptureCriterion.h" #include "FEContactGapCriterion.h" #include "FEInitialDisplacement.h" #include "FEInitialVelocity.h" #include "FENodalForce.h" #include "FENodalTargetForce.h" #include "FEPreStrainElastic.h" #include "FEPreStrainUncoupledElastic.h" #include "FEConstPrestrain.h" #include "FEInSituStretchGradient.h" #include "FEPreStrainConstraint.h" #include "FEInitialPreStrain.h" #include "FEInitialRigidKinematics.h" #include "FENodeToNodeConstraint.h" #include "FEDeformationMapGenerator.h" #include "FESolidModule.h" #include "FESolidAnalysis.h" #include "FEElasticBeamMaterial.h" #include "FETiedLineConstraint.h" #include "FESlideLineConstraint.h" //----------------------------------------------------------------------------- //! Register all the classes of the FEBioMech module with the FEBio framework. void FEBioMech::InitModule() { //----------------------------------------------------------------------------- // Domain factory FECoreKernel& febio = FECoreKernel::GetInstance(); febio.RegisterDomain(new FESolidDomainFactory); //----------------------------------------------------------------------------- // create module febio.CreateModule(new FESolidModule, "solid", "{" " \"title\" : \"Structural Mechanics\"," " \"info\" : \"Quasi-static or dynamical structural mechanics analysis.\"" "}"); //----------------------------------------------------------------------------- // analyis classes (default type must match module name!) REGISTER_FECORE_CLASS(FESolidAnalysis, "solid"); //----------------------------------------------------------------------------- // Solver classes (default type must match module name!) REGISTER_FECORE_CLASS(FESolidSolver2, "solid"); REGISTER_FECORE_CLASS(FEExplicitSolidSolver, "explicit-solid"); REGISTER_FECORE_CLASS(FESolidSolver, "solid_old"); REGISTER_FECORE_CLASS(FECGSolidSolver, "CG-solid"); //----------------------------------------------------------------------------- // material classes // elastic materials (derived from FEElasticMaterial) REGISTER_FECORE_CLASS(FE2DFiberNeoHookean, "2D fiber neo-Hookean"); REGISTER_FECORE_CLASS(FEABUnconstrained, "Arruda-Boyce unconstrained"); REGISTER_FECORE_CLASS(FECarreauYasudaViscousSolid, "Carreau-Yasuda viscous solid"); REGISTER_FECORE_CLASS(FECellGrowth, "cell growth"); REGISTER_FECORE_CLASS(FECubicCLE, "cubic CLE"); REGISTER_FECORE_CLASS(FEDamageNeoHookean, "damage neo-Hookean"); REGISTER_FECORE_CLASS(FEDonnanEquilibrium, "Donnan equilibrium"); REGISTER_FECORE_CLASS(FEEFDDonnanEquilibrium, "EFD Donnan equilibrium"); REGISTER_FECORE_CLASS(FEEFDNeoHookean, "EFD neo-Hookean (new)"); REGISTER_FECORE_CLASS(FEEFDNeoHookeanOld, "EFD neo-Hookean"); REGISTER_FECORE_CLASS(FEEllipsoidalFiberDistribution, "ellipsoidal fiber distribution"); REGISTER_FECORE_CLASS(FEEllipsoidalFiberDistributionOld, "ellipsoidal fiber distribution (old)"); REGISTER_FECORE_CLASS(FEFungOrthoCompressible, "Fung-ortho-compressible"); REGISTER_FECORE_CLASS(FECompressibleGentMaterial, "compressible Gent"); REGISTER_FECORE_CLASS(FEHolmesMow, "Holmes-Mow"); REGISTER_FECORE_CLASS(FEHolmesMowUC, "uncoupled Holmes-Mow"); REGISTER_FECORE_CLASS(FEHolzapfelUnconstrained, "HGO unconstrained"); REGISTER_FECORE_CLASS(FEIsotropicElastic, "isotropic elastic"); REGISTER_FECORE_CLASS(FEIsoHencky, "isotropic Hencky"); REGISTER_FECORE_CLASS(FECoupledMooneyRivlin, "coupled Mooney-Rivlin"); REGISTER_FECORE_CLASS(FECoupledVerondaWestmann, "coupled Veronda-Westmann"); REGISTER_FECORE_CLASS(FENaturalNeoHookean, "natural neo-Hookean"); REGISTER_FECORE_CLASS(FENeoHookean, "neo-Hookean"); REGISTER_FECORE_CLASS(FENeoHookeanAD, "neo-Hookean AD"); REGISTER_FECORE_CLASS(FENeoHookeanTransIso, "neo-Hookean transiso"); REGISTER_FECORE_CLASS(FETraceFreeNeoHookean, "trace-free neo-Hookean"); REGISTER_FECORE_CLASS(FENewtonianViscousSolid, "Newtonian viscous solid"); REGISTER_FECORE_CLASS(FEOgdenUnconstrained, "Ogden unconstrained"); REGISTER_FECORE_CLASS(FEOrthoElastic, "orthotropic elastic"); REGISTER_FECORE_CLASS(FEOrthotropicCLE, "orthotropic CLE"); REGISTER_FECORE_CLASS(FEOsmoticVirialExpansion, "osmotic virial expansion"); REGISTER_FECORE_CLASS(FEPerfectOsmometer, "perfect osmometer"); REGISTER_FECORE_CLASS(FESphericalFiberDistribution, "spherical fiber distribution"); REGISTER_FECORE_CLASS(FEStVenantKirchhoff, "St.Venant-Kirchhoff"); REGISTER_FECORE_CLASS(FEViscoElasticDamage, "viscoelastic damage"); REGISTER_FECORE_CLASS(FEViscoElasticMaterial, "viscoelastic"); REGISTER_FECORE_CLASS(FEElasticMultigeneration, "multigeneration"); REGISTER_FECORE_CLASS(FERemodelingElasticMaterial, "remodeling solid"); REGISTER_FECORE_CLASS(FECarterHayesOld, "Carter-Hayes (old)"); REGISTER_FECORE_CLASS(FEContinuousFiberDistribution, "continuous fiber distribution"); REGISTER_FECORE_CLASS(FEODFFiberDistribution, "fiberODF"); REGISTER_FECORE_CLASS(FECoupledTransIsoVerondaWestmann, "coupled trans-iso Veronda-Westmann"); REGISTER_FECORE_CLASS(FECoupledTransIsoMooneyRivlin, "coupled trans-iso Mooney-Rivlin"); REGISTER_FECORE_CLASS(FEGenericHyperelastic, "hyperelastic"); REGISTER_FECORE_CLASS(FEGenericTransIsoHyperelastic, "trans-iso hyperelastic"); REGISTER_FECORE_CLASS(FEDamageFiberPower, "damage fiber power"); REGISTER_FECORE_CLASS(FEDamageFiberExponential, "damage fiber exponential"); REGISTER_FECORE_CLASS(FEDamageFiberExpLinear, "damage fiber exp-linear"); REGISTER_FECORE_CLASS(FEGenerationMaterial, "generation"); REGISTER_FECORE_CLASS(FEHGOCoronary, "HGO-coronary"); REGISTER_FECORE_CLASS(FELungMaterial, "lung"); REGISTER_FECORE_CLASS(FEKinematicGrowth, "kinematic growth"); REGISTER_FECORE_CLASS(FEScaledElasticMaterial, "scaled elastic"); // These materials are derived from FEElasticMaterial and use FEElasticMaterials REGISTER_FECORE_CLASS(FEElasticMixture, "solid mixture"); REGISTER_FECORE_CLASS(FEReactiveViscoelasticMaterial, "reactive viscoelastic"); REGISTER_FECORE_CLASS(FEDamageMaterial, "elastic damage"); REGISTER_FECORE_CLASS(FERVEDamageMaterial, "reactive viscoelastic damage"); REGISTER_FECORE_CLASS(FEReactiveFatigue, "reactive fatigue"); REGISTER_FECORE_CLASS(FERVEFatigueMaterial, "reactive viscoelastic fatigue"); REGISTER_FECORE_CLASS(FEReactivePlasticity, "reactive plasticity"); REGISTER_FECORE_CLASS(FEReactivePlasticDamage, "reactive plastic damage"); // Uncoupled elastic materials (derived from FEUncoupledMaterial) REGISTER_FECORE_CLASS(FEArrudaBoyce, "Arruda-Boyce"); REGISTER_FECORE_CLASS(FE2DTransIsoMooneyRivlin, "2D trans iso Mooney-Rivlin"); REGISTER_FECORE_CLASS(FE2DTransIsoVerondaWestmann, "2D trans iso Veronda-Westmann"); REGISTER_FECORE_CLASS(FEDamageMooneyRivlin, "damage Mooney-Rivlin"); REGISTER_FECORE_CLASS(FEDamageTransIsoMooneyRivlin, "damage trans iso Mooney-Rivlin"); REGISTER_FECORE_CLASS(FEEFDMooneyRivlin, "EFD Mooney-Rivlin"); REGISTER_FECORE_CLASS(FEEFDUncoupled, "EFD uncoupled"); REGISTER_FECORE_CLASS(FEEFDVerondaWestmann, "EFD Veronda-Westmann"); REGISTER_FECORE_CLASS(FEFungOrthotropic, "Fung orthotropic"); REGISTER_FECORE_CLASS(FEHolzapfelGasserOgden, "Holzapfel-Gasser-Ogden"); REGISTER_FECORE_CLASS(FEGentMaterial, "Gent"); REGISTER_FECORE_CLASS(FEIncompNeoHookean, "incomp neo-Hookean"); REGISTER_FECORE_CLASS(FEMooneyRivlin, "Mooney-Rivlin"); REGISTER_FECORE_CLASS(FEMooneyRivlinAD, "Mooney-Rivlin AD"); REGISTER_FECORE_CLASS(FEMuscleMaterial, "muscle material"); REGISTER_FECORE_CLASS(FENewtonianViscousSolidUC, "Newtonian viscous solid uncoupled"); REGISTER_FECORE_CLASS(FEOgdenMaterial, "Ogden"); REGISTER_FECORE_CLASS(FETCNonlinearOrthotropic, "TC nonlinear orthotropic"); REGISTER_FECORE_CLASS(FETendonMaterial, "tendon material"); REGISTER_FECORE_CLASS(FETransIsoMooneyRivlin, "trans iso Mooney-Rivlin"); REGISTER_FECORE_CLASS(FETransIsoMREstrada, "trans iso MR-Estrada"); REGISTER_FECORE_CLASS(FETransIsoVerondaWestmann, "trans iso Veronda-Westmann"); REGISTER_FECORE_CLASS(FEUncoupledElasticMixture, "uncoupled solid mixture"); REGISTER_FECORE_CLASS(FEVerondaWestmann, "Veronda-Westmann"); REGISTER_FECORE_CLASS(FEUncoupledViscoElasticDamage, "uncoupled viscoelastic damage"); REGISTER_FECORE_CLASS(FEUncoupledViscoElasticMaterial, "uncoupled viscoelastic"); REGISTER_FECORE_CLASS(FEMRVonMisesFibers, "Mooney-Rivlin von Mises Fibers"); REGISTER_FECORE_CLASS(FEUncoupledActiveContraction, "uncoupled active contraction"); REGISTER_FECORE_CLASS(FEContinuousFiberDistributionUC, "continuous fiber distribution uncoupled"); REGISTER_FECORE_CLASS(FEPRLig, "PRLig"); REGISTER_FECORE_CLASS(FEUncoupledReactiveViscoelasticMaterial, "uncoupled reactive viscoelastic"); REGISTER_FECORE_CLASS(FEDamageMaterialUC, "uncoupled elastic damage"); REGISTER_FECORE_CLASS(FEUncoupledReactiveFatigue, "uncoupled reactive fatigue"); REGISTER_FECORE_CLASS(FEGenericHyperelasticUC, "uncoupled hyperelastic"); REGISTER_FECORE_CLASS(FEGenericTransIsoHyperelasticUC, "uncoupled trans-iso hyperelastic"); REGISTER_FECORE_CLASS(FEIsotropicLeeSacks, "isotropic Lee-Sacks"); REGISTER_FECORE_CLASS(FEIsotropicLeeSacksUncoupled, "uncoupled isotropic Lee-Sacks"); REGISTER_FECORE_CLASS(FEPolynomialHyperElastic, "polynomial"); REGISTER_FECORE_CLASS(FEShenoyMaterial, "Shenoy"); REGISTER_FECORE_CLASS(FEFiberEFDNeoHookean, "fiber neo-Hookean"); REGISTER_FECORE_CLASS(FEScaledUncoupledMaterial, "scaled uncoupled"); REGISTER_FECORE_CLASS(FEYeoh, "Yeoh"); // fiber materials (derived from FEFiberMaterial) REGISTER_FECORE_CLASS(FEFiberCDF , "fiber-CDF" ); REGISTER_FECORE_CLASS(FEFiberNH , "fiber-NH" ); REGISTER_FECORE_CLASS(FEFiberExpPow , "fiber-exp-pow" ); REGISTER_FECORE_CLASS(FEFiberExpLinear , "fiber-exp-linear" ); REGISTER_FECORE_CLASS(FEFiberPow , "fiber-pow" ); REGISTER_FECORE_CLASS(FEFiberPowLinear , "fiber-pow-linear" ); REGISTER_FECORE_CLASS(FEFiberExpPowLinear, "fiber-exp-pow-linear"); REGISTER_FECORE_CLASS(FEFiberNaturalNH , "fiber-natural-NH" ); REGISTER_FECORE_CLASS(FEFiberEntropyChain, "fiber-entropy-chain" ); REGISTER_FECORE_CLASS(FEVolumeGrowth , "volume growth" ); REGISTER_FECORE_CLASS(FEAreaGrowth , "area growth" ); REGISTER_FECORE_CLASS(FEFiberGrowth , "fiber growth" ); REGISTER_FECORE_CLASS(FEGeneralGrowth , "general growth" ); // Elastic Fiber materials (derived from FEElasticFiberMaterial) REGISTER_FECORE_CLASS(FEElasticFiberCDF , "fiber-CDF" ); REGISTER_FECORE_CLASS(FEElasticFiberNH , "fiber-NH" ); REGISTER_FECORE_CLASS(FEElasticFiberExpPow , "fiber-exp-pow" ); REGISTER_FECORE_CLASS(FEElasticFiberExpLinear , "fiber-exp-linear" ); REGISTER_FECORE_CLASS(FEElasticFiberPow , "fiber-pow" ); REGISTER_FECORE_CLASS(FEElasticFiberPowLinear , "fiber-pow-linear" ); REGISTER_FECORE_CLASS(FEElasticFiberExpPowLinear, "fiber-exp-pow-linear"); REGISTER_FECORE_CLASS(FEElasticFiberNaturalNH , "fiber-natural-NH" ); REGISTER_FECORE_CLASS(FEElasticFiberEntropyChain, "fiber-entropy-chain" ); // fiber materials for uncoupled formulation (derived from FEFiberMaterialUC) REGISTER_FECORE_CLASS(FEFiberCDFUncoupled , "fiber-CDF-uncoupled" ); REGISTER_FECORE_CLASS(FEFiberExpLinearUC , "uncoupled fiber-exp-linear"); REGISTER_FECORE_CLASS(FEFiberNHUC , "fiber-NH-uncoupled"); REGISTER_FECORE_CLASS(FEFiberExpPowUC , "fiber-exp-pow-uncoupled"); REGISTER_FECORE_CLASS(FEFiberPowLinearUC , "fiber-pow-linear-uncoupled"); REGISTER_FECORE_CLASS(FEFiberEntropyChainUC, "uncoupled fiber-entropy-chain"); // Uncoupled elastic fiber materials (derived from FEUncoupledFiberMaterial) REGISTER_FECORE_CLASS(FEElasticFiberCDFUncoupled , "fiber-CDF-uncoupled" ); REGISTER_FECORE_CLASS(FEUncoupledFiberExpLinear , "uncoupled fiber-exp-linear"); REGISTER_FECORE_CLASS(FEUncoupledFiberNH , "fiber-NH-uncoupled"); REGISTER_FECORE_CLASS(FEUncoupledFiberExpPow , "fiber-exp-pow-uncoupled"); REGISTER_FECORE_CLASS(FEUncoupledFiberPowLinear , "fiber-pow-linear-uncoupled"); REGISTER_FECORE_CLASS(FEUncoupledFiberKiousis , "fiber-Kiousis-uncoupled"); REGISTER_FECORE_CLASS(FEUncoupledFiberEntropyChainUC, "uncoupled fiber-entropy-chain"); // obsolete fiber materials REGISTER_FECORE_CLASS(FEFiberExponentialPower, "fiber-exponential-power-law"); REGISTER_FECORE_CLASS(FEFiberExponentialPowerUC, "fiber-exponential-power-law-uncoupled"); // solid materials (derived from FESolidMaterial) REGISTER_FECORE_CLASS(FERigidMaterial, "rigid body"); REGISTER_FECORE_CLASS(FEVonMisesPlasticity, "von-Mises plasticity"); // Fiber density distributions for CFD materials REGISTER_FECORE_CLASS(FESphericalFiberDensityDistribution, "spherical"); REGISTER_FECORE_CLASS(FEEllipsoidalFiberDensityDistribution, "ellipsoidal"); REGISTER_FECORE_CLASS(FEVonMises3DFiberDensityDistribution, "von-Mises-3d"); REGISTER_FECORE_CLASS(FEVonMises3DTwoFDDAxisymmetric, "von-Mises-3d-two-axisym"); REGISTER_FECORE_CLASS(FECircularFiberDensityDistribution, "circular"); REGISTER_FECORE_CLASS(FEEllipticalFiberDensityDistribution, "elliptical"); REGISTER_FECORE_CLASS(FEVonMises2DFiberDensityDistribution, "von-Mises-2d"); REGISTER_FECORE_CLASS(FEStructureTensorDistribution, "structure-tensor"); // Fiber distribution integration schemes for CFD materials REGISTER_FECORE_CLASS(FEFiberIntegrationGauss, "fibers-3d-gauss"); REGISTER_FECORE_CLASS(FEFiberIntegrationGeodesic, "fibers-3d-geodesic"); REGISTER_FECORE_CLASS(FEFiberIntegrationGaussKronrod, "fibers-3d-gkt"); REGISTER_FECORE_CLASS(FEFiberIntegrationTriangle, "fibers-3d-fei"); REGISTER_FECORE_CLASS(FEFiberIntegrationTrapezoidal, "fibers-2d-trapezoidal"); // Fiber ODF classes REGISTER_FECORE_CLASS(FEFiberODF, "fiber-odf"); // Other materials REGISTER_FECORE_CLASS(FELinearTrussMaterial, "linear truss"); REGISTER_FECORE_CLASS(FEHuiskesSupply, "Huiskes-supply"); REGISTER_FECORE_CLASS(FEUncoupledActiveFiberContraction, "uncoupled active_contraction"); REGISTER_FECORE_CLASS(FEActiveFiberContraction, "active_contraction"); REGISTER_FECORE_CLASS(FEForceVelocityContraction, "force-velocity-Estrada"); REGISTER_FECORE_CLASS(FEWrinkleOgdenMaterial, "wrinkle Ogden"); REGISTER_FECORE_CLASS(FEElasticMembrane, "elastic membrane"); // active contraction materials REGISTER_FECORE_CLASS(FEPrescribedActiveContractionUniaxial, "prescribed uniaxial active contraction"); REGISTER_FECORE_CLASS(FEPrescribedActiveContractionUniaxialUC, "uncoupled prescribed uniaxial active contraction"); REGISTER_FECORE_CLASS(FEPrescribedActiveContractionTransIso, "prescribed trans iso active contraction"); REGISTER_FECORE_CLASS(FEPrescribedActiveContractionTransIsoUC, "uncoupled prescribed trans iso active contraction"); REGISTER_FECORE_CLASS(FEPrescribedActiveContractionIsotropic, "prescribed isotropic active contraction"); REGISTER_FECORE_CLASS(FEPrescribedActiveContractionIsotropicUC, "uncoupled prescribed isotropic active contraction"); REGISTER_FECORE_CLASS(FEPrescribedActiveContractionFiber, "prescribed fiber active contraction"); REGISTER_FECORE_CLASS(FEPrescribedActiveContractionFiberUC, "uncoupled prescribed fiber active contraction"); REGISTER_FECORE_CLASS(FEActiveFiberStress, "active fiber stress"); REGISTER_FECORE_CLASS(FEActiveFiberStressUC, "uncoupled active fiber stress"); // discrete materials REGISTER_FECORE_CLASS(FECompositeDiscreteMaterial, "discrete composite"); REGISTER_FECORE_CLASS(FELinearSpring, "linear spring"); REGISTER_FECORE_CLASS(FETensionOnlyLinearSpring, "tension-only linear spring"); REGISTER_FECORE_CLASS(FENonlinearSpringMaterial, "nonlinear spring"); REGISTER_FECORE_CLASS(FEExperimentalSpring, "experimental spring"); REGISTER_FECORE_CLASS(FEDiscreteContractileMaterial, "Hill"); REGISTER_FECORE_CLASS(FETorsionalSpring, "torsion spring"); // bond relaxation materials (used by reactive visco-elastic materials) REGISTER_FECORE_CLASS(FEBondRelaxationExponential, "relaxation-exponential"); REGISTER_FECORE_CLASS(FEBondRelaxationExpDistortion, "relaxation-exp-distortion"); REGISTER_FECORE_CLASS(FEBondRelaxationExpDistUser, "relaxation-exp-dist-user"); REGISTER_FECORE_CLASS(FEBondRelaxationFung, "relaxation-Fung"); REGISTER_FECORE_CLASS(FEBondRelaxationPark, "relaxation-Park"); REGISTER_FECORE_CLASS(FEBondRelaxationParkDistortion, "relaxation-Park-distortion"); REGISTER_FECORE_CLASS(FEBondRelaxationParkDistUser, "relaxation-Park-dist-user"); REGISTER_FECORE_CLASS(FEBondRelaxationPower, "relaxation-power"); REGISTER_FECORE_CLASS(FEBondRelaxationPowerDistortion, "relaxation-power-distortion"); REGISTER_FECORE_CLASS(FEBondRelaxationPowerDistUser, "relaxation-power-dist-user"); REGISTER_FECORE_CLASS(FEBondRelaxationCarreau, "relaxation-Carreau"); REGISTER_FECORE_CLASS(FEBondRelaxationProny, "relaxation-Prony"); REGISTER_FECORE_CLASS(FEBondRelaxationMalkin, "relaxation-Malkin"); REGISTER_FECORE_CLASS(FEBondRelaxationMalkinDist, "relaxation-Malkin-distortion"); REGISTER_FECORE_CLASS(FEBondRelaxationMalkinDistUser, "relaxation-Malkin-dist-user"); REGISTER_FECORE_CLASS(FEBondRelaxationCSexp, "relaxation-CSexp"); REGISTER_FECORE_CLASS(FEBondRelaxationCSexpDistUser, "relaxation-CSexp-dist-user"); // bond recruitment materials (used by reactive visco-elastic materials) REGISTER_FECORE_CLASS(FEBondRecruitmentUser, "recruitment user"); REGISTER_FECORE_CLASS(FEBondRecruitmentPower, "recruitment power"); REGISTER_FECORE_CLASS(FEBondRecruitmentExp, "recruitment exponential"); REGISTER_FECORE_CLASS(FEBondRecruitmentPoly, "recruitment polynomial"); REGISTER_FECORE_CLASS(FEBondRecruitmentLogNormal, "recruitment log-normal"); REGISTER_FECORE_CLASS(FEBondRecruitmentWeibull, "recruitment Weibull"); REGISTER_FECORE_CLASS(FEBondRecruitmentPQP, "recruitment quintic"); REGISTER_FECORE_CLASS(FEBondRecruitmentGamma, "recruitment gamma"); // damage cumulative distribution functions (used by damage materials) REGISTER_FECORE_CLASS(FEDamageCDFSimo, "CDF Simo"); REGISTER_FECORE_CLASS(FEDamageCDFLogNormal, "CDF log-normal"); REGISTER_FECORE_CLASS(FEDamageCDFWeibull, "CDF Weibull"); REGISTER_FECORE_CLASS(FEDamageCDFStep, "CDF step"); REGISTER_FECORE_CLASS(FEDamageCDFPQP, "CDF quintic"); REGISTER_FECORE_CLASS(FEDamageCDFGamma, "CDF gamma"); REGISTER_FECORE_CLASS(FEDamageCDFUser, "CDF user"); // damage criterion (used by damage and plastic materials) REGISTER_FECORE_CLASS(FEDamageCriterionSimo, "DC Simo"); REGISTER_FECORE_CLASS(FEDamageCriterionSED, "DC strain energy density"); REGISTER_FECORE_CLASS(FEDamageCriterionSSE, "DC specific strain energy"); REGISTER_FECORE_CLASS(FEDamageCriterionVMS, "DC von Mises stress"); REGISTER_FECORE_CLASS(FEDamageCriterionDrucker, "DC Drucker shear stress"); REGISTER_FECORE_CLASS(FEDamageCriterionMSS, "DC max shear stress"); REGISTER_FECORE_CLASS(FEDamageCriterionMNS, "DC max normal stress"); REGISTER_FECORE_CLASS(FEDamageCriterionMNLS, "DC max normal Lagrange strain"); REGISTER_FECORE_CLASS(FEDamageCriterionOSS, "DC octahedral shear strain"); REGISTER_FECORE_CLASS(FEDamageCriterionONS, "DC octahedral natural strain"); REGISTER_FECORE_CLASS(FEDamageCriterionDruckerPrager, "DC Drucker-Prager"); REGISTER_FECORE_CLASS(FEDamageCriterionDeshpandeFleck, "DC Deshpande-Fleck"); // plastic flow curve (used by plastic materials) REGISTER_FECORE_CLASS(FEPlasticFlowCurvePaper, "PFC paper"); REGISTER_FECORE_CLASS(FEPlasticFlowCurveUser , "PFC user"); REGISTER_FECORE_CLASS(FEPlasticFlowCurveMath , "PFC math"); // prestrain materials REGISTER_FECORE_CLASS(FEPrestrainElastic, "prestrain elastic"); REGISTER_FECORE_CLASS(FEPreStrainUncoupledElastic, "uncoupled prestrain elastic"); REGISTER_FECORE_CLASS(FEConstPrestrainGradient, "prestrain gradient"); REGISTER_FECORE_CLASS(FEInSituStretchGradient, "in-situ stretch"); // beam materials REGISTER_FECORE_CLASS(FEElasticBeamMaterial, "linear-beam"); //----------------------------------------------------------------------------- // domain classes REGISTER_FECORE_CLASS(FERigidSolidDomain, "rigid-solid"); REGISTER_FECORE_CLASS(FERigidShellDomain, "rigid-shell"); REGISTER_FECORE_CLASS(FERigidShellDomainOld, "rigid-shell-old"); REGISTER_FECORE_CLASS(FERemodelingElasticDomain, "remodeling-solid"); REGISTER_FECORE_CLASS(FE3FieldElasticSolidDomain, "three-field-solid"); REGISTER_FECORE_CLASS(FE3FieldElasticShellDomain, "three-field-shell"); REGISTER_FECORE_CLASS(FEUDGHexDomain, "udg-hex"); REGISTER_FECORE_CLASS(FESRIElasticSolidDomain, "sri-solid"); REGISTER_FECORE_CLASS(FEUT4Domain, "ut4-solid"); REGISTER_FECORE_CLASS(FEStandardElasticSolidDomain, "elastic-solid"); REGISTER_FECORE_CLASS(FEElasticShellDomain, "elastic-shell"); REGISTER_FECORE_CLASS(FEElasticShellDomainOld, "elastic-shell-old"); REGISTER_FECORE_CLASS(FEElasticEASShellDomain, "elastic-shell-eas"); REGISTER_FECORE_CLASS(FEElasticANSShellDomain, "elastic-shell-ans"); REGISTER_FECORE_CLASS(FELinearTrussDomain, "linear-truss"); REGISTER_FECORE_CLASS(FEElasticTrussDomain, "elastic-truss"); REGISTER_FECORE_CLASS(FEElasticBeamDomain, "linear-beam"); REGISTER_FECORE_CLASS(FEDiscreteElasticDomain, "discrete"); REGISTER_FECORE_CLASS(FEDeformableSpringDomain, "deformable-spring"); REGISTER_FECORE_CLASS(FEDeformableSpringDomain2, "deformable-spring2"); //----------------------------------------------------------------------------- // classes derived from FEBoundaryCondition REGISTER_FECORE_CLASS(FEFixedDisplacement , "zero displacement"); REGISTER_FECORE_CLASS(FEFixedRotation , "zero rotation"); REGISTER_FECORE_CLASS(FEFixedShellDisplacement , "zero shell displacement"); REGISTER_FECORE_CLASS(FEPrescribedDisplacement , "prescribed displacement"); REGISTER_FECORE_CLASS(FEPrescribedRotation , "prescribed rotation"); REGISTER_FECORE_CLASS(FEPrescribedShellDisplacement , "prescribed shell displacement"); REGISTER_FECORE_CLASS(FEBCPrescribedDeformation , "prescribed deformation"); REGISTER_FECORE_CLASS(FEPrescribedNormalDisplacement, "normal displacement"); REGISTER_FECORE_CLASS(FEBCRigidDeformation , "rigid deformation"); REGISTER_FECORE_CLASS(FEBCPrescribedDeformation2O , "prescribed deformation 2O"); REGISTER_FECORE_CLASS(FERigidNodeSet , "rigid"); //----------------------------------------------------------------------------- // classes derived from FEInitialCondition REGISTER_FECORE_CLASS(FEInitialDisplacement, "displacement"); REGISTER_FECORE_CLASS(FEInitialVelocity, "velocity"); REGISTER_FECORE_CLASS(FEInitialShellVelocity, "shell velocity"); REGISTER_FECORE_CLASS(FEInitialPreStrain, "prestrain"); REGISTER_FECORE_CLASS(FEInitialRigidKinematics, "rigid kinematics"); //----------------------------------------------------------------------------- // classes derived from FENodalLoad REGISTER_FECORE_CLASS(FENodalForce, "nodal_force"); REGISTER_FECORE_CLASS(FENodalTargetForce, "nodal_target_force"); //----------------------------------------------------------------------------- // classes derived from FESurfaceLoad REGISTER_FECORE_CLASS(FEPressureLoad, "pressure"); REGISTER_FECORE_CLASS(FETractionLoad, "traction"); REGISTER_FECORE_CLASS(FESurfaceForceUniform, "force"); REGISTER_FECORE_CLASS(FEBearingLoad, "bearing load"); REGISTER_FECORE_CLASS(FEIdealGasPressure, "ideal gas pressure"); REGISTER_FECORE_CLASS(FEPressureRobinBC, "pressure Robin BC", FECORE_EXPERIMENTAL); REGISTER_FECORE_CLASS(FETractionRobinBC, "traction Robin BC", FECORE_EXPERIMENTAL); REGISTER_FECORE_CLASS(FEPipetteAspiration, "pipette aspiration"); //----------------------------------------------------------------------------- // classes derived from FEBodyForce REGISTER_FECORE_CLASS(FEConstBodyForceOld, "const"); // obsolete in 3.0 REGISTER_FECORE_CLASS(FENonConstBodyForceOld, "non-const"); // obsolete in 3.0 REGISTER_FECORE_CLASS(FEGenericBodyForce, "body force"); REGISTER_FECORE_CLASS(FECentrifugalBodyForce, "centrifugal"); REGISTER_FECORE_CLASS(FEPointBodyForce, "point", FECORE_EXPERIMENTAL); REGISTER_FECORE_CLASS(FESurfaceAttractionBodyForce, "surface attraction"); REGISTER_FECORE_CLASS(FEMassDamping, "mass damping"); REGISTER_FECORE_CLASS(FEMovingFrameLoad, "moving frame"); REGISTER_FECORE_CLASS(FERadialBodyForce, "radial force"); REGISTER_FECORE_CLASS(FEAxialBodyForce, "axial force"); //----------------------------------------------------------------------------- // constraint classes REGISTER_FECORE_CLASS(FEPointConstraint, "point"); REGISTER_FECORE_CLASS(FESymmetryPlane, "symmetry plane"); REGISTER_FECORE_CLASS(FERigidJoint, "rigid joint"); REGISTER_FECORE_CLASS(FEGenericRigidJoint, "generic rigid joint"); REGISTER_FECORE_CLASS(FERigidSphericalJoint, "rigid spherical joint"); REGISTER_FECORE_CLASS(FERigidRevoluteJoint, "rigid revolute joint"); REGISTER_FECORE_CLASS(FERigidPrismaticJoint, "rigid prismatic joint"); REGISTER_FECORE_CLASS(FERigidCylindricalJoint, "rigid cylindrical joint"); REGISTER_FECORE_CLASS(FERigidPlanarJoint, "rigid planar joint"); REGISTER_FECORE_CLASS(FERigidLock, "rigid lock"); REGISTER_FECORE_CLASS(FERigidSpring, "rigid spring"); REGISTER_FECORE_CLASS(FERigidDamper, "rigid damper"); REGISTER_FECORE_CLASS(FERigidAngularDamper, "rigid angular damper"); REGISTER_FECORE_CLASS(FERigidContractileForce, "rigid contractile force"); REGISTER_FECORE_CLASS(FEVolumeConstraint, "volume"); REGISTER_FECORE_CLASS(FEDiscreteContact, "discrete contact"); REGISTER_FECORE_CLASS(FEDiscreteContact2, "discrete contact2"); REGISTER_FECORE_CLASS(FEDistanceConstraint, "node distance"); REGISTER_FECORE_CLASS(FEGPAConstraint, "prestrain"); REGISTER_FECORE_CLASS(FEInSituStretchConstraint, "in-situ stretch"); REGISTER_FECORE_CLASS(FEAzimuthConstraint, "azimuth constraint"); REGISTER_FECORE_CLASS(FEFixedNormalDisplacement, "fixed normal displacement"); // Lagrange multiplier constraints REGISTER_FECORE_CLASS(FENodeToNodeConstraint, "node-on-node"); //----------------------------------------------------------------------------- // classes derived from FEContactInterface REGISTER_FECORE_CLASS(FESlidingInterface, "sliding-node-on-facet"); REGISTER_FECORE_CLASS(FEFacet2FacetSliding, "sliding-facet-on-facet"); REGISTER_FECORE_CLASS(FESlidingElasticInterface, "sliding-elastic"); REGISTER_FECORE_CLASS(FETiedInterface, "tied-node-on-facet"); REGISTER_FECORE_CLASS(FEFacet2FacetTied, "tied-facet-on-facet"); REGISTER_FECORE_CLASS(FETiedElasticInterface, "tied-elastic"); REGISTER_FECORE_CLASS(FEPeriodicBoundary, "periodic boundary"); REGISTER_FECORE_CLASS(FERigidWallInterface, "rigid_wall"); REGISTER_FECORE_CLASS(FEPeriodicSurfaceConstraint, "surface constraint"); REGISTER_FECORE_CLASS(FEStickyInterface, "sticky"); REGISTER_FECORE_CLASS(FEMortarSlidingContact, "mortar-sliding", FECORE_EXPERIMENTAL); REGISTER_FECORE_CLASS(FEMortarTiedContact, "mortar-tied", FECORE_EXPERIMENTAL); REGISTER_FECORE_CLASS(FEContactPotential, "contact potential"); REGISTER_FECORE_CLASS(FEEdgeToSurfaceContactPotential, "edge-to-surface contact potential"); REGISTER_FECORE_CLASS(FEEdgeToSurfaceSlidingContact, "edge-to-surface sliding contact"); REGISTER_FECORE_CLASS(FETiedLineConstraint, "tied-line"); REGISTER_FECORE_CLASS(FESlideLineConstraint, "slide-line"); //----------------------------------------------------------------------------- // classes derived directly from FERigidBC REGISTER_FECORE_CLASS(FERigidFixedBCNew , "rigid_fixed" ); REGISTER_FECORE_CLASS(FERigidDisplacement , "rigid_displacement" ); REGISTER_FECORE_CLASS(FERigidRotation , "rigid_rotation" ); REGISTER_FECORE_CLASS(FERigidRotationVector , "rigid_rotation_vector" ); REGISTER_FECORE_CLASS(FERigidEulerAngles , "rigid_euler_angles" ); REGISTER_FECORE_CLASS(FERigidFixedBCOld , "rigid_fixed_old" , 0x300); // obsolete in 4.0 REGISTER_FECORE_CLASS(FERigidPrescribedOld , "rigid_prescribed_old", 0x300); // obsolete in 4.0 // classes derived directly from FERigidIC REGISTER_FECORE_CLASS(FERigidBodyVelocity , "initial_rigid_velocity" ); REGISTER_FECORE_CLASS(FERigidBodyAngularVelocity, "initial_rigid_angular_velocity"); //----------------------------------------------------------------------------- // classes derived directly from FERigidLoad REGISTER_FECORE_CLASS(FERigidAxialForce , "rigid_axial_force" ); REGISTER_FECORE_CLASS(FERigidBodyForce , "rigid_force" ); REGISTER_FECORE_CLASS(FERigidBodyMoment , "rigid_moment" ); REGISTER_FECORE_CLASS(FERigidFollowerForce , "rigid_follower_force" ); REGISTER_FECORE_CLASS(FERigidFollowerMoment, "rigid_follower_moment"); REGISTER_FECORE_CLASS(FERigidCable , "rigid_cable"); REGISTER_FECORE_CLASS(FERigidCablePoint , "rigid_cable_point"); //----------------------------------------------------------------------------- // classes derived from FEPlotData REGISTER_FECORE_CLASS(FEPlotElementVelocity, "velocity"); REGISTER_FECORE_CLASS(FEPlotElementAcceleration, "acceleration"); REGISTER_FECORE_CLASS(FEPlotDensity, "density"); REGISTER_FECORE_CLASS(FEPlotElementStress, "stress"); REGISTER_FECORE_CLASS(FEPlotElementPK2Stress, "PK2 stress"); REGISTER_FECORE_CLASS(FEPlotElementPK1Stress, "PK1 stress"); REGISTER_FECORE_CLASS(FEPlotElementMixtureStress, "mixture stress"); REGISTER_FECORE_CLASS(FEPlotElementPlasticYieldStress, "plastic yield stress"); REGISTER_FECORE_CLASS(FEPlotElementDruckerShear, "Drucker shear stress"); REGISTER_FECORE_CLASS(FEPlotElementPragerDruckerStress, "Drucker-Prager stress"); REGISTER_FECORE_CLASS(FEPlotElementDeshpandeFleckStress, "Deshpande-Fleck stress"); REGISTER_FECORE_CLASS(FEPlotMixtureStrainEnergyDensity, "mixture strain energy density"); REGISTER_FECORE_CLASS(FEPlotMixtureDevStrainEnergyDensity, "mixture deviatoric strain energy density"); REGISTER_FECORE_CLASS(FEPlotMixtureSpecificStrainEnergy, "mixture specific strain energy"); REGISTER_FECORE_CLASS(FEPlotElementUncoupledPressure, "uncoupled pressure"); REGISTER_FECORE_CLASS(FEPlotElementElasticity, "elasticity"); REGISTER_FECORE_CLASS(FEPlotElementDevElasticity, "deviatoric elasticity"); REGISTER_FECORE_CLASS(FEPlotRelativeVolume, "relative volume"); REGISTER_FECORE_CLASS(FEPlotSPRRelativeVolume, "SPR relative volume"); REGISTER_FECORE_CLASS(FEPlotShellRelativeVolume, "shell relative volume");// , FECORE_SPEC(3, 0)); // NOTE: deprecated REGISTER_FECORE_CLASS(FEPlotFiberVector, "fiber vector"); REGISTER_FECORE_CLASS(FEPlotFiberStretch, "fiber stretch"); REGISTER_FECORE_CLASS(FEPlotDevFiberStretch, "deviatoric fiber stretch"); REGISTER_FECORE_CLASS(FEPlotMaterialAxes, "material axes"); REGISTER_FECORE_CLASS(FEPlotShellThickness, "shell thickness"); REGISTER_FECORE_CLASS(FEPlotShellDirector, "shell director"); REGISTER_FECORE_CLASS(FEPlotNodalShellDirector, "nodal shell director"); REGISTER_FECORE_CLASS(FEPlotDamage, "damage"); REGISTER_FECORE_CLASS(FEPlotIntactBondFraction, "intact bond fraction"); REGISTER_FECORE_CLASS(FEPlotFatigueBondFraction, "fatigue bond fraction"); REGISTER_FECORE_CLASS(FEPlotYieldedBondFraction, "yielded bond fraction"); REGISTER_FECORE_CLASS(FEPlotOctahedralPlasticStrain, "octahedral plastic strain"); REGISTER_FECORE_CLASS(FEPlotReactivePlasticityHeatSupply, "plasticity heat supply density"); REGISTER_FECORE_CLASS(FEPlotMixtureVolumeFraction, "volume fraction"); REGISTER_FECORE_CLASS(FEPlotUT4NodalStresses, "ut4 nodal stress"); REGISTER_FECORE_CLASS(FEPlotContactGap, "contact gap"); REGISTER_FECORE_CLASS(FEPlotNodalContactGap, "nodal contact gap"); REGISTER_FECORE_CLASS(FEPlotVectorGap, "vector gap"); REGISTER_FECORE_CLASS(FEPlotNodalVectorGap, "nodal vector gap"); REGISTER_FECORE_CLASS(FEPlotContactPressure, "contact pressure"); REGISTER_FECORE_CLASS(FEPlotNodalContactPressure, "nodal contact pressure"); REGISTER_FECORE_CLASS(FEPlotContactTraction, "contact traction"); REGISTER_FECORE_CLASS(FEPlotNodalContactTraction, "nodal contact traction"); REGISTER_FECORE_CLASS(FEPlotStickStatus, "contact stick"); REGISTER_FECORE_CLASS(FEPlotContactForce, "contact force"); REGISTER_FECORE_CLASS(FEPlotContactArea, "contact area"); REGISTER_FECORE_CLASS(FEPlotContactPenalty, "contact penalty"); REGISTER_FECORE_CLASS(FEPlotContactStatus, "contact status"); REGISTER_FECORE_CLASS(FEPlotSPRStresses, "SPR stress"); REGISTER_FECORE_CLASS(FEPlotSPRLinearStresses, "SPR-P1 stress"); REGISTER_FECORE_CLASS(FEPlotSPRPrincStresses, "SPR principal stress"); REGISTER_FECORE_CLASS(FEPlotNodalStresses, "nodal stress"); REGISTER_FECORE_CLASS(FEPlotShellTopStress, "shell top stress"); REGISTER_FECORE_CLASS(FEPlotShellBottomStress, "shell bottom stress"); REGISTER_FECORE_CLASS(FEPlotShellTopNodalStresses, "shell top nodal stress"); REGISTER_FECORE_CLASS(FEPlotShellBottomNodalStresses, "shell bottom nodal stress"); REGISTER_FECORE_CLASS(FEPlotNodalStrains, "nodal strain"); REGISTER_FECORE_CLASS(FEPlotShellTopNodalStrains, "shell top nodal strain"); REGISTER_FECORE_CLASS(FEPlotShellBottomNodalStrains, "shell bottom nodal strain"); REGISTER_FECORE_CLASS(FEPlotShellTopStrain, "shell top strain"); REGISTER_FECORE_CLASS(FEPlotShellBottomStrain, "shell bottom strain"); REGISTER_FECORE_CLASS(FEPlotShellStrain, "shell strain"); REGISTER_FECORE_CLASS(FEPlotDeformationGradient, "deformation gradient"); REGISTER_FECORE_CLASS(FEPlotLagrangeStrain, "Lagrange strain"); REGISTER_FECORE_CLASS(FEPlotInfStrain, "infinitesimal strain"); REGISTER_FECORE_CLASS(FEPlotSPRLagrangeStrain, "SPR Lagrange strain"); REGISTER_FECORE_CLASS(FEPlotSPRInfStrain, "SPR infinitesimal strain"); REGISTER_FECORE_CLASS(FEPlotAlmansiStrain, "Almansi strain"); REGISTER_FECORE_CLASS(FEPlotRightCauchyGreen, "right Cauchy-Green"); REGISTER_FECORE_CLASS(FEPlotLeftCauchyGreen, "left Cauchy-Green"); REGISTER_FECORE_CLASS(FEPlotRightStretch, "right stretch"); REGISTER_FECORE_CLASS(FEPlotLeftStretch, "left stretch"); REGISTER_FECORE_CLASS(FEPlotRightHencky, "right Hencky"); REGISTER_FECORE_CLASS(FEPlotLeftHencky, "left Hencky"); REGISTER_FECORE_CLASS(FEPlotRateOfDeformation, "rate of deformation"); REGISTER_FECORE_CLASS(FEPlotMortarContactGap, "mortar-gap"); REGISTER_FECORE_CLASS(FEPlotSurfaceTraction, "surface traction"); REGISTER_FECORE_CLASS(FEPlotNodalSurfaceTraction, "nodal surface traction"); REGISTER_FECORE_CLASS(FEPlotEnclosedVolume, "enclosed volume"); REGISTER_FECORE_CLASS(FEPlotEnclosedVolumeChange, "enclosed volume change"); REGISTER_FECORE_CLASS(FEPlotSurfaceArea, "surface area"); REGISTER_FECORE_CLASS(FEPlotFacetArea, "facet area"); REGISTER_FECORE_CLASS(FEPlotStrainEnergyDensity, "strain energy density"); REGISTER_FECORE_CLASS(FEPlotDevStrainEnergyDensity, "deviatoric strain energy density"); REGISTER_FECORE_CLASS(FEPlotSpecificStrainEnergy, "specific strain energy"); REGISTER_FECORE_CLASS(FEPlotKineticEnergyDensity, "kinetic energy density"); REGISTER_FECORE_CLASS(FEPlotElementStrainEnergy, "element strain energy"); REGISTER_FECORE_CLASS(FEPlotElementKineticEnergy, "element kinetic energy"); REGISTER_FECORE_CLASS(FEPlotElementCenterOfMass, "element center of mass"); REGISTER_FECORE_CLASS(FEPlotElementLinearMomentum, "element linear momentum"); REGISTER_FECORE_CLASS(FEPlotElementAngularMomentum, "element angular momentum"); REGISTER_FECORE_CLASS(FEPlotElementStressPower, "element stress power"); REGISTER_FECORE_CLASS(FEPlotCurrentElementStrainEnergy, "current element strain energy"); REGISTER_FECORE_CLASS(FEPlotCurrentElementKineticEnergy, "current element kinetic energy"); REGISTER_FECORE_CLASS(FEPlotCurrentElementCenterOfMass, "current element center of mass"); REGISTER_FECORE_CLASS(FEPlotCurrentElementLinearMomentum, "current element linear momentum"); REGISTER_FECORE_CLASS(FEPlotCurrentElementAngularMomentum, "current element angular momentum"); REGISTER_FECORE_CLASS(FEPlotNodeDisplacement, "displacement"); REGISTER_FECORE_CLASS(FEPlotNodeIncrementalDisplacement, "incremental displacement"); REGISTER_FECORE_CLASS(FEPlotNodeRotation, "rotation"); REGISTER_FECORE_CLASS(FEPlotNodeShellDisplacement, "shell displacement"); REGISTER_FECORE_CLASS(FEPlotNodeVelocity, "nodal velocity"); REGISTER_FECORE_CLASS(FEPlotNodeAcceleration, "nodal acceleration"); REGISTER_FECORE_CLASS(FEPlotNodeReactionForces, "reaction forces"); REGISTER_FECORE_CLASS(FEPlotRigidReactionForce, "rigid force"); REGISTER_FECORE_CLASS(FEPlotRigidReactionTorque, "rigid torque"); REGISTER_FECORE_CLASS(FEPlotRigidDisplacement, "rigid position"); REGISTER_FECORE_CLASS(FEPlotRigidVelocity, "rigid velocity"); REGISTER_FECORE_CLASS(FEPlotRigidAcceleration, "rigid acceleration"); REGISTER_FECORE_CLASS(FEPlotRigidRotation, "rigid angular position"); REGISTER_FECORE_CLASS(FEPlotRigidAngularVelocity, "rigid angular velocity"); REGISTER_FECORE_CLASS(FEPlotRigidAngularAcceleration, "rigid angular acceleration"); REGISTER_FECORE_CLASS(FEPlotRigidLinearMomentum, "rigid linear momentum"); REGISTER_FECORE_CLASS(FEPlotRigidAngularMomentum, "rigid angular momentum"); REGISTER_FECORE_CLASS(FEPlotRigidKineticEnergy, "rigid kinetic energy"); REGISTER_FECORE_CLASS(FEPlotRigidEuler, "Euler angle"); REGISTER_FECORE_CLASS(FEPlotRigidRotationVector, "rigid rotation vector"); REGISTER_FECORE_CLASS(FEPlotScalarSurfaceLoad, "scalar surface load"); REGISTER_FECORE_CLASS(FEPlotNetSurfaceReactionForce, "surface reaction force"); REGISTER_FECORE_CLASS(FEPlotNetSurfaceReactionMoment, "surface reaction moment"); REGISTER_FECORE_CLASS(FEPlotStressError, "stress error"); REGISTER_FECORE_CLASS(FEPlotFiberTargetStretch, "in-situ target stretch"); REGISTER_FECORE_CLASS(FEPlotPreStrainStretch, "prestrain stretch"); REGISTER_FECORE_CLASS(FEPlotPreStrainStretchError, "prestrain stretch error"); REGISTER_FECORE_CLASS(FEPlotPreStrainCorrection, "prestrain correction"); REGISTER_FECORE_CLASS(FEPlotSPRPreStrainCorrection, "SPR prestrain correction"); REGISTER_FECORE_CLASS(FEPlotPreStrainCompatibility, "prestrain compatibility"); REGISTER_FECORE_CLASS(FEPlotDiscreteElementStretch, "discrete element stretch"); REGISTER_FECORE_CLASS(FEPlotDiscreteElementElongation, "discrete element elongation"); REGISTER_FECORE_CLASS(FEPlotDiscreteElementPercentElongation, "discrete element percent elongation"); REGISTER_FECORE_CLASS(FEPlotDiscreteElementDirection, "discrete element direction"); REGISTER_FECORE_CLASS(FEPlotDiscreteElementLength, "discrete element length"); REGISTER_FECORE_CLASS(FEPlotDiscreteElementForce, "discrete element force"); REGISTER_FECORE_CLASS(FEPlotDiscreteElementSignedForce, "discrete element signed force"); REGISTER_FECORE_CLASS(FEPlotDiscreteElementStrainEnergy, "discrete element strain energy"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_D , "continuous damage"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_D1 , "continuous damage D1"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_Ds , "continuous damage Ds"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_D2 , "continuous damage D2"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_D3 , "continuous damage D3"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_P , "continuous damage P"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_Psi0 , "continuous damage Psi0"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_beta , "continuous damage beta"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_gamma, "continuous damage gamma"); REGISTER_FECORE_CLASS(FEPlotContinuousDamage_D2beta, "continuous damage D2beta"); REGISTER_FECORE_CLASS(FEPlotRVEgenerations, "RVE generations"); REGISTER_FECORE_CLASS(FEPlotRVEbonds, "RVE reforming bonds"); REGISTER_FECORE_CLASS(FEPlotRVErecruitment, "RVE recruitment"); REGISTER_FECORE_CLASS(FEPlotRVEstrain, "RVE strain"); REGISTER_FECORE_CLASS(FEPlotStrongBondSED, "strong bond SED"); REGISTER_FECORE_CLASS(FEPlotWeakBondSED, "weak bond SED"); REGISTER_FECORE_CLASS(FEPlotStrongBondDevSED, "deviatoric strong bond SED"); REGISTER_FECORE_CLASS(FEPlotWeakBondDevSED, "deviatoric weak bond SED"); REGISTER_FECORE_CLASS(FEPlotTrussStretch , "truss stretch"); REGISTER_FECORE_CLASS(FEPlotGrowthLagrangeStrain, "growth Lagrange strain"); REGISTER_FECORE_CLASS(FEPlotGrowthInfStrain, "growth infinitesimal strain"); REGISTER_FECORE_CLASS(FEPlotGrowthRightStretch, "growth right stretch"); REGISTER_FECORE_CLASS(FEPlotGrowthLeftStretch, "growth left stretch"); REGISTER_FECORE_CLASS(FEPlotGrowthRightHencky, "growth right Hencky"); REGISTER_FECORE_CLASS(FEPlotGrowthLeftHencky, "growth left Hencky"); REGISTER_FECORE_CLASS(FEPlotGrowthRelativeVolume, "growth relative volume"); REGISTER_FECORE_CLASS(FEPlotIdealGasPressure, "ideal gas pressure"); REGISTER_FECORE_CLASS(FEPlotBodyForce, "body force"); REGISTER_FECORE_CLASS(FEPlotTotalLinearMomentum, "total linear momentum"); REGISTER_FECORE_CLASS(FEPlotTotalAngularMomentum, "total angular momentum"); REGISTER_FECORE_CLASS(FEPlotTotalEnergy, "total energy"); // beam variables REGISTER_FECORE_CLASS(FEPlotBeamStress , "beam stress"); REGISTER_FECORE_CLASS(FEPlotBeamStressCouple, "beam stress couple"); REGISTER_FECORE_CLASS(FEPlotBeamStrain , "beam strain"); REGISTER_FECORE_CLASS(FEPlotBeamCurvature , "beam curvature"); REGISTER_FECORE_CLASS(FEPlotBeamReferenceStress , "beam reference stress"); REGISTER_FECORE_CLASS(FEPlotBeamReferenceStressCouple, "beam reference stress couple"); REGISTER_FECORE_CLASS(FEPlotEdgeContactGap, "edge contact gap"); // 2O continuum fields REGISTER_FECORE_CLASS(FEPlotElementsnorm, "s norm"); //----------------------------------------------------------------------------- // Derived from FELogNodeData REGISTER_FECORE_CLASS(FENodeXPos, "x"); REGISTER_FECORE_CLASS(FENodeYPos, "y"); REGISTER_FECORE_CLASS(FENodeZPos, "z"); REGISTER_FECORE_CLASS(FENodeXDisp, "ux"); REGISTER_FECORE_CLASS(FENodeYDisp, "uy"); REGISTER_FECORE_CLASS(FENodeZDisp, "uz"); REGISTER_FECORE_CLASS(FENodeXVel, "vx"); REGISTER_FECORE_CLASS(FENodeYVel, "vy"); REGISTER_FECORE_CLASS(FENodeZVel, "vz"); REGISTER_FECORE_CLASS(FENodeXAcc, "ax"); REGISTER_FECORE_CLASS(FENodeYAcc, "ay"); REGISTER_FECORE_CLASS(FENodeZAcc, "az"); REGISTER_FECORE_CLASS(FENodeForceX, "Rx"); REGISTER_FECORE_CLASS(FENodeForceY, "Ry"); REGISTER_FECORE_CLASS(FENodeForceZ, "Rz"); //----------------------------------------------------------------------------- // Derived from FELogFaceData REGISTER_FECORE_CLASS(FELogContactGap , "contact gap"); REGISTER_FECORE_CLASS(FELogContactPressure, "contact pressure"); REGISTER_FECORE_CLASS(FELogContactTractionX, "contact_traction.x"); REGISTER_FECORE_CLASS(FELogContactTractionY, "contact_traction.y"); REGISTER_FECORE_CLASS(FELogContactTractionZ, "contact_traction.z"); //----------------------------------------------------------------------------- // Derived from FELogElemData REGISTER_FECORE_CLASS(FELogElemPosX, "x"); REGISTER_FECORE_CLASS(FELogElemPosY, "y"); REGISTER_FECORE_CLASS(FELogElemPosZ, "z"); REGISTER_FECORE_CLASS(FELogElemJacobian, "J"); REGISTER_FECORE_CLASS(FELogElemStrainX, "Ex"); REGISTER_FECORE_CLASS(FELogElemStrainY, "Ey"); REGISTER_FECORE_CLASS(FELogElemStrainZ, "Ez"); REGISTER_FECORE_CLASS(FELogElemStrainXY, "Exy"); REGISTER_FECORE_CLASS(FELogElemStrainYZ, "Eyz"); REGISTER_FECORE_CLASS(FELogElemStrainXZ, "Exz"); REGISTER_FECORE_CLASS(FELogElemStrainEffective, "effective strain"); REGISTER_FECORE_CLASS(FELogElemStrain1, "E1"); REGISTER_FECORE_CLASS(FELogElemStrain2, "E2"); REGISTER_FECORE_CLASS(FELogElemStrain3, "E3"); REGISTER_FECORE_CLASS(FELogElemInfStrainX, "ex"); REGISTER_FECORE_CLASS(FELogElemInfStrainY, "ey"); REGISTER_FECORE_CLASS(FELogElemInfStrainZ, "ez"); REGISTER_FECORE_CLASS(FELogElemInfStrainXY, "exy"); REGISTER_FECORE_CLASS(FELogElemInfStrainYZ, "eyz"); REGISTER_FECORE_CLASS(FELogElemInfStrainXZ, "exz"); REGISTER_FECORE_CLASS(FELogElemRightStretchX, "Ux"); REGISTER_FECORE_CLASS(FELogElemRightStretchY, "Uy"); REGISTER_FECORE_CLASS(FELogElemRightStretchZ, "Uz"); REGISTER_FECORE_CLASS(FELogElemRightStretchXY, "Uxy"); REGISTER_FECORE_CLASS(FELogElemRightStretchYZ, "Uyz"); REGISTER_FECORE_CLASS(FELogElemRightStretchXZ, "Uxz"); REGISTER_FECORE_CLASS(FELogElemRightStretchEffective, "effective right stretch"); REGISTER_FECORE_CLASS(FELogElemRightStretch1, "U1"); REGISTER_FECORE_CLASS(FELogElemRightStretch2, "U2"); REGISTER_FECORE_CLASS(FELogElemRightStretch3, "U3"); REGISTER_FECORE_CLASS(FELogElemLeftStretchX, "Vx"); REGISTER_FECORE_CLASS(FELogElemLeftStretchY, "Vy"); REGISTER_FECORE_CLASS(FELogElemLeftStretchZ, "Vz"); REGISTER_FECORE_CLASS(FELogElemLeftStretchXY, "Vxy"); REGISTER_FECORE_CLASS(FELogElemLeftStretchYZ, "Vyz"); REGISTER_FECORE_CLASS(FELogElemLeftStretchXZ, "Vxz"); REGISTER_FECORE_CLASS(FELogElemLeftStretchEffective, "effective left stretch"); REGISTER_FECORE_CLASS(FELogElemLeftStretch1, "V1"); REGISTER_FECORE_CLASS(FELogElemLeftStretch2, "V2"); REGISTER_FECORE_CLASS(FELogElemLeftStretch3, "V3"); REGISTER_FECORE_CLASS(FELogElemRightHenckyX, "Hx"); REGISTER_FECORE_CLASS(FELogElemRightHenckyY, "Hy"); REGISTER_FECORE_CLASS(FELogElemRightHenckyZ, "Hz"); REGISTER_FECORE_CLASS(FELogElemRightHenckyXY, "Hxy"); REGISTER_FECORE_CLASS(FELogElemRightHenckyYZ, "Hyz"); REGISTER_FECORE_CLASS(FELogElemRightHenckyXZ, "Hxz"); REGISTER_FECORE_CLASS(FELogElemRightHenckyEffective, "effective right Hencky"); REGISTER_FECORE_CLASS(FELogElemRightHencky1, "H1"); REGISTER_FECORE_CLASS(FELogElemRightHencky2, "H2"); REGISTER_FECORE_CLASS(FELogElemRightHencky3, "H3"); REGISTER_FECORE_CLASS(FELogElemLeftHenckyX, "hx"); REGISTER_FECORE_CLASS(FELogElemLeftHenckyY, "hy"); REGISTER_FECORE_CLASS(FELogElemLeftHenckyZ, "hz"); REGISTER_FECORE_CLASS(FELogElemLeftHenckyXY, "hxy"); REGISTER_FECORE_CLASS(FELogElemLeftHenckyYZ, "hyz"); REGISTER_FECORE_CLASS(FELogElemLeftHenckyXZ, "hxz"); REGISTER_FECORE_CLASS(FELogElemLeftHenckyEffective, "effective left Hencky"); REGISTER_FECORE_CLASS(FELogElemLeftHencky1, "h1"); REGISTER_FECORE_CLASS(FELogElemLeftHencky2, "h2"); REGISTER_FECORE_CLASS(FELogElemLeftHencky3, "h3"); REGISTER_FECORE_CLASS(FELogElemStressX, "sx"); REGISTER_FECORE_CLASS(FELogElemStressY, "sy"); REGISTER_FECORE_CLASS(FELogElemStressZ, "sz"); REGISTER_FECORE_CLASS(FELogElemStressXY, "sxy"); REGISTER_FECORE_CLASS(FELogElemStressYZ, "syz"); REGISTER_FECORE_CLASS(FELogElemStressXZ, "sxz"); REGISTER_FECORE_CLASS(FELogElemStressEffective, "effective stress"); REGISTER_FECORE_CLASS(FELogElemStress1, "s1"); REGISTER_FECORE_CLASS(FELogElemStress2, "s2"); REGISTER_FECORE_CLASS(FELogElemStress3, "s3"); REGISTER_FECORE_CLASS(FELogElemPK2StressX , "Sx"); REGISTER_FECORE_CLASS(FELogElemPK2StressY , "Sy"); REGISTER_FECORE_CLASS(FELogElemPK2StressZ , "Sz"); REGISTER_FECORE_CLASS(FELogElemPK2StressXY, "Sxy"); REGISTER_FECORE_CLASS(FELogElemPK2StressYZ, "Syz"); REGISTER_FECORE_CLASS(FELogElemPK2StressXZ, "Sxz"); REGISTER_FECORE_CLASS(FELogElemPK1StressXX, "Pxx"); REGISTER_FECORE_CLASS(FELogElemPK1StressYY, "Pyy"); REGISTER_FECORE_CLASS(FELogElemPK1StressZZ, "Pzz"); REGISTER_FECORE_CLASS(FELogElemPK1StressXY, "Pxy"); REGISTER_FECORE_CLASS(FELogElemPK1StressYZ, "Pyz"); REGISTER_FECORE_CLASS(FELogElemPK1StressZX, "Pzx"); REGISTER_FECORE_CLASS(FELogElemPK1StressZY, "Pzy"); REGISTER_FECORE_CLASS(FELogElemPK1StressXZ, "Pxz"); REGISTER_FECORE_CLASS(FELogElemPK1StressYX, "Pyx"); REGISTER_FECORE_CLASS_T2(FELogElemStressEigenVector_T, 0, 0, "s1x"); REGISTER_FECORE_CLASS_T2(FELogElemStressEigenVector_T, 0, 1, "s1y"); REGISTER_FECORE_CLASS_T2(FELogElemStressEigenVector_T, 0, 2, "s1z"); REGISTER_FECORE_CLASS_T2(FELogElemStressEigenVector_T, 1, 0, "s2x"); REGISTER_FECORE_CLASS_T2(FELogElemStressEigenVector_T, 1, 1, "s2y"); REGISTER_FECORE_CLASS_T2(FELogElemStressEigenVector_T, 1, 2, "s2z"); REGISTER_FECORE_CLASS_T2(FELogElemStressEigenVector_T, 2, 0, "s3x"); REGISTER_FECORE_CLASS_T2(FELogElemStressEigenVector_T, 2, 1, "s3y"); REGISTER_FECORE_CLASS_T2(FELogElemStressEigenVector_T, 2, 2, "s3z"); REGISTER_FECORE_CLASS(FELogElemDeformationGradientXX, "Fxx"); REGISTER_FECORE_CLASS(FELogElemDeformationGradientXY, "Fxy"); REGISTER_FECORE_CLASS(FELogElemDeformationGradientXZ, "Fxz"); REGISTER_FECORE_CLASS(FELogElemDeformationGradientYX, "Fyx"); REGISTER_FECORE_CLASS(FELogElemDeformationGradientYY, "Fyy"); REGISTER_FECORE_CLASS(FELogElemDeformationGradientYZ, "Fyz"); REGISTER_FECORE_CLASS(FELogElemDeformationGradientZX, "Fzx"); REGISTER_FECORE_CLASS(FELogElemDeformationGradientZY, "Fzy"); REGISTER_FECORE_CLASS(FELogElemDeformationGradientZZ, "Fzz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 0, "cxxxx"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 1, "cxxyy"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 2, "cyyyy"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 3, "cxxzz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 4, "cyyzz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 5, "czzzz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 6, "cxxxy"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 7, "cyyxy"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 8, "czzxy"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 9, "cxyxy"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 10, "cxxyz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 11, "cyyyz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 12, "czzyz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 13, "cxyyz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 14, "cyzyz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 15, "cxxxz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 16, "cyyxz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 17, "czzxz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 18, "cxyxz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 19, "cyzxz"); REGISTER_FECORE_CLASS_T(FELogElemElasticity, 20, "cxzxz"); REGISTER_FECORE_CLASS(FELogElemStrainEnergyDensity, "sed"); REGISTER_FECORE_CLASS(FELogElemDevStrainEnergyDensity, "devsed"); REGISTER_FECORE_CLASS(FELogElemFiberStretch, "fiber_stretch"); REGISTER_FECORE_CLASS_T(FELogElemFiberVector_N, 0, "fiber_x"); REGISTER_FECORE_CLASS_T(FELogElemFiberVector_N, 1, "fiber_y"); REGISTER_FECORE_CLASS_T(FELogElemFiberVector_N, 2, "fiber_z"); REGISTER_FECORE_CLASS(FELogDamage, "D"); REGISTER_FECORE_CLASS_T(FELogDamage_n, 0, "damage_1"); REGISTER_FECORE_CLASS_T(FELogDamage_n, 1, "damage_2"); REGISTER_FECORE_CLASS_T(FELogDamage_n, 2, "damage_3"); REGISTER_FECORE_CLASS_T(FELogDamage_n, 3, "damage_4"); REGISTER_FECORE_CLASS_T(FELogDamage_n, 4, "damage_5"); REGISTER_FECORE_CLASS_T(FELogDamage_n, 5, "damage_6"); REGISTER_FECORE_CLASS_T(FELogDamage_n, 6, "damage_7"); REGISTER_FECORE_CLASS_T(FELogDamage_n, 7, "damage_8"); REGISTER_FECORE_CLASS(FELogIntactBonds, "wi"); REGISTER_FECORE_CLASS(FELogYieldedBonds, "wy"); REGISTER_FECORE_CLASS(FELogFatigueBonds, "wf"); REGISTER_FECORE_CLASS(FELogOctahedralPlasticStrain, "ops"); REGISTER_FECORE_CLASS(FELogDiscreteElementStretch , "discrete element stretch"); REGISTER_FECORE_CLASS(FELogDiscreteElementElongation, "discrete element elongation"); REGISTER_FECORE_CLASS(FELogDiscreteElementForce , "discrete element force" ); REGISTER_FECORE_CLASS(FELogDiscreteElementForceX , "Fde.x"); REGISTER_FECORE_CLASS(FELogDiscreteElementForceY , "Fde.y"); REGISTER_FECORE_CLASS(FELogDiscreteElementForceZ , "Fde.z"); REGISTER_FECORE_CLASS(FELogContactArea, "contact area"); REGISTER_FECORE_CLASS(FELogMaxContactGap, "max contact gap"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 0, 0, "mixture_stress[0].xx"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 0, 1, "mixture_stress[0].xy"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 0, 2, "mixture_stress[0].yy"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 0, 3, "mixture_stress[0].xz"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 0, 4, "mixture_stress[0].yz"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 0, 5, "mixture_stress[0].zz"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 1, 0, "mixture_stress[1].xx"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 1, 1, "mixture_stress[1].xy"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 1, 2, "mixture_stress[1].yy"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 1, 3, "mixture_stress[1].xz"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 1, 4, "mixture_stress[1].yz"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 1, 5, "mixture_stress[1].zz"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 2, 0, "mixture_stress[2].xx"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 2, 1, "mixture_stress[2].xy"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 2, 2, "mixture_stress[2].yy"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 2, 3, "mixture_stress[2].xz"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 2, 4, "mixture_stress[2].yz"); REGISTER_FECORE_CLASS_T2(FELogElementMixtureStress_T, 2, 5, "mixture_stress[2].zz"); REGISTER_FECORE_CLASS_T2(FELogTotalDeformationGradient_T, 0, 0, "Ft_xx"); REGISTER_FECORE_CLASS_T2(FELogTotalDeformationGradient_T, 0, 1, "Ft_xy"); REGISTER_FECORE_CLASS_T2(FELogTotalDeformationGradient_T, 0, 2, "Ft_xz"); REGISTER_FECORE_CLASS_T2(FELogTotalDeformationGradient_T, 1, 0, "Ft_yx"); REGISTER_FECORE_CLASS_T2(FELogTotalDeformationGradient_T, 1, 1, "Ft_yy"); REGISTER_FECORE_CLASS_T2(FELogTotalDeformationGradient_T, 1, 2, "Ft_yz"); REGISTER_FECORE_CLASS_T2(FELogTotalDeformationGradient_T, 2, 0, "Ft_zx"); REGISTER_FECORE_CLASS_T2(FELogTotalDeformationGradient_T, 2, 1, "Ft_zy"); REGISTER_FECORE_CLASS_T2(FELogTotalDeformationGradient_T, 2, 2, "Ft_zz"); // derived from FELogDomainData REGISTER_FECORE_CLASS(FENormalizedInternalEnergy, "normalized internal energy"); REGISTER_FECORE_CLASS(FELogTotalEnergy, "total energy"); //----------------------------------------------------------------------------- // Derived from FELogObjectData REGISTER_FECORE_CLASS(FELogRigidBodyPosX, "x"); REGISTER_FECORE_CLASS(FELogRigidBodyPosY, "y"); REGISTER_FECORE_CLASS(FELogRigidBodyPosZ, "z"); REGISTER_FECORE_CLASS(FELogRigidBodyVelX, "vx"); REGISTER_FECORE_CLASS(FELogRigidBodyVelY, "vy"); REGISTER_FECORE_CLASS(FELogRigidBodyVelZ, "vz"); REGISTER_FECORE_CLASS(FELogRigidBodyAccX, "ax"); REGISTER_FECORE_CLASS(FELogRigidBodyAccY, "ay"); REGISTER_FECORE_CLASS(FELogRigidBodyAccZ, "az"); REGISTER_FECORE_CLASS(FELogRigidBodyAngPosX, "thx"); REGISTER_FECORE_CLASS(FELogRigidBodyAngPosY, "thy"); REGISTER_FECORE_CLASS(FELogRigidBodyAngPosZ, "thz"); REGISTER_FECORE_CLASS(FELogRigidBodyAngVelX, "omx"); REGISTER_FECORE_CLASS(FELogRigidBodyAngVelY, "omy"); REGISTER_FECORE_CLASS(FELogRigidBodyAngVelZ, "omz"); REGISTER_FECORE_CLASS(FELogRigidBodyAngAccX, "alx"); REGISTER_FECORE_CLASS(FELogRigidBodyAngAccY, "aly"); REGISTER_FECORE_CLASS(FELogRigidBodyAngAccZ, "alz"); REGISTER_FECORE_CLASS(FELogRigidBodyQuatX, "qx"); REGISTER_FECORE_CLASS(FELogRigidBodyQuatY, "qy"); REGISTER_FECORE_CLASS(FELogRigidBodyQuatZ, "qz"); REGISTER_FECORE_CLASS(FELogRigidBodyQuatW, "qw"); REGISTER_FECORE_CLASS(FELogRigidBodyR11, "R11"); REGISTER_FECORE_CLASS(FELogRigidBodyR12, "R12"); REGISTER_FECORE_CLASS(FELogRigidBodyR13, "R13"); REGISTER_FECORE_CLASS(FELogRigidBodyR21, "R21"); REGISTER_FECORE_CLASS(FELogRigidBodyR22, "R22"); REGISTER_FECORE_CLASS(FELogRigidBodyR23, "R23"); REGISTER_FECORE_CLASS(FELogRigidBodyR31, "R31"); REGISTER_FECORE_CLASS(FELogRigidBodyR32, "R32"); REGISTER_FECORE_CLASS(FELogRigidBodyR33, "R33"); REGISTER_FECORE_CLASS(FELogRigidBodyEulerX, "EulerX"); REGISTER_FECORE_CLASS(FELogRigidBodyEulerY, "EulerY"); REGISTER_FECORE_CLASS(FELogRigidBodyEulerZ, "EulerZ"); REGISTER_FECORE_CLASS(FELogRigidBodyForceX, "Fx"); REGISTER_FECORE_CLASS(FELogRigidBodyForceY, "Fy"); REGISTER_FECORE_CLASS(FELogRigidBodyForceZ, "Fz"); REGISTER_FECORE_CLASS(FELogRigidBodyTorqueX, "Mx"); REGISTER_FECORE_CLASS(FELogRigidBodyTorqueY, "My"); REGISTER_FECORE_CLASS(FELogRigidBodyTorqueZ, "Mz"); REGISTER_FECORE_CLASS(FELogRigidBodyKineticEnergy, "KE"); REGISTER_FECORE_CLASS(FELogRigidBodyIHAwx, "IHAwx"); REGISTER_FECORE_CLASS(FELogRigidBodyIHAwy, "IHAwy"); REGISTER_FECORE_CLASS(FELogRigidBodyIHAwz, "IHAwz"); REGISTER_FECORE_CLASS(FELogRigidBodyIHAwm, "IHAwm"); REGISTER_FECORE_CLASS(FELogRigidBodyIHAsx, "IHAsx"); REGISTER_FECORE_CLASS(FELogRigidBodyIHAsy, "IHAsy"); REGISTER_FECORE_CLASS(FELogRigidBodyIHAsz, "IHAsz"); REGISTER_FECORE_CLASS(FELogRigidBodyIHAtd, "IHAtd"); REGISTER_FECORE_CLASS(FELogRigidBodyFHAwx, "FHAwx"); REGISTER_FECORE_CLASS(FELogRigidBodyFHAwy, "FHAwy"); REGISTER_FECORE_CLASS(FELogRigidBodyFHAwz, "FHAwz"); REGISTER_FECORE_CLASS(FELogRigidBodyFHAwm, "FHAwm"); REGISTER_FECORE_CLASS(FELogRigidBodyFHAsx, "FHAsx"); REGISTER_FECORE_CLASS(FELogRigidBodyFHAsy, "FHAsy"); REGISTER_FECORE_CLASS(FELogRigidBodyFHAsz, "FHAsz"); REGISTER_FECORE_CLASS(FELogRigidBodyFHAtd, "FHAtd"); REGISTER_FECORE_CLASS(FELogRigidConnectorIHAwx, "rcIHAwx"); REGISTER_FECORE_CLASS(FELogRigidConnectorIHAwy, "rcIHAwy"); REGISTER_FECORE_CLASS(FELogRigidConnectorIHAwz, "rcIHAwz"); REGISTER_FECORE_CLASS(FELogRigidConnectorIHAwm, "rcIHAwm"); REGISTER_FECORE_CLASS(FELogRigidConnectorIHAsx, "rcIHAsx"); REGISTER_FECORE_CLASS(FELogRigidConnectorIHAsy, "rcIHAsy"); REGISTER_FECORE_CLASS(FELogRigidConnectorIHAsz, "rcIHAsz"); REGISTER_FECORE_CLASS(FELogRigidConnectorIHAtd, "rcIHAtd"); REGISTER_FECORE_CLASS(FELogRigidConnectorFHAwx, "rcFHAwx"); REGISTER_FECORE_CLASS(FELogRigidConnectorFHAwy, "rcFHAwy"); REGISTER_FECORE_CLASS(FELogRigidConnectorFHAwz, "rcFHAwz"); REGISTER_FECORE_CLASS(FELogRigidConnectorFHAwm, "rcFHAwm"); REGISTER_FECORE_CLASS(FELogRigidConnectorFHAsx, "rcFHAsx"); REGISTER_FECORE_CLASS(FELogRigidConnectorFHAsy, "rcFHAsy"); REGISTER_FECORE_CLASS(FELogRigidConnectorFHAsz, "rcFHAsz"); REGISTER_FECORE_CLASS(FELogRigidConnectorFHAtd, "rcFHAtd"); //----------------------------------------------------------------------------- // Derived from FELogConnectorData REGISTER_FECORE_CLASS(FELogRigidConnectorForceX, "RCFx"); REGISTER_FECORE_CLASS(FELogRigidConnectorForceY, "RCFy"); REGISTER_FECORE_CLASS(FELogRigidConnectorForceZ, "RCFz"); REGISTER_FECORE_CLASS(FELogRigidConnectorMomentX, "RCMx"); REGISTER_FECORE_CLASS(FELogRigidConnectorMomentY, "RCMy"); REGISTER_FECORE_CLASS(FELogRigidConnectorMomentZ, "RCMz"); REGISTER_FECORE_CLASS(FELogRigidConnectorTranslationX, "RCx"); REGISTER_FECORE_CLASS(FELogRigidConnectorTranslationY, "RCy"); REGISTER_FECORE_CLASS(FELogRigidConnectorTranslationZ, "RCz"); REGISTER_FECORE_CLASS(FELogRigidConnectorRotationX, "RCthx"); REGISTER_FECORE_CLASS(FELogRigidConnectorRotationY, "RCthy"); REGISTER_FECORE_CLASS(FELogRigidConnectorRotationZ, "RCthz"); //----------------------------------------------------------------------------- // Derived from FELogNLConstraintData REGISTER_FECORE_CLASS(FELogVolumeConstraint, "constrained volume"); REGISTER_FECORE_CLASS(FELogVolumePressure, "volume pressure"); //----------------------------------------------------------------------------- // Derived from DataRecord REGISTER_FECORE_CLASS(ObjectDataRecord, "rigid_body_data"); //----------------------------------------------------------------------------- // Derived from FEMeshAdaptorCriterion REGISTER_FECORE_CLASS(FEStressCriterion, "stress"); REGISTER_FECORE_CLASS(FEDamageAdaptorCriterion, "damage"); REGISTER_FECORE_CLASS(FERelativeVolumeCriterion, "relative volume"); REGISTER_FECORE_CLASS(FESpringForceCriterion, "spring force"); REGISTER_FECORE_CLASS(FESpringStretchCriterion, "spring stretch"); REGISTER_FECORE_CLASS(FEContactGapCriterion, "contact gap"); //----------------------------------------------------------------------------- // Derived from FEElemDataGenerator REGISTER_FECORE_CLASS(FEDeformationMapGenerator, "defgrad"); febio.SetActiveModule(0); }
C++
3D
febiosoftware/FEBio
FEBioMech/FEHuiskesSupply.cpp
.cpp
5,602
148
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEHuiskesSupply.h" #include <FECore/FEModel.h> #include <FECore/log.h> //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FEHuiskesSupply, FESolidSupply) ADD_PARAMETER(m_B, "B"); ADD_PARAMETER(m_k, "k")->setUnits(UNIT_SPECIFIC_ENERGY); ADD_PARAMETER(m_D, FE_RANGE_GREATER_OR_EQUAL(0.0), "D")->setUnits(UNIT_LENGTH)->setLongName("sensor distance"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FEHuiskesSupply::FEHuiskesSupply(FEModel* pfem) : FESolidSupply(pfem) { m_B = m_k = m_D = 0; } //----------------------------------------------------------------------------- //! Initialization bool FEHuiskesSupply::Init() { // get neighboring elements for given proximity if (m_D > 0) { double mult = 4; //! multiplier of characteristic distance, such that exp(-mult) << 1 FEMesh& mesh = GetFEModel()->GetMesh(); if (m_topo.Create(&mesh) == false) { feLogError("Failed building mesh topo."); return false; } feLogInfo("Evaluating element proximity..."); m_EPL.assign(mesh.Elements(), std::vector<int>()); for (int i=0; i< mesh.Elements(); ++i) { std::vector<int> epl = m_topo.ElementProximityList(i, m_D*mult); m_EPL[i] = epl; } feLogInfo("Done."); } return true; } //----------------------------------------------------------------------------- //! Solid supply double FEHuiskesSupply::Supply(FEMaterialPoint& pt) { FERemodelingMaterialPoint* rpt = pt.ExtractData<FERemodelingMaterialPoint>(); double rhor = rpt->m_rhor; double sed = rpt->m_sed; double rhorhat = m_B*(sed/rhor - m_k); if (m_D > 0) { FEMesh& mesh = GetFEModel()->GetMesh(); int ie = pt.m_elem->GetLocalID(); int NEPL = (int)m_EPL[ie].size(); #pragma omp parallel for shared (NEPL) for (int i=0; i<NEPL; ++i) { int je = m_EPL[ie][i]; if (je > -1) { FEElement* el = mesh.Element(je); for (int k=0; k<el->GaussPoints(); ++k) { FEMaterialPoint& mp = *(el->GetMaterialPoint(k)); double d = (pt.m_rt - mp.m_rt).unit(); rpt = mp.ExtractData<FERemodelingMaterialPoint>(); FEElasticMaterialPoint& et = *mp.ExtractData<FEElasticMaterialPoint>(); rhorhat += exp(-d/m_D)*m_B*(rpt->m_sed/rpt->m_rhor - m_k); } } } } return rhorhat; } //----------------------------------------------------------------------------- //! Tangent of solid supply with respect to strain mat3ds FEHuiskesSupply::Tangent_Supply_Strain(FEMaterialPoint &pt) { FEElasticMaterialPoint& et = *pt.ExtractData<FEElasticMaterialPoint>(); FERemodelingMaterialPoint* rpt = pt.ExtractData<FERemodelingMaterialPoint>(); mat3ds ruhat = et.m_s*(m_B/rpt->m_rhor); if (m_D > 0) { FEMesh& mesh = GetFEModel()->GetMesh(); int ie = pt.m_elem->GetLocalID(); int NEPL = (int)m_EPL[ie].size(); #pragma omp parallel for shared (NEPL) for (int i=0; i<NEPL; ++i) { int je = m_EPL[ie][i]; if (je > -1) { FEElement* el = mesh.Element(je); for (int k=0; k<el->GaussPoints(); ++k) { FEMaterialPoint& mp = *(el->GetMaterialPoint(k)); double d = (pt.m_rt - mp.m_rt).unit(); rpt = mp.ExtractData<FERemodelingMaterialPoint>(); FEElasticMaterialPoint& et = *mp.ExtractData<FEElasticMaterialPoint>(); ruhat += et.m_s*(exp(-d/m_D)*m_B/rpt->m_rhor); } } } } return ruhat; } //----------------------------------------------------------------------------- //! Tangent of solid supply with respect to referential density double FEHuiskesSupply::Tangent_Supply_Density(FEMaterialPoint &mp) { FERemodelingMaterialPoint& rpt = *mp.ExtractData<FERemodelingMaterialPoint>(); double rhor = rpt.m_rhor; double sed = rpt.m_sed; double dsed = rpt.m_dsed; return (dsed - sed/rhor)*m_B/rhor; }
C++
3D
febiosoftware/FEBio
FEBioMech/FEExplicitSolidSolver.h
.h
3,461
124
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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/FESolver.h" #include "FECore/FEGlobalVector.h" #include <FECore/FETimeInfo.h> #include <FECore/FEDofList.h> #include "FERigidSolver.h" //----------------------------------------------------------------------------- //! This class implements a nonlinear explicit solver for solid mechanics //! problems. class FEExplicitSolidSolver : public FESolver { enum MassLumpingMethod { NO_MASS_LUMPING, // use consistent mass matrix ROW_SUM_LUMPING, // use simple row-sum lumping HRZ_LUMPING // use Hinton-Rock-Zienkiewicz lumping }; struct Data { double v = 0; // velocity double a = 0; // acceleration double mi = 0; // inverted mass }; public: //! constructor FEExplicitSolidSolver(FEModel* pfem); //! destructor virtual ~FEExplicitSolidSolver() {} public: //! Data initialization bool Init() override; //! clean up void Clean() override; //! Solve an analysis step bool SolveStep() override; //! Update data void Update(vector<double>& ui) override; //! Serialize data void Serialize(DumpStream& ar) override; //! initialize equations bool InitEquations() override; public: //! update kinematics void UpdateKinematics(vector<double>& ui); //! Update rigid bodies void UpdateRigidBodies(vector<double>& ui); //! solve the step bool DoSolve(); void PrepStep(); bool Residual(vector<double>& R); void NonLinearConstraintForces(FEGlobalVector& R, const FETimeInfo& tp); void ContactForces(FEGlobalVector& R); private: bool CalculateMassMatrix(); public: int m_mass_lumping; //!< specify mass lumping method double m_dyn_damping; //!< velocity damping for the explicit solver public: // equation numbers int m_nreq; //!< start of rigid body equations vector<Data> m_data; vector<double> m_ui; //!< residual loads vector<double> m_Ut; //!< Total dispalcement vector at time t (incl all previous timesteps) vector<double> m_Rt; //!< residual loads vector<double> m_Fr; //!< nodal reaction forces protected: FEDofList m_dofU, m_dofV, m_dofQ, m_dofRQ; FEDofList m_dofSU, m_dofSV, m_dofSA; FERigidSolverNew m_rigidSolver; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FESolidDomainFactory.h
.h
1,561
38
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FECore/FECoreKernel.h" //----------------------------------------------------------------------------- class FESolidDomainFactory : public FEDomainFactory { public: virtual FEDomain* CreateDomain(const FE_Element_Spec& spec, FEMesh* pm, FEMaterial* pmat); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEGenericHyperelastic.cpp
.cpp
6,063
205
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 "FEGenericHyperelastic.h" #include <FECore/MMath.h> #include <FECore/MObj2String.h> #include <FECore/log.h> BEGIN_FECORE_CLASS(FEGenericHyperelastic, FEElasticMaterial) ADD_PARAMETER(m_exp, "W")->setUnits(UNIT_ENERGY); END_FECORE_CLASS(); FEGenericHyperelastic::FEGenericHyperelastic(FEModel* fem) : FEElasticMaterial(fem) { } bool FEGenericHyperelastic::Init() { if (BuildMathExpressions() == false) return false; return FEElasticMaterial::Init(); } bool FEGenericHyperelastic::BuildMathExpressions() { vector<string> vars = { "I1", "I2", "J", "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()); } } // create math object m_W.AddVariables(vars); if (m_W.Create(m_exp) == false) return false; // calculate all derivatives MITEM W1 = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(0), 1)); MITEM W2 = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(1), 1)); MITEM WJ = MSimplify(MDerive(m_W.GetExpression(), *m_W.Variable(2), 1)); m_W1.AddVariables(vars); m_W1.SetExpression(W1); m_W2.AddVariables(vars); m_W2.SetExpression(W2); m_WJ.AddVariables(vars); m_WJ.SetExpression(WJ); 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); MITEM WJJ = MDerive(m_WJ.GetExpression(), *m_WJ.Variable(2), 1); m_WJJ.AddVariables(vars); m_WJJ.SetExpression(WJJ); #ifndef NDEBUG MObj2String o2s; 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 sWJ = o2s.Convert(m_WJ); feLog("WJ = %s\n", sWJ.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()); string sWJJ = o2s.Convert(m_WJJ); feLog("WJJ = %s\n", sWJJ.c_str()); #endif return true; } // serialization void FEGenericHyperelastic::Serialize(DumpStream& ar) { FEElasticMaterial::Serialize(ar); if ((ar.IsShallow() == false) && ar.IsLoading()) { bool b = BuildMathExpressions(); assert(b); } } mat3ds FEGenericHyperelastic::Stress(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); mat3d& F = pt.m_F; double J = pt.m_J; mat3ds B = pt.LeftCauchyGreen(); mat3ds B2 = B.sqr(); double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); vector<double> v = { I1, I2, J, 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 WJ = m_WJ.value_s(v); mat3dd I(1.0); mat3ds s = (B*(W1 + W2*I1) - B2*W2)*(2.0/J) + WJ*I; return s; } tens4ds FEGenericHyperelastic::Tangent(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); mat3d& F = pt.m_F; double J = pt.m_J; mat3ds B = pt.LeftCauchyGreen(); mat3ds B2 = B.sqr(); double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); vector<double> v = { I1, I2, J, 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 WJ = m_WJ.value_s(v); double W11 = m_W11.value_s(v); double W22 = m_W22.value_s(v); double W12 = m_W12.value_s(v); double WJJ = m_WJJ.value_s(v); mat3dd I(1.0); tens4ds IxI = dyad1s(I); tens4ds BxB = dyad1s(B); tens4ds B2xB2 = dyad1s(B2); tens4ds BoB2 = dyad1s(B, B2); tens4ds Ib = dyad4s(B); tens4ds I4 = dyad4s(I); tens4ds cw = BxB*(W11 + 2*W12*I1 + W22*I1*I1 + W2) - BoB2*(W12 + W22*I1) + B2xB2*W22 - Ib*W2; tens4ds cp = IxI*(WJJ*J + WJ) - I4*(2 * WJ); tens4ds c = cp + cw*(4.0 / J); return c; } double FEGenericHyperelastic::StrainEnergyDensity(FEMaterialPoint& mp) { FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>(); mat3d& F = pt.m_F; double J = pt.m_J; mat3ds B = pt.LeftCauchyGreen(); mat3ds B2 = B.sqr(); double I1 = B.tr(); double I2 = 0.5*(I1*I1 - B2.tr()); vector<double> v = { I1, I2, J, 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/FEEdgeToSurfaceSlidingContact.cpp
.cpp
21,877
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 "FEEdgeToSurfaceSlidingContact.h" #include <FECore/FENode.h> #include <FECore/FEGlobalMatrix.h> #include <FECore/FELinearSystem.h> #include <FECore/FEBox.h> #include <FECore/FEModel.h> #include <FECore/FEAnalysis.h> #include <FECore/FEClosestPointProjection.h> #include <FECore/FEGlobalMatrix.h> #include <stdexcept> void FEEdgeToSurfaceSlidingContactSurface::Update() { for (int i = 0; i < Elements(); ++i) { FESurfaceElement& el = Element(i); vec3d re[FEElement::MAX_NODES]; GetNodalCoordinates(el, re); for (int n = 0; n < el.GaussPoints(); ++n) { FESurfaceMaterialPoint& mp = static_cast<FESurfaceMaterialPoint&>(*el.GetMaterialPoint(n)); mp.m_rt = el.eval(re, n); // kinematics at integration points mp.dxr = el.eval_deriv1(re, n); mp.dxs = el.eval_deriv2(re, n); mp.m_Jt = (mp.dxr ^ mp.dxs).norm(); } } } FEEdgeToSurfaceSlidingContactSurface::FEEdgeToSurfaceSlidingContactSurface(FEModel* fem) : FEContactSurface(fem) { } //================================================================================================= FEEdgeToSurfaceSlidingContactEdge::FEEdgeToSurfaceSlidingContactEdge(FEModel* fem) : FEEdge(fem) { } bool FEEdgeToSurfaceSlidingContactEdge::Init() { if (!FEEdge::Init()) return false; DOFS& dofs = GetFEModel()->GetDOFS(); m_dofX = dofs.GetDOF("x"); m_dofY = dofs.GetDOF("y"); m_dofZ = dofs.GetDOF("z"); m_points.resize(Nodes()); return true; } void FEEdgeToSurfaceSlidingContactEdge::UnpackLM(FELineElement& 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]; } } FEMaterialPoint* FEEdgeToSurfaceSlidingContactEdge::CreateMaterialPoint() { return new FEE2SSlidingContactPoint(); } bool FEEdgeToSurfaceSlidingContactEdge::Create(FESegmentSet& eset) { return FEEdge::Create(eset, FE_LINE2NI); } void FEEdgeToSurfaceSlidingContactEdge::Update() { for (int i = 0; i < Elements(); ++i) { FELineElement& el = Element(i); vec3d rt[FEElement::MAX_NODES]; GetNodalCoordinates(el, rt); // Jacobian is length in spatial coordinates divided by length in parametric coordinates (=2) double J = (rt[1] - rt[0]).Length() / 2.0; for (int n = 0; n < el.GaussPoints(); ++n) { FEE2SSlidingContactPoint& mp = static_cast<FEE2SSlidingContactPoint&>(*el.GetMaterialPoint(n)); mp.m_rt = el.eval(rt, n); mp.m_Jt = J; } } } void FEEdgeToSurfaceSlidingContactEdge::Serialize(DumpStream& ar) { FEEdge::Serialize(ar); ar.LockPointerTable(); for (int i = 0; i < m_points.size(); ++i) { ar & m_points[i]; } ar.UnlockPointerTable(); } //================================================================================================= BEGIN_FECORE_CLASS(FEEdgeToSurfaceSlidingContact, FESurfaceConstraint) 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_tol" ); ADD_PARAMETER(m_nsegup , "seg_up" ); ADD_PARAMETER(m_sradius , "search_radius"); ADD_PROPERTY(m_edge, "edgelist")->AddFlag(FEProperty::Reference); END_FECORE_CLASS(); FEEdgeToSurfaceSlidingContact::FEEdgeToSurfaceSlidingContact(FEModel* fem) : FESurfaceConstraint(fem), m_edge(fem), m_surf(fem) { m_atol = 0.1; m_eps = 1.0; m_naugmin = 0; m_naugmax = 0; m_stol = 0.01; m_nsegup = 0; m_sradius = 0; m_bfirst = true; } FESurface* FEEdgeToSurfaceSlidingContact::GetSurface() { return &m_surf; } // initialization bool FEEdgeToSurfaceSlidingContact::Init() { if (FESurfaceConstraint::Init() == false) return false; m_bfirst = true; if (m_edge.Init() == false) return false; if (m_surf.Init() == false) return false; return true; } //! Projects the primary surface onto the secondary surface. //! That is, for each primary surface node we determine the closest //! secondary surface element and the projection of that node onto //! this element. //! \todo this function needs to identify the different types of contact: //! 1/ first contact //! 2/ crossing of element boundary //! 3/ contact termination //! either by failure to find projection or when g < tolerance void FEEdgeToSurfaceSlidingContact::ProjectSurface(bool bupseg, bool bmove) { FEClosestPointProjection cpp(m_surf); cpp.SetTolerance(m_stol); cpp.SetSearchRadius(m_sradius); cpp.HandleSpecialCases(true); cpp.Init(); for (int i = 0; i < m_edge.Nodes(); ++i) { // get the node FENode& node = m_edge.Node(i); // get the nodal position vec3d x = node.m_rt; // get the global node number int m = m_edge.NodeIndex(i); FEE2SSlidingContactPoint& cp = m_edge.m_points[i]; // get the previous secondary surface element (if any) FESurfaceElement* pme = cp.m_pme; // If the node is in contact, let's see if the node still is // on the same element vec3d q; if (pme != 0) { FESurfaceElement& mel = *pme; double r = cp.m_rs[0]; double s = cp.m_rs[1]; q = m_surf.ProjectToSurface(mel, x, r, s); cp.m_rs[1] = s; cp.m_rs[0] = r; // we only check when we can update the segments // otherwise, we just stick with this element, even // if the node is no longer inside it. if (bupseg) { if (!m_surf.IsInsideElement(mel, r, s, m_stol)) { // see if the node might have moved to another element FESurfaceElement* pold = pme; cp.m_rs = vec2d(0, 0); pme = cpp.Project(m, q, cp.m_rs); } } } else if (bupseg) { // get the secondary surface element // don't forget to initialize the search for the first node! cp.m_rs = vec2d(0, 0); pme = cpp.Project(m, q, cp.m_rs); } // if we found a secondary surface element, update the gap and normal data cp.m_pme = pme; if (pme != 0) { FESurfaceElement& mel = *cp.m_pme; double r = cp.m_rs[0]; double s = cp.m_rs[1]; // the normal is set to the secondary surface element normal cp.m_nu = m_surf.SurfaceNormal(mel, r, s); // calculate gap cp.m_gap = -(cp.m_nu * (x - q)); if (bmove && (cp.m_gap > 0)) { node.m_r0 = node.m_rt = q; cp.m_gap = 0; } // TODO: what should we do if the gap function becomes // negative? setting the Lagrange multipliers to zero // might make the system unstable. /* if (ss.gap[i] < 0) { ss.Lm[i] = 0; ss.pme[i] = 0; } */ } 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 cp.m_gap = 0; cp.m_Lm = 0; } } } // update void FEEdgeToSurfaceSlidingContact::Update() { FESurfaceConstraint::Update(); int niter = GetFEModel()->GetCurrentStep()->GetFESolver()->m_niter; // should we do a segment update or not? // TODO: check what happens when m_nsegup == -1 and m_npass = 2; // We have to make sure that in this case, both surfaces get at least // one pass! bool bupdate = (m_bfirst || (m_nsegup == 0) ? true : (niter <= m_nsegup)); m_edge.Update(); m_surf.Update(); // project primary surface onto secondary surface // this also calculates the nodal gap functions ProjectSurface(bupdate); // set the first-entry-flag to false m_bfirst = false; } // Build the matrix profile void FEEdgeToSurfaceSlidingContact::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"); for (int j = 0; j < m_edge.Nodes(); ++j) { FESurfaceElement* pe = m_edge.m_points[j].m_pme; 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] = m_edge.Node(j).m_ID[dof_X]; lm[1] = m_edge.Node(j).m_ID[dof_Y]; lm[2] = m_edge.Node(j).m_ID[dof_Z]; lm[3] = m_edge.Node(j).m_ID[dof_RU]; lm[4] = m_edge.Node(j).m_ID[dof_RV]; lm[5] = m_edge.Node(j).m_ID[dof_RW]; for (int k = 0; k < n; ++k) { vector<int>& id = mesh.Node(en[k]).m_ID; lm[6 * (k + 1) ] = id[dof_X]; lm[6 * (k + 1) + 1] = id[dof_Y]; lm[6 * (k + 1) + 2] = id[dof_Z]; lm[6 * (k + 1) + 3] = id[dof_RU]; lm[6 * (k + 1) + 4] = id[dof_RV]; lm[6 * (k + 1) + 5] = id[dof_RW]; } K.build_add(lm); } } } // The LoadVector function evaluates the "forces" that contribute to the residual of the system void FEEdgeToSurfaceSlidingContact::LoadVector(FEGlobalVector& R, const FETimeInfo& tp) { // element contact force vector vector<double> fe; // the lm array for this force vector vector<int> lm; // the en array vector<int> en; // the elements LM vectors vector<int> sLM; vector<int> mLM; const int MN = FEElement::MAX_NODES; vec3d r0[MN]; double w[MN]; double detJ[MN]; vec3d dxr, dxs; int ne = m_edge.Elements(); for (int j = 0; j < ne; ++j) { // get the next element FELineElement& sel = m_edge.Element(j); int nseln = sel.Nodes(); // get the element's LM array m_edge.UnpackLM(sel, sLM); // nodal coordinates for (int i = 0; i < nseln; ++i) r0[i] = m_edge.GetMesh()->Node(sel.m_node[i]).m_r0; // we calculate all the metrics we need before we // calculate the nodal forces double* w1 = sel.GaussWeights(); for (int n = 0; n < nseln; ++n) { FEE2SSlidingContactPoint& mp1 = static_cast<FEE2SSlidingContactPoint&>(*sel.GetMaterialPoint(n)); detJ[n] = mp1.m_Jt; w[n] = sel.GaussWeights()[n]; } // loop over primary surface element nodes (which are the integration points as well) // and calculate the contact nodal force for (int n = 0; n < nseln; ++n) { // get the local node number int m = sel.m_lnode[n]; FEE2SSlidingContactPoint& cp = m_edge.m_points[m]; // see if this node's constraint is active // that is, if it has an element associated with it // TODO: is this a good way to test for an active constraint // The rigid wall criteria seems to work much better. if (cp.m_pme != 0) { // This node is active and could lead to a non-zero // contact force. // get the secondary surface element FESurfaceElement& mel = *cp.m_pme; 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(m, mel, fe); // multiply force with weights for (int l = 0; l < ndof; ++l) fe[l] *= detJ[n] * w[n]; // fill the lm array lm.resize(3 * (nmeln + 1)); lm[0] = sLM[n * 3 ]; lm[1] = sLM[n * 3 + 1]; lm[2] = sLM[n * 3 + 2]; for (int l = 0; l < nmeln; ++l) { lm[3 * (l + 1) ] = mLM[l * 3]; lm[3 * (l + 1) + 1] = mLM[l * 3 + 1]; lm[3 * (l + 1) + 2] = mLM[l * 3 + 2]; } // fill the en array en.resize(nmeln + 1); en[0] = sel.m_node[n]; for (int l = 0; l < nmeln; ++l) en[l + 1] = mel.m_node[l]; // assemble into global force vector R.Assemble(en, lm, fe); } } } } void FEEdgeToSurfaceSlidingContact::ContactNodalForce(int m, FESurfaceElement& mel, vector<double>& fe) { // max nr of element nodes const int MAXMN = FEElement::MAX_NODES; // secondary surface element nodes vec3d rtm[MAXMN]; // shape function values double H[MAXMN]; // contact vectors double N[3 * (MAXMN + 1)]; double eps = m_eps; // get the mesh FEMesh& mesh = GetFEModel()->GetMesh(); int nmeln, ndof; FEE2SSlidingContactPoint& cp = m_edge.m_points[m]; // gap function double gap = cp.m_gap; // get primary surface node normal force double Ln = cp.m_Lm; double tn = Ln + eps * gap; tn = MBRACKET(tn); // get the primary surface node normal vec3d& nu = cp.m_nu; nmeln = mel.Nodes(); ndof = 3 * (1 + nmeln); // get the secondary surface 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 node // onto the secondary surface element double r = cp.m_rs[0]; double s = cp.m_rs[1]; // get the secondary surface element shape function values at this node mel.shape_fnc(H, r, s); // --- N O R M A L T R A C T I O N --- // 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]; } // Evaluates the contriubtion to the stiffness matrix void FEEdgeToSurfaceSlidingContact::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) { FEElementMatrix ke; const int MAXMN = FEElement::MAX_NODES; vector<int> lm(3 * (MAXMN + 1)); vector<int> en(MAXMN + 1); double w[MAXMN]; vec3d r0[MAXMN]; double detJ[MAXMN]; vec3d dxr, dxs; vector<int> sLM; vector<int> mLM; // loop over all primary surface elements int ne = m_edge.Elements(); for (int j = 0; j < ne; ++j) { // unpack the next element FELineElement& se = m_edge.Element(j); int nseln = se.Nodes(); // get the element's LM array m_edge.UnpackLM(se, sLM); // get the nodal coordinates for (int i = 0; i < nseln; ++i) r0[i] = m_edge.GetMesh()->Node(se.m_node[i]).m_r0; // get all the metrics we need for (int n = 0; n < nseln; ++n) { FEE2SSlidingContactPoint& mp1 = static_cast<FEE2SSlidingContactPoint&>(*se.GetMaterialPoint(n)); detJ[n] = mp1.m_Jt; w[n] = se.GaussWeights()[n]; } // loop over all integration points (that is nodes) for (int n = 0; n < nseln; ++n) { int m = se.m_lnode[n]; FEE2SSlidingContactPoint& cp = m_edge.m_points[m]; // see if this node's constraint is active // that is, if it has an element associated with it if (cp.m_pme != 0) { // get the secondary surface element FESurfaceElement& me = *cp.m_pme; // 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(m, me, ke); // muliply with weights for (int k = 0; k < ndof; ++k) for (int l = 0; l < ndof; ++l) ke[k][l] *= detJ[n] * w[n]; // fill the lm array lm[0] = sLM[n * 3 ]; lm[1] = sLM[n * 3 + 1]; lm[2] = sLM[n * 3 + 2]; for (int k = 0; k < nmeln; ++k) { lm[3 * (k + 1) ] = mLM[k * 3]; lm[3 * (k + 1) + 1] = mLM[k * 3 + 1]; lm[3 * (k + 1) + 2] = mLM[k * 3 + 2]; } // create the en array en.resize(nmeln + 1); en[0] = se.m_node[n]; for (int k = 0; k < nmeln; ++k) en[k + 1] = me.m_node[k]; // assemble stiffness matrix ke.SetNodes(en); ke.SetIndices(lm); LS.Assemble(ke); } } } } void FEEdgeToSurfaceSlidingContact::ContactNodalStiffness(int m, FESurfaceElement& mel, matrix& ke) { const int MAXMN = FEElement::MAX_NODES; vector<int> lm(3 * (MAXMN + 1)); vector<int> en(MAXMN + 1); vec3d dxr, dxs; 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 = GetFEModel()->GetMesh(); // nr of element nodes and degrees of freedom int nmeln = mel.Nodes(); int ndof = 3 * (1 + nmeln); // penalty factor double eps = m_eps; // nodal coordinates vec3d rt[MAXMN]; for (int j = 0; j < nmeln; ++j) rt[j] = mesh.Node(mel.m_node[j]).m_rt; // node natural coordinates in secondary surface element FEE2SSlidingContactPoint& cp = m_edge.m_points[m]; double r = cp.m_rs[0]; double s = cp.m_rs[1]; // gap double gap = cp.m_gap; // lagrange multiplier double Lm = cp.m_Lm; // get node normal force double tn = Lm + eps * gap; tn = MBRACKET(tn); // get the node normal vec3d& nu = cp.m_nu; // get the secondary surface element shape function values and the derivatives at this 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; } } void FEEdgeToSurfaceSlidingContact::Serialize(DumpStream& ar) { FESurfaceConstraint::Serialize(ar); m_edge.Serialize(ar); m_surf.Serialize(ar); }
C++
3D
febiosoftware/FEBio
FEBioMech/FEHolzapfelGasserOgden.h
.h
2,153
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 "FEUncoupledMaterial.h" #include <FECore/FEModelParam.h> class FEHolzapfelGasserOgden : public FEUncoupledMaterial { public: FEParamDouble m_c; // neo-Hookean c coefficient FEParamDouble m_k1,m_k2; // fiber material constants FEParamDouble m_kappa; // structure coefficient FEParamDouble m_gdeg; // fiber angle in degrees public: FEHolzapfelGasserOgden(FEModel* pfem); //! calculate deviatoric stress at material point mat3ds DevStress(FEMaterialPoint& pt) override; //! calculate deviatoric tangent stiffness at material point tens4ds DevTangent(FEMaterialPoint& pt) override; //! calculate deviatoric strain energy density at material point double DevStrainEnergyDensity(FEMaterialPoint& pt) override; // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FETiedInterface.h
.h
3,714
110
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEContactInterface.h" #include "FETiedContactSurface.h" //----------------------------------------------------------------------------- //! This class implements a tied interface. class FETiedInterface : public FEContactInterface { public: //! constructor FETiedInterface(FEModel* pfem); //! destructor virtual ~FETiedInterface(){} //! Initializes sliding interface bool Init() override; //! interface activation void Activate() override; //! projects nodes onto secondary surface void ProjectSurface(FETiedContactSurface& ss, FETiedContactSurface& ms, bool bmove = false); //! serialize data to archive void Serialize(DumpStream& ar) override; //! return the primary and secondary surface FESurface* GetPrimarySurface() override { return &ss; } FESurface* GetSecondarySurface() override { return &ms; } //! return integration rule class bool UseNodalIntegration() override { return true; } //! build the matrix profile for use in the stiffness matrix void BuildMatrixProfile(FEGlobalMatrix& K) override; //! return number of equations to be allocated for Lagrange multipliers int InitEquations(int neq) 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; //! prepare for next time step void PrepStep() override; //! Update Lagrange multipliers void Update(const std::vector<double>& Ui, const std::vector<double>& ui) override; void UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) override; public: FETiedContactSurface ss; //!< primary surface FETiedContactSurface ms; //!< secondary surface public: double m_atol; //!< augmentation tolerance double m_eps; //!< penalty scale factor double m_stol; //!< search tolerance int m_naugmax; //!< maximum nr of augmentations int m_naugmin; //!< minimum nr of augmentations bool m_boffset; //!< offset primary surface for shells double m_Dmax; //!< max distance for contact bool m_bspecial; //!< handle special cases in projection bool m_breloc; //!< node relocation on initialization vector<int> m_LM; //!< Lagrange multiplier equations DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FEVonMisesPlasticity.h
.h
3,283
120
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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/DumpStream.h> //----------------------------------------------------------------------------- class FEJ2PlasticMaterialPoint : public FEElasticMaterialPoint { public: FEJ2PlasticMaterialPoint() {} FEMaterialPointData* Copy() { return new FEJ2PlasticMaterialPoint(*this); } void Init() { // intialize data to zero e0.zero(); e1.zero(); sn.zero(); b = false; Y1 = Y0; // don't forget to intialize the nested data FEMaterialPointData::Init(); } void Update(const FETimeInfo& timeInfo) { e0 = e1; sn = m_s; Y0 = Y1; // don't forget to call the base class FEElasticMaterialPoint::Update(timeInfo); } void Serialize(DumpStream& ar) { FEElasticMaterialPoint::Serialize(ar); ar & e0 & e1 & sn; ar & Y0 & Y1 & b; } public: mat3ds e0, e1; // strain at time n and n+1 mat3ds sn; // stress at time n double Y0, Y1; // yield strenght at time n, n+1 bool b; // plasticity flag }; //----------------------------------------------------------------------------- //! This class implements a simple von-Mises plasticity model with isotropic //! hardening. class FEVonMisesPlasticity : public FESolidMaterial { public: FEVonMisesPlasticity(FEModel* pfem); public: double m_E; //!< Young's modulus double m_v; //!< Poisson's ratio double m_K; //!< bulk modulus double m_G; //!< shear modulus double m_Y; //!< initial yield strength double m_H; //!< hardening modulus public: FEMaterialPointData* CreateMaterialPointData() override; //! calculate stress at material point mat3ds Stress(FEMaterialPoint& pt) override; //! calculate tangent stiffness at material point tens4ds Tangent(FEMaterialPoint& pt) override; //! data initialization and checking bool Init() override; // declare the parameter list DECLARE_FECORE_CLASS(); }; class FEBIOMECH_API FESolidStress : public FEDomainParameter { public: FESolidStress(); FEParamValue value(FEMaterialPoint& mp) override; };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FERigidEulerAngles.cpp
.cpp
3,354
114
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FERigidEulerAngles.h" BEGIN_FECORE_CLASS(FERigidEulerAngles, FERigidBC) ADD_PARAMETER(m_rigidMat, "rb")->setEnums("$(rigid_materials)")->setLongName("Rigid material"); ADD_PARAMETER(m_convention, "convention")->setEnums("ZXY\0"); ADD_PARAMETER(m_Ex, "Ex")->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE)->setUnits(UNIT_DEGREE); ADD_PARAMETER(m_Ey, "Ey")->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE)->setUnits(UNIT_DEGREE); ADD_PARAMETER(m_Ez, "Ez")->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE)->setUnits(UNIT_DEGREE); END_FECORE_CLASS(); FERigidEulerAngles::FERigidEulerAngles(FEModel* fem) : FERigidBC(fem) { m_convention = 0; m_Ex = m_Ey = m_Ez = 0.0; m_rc[0] = new FERigidPrescribedBC(fem); m_rc[0]->SetBC(3); m_rc[1] = new FERigidPrescribedBC(fem); m_rc[1]->SetBC(4); m_rc[2] = new FERigidPrescribedBC(fem); m_rc[2]->SetBC(5); } FERigidEulerAngles::~FERigidEulerAngles() { delete m_rc[0]; delete m_rc[1]; delete m_rc[2]; } bool FERigidEulerAngles::Init() { for (int i = 0; i < 3; ++i) { m_rc[i]->SetRigidMaterial(m_rigidMat); if (m_rc[i]->Init() == false) return false; } return true; } void FERigidEulerAngles::Activate() { FERigidBC::Activate(); m_rc[0]->Activate(); m_rc[1]->Activate(); m_rc[2]->Activate(); UpdateRotations(); } void FERigidEulerAngles::Deactivate() { FERigidBC::Deactivate(); m_rc[0]->Deactivate(); m_rc[1]->Deactivate(); m_rc[2]->Deactivate(); } void FERigidEulerAngles::InitTimeStep() { UpdateRotations(); } void FERigidEulerAngles::UpdateRotations() { quatd q; double Ex = DEG2RAD * m_Ex; double Ey = DEG2RAD * m_Ey; double Ez = DEG2RAD * m_Ez; q.SetEuler(Ex, Ey, Ez); vec3d r = q.GetRotationVector(); m_rc[0]->SetValue(r.x); m_rc[1]->SetValue(r.y); m_rc[2]->SetValue(r.z); } void FERigidEulerAngles::Serialize(DumpStream& ar) { FERigidBC::Serialize(ar); if (ar.IsShallow() == false) { for (int j = 0; j < 3; ++j) { // We need to serialize a reference to avoid that // restart will try to allocate the m_rc variables FERigidPrescribedBC& rc = *m_rc[j]; ar& rc; } } }
C++
3D
febiosoftware/FEBio
FEBioMech/FERigidEulerAngles.h
.h
1,812
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 "RigidBC.h" #include "febiomech_api.h" class FEBIOMECH_API FERigidEulerAngles : public FERigidBC { enum EulerConvention { EULER_ZXY }; public: FERigidEulerAngles(FEModel* fem); ~FERigidEulerAngles(); bool Init() override; void Activate() override; void Deactivate() override; void InitTimeStep() override; void Serialize(DumpStream& ar) override; private: void UpdateRotations(); private: int m_convention; double m_Ex, m_Ey, m_Ez; FERigidPrescribedBC* m_rc[3]; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioMech/FENewtonianViscousSolidUC.cpp
.cpp
3,094
88
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FENewtonianViscousSolidUC.h" //----------------------------------------------------------------------------- // define the material parameters BEGIN_FECORE_CLASS(FENewtonianViscousSolidUC, FEUncoupledMaterial) ADD_PARAMETER(m_kappa, FE_RANGE_GREATER_OR_EQUAL( 0.0), "kappa")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_mu , FE_RANGE_GREATER_OR_EQUAL( 0.0), "mu" )->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_secant_tangent, "secant_tangent"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FENewtonianViscousSolidUC::FENewtonianViscousSolidUC(FEModel* pfem) : FEUncoupledMaterial(pfem) { m_kappa = 0.0; m_mu = 0.0; m_secant_tangent = false; } //----------------------------------------------------------------------------- mat3ds FENewtonianViscousSolidUC::DevStress(FEMaterialPoint& mp) { FEElasticMaterialPoint& pe = *mp.ExtractData<FEElasticMaterialPoint>(); mat3ds D = pe.RateOfDeformation(); // Identity mat3dd I(1); // calculate stress mat3ds s = I*(D.tr()*(m_kappa - 2*m_mu/3)) + D*(2*m_mu); // determinant of deformation gradient double J = pe.m_J; return s.dev()*(2.0/J); } //----------------------------------------------------------------------------- tens4ds FENewtonianViscousSolidUC::DevTangent(FEMaterialPoint& mp) { mat3dd I(1); tens4ds Cv; double dt = CurrentTimeIncrement(); if (dt > 0) Cv = (dyad1s(I, I)*(m_kappa - 2 * m_mu / 3) + dyad4s(I, I)*(2 * m_mu)) / (2 * dt); else Cv.zero(); return Cv; } //----------------------------------------------------------------------------- double FENewtonianViscousSolidUC::DevStrainEnergyDensity(FEMaterialPoint& mp) { return 0; }
C++
3D
febiosoftware/FEBio
FEBioMech/FESSIShellDomain.h
.h
7,195
172
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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/FEShellDomain.h> #include <FECore/FEModelParam.h> #include <functional> #include "febiomech_api.h" #include <FECore/FEDofList.h> class FEDataStream; //----------------------------------------------------------------------------- // This class extends the FEShellDomain and implements the solid-shell interface (SSI) logic. // It is used by the new shell formulation. class FEBIOMECH_API FESSIShellDomain : public FEShellDomainNew { public: FESSIShellDomain(FEModel* pfem); //! initialize domain //! one-time initialization, called during model initialization bool Init() override; //! serialization void Serialize(DumpStream& ar) override; //! Update element data prior to solving time step void PreSolveUpdate(const FETimeInfo& timeInfo) override; //! Initialize shell normals bool InitShells() override; protected: //! Find interfaces between solid element faces and shell elements void FindSSI(); public: //! calculates covariant basis vectors at an integration point void CoBaseVectors0(FEShellElement& el, int n, vec3d g[3]); //! calculates covariant basis vectors at any point void CoBaseVectors0(FEShellElement& el, double r, double s, double t, vec3d g[3]); //! calculates contravariant basis vectors at an integration point void ContraBaseVectors0(FEShellElement& el, int n, vec3d g[3]); //! calculates contravariant basis vectors at any point void ContraBaseVectors0(FEShellElement& el, double r, double s, double t, vec3d g[3]); // inverse jacobian with respect to reference frame at an integration point double invjac0(FEShellElement& el, double J[3][3], int n); // inverse jacobian with respect to reference frame at any point double invjac0(FEShellElement& el, double J[3][3], double r, double s, double t); // jacobian with respect to reference frame double detJ0(FEShellElement& el, int n); // jacobian with respect to current frame at any point double detJ0(FEShellElement& el, double r, double s, double t); public: //! calculates covariant basis vectors at an integration point void CoBaseVectors(FEShellElement& el, int n, vec3d g[3]); //! calculates covariant basis vectors at any point void CoBaseVectors(FEShellElement& el, double r, double s, double t, vec3d g[3]); //! calculates covariant basis vectors at any point void CoBaseVectors(FEShellElement& el, double r, double s, double t, vec3d g[3], const double alpha); //! calculates covariant basis vectors at an integration point at previous time void CoBaseVectorsP(FEShellElement& el, int n, vec3d g[3]); //! calculates covariant basis vectors at an integration point at intermediate time void CoBaseVectors(FEShellElement& el, int n, vec3d g[3], const double alpha); //! calculates contravariant basis vectors at an integration point void ContraBaseVectors(FEShellElement& el, int n, vec3d g[3]); //! calculates contravariant basis vectors at an integration point at intermediate time void ContraBaseVectors(FEShellElement& el, int n, vec3d g[3], const double alpha); //! calculates contravariant basis vectors at any point void ContraBaseVectors(FEShellElement& el, double r, double s, double t, vec3d g[3]); //! calculates contravariant basis vectors at any point void ContraBaseVectors(FEShellElement& el, double r, double s, double t, vec3d g[3], const double alpha); // jacobian with respect to current frame at an integration point double detJ(FEShellElement& el, int n); // jacobian with respect to current frame at an integration point at intermediate time double detJ(FEShellElement& el, int n, const double alpha); // jacobian with respect to current frame at any point double detJ(FEShellElement& el, double r, double s, double t); // calculate deformation gradient at an integration point double defgrad(FEShellElement& el, mat3d& F, int n); // calculate deformation gradient at any point double defgrad(FEShellElement& el, mat3d& F, double r, double s, double t); // calculate deformation gradient at an integration point at previous time double defgradp(FEShellElement& el, mat3d& F, int n); // inverse jacobian with respect to current frame double invjact(FEShellElement& el, double J[3][3], int n); //! evaluate a vector function over the shell vec3d evaluate(FEShellElement& el, vec3d* vn, vec3d* dvn, int n); //! evaluate a scalar function over the shell double evaluate(FEShellElement& el, double* pn, double* dpn, int n); //! calculate the gradient of a scalar function over the shell vec3d gradient(FEShellElement& el, double* pn, double* dpn, int n); //! evaluate a scalar function over the shell double evaluate(FEShellElement& el, vector<double> pn, vector<double> dpn, int n); //! calculate the gradient of a scalar function over the shell vec3d gradient(FEShellElement& el, vector<double> pn, vector<double> dpn, int n); //! Functions for element-DOF updates virtual void UpdateEAS(vector<double>& ui) {} virtual void UpdateIncrementsEAS(vector<double>& ui, const bool binc) {} void Update(const FETimeInfo& tp) override; protected: FEDofList m_dofU; // displacement dofs FEDofList m_dofSU; // shell displacement dofs FEDofList m_dofR; // rigid rotation public: bool m_bnodalnormals; // flag for nodal (true) or element (false) normals DECLARE_FECORE_CLASS(); }; //----------------------------------------------------------------------------- void writeIntegratedElementValue(FESSIShellDomain& dom, FEDataStream& ar, std::function<double (const FEMaterialPoint& mp)> fnc); void writeIntegratedElementValue(FESSIShellDomain& dom, FEDataStream& ar, std::function<vec3d (const FEMaterialPoint& mp)> fnc);
Unknown