-
Notifications
You must be signed in to change notification settings - Fork 201
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
Added check of gridding for RZ spectral solver #1005
Changes from 11 commits
a34f8a9
0433f2c
63a628f
def5990
beb191d
61a8a38
fa2f878
fdcba52
dd7ca92
ef9a4ba
cf778de
8b7b140
b4e003e
eb1fa85
87fc463
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,6 +213,86 @@ WarpXParser makeParser (std::string const& parse_function, std::vector<std::stri | |
return parser; | ||
} | ||
|
||
/** | ||
* \brief Ensures that the blocks are setup correctly for the RZ spectral solver | ||
* When using the RZ spectral solver, the Hankel transform cannot be | ||
* divided among multiple blocks. Each block must extend over the | ||
* entire radial extent. | ||
* The grid can be divided up along z, but the number of blocks | ||
* must be >= the number of processors. | ||
*/ | ||
void CheckGriddingForRZSpectral () | ||
{ | ||
#if (defined WARPX_DIM_RZ) && (defined WARPX_USE_PSATD) | ||
|
||
int max_level; | ||
Vector<int> n_cell(AMREX_SPACEDIM, -1); | ||
|
||
ParmParse pp_amr("amr"); | ||
|
||
pp_amr.get("max_level",max_level); | ||
pp_amr.getarr("n_cell",n_cell,0,AMREX_SPACEDIM); | ||
|
||
Vector<int> blocking_factor_x(max_level+1); | ||
Vector<int> max_grid_size_x(max_level+1); | ||
|
||
// Set the radial block size to be equal to the radial grid size. | ||
blocking_factor_x[0] = n_cell[0]; | ||
max_grid_size_x[0] = n_cell[0]; | ||
|
||
for (int lev=1 ; lev <= max_level ; lev++) { | ||
// For this to be correct, this needs to read in any user specified refinement ratios. | ||
// But since that is messy and unlikely to be needed anytime soon, the ratio is | ||
// fixed to 2 which will be the most likely value. | ||
blocking_factor_x[lev] = blocking_factor_x[lev-1]*2; // refRatio(lev-1); | ||
max_grid_size_x[lev] = max_grid_size_x[lev-1]*2; // refRatio(lev-1); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that, if the user already entered There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is correct, the user's value would be overwritten. The only acceptable value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, adding comment at line 251 |
||
pp_amr.addarr("blocking_factor_x", blocking_factor_x); | ||
pp_amr.addarr("max_grid_size_x", max_grid_size_x); | ||
|
||
// Adjust the longitudinal block sizes, making sure that there are | ||
// more blocks than processors. | ||
// The factor of 8 is there to make some room for higher order | ||
// shape factors and filtering. | ||
int nprocs = ParallelDescriptor::NProcs(); | ||
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(n_cell[1] >= 8*nprocs, | ||
"With RZ spectral, there must be at least two z-cells per processor so that there can be at least one block per processor."); | ||
|
||
// Get the longitudinal blocking factor in case it was set by the user. | ||
// If not set, use the default value of 8. | ||
Vector<int> bf; | ||
pp_amr.queryarr("blocking_factor",bf); | ||
pp_amr.queryarr("blocking_factor_y",bf); | ||
bf.resize(std::max(static_cast<int>(bf.size()),1),8); | ||
|
||
// Make sure that the blocking factor is small enough so | ||
// that there will be at least as many blocks as there | ||
// are processors. Because of the ASSERT above, bf will | ||
// never be less than 8. | ||
while (n_cell[1] < nprocs*bf[0]) { | ||
bf[0] /= 2; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, here, could you add a comment that says that this overwrites any previous value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I can add the comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
pp_amr.addarr("blocking_factor_y", bf); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that this function will add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is essentially correct. |
||
|
||
// Get the longitudinal max grid size in case it was set by the user. | ||
// If not set, use the default value of 128. | ||
Vector<int> mg; | ||
pp_amr.queryarr("max_grid_size",mg); | ||
pp_amr.queryarr("max_grid_size_y",mg); | ||
mg.resize(std::max(static_cast<int>(mg.size()),1),128); | ||
|
||
// Make sure that the max grid size (of the finest level) is small | ||
// enough so that there will be at least as many blocks as there | ||
// are processors. | ||
while (n_cell[1] < nprocs*mg[0]) { | ||
mg[0] /= 2; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, here, could you add a comment that says that this overwrites any previous value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
pp_amr.addarr("max_grid_size_y", mg); | ||
|
||
#endif | ||
} | ||
|
||
namespace WarpXUtilMsg{ | ||
|
||
void AlwaysAssert(bool is_expression_true, const std::string& msg = "ERROR!") | ||
|
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.
In the Sphinx documentation for the parameters
max_grid_size
andblocking_factor
, could you mention the constraints for RZ spectral, and mention that WarpX will automatically modify the input values so as to satisfy them?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.
Yes, I can add the documentation.
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.
Done