コード例 #1
0
 def test_ModelPartOutput(self):
     settings = KratosMultiphysics.Parameters()
     model_part_output = operations.Create(settings)
     self.assertTrue(settings.Has('operation_type'))
     self.assertTrue(settings.Has('prefix'))
     self.assertEqual(settings['operation_type'].GetString(),
                      'model_part_output')
     with patch('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_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('core.operations.KratosHDF5.HDF5PartitionedModelPartIO',
                autospec=True) as p:
         model_part = _SurrogateModelPart()
         hdf5_file = MagicMock(spec=KratosHDF5.HDF5FileSerial)
         partitioned_model_part_output(model_part, hdf5_file)
         args, _ = p.call_args
         self.assertEqual(args[1], '/ModelData/model_part/1.23')
コード例 #3
0
 def test_PrimalBossakInput(self):
     settings = KratosMultiphysics.Parameters()
     settings.AddEmptyValue('operation_type').SetString(
         '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('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)
         p.assert_called_once()
         nodal_solution_step_bossak_io.ReadNodalResults.assert_called_once()
コード例 #4
0
 def test_ElementDataValueInput(self):
     settings = KratosMultiphysics.Parameters()
     settings.AddEmptyValue('operation_type').SetString(
         '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('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)
         p.assert_called_once()
         element_data_value_io.ReadElementResults.assert_called_once()
コード例 #5
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)