{ "cells": [ { "cell_type": "markdown", "source": [ "# Tutorial 11: Fluid-Structure Interaction" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "In this tutorial, we will learn\n", "\n", " - How to solve a surface-coupled multi-physics problem.\n", " - Construct FE spaces defined in different domains.\n", " - Define interface triangulations and integrate on them.\n", "\n", "1. [Problem Statement](#probStat)\n", " - [Strong form](#strongForm)\n", " - [Geometry and Discrete model](#geometry)\n", " - [Boundary conditions and properties](#conditions)\n", "2. [Numerical scheme](#numericalScheme)\n", " - [FE spaces](#feSpace)\n", " - [Weak form](#weakForm)\n", " - [Numerical integration](#integration)\n", " - [Algebraic system of equations](#algebraic)\n", "3. [Post-processing](#postprocess)\n", " - [Visualization](#visualization)\n", " - [Quantities of interest](#QOIs)" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "## Problem statement\n", "```@raw HTML\n", "\n", "```\n", "### Strong form\n", " Let $\\Gamma_{\\rm FS}$ be the interface between a fluid domain $\\Omega_{\\rm F}$ and a solid domain $\\Omega_{\\rm S}$. We denote by $\\Gamma_{\\rm F,D}$ and $\\Gamma_{\\rm F,N}$ the fluid boundaries with Dirichlet and Neumann conditions, respectively.\n", "The Fluid-Structure Interaction (FSI) problem reads:\n", "\n", "find $u_{\\rm F}$, $p_{\\rm F}$ and $u_{\\rm S}$ such that\n", "$$\n", "\\left\\lbrace\n", "\\begin{aligned}\n", "-\\nabla\\cdot\\boldsymbol{\\sigma}_{\\rm F} = f &\\text{ in }\\Omega_{\\rm F},\\\\\n", "\\nabla\\cdot u_{\\rm F} = 0 &\\text{ in } \\Omega_{\\rm F},\\\\\n", "-\\nabla\\cdot\\boldsymbol{\\sigma}_{\\rm S} = s &\\text{ in }\\Omega_{\\rm S},\\\\\n", "\\end{aligned}\n", "\\right.\n", "$$\n", "\n", "satisfying the Dirichlet and Neumann boundary conditions\n", "$$\n", "\\left\\lbrace\n", "\\begin{aligned}\n", "u_{\\rm F} = g_{\\rm F} &\\text{ on } \\Gamma_{\\rm F,D},\\\\\n", "n_{\\rm F} \\cdot \\boldsymbol{\\sigma}_{\\rm F} = 0 &\\text{ on } \\Gamma_{\\rm F,N},\\\\\n", "u_{\\rm S} = g_{\\rm S} &\\text{ on } \\Gamma_{\\rm S,D},\\\\\n", "\\end{aligned}\n", "\\right.\n", "$$\n", "\n", "and the kinematic and dynamic conditions at the fluid-solid interface\n", "$$\n", "\\left\\lbrace\n", "\\begin{aligned}\n", "u_{\\rm F} = u_{\\rm S} &\\text{ on } \\Gamma_{\\rm FS},\\\\\n", "n_{\\rm F} \\cdot \\boldsymbol{\\sigma}_{\\rm F} + n_{\\rm S} \\cdot \\boldsymbol{\\sigma}_{\\rm S} = 0 &\\text{ on } \\Gamma_{\\rm FS}.\\\\\n", "\\end{aligned}\n", "\\right.\n", "$$\n", "\n", "Where $\\boldsymbol{\\sigma}_{\\rm F}(u_{\\rm F},p_{\\rm F})=2\\mu_{\\rm F}\\boldsymbol{\\varepsilon}(u_{\\rm F}) - p_{\\rm F}\\mathbf{I}$ and $\\boldsymbol{\\sigma}_{\\rm S}(u_{\\rm S})=2\\mu_{\\rm S}\\boldsymbol{\\varepsilon}(u_{\\rm S}) +\\lambda_{\\rm S}tr(\\boldsymbol{\\varepsilon}(u_{\\rm S}))\\mathbf{I}$." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "### Geometry and Discrete model\n", "In this tutorial we solve the benchmark descrived in [1], consisting on a flow over an elastic flag after a cylinder.\n", "The computational domain is defined by a channel of size $\\Omega \\doteq (0,4.5)\\times(0,0.41)$, with an embedded cylinder of radius $R=0.05$ and center at $C=(0.2,0.2)$. The associated FE triangulation is denoted by $\\mathcal{T}$, the fluid and solid domain and their associated triangulations will be denoted by $\\Omega_{\\rm F}$, $\\Omega_{\\rm S}$, $\\mathcal{T}_{\\rm F}$ and $\\mathcal{T}_{\\rm S}$, respectively.\n", "\n", "In order to load the discrete model we first setup Gridap" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Gridap" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "The discrete model for the elastic flag problem is generated by loading the `\"../models/elasticFlag.json\"` file." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "model = DiscreteModelFromFile(\"../models/elasticFlag.json\")" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "We can inspect the loaded geometry and associated parts by printing to a `vtk` file:" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "writevtk(model,\"model\")" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "This will produce an output in which we can identify the different parts of the domain, with the associated labels and tags.\n", "\n", "| Part | Notation | Label | Tag |\n", "| :---: | :---:| :---: | :---: |\n", "| Solid-cylinder wall | $\\Gamma_{\\rm S,D_{cyl}}$ | \"fixed\" | 1 |\n", "| Fluid-solid interface | $\\Gamma_{\\rm FS}$ | \"interface\" | 2 |\n", "| Channel inlet | $\\Gamma_{\\rm F,D_{in}}$ | \"inlet\" | 3 |\n", "| Channel outlet | $\\Gamma_{\\rm F,N_{out}}$ | \"outlet\" | 4 |\n", "| Channel walls | $\\Gamma_{\\rm F,D_{wall}}$ | \"noSlip\" | 5 |\n", "| Fluid-cylinder wall | $\\Gamma_{\\rm F,D_{cyl}}$ | \"cylinder\" | 6 |\n", "| Fluid domain | $\\Omega_{\\rm F}$ | \"fluid\" | 7 |\n", "| Solid domain | $\\Omega_{\\rm S}$ | \"solid\" | 8 |\n", "\n", "![](../assets/fsi/tags.png)" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "### External conditions and properties\n", "#### Boundary conditions\n", "We apply Dirichlet boundary conditions at the channel inlet, upper and lower boundaries and on the cylinder. A parabolic profile is enforced at the channel inlet, while a no-slip condition is imposed on the remaining Dirichlet boundaries.\n", "$$\n", "\\left\\lbrace\n", "\\begin{aligned}\n", "u_{\\rm F,in}(x,y) = 1.5U\\frac{y(H −y)}{\\left(\\frac{H}{2}\\right)^2}\\quad&\\textrm{on }\\Gamma_{\\rm F,D_{in}},\\\\\n", "u_{\\rm F,0}(x,y) = [0, 0]\\quad&\\textrm{on }\\Gamma_{\\rm F,D_{wall}}\\cup\\Gamma_{\\rm F,D_{cyl}},\\\\\n", "u_{\\rm S,0}(x,y) = [0, 0]\\quad&\\textrm{on }\\Gamma_{\\rm S,D_{cyl}}.\\\\\n", "\\end{aligned}\n", "\\right.\n", "$$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "const U = 1.0\n", "const H = 0.41\n", "uf_in(x) = VectorValue( 1.5 * U * x[2] * ( H - x[2] ) / ( (H/2)^2 ), 0.0 )\n", "uf_0(x) = VectorValue( 0.0, 0.0 )\n", "us_0(x) = VectorValue( 0.0, 0.0 )" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "We consider a free tranction condition at the channel outlet\n", "$$\n", "n_{\\rm F} \\cdot \\boldsymbol{\\sigma}_{\\rm F} = \\mathbf{0}\\quad\\textrm{on }\\Gamma_{\\rm F,N}\n", "$$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "hN(x) = VectorValue( 0.0, 0.0 )\n", "p_jump(x) = 0.0" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "#### External forces\n", "In this test, the body forces acting on the fluid an solid are zero." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "f(x) = VectorValue( 0.0, 0.0 )\n", "s(x) = VectorValue( 0.0, 0.0 )\n", "g(x) = 0.0" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "#### Material properties\n", "We use a linear elastic constitutive law for the elastic flag. Given the Young's modulus $E$ and the Poisson ratio $\\nu$, we can compute the Lamé constants, $\\lambda$ and $\\mu$, using the following function:" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "function lame_parameters(E,ν)\n", " λ = (E*ν)/((1+ν)*(1-2*ν))\n", " μ = E/(2*(1+ν))\n", " (λ, μ)\n", "end" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Then, we get the Lamé parameters for a solid with $E=1.0$ MPa and $\\nu=0.33$." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "const E_s = 1.0\n", "const ν_s = 0.33\n", "const (λ_s,μ_s) = lame_parameters(E_s,ν_s)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "The Cauchy stress tensor for the solid part is defined by $\\sigma_s = 2\\mu\\varepsilon + \\lambda tr(\\varepsilon)\\mathbf{I}$. Note that we use the trace operator from the `LinearAlgebra` package. With the macro `@law` we are able to define a function whose arguments depend on the coordinates, without the need of passing such coordinates as an argument." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using LinearAlgebra: tr\n", "@law σ_s(ε) = λ_s*tr(ε)*one(ε) + 2*μ_s*ε" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "For the fluid part, we only need to define the viscosity $\\mu_f$, which we set to $0.01$." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "const μ_f = 0.01" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "The Cauchy stress tensor for the fluid part is given by $\\sigma_f = \\sigma^{dev}_f - p\\mathbf{I}$, with $\\sigma^{dev}_f=2\\mu_f$ the deviatoric part of the stress. Since we use a mixed form with the pressure $p$ as an unknown, the stress law will only involve the deviatoric part." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "@law σ_dev_f(ε) = 2*μ_f*ε" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "## Numerical scheme\n", "```@raw HTML\n", "\n", "```\n", "### FE Spaces\n", "In this tutorial we use an *inf-sup* stable velocity-pressure pair, $P_k/P_{k-1}$ elements, with continuous velocities and pressures. We select the same velocity interpolation space for the fluid and the solid parts, defined as follows\n", "$$\n", "V_{\\rm X} \\doteq \\{ v \\in [H^1(\\Omega_{\\rm X})]^d:\\ v|_T\\in [P_k(T)]^d \\text{ for all } T\\in\\mathcal{T}_{\\rm X} \\},\n", "$$\n", "where $T$ denotes an arbitrary cell of the FE mesh $\\mathcal{T}_{\\rm X}$, and $P_k(T)$ is the usual Lagrangian FE space of order $k$ defined on a mesh of triangles or tetrahedra. Note that the sub-index $(\\cdot)_{\\rm X}$ stands for the fluid or solid parts, $(\\cdot)_{\\rm F}$ or $(\\cdot)_{\\rm S}$, respectively.\n", "On the other hand, the space for the pressure is only defined in the fluid domain, $\\Omega_{\\rm F}$, and is given by\n", "$$\n", "Q \\doteq \\{ q \\in C^0(\\Omega):\\ q|_T\\in P_{k-1}(T) \\text{ for all } T\\in\\mathcal{T}_{\\rm F}\\}.\n", "$$" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Before creating the FE spaces, we first need to define the discrete model of each of the sub-domains, which are constructed restricting the global discrete model to the corresponding part. This is done by calling the `DiscreteModel` function with the desired geometrical part label, i.e. `\"solid\"` and `\"fluid\"`, respectively." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "model_solid = DiscreteModel(model,\"solid\")\n", "model_fluid = DiscreteModel(model,\"fluid\")" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "In what follows we will assume a second-order veloticty interpolation, i.e. $k=2$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "k = 2" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Having set up all the ingredients, we can create the different FE spaces for the test functions. For the velocity FE spaces we call the `TestFESpace` function with the corresponding discrete model, using a 2-dimensional `VectorValue` type, a `:Lagrangian` reference FE element of order `k` and conformity `:H1`. Note that we assign different Dirichlet boundary labels for the two different parts, generating the variational spaces with homogeneous Dirichlet boundary conditions, $V_{\\rm F,0}$ and $V_{\\rm S,0}$ ." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "Vf = TestFESpace(\n", " model=model_fluid,\n", " valuetype=VectorValue{2,Float64},\n", " reffe=:Lagrangian,\n", " order=k,\n", " conformity =:H1,\n", " dirichlet_tags=[\"inlet\", \"noSlip\", \"cylinder\"])\n", "\n", "Vs = TestFESpace(\n", " model=model_solid,\n", " valuetype=VectorValue{2,Float64},\n", " reffe=:Lagrangian,\n", " order=k,\n", " conformity =:H1,\n", " dirichlet_tags=[\"fixed\"])" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "For the pressure test FE space, we use the fluid discrete model, a scalar value type, a `:Lagrangian` reference FE element of order `k-1` and `:C0` conformity." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "Qf = TestFESpace(\n", " model=model_fluid,\n", " valuetype=Float64,\n", " order=k-1,\n", " reffe=:Lagrangian,\n", " conformity=:C0)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "The trial FE spaces are generated from the test FE spaces, adding the corresponding function for the various Dirichlet boundaries, leading to $U_{\\rm F,g_{\\rm F}}$, $U_{\\rm S,g_{\\rm S}}$ and $P_{\\rm F}$." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "Uf = TrialFESpace(Vf,[uf_in, uf_0, uf_0])\n", "Us = TrialFESpace(Vs,[us_0])\n", "Pf = TrialFESpace(Qf)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Finally, we glue the test and trial FE spaces together, defining a unique test and trial space for all the fields using the `MultiFieldFESpace` function. That is $Y=[V_{\\rm S,0}, V_{\\rm F,0}, Q_{\\rm F}]^T$ and $X=[U_{\\rm S,g_{\\rm S}}, U_{\\rm F,g_{\\rm F}}, P_{\\rm F}]^T$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "Y = MultiFieldFESpace([Vs,Vf,Qf])\n", "X = MultiFieldFESpace([Us,Uf,Pf])" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "### Weak form\n", "We now introduce the solution and test function vectors as $\\mathbf{x}^h=[\\mathbf{u}^h_{\\rm S},\\mathbf{u}^h_{\\rm F}, p^h_{\\rm F}]^T$ and $\\mathbf{y}^h=[\\mathbf{v}^h_{\\rm S},\\mathbf{v}^h_{\\rm F}, q^h_{\\rm F}]^T$. The weak form of the coupled FSI problem using the Nitche's method, see for instance [2], reads:\n", "find $\\mathbf{x}^h \\in X$ such that\n", "$$\n", "a_s(\\mathbf{x}^h,\\mathbf{y}^h) + a_f(\\mathbf{x}^h,\\mathbf{y}^h) + a_{fs}(\\mathbf{x}^h,\\mathbf{y}^h) = l_s(\\mathbf{y}^h) + l_f(\\mathbf{y}^h) + l_{f,\\Gamma_N}(\\mathbf{y}^h)\\qquad\\forall\\mathbf{y}^h\\in Y,\n", "$$\n", "with the following definitions:" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "- $a_s(\\mathbf{x}^h,\\mathbf{y}^h)$ is the bilinear form associated with the solid counterpart, defined as\n", "$$\n", "a_s(\\mathbf{x}^h,\\mathbf{y}^h)=(\\varepsilon(\\mathbf{v}^h_{\\rm S}),\\boldsymbol{\\sigma}_s(\\mathbf{u}^h_{\\rm S})).\n", "$$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "function a_s(x,y)\n", " us,uf,p = x\n", " vs,vf,q = y\n", "\tε(vs) ⊙ σ_s(ε(us))\n", "end" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "- $a_f(\\mathbf{x}^h,\\mathbf{y}^h)$ is the bilinear form associated with the fluid counterpart, defined as\n", "$$\n", "a_f(\\mathbf{x}^h,\\mathbf{y}^h)=(\\varepsilon(\\mathbf{v}^h_{\\rm F}),\\boldsymbol{\\sigma}^{dev}_f(\\mathbf{u}^h_{\\rm F})) - (\\nabla\\cdot\\mathbf{v}^h_{\\rm F},p_{\\rm F}) + (q_{\\rm F}, \\nabla\\cdot\\mathbf{u}^h_{\\rm F}).\n", "$$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "function a_f(x,y)\n", " us,uf,p = x\n", " vs,vf,q = y\n", " (ε(vf) ⊙ σ_dev_f(ε(uf))) - (∇⋅vf)*p + q*(∇⋅uf)\n", "end" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "- $a_{fs}(\\mathbf{x}^h,\\mathbf{y}^h)$ is the bilinear form associated with the coupling between fluid and solid counterparts. To difine this form we use the well known Nitsche's method, which enforces the continuity of fluid and solid velocities as well as the continuity of the normal stresses, see for instance [2]. The final expression for this term reads:\n", "$$\n", "\\begin{aligned}\n", "a_{fs}(\\mathbf{x}^h,\\mathbf{y}^h)=&\\langle\\gamma\\frac{\\mu_f}{h}(\\mathbf{v}^h_{\\rm F}-\\mathbf{v}^h_{\\rm S}),(\\mathbf{u}^h_{\\rm F}-\\mathbf{u}^h_{\\rm S})\\rangle_{\\Gamma_{\\rm FS}}\\\\\n", "&- \\langle(\\mathbf{v}^h_{\\rm F}-\\mathbf{v}^h_{\\rm S}),\\mathbf{n}_{\\rm FS}\\cdot\\boldsymbol{\\sigma}^{dev}_f(\\mathbf{u}^h_{\\rm F})\\rangle_{\\Gamma_{\\rm FS}}\n", "+ \\langle(\\mathbf{v}^h_{\\rm F}-\\mathbf{v}^h_{\\rm S}),p^h_{\\rm F}\\mathbf{n}_{\\rm FS}\\rangle_{\\Gamma_{\\rm FS}}\\\\\n", "&- \\chi\\langle\\mathbf{n}_{\\rm FS}\\cdot\\boldsymbol{\\sigma}^{dev}_f(\\mathbf{v}^h_{\\rm F}),(\\mathbf{u}^h_{\\rm F}-\\mathbf{u}^h_{\\rm S})\\rangle_{\\Gamma_{\\rm FS}}\n", "+ \\langle q^h_{\\rm F}\\mathbf{n}_{\\rm FS},(\\mathbf{u}^h_{\\rm F}-\\mathbf{u}^h_{\\rm S})\\rangle_{\\Gamma_{\\rm FS}}\\\\\n", "\\end{aligned}\n", "$$\n", "Where $\\chi$ is a parameter that can take values $1.0$ or $-1.0$ and it is used to define the symmetric or antisymmetric version of the method, respectively." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "const γ = 1.0\n", "const χ = -1.0\n", "function a_fs(x,y)\n", " us_Γ, uf_Γ, p_Γ = x\n", " vs_Γ, vf_Γ, q_Γ = y\n", " uf = jump(uf_Γ)\n", " p = jump(p_Γ)\n", " us = -jump(us_Γ)\n", " vf = jump(vf_Γ)\n", " q = jump(q_Γ)\n", " vs = -jump(vs_Γ)\n", " εuf = jump(ε(uf_Γ))\n", " εvf = jump(ε(vf_Γ))\n", " penaltyTerms = α*vf⋅uf - α*vf⋅us - α*vs⋅uf + α*vs⋅us\n", "\tintegrationByParts = ( vf⋅(p*n_Γfs) - vf⋅(n_Γfs⋅σ_dev_f(εuf)) ) - ( vs⋅(p*n_Γfs) - vs⋅(n_Γfs⋅σ_dev_f(εuf)) )\n", "\tsymmetricTerms = ( q*(n_Γfs⋅uf) - χ*(n_Γfs⋅σ_dev_f(εvf))⋅uf ) - ( q*(n_Γfs⋅us) - χ*(n_Γfs⋅σ_dev_f(εvf))⋅us )\n", " penaltyTerms + integrationByParts + symmetricTerms\n", "end" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "- $l_s(\\mathbf{y}^h)$ is the linear form associated with the solid counterpart, defined as\n", "$$\n", "l_s(\\mathbf{y}^h)=(\\mathbf{v}^h_{\\rm S},s).\n", "$$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "function l_s(y)\n", " vs,vf,q = y\n", " vs⋅s\n", "end" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "- $l_f(\\mathbf{y}^h)$ is the linear form associated with the fluid counterpart, defined as\n", "$$\n", "l_f(\\mathbf{y}^h)=(\\mathbf{v}^h_{\\rm F},f).\n", "$$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "function l_f(y)\n", " vs,vf,q = y\n", " vf⋅f + q*g\n", "end" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "- $l_{f,\\Gamma_N}(\\mathbf{y}^h)$ is the linear form associated with the fluid Neumann boundary condition, defined as\n", "$$\n", "l_{f,\\Gamma_N}(\\mathbf{y}^h)=\\langle\\mathbf{v}^h_{\\rm F},h\\rangle_{\\Gamma_N}.\n", "$$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "function l_f_Γn(y)\n", " vs,vf,q = y\n", " vf⋅hN\n", "end" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "### Numerical integration\n", "To define the quadrature rules used in the numerical integration of the different terms, we first need to generate the domain triangulation. Here we create the triangulation of the global domain, $\\mathcal{T}$." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "trian = Triangulation(model)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "The solid and fluid triangulations, $\\mathcal{T}_{\\rm F}$ and $\\mathcal{T}_{\\rm S}$, are constructed from the discrete models restricted to the respective parts." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "trian_solid = Triangulation(model_solid)\n", "trian_fluid = Triangulation(model_fluid)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "We also generate the triangulation and associated outer normal field for the outlet boundary, $\\Gamma_{\\rm F,N_{out}}$, which will be used to impose a Neumann condition." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "trian_Γout = BoundaryTriangulation(model,\"outlet\")\n", "n_Γout = get_normal_vector(trian_Γout)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Finally, to impose the interface condition between solid and fluid, we will need the triangulation and normal field of such interface, $\\Gamma_{\\rm FS}$. The interface triangulation is generated by calling the `InterfaceTriangulation` function specifying the two interfacing domain models. Note that the normal field will point outwards with respect to the first entry." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "trian_Γfs = InterfaceTriangulation(model_fluid,model_solid)\n", "n_Γfs = get_normal_vector(trian_Γfs)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "From the interface triangulation we can obtain the interface elements length, $h$, and the penalty parameter, $\\alpha=\\gamma\\frac{\\mu_f}{h}$, used in the Nitsche's terms." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Gridap.Arrays\n", "using LinearAlgebra: norm\n", "xe = get_cell_coordinates(trian_Γfs)\n", "he = apply(x->norm(x[2]-x[1]),xe)\n", "α = apply(h->γ*μ_f/h, he)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Once we have all the triangulations, we can generate the quadrature rules to be applied each domain." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "degree = 2*k\n", "quad_solid = CellQuadrature(trian_solid,degree)\n", "quad_fluid = CellQuadrature(trian_fluid,degree)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Idem for the boundary part." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "bdegree = 2*k\n", "quad_Γout = CellQuadrature(trian_Γout,bdegree)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Idem for the interface part." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "idegree = 2*k\n", "quad_Γfs = CellQuadrature(trian_Γfs,idegree)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "### Algebraic System of Equations\n", "After defining the weak form of the problem and the integration quadrature rules to perform the numerical integration, we are ready to assemble the linear system of equations. In this case, the system will have the following structure:\n", "$$\n", "\\begin{bmatrix}\n", "\\mathbf{A}_{u,\\rm S}&\\mathbf{A}_{u,\\rm SF}&0\\\\\n", "\\mathbf{A}_{u,\\rm FS}&\\mathbf{A}_{u,\\rm F}&\\mathbf{A}_{up,\\rm F}\\\\\n", "0&\\mathbf{A}_{up,\\rm F}&\\mathbf{A}_{p,\\rm F}\\\\\n", "\\end{bmatrix}\\begin{bmatrix}\n", "\\mathbf{U}^h_{\\rm S}\\\\\n", "\\mathbf{U}^h_{\\rm F}\\\\\n", "\\mathbf{P}^h_{\\rm F}\\\\\n", "\\end{bmatrix} = \\begin{bmatrix}\n", "\\mathbf{F}^h_{u,\\rm S}\\\\\n", "\\mathbf{F}^h_{u,\\rm F}\\\\\n", "\\mathbf{F}^h_{p,\\rm F}\\\\\n", "\\end{bmatrix}\n", "$$\n", "In order to construct the system we first define the diferent discrete terms using the functions `AffineFETerm`, that assemble contributions on the left-hand side and the right-hand side of the system, for the fluid and solid interior terms evaluated in the respective triangulations, $\\mathcal{T}_{\\rm F}$ and $\\mathcal{T}_{\\rm S}$. The fluid Neumann boundary condition is assembled using the function `FESource`, which only affects the right-hand side of the system, evaluating the corresponding form on the triangulation of the outlet boundary, $\\Gamma_{\\rm F,N_{out}}$. The coupling terms are evaluated at the interface $\\Gamma_{\\rm FS}$ using the function `LinearFETerm`, assembling only to the left-hand side of the system." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "t_Ω_s= AffineFETerm(a_s,l_s,trian_solid,quad_solid)\n", "t_Ω_f = AffineFETerm(a_f,l_f,trian_fluid,quad_fluid)\n", "t_Γfs = LinearFETerm(a_fs,trian_Γfs,quad_Γfs)\n", "t_Γn_f = FESource(l_f_Γn,trian_Γout,quad_Γout)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "The final FE operator is constructed using the function `AffineFEOperator` and passing as arguments the trial and test FE spaces, $X$ and $Y$, and all the different terms previously defined." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "op = AffineFEOperator(X,Y,t_Ω_s,t_Ω_f,t_Γn_f,t_Γfs)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Finally, we call `solve` to obtain the solution vector of nodal values $[\\mathbf{U}^h_{\\rm S},\\mathbf{U}^h_{\\rm F},\\mathbf{P}^h_{\\rm F}]^T$" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "uhs, uhf, ph = solve(op)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "## Post-processing\n", "```@raw HTML\n", "\n", "```\n", "### Visualization\n", "The solution fields $[\\mathbf{U}^h_{\\rm S},\\mathbf{U}^h_{\\rm F},\\mathbf{P}^h_{\\rm F}]^T$ are defined over all the domain, extended with zeros on the inactive part. Calling the function `writevtk` passing the global triangulation, we will output the global fields." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "writevtk(trian,\"trian\", cellfields=[\"uhs\" => uhs, \"uhf\" => uhf, \"ph\" => ph])" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "![](../assets/fsi/Global_solution.png)" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "However, we can also restrict the fields to the active part by calling the function `restrict` with the field along with the respective active triangulation." ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "uhs_solid = restrict(uhs, trian_solid)\n", "uhf_fluid = restrict(uhf, trian_fluid)\n", "ph_fluid = restrict(ph, trian_fluid)\n", "writevtk(trian_solid,\"trian_solid\",cellfields=[\"uhs\"=>uhs_solid])\n", "writevtk(trian_fluid,\"trian_fluid\",cellfields=[\"ph\"=>ph_fluid,\"uhf\"=>uhf_fluid])" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "![](../assets/fsi/Local_solution.png)" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "```@raw HTML\n", "\n", "```\n", "### Quantities of Interest" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "trian_ΓS = BoundaryTriangulation(model,[\"cylinder\",\"interface\"])\n", "quad_ΓS = CellQuadrature(trian_ΓS,bdegree)\n", "n_ΓS = get_normal_vector(trian_ΓS)\n", "uh_ΓS = restrict(uhf_fluid,trian_ΓS)\n", "ph_ΓS = restrict(ph_fluid,trian_ΓS)\n", "FD, FL = sum( integrate( (n_ΓS⋅σ_dev_f(ε(uh_ΓS))) - ph_ΓS*n_ΓS, trian_ΓS, quad_ΓS ) )\n", "println(\"Drag force: \", FD)\n", "println(\"Lift force: \", FL)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "## References\n", "[1] Turek, S., Hron, J., Madlik, M., Razzaq, M., Wobker, H., & Acker, J. F. (2011).* Numerical simulation and benchmarking of a monolithic multigrid solver for fluid-structure interaction problems with application to hemodynamics*. In Fluid Structure Interaction II (pp. 193-220). Springer, Berlin, Heidelberg.*\n", "\n", "[2] Burman, E., and Fernández, M. A. *Stabilized explicit coupling for fluid–structure interaction using Nitsche's method.* Comptes Rendus Mathematique 345.8 (2007): 467-472." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" ], "metadata": {} } ], "nbformat_minor": 3, "metadata": { "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.3.1" }, "kernelspec": { "name": "julia-1.3", "display_name": "Julia 1.3.1", "language": "julia" } }, "nbformat": 4 }