Skip to content

Commit

Permalink
Merge branches 'master' and 'master' of https://github.com/KVSlab/tur…
Browse files Browse the repository at this point in the history
  • Loading branch information
keiyamamo committed May 15, 2023
2 parents 5753d49 + f89397c commit 4820f59
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 33 deletions.
14 changes: 7 additions & 7 deletions docs/examples/example.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Configuration file for turtleFSI

[Parameter for turtleFSI] # Section is required by configargparse but is not used anywhere in turtleFSI
################################################################################
# Define solver, numerics, and problem file
################################################################################
Expand All @@ -22,21 +22,21 @@ theta=0.501
################################################################################

# Turn on/off solving of the fluid problem ('fluid', 'no_fluid')
fluid="fluid"
fluid=fluid

# Turn on/off solving of the solid problem ('solid', 'no_solid')
solid="solid"
solid=solid

# Use Robin boundary conditions for solid
robin_bc=False

# Set approach for extrapolating the deformation into the fluid domain
# ('laplace', 'elastic', 'biharmonic', 'no_extrapolation')
extrapolation="laplace"
extrapolation=laplace

# Set the sub type of the extrapolation method ('constant'," 'small_constant',
# 'volume', 'volume_change', 'constrained_disp', 'constrained_disp_vel')
extrapolation-sub-type="constant"
extrapolation-sub-type=constant

# List of boundary ids for the weak formulation of the biharmonic mesh lifting
# operator with 'constrained_disp_vel'
Expand Down Expand Up @@ -95,7 +95,7 @@ dx-s-id=2

# Selected linear solver for each Newton iteration, to see a complete list
# run list_linear_solvers()
linear-solver="mumps"
linear-solver=mumps

# Absolute error tolerance for the Newton iterations
atol=1e-7
Expand Down Expand Up @@ -140,7 +140,7 @@ save-deg=1
checkpoint-step=500

# Path to store the results. You can store multiple simulations in one folder
folder="results"
folder=results

# Over write the standard 1, 2, 3 name of the sub folders
#sub-folder=None
Expand Down
16 changes: 8 additions & 8 deletions docs/examples/example.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Configuration file for turtleFSI

[Parameter for turtleFSI] # Section is required by configargparse but is not used anywhere in turtleFSI
################################################################################
# Define solver, numerics, and problem file
################################################################################

# Name of problem file to solve. Could either be located in the turtleFSI
# repository (TF_cfd, TF_csm, TF_fsi, turtle_demo) or it could be a problem
# file you have created locally.
problem: "turtle_demo"
problem: turtle_demo

# Setting temporal integration.
# (theta=0 : first order explicit forward Euler scheme)
Expand All @@ -22,21 +22,21 @@ theta: 0.501
################################################################################

# Turn on/off solving of the fluid problem ('fluid', 'no_fluid')
fluid: "fluid"
fluid: fluid

# Turn on/off solving of the solid problem ('solid', 'no_solid')
solid: "solid"
solid: solid

# Use Robin boundary conditions for solid
robin_bc: False

# Set approach for extrapolating the deformation into the fluid domain
# ('laplace', 'elastic', 'biharmonic', 'no_extrapolation')
extrapolation: "laplace"
extrapolation: laplace

# Set the sub type of the extrapolation method ('constant'," 'small_constant',
# 'volume', 'volume_change', 'constrained_disp', 'constrained_disp_vel')
extrapolation-sub-type: "constant"
extrapolation-sub-type: constant

# List of boundary ids for the weak formulation of the biharmonic mesh lifting
# operator with 'constrained_disp_vel'
Expand Down Expand Up @@ -95,7 +95,7 @@ dx-s-id: 2

# Selected linear solver for each Newton iteration, to see a complete list
# run list_linear_solvers()
linear-solver: "mumps"
linear-solver: mumps

# Absolute error tolerance for the Newton iterations
atol: 1e-7
Expand Down Expand Up @@ -140,7 +140,7 @@ save-deg: 1
checkpoint-step: 500

# Path to store the results. You can store multiple simulations in one folder
folder: "results"
folder: results

# Over write the standard 1, 2, 3 name of the sub folders
#sub-folder: None
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ dependencies:
- scipy
- configargparse
- numpy
- pyyaml
- pip:
- cppimport
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
long_description = fh.read()

DEPENDENCIES = ['configargparse', "fenics-dolfin",
"scipy", "cppimport", "numpy"]
"scipy", "cppimport", "numpy", "pyyaml"]
TEST_DEPENDENCIES = ['pytest']

