Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
box_2D_gen_unstruc_mesh is distributed under LICENSE.txt:
BoxMeshDM is distributed under LICENSE.txt:

Copyright (c) 2025-2026 box_2D_gen_unstruc_mesh Developers
Copyright (c) 2025-2026 BoxMeshDM Developers
License: MIT, http://opensource.org/licenses/MIT

Guidelines
Expand All @@ -24,7 +24,7 @@ Contributing

Contributing code to this project assumes that

- you implicitly transfer the copyright of your contribution to the box_2D_gen_unstruc_mesh
- you implicitly transfer the copyright of your contribution to the BoxMeshDM
Developers or that your contributions are not significant enough to claim
copyright

Expand Down
2 changes: 1 addition & 1 deletion box_2D_gen_unstruc_mesh.cpp → BoxMeshDM.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "box_2D_gen_unstruc_mesh.h"
#include "BoxMeshDM.h"
#include <iostream>
#include <vector>
#include <cmath>
Expand Down
4 changes: 2 additions & 2 deletions box_2D_gen_unstruc_mesh.h → BoxMeshDM.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef BOX_2D_GEN_UNSTRUC_MESH_H
#define BOX_2D_GEN_UNSTRUC_MESH_H
#ifndef BOXMESHDM_H
#define BOXMESHDM_H

#include <petscdmplex.h>

Expand Down
40 changes: 20 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ~~~~~~~~~~~~~~~~~
# box_2D_gen_unstruc_mesh - Steven Dargaville
# Makefile for box_2D_gen_unstruc_mesh
# BoxMeshDM - Steven Dargaville
# Makefile for BoxMeshDM
#
# Must have defined PETSC_DIR and PETSC_ARCH before calling
# Copied from $PETSC_DIR/share/petsc/Makefile.basic.user
Expand Down Expand Up @@ -43,22 +43,22 @@ PETSC_LINK_LIBS_NORPATH := $(LDLIBS)
endif

# Output executable name
OUT := box_2D_gen_unstruc_mesh
OUT := BoxMeshDM

# Output the library - either static or dynamic
ifeq ($(PETSC_USE_SHARED_LIBRARIES),0)
LIB_OUT = libbox_2D_gen_unstruc_mesh.a
LIB_OUT = libboxmeshdm.a
else
# mac osx name is different
ifeq ($(shell uname -s 2>/dev/null),Darwin)
LIB_OUT = libbox_2D_gen_unstruc_mesh.dylib
LIB_OUT = libboxmeshdm.dylib
else
LIB_OUT = libbox_2D_gen_unstruc_mesh.so
LIB_OUT = libboxmeshdm.so
endif
endif

# All the files required by box_2D_gen_unstruc_mesh
OBJS := box_2D_gen_unstruc_mesh.o
# All the files required by BoxMeshDM
OBJS := BoxMeshDM.o

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Rules
Expand Down Expand Up @@ -103,10 +103,10 @@ else
# Shared library
ifeq ($(shell uname -s 2>/dev/null),Darwin)
# macOS: Link with rpath to find the dylib in current directory
$(LINK.cc) -o test_lib test_lib.o -L. -lbox_2D_gen_unstruc_mesh $(PETSC_LIB) -Wl,-rpath,@loader_path
$(LINK.cc) -o test_lib test_lib.o -L. -lboxmeshdm $(PETSC_LIB) -Wl,-rpath,@loader_path
else
# Linux: Link with rpath to find the .so in current directory
$(LINK.cc) -o test_lib test_lib.o -L. -lbox_2D_gen_unstruc_mesh $(PETSC_LIB) -Wl,-rpath,'$$ORIGIN'
$(LINK.cc) -o test_lib test_lib.o -L. -lboxmeshdm $(PETSC_LIB) -Wl,-rpath,'$$ORIGIN'
endif
endif

