def test_import_cal_file(): """Test the importation of legacy Nemoh.cal files.""" current_file_path = os.path.dirname(os.path.abspath(__file__)) # Non symmetrical body cal_file_path = os.path.join(current_file_path, "Nemoh_verification_cases", "NonSymmetrical", "Nemoh.cal") problems = import_cal_file(cal_file_path) assert len(problems) == 6 * 41 + 41 for problem in problems: assert problem.rho == 1000.0 assert problem.g == 9.81 assert problem.depth == np.infty assert isinstance(problem.body, FloatingBody) assert problem.body.nb_dofs == 6 assert problem.body.mesh.nb_vertices == 351 assert problem.body.mesh.nb_faces == 280 assert problem.omega in np.linspace(0.1, 2.0, 41) if isinstance(problem, DiffractionProblem): assert problem.wave_direction == 0.0 # Symmetrical cylinder cal_file_path = os.path.join(current_file_path, "Nemoh_verification_cases", "Cylinder", "Nemoh.cal") problems = import_cal_file(cal_file_path) assert len(problems) == 6 * 2 + 2 for problem in problems: assert problem.rho == 1000.0 assert problem.g == 9.81 assert problem.depth == np.infty assert isinstance(problem.body.mesh, ReflectionSymmetricMesh) assert isinstance(problem.body.mesh[0], Mesh) assert problem.body.nb_dofs == 6 # assert problem.body.mesh.nb_vertices == 2*540 assert problem.body.mesh.nb_faces == 2 * 300 assert problem.omega == 0.1 or problem.omega == 2.0 if isinstance(problem, DiffractionProblem): assert problem.wave_direction == 0.0
def main(): args = parser.parse_args() for paramfile in args.paramfiles: problems = import_cal_file(paramfile) solver = BEMSolver() results = [solver.solve(pb) for pb in problems] data = assemble_dataset(results) print(data) results_directory = os.path.join(os.path.dirname(paramfile), 'results') try: os.mkdir(results_directory) except FileExistsError: LOG.warning( "The 'results' directory already exists. You might be overwriting existing data." ) LOG.info("Write results in legacy tecplot format.") write_dataset_as_tecplot_files(results_directory, data)