-
Notifications
You must be signed in to change notification settings - Fork 19
handle CGDims properly in serial and MPI #969
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
| */ | ||
|
|
||
| #include "include/MEVPDynamics.hpp" | ||
| #include "include/ModelArray.hpp" | ||
| #include "include/ModelMetadata.hpp" | ||
| #include "include/constants.hpp" | ||
| #include "include/gridNames.hpp" | ||
|
|
||
|
|
@@ -98,17 +100,27 @@ void MEVPDynamics::setData(const ModelState::DataMap& ms) | |
| if (uice.getType() == ModelArray::Type::CG && uice.dimensions()[0] != cgDims[0]) { | ||
| // CG degree of the read data | ||
| const unsigned int fileCGdegree = (ModelArray::dimensions(ModelArray::Type::CG)[0] - 1) | ||
| / ModelArray::dimensions(ModelArray::Type::H)[0]; | ||
| const unsigned int modelCGdegree = (cgDims[0] - 1) | ||
| / ModelArray::dimensions(ModelArray::Type::H)[0]; | ||
| / ModelArray::dimensions(ModelArray::Type::H)[0]; | ||
| const unsigned int modelCGdegree | ||
| = (cgDims[0] - 1) / ModelArray::dimensions(ModelArray::Type::H)[0]; | ||
|
|
||
| throw std::runtime_error( | ||
| "Differing CG degrees between input data and model are not supported. File CG degree = " | ||
| + std::to_string(fileCGdegree) + ", model CG degree = " | ||
| + std::to_string(modelCGdegree) + "."); | ||
| "Differing CG degrees between input data and model are not supported. File CG degree = " | ||
| + std::to_string(fileCGdegree) + ", model CG degree = " + std::to_string(modelCGdegree) | ||
| + "."); | ||
| } | ||
| // Set the dimensions of CG arrays | ||
| #ifdef USE_MPI | ||
| auto& metadata = ModelMetadata::getInstance(); | ||
| ModelArray::MultiDim globalDims, localDims; | ||
| globalDims[0] = metadata.getGlobalExtentX(); | ||
| globalDims[1] = metadata.getGlobalExtentY(); | ||
| localDims[0] = metadata.getLocalExtentX(); | ||
| localDims[1] = metadata.getLocalExtentY(); | ||
| ModelArray::setDimensions(ModelArray::Type::CG, globalDims, localDims); | ||
|
Comment on lines
+116
to
+120
Collaborator
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. Also, the metadata class could have a function to generate the correct form of the combined local/global dims. |
||
| #else | ||
| ModelArray::setDimensions(ModelArray::Type::CG, cgDims); | ||
| #endif | ||
|
|
||
| // Set the data in the kernel arrays. | ||
| for (const auto& fieldName : namedFields) { | ||
|
|
@@ -155,9 +167,10 @@ void MEVPDynamics::advectField( | |
| ModelState MEVPDynamics::getStatePrognostic() const | ||
| { | ||
| return { { | ||
| { uName, kernel.getCGData(uName) }, | ||
| { vName, kernel.getCGData(vName) }, | ||
| }, { getConfiguration() } }; | ||
| { uName, kernel.getCGData(uName) }, | ||
| { vName, kernel.getCGData(vName) }, | ||
| }, | ||
| { getConfiguration() } }; | ||
| } | ||
|
|
||
| MEVPDynamics::HelpMap& MEVPDynamics::getHelpText(HelpMap& map, bool getAll) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,7 +146,11 @@ TEST_CASE("Write and read a ModelState-based RectGrid restart file") | |
|
|
||
| // Reset dimensions so it is possible to check if they | ||
| // are read correctly from refeence file | ||
| #ifdef USE_MPI | ||
| ModelArray::setDimensions(ModelArray::Type::H, { 1, 1 }, { 1, 1 }); | ||
|
Collaborator
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. This would become ``` |
||
| #else | ||
| ModelArray::setDimensions(ModelArray::Type::H, { 1, 1 }); | ||
| #endif | ||
| REQUIRE(ModelArray::dimensions(ModelArray::Type::H)[0] == 1); | ||
| RectangularGrid gridIn; | ||
| size_t targetX = 1; | ||
|
|
||
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 must admit that I don't like the idea of having a different function signature serial and MPI versions of the code. I wonder if a better solution might be changing the result of
ModelArray::dimensionsfrom a plainMultiDimto a vector of not scalars but local-global pairs in the MPI case.