Coder Social home page Coder Social logo

opm-linear-solver-lab's Introduction

opm-linear-solver-lab

Experimental playground for testing out linear solvers in OPM Flow.

Compiling

We assume you have opm and dune in your prefix path. Compiling should just be

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Note that you probably want to specify CMAKE_PREFIX_PATH to point to the locations of the OPM and Dune build folder, that is

# from build. 
# IMPORTANT: Notice the quotation marks around the prefix path. 
# This is IMPORTANT when you have multiple paths
cmake .. -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_PREFIX_PATH="/path/to/opm-common/build;/path/to/opm-grid/build;MOREPATHSHERE"

To simplify this process, we've added the script build_helpers/prefix_path.sh to generate this prefix path. If you directory structure looks like this:

#DUNE
/some/path/for/dune/dune-common/build
/some/path/for/dune/dune-grid/build
/some/path/for/dune/dune-geometry/build
/some/path/for/dune/dune-istl/build

#OPM
/some/path/other/path/for/opm/opm-common/build
/some/path/other/path/for/opm/opm-grid/build
/some/path/other/path/for/opm/opm-models/build
/some/path/other/path/for/opm/opm-simulators/build

you can run cmake as

# from build. 
cmake .. -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_PREFIX_PATH="$(bash ../build_helpers/prefix_path.sh /some/path/other/path/for/opm/ /some/path/for/dune/dune-common/)"

Note on libfmt

You probably need to have libfmt installed. On Ubuntu this can be accomplished by installing

sudo apt install libfmt-dev

Alternatively you can manually donwload and install libfmt. Make sure to extend your CMAKE_PREFIX_PATH to contain the install directory of libfmt.

Running

From the build folder, you can run eg.

./linsolverlab \
    -x ../examples/matrices/spe1/rhs.mm \
    -y  ../examples/matrices/spe1/rhs.mm  \
    -m  ../examples/matrices/spe1/matrix.mm \
    -c ../examples/configurations/cpu/ilu0.json \
    -g ../examples/configurations/gpu/cuilu0.json

Example output

{
    "CPU": {
        "runtime": "21541",
        "failed_by_exception": "false",
        "iterations": "25",
        "reduction": "9.463892568041427e-13",
        "converged": "true",
        "conv_rate": "0.33040209473507992",
        "elapsed": "0.021522673999999999",
        "condition_estimate": "-1"
    },
    "GPU": {
        "runtime": "21831",
        "failed_by_exception": "false",
        "iterations": "25",
        "reduction": "3.532348061635463e-13",
        "converged": "true",
        "conv_rate": "0.31763074967064442",
        "elapsed": "0.02177946",
        "condition_estimate": "-1"
    }
}

Running only preconditioner

./linsolverlab \
    -x ../examples/matrices/spe1/rhs.mm \
    -y  ../examples/matrices/spe1/rhs.mm  \
    -m  ../examples/matrices/spe1/matrix.mm \
    -c ../examples/configurations/cpu/ilu0_onlypreconditioner.json \
    -g ../examples/configurations/gpu/cuilu0_onlypreconditioner.json

Example output

{
    "CPU": {
        "runtime": "6",
        "failed_by_exception": "false",
        "iterations": "1",
        "reduction": "0",
        "converged": "true",
        "conv_rate": "1",
        "elapsed": "0",
        "condition_estimate": "-1"
    },
    "GPU": {
        "runtime": "2396",
        "failed_by_exception": "false",
        "iterations": "1",
        "reduction": "0",
        "converged": "true",
        "conv_rate": "1",
        "elapsed": "0",
        "condition_estimate": "-1"
    }
}

Running benchmarks

OPM-flow

Generating benchmark data

# usage: run_opm_benchmark.py <subfolder1> [<subfolder2> ...]
python benchmarking_scripts/run_opm_benchmark.py sleipner

Adjusting the experiment in the file

    json_files = [
        'examples/configurations/cpu/ilu0.json --block-size 2',
        'examples/configurations/cpu/dilu.json --block-size 2',
        'examples/configurations/gpu/cuilu0.json --block-size 2',
        'examples/configurations/gpu/cudilu.json --block-size 2'
    ]
    matrix_root = "./examples/matrices"  # folder where the matrix files can be found
    limit = 10  # Adjust this to change the number of matrices processed per directory

Plotting the results

python benchmarking_scripts/process_and_plot_opm.py

opm-linear-solver-lab's People

Contributors

kjetilly avatar akva2 avatar jakobtorben avatar

Watchers

Olav Møyner avatar Atgeirr Flø Rasmussen avatar  avatar  avatar Jon avatar Kjetil Andre Johannessen avatar Håvard Heitlo Holm avatar Vinícius Oliveira Martins avatar  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.