Expand All @@ -118,17 +118,17 @@ tests_lib: test_lib
# Tests - check executable exists and run it
# and also builds the library and tests it can be linked
# against and run
tests: box_2D_gen_unstruc_mesh
tests: BoxMeshDM
@echo "Running tests on executable..."
./box_2D_gen_unstruc_mesh
./box_2D_gen_unstruc_mesh -target_edge_length 0.002
./box_2D_gen_unstruc_mesh -target_edge_length 0.003 -final_smooth_its 5
./box_2D_gen_unstruc_mesh -target_edge_length 0.004 -integrity_check 0
./box_2D_gen_unstruc_mesh -target_edge_length 0.005 -print_stats 0
./box_2D_gen_unstruc_mesh -target_edge_length 0.006 -integrity_check 0 -print_stats 0
./box_2D_gen_unstruc_mesh -target_edge_length 0.005 -domain_width 2.0 -domain_height 0.5
$(MPIEXEC) -n 2 ./box_2D_gen_unstruc_mesh -target_edge_length 0.01 -domain_width 1.0 -domain_height 1.0
$(MPIEXEC) -n 2 ./box_2D_gen_unstruc_mesh -target_edge_length 0.005 -domain_width 2.0 -domain_height 0.5
./BoxMeshDM
./BoxMeshDM -target_edge_length 0.002
./BoxMeshDM -target_edge_length 0.003 -final_smooth_its 5
./BoxMeshDM -target_edge_length 0.004 -integrity_check 0
./BoxMeshDM -target_edge_length 0.005 -print_stats 0
./BoxMeshDM -target_edge_length 0.006 -integrity_check 0 -print_stats 0
./BoxMeshDM -target_edge_length 0.005 -domain_width 2.0 -domain_height 0.5
$(MPIEXEC) -n 2 ./BoxMeshDM -target_edge_length 0.01 -domain_width 1.0 -domain_height 1.0
$(MPIEXEC) -n 2 ./BoxMeshDM -target_edge_length 0.005 -domain_width 2.0 -domain_height 0.5
$(MAKE) lib
$(MAKE) tests_lib
@echo "All tests completed successfully!"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ There are five input variables that can be changed from the command line:

For example, after building the executable we can generate a mesh using 2 MPI ranks on the command line by calling:

mpiexec -n 2 ./box_2D_gen_unstruc_mesh
mpiexec -n 2 ./BoxMeshDM

which will generate a mesh with the default parameters. To decrease the edge length for example,

mpiexec -n 2 ./box_2D_gen_unstruc_mesh -target_edge_length 0.001
mpiexec -n 2 ./BoxMeshDM -target_edge_length 0.001

If you wish to write out the meshes generated this way, ensure PETSc has been configured with HDF5 (``--download-hdf5``) and run the code with ``-write_mesh true``. The resulting ``.h5`` file can be read into a PETSc DMPlex with ``-dm_plex_filename box_mesh.h5``.

Expand All @@ -54,11 +54,11 @@ To visualise the mesh, from the command line run ``${PETSC_DIR}/lib/petsc/bin/pe

For large scale use, the code can be compiled as a library. Hence instead of writing out the mesh, the routine ``GenerateBoxMeshDM`` can be called directly from existing code. This returns a parallel, load balanced PETSc DMPlex object that can be used without I/O.

Ensure ``PETSC_DIR`` and ``PETSC_ARCH`` environmental variables are set and then call ``make clean && make lib``. You then need to include the ``.h`` file in your code and link to the output library ``libbox_2D_gen_unstruc_mesh``.
Ensure ``PETSC_DIR`` and ``PETSC_ARCH`` environmental variables are set and then call ``make clean && make lib``. You then need to include the ``.h`` file in your code and link to the output library ``libboxmeshdm``.

In your code, to generate a PETSc DM that can then be used as normal, you can call in C/C++ (see ``test_lib.c``):

#include "box_2D_gen_unstruc_mesh.h"
#include "BoxMeshDM.h"

// ...

Expand Down
8 changes: 4 additions & 4 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG BRANCH=main
ARG ARCH=arch-linux-c-opt

LABEL maintainer="Steven Dargaville"
LABEL description="box_2D_gen_unstruc_mesh"
LABEL description="BoxMeshDM"

