-
Notifications
You must be signed in to change notification settings - Fork 24
Start EB #504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Start EB #504
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
996d1de
Start EB
WeiqunZhang 51fc0ad
Fix
ax3l b3fb822
CMake: Move EB Control in
ax3l 2a8ff88
Docs Update
ax3l 7856ff8
Copyright File Headers
ax3l 8c8a6b7
Modern Enum
ax3l c4c8879
Start EB Test Template
ax3l 20c53ef
add ifdef AMREX_UEE_EB
WeiqunZhang 2245540
Add test
WeiqunZhang b4f7d0d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 076bee7
add cmake build option to setup.py
WeiqunZhang aa385c2
Fix: CMake Logic
ax3l 724b5b8
Simplify
ax3l File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| if (NOT AMReX_EB) | ||
| return() | ||
| endif() | ||
|
|
||
| foreach(D IN LISTS AMReX_SPACEDIM) | ||
| if (D GREATER 1) | ||
| target_sources(pyAMReX_${D}d | ||
| PRIVATE | ||
| EB.cpp | ||
| EBFabFactory.cpp | ||
| ) | ||
| endif() | ||
| endforeach() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* Copyright 2022 The AMReX Community | ||
| * | ||
| * Authors: Weiqun Zhang, Axel Huebl | ||
| * License: BSD-3-Clause-LBNL | ||
| */ | ||
| #include "pyAMReX.H" | ||
|
|
||
| #include <AMReX_EB2.H> | ||
|
|
||
|
|
||
| void init_EBFabFactory (py::module& m); | ||
|
|
||
| void init_EB (py::module& m) | ||
| { | ||
| using namespace amrex; | ||
|
|
||
| m.def( | ||
| "EB2_Build", | ||
| [] (Geometry const& geom, int required_coarsening_level, int max_coarsening_level, | ||
| int ngrow, bool build_coarse_level_by_coarsening, bool extend_domain_face, | ||
| int num_coarsen_opt) | ||
| { | ||
| EB2::Build(geom, required_coarsening_level, max_coarsening_level, ngrow, | ||
| build_coarse_level_by_coarsening, extend_domain_face, num_coarsen_opt); | ||
| }, | ||
| py::arg("geom"), py::arg("required_coarsening_level"), py::arg("max_coarsening_level"), | ||
| py::arg("ngrow") = 4, py::arg("build_coarse_level_by_coarsening") = true, | ||
| py::arg("extend_domain_face") = EB2::ExtendDomainFace(), | ||
| py::arg("num_coarsen_opt") = EB2::NumCoarsenOpt(), | ||
| "EB generation" | ||
| ); | ||
|
|
||
| init_EBFabFactory(m); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* Copyright 2022 The AMReX Community | ||
| * | ||
| * Authors: Weiqun Zhang, Axel Huebl | ||
| * License: BSD-3-Clause-LBNL | ||
| */ | ||
| #include "pyAMReX.H" | ||
|
|
||
| #include <AMReX_EBFabFactory.H> | ||
| #include <AMReX_MultiFab.H> | ||
|
|
||
|
|
||
| void init_EBFabFactory (py::module& m) | ||
| { | ||
| using namespace amrex; | ||
|
|
||
| py::class_<EBFArrayBoxFactory, FabFactory<FArrayBox>>(m, "EBFArrayBoxFactory") | ||
| .def("getVolFrac", &EBFArrayBoxFactory::getVolFrac, | ||
| py::return_value_policy::reference_internal, | ||
| "Return volume faction MultiFab"); | ||
|
|
||
| py::native_enum<EBSupport>(m, "EBSupport", "enum.Enum") | ||
| .value("basic", EBSupport::basic) | ||
| .value("volume", EBSupport::volume) | ||
| .value("full", EBSupport::full) | ||
| .export_values() | ||
| .finalize() | ||
| ; | ||
|
|
||
| m.def( | ||
| "makeEBFabFactory", | ||
| [] (Geometry const& geom, BoxArray const& ba, DistributionMapping const& dm, | ||
| Vector<int> const& ngrow, EBSupport support) | ||
| { | ||
| return makeEBFabFactory(geom, ba, dm, ngrow, support); | ||
| }, | ||
| py::arg("geom"), py::arg("ba"), py::arg("dm"), py::arg("ngrow"), | ||
| py::arg("support"), | ||
| "Make EBFArrayBoxFactory for given Geometry, BoxArray and DistributionMapping" | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| import numpy | ||
| import pytest | ||
|
|
||
| import amrex.space3d as amr | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not amr.Config.have_eb, reason="Requires -DAMReX_EB=ON") | ||
| def test_makeEBFabFactory(): | ||
| n_cell = 64 | ||
| max_grid_size = 16 | ||
|
|
||
| # Build Geometry | ||
| domain = amr.Box( | ||
| amr.IntVect(0, 0, 0), amr.IntVect(n_cell - 1, n_cell - 1, n_cell - 1) | ||
| ) | ||
| real_box = amr.RealBox([0.0, 0.0, 0.0], [1.0, 1.0, 1.0]) | ||
| coord = 0 # Cartesian | ||
| is_per = [1, 1, 1] # is periodic? | ||
| geom = amr.Geometry(domain, real_box, coord, is_per) | ||
|
|
||
| # EB parameters | ||
| pp = amr.ParmParse("eb2") | ||
| pp.add("geom_type", "sphere") | ||
| pp.addarr("sphere_center", [0.5, 0.5, 0.5]) | ||
| rsphere = 0.25 | ||
| pp.add("sphere_radius", rsphere) | ||
| pp.add("sphere_has_fluid_inside", 1) | ||
|
|
||
| # EB generation | ||
| eb_requried_level = 0 | ||
| eb_max_level = 2 | ||
| amr.EB2_Build(geom, eb_requried_level, eb_max_level) | ||
|
|
||
| # Build BoxArray | ||
| ba = amr.BoxArray(domain) | ||
| ba.max_size(max_grid_size) | ||
|
|
||
| # Build DistributionMapping | ||
| dm = amr.DistributionMapping(ba) | ||
|
|
||
| # Make EB Factory | ||
| ng = amr.Vector_int([1, 1, 1]) | ||
| factory = amr.makeEBFabFactory(geom, ba, dm, ng, amr.EBSupport.full) | ||
|
|
||
| # Get EB data | ||
| vfrac = factory.getVolFrac() | ||
|
|
||
| dx = geom.data().CellSize() | ||
| total_vol = vfrac.sum() * dx[0] * dx[1] * dx[2] | ||
| sphere_vol = 4.0 / 3.0 * numpy.pi * rsphere**3 | ||
| assert abs(sphere_vol - total_vol) / sphere_vol < 2.0e-3 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, gotta build locally but something broke the autodocs for all types
https://pyamrex.readthedocs.io/en/latest/usage/api.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I built locally and the issue is sizmailov/pybind11-stubgen#275
EBFArrayBoxFactorydepends onFabFactory_FArrayBoxbut pybind11-stubgen does falsly an alphabetical sorting. Hoping this PR gets accepted and unbreaks it, otherwise we need to fork pybind11-stubgen.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#509