I have created two cylindrical meshes using PyVista with the goal of performing a modal analysis using PyAnsys on both the inner cylinder (shown in blue) and the outer cylinder (shown in grey). Where each of these cylinders have differing material properties and form part of a single model:
Mesh generation script:
import numpy as np
import pyvista as pv
def create_mesh(inner_radius, thickness, height, z_res, c_res, r_res_pipe, r_res_fluid):
# Create a pipe mesh using a structured grid using the specified mesh density:
outer_radius = inner_radius + thickness
# Create a list of radial divisions between the inner and outer radii:
if r_res_pipe % 2 != 0:
r_res_pipe = r_res_pipe + 1 # radial resolution must be even to accommodate array reshaping
radial_divisions = np.linspace(inner_radius, outer_radius, r_res_pipe)
grid = pv.CylinderStructured(
radius=radial_divisions, height=height, theta_resolution=c_res, z_resolution=z_res
)
grid.points = grid.points
original_mesh = pv.UnstructuredGrid(grid)
pipe_mesh = original_mesh
points = pipe_mesh.points.reshape(z_res, c_res, r_res_pipe * 3)
points[:, c_res - 1, :] = points[:, 0, :]
pipe_mesh.points = points.reshape(z_res * (c_res) * 2, int(r_res_pipe + r_res_pipe / 2))
pipe_mesh.plot(color='grey', show_edges=True)
# Create a fluid mesh using a structured grid based on the pipe dimensions:
# Create a list of radial divisions between the inner and outer radii:
if r_res_fluid % 2 != 0:
r_res_fluid = r_res_fluid + 1 # radial resolution must be even to accommodate array reshaping
radial_divisions = np.linspace(0.0, inner_radius, r_res_fluid)
grid = pv.CylinderStructured(
radius=radial_divisions, height=height, theta_resolution=c_res, z_resolution=z_res
)
grid.points = grid.points
original_mesh = pv.UnstructuredGrid(grid)
fluid_mesh = original_mesh
points = fluid_mesh.points.reshape(z_res, c_res, r_res_fluid * 3)
points[:, c_res - 1, :] = points[:, 0, :]
fluid_mesh.points = points.reshape(z_res * (c_res) * 2, int(r_res_fluid + r_res_fluid / 2))
fluid_mesh.plot(color='blue', show_edges=True)
return pipe_mesh, fluid_mesh
In order to do this, I need to share the topology between the grey and blue meshes. Is there an MAPDL command that can handle this?
I have looked through the documentation, but cannot find anything that can do this (however, my understanding of the library is not great and I might be missing something).