Skip to content
Snippets Groups Projects
Commit 3bc80b9e authored by Jan Habscheid's avatar Jan Habscheid
Browse files

Docstrings for gismo functions

parent f63f9a90
No related branches found
No related tags found
1 merge request!6Documentation
......@@ -5,11 +5,63 @@ import pandas as pd
from gismo.gismo_export import AdditionalBlocks, export
def generate(size_1, size_2, size_3, BOX_LENGTH, BOX_HEIGHT, EPS, INLET_BOUNDARY_ID, OUTLET_BOUNDARY_ID, knots_y, TILING, CLOSING_FACE, MICROTILE):
def generate(
size_1:int, size_2:int, size_3:int,
BOX_LENGTH:float, BOX_HEIGHT:float,
EPS:float,
INLET_BOUNDARY_ID:int, OUTLET_BOUNDARY_ID:int,
knots_y:np.ndarray,
TILING:list,
CLOSING_FACE:str,
MICROTILE:str
) -> (sp.microstructure.Microstructure, list):
'''
Generate a microstructure
For a given size_1, size_2, and size_3, generate a microstructure with the given parameters.
Parameters
----------
size_1 : int
Size of microtile on lowest level
size_2 : int
Size of microtile on middle level
size_3 : int
Size of microtile on highest level
BOX_LENGTH : float
Length of the box
BOX_HEIGHT : float
Height of the box
EPS : float
Precision
INLET_BOUNDARY_ID : int
Identifier for inlet boundary
OUTLET_BOUNDARY_ID : int
Identifier for outlet boundary
knots_y : np.ndarray
Knots for y direction
TILING : list
Tiling of the microstructure
[nx, ny] with nx, ny integers the number of tiles in x and y direction
CLOSING_FACE : str
Closing face of the microstructure, either "x" or "y"
MICROTILE : str
Type of microtile. See splinepy.microstructure.Microstructure for details
Returns
-------
sp.microstructure.Microstructure
Microstructure
list
List of additional blocks for gismo export
Raises
------
ValueError
If the parametric function doesnt find the according y-value
'''
# Define microstructure deformation function
initial_macro_spline = sp.helpme.create.box(BOX_LENGTH, BOX_HEIGHT)
# x0_max, x1_max = initial_macro_spline.cps.max(axis=0)
# print(f'x0_max: {x0_max}, x1_max: {x1_max}')
# Define identifier functions for microstructure boundaries
def identifier_inlet(points):
......@@ -25,9 +77,6 @@ def generate(size_1, size_2, size_3, BOX_LENGTH, BOX_HEIGHT, EPS, INLET_BOUNDARY
# Define current parameterization function
def para_function_(x):
# print(f'x: {x}')
# print(f'index: {index}')
x_ = x[0][0]
y_ = x[0][1]
if np.isclose(y_, knots_y[0], rtol=1e-2):
return np.array(size_1).reshape(-1, 1)
......@@ -41,7 +90,6 @@ def generate(size_1, size_2, size_3, BOX_LENGTH, BOX_HEIGHT, EPS, INLET_BOUNDARY
# Create microstructure
generator = sp.microstructure.Microstructure(
deformation_function=initial_macro_spline.copy(),
# deformation_function=initial_parameter_spline.copy(),
tiling=TILING,
microtile=MICROTILE,
parametrization_function=para_function_,
......@@ -81,7 +129,6 @@ def generate(size_1, size_2, size_3, BOX_LENGTH, BOX_HEIGHT, EPS, INLET_BOUNDARY
block_id=3,
dim=2,
function_list=["0"],
# bc_list=[(f"BID{OUTLET_BOUNDARY_ID}", "Dirichlet", 0)],
bc_list=[], # use empty list, as bc_list argument is needed, but cv_list is wanted for corner value only
cv_list=[
("0", "40", "2", "0"),
......
......@@ -55,6 +55,7 @@ def integrate_multipatch(multipatch, fields):
return integration_sum
def compute_integral_error(multipatch, fields_original, fields_recreated, norm="l2"):
"""Compute integral error between original and recreated fields"""
fields_error = []
for patch, field_orig, field_recreated in zip(multipatch.patches, fields_original, fields_recreated):
field_error = patch.copy()
......@@ -66,8 +67,8 @@ def compute_integral_error(multipatch, fields_original, fields_recreated, norm="
else:
return error_integral
# Load XML file to numpy array
def get_solution_vectors(file_path, two_dimensional=False):
"""Load XML file to numpy array"""
# Parse the XML file
tree = ET.parse(file_path)
root = tree.getroot()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment