def tearDown(self): with unittest.WorkFolderScope(self.work_folder, __file__): DeleteFileIfExisting(self.input_file+"_x.mdpa") DeleteFileIfExisting(self.input_file+"_y.mdpa") if not self.print_output: DeleteFileIfExisting("adjoint_diffusion_test.post.lst") DeleteFileIfExisting("diffusion_test_primal.post.bin") DeleteFileIfExisting("diffusion_test_adjoint.post.bin")
def __call__(self, model_part, hdf5_file): file_path, file_name = os.path.split(hdf5_file.GetFileName()) time_prefix = file_name.replace(".h5", "") + "-" current_time = model_part.ProcessInfo[KratosMultiphysics.TIME] if file_path == "": file_path = "." # os.listdir fails with empty path for name in os.listdir(file_path): if name.startswith(time_prefix): file_time = float(name.replace(".h5", "")[len(time_prefix):]) if file_time > current_time: DeleteFileIfExisting(os.path.join(file_path, name))
def test_ping_pong(self): self._createTest("ping_pong_test", "cosim_ping_pong_parameters") CoSimulationAnalysis(self.cosim_parameters).Run() DeleteFileIfExisting('ping.log') DeleteFileIfExisting('pong.log') DeleteFileIfExisting('EMPIRE_datafield_pong_send_data.dat') DeleteFileIfExisting('EMPIRE_datafield_ping_send_data.dat') DeleteFileIfExisting('EMPIRE_datafield_pong_recv_data.dat') DeleteFileIfExisting('EMPIRE_datafield_ping_recv_data.dat')
def ComputeSensitivity(node_ids, step_size, kratos_parameters, drag_direction, drag_model_part_name, primal_problem_solving_method): FiniteDifferenceBodyFittedDragShapeSensitivityAnalysis._AddResponseFunctionOutput( kratos_parameters, drag_model_part_name) output_file_name = drag_model_part_name + "_drag.dat" def compute_drag(kratos_parameters): primal_problem_solving_method(kratos_parameters) return FiniteDifferenceBodyFittedDragShapeSensitivityAnalysis._GetTimeAveragedDrag( drag_direction, output_file_name) sensitivities = ComputeFiniteDifferenceSensitivity( node_ids, step_size, kratos_parameters, compute_drag) DeleteFileIfExisting(output_file_name) return sensitivities
def ComputeSensitivity(node_ids, step_size, kratos_parameters, norm_model_part_name, primal_problem_solving_method, primal_output_process_inclusion_method, is_steady = False): FiniteDifferenceVelocityPressureNormSquareShapeSensitivityAnalysis._AddResponseFunctionOutput( kratos_parameters, norm_model_part_name) def compute_drag(kratos_parameters): primal_problem_solving_method(kratos_parameters) return FiniteDifferenceVelocityPressureNormSquareShapeSensitivityAnalysis._ObjectiveValueEvaluation(is_steady) sensitivities = ComputeFiniteDifferenceSensitivity(node_ids, step_size, kratos_parameters, compute_drag, primal_output_process_inclusion_method) DeleteFileIfExisting( "velocity_pressure_norm_square_response_output.dat") return sensitivities
def DeleteH5Files(): for name in os.listdir(): if name.endswith(".h5"): DeleteFileIfExisting(name)
def tearDown(self): DeleteFileIfExisting("kratos.h5") DeleteFileIfExisting("kratos-1.0.h5")
def tearDown(self): DeleteFileIfExisting(self.fluid_input_file+'.time') DeleteFileIfExisting(self.structure_input_file+'.time')