diff --git a/demo/3_airfoil_displacement/linear_elastic_airfoil_deformation.py b/demo/3_airfoil_displacement/linear_elastic_airfoil_deformation.py index 702d72a..2d24a39 100644 --- a/demo/3_airfoil_displacement/linear_elastic_airfoil_deformation.py +++ b/demo/3_airfoil_displacement/linear_elastic_airfoil_deformation.py @@ -1,6 +1,5 @@ import os import numpy as np -import matplotlib.pyplot as plt from mpi4py import MPI @@ -20,21 +19,29 @@ # MPI communicator for mesh mesh_comm = MPI.COMM_WORLD # Read mesh from .msh file -mesh, cell_tags, facet_tags = dolfinx.io.gmshio.read_from_msh(os.path.join(dir,"mesh_data/mesh.msh"), mesh_comm, gmsh_model_rank, gdim=gdim) +mesh, cell_tags, facet_tags = \ + dolfinx.io.gmshio.read_from_msh(os.path.join(dir, "mesh_data/mesh.msh"), + mesh_comm, gmsh_model_rank, gdim=gdim) # Store reference mesh -with dolfinx.io.XDMFFile(mesh.comm, os.path.join(dir,"mesh_data/reference_mesh.xdmf"),"w") as reference_mesh_file: +with dolfinx.io.XDMFFile(mesh.comm, + os.path.join(dir, "mesh_data/reference_mesh.xdmf"), + "w") as reference_mesh_file: reference_mesh_file.write_mesh(mesh) # Mesh deformation based on displacement boundary of the obstacle + + def bc_obstacle(x): # Scaling the obstacle in x direction with fixed starting point - + # Version 2: (0.2 * x[0], 0.0 * x[1]) return (0.1 * x[0], 0.0 * x[1]) + def bc_wall(x): - return ( 0.0 * x[0], 0.0 * x[1]) + return (0.0 * x[0], 0.0 * x[1]) + if mesh.comm.Get_rank() == 0: print("Mesh points before deformation") @@ -47,11 +54,12 @@ def bc_wall(x): nu = [0.3] # Mesh deformation with reset_reference=True -with LinearElasticMeshMotion(mesh, cell_tags,facet_tags, [1,2], - [bc_wall,bc_obstacle],E,nu, reset_reference=True, - is_deformation=True): +with LinearElasticMeshMotion(mesh, cell_tags, facet_tags, [1, 2], + [bc_wall, bc_obstacle], E, nu, + reset_reference=True, is_deformation=True): # Store deformed mesh - with dolfinx.io.XDMFFile(mesh.comm, os.path.join(dir,"mesh_data/linear_elastic_deformed_mesh.xdmf"), + with dolfinx.io.XDMFFile(mesh.comm, os.path.join(dir, + "mesh_data/linear_elastic_deformed_mesh.xdmf"), "w") as deformed_mesh_file: deformed_mesh_file.write_mesh(mesh)