AnsysLink/test/test_mechdb_reader.py

51 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""
Test script to read mesh statistics from .mechdb files
"""
import sys
import os
from pathlib import Path
# Add project root to path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from backend.utils.mechdb_reader import read_mechdb_statistics
def main():
"""Test reading mechdb files"""
# Use the known real mechdb file
mechdb_path = r"C:\Users\Tellme\AppData\Local\Temp\ANSYS.Tellme.1\AnsysMech118E\Project_Mech_Files\verification_test.mechdb"
if not os.path.exists(mechdb_path):
print(f"MechDB file not found: {mechdb_path}")
return
latest_mechdb = Path(mechdb_path)
print(f"Testing with file: {latest_mechdb}")
print(f"File size: {latest_mechdb.stat().st_size:,} bytes")
# Test simulation mode first
print("\n=== Testing Simulation Mode ===")
sim_stats = read_mechdb_statistics(str(latest_mechdb), simulation_mode=True)
print(f"Simulation results: {sim_stats}")
# Test real mode
print("\n=== Testing Real ANSYS Mode ===")
real_stats = read_mechdb_statistics(str(latest_mechdb), simulation_mode=False)
print(f"Real results: {real_stats}")
# Compare results
if sim_stats.get('success') and real_stats.get('success'):
print("\n=== Comparison ===")
print(f"Simulation - Elements: {sim_stats['element_count']}, Nodes: {sim_stats['node_count']}")
print(f"Real ANSYS - Elements: {real_stats['element_count']}, Nodes: {real_stats['node_count']}")
elif real_stats.get('success'):
print(f"\n✓ Real ANSYS reading successful: {real_stats['element_count']} elements, {real_stats['node_count']} nodes")
elif sim_stats.get('success'):
print(f"\n✓ Simulation reading successful: {sim_stats['element_count']} elements, {sim_stats['node_count']} nodes")
else:
print("\n✗ Both reading methods failed")
if __name__ == '__main__':
main()