Skip to content

Commit

Permalink
Merge pull request #6 from DamynChipman/develop
Browse files Browse the repository at this point in the history
Bug fixes to merge into new release
  • Loading branch information
DamynChipman authored Jan 18, 2024
2 parents 659ca7e + e428a51 commit 5f6bd2c
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 132 deletions.
7 changes: 0 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Expand Down
51 changes: 23 additions & 28 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,59 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [macos-latest]
build_type: [Debug]
os: [macos-latest, ubuntu-latest]
build_type: [Release, Debug]
mpi: ['mpich', 'openmpi']
c_compiler: [mpicc]
cpp_compiler: [mpic++]
fortran_compiler: [gfortran]

include:
- os: macos-latest
mpi_path: /usr/local
- os: ubuntu-latest
mpi_path: /usr
flags: -fno-lto
steps:
- uses: actions/checkout@v3
- uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi }}
- uses: modflowpy/install-gfortran-action@v1

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_CXX_FLAGS=${{ matrix.flags }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_C_FLAGS=${{ matrix.flags }}
-DCMAKE_Fortran_COMPILER=${{ matrix.fortran_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DMPI_PATH=/usr/local
-DMPI_PATH=${{ matrix.mpi_path }}
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
run: ctest --build-config ${{ matrix.build_type }} --rerun-failed --output-on-failure
# - name: Run
# working-directory: ${{ steps.strings.outputs.build-output-dir }}/examples/elliptic-single
# run: |
# mpiexec -n 2 elliptic-single
# - uses: actions/upload-artifact@v4
# with:
# name: elliptic-mesh
# path: ${{ steps.strings.outputs.build-output-dir }}/examples/elliptic-single/*vtu
38 changes: 4 additions & 34 deletions src/Patches/FiniteVolume/FiniteVolumeGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,11 @@ FiniteVolumeGrid::FiniteVolumeGrid(MPI::Communicator comm, int nx, double x_lowe
ny_(ny),
y_lower_(y_lower),
y_upper_(y_upper),
dy_((y_upper - y_lower)/ny) {

//
// create();
// setFromOptions();
// setup();

}

FiniteVolumeGrid::~FiniteVolumeGrid() {
// if (dm == PETSC_NULLPTR) {
// DMDestroy(&dm);
// }
}

Petsc::ErrorCode FiniteVolumeGrid::create() {
if (dm == PETSC_NULLPTR) {
int dof_vertex = 0;
int dof_face = 0;
int dof_element = 1;
int stencil_width = 1;
return DMStagCreate2d(this->getComm(), DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, nx_, ny_, PETSC_DECIDE, PETSC_DECIDE, dof_vertex, dof_face, dof_element, DMSTAG_STENCIL_STAR, stencil_width, nullptr, nullptr, &dm);
}
else {
return 0;
}
}

Petsc::ErrorCode FiniteVolumeGrid::setFromOptions() {
return DMSetFromOptions(dm);
}
dy_((y_upper - y_lower)/ny)
{}

Petsc::ErrorCode FiniteVolumeGrid::setup() {
return DMSetUp(dm);
}
FiniteVolumeGrid::~FiniteVolumeGrid()
{}

double FiniteVolumeGrid::point(DimensionIndex dim, int index) {
double p = 0;
Expand Down
35 changes: 0 additions & 35 deletions src/Patches/FiniteVolume/FiniteVolumeGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

#include <string>

#include <petsc.h>
#include <petscdmda.h>

#include "../../EllipticForestApp.hpp"
#include "../../MPI.hpp"
#include "../../PatchGrid.hpp"
Expand All @@ -21,11 +18,6 @@ enum DimensionIndex {
Y = 1
};

namespace Petsc {
using DataManagement = DM;
using ErrorCode = PetscErrorCode;
} // NAMESPACE : Petsc

class FiniteVolumeGrid : public MPI::MPIObject, public PatchGridBase<double> {

protected:
Expand Down Expand Up @@ -80,12 +72,6 @@ class FiniteVolumeGrid : public MPI::MPIObject, public PatchGridBase<double> {

public:

/**
* @brief The PETSc data management handle
*
*/
Petsc::DataManagement dm = PETSC_NULLPTR;

/**
* @brief Construct a new FiniteVolumeGrid object (default)
*
Expand All @@ -111,27 +97,6 @@ class FiniteVolumeGrid : public MPI::MPIObject, public PatchGridBase<double> {
*/
~FiniteVolumeGrid();

/**
* @brief Creates the PETSc components of the grid
*
* @return Petsc::ErrorCode
*/
Petsc::ErrorCode create();

/**
* @brief Sets the PETSc components from options of the grid
*
* @return Petsc::ErrorCode
*/
Petsc::ErrorCode setFromOptions();

/**
* @brief Sets the grid up
*
* @return Petsc::ErrorCode
*/
Petsc::ErrorCode setup();

/**
* @brief Returns the coordinate of the cell center at `index` for dimension `dim`
*
Expand Down
12 changes: 12 additions & 0 deletions src/QuadNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class Node : public MPI::MPIObject {
*/
MPI::Communicator node_comm;

/**
* @brief Flag for if the node communicator has been set
*
*/
bool node_comm_set = false;

/**
* @brief Construct a new Node object (default)
*
Expand Down Expand Up @@ -94,6 +100,12 @@ class Node : public MPI::MPIObject {

}

~Node() {
if (node_comm_set) {
MPI_Comm_free(&node_comm);
}
}

/**
* @brief Checks if this node is owned by this rank
*
Expand Down
1 change: 1 addition & 0 deletions src/Quadtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class Quadtree : public MPI::MPIObject {
// Additional info for node
node->leaf = local_num >= 0;
node->node_comm = node_comm;
node->node_comm_set = true;

// Put in map
map[path] = node;
Expand Down
1 change: 1 addition & 0 deletions src/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <initializer_list>
#include <string>

Expand Down
28 changes: 0 additions & 28 deletions test/test_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,6 @@ TEST(Matrix, range) {

}

TEST(Matrix, get_row_and_col) {

Matrix<double> m1(3, 4, {
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12
});

Vector<double> v1({9, 10, 11, 12});

Vector<double> v2 = m1.getRow(2);
EXPECT_EQ(v2.size(), v1.size());

for (auto i = 0; i < v2.size(); i++) {
EXPECT_EQ(v2[i], v1[i]);
}

Vector<double> v3({2, 6, 10});

Vector<double> v4 = m1.getCol(1);
EXPECT_EQ(v3.size(), v3.size());

for (auto i = 0; i < v4.size(); i++) {
EXPECT_EQ(v3[i], v4[i]);
}

}

TEST(Matrix, index_sets) {

Matrix<double> m1(6, 8, {
Expand Down

0 comments on commit 5f6bd2c

Please sign in to comment.