Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions splib/mechanics/mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

7 changes: 6 additions & 1 deletion stlib/materials/deformable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading