|
| 1 | +/*This file is part of the FEBio source code and is licensed under the MIT license |
| 2 | +listed below. |
| 3 | +
|
| 4 | +See Copyright-FEBio.txt for details. |
| 5 | +
|
| 6 | +Copyright (c) 2021 University of Utah, The Trustees of Columbia University in |
| 7 | +the City of New York, and others. |
| 8 | +
|
| 9 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 10 | +of this software and associated documentation files (the "Software"), to deal |
| 11 | +in the Software without restriction, including without limitation the rights |
| 12 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 13 | +copies of the Software, and to permit persons to whom the Software is |
| 14 | +furnished to do so, subject to the following conditions: |
| 15 | +
|
| 16 | +The above copyright notice and this permission notice shall be included in all |
| 17 | +copies or substantial portions of the Software. |
| 18 | +
|
| 19 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 | +SOFTWARE.*/ |
| 26 | +#include "stdafx.h" |
| 27 | +#include "FEBCPrescribedDeformation2O.h" |
| 28 | +#include <FECore/FEMesh.h> |
| 29 | + |
| 30 | +BEGIN_FECORE_CLASS(FEBCPrescribedDeformation2O, FEPrescribedNodeSet) |
| 31 | + ADD_PARAMETER(m_scale, "scale"); |
| 32 | + ADD_PARAMETER(m_F , "F"); |
| 33 | + ADD_PARAMETER(m_G , "G"); |
| 34 | + ADD_PARAMETER(m_refNode, "reference"); |
| 35 | +END_FECORE_CLASS(); |
| 36 | + |
| 37 | +FEBCPrescribedDeformation2O::FEBCPrescribedDeformation2O(FEModel* pfem) : FEPrescribedNodeSet(pfem) |
| 38 | +{ |
| 39 | + m_scale = 1.0; |
| 40 | + m_F.unit(); |
| 41 | + m_G.zero(); |
| 42 | + m_refNode = -1; |
| 43 | + |
| 44 | + if (pfem) |
| 45 | + { |
| 46 | + FEDofList dofs(pfem); |
| 47 | + dofs.AddVariable("displacement"); |
| 48 | + SetDOFList(dofs); |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +//----------------------------------------------------------------------------- |
| 53 | +bool FEBCPrescribedDeformation2O::Init() |
| 54 | +{ |
| 55 | + if (m_refNode < 0) return false; |
| 56 | + return FEPrescribedNodeSet::Init(); |
| 57 | +} |
| 58 | + |
| 59 | +//----------------------------------------------------------------------------- |
| 60 | +// Sets the displacement scale factor. An optional load curve index can be given |
| 61 | +// of the load curve that will control the scale factor. |
| 62 | +void FEBCPrescribedDeformation2O::SetScale(double s, int lc) |
| 63 | +{ |
| 64 | + m_scale = s; |
| 65 | + if (lc >= 0) AttachLoadController(&m_scale, lc); |
| 66 | +} |
| 67 | + |
| 68 | +//----------------------------------------------------------------------------- |
| 69 | +void FEBCPrescribedDeformation2O::CopyFrom(FEBoundaryCondition* pbc) |
| 70 | +{ |
| 71 | + FEBCPrescribedDeformation2O* ps = dynamic_cast<FEBCPrescribedDeformation2O*>(pbc); assert(ps); |
| 72 | + m_scale = ps->m_scale; |
| 73 | + m_F = ps->m_F; |
| 74 | + m_G = ps->m_G; |
| 75 | + m_refNode = ps->m_refNode; |
| 76 | + CopyParameterListState(ps->GetParameterList()); |
| 77 | +} |
| 78 | + |
| 79 | +//----------------------------------------------------------------------------- |
| 80 | +void FEBCPrescribedDeformation2O::SetReferenceNode(int n) |
| 81 | +{ |
| 82 | + m_refNode = n; |
| 83 | +} |
| 84 | + |
| 85 | +//----------------------------------------------------------------------------- |
| 86 | +void FEBCPrescribedDeformation2O::SetDeformationGradient(const mat3d& F) |
| 87 | +{ |
| 88 | + m_F = F; |
| 89 | +} |
| 90 | + |
| 91 | +//----------------------------------------------------------------------------- |
| 92 | +void FEBCPrescribedDeformation2O::SetDeformationHessian(const tens3drs& G) |
| 93 | +{ |
| 94 | + m_G = G; |
| 95 | +} |
| 96 | + |
| 97 | +//----------------------------------------------------------------------------- |
| 98 | +void FEBCPrescribedDeformation2O::GetNodalValues(int nodelid, std::vector<double>& val) |
| 99 | +{ |
| 100 | + FEMesh& mesh = GetMesh(); |
| 101 | + vec3d X1 = mesh.Node(m_refNode).m_r0; |
| 102 | + |
| 103 | + vec3d X = GetNodeSet()->Node(nodelid)->m_r0; |
| 104 | + |
| 105 | + mat3ds XX = dyad(X); |
| 106 | + mat3ds XX1 = dyad(X1); |
| 107 | + mat3d U = m_F - mat3dd(1.0); |
| 108 | + vec3d u = U*(X - X1) + m_G.contract2s(XX - XX1)*0.5; |
| 109 | + u*=m_scale; |
| 110 | + |
| 111 | + val[0] = u.x; |
| 112 | + val[1] = u.y; |
| 113 | + val[2] = u.z; |
| 114 | +} |
0 commit comments