Пример #1
0
 def test_ModelPartOutput(self):
     settings = ParametersWrapper()
     model_part_output = operations.Create(settings)
     self.assertTrue(settings.Has('operation_type'))
     self.assertTrue(settings.Has('prefix'))
     self.assertEqual(settings['operation_type'], 'model_part_output')
     with patch('KratosMultiphysics.HDF5Application.core.operations.KratosHDF5.HDF5ModelPartIO', autospec=True) as p:
         model_part_io = p.return_value
         model_part = _SurrogateModelPart()
         hdf5_file = MagicMock(spec=KratosHDF5.HDF5FileSerial)
         model_part_output(model_part, hdf5_file)
         p.assert_called_once_with(hdf5_file, '/ModelData')
         model_part_io.WriteModelPart.assert_called_once_with(model_part)
Пример #2
0
 def test_PrimalBossakInput(self):
     settings = ParametersWrapper()
     settings['operation_type'] = 'primal_bossak_input'
     primal_bossak_input = operations.Create(settings)
     self.assertTrue(settings.Has('prefix'))
     self.assertTrue(settings.Has('list_of_variables'))
     self.assertTrue(settings['list_of_variables'].IsArray())
     self.assertIsInstance(primal_bossak_input, operations.VariableIO)
     with patch('KratosMultiphysics.HDF5Application.core.operations.KratosHDF5.HDF5NodalSolutionStepBossakIO', autospec=True) as p:
         nodal_solution_step_bossak_io = p.return_value
         model_part = _SurrogateModelPart()
         hdf5_file = MagicMock(spec=KratosHDF5.HDF5FileSerial)
         primal_bossak_input(model_part, hdf5_file)
         self.assertEqual(p.call_count, 1)
         self.assertEqual(nodal_solution_step_bossak_io.ReadNodalResults.call_count, 1)
Пример #3
0
 def test_ElementDataValueInput(self):
     settings = ParametersWrapper()
     settings['operation_type'] = 'element_data_value_input'
     element_data_value_input = operations.Create(settings)
     self.assertTrue(settings.Has('prefix'))
     self.assertTrue(settings.Has('list_of_variables'))
     self.assertTrue(settings['list_of_variables'].IsArray())
     self.assertIsInstance(element_data_value_input, operations.VariableIO)
     with patch('KratosMultiphysics.HDF5Application.core.operations.KratosHDF5.HDF5ElementDataValueIO', autospec=True) as p:
         element_data_value_io = p.return_value
         model_part = _SurrogateModelPart()
         hdf5_file = MagicMock(spec=KratosHDF5.HDF5FileSerial)
         element_data_value_input(model_part, hdf5_file)
         self.assertEqual(p.call_count, 1)
         self.assertEqual(element_data_value_io.ReadElementResults.call_count, 1)
Пример #4
0
 def test_ModelPartOutput_NonTerminalPrefix(self):
     settings = ParametersWrapper('''
         {
             "operation_type": "model_part_output",
             "prefix": "/ModelData/<model_part_name>/<time>",
             "time_format": "0.2f"
         }
         ''')
     model_part_output = operations.Create(settings)
     with patch('KratosMultiphysics.HDF5Application.core.operations.KratosHDF5.HDF5ModelPartIO', autospec=True) as p:
         model_part = _SurrogateModelPart()
         hdf5_file = MagicMock(spec=KratosHDF5.HDF5FileSerial)
         model_part_output(model_part, hdf5_file)
         args, _ = p.call_args
         self.assertEqual(args[1], '/ModelData/model_part/1.23')
