def compareResults(reference_file, results_file): settings_check_process = KratosMultiphysics.Parameters(""" { "reference_file_name" : "", "output_file_name" : "", "comparison_type" : "dat_file", "remove_output_file" : true, "tolerance" : 1e-6 } """) settings_check_process["reference_file_name"].SetString(reference_file) settings_check_process["output_file_name"].SetString(results_file) # creating a dummy model check_process = CompareTwoFilesCheckProcess(settings_check_process) check_process.ExecuteInitialize() check_process.ExecuteBeforeSolutionLoop() check_process.ExecuteInitializeSolutionStep() check_process.ExecuteFinalizeSolutionStep() check_process.ExecuteBeforeOutputStep() check_process.ExecuteAfterOutputStep() check_process.ExecuteFinalize()
def test_PostprocessEigenvaluesProcess(self): test_model = KratosMultiphysics.Model() model_part = KratosMultiphysics.ModelPart("computing_domain") model_part.AddNodalSolutionStepVariable( KratosMultiphysics.DISPLACEMENT) model_part.AddNodalSolutionStepVariable(KratosMultiphysics.REACTION) model_part.AddNodalSolutionStepVariable(KratosMultiphysics.ROTATION) model_part.AddNodalSolutionStepVariable(KratosMultiphysics.TORQUE) CreateNodes(model_part) # adding dofs is needed for the process internally KratosMultiphysics.VariableUtils().AddDof( KratosMultiphysics.DISPLACEMENT_X, KratosMultiphysics.REACTION_X, model_part) KratosMultiphysics.VariableUtils().AddDof( KratosMultiphysics.DISPLACEMENT_Y, KratosMultiphysics.REACTION_Y, model_part) KratosMultiphysics.VariableUtils().AddDof( KratosMultiphysics.DISPLACEMENT_Z, KratosMultiphysics.REACTION_Z, model_part) KratosMultiphysics.VariableUtils().AddDof( KratosMultiphysics.ROTATION_X, KratosMultiphysics.TORQUE_X, model_part) KratosMultiphysics.VariableUtils().AddDof( KratosMultiphysics.ROTATION_Y, KratosMultiphysics.TORQUE_Y, model_part) KratosMultiphysics.VariableUtils().AddDof( KratosMultiphysics.ROTATION_Z, KratosMultiphysics.TORQUE_Z, model_part) test_model.AddModelPart(model_part) # set EigenValues and -Vectors num_eigenvalues = 4 eigenval_vector = GetEigenValueVector(num_eigenvalues) model_part.ProcessInfo[ StructuralMechanicsApplication.EIGENVALUE_VECTOR] = eigenval_vector for node in model_part.Nodes: node.SetValue(StructuralMechanicsApplication.EIGENVECTOR_MATRIX, GetEigenVectorMatrix(num_eigenvalues, node.Id)) # Use the process # here the minimum settings are specified to test the default values! settings_eigen_process = KratosMultiphysics.Parameters( """{"result_file_format_use_ascii" : true}""") post_eigen_process = PostProcessEigenvaluesProcess( test_model, settings_eigen_process) post_eigen_process.ExecuteInitialize() post_eigen_process.ExecuteBeforeSolutionLoop() post_eigen_process.ExecuteInitializeSolutionStep() post_eigen_process.ExecuteFinalizeSolutionStep() post_eigen_process.ExecuteBeforeOutputStep() post_eigen_process.ExecuteAfterOutputStep() post_eigen_process.ExecuteFinalize() # check the results settings_check_process = KratosMultiphysics.Parameters(""" { "reference_file_name" : "", "output_file_name" : "", "remove_output_file" : true, "comparison_type" : "post_res_file" } """) settings_check_process["reference_file_name"].SetString( GetFilePath("test_postprocess_eigenvalues_process.ref")) settings_check_process["output_file_name"].SetString( "Structure_EigenResults_0.post.res") check_process = CompareTwoFilesCheckProcess(test_model, settings_check_process) check_process.ExecuteInitialize() check_process.ExecuteBeforeSolutionLoop() check_process.ExecuteInitializeSolutionStep() check_process.ExecuteFinalizeSolutionStep() check_process.ExecuteBeforeOutputStep() check_process.ExecuteAfterOutputStep() check_process.ExecuteFinalize()