Skip to content

Commit

Permalink
Demos added in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
niravshah241 committed Aug 1, 2024
1 parent e0c6169 commit b974f15
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions demo/3_airfoil_displacement/linear_elastic_airfoil_deformation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import numpy as np
import matplotlib.pyplot as plt

from mpi4py import MPI

Expand All @@ -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")
Expand All @@ -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)

Expand Down

0 comments on commit b974f15

Please sign in to comment.