Skip to content

Commit

Permalink
two separate fixes -- particle_compare and ref_ratio=1 (AMReX-Codes#3655
Browse files Browse the repository at this point in the history
)

## Summary

## Additional background

## Checklist

The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [X] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
asalmgren authored Dec 3, 2023
1 parent 2f1b1d1 commit efd77ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Src/AmrCore/AMReX_AmrMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ AmrMesh::checkInput ()
for (int i = 0; i < max_level; i++)
{
if (MaxRefRatio(i) < 2) {
amrex::Error("Amr::checkInput: bad ref_ratios");
amrex::Warning("Amr::checkInput: ref_ratios all equal to one!");
}
}

Expand Down
19 changes: 16 additions & 3 deletions Tools/Postprocessing/C_Src/particle_compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,15 @@ int main_main()
std::string fn2;
std::string pt;
Real rtol = 0.0;
Real atol = 0.0;

int farg=1;
while (farg <= narg) {
const std::string fname = amrex::get_command_argument(farg);
if (fname == "-r" || fname == "--rel_tol") {
rtol = std::stod(amrex::get_command_argument(++farg));
} else if (fname == "--abs_tol") {
atol = std::stod(amrex::get_command_argument(++farg));
} else {
break;
}
Expand Down Expand Up @@ -472,6 +475,7 @@ int main_main()
<< "\n"
<< " optional arguments:\n"
<< " -r|--rel_tol rtol : relative tolerance (default is 0)\n"
<< " --abs_tol atol : absolute tolerance (default is 0)\n"
<< std::endl;
return EXIT_SUCCESS;
}
Expand Down Expand Up @@ -555,16 +559,25 @@ int main_main()

int exit_code = 0;
for (int i = 0; i < header1.num_comp; ++i) {
if (global_norms[i+header1.num_comp] > rtol) exit_code = 1;
if (global_norms[i ] > atol &&
global_norms[i+header1.num_comp] > rtol) exit_code = 1;
}

if (exit_code == 0)
{
amrex::Print() << " PARTICLES AGREE to relative tolerance " << rtol << "\n";
if (atol > 0.) {
amrex::Print() << " PARTICLES AGREE to relative tolerance " << rtol << " and/or absolute tolerance " << atol << "\n";
} else {
amrex::Print() << " PARTICLES AGREE to relative tolerance " << rtol << "\n";
}
}
else
{
amrex::Print() << " PARTICLES DISAGREE to relative tolerance " << rtol << "\n";
if (atol > 0.) {
amrex::Print() << " PARTICLES DISAGREE to relative tolerance " << rtol << " and/or absolute tolerance " << atol << "\n";
} else {
amrex::Print() << " PARTICLES DISAGREE to relative tolerance " << rtol << "\n";
}
}

return exit_code;
Expand Down

0 comments on commit efd77ff

Please sign in to comment.