diff --git a/splib/mechanics/mass.py b/splib/mechanics/mass.py index a3ee1fe2..c003c3e6 100644 --- a/splib/mechanics/mass.py +++ b/splib/mechanics/mass.py @@ -6,18 +6,18 @@ # TODO : use the massDensity ONLY and deduce totalMass if necessary from it + volume @ReusableMethod -def addMass(node, elem:ElementType, totalMass=DEFAULT_VALUE, massDensity=DEFAULT_VALUE, lumping=DEFAULT_VALUE, **kwargs): +def addMass(node, elem:ElementType, totalMass=DEFAULT_VALUE, massDensity=DEFAULT_VALUE, lumping=DEFAULT_VALUE, topology=DEFAULT_VALUE, **kwargs): if (not isDefault(totalMass)) and (not isDefault(massDensity)) : print("[warning] You defined the totalMass and the massDensity in the same time, only taking massDensity into account") del kwargs["massDensity"] - # if(elem !=ElementType.POINTS and elem !=ElementType.EDGES): - # node.addObject("MeshMatrixMass",name="mass", totalMass=totalMass, massDensity=massDensity, lumping=lumping, **kwargs) - # else: - # if (not isDefault(massDensity)) : - # print("[warning] mass density can only be used on a surface or volumetric topology. Please use totalMass instead") - # if (not isDefault(lumping)) : - # print("[warning] lumping can only be set for surface or volumetric topology") + if(elem !=ElementType.POINTS and elem !=ElementType.EDGES): + node.addObject("MeshMatrixMass",name="mass", totalMass=totalMass, massDensity=massDensity, lumping=lumping, topology=topology, **kwargs) + else: + if (not isDefault(massDensity)) : + print("[warning] mass density can only be used on a surface or volumetric topology. Please use totalMass instead") + if (not isDefault(lumping)) : + print("[warning] lumping can only be set for surface or volumetric topology") - node.addObject("UniformMass",name="mass", totalMass=totalMass, **kwargs) + node.addObject("UniformMass",name="mass", totalMass=totalMass, topology=topology,**kwargs) diff --git a/stlib/materials/deformable.py b/stlib/materials/deformable.py index 69a9558b..a24763df 100644 --- a/stlib/materials/deformable.py +++ b/stlib/materials/deformable.py @@ -14,7 +14,12 @@ class DeformableBehaviorParameters(MaterialParameters): parameters : list[float] = dataclasses.field(default_factory=lambda: [1000, 0.45]) # young modulus, poisson ratio def __addDeformableMaterial(node): - addMass(node, node.parameters.elementType, massDensity=node.parameters.massDensity, lumping=node.parameters.massLumping) + + massKwargs = {} + if node.parameters.elementType != ElementType.EDGES: #If we use the MeshMatrixMass, then the mass will need us to specify the mstate to use + massKwargs["geometryState"] = "@States" + + addMass(node, node.parameters.elementType, massDensity=node.parameters.massDensity, lumping=node.parameters.massLumping, topology="@../Geometry/container", mass=massKwargs) # TODO : change this with inheritance if(node.parameters.constitutiveLawType == ConstitutiveLaw.HYPERELASTIC): addHyperelasticity(node, node.parameters.elementType, node.parameters.parameters, topology="@../Geometry/container")