Skip to content
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

Add dimension and consistency checks for size / corners and num_cells / dx #155

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

streeve
Copy link
Collaborator

@streeve streeve commented Nov 22, 2024

Also adds errors if neither are available

@streeve streeve requested a review from pabloseleson November 22, 2024 23:08
@streeve streeve self-assigned this Nov 22, 2024
src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@streeve streeve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pabloseleson can you test a couple examples to make sure this is working?

src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
src/CabanaPD_Input.hpp Show resolved Hide resolved
src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
src/CabanaPD_Input.hpp Outdated Show resolved Hide resolved
@streeve
Copy link
Collaborator Author

streeve commented Dec 6, 2024

@pabloseleson this now only addresses your requested changes since it was needed in #155

@streeve streeve changed the title Update inputs to allow size or corners and num_cells or dx Add dimension and consistency checks for size / corners and num_cells / dx Dec 6, 2024
@pabloseleson
Copy link
Collaborator

pabloseleson commented Dec 12, 2024

Here are 3 tests with outputs:

Test 1:

Inputs:

"num_cells"              : {"value": [10, 20, 25]},
"system_size"            : {"value": [100.0, 150.0, 300.0], "unit": "m"},

Outputs:

system_size : (100.0 , 150.0 , 300.0) "m"
low_corner : (-50.0 , -75.0 , -150.0) "m"
high_corner : (50.0 , 75.0 , 150.0) "m"
nc : (10 , 20 , 25)
dx : (10.0 , 7.5 , 12.0) "m"

Test 2:

Inputs:

"dx"                     : {"value": [10.0, 7.5, 12.0], "unit": "m"},
"low_corner"             : {"value": [-50.0 , -75.0 , -150.0], "unit": "m"},
"high_corner"            : {"value": [50.0 , 75.0 , 150.0], "unit": "m"},

Outputs:

system_size : (100.0 , 150.0 , 300.0) "m"
low_corner : (-50.0 , -75.0 , -150.0) "m"
high_corner : (50.0 , 75.0 , 150.0) "m"
nc : (10 , 20 , 25)
dx : (10.0 , 7.5 , 12.0) "m"

Test 3:

Inputs:

"dx"                     : {"value": [10.0, 7.5, 12.0], "unit": "m"},
"low_corner"             : {"value": [-25.0 , 0.0 , -75.0], "unit": "m"},
"high_corner"            : {"value": [75.0 , 150.0 , 225.0], "unit": "m"},

Outputs:

system_size : (100.0 , 150.0 , 300.0) "m"
low_corner : (-25.0 , 0.0 , -75.0) "m"
high_corner : (75.0 , 150.0 , 225.0) "m"
nc : (10 , 20 , 25)
dx : (10.0 , 7.5 , 12.0) "m"

Output code (in CabanaPD_Input.hpp at the end of setupSize)

    std::cout << " =========== " << std::endl;
    std::cout << " system_size : " << "(" << inputs["system_size"]["value"][0] << " , " << inputs["system_size"]["value"][1] << " , " << inputs["system_size"]["value"][2] << ") " << inputs["system_size"]["unit"] << std::endl;
    std::cout << " low_corner  : " << "(" << inputs["low_corner"]["value"][0] << " , " << inputs["low_corner"]["value"][1] << " , " << inputs["low_corner"]["value"][2] << ") " << inputs["low_corner"]["unit"] << std::endl;
    std::cout << " high_corner : " << "(" << inputs["high_corner"]["value"][0] << " , " << inputs["high_corner"]["value"][1] << " , " << inputs["high_corner"]["value"][2] << ") " << inputs["high_corner"]["unit"] << std::endl;
    std::cout << " =========== " << std::endl;
    std::cout << " nc          : " << "(" << inputs["num_cells"]["value"][0] << " , " << inputs["num_cells"]["value"][1] << " , " << inputs["num_cells"]["value"][2] << ") " << std::endl;
    std::cout << " dx          : " << "(" << inputs["dx"]["value"][0] << " , " << inputs["dx"]["value"][1] << " , " << inputs["dx"]["value"][2] << ") " << inputs["dx"]["unit"] << std::endl;

@pabloseleson
Copy link
Collaborator

pabloseleson commented Dec 12, 2024

Tests for inconsistencies:

Test i

Inputs:

"dx"                     : {"value": [10.0, 7.5, 12.0], "unit": "cm"},
"low_corner"            : {"value":  [-25.0 , 0.0 , -75.0], "unit": "m"},
"high_corner"            : {"value": [75.0 , 150.0 , 225.0], "unit": "m"},

Output