ENV CHECKOUT_BRANCH=$BRANCH
ENV PETSC_ARCH=$ARCH
Expand All @@ -21,12 +21,12 @@ WORKDIR /build
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Copy the source code and build it
COPY . /build/box_2D_gen_unstruc_mesh
COPY . /build/BoxMeshDM

RUN set -e; \
cd box_2D_gen_unstruc_mesh && \
cd BoxMeshDM && \
make clean && make lib && \
make clean && make && \
make clean && make tests

WORKDIR /build/box_2D_gen_unstruc_mesh
WORKDIR /build/BoxMeshDM
8 changes: 4 additions & 4 deletions dockerfiles/Dockerfile_64_bit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG BRANCH=main
ARG ARCH=arch-linux-c-opt

LABEL maintainer="Steven Dargaville"
LABEL description="box_2D_gen_unstruc_mesh_64_bit"
LABEL description="BoxMeshDM_64_bit"

ENV CHECKOUT_BRANCH=$BRANCH
ENV PETSC_ARCH=$ARCH
Expand All @@ -17,12 +17,12 @@ ENV PETSC_OPTIONS="-on_error_abort"
WORKDIR /build

# Copy the source code and build it
COPY . /build/box_2D_gen_unstruc_mesh
COPY . /build/BoxMeshDM

RUN set -e; \
cd box_2D_gen_unstruc_mesh && \
cd BoxMeshDM && \
make clean && make lib && \
make clean && make && \
make clean && make tests

WORKDIR /build/box_2D_gen_unstruc_mesh
WORKDIR /build/BoxMeshDM
14 changes: 7 additions & 7 deletions dockerfiles/Dockerfile_pflare
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG BRANCH=main
ARG ARCH=arch-linux-c-opt

LABEL maintainer="Steven Dargaville"
LABEL description="box_2D_gen_unstruc_mesh_pflare"
LABEL description="BoxMeshDM_pflare"

ENV CHECKOUT_BRANCH=$BRANCH
ENV PETSC_ARCH=$ARCH
Expand All @@ -20,23 +20,23 @@ WORKDIR /build
# Ensure pipelines fail if any stage fails
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ENV BOX_PREFIX=/build/box_2D_gen_unstruc_mesh
ENV BOX_PREFIX=/build/BoxMeshDM

# Copy the source code and build it
COPY . /build/box_2D_gen_unstruc_mesh
COPY . /build/BoxMeshDM

# Build the library version only
RUN set -e; \
cd box_2D_gen_unstruc_mesh && \
cd BoxMeshDM && \
make clean && make lib

ENV CFLAGS="${CFLAGS} -I${BOX_PREFIX}" \
LDFLAGS="-Wl,-rpath,${BOX_PREFIX} ${LDFLAGS}" \
LDLIBS="${LDLIBS} -L${BOX_PREFIX} -lbox_2D_gen_unstruc_mesh" \
LDLIBS="${LDLIBS} -L${BOX_PREFIX} -lboxmeshdm" \
LD_LIBRARY_PATH="${BOX_PREFIX}:${LD_LIBRARY_PATH}"

# Use the branch supg_box_mesh in PFLARE which modifies the supg and DG
# tests to use the box_2D_gen_unstruc_mesh library to generate a mesh
# tests to use the BoxMeshDM library to generate a mesh
# Verify the solution is 1 everywhere in serial and parallel
RUN set -e; \
cd /build && \
Expand All @@ -52,4 +52,4 @@ RUN set -e; \
mpiexec -n 2 ./adv_dg_upwind -target_edge_length 0.01 -pc_type air -verify_solution && \
mpiexec -n 2 ./adv_dg_upwind -target_edge_length 0.01 -domain_height 2.0 -pc_type air -verify_solution

WORKDIR /build/box_2D_gen_unstruc_mesh
WORKDIR /build/BoxMeshDM
2 changes: 1 addition & 1 deletion test_lib.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <petscsys.h>
#include "box_2D_gen_unstruc_mesh.h"
#include "BoxMeshDM.h"

int main(int argc, char** argv) {
PetscCall(PetscInitialize(&argc, &argv, NULL, NULL));
Expand Down
Loading