Skip to content

Commit

Permalink
Added nodal_target_force load, which can be used to ramp down reactio…
Browse files Browse the repository at this point in the history
…n forces produced by prescribed displacements.
  • Loading branch information
SteveMaas1978 committed Sep 6, 2024
1 parent 8a392f7 commit f229c10
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 1 deletion.
2 changes: 2 additions & 0 deletions FEBioMech/FEBioMechModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ SOFTWARE.*/

#include "FEInitialVelocity.h"
#include "FENodalForce.h"
#include "FENodalTargetForce.h"

#include "FEPreStrainElastic.h"
#include "FEPreStrainUncoupledElastic.h"
Expand Down Expand Up @@ -632,6 +633,7 @@ void FEBioMech::InitModule()
//-----------------------------------------------------------------------------
// classes derived from FENodalLoad
REGISTER_FECORE_CLASS(FENodalForce, "nodal_force");
REGISTER_FECORE_CLASS(FENodalTargetForce, "nodal_target_force");

//-----------------------------------------------------------------------------
// classes derived from FESurfaceLoad
Expand Down
78 changes: 78 additions & 0 deletions FEBioMech/FENodalTargetForce.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#include "stdafx.h"
#include "FENodalTargetForce.h"
#include "FEBioMech.h"
#include <FECore/FENodeSet.h>
#include <FECore/FEMaterialPoint.h>
#include <FECore/FENode.h>

// NOTE: We pass FEModelLoad as the base since I don't want the relative flag
BEGIN_FECORE_CLASS(FENodalTargetForce, FEModelLoad)
ADD_PARAMETER(m_w, "scale")->setUnits(UNIT_NONE)->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE);
ADD_PARAMETER(m_f, "force")->setUnits(UNIT_FORCE);
ADD_PARAMETER(m_shellBottom, "shell_bottom");
END_FECORE_CLASS();

FENodalTargetForce::FENodalTargetForce(FEModel* fem) : FENodalLoad(fem)
{
m_w = 1;
m_f = vec3d(0, 0, 0);
m_shellBottom = false;
}

void FENodalTargetForce::Activate()
{
// use a little hack to get the initial reaction forces
m_brelative = true;
FENodalLoad::Activate();
m_brelative = false;
}

bool FENodalTargetForce::SetDofList(FEDofList& dofList)
{
if (m_shellBottom)
return dofList.AddVariable(FEBioMech::GetVariableName(FEBioMech::SHELL_DISPLACEMENT));
else
return dofList.AddVariable(FEBioMech::GetVariableName(FEBioMech::DISPLACEMENT));
}

void FENodalTargetForce::GetNodalValues(int inode, std::vector<double>& val)
{
assert(val.size() == 3);
const FENodeSet& nset = *GetNodeSet();
const FENode& node = *nset.Node(inode);

FEMaterialPoint mp;
mp.m_r0 = node.m_r0;
mp.m_index = inode;

vec3d f = m_f(mp);

val[0] = m_rval[inode][0] * (1.0 - m_w) + m_w * f.x;
val[1] = m_rval[inode][1] * (1.0 - m_w) + m_w * f.y;
val[2] = m_rval[inode][2] * (1.0 - m_w) + m_w * f.z;
}
52 changes: 52 additions & 0 deletions FEBioMech/FENodalTargetForce.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 <FECore/FENodalLoad.h>
#include "febiomech_api.h"

class FEBIOMECH_API FENodalTargetForce : public FENodalLoad
{
public:
FENodalTargetForce(FEModel* fem);

void Activate() override;

protected: // required functions of FENodalLoad

// Set the dof list
bool SetDofList(FEDofList& dofList) override;

// get the nodal values
void GetNodalValues(int inode, std::vector<double>& val) override;

private:
double m_w;
FEParamVec3 m_f;
bool m_shellBottom;

DECLARE_FECORE_CLASS();
};

2 changes: 1 addition & 1 deletion FECore/FENodalLoad.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class FECORE_API FENodalLoad : public FEModelLoad
//! evaluate the contribution to the global stiffness matrix
virtual void StiffnessMatrix(FELinearSystem& LS) override;

private:
protected:
FEDofList m_dofs;
FENodeSet* m_nodeSet;
bool m_brelative;
Expand Down

0 comments on commit f229c10

Please sign in to comment.