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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 41 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Deploy

on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-docs
cancel-in-progress: true

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Install dependencies
run: |
sudo apt install doxygen
sudo apt install graphviz
python3 -m pip install sphinx sphinx_rtd_theme sphinxcontrib-bibtex
python3 -m pip install -I docutils==0.16 # Downgrade docutils so that bullet points render properly with Sphinx

- name: Build doxygen
run: |
doxygen doxyfile

- name: Build sphinx
run: |
cd Sphinx
make github

- name: Deploy
if: github.event_name == 'push' && github.repository == 'rmrsk/EBGeometry' && github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
folder: docs
clean: false
17 changes: 14 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
*.o
*.d
*.F90
Examples/AMReX/plt*
Examples/AMReX/tmp_build_dir
Examples/AMReX/Backtrace.*
*.hdf5
pout.*
*.mod
docs/**
Examples/AMReX_DCEL/plt*
Examples/AMReX_DCEL/tmp_build_dir
Examples/AMReX_DCEL/Backtrace.*
Examples/AMReX_Shapes/plt*
Examples/AMReX_Shapes/tmp_build_dir
Examples/AMReX_Shapes/Backtrace.*
Examples/Chombo3_Shapes/d/**
Examples/Chombo3_Shapes/o/**
Examples/Chombo3_Shapes/f/**
Examples/Chombo3_Shapes/d/**

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Examples/AMReX/main.cpp → Examples/AMReX_DCEL/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ int main (int argc, char* argv[]) {
}

// Create our signed distance function. K is the tree degree while T is the EBGeometry precision.
constexpr int K = 2;
constexpr int K = 4;

using T = float;
using Vec3 = EBGeometry::Vec3T<T>;
Expand Down
26 changes: 26 additions & 0 deletions Examples/AMReX_Shapes/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
DEBUG = FALSE
TEST = TRUE
USE_ASSERTION = TRUE

USE_EB = TRUE

USE_MPI = TRUE
USE_OMP = FALSE

COMP = gnu

DIM = 3

AMREX_HOME ?= ../../../../amrex

include $(AMREX_HOME)/Tools/GNUMake/Make.defs

include ./Make.package

Pdirs := Base Boundary AmrCore EB

Ppack += $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir)/Make.package)

include $(Ppack)

include $(AMREX_HOME)/Tools/GNUMake/Make.rules
1 change: 1 addition & 0 deletions Examples/AMReX_Shapes/Make.package
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CEXE_sources += main.cpp
34 changes: 34 additions & 0 deletions Examples/AMReX_Shapes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
This example uses the embedded boundary grid generation from AMReX, using analytic SDFs from EBGeometry.
To compile this application, first install AMReX somewhere and point the AMREX_HOME environment variable to it.

Compiling
---------

Compile (with your standard AMReX settings) using

make -s -j8

Running
-------

With MPI:

mpirun -np 8 main3d.<something>.ex eb2.cover_multiple_cuts=1 which_geom=0

Some of the geometries will generate cut-cells which AMReX does not support, so the geometries should be run with eb2.cover_multiple_cuts=1.

Supported geometries
--------------------
To select different geometries, set which_geom to one of the below.

* `which_geom = 0` Sphere
* `which_geom = 1` Plane
* `which_geom = 2` Infinite cylinder
* `which_geom = 3` Finite cylinder
* `which_geom = 4` Capsule
* `which_geom = 5` Box
* `which_geom = 6` Rounded box
* `which_geom = 7` Torus
* `which_geom = 8` Infinite cone
* `which_geom = 9` Finite cone
* `which_geom = 10` Spherical shell
176 changes: 176 additions & 0 deletions Examples/AMReX_Shapes/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
/* EBGeometry
* Copyright © 2022 Robert Marskar
* Please refer to Copyright.txt and LICENSE in the EBGeometry root directory.
*/

// AMReX includes
#include <AMReX.H>
#include <AMReX_EB2.H>
#include <AMReX_EB2_IF.H>
#include <AMReX_ParmParse.H>
#include <AMReX_PlotFileUtil.H>

// Our include
#include "../../EBGeometry.hpp"

using namespace amrex;

using T = float;
using SDF = EBGeometry::SignedDistanceFunction<T>;
using Vec3 = EBGeometry::Vec3T<T>;

namespace amrex {
namespace EB2 {

/*!
@brief This is just an EBGeometry-exposed signed distance field usable with AMReX.
*/
class AMReXSDF {
public:

/*!
@brief Full constructor.
@param[in] a_filename File name. Must be a PLY file and will be parser by the PLY parser.
@param[in] a_flipSign Hook for swapping inside/outside.
*/
AMReXSDF(std::shared_ptr<SDF>& a_sdf){
m_sdf = a_sdf;
}

/*!
@brief Copy constructor.
@param[in] a_other Other SDF.
*/
AMReXSDF(const AMReXSDF& a_other) {
this->m_sdf = a_other.m_sdf;
}

/*!
@brief AMReX's implicit function definition.
*/
Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept {
return m_sdf->signedDistance(Vec3(x,y,z));
};

/*!
@brief Also an AMReX implicit function implementation
*/
inline Real operator() (const RealArray& p) const noexcept {
return this->operator()(AMREX_D_DECL(p[0],p[1],p[2]));
}

protected:

/*!
@brief EBGeometry signed distance function.
*/
std::shared_ptr<SDF> m_sdf;
};
}
}

