diff --git a/src/mesh/StencilBuilder.cpp b/src/mesh/StencilBuilder.cpp index 350492419db550e28293eeb913f7818777ddf210..d20ebbb5a299aec8f930140fa86fc78052c087f3 100644 --- a/src/mesh/StencilBuilder.cpp +++ b/src/mesh/StencilBuilder.cpp @@ -2,6 +2,7 @@ #include <mesh/Connectivity.hpp> #include <mesh/ItemArray.hpp> +#include <utils/GlobalVariableManager.hpp> #include <utils/Messenger.hpp> #include <set> @@ -113,6 +114,18 @@ StencilBuilder::_build(const ConnectivityType& connectivity, size_t number_of_layers, const BoundaryDescriptorList& symmetry_boundary_descriptor_list) const { + if ((parallel::size() > 1) and (number_of_layers > GlobalVariableManager::instance().getNumberOfGhostLayers())) { + std::ostringstream error_msg; + error_msg << "Stencil builder requires" << rang::fgB::yellow << number_of_layers << rang::fg::reset + << " layers while parallel number of ghost layer is " + << GlobalVariableManager::instance().getNumberOfGhostLayers() << ".\n"; + error_msg << "Increase the number of ghost layers (using '--number-of-ghost-layers' option)."; + throw NormalError(error_msg.str()); + } + if (number_of_layers > 2) { + throw NotImplementedError("number of layers too large"); + } + if (symmetry_boundary_descriptor_list.size() == 0) { if (number_of_layers == 1) { Array<const uint32_t> row_map = this->_getRowMap(connectivity); @@ -120,13 +133,6 @@ StencilBuilder::_build(const ConnectivityType& connectivity, return {ConnectivityMatrix{row_map, column_indices}, {}}; } else { - if (number_of_layers > 2) { - throw NotImplementedError("number of layers too large"); - } - if (parallel::size() > 1) { - throw NotImplementedError("stencils with more than 1 layers are not defined in parallel"); - } - auto cell_to_node_matrix = connectivity.cellToNodeMatrix(); auto node_to_cell_matrix = connectivity.nodeToCellMatrix();