Units for dx do not match system units.
libc++abi: terminating due to uncaught exception of type std::runtime_error: Aborting after error from input. See error file.
[pscstudio:65566] *** Process received signal ***
[pscstudio:65566] Signal: Abort trap: 6 (6)
[pscstudio:65566] Signal code: (0)
[pscstudio:65566] [ 0] 0 libsystem_platform.dylib 0x0000000193146584 _sigtramp + 56
[pscstudio:65566] [ 1] 0 libsystem_pthread.dylib 0x0000000193115c20 pthread_kill + 288
[pscstudio:65566] [ 2] 0 libsystem_c.dylib 0x0000000193022a30 abort + 180
[pscstudio:65566] [ 3] 0 libc++abi.dylib 0x00000001930ccd08 _ZN10__cxxabiv130__aligned_malloc_with_fallbackEm + 0
[pscstudio:65566] [ 4] 0 libc++abi.dylib 0x00000001930bcfa4 _ZL28demangling_terminate_handlerv + 320
[pscstudio:65566] [ 5] 0 libobjc.A.dylib 0x0000000192d57c00 _ZL15_objc_terminatev + 160
[pscstudio:65566] [ 6] 0 libc++abi.dylib 0x00000001930cc0cc _ZSt11__terminatePFvvE + 16
[pscstudio:65566] [ 7] 0 libc++abi.dylib 0x00000001930cf348 __cxa_get_exception_ptr + 0
[pscstudio:65566] [ 8] 0 libc++abi.dylib 0x00000001930cf28c _ZN10__cxxabiv1L22exception_cleanup_funcE19_Unwind_Reason_CodeP17_Unwind_Exception + 0
[pscstudio:65566] [ 9] 0 ElasticWave 0x000000010290f718 ZN8CabanaPD7log_errINSt3__113basic_ostreamIcNS1_11char_traitsIcEEEERA40_KcEEvRT_OT0 + 140
[pscstudio:65566] [10] 0 ElasticWave 0x00000001029022a0 _ZN8CabanaPD6Inputs9setupSizeEv + 3800
[pscstudio:65566] [11] 0 ElasticWave 0x00000001029007cc _ZN8CabanaPD6InputsC2ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 128
[pscstudio:65566] [12] 0 ElasticWave 0x00000001028fe624 _Z18elasticWaveExampleNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE + 140
[pscstudio:65566] [13] 0 ElasticWave 0x00000001029006f8 main + 184
[pscstudio:65566] [14] 0 dyld 0x0000000192d8b154 start + 2476
[pscstudio:65566] *** End of error message ***
zsh: abort ./ElasticWave

Test ii

Inputs:

"dx"                     : {"value": [10.0, 7.5, 12.0], "unit": "m"},
"low_corner"            : {"value":  [-25.0 , 0.0 , -75.0], "unit": "cm"},
"high_corner"            : {"value": [75.0 , 150.0 , 225.0], "unit": "m"},

Output:

Units for low_corner and high_corner do not match.
...

Test iii

Inputs:

"dx"                     : {"value": [10.0, 7.5, 12.0], "unit": "m"},
"system_size"            : {"value": [100.0, 150.0, 300.0], "unit": "cm"},

Output:

Units for dx do not match system units.
...

@pabloseleson
Copy link
Collaborator

pabloseleson commented Dec 12, 2024

Tests for inconsistent dimensions

Test a

Inputs:

"dx"                     : {"value": [10.0, 7.5], "unit": "m"},
"system_size"            : {"value": [100.0, 150.0, 300.0], "unit": "m"},

Output:

CabanaPD requires 3d (dx).
...

Test b

Inputs:

"dx"                     : {"value": [10.0, 7.5, 12.0], "unit": "m"},
"system_size"            : {"value": [100.0, 150.0], "unit": "m"},

Output:

CabanaPD requires 3d (system_size).
...

Test c

Inputs:

"dx"                     : {"value": [10.0, 7.5, 12.0], "unit": "m"},
"low_corner"            : {"value":  [-25.0 , 0.0 ], "unit": "m"},
"high_corner"            : {"value": [75.0 , 150.0 , 225.0], "unit": "m"},

Output:

CabanaPD requires 3d (low_corner).
...

Test d

Inputs:

"dx"                     : {"value": [10.0, 7.5, 12.0], "unit": "m"},
"low_corner"            : {"value":  [-25.0 , 0.0 , -75.0], "unit": "m"},
"high_corner"            : {"value": [75.0 , 150.0 ], "unit": "m"},

Output:

CabanaPD requires 3d (high_corner).
...

Test e

Inputs:

"num_cells"              : {"value": [10, 20]},
"system_size"            : {"value": [100.0, 150.0, 300.0], "unit": "m"},

Output:

CabanaPD requires 3d (num_cells).
...

Test f

Inputs:

"num_cells"              : {"value": [10, 20, 25]},
"system_size"            : {"value": [100.0, 150.0], "unit": "m"},

Output:

CabanaPD requires 3d (system_size).
...

@streeve streeve enabled auto-merge December 12, 2024 22:32
@streeve streeve merged commit 7f94f25 into ORNL:main Dec 12, 2024
14 checks passed
@streeve streeve deleted the box_inputs branch December 12, 2024 22:48
@streeve streeve mentioned this pull request Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants