Mesh generator example notebook
.. _mesh_processer_test:
import pyvista as pv
import numpy as np
import sys
import os
pv.global_theme.allow_empty_mesh = True
import subprocess
def find_git_root(path=None):
try:
# If no path is provided, use the current working directory
path = path or os.getcwd()
# Use git rev-parse to find the root directory of the repository
result = subprocess.run(
["git", "rev-parse", "--show-toplevel"],
cwd=path,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
check=True
)
return result.stdout.strip()
except subprocess.CalledProcessError:
return None
# Example usage:
git_root = find_git_root()
libPath = os.path.join(git_root,'T00_Common','py')
sys.path.insert(0, libPath)
import myAceplaque.mesher as plq
file_dir = os.path.join(git_root,'T01_Benchmark')
# Define the relative paths
relative_paths = {
'wall': 'geometry_creation/vessel.stl',
'calc': 'geometry_creation/tissue_plaque.stl',
'fibr': 'geometry_creation/tissue_fibr.stl',
'lrnc': None, # Assume this path might be intentionally left empty
'out': '' # This represents the output directory relative to script_dir
}
# Join the script directory with the relative paths
paths = plq.join_relative_paths(file_dir, relative_paths)
'wall': '/Users/alessandromastrofini/LocalFiles/acePlaque-tesi/T01_Benchmark/geometry_creation/vessel.stl'
'calc': '/Users/alessandromastrofini/LocalFiles/acePlaque-tesi/T01_Benchmark/geometry_creation/tissue_plaque.stl'
'fibr': '/Users/alessandromastrofini/LocalFiles/acePlaque-tesi/T01_Benchmark/geometry_creation/tissue_fibr.stl'
'lrnc': ''
'out': '/Users/alessandromastrofini/LocalFiles/acePlaque-tesi/T01_Benchmark'
myMesh = plq.myMesh(paths)
Scale
myMesh.scale_meshes(1)
myMesh.visualize_mesh(type='scaled')
Generate materials map
myMesh.assign_material_map(spacing=0.0001)
ERROR:root:No cells to build
2024-09-02 10:20:01.456 ( 15.027s) [ 24352]vtkStaticCellLocator.cx:1474 ERR| vtkStaticCellLocator (0x12db3b220): No cells to build
myMesh.visualize_material_map()
Save text for materials
myMesh.write_material_map()
Processing file matx.h5...
Interpolated function saved to interpMatx.m
Finished processing matx.h5
Processing file lrnc.h5...
Interpolated function saved to interpLrnc.m
Finished processing lrnc.h5
Processing file fibr.h5...
Interpolated function saved to interpFibr.m
Finished processing fibr.h5
Processing file calc.h5...
Interpolated function saved to interpCalc.m
Finished processing calc.h5
myMesh.create_volumetric_wall_mesh(block_height_multiplier=0.9,
hmax='5E-4',
hmin='3.5E-4')
MATLAB script saved as /Users/alessandromastrofini/LocalFiles/acePlaque-tesi/T00_Common/../T01_Benchmark/mesh/script.m
COMSOL Multiphysics server 6.1 (Build: 252) started listening on port 2036
Use the console command 'close' to exit the program
2024-08-31 23:59:28 A LiveLink™ for MATLAB® client with username 'xx' has logged in from 'MacBook-Pro-di-Alessandro-8.local'
MATLAB is now connected to a COMSOL Multiphysics Server at localhost:2036
Run the commands below to access the COMSOL ModelUtil commands:
import com.comsol.model.util.*
Mesh correctly exported
2024-08-31 23:59:40 A LiveLink™ for MATLAB® client with username 'xx' logged in from 'MacBook-Pro-di-Alessandro-8.local' has disconnected
Mesh data saved to /Users/alessandromastrofini/LocalFiles/acePlaque-tesi/T00_Common/../T01_Benchmark/mesh/mesh.h5
Identified surface tag as: {'top': 2, 'bottom': 4, 'internal': 3, 'external': 1}