Пример #5
0
 def test_PartitionedModelPartOutput(self):
     settings = ParametersWrapper()
     settings['operation_type'] = 'partitioned_model_part_output'
     partitioned_model_part_output = operations.Create(settings)
     self.assertTrue(settings.Has('operation_type'))
     self.assertTrue(settings.Has('prefix'))
     with patch(
             'KratosMultiphysics.HDF5Application.core.operations.KratosHDF5.HDF5PartitionedModelPartIO'
     ) as p:
         partitioned_model_part_io = p.return_value
         model_part = test_hdf5_core._SurrogateModelPart()
         hdf5_file = MagicMock(spec=KratosHDF5.HDF5FileParallel)
         partitioned_model_part_output(model_part, hdf5_file)
         p.assert_called_once_with(hdf5_file, '/ModelData')
         partitioned_model_part_io.WriteModelPart.assert_called_once_with(
             model_part)
Пример #6
0
 def test_NodalDataValueInput(self):
     settings = KratosMultiphysics.Parameters()
     settings.AddEmptyValue('operation_type').SetString(
         'nodal_data_value_input')
     nodal_data_value_input = operations.Create(settings)
     self.assertTrue(settings.Has('prefix'))
     self.assertTrue(settings.Has('list_of_variables'))
     self.assertTrue(settings['list_of_variables'].IsArray())
     self.assertIsInstance(nodal_data_value_input, operations.VariableIO)
     with patch('KratosMultiphysics.HDF5Application.core.operations.KratosHDF5.HDF5NodalDataValueIO', autospec=True) as p:
         nodal_data_value_io = p.return_value
         model_part = _SurrogateModelPart()
         hdf5_file = MagicMock(spec=KratosHDF5.HDF5FileSerial)
         nodal_data_value_input(model_part, hdf5_file)
         self.assertEqual(p.call_count, 1)
         self.assertEqual(nodal_data_value_io.ReadNodalResults.call_count, 1)
Пример #7
0
 def test_NodalFlagValueOutput(self):
     settings = ParametersWrapper()
     settings['operation_type'] = 'nodal_flag_value_output'
     nodal_flag_value_output = operations.Create(settings)
     self.assertTrue(settings.Has('prefix'))
     self.assertTrue(settings.Has('list_of_variables'))
     self.assertTrue(settings['list_of_variables'].IsArray())
     self.assertIsInstance(nodal_flag_value_output, operations.VariableIO)
     with patch(
             'KratosMultiphysics.HDF5Application.core.operations.KratosHDF5.HDF5NodalFlagValueIO',
             autospec=True) as p:
         nodal_flag_value_io = p.return_value
         model_part = _SurrogateModelPart()
         hdf5_file = MagicMock(spec=KratosHDF5.HDF5FileSerial)
         nodal_flag_value_output(model_part, hdf5_file)
         self.assertEqual(p.call_count, 1)
         self.assertEqual(nodal_flag_value_io.WriteNodalFlags.call_count, 1)
Пример #8
0
 def test_PartitionedModelPartOutput_NonTerminalPrefix(self):
     settings = KratosMultiphysics.Parameters('''
         {
             "operation_type": "partitioned_model_part_output",
             "prefix": "/ModelData/<identifier>/<time>",
             "time_format": "0.2f"
         }
         ''')
     partitioned_model_part_output = operations.Create(settings)
     with patch(
             'KratosMultiphysics.HDF5Application.core.operations.KratosHDF5.HDF5PartitionedModelPartIO',
             autospec=True) as p:
         model_part = test_hdf5_core._SurrogateModelPart()
         hdf5_file = MagicMock(spec=KratosHDF5.HDF5FileParallel)
         partitioned_model_part_output(model_part, hdf5_file)
         args, _ = p.call_args
         self.assertEqual(args[1], '/ModelData/model_part/1.23')
Пример #9
0
 def test_CreateNonExistingOperation(self):
     settings = ParametersWrapper()
     settings['operation_type'] = 'abcdefg'
     with self.assertRaisesRegex(ValueError, r'"operation_type" has invalid value "abcdefg"'):
         operations.Create(settings)
Пример #10
0
 def test_CreateNonExistingOperation(self):
     settings = KratosMultiphysics.Parameters()
     settings.AddEmptyValue('operation_type').SetString('abcdefg')
     with self.assertRaisesRegex(ValueError, r'"operation_type" has invalid value "abcdefg"'):
         operations.Create(settings)