def test_one_mesh(self): mesh_description_3D = {"elements": {"Hexa": {"MyFancyElement": 0}}} meshes = [ create_kratos_input_tui.SalomeMesh(self.mesh_hexa, mesh_description_3D, "domain") ] model_part = create_kratos_input_tui.CreateModelPart(meshes) self.assertEqual(model_part.NumberOfSubModelParts(), 1) self.assertEqual(model_part.NumberOfNodes(), 729) self.assertEqual(model_part.NumberOfElements(), 512) self.assertEqual(model_part.NumberOfConditions(), 0) self.assertEqual(model_part.NumberOfProperties(), 1) smp = model_part.GetSubModelPart("domain") self.assertEqual(smp.NumberOfSubModelParts(), 0) self.assertEqual(smp.NumberOfNodes(), 729) self.assertEqual(smp.NumberOfElements(), 512) self.assertEqual(smp.NumberOfConditions(), 0) self.assertEqual(smp.NumberOfProperties(), 1)
sys.path.append("../../") # adding root folder of plugin to path import create_kratos_input_tui from kratos_salome_plugin.write_mdpa import WriteMdpa # fluid mesh fluid_mesh_description_domain = { "elements" : {"Triangle" : {"Element2D3N" : 1} } } fluid_mesh_description_wall = { "conditions" : {"Edge" : {"WallCondition2D2N" : 0} } } meshes_fl = [ create_kratos_input_tui.SalomeMesh(fluid_mesh, fluid_mesh_description_domain, "Parts_Fluid") ] for name, sub_mesh in fluid_sub_meshes.items(): meshes_fl.append(create_kratos_input_tui.SalomeMesh(sub_mesh, fluid_mesh_description_wall, name)) model_part_fluid = create_kratos_input_tui.CreateModelPart(meshes_fl) props = model_part_fluid.GetProperties(1) props.SetValue("DENSITY", 956.0) props.SetValue("DYNAMIC_VISCOSITY", 0.145) mdpa_info_fluid = "mdpa for fluid model FSI Mok" WriteMdpa(model_part_fluid, "Mok_CFD", mdpa_info_fluid) # structure mesh structure_mesh_description_domain = { "elements" : {"Quadrangle" : {"TotalLagrangianElement2D4N" : 0} } } meshes_str = [ create_kratos_input_tui.SalomeMesh(structure_mesh, structure_mesh_description_domain, "Parts_Structure") ] for name, sub_mesh in structure_sub_meshes.items():
def test_multiple_meshes(self): mesh_description_3D = { "elements": { "Hexa": { "MyFancyElement": 1 } }, "conditions": { "Hexa": { "VolumeLoadCondition": 0 } } } mesh_description_1D = { "conditions": { "Edge": { "LineSupportDisp": 63, "LineSupportRot": 7 } } } mesh_description_0D = {"elements": {"Ball": {"PointMassBall": 4}}} meshes = [ create_kratos_input_tui.SalomeMesh(self.mesh_hexa, mesh_description_3D, "domain"), create_kratos_input_tui.SalomeMesh(self.group_hexa_edges, mesh_description_1D, "supports"), create_kratos_input_tui.SalomeMesh(self.group_hexa_ball_elements, mesh_description_0D, "domain.point_masses") ] model_part = create_kratos_input_tui.CreateModelPart(meshes) self.assertEqual(model_part.NumberOfSubModelParts(), 2) self.assertEqual(model_part.NumberOfNodes(), 729) self.assertEqual(model_part.NumberOfElements(), 518) self.assertEqual(model_part.NumberOfConditions(), 704) self.assertEqual(model_part.NumberOfProperties(), 5) smp_domain = model_part.GetSubModelPart("domain") self.assertEqual(smp_domain.NumberOfNodes(), 729) self.assertEqual(smp_domain.NumberOfElements(), 518) self.assertEqual(smp_domain.NumberOfConditions(), 512) self.assertEqual(smp_domain.NumberOfSubModelParts(), 1) self.assertEqual(smp_domain.NumberOfProperties(), 3) smp_point_mass = smp_domain.GetSubModelPart("point_masses") self.assertEqual(smp_point_mass.NumberOfSubModelParts(), 0) self.assertEqual(smp_point_mass.NumberOfNodes(), 6) self.assertEqual(smp_point_mass.NumberOfElements(), 6) self.assertEqual(smp_point_mass.NumberOfConditions(), 0) self.assertEqual(smp_point_mass.NumberOfProperties(), 1) smp_supports = model_part.GetSubModelPart("supports") self.assertEqual(smp_supports.NumberOfSubModelParts(), 0) self.assertEqual(smp_supports.NumberOfNodes(), 92) self.assertEqual(smp_supports.NumberOfElements(), 0) self.assertEqual(smp_supports.NumberOfConditions(), 192) self.assertEqual(smp_supports.NumberOfProperties(), 2)