forked from sofa-framework/sofa
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEM.Elastic] Start unification of tetra FF and division of tests (so…
…fa-framework#4778) * [FEM.Elastic] Start unification of tetra FF and division of tests * Fix 'd_youngModulus' was not declared in this scope * share common topology link * restore warning when topology has no tetras * Rename because it can also be used for triangle force fields * remove use of getValue * fix Data duplicate * use of empty * clean Real * apply renaming of Data * fix test due to Data renaming
- Loading branch information
Showing
20 changed files
with
1,266 additions
and
1,173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...astic/src/sofa/component/solidmechanics/fem/elastic/BaseLinearElasticityFEMForceField.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/****************************************************************************** | ||
* SOFA, Simulation Open-Framework Architecture * | ||
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify it * | ||
* under the terms of the GNU Lesser General Public License as published by * | ||
* the Free Software Foundation; either version 2.1 of the License, or (at * | ||
* your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, but WITHOUT * | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * | ||
* for more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||
******************************************************************************* | ||
* Authors: The SOFA Team and external contributors (see Authors.txt) * | ||
* * | ||
* Contact information: [email protected] * | ||
******************************************************************************/ | ||
#define SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_BASETETRAHEDRONFEMFORCEFIELD_CPP | ||
#include <sofa/component/solidmechanics/fem/elastic/BaseLinearElasticityFEMForceField.inl> | ||
|
||
namespace sofa::component::solidmechanics::fem::elastic | ||
{ | ||
template class BaseLinearElasticityFEMForceField<defaulttype::Vec3Types>; | ||
} |
67 changes: 67 additions & 0 deletions
67
...Elastic/src/sofa/component/solidmechanics/fem/elastic/BaseLinearElasticityFEMForceField.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/****************************************************************************** | ||
* SOFA, Simulation Open-Framework Architecture * | ||
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify it * | ||
* under the terms of the GNU Lesser General Public License as published by * | ||
* the Free Software Foundation; either version 2.1 of the License, or (at * | ||
* your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, but WITHOUT * | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * | ||
* for more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||
******************************************************************************* | ||
* Authors: The SOFA Team and external contributors (see Authors.txt) * | ||
* * | ||
* Contact information: [email protected] * | ||
******************************************************************************/ | ||
#pragma once | ||
#include <sofa/component/solidmechanics/fem/elastic/config.h> | ||
#include <sofa/core/behavior/ForceField.h> | ||
#include <sofa/core/topology/BaseMeshTopology.h> | ||
|
||
|
||
namespace sofa::component::solidmechanics::fem::elastic | ||
{ | ||
|
||
template<class DataTypes> | ||
class BaseLinearElasticityFEMForceField : public core::behavior::ForceField<DataTypes> | ||
{ | ||
public: | ||
using Coord = typename DataTypes::Coord; | ||
using VecReal = typename DataTypes::VecReal; | ||
using Real = typename DataTypes::Real; | ||
|
||
SOFA_CLASS(SOFA_TEMPLATE(BaseLinearElasticityFEMForceField, DataTypes), SOFA_TEMPLATE(core::behavior::ForceField, DataTypes)); | ||
|
||
Data<Real> d_poissonRatio; ///< FEM Poisson Ratio in Hooke's law [0,0.5[ | ||
Data<VecReal > d_youngModulus; ///< FEM Young's Modulus in Hooke's law | ||
|
||
/// Link to be set to the topology container in the component graph. | ||
SingleLink<BaseLinearElasticityFEMForceField<DataTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINK> l_topology; | ||
|
||
static inline const VecReal defaultYoungModulusValue = []() | ||
{ | ||
VecReal newY; | ||
newY.resize(1); | ||
newY[0] = 5000; | ||
return newY; | ||
}(); | ||
|
||
BaseLinearElasticityFEMForceField(); | ||
|
||
void setPoissonRatio(Real val); | ||
void setYoungModulus(Real val); | ||
|
||
Real getYoungModulusInElement(sofa::Size elementId); | ||
}; | ||
|
||
#if !defined(SOFA_COMPONENT_SOLIDMECHANICS_FEM_ELASTIC_BASELINEARELASTICITYFEMFORCEFIELD_CPP) | ||
extern template class BaseLinearElasticityFEMForceField<defaulttype::Vec3Types>; | ||
#endif | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
...astic/src/sofa/component/solidmechanics/fem/elastic/BaseLinearElasticityFEMForceField.inl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/****************************************************************************** | ||
* SOFA, Simulation Open-Framework Architecture * | ||
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify it * | ||
* under the terms of the GNU Lesser General Public License as published by * | ||
* the Free Software Foundation; either version 2.1 of the License, or (at * | ||
* your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, but WITHOUT * | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * | ||
* for more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||
******************************************************************************* | ||
* Authors: The SOFA Team and external contributors (see Authors.txt) * | ||
* * | ||
* Contact information: [email protected] * | ||
******************************************************************************/ | ||
#pragma once | ||
#include <sofa/component/solidmechanics/fem/elastic/BaseLinearElasticityFEMForceField.h> | ||
#include <sofa/core/behavior/ForceField.inl> | ||
|
||
namespace sofa::component::solidmechanics::fem::elastic | ||
{ | ||
|
||
template <class DataTypes> | ||
BaseLinearElasticityFEMForceField<DataTypes>::BaseLinearElasticityFEMForceField() | ||
: d_poissonRatio(initData(&d_poissonRatio,(Real)0.45,"poissonRatio","FEM Poisson Ratio in Hooke's law [0,0.5[")) | ||
, d_youngModulus(initData(&d_youngModulus, defaultYoungModulusValue, "youngModulus","FEM Young's Modulus in Hooke's law")) | ||
, l_topology(initLink("topology", "link to the topology container")) | ||
{ | ||
d_poissonRatio.setRequired(true); | ||
d_poissonRatio.setWidget("poissonRatio"); | ||
|
||
d_youngModulus.setRequired(true); | ||
} | ||
|
||
template <class DataTypes> | ||
void BaseLinearElasticityFEMForceField<DataTypes>::setPoissonRatio(Real val) | ||
{ | ||
this->d_poissonRatio.setValue(val); | ||
} | ||
|
||
template <class DataTypes> | ||
void BaseLinearElasticityFEMForceField<DataTypes>::setYoungModulus(Real val) | ||
{ | ||
VecReal newY; | ||
newY.resize(1); | ||
newY[0] = val; | ||
d_youngModulus.setValue(newY); | ||
} | ||
|
||
template <class DataTypes> | ||
auto BaseLinearElasticityFEMForceField<DataTypes>::getYoungModulusInElement(sofa::Size elementId) | ||
-> Real | ||
{ | ||
Real youngModulusElement {}; | ||
|
||
const auto& youngModulus = d_youngModulus.getValue(); | ||
if (youngModulus.size() > elementId) | ||
{ | ||
youngModulusElement = youngModulus[elementId]; | ||
} | ||
else if (!youngModulus.empty()) | ||
{ | ||
youngModulusElement = youngModulus[0]; | ||
} | ||
else | ||
{ | ||
setYoungModulus(5000); | ||
youngModulusElement = youngModulus[0]; | ||
} | ||
return youngModulusElement; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.