int main (int argc, char* argv[]) {
amrex::Initialize(argc, argv);

int n_cell = 128;
int max_grid_size = 32;
int whichGeom = 0;

std::string filename;

// read parameters
ParmParse pp;
pp.query("n_cell", n_cell);
pp.query("max_grid_size", max_grid_size);
pp.query("which_geom", whichGeom);


Geometry geom;
RealBox rb;

std::shared_ptr<SDF> func;
if(whichGeom == 0){ // Sphere.
rb = RealBox({-1,-1,-1}, {1,1,1});
func = std::make_shared<EBGeometry::SphereSDF<T>> (Vec3::zero(), T(0.5), false);
}
else if(whichGeom == 1){ // Plane.
rb = RealBox({-1,-1,-1}, {1,1,1});

func = std::make_shared<EBGeometry::PlaneSDF<T> > (Vec3::zero(), Vec3::one(), false);
}
else if(whichGeom == 2){ // Infinite cylinder.
rb = RealBox({-1,-1,-1}, {1,1,1});

func = std::make_shared<EBGeometry::InfiniteCylinderSDF<T> > (Vec3::zero(), T(0.1), 2, false);
}
else if(whichGeom == 3){ // Finite cylinder.
rb = RealBox({-2,-2,-2}, {2,2,2});

func = std::make_shared<EBGeometry::CylinderSDF<T> > (-Vec3::one(), Vec3::one(), 0.25, false);
}
else if(whichGeom == 4){ // Capsule.
rb = RealBox({-2,-2,-2}, {2,2,2});

func = std::make_shared<EBGeometry::CapsuleSDF<T> > (-Vec3::one(), Vec3::one(), 0.25, false);
}
else if(whichGeom == 5){ // Box.
rb = RealBox({-2,-2,-2}, {2,2,2});

func = std::make_shared<EBGeometry::BoxSDF<T> > (-Vec3::one(), Vec3::one(), false);
}
else if(whichGeom == 6){ // Rounded box.
rb = RealBox({-2,-2,-2}, {2,2,2});

auto box = std::make_shared<EBGeometry::BoxSDF<T> > (-Vec3::one(), Vec3::one(), false);
func = std::make_shared<EBGeometry::RoundedSDF<T> >(box, 0.25);
}
else if(whichGeom == 7){ // Torus.
rb = RealBox({-2,-2,-2}, {2,2,2});

func = std::make_shared<EBGeometry::TorusSDF<T> >(Vec3::zero(), 1.0, 0.25, false);
}
else if(whichGeom == 8){ // Infinite cone.
rb = RealBox({-2,-2,-2}, {2,2,2});

func = std::make_shared<EBGeometry::InfiniteConeSDF<T> >(Vec3(0.0, 0.0, 1.0), 30.0, false);
}
else if(whichGeom == 9){ // Finite cone.
rb = RealBox({-2,-2,-2}, {2,2,2});

func = std::make_shared<EBGeometry::ConeSDF<T> >(Vec3(0.0, 0.0, 1.0), 2.0, 30, false);
}
if(whichGeom == 10){ // Spherical shell.
rb = RealBox({-1,-1,-1}, {1,1,1});

auto sphere = std::make_shared<EBGeometry::SphereSDF<T>> (Vec3::zero(), T(0.5), false);
func = std::make_shared<EBGeometry::AnnularSDF<T>> (sphere, 0.1);
}

Array<int,AMREX_SPACEDIM> is_periodic{false, false, false};
Geometry::Setup(&rb, 0, is_periodic.data());
Box domain(IntVect(0), IntVect(n_cell-1));
geom.define(domain);

EB2::AMReXSDF sdf(func);

auto gshop = EB2::makeShop(sdf);
EB2::Build(gshop, geom, 0, 0);

// Put some data
MultiFab mf;
{
BoxArray ba(geom.Domain());
ba.maxSize(max_grid_size);
DistributionMapping dm{ba};

std::unique_ptr<EBFArrayBoxFactory> factory
= amrex::makeEBFabFactory(geom, ba, dm, {2,2,2}, EBSupport::full);

mf.define(ba, dm, 1, 0, MFInfo(), *factory);
mf.setVal(1.0);
}

EB_WriteSingleLevelPlotfile("plt", mf, {"rho"}, geom, 0.0, 0);

amrex::Finalize();
}
12 changes: 12 additions & 0 deletions Examples/Chombo3_DCEL/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# Things for the Chombo makefile system.
ebase = main

#CHOMBO_HOME = /home/robertm/Projects/Chombo_3.2/lib

LibNames = EBAMRElliptic EBAMRTools Workshop EBTools AMRElliptic AMRTools BoxTools

base_dir = .
src_dirs = ../../

include $(CHOMBO_HOME)/mk/Make.example
28 changes: 28 additions & 0 deletions Examples/Chombo3_DCEL/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
This example uses the embedded boundary grid generation from Chombo3, and shows how to use DCEL functionality from EBGeometry.
To compile this application, first install Chombo somewhere and point the CHOMBO_HOME environment variable to it.

Compiling
---------

Compile (with your standard Chombo settings) using

make -s -j8 DIM=3 OPT=HIGH main

Running
-------

With MPI:

mpirun -np 8 main3d.<something>.ex examples.inputs

Supported geometries
--------------------
To select different geometries, set which_geom to one of the below.

* `which_geom = 0` Airfoil
* `which_geom = 1` Sphere
* `which_geom = 2` Dodecahedron
* `which_geom = 3` Horse
* `which_geom = 4` Porsche
* `which_geom = 5` Orion capsule
* `which_geom = 6` Armadillo
Empty file.
3 changes: 3 additions & 0 deletions Examples/Chombo3_DCEL/examples.inputs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ncells = 128
grid_size = 16
which_geom = 0
Loading