Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Stokes flow example #54

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# SPDX-License-Identifier: MIT

add_subdirectory(poisson)
add_subdirectory(linelast)
add_subdirectory(linelast)
add_subdirectory(stokes)
15 changes: 15 additions & 0 deletions examples/stokes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Lawrence Livermore National Security, LLC. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: MIT

file(COPY stokes.sampling.yml DESTINATION ${CMAKE_BINARY_DIR}/examples/stokes)
file(COPY array.8.yml DESTINATION ${CMAKE_BINARY_DIR}/examples/stokes)

file(COPY generate_configs.py DESTINATION ${CMAKE_BINARY_DIR}/examples/stokes)
file(COPY setup_stokes.sh DESTINATION ${CMAKE_BINARY_DIR}/examples/stokes)

file(COPY meshes/square.o3.mesh DESTINATION ${CMAKE_BINARY_DIR}/examples/stokes/meshes)
file(COPY meshes/square-circle.msh.mfem DESTINATION ${CMAKE_BINARY_DIR}/examples/stokes/meshes)
file(COPY meshes/square-triangle.msh.mfem DESTINATION ${CMAKE_BINARY_DIR}/examples/stokes/meshes)
file(COPY meshes/square-star.msh.mfem DESTINATION ${CMAKE_BINARY_DIR}/examples/stokes/meshes)
file(COPY meshes/square-square.msh.mfem DESTINATION ${CMAKE_BINARY_DIR}/examples/stokes/meshes)
116 changes: 116 additions & 0 deletions examples/stokes/array.8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
main:
#mode: run_example/sample_generation/build_rom/single_run
mode: single_run
use_rom: true
solver: stokes

mesh:
type: component-wise
component-wise:
# you can try other config files you generated by specifying it here.
global_config: "configs/test.box-channel.8x8.h5"
components:
- name: "empty"
file: "meshes/square.o3.mesh"
- name: "square-circle"
file: "meshes/square-circle.msh.mfem"
- name: "square-square"
file: "meshes/square-square.msh.mfem"
- name: "square-triangle"
file: "meshes/square-triangle.msh.mfem"
- name: "square-star"
file: "meshes/square-star.msh.mfem"

domain-decomposition:
type: interior_penalty

discretization:
order: 2
full-discrete-galerkin: false

solver:
direct_solve: true
use_amg: true
max_iter: 1000000
print_level: 0
absolute_tolerance: 1.0e-10
relative_tolerance: 1.0e-10

visualization:
enabled: true
visualize_error: true
unified_paraview: false
file_path:
prefix: paraview/8x8/stokes_array_output

parameterized_problem:
name: flow_past_array
#name: stokes_channel

single_run:
choose_from_random_sample: false
flow_past_array:
nu: 1.1
u0_x: 1.5
u0_y: -0.8
du_x: 0.
du_y: 0.
stokes_channel:
nu: 1.1
U: 1.5
L: 4.
x0: 2.

sample_generation:
type: "random"
random_sample_generator:
number_of_samples: 100
maximum_number_of_snapshots: 100
parameters:
- key: mesh/component-wise/global_config
type: filename
minimum: 0
maximum: 99
format: "boxchannel_sample/8x8_samples/box-channel.8x8.%06d.h5"
- key: single_run/flow_past_array/u0_x
type: double
minimum: -1.5
maximum: 1.5
- key: single_run/flow_past_array/u0_y
type: double
minimum: -1.5
maximum: 1.5

basis:
prefix: "basis/stokes_basis"
number_of_basis: 36
tags:
- name: "empty"
- name: "square-circle"
- name: "square-square"
- name: "square-triangle"
- name: "square-star"
svd:
save_spectrum: true
update_right_sv: false
visualization:
enabled: false
prefix: stokes_comp

model_reduction:
rom_handler_type: mfem
linear_solver_type: direct
linear_system_type: spd
# This is the input for saving ROM matrix/rhs system.
save_linear_system:
enabled: true
prefix: rom-system/stokes.8x8
preconditioner: gs
# individual/universal
subdomain_training: universal
save_operator:
level: component
prefix: "stokes_comp"
compare_solution:
enabled: true

24 changes: 24 additions & 0 deletions examples/stokes/generate_configs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
# Add path to root utils/python/ directory to find config scripts
sys.path.insert(0, "../../../utils/python/")

from config import Empty, ObjectInSpace
from box_channel_config import BoxChannelConfig

if __name__ == "__main__":
comp_list = {'empty': Empty(),
'circle': ObjectInSpace('square-circle'),
'square': ObjectInSpace('square-square'),
'triangle': ObjectInSpace('square-triangle'),
'star': ObjectInSpace('square-star'),}

example = BoxChannelConfig(2,2)
for name, comp in comp_list.items():
example.addComponent(comp)

example.GenerateAllConfigs(0)

test = BoxChannelConfig(8,8)
for name, comp in comp_list.items():
test.addComponent(comp)
test.CreateRandomConfig('test.box-channel.8x8.h5')
Loading
Loading