Commit 855cc3e7 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1529 Coords: add in debug mode a function which checks their consistency...

#1529 Coords: add in debug mode a function which checks their consistency (i.e. the total number of existing Coords objects is the sum of the Coords of all the meshes).
parent 81368def
......@@ -24,12 +24,13 @@
#include "Geometry/Coords/Coords.hpp"
#include "Geometry/Coords/Exceptions/Coords.hpp"
#include "Geometry/Domain/Domain.hpp"
#include "Geometry/Mesh/Internal/MeshManager.hpp"
namespace MoReFEM
{
Coords::~Coords()
{
#ifndef NDEBUG
......@@ -166,6 +167,40 @@ namespace MoReFEM
point.Print(stream);
return stream;
}
# ifndef NDEBUG
void AssertNCoordsConsistency(const Wrappers::Mpi& mpi)
{
decltype(auto) mesh_manager = Internal::MeshNS::MeshManager::GetInstance(__FILE__, __LINE__);
decltype(auto) mesh_storage = mesh_manager.GetStorage();
auto Ncoords_in_meshes = 0u;
for (const auto& [mesh_id, mesh_ptr] : mesh_storage)
{
static_cast<void>(mesh_id);
assert(!(!mesh_ptr));
const auto& mesh = *mesh_ptr;
Ncoords_in_meshes += mesh.NprocessorWiseCoord();
Ncoords_in_meshes += mesh.NghostCoord();
}
if (Ncoords_in_meshes != Coords::Nobjects())
{
std::ostringstream oconv;
oconv << "Inconsistent number of Coords on processor " << mpi.GetRank<int>() << ": both meshes "
"encompasses " << Ncoords_in_meshes << " whereas there are " << Coords::Nobjects() << " Coords "
"object currently alive on the processor.";
throw Exception(oconv.str(), __FILE__, __LINE__);
}
}
# endif // NDEBUG
} // namespace MoReFEM
......
......@@ -493,11 +493,21 @@ namespace MoReFEM
void WriteVTK_PolygonalDataFormat(const Coords& point, std::ostream& stream);
//! \copydoc doxygen_hide_std_stream_out_overload
std::ostream& operator<<(std::ostream& stream, const Coords& rhs);
# ifndef NDEBUG
/*!
* \brief Check whether all \a Coords on the current processor are properly accounted for in the \a Mesh objects.
*
* \copydetails doxygen_hide_mpi_param
*
* If not, an exception is thrown (so that the actual numbers are displayed - something a mere assert can't handle.
*/
void AssertNCoordsConsistency(const Wrappers::Mpi& mpi);
# endif // NDEBUG
} // namespace MoReFEM
......
......@@ -274,6 +274,12 @@ namespace MoReFEM
DoConsiderProcessorWiseLocal2GlobalT,
std::move(mesh_directory_storage));
# ifndef NDEBUG
{
AssertNCoordsConsistency(mpi);
}
# endif // NDEBUG
Internal::MeshNS::WriteInterfaceListForEachMesh(mesh_directory_storage);
// As FiberListManager gets a constructor with arguments, call it explicitly there.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment