### ===================================================================================================================
### Function to check if the geometry-name complies to VIIA naming conventions
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# No imports required
### ===================================================================================================================
### 2. Get geometry-group based on geometry-name
### ===================================================================================================================
[docs]def viia_check_geometry_name(geometry_name: str, geometry_group: str) -> bool:
"""
Function to check whether the geometry-name is according to VIIA convention.
Input:
- project (obj): VIIA project object containing collections of fem objects and project variables.
- geometry_name (str): Name of the geometry.
- geometry_group (str): Name of the geometry-group.
Output:
- Returns True if the geometry-name complies to VIIA naming convention.
- Raises an error if the geometry-name is not according to VIIA convention.
"""
if 'surfaces' in geometry_group:
if len(geometry_name.split('-')) not in [1, 2, 4, 5]:
raise ValueError(
f"ERROR: Name of {geometry_name} is not according to VIIA convention, it should look like "
f"'VLOER-73', 'WAND-100', 'WANDEN-20-L5P-POS-SPUITBETON' or 'WANDEN-40-L5P-SPUITBETON'.")
elif 'lines' in geometry_group:
geometry_name = geometry_name.split('-')
if len(geometry_name) not in [2] and geometry_name[0] not in ['LIJNMASSA']:
raise ValueError(
f"ERROR: Name of {'-'.join(geometry_name)} is not according to VIIA convention, it should look like "
f"'BALK-200x250', 'KOLOM-100x100' or 'LATEI-50x100'.")
elif len(geometry_name) not in [1] and geometry_name[0] in ['LIJNMASSA'] and \
geometry_name[1] not in ['DISCREET']:
raise ValueError(
f"ERROR: Name of {'-'.join(geometry_name)} is not according to VIIA convention, it should look like "
f"'LIJNMASSA-DISCREET'.")
elif 'L' in geometry_name[-1] and geometry_name[-1] not in ['LIJNMASSA', 'DISCREET']:
if len(geometry_name[-1].split('x')) not in [2, 3, 4]:
raise ValueError(
f"ERROR: Name of {'-'.join(geometry_name)} is not according to VIIA convention, it should look "
f"like 'L30x5', 'L30x30x5' or 'L30x30x5x5'.")
elif 'T' in geometry_name[-1] and geometry_name[-1] not in ['DISCREET']:
if len(geometry_name[-1].split('x')) not in [2, 3, 4]:
raise ValueError(
f"ERROR: Name of {'-'.join(geometry_name)} is not according to VIIA convention, it should look "
f"like 'T20x3', 'L20x20x3' or 'L20x20x3x5'.")
elif 'D' in geometry_name[-1] or 'RD' in geometry_name[-1] or 'CHS' in geometry_name[-1]:
if len(geometry_name[-1].split('x')) not in [1, 2]:
raise ValueError(
f"ERROR: Name of {'-'.join(geometry_name)} is not according to VIIA convention, it should look "
f"like 'D10', 'D40x4' or 'CHS50x5'.")
elif 'RHS' in geometry_name[-1] or 'K' in geometry_name[-1]:
if len(geometry_name[-1].split('x')) not in [2, 3, 4, 6]:
raise ValueError(
f"ERROR: Name of {'-'.join(geometry_name)} is not according to VIIA convention, it should look "
f"like 'K30x5', 'RHS40x40x3', 'RHS40x40x3x5' or 'K50x30x12x10x8x5'.")
else:
if len(geometry_name[-1].split('x')) not in [1, 2]:
raise ValueError(
f"ERROR: Name of {'-'.join(geometry_name)} is not according to VIIA convention, it should look "
f"like '300x400', 'IPE160' or 'HEA160'.")
elif 'surface-reinforcements' in geometry_group:
if len(geometry_name.split('-')) not in [3, 4]:
raise ValueError(
f"ERROR: Name of {geometry_name} is not according to VIIA convention, it should look like "
f"'WANDEN-L5P-CFRPMESH' or 'WANDEN-L5P-CFRPMESH-2x'.")
elif 'line-reinforcements-with-bondslip' in geometry_group:
if len(geometry_name.split('-')) not in [3]:
raise ValueError(
f"ERROR: Name of {geometry_name} is not according to VIIA convention, it should look like "
f"'L4O-CFRPSTRIP-20x1.4'.")
elif 'points' in geometry_group:
if 'ROTVEER' in geometry_name:
if len(geometry_name.split('-')) not in [1, 2]:
raise ValueError(
f"ERROR: Name of {geometry_name} is not according to VIIA convention, it should look like "
f"'ROTVEER-(1,0,0)'.")
elif 'PUNTMASSA' in geometry_name:
if 'PUNTMASSA' != geometry_name:
raise ValueError(
f"ERROR: Name of {geometry_name} is not according to VIIA convention, it should look like "
f"'PUNTMASSA'.")
elif 'PUNT' in geometry_name:
if len(geometry_name.split('-')) not in [3]:
raise ValueError(
f"ERROR: Name of {geometry_name} is not according to VIIA convention, it should look like "
f"'PUNT-IF-0.01'.")
else:
raise ValueError(
f"ERROR: The {geometry_group} and {geometry_name} are not checked against VIIA convention. Check if"
f"the geometry name is present in the Database or not.")
return True
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================