86 lines
2.9 KiB
Python
86 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test to confirm mesh generation success
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from backend.pymechanical.session_manager import ANSYSSessionManager
|
|
import logging
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(levelname)s:%(name)s:%(message)s'
|
|
)
|
|
|
|
def test_mesh_success():
|
|
"""Test mesh generation and confirm success"""
|
|
print("Mesh Generation Success Test")
|
|
print("=" * 50)
|
|
|
|
session_manager = None
|
|
try:
|
|
# Initialize ANSYS session
|
|
session_manager = ANSYSSessionManager(simulation_mode=False)
|
|
session_manager.start_session()
|
|
print("✓ ANSYS session started")
|
|
|
|
# Import geometry
|
|
geometry_file = "resource\\blade.step"
|
|
print(f"1. Importing geometry from {geometry_file}...")
|
|
if session_manager.import_geometry(geometry_file):
|
|
print("✓ Geometry imported successfully")
|
|
else:
|
|
print("✗ Geometry import failed")
|
|
return
|
|
|
|
# Apply mesh controls (like we do successfully)
|
|
print("\n2. Applying mesh controls...")
|
|
named_selections = ['leading_edge', 'trailing_edge', 'blade_root', 'blade_surfaces']
|
|
|
|
# Create named selections first
|
|
selection_result = session_manager.create_named_selections()
|
|
if selection_result['success']:
|
|
print("✓ Named selections created")
|
|
|
|
# Apply mesh controls
|
|
mesh_result = session_manager.apply_mesh_controls(named_selections)
|
|
if mesh_result['success']:
|
|
print("✓ Mesh controls applied")
|
|
|
|
# Now test our mesh generator
|
|
print("\n3. Testing mesh generator...")
|
|
generation_result = session_manager.generate_mesh()
|
|
|
|
print(f"Generation result: {generation_result}")
|
|
|
|
if generation_result.get('success'):
|
|
print("✓ Mesh generation reported as successful!")
|
|
print(f" - Elements: {generation_result.get('element_count', 'N/A')}")
|
|
print(f" - Nodes: {generation_result.get('node_count', 'N/A')}")
|
|
print(f" - Generation time: {generation_result.get('generation_time', 'N/A')} seconds")
|
|
else:
|
|
print("✗ Mesh generation failed")
|
|
print(f" - Error: {generation_result.get('error_message', 'Unknown error')}")
|
|
|
|
# Get mesh statistics
|
|
print("\n4. Getting mesh statistics...")
|
|
stats = session_manager.get_mesh_statistics()
|
|
print(f"Statistics: {stats}")
|
|
|
|
print("\n✓ Mesh success test completed")
|
|
|
|
except Exception as e:
|
|
print(f"\n✗ Mesh success test failed: {str(e)}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
finally:
|
|
if session_manager:
|
|
session_manager.close_session()
|
|
|
|
if __name__ == "__main__":
|
|
test_mesh_success() |