Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
POD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Habscheid
POD
Commits
3bc80b9e
Commit
3bc80b9e
authored
2 months ago
by
Jan Habscheid
Browse files
Options
Downloads
Patches
Plain Diff
Docstrings for gismo functions
parent
f63f9a90
Branches
Branches containing commit
No related tags found
1 merge request
!6
Documentation
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gismo/GenerateMicrostructures_fun.py
+55
-8
55 additions, 8 deletions
gismo/GenerateMicrostructures_fun.py
gismo/error_evaluation.py
+2
-1
2 additions, 1 deletion
gismo/error_evaluation.py
with
57 additions
and
9 deletions
gismo/GenerateMicrostructures_fun.py
+
55
−
8
View file @
3bc80b9e
...
...
@@ -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
"
),
...
...
This diff is collapsed.
Click to expand it.
gismo/error_evaluation.py
+
2
−
1
View file @
3bc80b9e
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment