Skip to content

Commit

Permalink
Add option for truly 2D meshes; improve documentation; add further an…
Browse files Browse the repository at this point in the history
…d revamp examples
  • Loading branch information
Marc Hirschvogel committed Nov 10, 2023
1 parent da51633 commit 18c3070
Show file tree
Hide file tree
Showing 29 changed files with 54,688 additions and 78 deletions.
Binary file modified doc/ambit_doc.pdf
Binary file not shown.
137 changes: 78 additions & 59 deletions doc/ambit_doc.tex

Large diffs are not rendered by default.

Binary file removed doc/examples/flow0d/syspul_plots.png
Binary file not shown.
Binary file added doc/examples/flow0d/syspul_results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/examples/flow0d/syspul_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions doc/examples/fluid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# README #

This example shows how to set up 2D fluid flow in a channel around a rigid obstacle, using Taylor-Hood elements.


### Instructions ###

Run the simulation, either in one of the provided Docker containers or using your own FEniCSx/Ambit installation, using the command
```
mpiexec -n 1 python3 fluid_channel.py
```
It is fully sufficient to use one core (mpiexec -n 1) for the presented setup.

Open the results file results_channel_velocity.xdmf and results_channel_pressure.xdmf in Paraview, and visualize the velocity as well as the pressure over time.

### Solution

The figure shows the velocity magnitude (top) as well as the pressure (bottom part) at the end of the simulation.
Binary file added doc/examples/fluid/channel_results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/examples/fluid/channel_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions doc/examples/fluid/fluid_channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python3

"""
A 2D fluid dynamics problem of incompressible Navier-Stokes channel flow around a rigid cylindrical obstacle.
"""

import ambit_fe
import numpy as np
from pathlib import Path


def main():

basepath = str(Path(__file__).parent.absolute())

"""
Parameters for input/output
"""
IO_PARAMS = {# problem type 'fluid': incompressible Navier-Stokes flow
'problem_type' : 'fluid',
# the meshes for the domain and boundary topology are specified separately
'mesh_domain' : basepath+'/input/channel_domain.xdmf',
'mesh_boundary' : basepath+'/input/channel_boundary.xdmf',
# at which step frequency to write results (set to 0 in order to not write any output)
'write_results_every' : 1,
# where to write the output to
'output_path' : basepath+'/tmp/',
# which results to write
'results_to_write' : ['velocity','pressure'],
# the 'midfix' for all simulation result file names: will be results_<simname>_<field>.xdmf/.h5
'simname' : 'fluid_channel'}

"""
Parameters for the linear and nonlinear solution schemes
"""
SOLVER_PARAMS = {'solve_type' : 'direct',
#'direct_solver' : 'superlu_dist', # no idea why, but mumps does not seem to like this system in parallel...
'tol_res' : [1e-8, 1e-8],
'tol_inc' : [1e-8, 1e-8]}

"""
Parameters for the fluid mechanics time integration scheme, plus the global time parameters
"""
TIME_PARAMS = {'maxtime' : 0.5,
'numstep' : 100,
'timint' : 'ost',
'theta_ost' : 1.0}

"""
Finite element parameters: Taylor-Hood elements with quadratic approximation for the velocity and linear approximation for the pressure
"""
FEM_PARAMS = {# the order of the finite element ansatz functions for the velocity and pressure
'order_vel' : 2,
'order_pres' : 1,
# the degree of the quadrature scheme
'quad_degree' : 5}

"""
Constitutive parameters for the fluid: let's use parameters of glycerine
"""
MATERIALS = { 'MAT1' : {'newtonian' : {'mu' : 1420.0e-6}, # kPa s
'inertia' : {'rho' : 1.26e-6}} } # kg/mm^3


"""
Time curves, e.g. any prescribed time-controlled/-varying loads or functions
"""
class time_curves():

def tc1(self, t):

Umax = 1e3

t_ramp = 0.3

return Umax * 0.5*(1.-np.cos(np.pi*t/t_ramp)) * (t < t_ramp) + Umax * (t >= t_ramp)


"""
Boundary conditions: ids: 1: inflow, 2: bottom wall, 3: axial outflow, 4: top wall - 5: obstacle
Wall and obstactle are fixed, in-flow velocity is prescribed, outflow is free ("Neumann zero")
"""
BC_DICT = { 'dirichlet' : [{'id' : [1], 'dir' : 'x', 'curve' : 1},
{'id' : [2,4,5], 'dir' : 'all', 'val' : 0.}]}


# problem setup
problem = ambit_fe.ambit_main.Ambit(IO_PARAMS, TIME_PARAMS, SOLVER_PARAMS, FEM_PARAMS, MATERIALS, BC_DICT, time_curves=time_curves())

# solve time-dependent problem
problem.solve_problem()



if __name__ == "__main__":

main()
Loading

0 comments on commit 18c3070

Please sign in to comment.