NasCar
Loading...
Searching...
No Matches
NaSCar : Navier-Stokes Cartesian

This numerical code solves fluide-structure interactions problems based on the incompressible Navier-Stokes equations

This code, witten in C and based on PetsC, is devoted to solve 3D-flows in around moving and deformable bodies. The incompressible Navier-Stokes equations are discretized in space on Cartsesain grids using Finite Differences and Finites Volumes, and the bodies are taken into account thanks to penalization and/or immersed boundary methods. The interface between the fluid and the bodies is tracked with a level set function or in a Lagrangian way. The numerical code is fully second order (time and space). The temporal resolution of the incompressible Navier-Stokes equations is based on projection schemes of Chorin-Temam's type.


Installation (https://petsc.org/release/) and compilation

  • Installation: example on MAC OS:

    ‍brew install petsc (all necessary librairies like MPI are aslo installed with petsc).

    ‍xcode-select –install (Possibly, you have also to install some necessary xcode command line tools)

  • Compilation and execution

    ‍make clean (or make mrproper) -> clean the working directory

    ‍make ns3d -> compilation to create execution file ns3d

    ‍make run -> execution of code (if more than 1 million of degrees of freedom are used, you may have to consider using a scheduler and a batch file)

  • Documentation

    ‍make doc -> this documentation is generated by doxygen

  • General overview

    ‍The input parameters defining the flow configuration are read in the *.DAT files, depending on the test case read in TEST_CASES.DAT

    ‍The results are written in some directories

    • Results: the temporal evolutions of some quantities like drag, lift, energy, ...
    • Solution: snapshots of some flow fields like velocity, pressure, vorticity, ...
    • Body: body mesh geometry with surface pressure, drag, lift, ...

Eaxmples of numerical simulations:

  • Three different test cases can be chosen in the file TEST_CASES.DAT (chose 1, 2, 3 or 4). Visualizations are done using paraview (https://www.paraview.org) from pvtr (vtk) files in the Solution directory: the bodies correpond to the contour 0 of Level_Set, and the fluid-structure interface is the contour 0 of the function PSI. Note that TEST1.DAT, TEST2.DAT, TEST3.DAT, TEST4.DAT and TEST5.DAT comes here with a coarse mesh, so that it is possible to run these tests on a laptop with 4 to 8 cores in few hours. For more realistic solutions like the attached movies, it is necessary to at least double the number of mesh points NX, NY, and NY.
TEST1: Dolphin jump
TEST2: Boat ride
TEST3: Snake swimming at water surface
TEST4: fishes swimming in an enclosure, with collisions
TEST5: elastic membrane actuated with a torus holder
  • TEST1 is fully described in [10].
  • TEST1, TEST2 and TEST3 are based on [16]
  • TEST4 is based on a derived version of the collison models introduced in [14] and [15]
  • TEST5 is a LVAD, inspired by the one developed by Corwave: an elastic membrane is actuated with a torus holder
  • Other handcrafted test cases can be considered with parameters in INPUT.DAT (if another value than 1, 2 or 3 is choosen in TEST_CASES.DAT). See https://www.math.u-bordeaux.fr/~mbergman/ for simulations performed with NaSCar, including wave energy converters [9], fish swimming from experimental images [6], sedimentation of particles [15], fish with elastic tail [8], wind turbines [5] and jellyfish [7].

General structure of the code

The main program is main.c

Initialisation stage

‍the struc.h defines the necessary variables

‍The files TEST_CASE.DAT, INPUT.DAT (or TEST1.DAT, TEST2.DAT, TEST3.DAT or TEST4.DAT, depending of the choice made in TEST_CASE.DAT) are read in initialisations.c

‍the arrays defined in struct.h are allocated with dimensions read in INPUT.DAT in Alloc.c

‍the petsc vectors are created in Vectors.c

‍Some other Petsc creations (the grid) are in main.c

‍Initial conditions (for velocity, pressure, etc) are defined in initialisations.c

‍Different body geomeries can be used (choice in INPUT.DAT), like fish (Body_Fish.c), rings or torus (Body_Anneau.c, Body_Tore.c)

Main computations: Numerical resolution of the unsteady Fluid-Structure interaction problems (in a temporal loop)

‍All the next steps are iterativeley computed in a temporal loop, where the time step is comptuted in dedicated function in Prediction.c

(1) Resolution of the incompressible Navier-Stokes equations with Chorin-Temam [13] [23] factional step method

‍The momentum equation is solve using a pressure guess in Prediction.c, where the stress tensor is computed in Stress.c: The stress tensor can be fluid or elastic (Navier model with Mooney Rivlin [17]). The numerical schemes for convective and diffusive terms can be chosen in INPUT.DAT (upwind, centered, WENO5, explicit or iplicit). The bi-fluid interface is defined using the CSF method [11]

‍The Poisson equation is solved in Poisson.c

‍The pressure and velocity fields are corrected in Correction.c to have a solenoidal velocity field (mass conservation)

(2) Computation of the body motion: imposed or passive deformation + rigid motion

‍Compute the aerodynamic forces and torques [18] in CoefAero.c

‍Compute the body deformation (with procrustes analysis [3]) and motion in Body_***.c files, for instance Body_Dolphin2.c for the dolphin test case

‍Compute the Level Set function [19] [21] from Body Lagrangian markers in LevelSet.c

‍Penalisation [1] or IPC [7] step to impose to take into account the body in the Navier-Stokes equations in Penalisation.c

‍Transport the bi-fuid or fluid-elastic structure intefaces in Transport.c, togheter with some reinitialisation steps [16]. For fluid-elastic structure problems, extrapolation [2] of the backward characteristics is performed in Extrapol.c

(3) Time to time, export the field solutions

‍The fields solutions are exported in directory 'Solution' using Export.c

‍The body geometry, with surface informations (normals, stress, pressure, etc) are written in the 'Body' directory using Export.c

‍The temporal evolutions of some quatities of interest (drag, lift, power, etc) are written in the 'Results' directory by main.c

Finalisation stage

‍When the temporal loop is over, delete/deallocate all variables using functions in Alloc.c and Vectors.c


Version
1.0
Author
Michel Bergmann
Date
2023-02-03