Skip to content

Predeform: take the material models and parameters from the main problem file - #245

Open
simonecap00 wants to merge 1 commit into
masterfrom
predeform-main-problem
Open

simonecap00 wants to merge 1 commit into
masterfrom
predeform-main-problem

Conversation

@simonecap00

Copy link
Copy Markdown

Related to #241

Summary

predeform.py defined its own solid model, Robin boundary condition, fluid, load and boundary IDs in its code
(currently MooneyRivlin + Robin). The pre-deformation and the main simulation could therefore use different material
models without any warning: for example MooneyRivlin in the predeform and StVenantKirchoff in aneurysm.py, which
does not set material_model and falls back to the turtleFSI default.

This is the inconsistency reported in #241. Instead of copying the MooneyRivlin parameters into aneurysm.py, this PR
lets the predeform take the model from the main problem file, so the two are consistent by construction for any
model. aneurysm.py keeps StVenantKirchoff, now written explicitly, so test_aneurysm_problem is unchanged.

With this PR the predeform takes these parameters from the problem file of the main simulation, given with
--main_problem:

turtleFSI -p predeform --main_problem=aneurysm

--main_problem is the name of the main problem file (looked up in the current directory, then in vasp.simulations
and turtleFSI.problems) or a path to it. Arguments given on the command line still override the values of the main
problem file.

What the predeform takes from the main problem file

  • Solid: material_model (mandatory), solid_properties or rho_s/mu_s/lambda_s, dx_s_id
  • Fluid: fluid_properties or rho_f/mu_f, dx_f_id, and nonnewtonian/cross_params for a non-Newtonian
    fluid
  • Robin boundary condition, if it is used: robin_bc, k_s, c_s, ds_s_id
  • Load: P_final and v_max_final (mandatory)
  • Boundary IDs: inlet_id and fsi_id (mandatory), rigid_id and inlet_outlet_s_id (optional), each as an
    integer or a list
  • get_mesh_domain_and_boundaries, if the main problem file defines it, together with the parameters it takes
    (e.g. mesh_path, fsi_region). Regions created in the code are then the same in both simulations, e.g. the
    fluid region 1001 of offset_stenosis.py.
  • folder: the results are stored in <folder>/predeform_results

The time stepping, solver settings and load ramps stay in predeform.py, with the same values as before.

Explicit errors instead of silent defaults

The predeform stops before loading the mesh if the main problem file has any of these problems. All problems are
reported together.

  • material_model is not defined
  • an unknown material model is used
  • a parameter required by the model is missing (rho_s, mu_s, lambda_s, plus C01/C10/C11 for
    MooneyRivlin, Jm for Gent, mu_visc_s/lambda_visc_s for viscoelasticity)
  • MooneyRivlin or Gent is given with scalar parameters only
  • solid_properties does not match dx_s_id in length or order (turtleFSI pairs them by position)
  • the fluid density or viscosity is not defined
  • robin_bc=True without ds_s_id, which would otherwise apply the Robin condition on the whole exterior boundary,
    or with k_s/c_s that are not lists with one value per boundary
  • P_final, v_max_final, inlet_id or fsi_id is missing, or v_max_final does not match the number of inlets

The main problem files call the same solid and Robin checks (check_material_parameters in simulation_common.py)
from their initiate().

Log

The predeform prints which parameters were taken from which problem file, which function reads the mesh, and where
the results are stored. The material models and parameters of each region are printed by turtleFSI in both
simulations; see the companion PR KVSlab/turtleFSI#118. This PR also works without it: turtleFSI then prints the
regions as before.

Other changes

  • Boundary IDs: the predeform boundary conditions accept integers or lists (several inlets or FSI interfaces).
    v_max_final can be one value or one value per inlet.
  • Non-Newtonian fluid: the predeform calls mu_eff.update() at each time step when the fluid is non-Newtonian
    (Add non-Newtonian (modified Cross) viscosity model for the fluid turtleFSI#115). It works with or without that PR.
  • Problem files:
    • aneurysm.py, cylinder.py, offset_stenosis.py: explicit material_model="StVenantKirchoff", the same model
      as before.
    • aneurysm.py, offset_stenosis.py, avf.py: P_final and v_max_final with example values, to be adapted to
      each case.
    • avf.py:
      • the inlets are defined once as inlet_id=[3, 2] (PA, DA), used by its create_bcs and by the predeform. The
        former inlet_id1/inlet_id2 are left commented with a note.
      • k_s/c_s are lists, as required by the current turtleFSI.
  • Docs: docs/prestress.md, docs/avf.md, src/vasp/simulations/README.md
  • Tests: test_predeform_problem uses --main_problem=cylinder

Possible follow-up (not in this PR)

The pre-deformed mesh is still generated in a separate step with vasp-predeform-mesh. A possible automation is to
generate it at the end of the predeform run (e.g. in finished(), from the final displacement in memory), so that
the whole pre-deformation is a single command. Both results would be kept: the predeform results in
<folder>/predeform_results and the pre-deformed mesh next to them. vasp-predeform-mesh would remain available,
e.g. for a different --scale-factor.

Breaking changes

  • turtleFSI -p predeform requires --main_problem.
  • A main problem file used with the predeform must define material_model, P_final, v_max_final, inlet_id and
    fsi_id.
  • avf.py: inlet_id1/inlet_id2 are replaced by the list inlet_id.

Verification

Tests were run locally on macOS arm64 (conda-forge FEniCS 2019.1.0) and on a Linux workstation
(FEniCS 2019.1.0, NumPy 1.26). The predeform runs below used turtleFSI from the branch of KVSlab/turtleFSI#115
(non-Newtonian fluid), so they also cover the non-Newtonian changes.

  • Equivalence: the new predeform, with a main problem file containing exactly the parameters previously
    hard-coded in predeform.py, gives the same final displacement as the predeform on master (relative difference
    ~5e-16, cylinder test mesh, 4 MPI processes). The mesh and the domain/boundary markers are identical.
  • Error cases: 14 main problem files with one mistake each stop with the expected message (both machines).
  • Predeform with the VaSP problem files (Linux): cylinder, offset_stenosis (fluid region 1001 present),
    aneurysm (Robin taken from the problem file), a Robin case, and a non-Newtonian fluid (modified Cross model of
    Add non-Newtonian (modified Cross) viscosity model for the fluid turtleFSI#115, with the effective viscosity updated at each time step).
  • Main simulations (Linux): offset_stenosis gives the same values at probe point 5 as
    test_offset_stenosis_problem; cylinder and aneurysm run as before.
  • pytest: test_predeform_problem, test_cylinder_problem and tests/test_predeform.py pass with turtleFSI
    master and with the branch of Add non-Newtonian (modified Cross) viscosity model for the fluid turtleFSI#115, both with and without the companion PR.
  • Linters: flake8 is clean; mypy reports no new errors.
  • Not tested: the main simulation of avf.py, because there is no AVF mesh or patient data in the test data.

…lem file

The predeform takes the solid and fluid properties, the Robin boundary
condition, the load (P_final, v_max_final), the boundary IDs and the mesh
function from the main problem file given with --main_problem, and stops
with an explicit error if required parameters are missing or inconsistent.

Related to #241

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant