-
Notifications
You must be signed in to change notification settings - Fork 311
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
[all] Sofa add mechanical matrix mapper #721
Merged
guparan
merged 17 commits into
sofa-framework:master
from
SofaDefrost:Sofa_addMechanicalMatrixMapper
Sep 6, 2018
Merged
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e210b53
Revert "Remove unused function "renumberConstraintId""
EulalieCoevoet 81a609b
Merge remote-tracking branch 'upstream/master'
EulalieCoevoet ace853d
Merge remote-tracking branch 'upstream/master'
EulalieCoevoet 9d33c87
[simulation] ADD MechanicalMatrixMapper
ca0dd44
Remove option SOFA_WITH_ESPERIMENTAL_FEATURES
olivier-goury 56e37c8
[simulation] Move MechanicalMatrixMapper to module SofaGeneralAnimati…
3d0b261
[SofaGeneralAnimationLoop] RM useless includes
451aefe
[SofaGeneralAnimationLoop] Add test to init on component links
ac71b0e
[SofaGeneralAnimationLoop] Fix license date
0452e53
Add example using MechanicalMatrixMapper
olivier-goury 0c4a6dd
[SofaGeneralAnimationLoop] Fix problem at init
5ef9872
Merge branch 'Sofa_addMechanicalMatrixMapper' of https://github.com/S…
419ebf9
Update documentation and example location for MechanicalMatrixMapper
olivier-goury a14acf2
[SofaGeneralAnimationLoop] Clean MechanicalMatrixMapper
ed477cb
Add doc file next to MechanicalMatrixMapper example.
olivier-goury 05d3098
Remove renumberConstraintID modifications
olivier-goury af9f166
[SofaFramework] Delete useless file
guparan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
26 changes: 26 additions & 0 deletions
26
examples/Components/animationloop/MechanicalMatrixMapper.html
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,26 @@ | ||
<html> | ||
|
||
|
||
<body bgcolor="#F0F8FF"> | ||
|
||
<div id="contenu"> | ||
|
||
<h1>Mechanical matrix mapper</h1> | ||
|
||
<p>In this scene we demonstrate how to use the <FONT COLOR="#0B2161">MechanicalMatrixMapper</FONT> component. This component allows to map mechanical matrices (Stiffness, Mass) through a mapping. | ||
<p>This is needed in SOFA scenes having these two following particularities: | ||
<p> -- There are using a direct solver (e.g. SparseLDLSolver) that, unlike | ||
iterative solvers, need to build the mechanical matrices. | ||
<p> -- They involves ForceFields that implement addKToMatrix (i.e. that compute internal forces such as e.g. TetrahedronFEMForceField, | ||
TetrahedronHyperElasticityFEMForceField, but not ConstantForceField which only contributes to the right-hand side) and that | ||
ARE USED UNDER mappings. In this scene, the <FONT COLOR="#0B2161">HexaHedronFEMForceField</FONT> is used under a <FONT COLOR="#0B2161">SubsetMultiMapping</FONT> and a <FONT COLOR="#0B2161">RigidMapping</FONT>), and the MechanicalMatrixMapper is needed to map that ForceField to the degrees of freedom closer to the root in the scene graph. | ||
|
||
<p>Without this component, such a scene either crashes or gives unlogical behaviour. | ||
|
||
<br> | ||
|
||
</div> | ||
|
||
</body> | ||
|
||
</html> |
48 changes: 48 additions & 0 deletions
48
examples/Components/animationloop/MechanicalMatrixMapper.pyscn
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,48 @@ | ||
import Sofa | ||
|
||
def createScene(rootNode): | ||
|
||
rootNode.createObject('RequiredPlugin', name='ModelOrderReduction') | ||
rootNode.createObject('VisualStyle', displayFlags='showCollisionModels hideMappings showForceFields') | ||
|
||
meshDivision = rootNode.createChild('meshDivision') | ||
meshDivision.createObject('RegularGridTopology', name='topology', n=[2, 2, 4] , min=[-1, -1, -2], max=[1, 1, 2]) | ||
meshOfStructure = meshDivision.createObject('Mesh',name='beamMesh', src="@topology") | ||
meshDivision.createObject('MechanicalObject', template='Vec3d') | ||
boxFixed= meshDivision.createObject('BoxROI',template="Vec3d", name='box_roi_fix',box=[-1, -1, -2.05, 1, 1, -1.5] , position="@beamMesh.position" ) | ||
boxDeformable= meshDivision.createObject('BoxROI',template="Vec3d", name='box_roi_deformable',box=[-1, -1, -2.05, 1, 1, 1.5], position="@beamMesh.position" ) | ||
boxRigid= meshDivision.createObject('BoxROI',template="Vec3d", name='box_roi_rigid',box=[-1, -1, 1.500001, 1, 1, 2.05], position="@beamMesh.position") | ||
|
||
SolverNode= rootNode.createChild('SolverNode') | ||
SolverNode.createObject('EulerImplicit',verbose='false') | ||
SolverNode.createObject('SparseLDLSolver', name="ldlsolveur") | ||
SolverNode.createObject('MechanicalMatrixMapper', template='Vec3d,Rigid', object1='@./deformablePartNode/beamPart1Mech', object2='@./RigidNode/rigid1', nodeToParse='@./deformablePartNode/FEMNode') | ||
|
||
|
||
##### Deformable Part of the BEAM (Main Body) | ||
deformablePartNode= SolverNode.createChild('deformablePartNode') | ||
deformablePartNode.createObject('MechanicalObject', template='Vec3d',name='beamPart1Mech', position="@"+boxDeformable.getPathName()+".pointsInROI") | ||
|
||
##### Rigid Part of the BEAM (Top) | ||
RigidNode= SolverNode.createChild('RigidNode') | ||
RigidNode.createObject("MechanicalObject",template="Rigid",name="rigid1", position=[0, 0, 2, 0, 0, 0, 1], showObject=True, showObjectScale=0.5) | ||
RigidifiedNode= RigidNode.createChild('RigidifiedNode') | ||
|
||
RigidifiedNode.createObject("MechanicalObject",name="rigidMecha",template="Vec3d", position="@"+boxRigid.getPathName()+".pointsInROI") | ||
RigidifiedNode.createObject("RigidMapping",globalToLocalCoords="true") | ||
|
||
##### COMBINED BEAM | ||
FEMNode= deformablePartNode.createChild('FEMNode') | ||
RigidifiedNode.addChild(FEMNode) | ||
|
||
FEMNode.createObject('Mesh',name='meshInput',src="@"+meshOfStructure.getPathName()) | ||
FEMNode.createObject('MechanicalObject', template='Vec3d',name='beamMecha') | ||
FEMNode.createObject('HexahedronFEMForceField', name='HexaFF', src="@meshInput", poissonRatio=0.49, youngModulus=2000) | ||
FEMNode.createObject('RestShapeSpringsForceField', name='restShapeFF', points="@"+boxFixed.getPathName()+'.indices', stiffness=10000, angularStiffness=10000) | ||
FEMNode.createObject('UniformMass', totalmass=0.1) | ||
FEMNode.createObject('ConstantForceField', name='xMoins', indices=15, forces=[1000, 0, 0]) | ||
FEMNode.createObject("SubsetMultiMapping",name="subsetMapping",template="Vec3d,Vec3d", input="@../beamPart1Mech @../../RigidNode/RigidifiedNode/rigidMecha",output="@./beamMecha", indexPairs="0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 1 0 1 1 1 2 1 3") | ||
|
||
return rootNode | ||
|
||
|
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
77 changes: 77 additions & 0 deletions
77
modules/SofaGeneralAnimationLoop/MechanicalMatrixMapper.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,77 @@ | ||
/****************************************************************************** | ||
* SOFA, Simulation Open-Framework Architecture, version 1.0 RC 1 * | ||
* (c) 2006-2018 MGH, INRIA, USTL, UJF, CNRS * | ||
* * | ||
* This library 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 library 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 library; if not, write to the Free Software Foundation, * | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * | ||
******************************************************************************* | ||
* SOFA :: Modules * | ||
* * | ||
* Authors: The SOFA Team and external contributors (see Authors.txt) * | ||
* * | ||
* Contact information: contact@sofa-framework.org * | ||
******************************************************************************/ | ||
#include "MechanicalMatrixMapper.inl" | ||
#include <sofa/defaulttype/Vec3Types.h> | ||
#include <sofa/defaulttype/RigidTypes.h> | ||
#include <sofa/core/ObjectFactory.h> | ||
|
||
namespace sofa | ||
{ | ||
|
||
namespace component | ||
{ | ||
|
||
namespace interactionforcefield | ||
{ | ||
|
||
using namespace sofa::defaulttype; | ||
|
||
//////////////////////////////////////////// FACTORY ////////////////////////////////////////////// | ||
SOFA_DECL_CLASS(MechanicalMatrixMapper) | ||
|
||
int MechanicalMatrixMapperClass = core::RegisterObject("This component allows to map the stiffness (and mass) matrix through a mapping.") | ||
#ifdef SOFA_WITH_FLOAT | ||
.add< MechanicalMatrixMapper<Vec3fTypes, Rigid3fTypes> >() | ||
.add< MechanicalMatrixMapper<Vec3fTypes, Vec3fTypes> >() | ||
.add< MechanicalMatrixMapper<Vec1fTypes, Rigid3fTypes> >() | ||
.add< MechanicalMatrixMapper<Vec1fTypes, Vec1fTypes> >() | ||
#endif | ||
#ifdef SOFA_WITH_DOUBLE | ||
.add< MechanicalMatrixMapper<Vec3dTypes, Rigid3dTypes> >(true) | ||
.add< MechanicalMatrixMapper<Vec3dTypes, Vec3dTypes> >(true) | ||
.add< MechanicalMatrixMapper<Vec1dTypes, Rigid3dTypes> >(true) | ||
.add< MechanicalMatrixMapper<Vec1dTypes, Vec1dTypes> >(true) | ||
#endif | ||
; | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
#ifdef SOFA_WITH_DOUBLE | ||
template class MechanicalMatrixMapper<Vec3dTypes, Rigid3dTypes>; | ||
template class MechanicalMatrixMapper<Vec3dTypes, Vec3dTypes>; | ||
template class MechanicalMatrixMapper<Vec1dTypes, Rigid3dTypes>; | ||
template class MechanicalMatrixMapper<Vec1dTypes, Vec1dTypes>; | ||
#endif | ||
#ifdef SOFA_WITH_FLOAT | ||
template class MechanicalMatrixMapper<Vec3fTypes, Rigid3fTypes>; | ||
template class MechanicalMatrixMapper<Vec3fTypes, Vec3fTypes>; | ||
template class MechanicalMatrixMapper<Vec1fTypes, Rigid3fTypes>; | ||
template class MechanicalMatrixMapper<Vec1fTypes, Vec1fTypes>; | ||
#endif | ||
|
||
} // namespace forcefield | ||
|
||
} // namespace component | ||
|
||
} // namespace sofa |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please don't use serr/sout anymore...
but more fundamentally... a pure virtual method is ...pure specifically to force the object inheriting from the parent to not forget to implement them. Providing an empty implementation like this one sounds like skipping over the safeguard that was put in place so it compile and let the user handle the problem (which I doubt it can).
Don't we have a better way to handle those cases ?
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.
If the override is mandatory, a pure virtual function is the way to go. This compiler-bypassing behavior should not be allowed.
If the override is not mandatory, then non-virtual + msg_warning("You didn't override") seems nice.
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.
I agree with your Guillaume :)