-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] Proposition to reduce the number of alias declarations #4788
base: master
Are you sure you want to change the base?
Conversation
[ci-build][with-all-tests] |
6ecf25b
to
1f696af
Compare
typedef sofa::type::vector<MaterialStiffness> VecMaterialStiffness; ///< a vector of material stiffness matrices | ||
typedef type::Mat<6, 3, Real> StrainDisplacement; ///< the strain-displacement matrix (the transpose, actually) | ||
typedef type::Mat<6, 3, Real_t<DataTypes>> StrainDisplacement; ///< the strain-displacement matrix (the transpose, actually) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixing real precision in our codebase has the only consequence of making it very harde to track the preservation of a given level of precision (i.e, there is no undesired/un-expected loss).
In previously merged PR related to refactoring/removal of alias declaration the idea was to simply use SReal. So we are compiling SOFA either in double or in float and not a giant mic-mac.
, d_poisson(initData(&d_poisson, Real_t<DataTypes>(0.3), "poissonRatio", "Poisson ratio in Hooke's law")) | ||
, d_young(initData(&d_young, Real_t<DataTypes>(1000.), "youngModulus", "Young modulus in Hooke's law")) | ||
, d_thickness(initData(&d_thickness, Real_t<DataTypes>(1.), "thickness", "Thickness of the elements")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, d_poisson(initData(&d_poisson, Real_t<DataTypes>(0.3), "poissonRatio", "Poisson ratio in Hooke's law")) | |
, d_young(initData(&d_young, Real_t<DataTypes>(1000.), "youngModulus", "Young modulus in Hooke's law")) | |
, d_thickness(initData(&d_thickness, Real_t<DataTypes>(1.), "thickness", "Thickness of the elements")) | |
, d_poisson(initData(&d_poisson, SReal(0.3), "poissonRatio", "Poisson ratio in Hooke's law")) | |
, d_young(initData(&d_young, SReal(1000.), "youngModulus", "Young modulus in Hooke's law")) | |
, d_thickness(initData(&d_thickness, SReal(1.), "thickness", "Thickness of the elements")) |
Data<Real_t<DataTypes>> d_poisson; ///< Poisson ratio in Hooke's law | ||
Data<Real_t<DataTypes>> d_young; ///< Young modulus in Hooke's law | ||
Data<Real_t<DataTypes>> d_thickness; ///< Thickness of the elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data<Real_t<DataTypes>> d_poisson; ///< Poisson ratio in Hooke's law | |
Data<Real_t<DataTypes>> d_young; ///< Young modulus in Hooke's law | |
Data<Real_t<DataTypes>> d_thickness; ///< Thickness of the elements | |
Data<SReal> d_poisson; ///< Poisson ratio in Hooke's law | |
Data<SReal> d_young; ///< Young modulus in Hooke's law | |
Data<SReal> d_thickness; ///< Thickness of the elements |
Real_t<DataTypes> getPoisson() { return d_poisson.getValue(); } | ||
void setPoisson(Real_t<DataTypes> val); | ||
Real_t<DataTypes> getYoung() { return d_young.getValue(); } | ||
void setYoung(Real_t<DataTypes> val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real_t<DataTypes> getPoisson() { return d_poisson.getValue(); } | |
void setPoisson(Real_t<DataTypes> val); | |
Real_t<DataTypes> getYoung() { return d_young.getValue(); } | |
void setYoung(Real_t<DataTypes> val); | |
SReal getPoisson() { return d_poisson.getValue(); } | |
void setPoisson(SReal val); | |
SReal getYoung() { return d_young.getValue(); } | |
void setYoung(SReal val); |
@@ -162,26 +152,26 @@ class TriangleFEMForceField : public core::behavior::ForceField<DataTypes> | |||
protected: | |||
|
|||
/// f += Kx where K is the stiffness matrix and x a displacement | |||
virtual void applyStiffness(VecCoord& f, Real h, const VecCoord& x, const Real& kFactor); | |||
virtual void applyStiffness(VecCoord_t<DataTypes>& f, Real_t<DataTypes> h, const VecCoord_t<DataTypes>& x, const Real_t<DataTypes>& kFactor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual void applyStiffness(VecCoord_t<DataTypes>& f, Real_t<DataTypes> h, const VecCoord_t<DataTypes>& x, const Real_t<DataTypes>& kFactor); | |
virtual void applyStiffness(VecCoord_t<DataTypes>& f, SReal h, const VecCoord_t<DataTypes>& x, const SReal& kFactor); |
6d3bebd
to
a86543e
Compare
The goal is to reduce the number of alias declarations. I propose 2 methods:
DataVecCoord_t<Out>
). This is illustrated inMulti2Mapping
.using a set of macros. The aliases are still declared, but it is hidden inside the macro.I find the trait approach elegant (nothing is hidden and no use of macro or additional code), but too much verbose when only one template parameter is available (e.g.
TetrahedronFEMForceField
).The advantage of the macro is that it does not require changes in the code other than the alias declarations.
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if