Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/mesh/impls/bout/boutmesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ void BoutMesh::chooseProcessorSplit(Options& options) {
_("Number of processors ({:d}) not divisible by NPs in x direction ({:d})\n"),
NPES, NXPE);
}

if (nx % NXPE != 0) {
throw BoutException(
_("Number of x points ({:d}) not divisible by NPs in x direction ({:d})\n"), nx,
NXPE);
}
NYPE = NPES / NXPE;
} else {
// NXPE not set, but NYPE is
Expand All @@ -258,7 +262,11 @@ void BoutMesh::chooseProcessorSplit(Options& options) {
_("Number of processors ({:d}) not divisible by NPs in y direction ({:d})\n"),
NPES, NYPE);
}

if (ny % NYPE != 0) {
throw BoutException(
_("Number of y points ({:d}) not divisible by NPs in y direction ({:d})\n"), nx,
NXPE);
}
NXPE = NPES / NYPE;
}

Expand Down
42 changes: 39 additions & 3 deletions tests/unit/mesh/test_boutmesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -464,26 +464,62 @@ TEST_P(BadBoutMeshDecompositionTest, BadSingleCoreYDecomposition) {
EXPECT_THAT(result.reason, HasSubstr(params.expected_message));
}

TEST_F(BoutMeshTest, ChooseProcessorSplitBadNXPE) {
TEST_F(BoutMeshTest, ChooseProcessorSplitBadNXPETooManyXProcs) {
Options options{{"NXPE", 3}};

BoutMeshExposer mesh(1, 24, 1, 1, 1, 8);

EXPECT_THROW(mesh.chooseProcessorSplit(options), BoutException);
}

TEST_F(BoutMeshTest, ChooseProcessorSplitBadNYPE) {
TEST_F(BoutMeshTest, ChooseProcessorSplitBadNYPETooManyYProcs) {
Options options{{"NYPE", 7}};

BoutMeshExposer mesh(1, 24, 1, 1, 1, 8);

EXPECT_THROW(mesh.chooseProcessorSplit(options), BoutException);
}

TEST_F(BoutMeshTest, ChooseProcessorSplitBadNXPENotDivisibleByNYPE) {
WithQuietOutput info{output_info};
Options options{{"NXPE", 5}};

BoutMeshExposer mesh(5, 24, 1, 1, 1, 8);

EXPECT_THROW(mesh.chooseProcessorSplit(options), BoutException);
}

TEST_F(BoutMeshTest, ChooseProcessorSplitBadNYPENotDivisibleByNYPE) {
WithQuietOutput info{output_info};
Options options{{"NYPE", 5}};

BoutMeshExposer mesh(5, 5, 1, 1, 1, 8);

EXPECT_THROW(mesh.chooseProcessorSplit(options), BoutException);
}

TEST_F(BoutMeshTest, ChooseProcessorSplitBadNXPENotDivisibleByNYPE) {
WithQuietOutput info{output_info};
Options options{{"NXPE", 5}};

BoutMeshExposer mesh(5, 24, 1, 1, 1, 8);

EXPECT_THROW(mesh.chooseProcessorSplit(options), BoutException);
}

TEST_F(BoutMeshTest, ChooseProcessorSplitBadNYPENotDivisibleByNYPE) {
WithQuietOutput info{output_info};
Options options{{"NYPE", 5}};

BoutMeshExposer mesh(5, 5, 1, 1, 1, 8);

EXPECT_THROW(mesh.chooseProcessorSplit(options), BoutException);
}

TEST_F(BoutMeshTest, ChooseProcessorSplitNXPE) {
Options options{{"NXPE", 4}};

BoutMeshExposer mesh(1, 24, 1, 1, 1, 8);
BoutMeshExposer mesh(4, 24, 1, 1, 1, 8);

EXPECT_NO_THROW(mesh.chooseProcessorSplit(options));

Expand Down