Git Product home page Git Product logo

idefix's Introduction

Documentation Status Idefix CIs

What is Idefix?

Idefix is a computational fluid dynamics code based on a finite-volume high-order Godunov method, originally designed for astrophysical fluid dynamics applications. Idefix is designed to be performance-portable, and uses the Kokkos framework to achieve this goal. This means that it can run both on your laptop's cpu and on the largest GPU Exascale clusters. More technically, Idefix can run in serial, use OpenMP and/or MPI (message passing interface) for parallelization, and use GPU acceleration when available (based on Nvidia Cuda, AMD HIP, etc...). All these capabilities are embedded within one single code, so the code relies on relatively abstracted classes and objects available in C++17, which are not necessarily familiar to astrophysicists. A large effort has been devoted to simplify this level of abstraction so that the code can be modified by researchers and students familiar with C and who are aware of basic object-oriented concepts.

Idefix currently supports the following physics:

  • Compressible hydrodynamics in 1D, 2D, 3D
  • Compressible magnetohydrodynamics using constrained transport in 1D, 2D, 3D
  • Multiple geometry (cartesian, polar, spherical)
  • Variable mesh spacing
  • Multiple parallelisation strategies (OpenMP, MPI, GPU offloading, etc...)
  • Full non-ideal MHD (Ohmic, ambipolar, Hall)
  • Viscosity and thermal diffusion
  • Super-timestepping for all parabolic terms
  • Orbital advection (Fargo-like)
  • Self-gravity
  • Multi dust species modelled as pressureless fluids
  • Multiple planets interraction

Documentation

A full online documentation is available on readTheDoc.

Download:

Assuming you want to use https to get idefix (easiest option):

git clone --recurse-submodules https://github.com/idefix-code/idefix.git idefix
cd idefix

This will create and deploy Idefix in the directory idefix.

Installation:

Set the IDEFIX_DIR environment variable to the absolute path of the directory

export IDEFIX_DIR=<idefix main folder>

Add this line to ~/.<shell_rc_file> for a permanent install.

Compile an example:

Go to the example directory. For instance:

cd test/HD/sod

Configure the code launching cmake (version >= 3.16) in the example directory:

cmake $IDEFIX_DIR

Several options can be enabled from the command line (a complete list is available with cmake $IDEFIX_DIR -LH). For instance: -DIdefix_RECONSTRUCTION=Parabolic (enable PPM reconstruction), -DIdefix_MPI=ON (enable mpi), -DKokkos_ENABLE_OPENMP=ON (enable openmp parallelisation), etc... For more complex target architectures, it is recommended to use cmake GUI launching ccmake $IDEFIX_DIR in place of cmake and then switching on the required options. See the online documentation for details.

One can then compile the code:

make -j8

Running

serial (gpu/cpu), openMP (cpu)

simple launch the executable

./idefix

With MPI (cpu)

-dec can be used to specify a domain decomposition manually.

It can be omitted for 1D problems, or if NX, NY, NZ and nproc are all powers of 2. Otherwise, -dec is mandatory. For instance, in 2D, using a 2x2 domain decomposition:

mpirun -np 4 ./idefix -dec 2 2

or in 3D, using a 1x2x4 decomposition:

mpirun -np 8 ./idefix -dec 1 2 4

With MPI (gpu)

The same rules for cpu domain decomposition applies for gpus. In addition, one should manually specify how many GPU devices one wants to use per node. Example, in a run with 2 nodes, 4 gpu per node, one would launch idefix with

mpirun -np 8 ./idefix -dec 1 2 4 --kokkos-num-devices=4

Profiling

use the embedded profiling tool by adding "-profile" when calling idefix (no need to recompile)

./idefix -profile

Debugging

Add -DIdefix_DEBUG=ON when calling cmake, or activate the Idefix_DEBUG option in ccmake, and recompile. Note that this option triggers a lot of outputs and memory access checks which significantly slow down the code.

Code Validation

Most of tests provided in the test/ directory can be validated against analytical solution (standard test) and/or pre-computed solutions (non-regression tests). Note that the validation relies on large reference files that are stored in the separate idefix-code/reference repository that is cloned as a submodule.

Ensure that reference files were properly downloaded (in the reference/ directory of the root of idefix) before attempting to validate the code.

In order to do a full validation of a particular test (with all of the possible combination of algorithms), use the script testme.py with the -all option, as in e.g.:

cd $IDEFIX_DIR/test/HD/sod
./testme.py -all

Tests require Python 3 along with some third party dependencies to be installed. To install those deps, run

pip install -r test/python_requirements.txt

Contributing

Idefix is developed with the help of the pre-commit framework. We use cpplint to validate code style, mostly following the Google standards for C++, and several pre-commit hooks to automatically fix some coding bad practices.

