Commit 7634c98e authored by Gregor Olenik's avatar Gregor Olenik
Browse files

Merge branch 'dev' of github.com:greole/OGL into dev

parents 5e48661e ba43036e
name: CMake
on: [push]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
env:
FOAM_SRC: /home/runner/OpenFOAM/OpenFOAM-8/src
FOAM_USER_LIBBIN: /home/go/OpenFOAM/OpenFOAM-8/platforms
steps:
- name: Setup OpenFOAM Directory
# Create OpenFOAM directory and clone
run: mkdir -p ~/OpenFOAM
- name: Clone OpenFOAM
# Clone OpenFOAM
run: git clone --depth 1 https://github.com/OpenFOAM/OpenFOAM-8.git ~/OpenFOAM/OpenFOAM-8
- name: Show OpenFOAM folder
# Clone OpenFOAM
run: ls ~/OpenFOAM/OpenFOAM-8
- uses: actions/checkout@v2
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
language: cpp
sudo: true
compiler:
- gcc
dist: focal
os:
- linux
env:
- VERSION=8
- VERSION=7
cache:
directories:
- $HOME/OpenFOAM
addons:
apt:
update: true
packages:
- flexc++
- libfl-dev
- lcov
- libopenmpi-dev
before_install:
- sudo sh -c "wget --no-check-certificate -O - https://dl.openfoam.org/gpg.key | apt-key add -"
- sudo add-apt-repository http://dl.openfoam.org/ubuntu
- sudo apt update
install:
- sudo apt-get -y install openfoam$VERSION
- source /opt/openfoam$VERSION/etc/bashrc
before_script:
- cmake --version
- mkdir build
- cd build
- cmake ..
script:
- make -j4
......@@ -80,12 +80,6 @@ endif()
option(BUILD_SHARED_LIBS "Build shared library" ON)
add_library(OGL "" )
#g++ -m64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor
# -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes
# -O0 -fdefault-inline -ggdb3 -DFULLDEBUG -ftemplate-depth-100
# -I/home/go/OpenFOAM/OpenFOAM-6/src/finiteVolume/lnInclude
# -I/home/go/OpenFOAM/OpenFOAM-6/src/meshTools/lnInclude
# -std=c++14 -ggdb3 -O0 -fno-omit-frame-pointer -IlnInclude -I. -I/home/go/OpenFOAM/OpenFOAM-6/src/OpenFOAM/lnInclude -I/home/go/OpenFOAM/OpenFOAM-6/src/OSspecific/POSIX/lnInclude -fPIC -c common/common.C -o Make/linux64GccDPInt32Debug/common/common.o
add_compile_definitions(
WM_LABEL_SIZE=32
WM_ARCH_OPTION=64
......@@ -129,7 +123,6 @@ target_link_libraries(OGL
Ginkgo::ginkgo
)
install(TARGETS OGL
DESTINATION $ENV{FOAM_USER_LIBBIN}
)
......
# OpenFOAM Ginkgo Layer (OGL)
![build](https://github.com/greole/OGL/actions/workflows/cmake.yml/badge.svg)
[![Build Status](https://travis-ci.com/greole/OGL.svg?branch=dev)](https://travis-ci.com/greole/OGL)
A wrapper for [ginkgo](https://github.com/ginkgo-project/ginkgo) solver to provide GPGPU capabilities to [OpenFOAM](https://openfoam.org/)
......@@ -21,7 +21,6 @@ See also [ginkgo's](https://github.com/ginkgo-project/ginkgo) documentation for
the `system/controlDict` includes the `OGL.so` file:
libs ("libOGL.so");
## Usage
......
......@@ -41,18 +41,15 @@ class GKOBiCGStabFactory {
private:
// executor where Ginkgo will perform the computation
const label maxIterI_;
const scalar toleranceI_;
const word preconditioner_;
const label blockSize_;
public:
GKOBiCGStabFactory(const dictionary &controlDict_)
: maxIterI_(controlDict_.lookupOrDefault("maxIter", label(1000))),
toleranceI_(controlDict_.lookupOrDefault("tolerance", scalar(1e-6))),
preconditioner_(
controlDict_.lookupOrDefault("preconditioner", word("none"))){};
GKOBiCGStabFactory(const dictionary &dictionary_)
: preconditioner_(
dictionary_.lookupOrDefault("preconditioner", word("none"))),
blockSize_(dictionary_.lookupOrDefault("maxBlockSize", label(16))){};
std::unique_ptr<gko::solver::Bicgstab<double>::Factory,
std::default_delete<gko::solver::Bicgstab<double>::Factory>>
......@@ -61,7 +58,7 @@ public:
std::vector<std::shared_ptr<const gko::stop::CriterionFactory>>
criterion_vec) const
{
// if (preconditioner_ == "none")
if (preconditioner_ == "BJ") return create_BJ(exec, criterion_vec);
return create_default(exec, criterion_vec);
};
......@@ -79,17 +76,15 @@ public:
std::unique_ptr<gko::solver::Bicgstab<double>::Factory,
std::default_delete<gko::solver::Bicgstab<double>::Factory>>
create_BJ(std::shared_ptr<gko::Executor> exec) const
create_BJ(std::shared_ptr<gko::Executor> exec,
std::vector<std::shared_ptr<const gko::stop::CriterionFactory>>
criterion_vec) const
{
using bj = gko::preconditioner::Jacobi<>;
return gko::solver::Bicgstab<scalar>::build()
.with_criteria(
gko::stop::Iteration::build().with_max_iters(maxIterI_).on(
exec),
gko::stop::ResidualNormReduction<scalar>::build()
.with_reduction_factor(toleranceI_)
.on(exec))
.with_preconditioner(bj::build().with_max_block_size(8u).on(exec))
.with_criteria(criterion_vec)
.with_preconditioner(
bj::build().with_max_block_size(blockSize_).on(exec))
.on(exec);
};
};
......@@ -117,7 +112,7 @@ public:
const lduInterfaceFieldPtrsList &interfaces,
const dictionary &solverControls)
: GKOlduBaseSolver(fieldName, matrix, interfaceBouCoeffs,
interfaceIntCoeffs, interfaces, solverControls){};
interfaceIntCoeffs, interfaces, solverControls){};
//- Destructor
virtual ~GKOBiCGStab(){};
......
......@@ -40,10 +40,13 @@ private:
const word preconditioner_;
const label blockSize_;
public:
GKOCGFactory(const dictionary &controlDict_)
GKOCGFactory(const dictionary &dictionary_)
: preconditioner_(
controlDict_.lookupOrDefault("preconditioner", word("none"))){};
dictionary_.lookupOrDefault("preconditioner", word("none"))),
blockSize_(dictionary_.lookupOrDefault("maxBlockSize", label(16))){};
std::unique_ptr<gko::solver::Cg<double>::Factory,
std::default_delete<gko::solver::Cg<double>::Factory>>
......@@ -77,7 +80,8 @@ public:
using bj = gko::preconditioner::Jacobi<>;
return gko::solver::Cg<scalar>::build()
.with_criteria(criterion_vec)
.with_preconditioner(bj::build().with_max_block_size(8u).on(exec))
.with_preconditioner(
bj::build().with_max_block_size(blockSize_).on(exec))
.on(exec);
};
};
......
......@@ -184,7 +184,7 @@ public:
// to avoid unnecessary index re-orderings
// when v contains elements of equal values
std::stable_sort(sorting_idxs_->data(),
&sorting_idxs_->data()[nCells()],
&sorting_idxs_->data()[nElems()],
[this](size_t i1, size_t i2) {
return row_idxs_[i1] < row_idxs_[i2];
});
......@@ -230,8 +230,8 @@ public:
void sort_GKOMatrix() const
{
std::vector<scalar> tmp_values(nElems());
std::vector<scalar> tmp_col_idxs(nElems());
std::vector<scalar> tmp_row_idxs(nElems());
std::vector<label> tmp_col_idxs(nElems());
std::vector<label> tmp_row_idxs(nElems());
for (label i = 0; i < nElems(); i++) tmp_values[i] = values_[i];
for (label i = 0; i < nElems(); i++) tmp_col_idxs[i] = col_idxs_[i];
......@@ -323,8 +323,8 @@ public:
}
if (get_export())
export_system(fieldName(), gko::lend(gkomatrix), gko::lend(x),
gko::lend(b));
export_system(fieldName(), gko::lend(gkomatrix), gko::lend(x),
gko::lend(b));
solverPerf.initialResidual() = compute_residual(
......
......@@ -247,7 +247,7 @@ class Case:
return (
Path(self.test_base)
/ Path(self.executor.local_path)
/ "{}-{}".format(self.fields, self.solver)
/ "{}-{}-{}".format(self.fields, self.solver, self.preconditioner)
/ str(self.resolution)
)
......@@ -277,7 +277,7 @@ class Case:
\\nminIter {};\
\\nmaxIter 10000;\
\\nupdateSysMatrix no;\
\\nsort 0;\
\\nsort yes;\
\\nexecutor {};".format(
matrix_solver,
self.tolerance,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment