Skip to content

Commit b769e33

Browse files
Merge branch 'master' into pr-add-field-to-surface-mesh
2 parents 6c8c226 + f37305c commit b769e33

File tree

16 files changed

+191
-42
lines changed

16 files changed

+191
-42
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
target-branch: devel
6+
schedule:
7+
interval: monthly

CMakePresets.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@
155155
"type": "BOOL",
156156
"value": "ON"
157157
},
158+
"PLUGIN_BEAMADAPTER_CUDA": {
159+
"type": "BOOL",
160+
"value": "ON"
161+
},
158162
"PLUGIN_SOFAMATRIX": {
159163
"type": "BOOL",
160164
"value": "ON"
@@ -171,6 +175,10 @@
171175
"type": "BOOL",
172176
"value": "ON"
173177
},
178+
"PLUGIN_SOFADISTANCEGRID_CUDA": {
179+
"type": "BOOL",
180+
"value": "ON"
181+
},
174182
"PLUGIN_GEOMAGIC": {
175183
"type": "BOOL",
176184
"value": "ON"
@@ -272,6 +280,10 @@
272280
"type": "BOOL",
273281
"value": "ON"
274282
},
283+
"PLUGIN_SOFASPHFLUID_CUDA": {
284+
"type": "BOOL",
285+
"value": "ON"
286+
},
275287
"PLUGIN_SOFASPHFLUID": {
276288
"type": "BOOL",
277289
"value": "ON"

Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ void BilateralLagrangianConstraint<DataTypes>::getConstraintResolution(const Con
277277
std::vector<ConstraintResolution*>& resTab,
278278
unsigned int& offset)
279279
{
280+
if (!d_activate.getValue()) return;
281+
280282
SOFA_UNUSED(cParams);
281283
const unsigned minp=std::min(d_m1.getValue().size(), d_m2.getValue().size());
282284

Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.inl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void FastTetrahedralCorotationalForceField<DataTypes>::createTetrahedronRestInfo
5151

5252
auto [lambda, mu] = Inherited::toLameParameters(_3DMat, youngModulusElement, poissonRatioElement);
5353

54-
typename DataTypes::Real volume,val;
54+
typename DataTypes::Real val;
5555
typename DataTypes::Coord point[4]; //shapeVector[4];
5656
const typename DataTypes::VecCoord restPosition=this->mstate->read(core::vec_id::read_access::restPosition)->getValue();
5757

@@ -63,20 +63,20 @@ void FastTetrahedralCorotationalForceField<DataTypes>::createTetrahedronRestInfo
6363
// store the point position
6464
for(j=0; j<4; ++j)
6565
point[j]=(restPosition)[t[j]];
66-
/// compute 6 times the rest volume
67-
volume=dot(cross(point[1]-point[0],point[2]-point[0]),point[0]-point[3]);
66+
67+
const auto tetrahedronVolume = -geometry::Tetrahedron::signedVolume(point[0],point[1],point[2],point[3]);
6868
/// store the rest volume
69-
my_tinfo.restVolume=volume/6;
70-
mu*=fabs(volume)/6;
71-
lambda*=fabs(volume)/6;
69+
my_tinfo.restVolume = tetrahedronVolume;
70+
mu *= fabs(tetrahedronVolume);
71+
lambda *= fabs(tetrahedronVolume);
7272

7373
// store shape vectors at the rest configuration
7474
for(j=0; j<4; ++j)
7575
{
7676
if ((j%2)==0)
77-
my_tinfo.shapeVector[j]=cross(point[(j+2)%4] - point[(j+1)%4],point[(j+3)%4] - point[(j+1)%4])/volume;
77+
my_tinfo.shapeVector[j] = cross(point[(j+2)%4] - point[(j+1)%4],point[(j+3)%4] - point[(j+1)%4])/(tetrahedronVolume * 6);
7878
else
79-
my_tinfo.shapeVector[j]= -cross(point[(j+2)%4] - point[(j+1)%4],point[(j+3)%4] - point[(j+1)%4])/volume;
79+
my_tinfo.shapeVector[j] = -cross(point[(j+2)%4] - point[(j+1)%4],point[(j+3)%4] - point[(j+1)%4])/(tetrahedronVolume * 6);
8080
}
8181

8282
/// compute the vertex stiffness of the linear elastic material, needed for addKToMatrix

Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.inl

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -390,21 +390,10 @@ void TetrahedralCorotationalFEMForceField<DataTypes>::computeMaterialStiffness(i
390390

391391
// divide by 36 times volumes of the element
392392
const VecCoord& X0=this->mstate->read(core::vec_id::read_access::restPosition)->getValue();
393+
const auto tetrahedronVolume = geometry::Tetrahedron::volume(
394+
X0[a], X0[b], X0[c], X0[d]);
393395

394-
Coord A = (X0)[b] - (X0)[a];
395-
Coord B = (X0)[c] - (X0)[a];
396-
Coord C = (X0)[d] - (X0)[a];
397-
Coord AB = cross(A, B);
398-
Real volumes6 = fabs( dot( AB, C ) );
399-
if (volumes6<0)
400-
{
401-
msg_error() << "Negative volume for tetra " << a << ',' << b << ',' << c << ',' << d << "> = " << volumes6 / 6;
402-
}
403-
// materialMatrix /= (volumes6);//*6 christian
404-
// @TODO: in TetrahedronFEMForceField, the stiffness matrix is divided by 6 compared to the code in TetrahedralCorotationalFEMForceField. Check which is the correct one...
405-
// FF: there is normally a factor 1/6v in the strain-displacement matrix. Times transpose makes 1/36v². Integrating across the volume multiplies by v, so the factor is 1/36v
406-
materialMatrix /= (volumes6*6);
407-
396+
materialMatrix /= tetrahedronVolume * 36;
408397
}
409398

410399
template<class DataTypes>

Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.inl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,11 @@ void TetrahedronFEMForceField<DataTypes>::computeMaterialStiffness(Index i, Inde
283283

284284
// divide by 36 times volumes of the element
285285
const VecCoord &initialPoints=d_initialPoints.getValue();
286-
Coord A = initialPoints[b] - initialPoints[a];
287-
Coord B = initialPoints[c] - initialPoints[a];
288-
Coord C = initialPoints[d] - initialPoints[a];
289-
Coord AB = cross(A, B);
290-
Real volumes6 = fabs( dot( AB, C ) );
286+
const auto tetrahedronVolume = geometry::Tetrahedron::volume(
287+
initialPoints[a], initialPoints[b], initialPoints[c], initialPoints[d]);
291288

292-
m_restVolume += volumes6/6;
293-
if (volumes6<0)
294-
{
295-
msg_error() << "Negative volume for tetra "<<i<<" <"<<a<<','<<b<<','<<c<<','<<d<<"> = "<<volumes6/6 ;
296-
}
297-
materialsStiffnesses[i] /= (volumes6*6); // 36*Volume in the formula
289+
m_restVolume += tetrahedronVolume;
290+
materialsStiffnesses[i] /= tetrahedronVolume * 36;
298291
}
299292

300293
template<class DataTypes>

Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangleFEMForceField.inl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ void TriangleFEMForceField<DataTypes>::computeMaterialStiffnesses()
204204
const Real Estrain = this->getYoungModulusInElement(i) / ((1 + _p) * (1 - 2 * _p));
205205
const Real Estress = this->getYoungModulusInElement(i) / (1 - _p * _p);
206206

207-
const Real triangleVolume = (Real)0.5 * d_thickness.getValue() * cross(p[b] - p[a], p[c] - p[a]).norm();
207+
const Real triangleArea = sofa::geometry::Triangle::area(p[a], p[b], p[c]);
208+
const Real triangleVolume = d_thickness.getValue() * triangleArea;
208209

209210
if (d_planeStrain.getValue() == true)
210211
{

Sofa/Component/Visual/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(HEADER_FILES
1515
${SOFACOMPONENTVISUAL_SOURCE_DIR}/TrailRenderer.h
1616
${SOFACOMPONENTVISUAL_SOURCE_DIR}/TrailRenderer.inl
1717
${SOFACOMPONENTVISUAL_SOURCE_DIR}/Visual3DText.h
18+
${SOFACOMPONENTVISUAL_SOURCE_DIR}/VisualBoundingBox.h
1819
${SOFACOMPONENTVISUAL_SOURCE_DIR}/VisualGrid.h
1920
${SOFACOMPONENTVISUAL_SOURCE_DIR}/VisualModelImpl.h
2021
${SOFACOMPONENTVISUAL_SOURCE_DIR}/VisualStyle.h
@@ -31,6 +32,7 @@ set(SOURCE_FILES
3132
${SOFACOMPONENTVISUAL_SOURCE_DIR}/RecordedCamera.cpp
3233
${SOFACOMPONENTVISUAL_SOURCE_DIR}/TrailRenderer.cpp
3334
${SOFACOMPONENTVISUAL_SOURCE_DIR}/Visual3DText.cpp
35+
${SOFACOMPONENTVISUAL_SOURCE_DIR}/VisualBoundingBox.cpp
3436
${SOFACOMPONENTVISUAL_SOURCE_DIR}/VisualGrid.cpp
3537
${SOFACOMPONENTVISUAL_SOURCE_DIR}/VisualModelImpl.cpp
3638
${SOFACOMPONENTVISUAL_SOURCE_DIR}/VisualStyle.cpp
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Authors: The SOFA Team and external contributors (see Authors.txt) *
19+
* *
20+
* Contact information: [email protected] *
21+
******************************************************************************/
22+
23+
#include <sofa/component/visual/VisualBoundingBox.h>
24+
#include <sofa/core/visual/VisualParams.h>
25+
#include <sofa/core/ObjectFactory.h>
26+
#include <sofa/defaulttype/VecTypes.h>
27+
28+
namespace sofa::component::visual
29+
{
30+
31+
void registerVisualBoundingBox(sofa::core::ObjectFactory* factory)
32+
{
33+
factory->registerObjects(core::ObjectRegistrationData("Display an Axis Aligned Bounding Box (AABB).")
34+
.add< VisualBoundingBox >());
35+
}
36+
37+
VisualBoundingBox::VisualBoundingBox()
38+
: d_color(initData(&d_color, sofa::type::RGBAColor::yellow(), "color", "Color of the lines of the box."))
39+
, d_thickness(initData(&d_thickness, 1.0f, "thickness", "Thickness of the lines of the box."))
40+
{
41+
42+
}
43+
44+
void VisualBoundingBox::doDrawVisual(const core::visual::VisualParams* vparams)
45+
{
46+
47+
const auto& bbox = f_bbox.getValue();
48+
vparams->drawTool()->disableLighting();
49+
vparams->drawTool()->setMaterial(d_color.getValue());
50+
vparams->drawTool()->drawBoundingBox(bbox.minBBox(), bbox.maxBBox(), d_thickness.getValue());
51+
}
52+
53+
} // namespace sofa::component::visual
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Authors: The SOFA Team and external contributors (see Authors.txt) *
19+
* *
20+
* Contact information: [email protected] *
21+
******************************************************************************/
22+
#pragma once
23+
#include <sofa/component/visual/config.h>
24+
25+
#include <sofa/core/visual/VisualModel.h>
26+
#include <sofa/type/RGBAColor.h>
27+
28+
namespace sofa::component::visual
29+
{
30+
/*
31+
* Display an Axis Orientated Bounding Box.
32+
*/
33+
class SOFA_COMPONENT_VISUAL_API VisualBoundingBox : public core::visual::VisualModel
34+
{
35+
public:
36+
SOFA_CLASS(VisualBoundingBox, core::visual::VisualModel);
37+
38+
VisualBoundingBox();
39+
~VisualBoundingBox() override = default;
40+
41+
Data<sofa::type::RGBAColor> d_color; ///< Color of the lines in the grid. default=yellow
42+
Data<float> d_thickness; ///< Thickness of the lines in the grid
43+
44+
private:
45+
void doDrawVisual(const core::visual::VisualParams*) override;
46+
47+
};
48+
49+
} // namespace sofa::component::visual

0 commit comments

Comments
 (0)