-
Notifications
You must be signed in to change notification settings - Fork 61
Utilities: Locate and square/circle intersection area #594
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
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e18ae48
add some useful utilities for Prob files
baperry2 51d75ac
for square/circle intersection, ignore when square is far away
baperry2 3d52ef8
revert change to locate function, keep classic behavior
baperry2 52664e9
make locate host_device instead of just device
baperry2 dd01919
add utility unit tests to CI
baperry2 ec418f6
add minimal documentation on new utilities
baperry2 baf9825
Merge branch 'development' into utilities
baperry2 567d020
use standard build system for utility unit tests due to CUDA issue
baperry2 e0ead66
move namespace aliases outside of main function
baperry2 80dd8df
put some stuff back into GNUMakefile
baperry2 5c8d187
add nprocs arg to utilities build in ci
baperry2 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,29 @@ | ||
| # AMReX | ||
| DIM = 2 | ||
| PRECISION = DOUBLE | ||
| PROFILE = FALSE | ||
| VERBOSE = FALSE | ||
| DEBUG = FALSE | ||
|
|
||
| # Compiler | ||
| COMP = gnu | ||
| USE_MPI = FALSE | ||
| USE_OMP = FALSE | ||
| USE_CUDA = FALSE | ||
| USE_HIP = FALSE | ||
|
|
||
| # PelePhysics | ||
| FUEGO_GAS = TRUE | ||
| TINY_PROFILE = FALSE | ||
|
|
||
| # define the location of the PELE_PHYSICS top directory | ||
| PELE_PHYSICS_HOME ?= ../../.. | ||
|
|
||
| Eos_Model = GammaLaw | ||
| Chemistry_Model = Null | ||
| Transport_Model = Constant | ||
|
|
||
| Bpack := ./Make.package | ||
| Blocs := . | ||
|
|
||
| include $(PELE_PHYSICS_HOME)/Testing/Exec/Make.PelePhysics |
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 @@ | ||
| CEXE_sources += main.cpp |
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,61 @@ | ||
| #include <AMReX.H> | ||
| #include <AMReX_Print.H> | ||
| #include "Utilities.H" | ||
|
|
||
| int | ||
| main(int argc, char* argv[]) | ||
| { | ||
| amrex::Initialize(argc, argv); | ||
|
|
||
| // Test Unit Conversions | ||
| namespace m2c = pele::physics::utilities::mks2cgs; | ||
| namespace c2m = pele::physics::utilities::cgs2mks; | ||
| AMREX_ALWAYS_ASSERT(m2c::Length(1.0) == 100.0); | ||
| AMREX_ALWAYS_ASSERT(c2m::Length(1.0, 2) == 1.0e-4); | ||
| AMREX_ALWAYS_ASSERT(m2c::Mass(c2m::Mass(1.0)) == 1.0); | ||
| AMREX_ALWAYS_ASSERT(m2c::Mu(1.0) == m2c::Mass(1.0) / m2c::Length(1.0)); | ||
| amrex::Print() << "Unit Conversion Tests Passed" << std::endl; | ||
|
|
||
| // Test locate function | ||
| amrex::Array<amrex::Real, 5> sorted_data{0.0, 0.2, 0.5, 0.9, 1.0}; | ||
| int length = sorted_data.size(); | ||
| int idxlo = -1; | ||
| amrex::Real x = -50.0; | ||
| pele::physics::utilities::locate(sorted_data.data(), length, x, idxlo); | ||
| AMREX_ALWAYS_ASSERT(idxlo == 0); | ||
| x = 1.0; | ||
| pele::physics::utilities::locate(sorted_data.data(), length, x, idxlo); | ||
| AMREX_ALWAYS_ASSERT(idxlo == length - 1); | ||
| x = 0.25; | ||
| pele::physics::utilities::locate(sorted_data.data(), length, x, idxlo); | ||
| AMREX_ALWAYS_ASSERT(idxlo == 1); | ||
| amrex::Print() << "Locate Tests Passed" << std::endl; | ||
|
|
||
| // Test rectangle circle intersection area | ||
| // Quarter circle intersection | ||
| amrex::Real x0 = 0.0; | ||
| amrex::Real x1 = 1.0; | ||
| amrex::Real y0 = 0.0; | ||
| amrex::Real y1 = 1.0; | ||
| amrex::Real cx = 1.0; | ||
| amrex::Real cy = 1.0; | ||
| amrex::Real r = 1.0; | ||
| amrex::Real A1 = pele::physics::utilities::rectangle_circle_intersection_area( | ||
| x0, x1, y0, y1, cx, cy, r); | ||
| AMREX_ALWAYS_ASSERT(std::abs(A1 - 0.25 * M_PI) < 1e-14); | ||
| // No intersection | ||
| cx = 3.0; | ||
| cy = 3.0; | ||
| amrex::Real A2 = pele::physics::utilities::rectangle_circle_intersection_area( | ||
| x0, x1, y0, y1, cx, cy, r); | ||
| AMREX_ALWAYS_ASSERT(std::abs(A2) < 1e-14); | ||
| // Square covered by circle | ||
| r = 20.0; | ||
| amrex::Real A3 = pele::physics::utilities::rectangle_circle_intersection_area( | ||
| x0, x1, y0, y1, cx, cy, r); | ||
| AMREX_ALWAYS_ASSERT(std::abs(A3 - 1.0) < 1e-14); | ||
| amrex::Print() << "Intersection Area Tests Passed" << std::endl; | ||
|
|
||
| amrex::Finalize(); | ||
| return 0; | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.