Skip to content

Commit

Permalink
Adding test + doc
Browse files Browse the repository at this point in the history
  • Loading branch information
loumalouomega committed Sep 20, 2023
1 parent 063a668 commit 1d8c57d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kratos/tests/test_model_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
import KratosMultiphysics

class TestModelPart(KratosUnittest.TestCase):
"""
This class defines a set of unit tests for the ModelParts. ModelParts are hierarchical structures within the Kratos simulation framework that allow for organizing and managing various aspects of a computational model, such as nodes, elements, conditions, constraints, and subdomains.
The tests within this class cover a range of ModelPart-related operations, including the creation of ModelParts, retrieval of parent and root ModelParts, the creation and removal of sub-model parts, and verification of ModelPart hierarchy and structure.
By running these tests, it is possible to ensure that the ModelPart management features in KratosMultiphysics are functioning as expected, facilitating the setup and manipulation of complex computational models for various engineering and scientific simulations.
"""

def test_model_part_sub_model_parts(self):
current_model = KratosMultiphysics.Model()

Expand Down Expand Up @@ -910,6 +918,8 @@ def test_model_part_master_slave_constraint(self):

c1 = KratosMultiphysics.MasterSlaveConstraint(10)
model_part.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 1, n1, KratosMultiphysics.PRESSURE, n2, KratosMultiphysics.PRESSURE, 0.5, 0.0)
self.assertTrue(model_part.HasMasterSlaveConstraint(1))
self.assertFalse(model_part.HasMasterSlaveConstraint(2))

model_part.AddMasterSlaveConstraint(c1)

Expand All @@ -925,6 +935,8 @@ def test_model_part_master_slave_constraint(self):
subsub1 = sub1.CreateSubModelPart("subsub1")

ss1 = subsub1.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", 2, n1, KratosMultiphysics.PRESSURE, n2, KratosMultiphysics.PRESSURE, 0.5, 0.0)
self.assertTrue(model_part.HasMasterSlaveConstraint(1))
self.assertTrue(model_part.HasMasterSlaveConstraint(2))

self.assertTrue(ss1 in subsub1.MasterSlaveConstraints)
self.assertTrue(ss1 in sub1.MasterSlaveConstraints)
Expand Down Expand Up @@ -993,4 +1005,5 @@ def test_remove_nodes(self):
self.assertEqual(model_part.NumberOfNodes(0), 4)

if __name__ == '__main__':
KratosMultiphysics.Logger.GetDefaultOutput().SetSeverity(KratosMultiphysics.Logger.Severity.WARNING)
KratosUnittest.main()

0 comments on commit 1d8c57d

Please sign in to comment.