It is recommended (though not mandatory) to install pre-commit by running the following script from the top level of the repo

python3 -m pip install pre-commit
pre-commit install

Then, as one checks in their contribution with git commit, pre-commit hooks may perform changes in situ. One then needs to re-add and enter the git commit command again for the commit to be validated. Note that an important hook that does not perform auto-fixes is cpplint, so contributors need to accomodate for this one by hand.

Note that if for any reason you do not wish, or are unable to install pre-commit in your environment, formatting errors will be caught by our CI after you open a merge-request.

idefix's People

Contributors

dutta-alankar avatar glesur avatar neutrinoceros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

idefix's Issues

Doc - [merged]

In GitLab by @neutrinoceros on Jan 5, 2021, 10:53

Merges doc -> master

minor improvements to README.md
Most notably, add the url for compiled docs.

No executable bits in non executable text files - [merged]

In GitLab by @neutrinoceros on Jan 17, 2021, 12:04

Merges no_executable_bits -> master

Add a pre-commit hook to forbid executable bits are accidentally added to text files without shebang and correct the 22 ones files in question found in the repo.

Because most of them are inifiles, here's how I corrected them in just two lines.

git ls-files **/*.ini | xargs chmod -x
chmod -x idefix_pytools/sod.py

Hotfix deploy ci - [merged]

In GitLab by @neutrinoceros on Jan 7, 2021, 11:48

Merges hotfix_deploy_ci -> master

fix #4

solution was documented on stack-overflow

while I'm at it I added a pre-commit hook to validate .gitlab-ci.yml locally

edit: taking this back. The hook in question is broken because it doesn't automatically install one of its deps.

Python testing framework - [merged]

In GitLab by @neutrinoceros on Jan 14, 2021, 17:39

Merges python_testing_framework -> master

Currently the repo shows up as 25% Python while it's really just a handful of lines duplicated over and over
Screen_Shot_2021-01-14_at_17.31.45

I propose a to unify the python testing framework into a single reusable module.

performance indication overflown when the grid is large

When the grid size is large, the total number of grid points computed by TimeIntegrator to display the performance during the last integration gets an overflow, leading to negative perfs. The bug is here:

double rawperf = (timer.seconds()-lastLog) / (data.mygrid->np_int[IDIR]*data.mygrid->np_int[JDIR]*data.mygrid->np_int[KDIR]*cyclePeriod);

one-liner log entries ?

In GitLab by @neutrinoceros on Jan 26, 2021, 23:40

Currently, a single TimeIntegrator log entry is printed in the following format

TimeIntegrator: t=999.851 Cycle 644000 dt=0.00159374
	 3.41014e+06 cell updates/second

It would be cleaner to log in fixed-width columns such as

Timeintegrator:      t     |    Cycle    |      dt     |  cell updates/s
Timeintegrator:    999.851 |    644000   |  0.00159374 |   3.41014e+06

such that the final log file could easily be reduced to a csv-compatible form, for instance

./idefix > run.log
cat run.log | grep Timeintegrator | awk -F ":" '{print $2}'

HAVE_ENERGY is ill-defined

HAVE_ENERGY is set in definitions.hpp by user, but there is nothing checking that it is actually 1. Worse: if HAVE_ENERGY is defined to 0, then the code is inconsistent since there are #ifdef HAVE_ENERGY in the Hydro class (which assumes energy is defined), but at the same time, PRS is absent from Vc since HAVE_ENERGY=0.

feature idea: auto restart

In GitLab by @neutrinoceros on Jan 26, 2021, 11:20

-restart is especially useful when a walltime was set on the job scheduler. Currently, this option takes an int argument to represent the output number to restart from. However, when chaining jobs, it is not necessarily trivial to predict which output number is going to be last outputted. Detecting it at runtime is a simple enough task, but copy-pasting the required code in jobs submission scripts seems like a poor choice (in particular if it's buggy). I suggest we implement such a feature in idefix itself so that -restart implicitly targets the latest existing output when the number is unspecified.

Pipeline broken due to bash errors in checks.sh

Pipeline won’t run on several machines because of checks.sh which have been modified to automatically detect idefix path. (See error last night in the pipeline)

This should be fixed so that it is more robust, or reverted to previous checks.sh.

Doc setup - [merged]

Merges docSetup -> master

some additional information regarding the code. Still a lot to write, but the programming guide might be helpful

Contrib docs - [merged]

In GitLab by @neutrinoceros on Jan 7, 2021, 22:17

Merges contrib-docs -> master

  • add contributing guidelines (introduce pre-commit)
  • add a .git-blame-ignore-revs file to keep git blame useful.

Linting with pre-commit hooks - [merged]

In GitLab by @neutrinoceros on Jan 6, 2021, 20:14

Merges pre-commit-hook_linter -> master

Adopt pre-commit hooks to lint and auto-fix some nitpicky style mistakes instead of a custom bash script + a vendored clone of cpplint.py.

pre-commit simplifies the linting process by

  • lifting the burden of maintaining code-checkers locally
  • automating code-checks on everyone's machine

Some of the hooks used here will also auto-fix mistakes instead of just reporting them (like trailing whitespaces and space-tabs mixing).
Note that pre-commit hooks are installed in isolated environments so they do not interact with the external one.

Note that the following rules originally enforced by test/style/check_idefix_style.sh are currently not reproduced

  • forbid }}
  • left-justify all #pragmas
  • enforcement of std:: before sqrt or cbrt
  • forbid executable source files

However, I the first 2 of those could be auto-fixed with a clang-format hook (which would de facto make cpplint useless).

In the process I did some house keeping to separate linting for actual tests in gitlab's CI config file.

WIP: Pre commit.clang format - [closed]

In GitLab by @neutrinoceros on Jan 7, 2021, 14:37

Merges pre-commit.clang-format -> master

  • Replace cpplint hook with clang-format
  • format the whole code base
  • add .git-blame-ignore-revs to keep git-blame usable
  • add "contributing" docs

maint: pin kokkos version to 3.1.01 - [merged]

In GitLab by @neutrinoceros on Jan 12, 2021, 22:04

Merges pin_kokkos -> master

This is intended to solve the issue of not having a properly pinned version for Kokkos as submodule.
Judging by how the diff looks, it seems to me that we already have a pinned version. Note that this change is technically a backpedalling move to Kokkos 3.1.01, which is exactly one commit earlier than the previously pinned version. My bet is that it won't break anything on Idedfix's side, and the benefit is that this version has a well identified release number attached, which is always preferable to a somewhat unstable and impossible-to-recall git sha (IMHO).

maint: add 4 simple hooks - [merged]

In GitLab by @neutrinoceros on Jan 7, 2021, 19:22

Merges more_hooks -> master

Add:

  • markdown-toc: auto-gen a Table of Content in README.md (after I placed a <!-- toc --> token manually)
  • no-commit-to-branch: forbid direct (accidental) commits to master
  • check-merge-conflict: prevent accidental committing of git-conflict markers
  • check-yaml: check that yaml files (.gitlab-ci.yml) are parseable. This is not a proper validation against gitlab's expectations but it's a first level defense against mistakes.

New output Class - [merged]

Merges refurbOutputs -> master

This push introduces a new global Output class, which manage Vtk, dumps, user analysis and user-defined fields in vtk files.

Most notably, it changes the Setup class: Output is given as an argument of the constructor, and there is no MakeAnalysis method anymore. Analysis should now be enrolled by the Output object.

Analysis is now performed, and is used in the HallWhistler test as an example.

This push also cleans up dependencies and moves signal handling to the Input class, which is more logical (a signal is just another type of input).

Should also be coming later in this push the handling of user-def fields in vtk outputs.

Warning noise from Kokkos

In GitLab by @neutrinoceros on Jan 25, 2021, 14:23

Compiling idefix generates a lot of occurrences of this warning on my machine

warning: argument unused during compilation: '--gcc-toolchain=/usr' [-Wunused-command-line-argument]

I think this comes from Kokkos. I think it'd be worth disabling it if there's nothing else we can do about it because it tends to shadow more important warnings and errors.
I'm noting this down for later reference, when/if I find a solution to this.

how is gamma set?

The examples have both gamma set explicitely in setup.cpp calling Hydro::SetGamma(), and examples using gamma in input.ini which is initialized by Hydro constructor.

We should have only one method to initialise gamma.

maint: workflow optimisations - [closed]

In GitLab by @neutrinoceros on Jan 7, 2021, 19:11

Merges ci-conf -> master

Add the following rules to avoid unnecessary CI queuing

  • only deploy the docs if they are updated
  • only run integration tests if either src/, test/ or .gitlab-ci.yml is updated.

Note: maybe it's preferable to run integration test no matter what on master... I will think about this.

human readable completion message

In GitLab by @neutrinoceros on Jan 26, 2021, 23:20

Currently idefix prints the total runtime in seconds, like for instance

Completed in 8064.1 seconds and 644094 cycles

it'd be nicer to get it in a %d%h%m%s format

Run tests from anywhere - [merged]

In GitLab by @neutrinoceros on Dec 4, 2020, 12:20

Merges test_from_anywhere -> master

WIP (don't merge this yet)
Changes to test/checks.sh so that it's not required to run cd $IDEFiX_DIR/test to run the script.

I also want to add a warning there in case the env var ($IDEFiX_DIR) has an external and different def.

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.