Giter VIP home page Giter VIP logo

fv2d's Introduction

FV2D

2D finite volume code with Kokkos for experimentation/prototyping purposes

Dependencies

  • HDF5 (1.8+)
  • A C++ compiler compatible with C++17
  • CMake (3.16+)

Building

Building relies on CMake. As FV2D is built with Kokkos included as a submodule, all Kokkos option have to be passed here. For more information on how to indicate which architecture/compiler you wish to use with Kokkos, please refer to the Kokkos documentation. Here are a few examples of build commands for FV2D depending on the architecture :

Configuring on CPU with Clang

mkdir build_cpu
cd build_cpu
CC=clang CXX=clang++ cmake -DKokkos_ENABLE_OPENMP=ON -DCMAKE_BUILD_TYPE=Release ..

Configuring on an NVidia GPU with Clang

mkdir build_nvgpu
cd build_nvgpu
CC=clang CXX=clang++ cmake -DKokkos_ENABLE_CUDA=ON -DCMAKE_BUILD_TYPE=Release ..

Note: using nvcc and not clang for compiling with CUDA might lead to problems because of an incompatibility between nvcc and HighFive the hdf5 wrapper used in this project.

Configuring on an AMD GPU with HIP

mkdir build_amdgpu
cd build_amdgpu
CC=hipcc CXX=hipcc cmake -DKokkos_ENABLE_HIP=ON -DCMAKE_BUILD_TYPE=Release ..

Compiling

Once the program has been successfully configured, you can build the code :

make -j

At the end of the compilation, an executable fv2d should be created in the build folder.

Usage

To use fv2d simply run the fv2d executable and provide a .ini file on the command line. For instance, if you are in a build folder located right below the root of fv2d, you can run a test by typing :

./fv2d ../settings/blast.ini

The code will start outputting information :

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░        ░░   ░░░░░░░░░   ░░░░░░░░░░░░░░░░░   ░
▒   ▒▒▒▒▒▒▒▒   ▒▒▒▒▒▒▒   ▒▒▒   ▒  ▒▒▒▒▒▒▒▒▒   ▒
▒   ▒▒▒▒▒▒▒▒▒   ▒▒▒▒▒   ▒▒▒  ▒▒▒▒▒   ▒▒▒▒▒▒   ▒
▓       ▓▓▓▓▓▓   ▓▓▓   ▓▓▓▓▓▓▓▓▓   ▓▓▓▓   ▓   ▓
▓   ▓▓▓▓▓▓▓▓▓▓▓   ▓   ▓▓▓▓▓▓▓▓   ▓▓▓▓▓  ▓▓▓   ▓
▓   ▓▓▓▓▓▓▓▓▓▓▓▓     ▓▓▓▓▓▓▓   ▓▓▓▓▓▓▓  ▓▓▓   ▓
█   █████████████   ███████         ███   █   █
███████████████████████████████████████████████
Computing dts at (t=0) : dt_hyp=0.000521995; dt_TC=1e+06; dt_visc=1e+06
 - Saving at time 0
Computing dts at (t=0.000551063) : dt_hyp=0.000480941; dt_TC=1e+06; dt_visc=1e+06
Computing dts at (t=0.00106851) : dt_hyp=0.000459815; dt_TC=1e+06; dt_visc=1e+06
...

Each reporting line indicate the current time t and the timesteps associated with each physical process. dt_hyp is the hyperbolic time step associated with the hydro update, dt_TC the time step associated with thermal conduction, and finally dt_visc the viscous time step.

Once the execution is finished, the code displays a "goodbye" message :

    █     ▀██  ▀██         ▀██                              ▄█▄ 
   ███     ██   ██       ▄▄ ██    ▄▄▄   ▄▄ ▄▄▄     ▄▄▄▄     ███ 
  █  ██    ██   ██     ▄▀  ▀██  ▄█  ▀█▄  ██  ██  ▄█▄▄▄██    ▀█▀ 
 ▄▀▀▀▀█▄   ██   ██     █▄   ██  ██   ██  ██  ██  ██          █  
▄█▄  ▄██▄ ▄██▄ ▄██▄    ▀█▄▄▀██▄  ▀█▄▄█▀ ▄██▄ ██▄  ▀█▄▄▄▀     ▄  
                                                            ▀█▀ 

After that, a run.h5 file has been generated and contains all the outputs

Analysis

To analyse the data the simplest way is to use python with h5py.

The HDF5 file stores all snapshots at the root in keys having the form ite_{iteration number}. So for instance, to access iteration #5 : ite_5.

On top of each iteration, the root of the hef5 file stores the coordinates of the points of the mesh in the keys x and y.

Each iteration stores the primitive values associated with the run, so rho, prs, u and v.

For instance, to plot the status of the blast at the last step :

import h5py
import numpy as np
import matplotlib.pyplot as plt

f = h5py.File('run.h5', 'r')

Nite = len(f.keys())-2 # removing x and y
ite = f[f'ite_{Nite-1}']

fig, ax = plt.subplots(2, 2, figsize=(7, 7))
ax[0,0].imshow(ite['rho'])
ax[0,1].imshow(ite['prs'])
ax[1,0].imshow(ite['u'])
ax[1,1].imshow(ite['v'])

ax[0,0].set_title('Density')
ax[0,1].set_title('Pressure')
ax[1,0].set_title('$v_x$')
ax[1,1].set_title('$v_y$')

plt.tight_layout()
plt.show()

f.close()

Rendering of the 2D sedov Blast

More example of post-treatment scripts can be found in the python folder at the root of FV2D.

fv2d's People

Contributors

mdelorme avatar

Stargazers

Sylvain  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.