VERSION = "1.5"
Expand Down
21 changes: 12 additions & 9 deletions turtleFSI/modules/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ def assign_domain_properties(dx, dx_f_id, rho_f, mu_f, fluid_properties, dx_s_id

# 1. Create differential for each fluid region, and organize into fluid_properties list of dicts
dx_f = {}
if isinstance(dx_f_id, list): # If dx_f_id is a list (i.e, if there are multiple fluid regions):
for fluid_region in range(len(dx_f_id)):
dx_f[fluid_region] = dx(dx_f_id[fluid_region], subdomain_data=domains) # Create dx_f for each fluid region
fluid_properties.append({"dx_f_id":dx_f_id[fluid_region],"rho_f":rho_f[fluid_region],"mu_f":mu_f[fluid_region]})
dx_f_id_list=dx_f_id
else:
dx_f[0] = dx(dx_f_id, subdomain_data=domains)
dx_f_id_list=[dx_f_id]
fluid_properties.append({"dx_f_id":dx_f_id,"rho_f":rho_f,"mu_f":mu_f})
if len(fluid_properties) == 0:
if isinstance(dx_f_id, list): # If dx_f_id is a list (i.e, if there are multiple fluid regions):
for fluid_region in range(len(dx_f_id)):
dx_f[fluid_region] = dx(dx_f_id[fluid_region], subdomain_data=domains) # Create dx_f for each fluid region
fluid_properties.append({"dx_f_id":dx_f_id[fluid_region],"rho_f":rho_f[fluid_region],"mu_f":mu_f[fluid_region]})
dx_f_id_list=dx_f_id
else:
dx_f[0] = dx(dx_f_id, subdomain_data=domains)
dx_f_id_list=[dx_f_id]
fluid_properties.append({"dx_f_id":dx_f_id,"rho_f":rho_f,"mu_f":mu_f})
elif isinstance(fluid_properties, dict):
fluid_properties = [fluid_properties]

# Create solid region differentials
dx_s = {}
Expand Down
31 changes: 23 additions & 8 deletions turtleFSI/utils/argpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import configargparse
import string
import ast

import yaml

class StoreDictKeyPair(configargparse.Action):
def __init__(self, option_strings, dest, nargs=None, **kwargs):
Expand Down Expand Up @@ -120,13 +120,13 @@ def restricted_float(x):

def parse():

parser = configargparse.ArgumentParser(description=(
"turtleFSI is an open source Fluid-Structure Interaction (FSI) solver written in Python "
+ "and built upon the FEniCS finite element library. The purpose of turtleFSI is to "
+ "provide a user friendly and numerically robust monolithic FSI solver able to handle "
+ "problems characterized by large deformation. turtleFSI benefites from the state-of-the-art "
+ "parrallel computing features available from the FEniCS library and can be executed with "
+ "MPI on large computing resources."))
parser = configargparse.ArgParser(config_file_parser_class=configargparse.ConfigparserConfigFileParser,
description=("turtleFSI is an open source Fluid-Structure Interaction (FSI) solver written in Python "
+ "and built upon the FEniCS finite element library. The purpose of turtleFSI is to "
+ "provide a user friendly and numerically robust monolithic FSI solver able to handle "
+ "problems characterized by large deformation. turtleFSI benefites from the state-of-the-art "
+ "parrallel computing features available from the FEniCS library and can be executed with "
+ "MPI on large computing resources."))

# Configuration file
parser.add_argument('-c', '--config', is_config_file=True,
Expand Down Expand Up @@ -186,6 +186,12 @@ def parse():
help="1st Lame Coef. for the solid")
parser.add_argument("--gravity", type=float, default=None,
help="Gravitational force on the solid")

parser.add_argument("--solid_properties", type=yaml.safe_load, default=None,
help="Solid properties as a dictionary")

parser.add_argument("--fluid_properties", type=yaml.safe_load, default=None,
help="Fluid properties as a dictionary")

# Domain settings
parser.add_argument("--dx-f-id", type=int, default=None,
Expand Down Expand Up @@ -266,6 +272,15 @@ def parse():

# Parse arguments
args, unknownargs = parser.parse_known_args()

if args.__dict__["solid_properties"]:
for k, v in args.__dict__["solid_properties"].items():
if k != "material_model":
args.__dict__["solid_properties"][k] = float(v)

if args.__dict__["fluid_properties"]:
for k, v in args.__dict__["fluid_properties"].items():
args.__dict__["fluid_properties"][k] = float(v)

# Add dt and T as parameters for time-step and end-time respectively
d = {'dt': args.__dict__['time_step'],
Expand Down

0 comments on commit 4820f59

Please sign in to comment.