diff --git a/Sources/Geometry/Coords/Coords.hpp b/Sources/Geometry/Coords/Coords.hpp index 274006ac5394d501050885167c2d0a369844dcaa..939b86bee2573b2df131bd65149a6740ceebfd5e 100644 --- a/Sources/Geometry/Coords/Coords.hpp +++ b/Sources/Geometry/Coords/Coords.hpp @@ -234,7 +234,7 @@ namespace MoReFEM * This index: * - Stems directly from the input mesh. For instance, Medit ones begins at 1 and are then incremented. * - Is defined at the program-wise level. - * - Provides no guarantee about contigousness. + * - Provides no guarantee about contiguousness. * * It is fine to identify a \a Coords uniquely but should not be used for direct access to a \a Coords * in a \a Coords list. diff --git a/Sources/Geometry/GeometricElt/Advanced/TGeometricElt.hxx b/Sources/Geometry/GeometricElt/Advanced/TGeometricElt.hxx index a533a8a339c5d99c6cb0e742293c3ee647bdfcc1..3d67e9866558cf4e832df73d0f6e3a105f51b60f 100644 --- a/Sources/Geometry/GeometricElt/Advanced/TGeometricElt.hxx +++ b/Sources/Geometry/GeometricElt/Advanced/TGeometricElt.hxx @@ -236,6 +236,21 @@ PRAGMA_DIAGNOSTIC(ignored "-Wmissing-noreturn") assert(!(!coord_ptr)); auto it = processor_wise_reindexing.find(coord_ptr->GetIndex()); + if (it == processor_wise_reindexing.cend()) + { + std::vector<unsigned int> list; + list.reserve(processor_wise_reindexing.size()); + + for (const auto& item : processor_wise_reindexing) + list.push_back(item.first); + + Utilities::EliminateDuplicate(list); + + Utilities::PrintContainer(list, std::cout); + + std::cout << "INDEX = " << coord_ptr->GetIndex() << std::endl; + } + assert(it != processor_wise_reindexing.cend() && "Otherwise processor_wise_reindexing is poorly built."); diff --git a/Sources/Geometry/Mesh/Internal/Format/Medit.cpp b/Sources/Geometry/Mesh/Internal/Format/Medit.cpp index 51ecbcab53fc7a2121e671e8c17d0aacade535d4..a1c646cf69def10bda6ade2b0ea9d04f8c53cb51 100644 --- a/Sources/Geometry/Mesh/Internal/Format/Medit.cpp +++ b/Sources/Geometry/Mesh/Internal/Format/Medit.cpp @@ -245,7 +245,8 @@ namespace MoReFEM explicit MeditWrite(const std::string& medit_filename, int version, int dimension, - const Coords::vector_unique_ptr& coords_list, + const Coords::vector_unique_ptr& processor_wise_coords_list, + const Coords::vector_unique_ptr& ghosted_coords_list, const GeometricElt::vector_shared_ptr& geometric_elt_list); //@! Destructor @@ -294,6 +295,7 @@ namespace MoReFEM version, static_cast<int>(mesh.GetDimension()), mesh.GetProcessorWiseCoordsList(), + mesh.GetGhostedCoordsList(), geometric_elt_list_sort); } @@ -605,7 +607,8 @@ namespace MoReFEM MeditWrite::MeditWrite(const std::string& medit_filename, int version, int dimension, - const Coords::vector_unique_ptr& coords_list, + const Coords::vector_unique_ptr& processor_wise_coords_list, + const Coords::vector_unique_ptr& ghosted_coords_list, const GeometricElt::vector_shared_ptr& geometric_elt_list) : Medit(version) { @@ -632,7 +635,8 @@ namespace MoReFEM throw MeditExceptionNS::UnableToOpen(medit_filename, version_, "write", __FILE__, __LINE__); } - auto Ncoord = coords_list.size(); + auto Nprocessor_wise_coord = processor_wise_coords_list.size(); + auto Nghosted_coord = ghosted_coords_list.size(); { // ==================== @@ -640,17 +644,32 @@ namespace MoReFEM // ==================== - GmfSetKwd(mesh_index_, GmfVertices, static_cast<libmeshb_int>(Ncoord)); + GmfSetKwd(mesh_index_, GmfVertices, + static_cast<libmeshb_int>(Nprocessor_wise_coord + Nghosted_coord)); if (version == 1) { - for (const auto& coord_ptr : coords_list) - WriteMeditFormat<float>(static_cast<unsigned int>(dimension), *coord_ptr, mesh_index_); + for (const auto& coord_ptr : processor_wise_coords_list) + WriteMeditFormat<float>(static_cast<unsigned int>(dimension), + *coord_ptr, + mesh_index_); + + for (const auto& coord_ptr : ghosted_coords_list) + WriteMeditFormat<float>(static_cast<unsigned int>(dimension), + *coord_ptr, + mesh_index_); } else if (version == 2 || version == 3) { - for (const auto& coord_ptr : coords_list) - WriteMeditFormat<double>(static_cast<unsigned int>(dimension), *coord_ptr, mesh_index_); + for (const auto& coord_ptr : processor_wise_coords_list) + WriteMeditFormat<double>(static_cast<unsigned int>(dimension), + *coord_ptr, + mesh_index_); + + for (const auto& coord_ptr : ghosted_coords_list) + WriteMeditFormat<double>(static_cast<unsigned int>(dimension), + *coord_ptr, + mesh_index_); } else assert("Libmesh file version should be 1, 2 or 3" && false); @@ -679,15 +698,21 @@ namespace MoReFEM // of Coords written just above. // In sequential it should be completely harmless; check it with an assert. - std::unordered_map<unsigned int, int> processor_wise_reindexing; + std::unordered_map<unsigned int, int> reindexing; { - processor_wise_reindexing.max_load_factor(Utilities::DefaultMaxLoadFactor()); - processor_wise_reindexing.reserve(Ncoord); + reindexing.max_load_factor(Utilities::DefaultMaxLoadFactor()); + reindexing.reserve(Nprocessor_wise_coord + Nghosted_coord); } - - for (std::size_t i = 0; i < Ncoord; ++i) - processor_wise_reindexing.insert(std::make_pair(coords_list[i]->GetIndex(), - static_cast<int>(i) + 1)); + + for (std::size_t i = 0; i < Nprocessor_wise_coord; ++i) + reindexing.insert(std::make_pair(processor_wise_coords_list[i]->GetIndex(), + static_cast<int>(i) + 1)); + + for (std::size_t i = 0; i < Nghosted_coord; ++i) + reindexing.insert(std::make_pair(ghosted_coords_list[i]->GetIndex(), + static_cast<int>(i + Nprocessor_wise_coord) + 1)); + + assert(reindexing.size() == Nprocessor_wise_coord + Nghosted_coord); // Now we can write into the file with all informations from the map for (const auto& block : geometric_elt_by_type) @@ -699,7 +724,7 @@ namespace MoReFEM GmfSetKwd(mesh_index_, geometric_elt_code, static_cast<int>(Ngeometric_elements)); for (const auto& geometric_elt_ptr : geometric_elt_per_type_list) - geometric_elt_ptr->WriteMeditFormat(mesh_index_, processor_wise_reindexing); + geometric_elt_ptr->WriteMeditFormat(mesh_index_, reindexing); } } } diff --git a/Sources/Geometry/Mesh/Mesh.cpp b/Sources/Geometry/Mesh/Mesh.cpp index 6fd01574a6cde50e1eef2b43f06dea827643a22b..1b0d96bf8662cc36f6afceabb406e4946af4b6ae 100644 --- a/Sources/Geometry/Mesh/Mesh.cpp +++ b/Sources/Geometry/Mesh/Mesh.cpp @@ -328,13 +328,13 @@ namespace MoReFEM void Mesh::ShrinkToProcessorWise(const Wrappers::Mpi& mpi, - const GeometricElt::vector_shared_ptr& processor_wise_geo_element, - Coords::vector_raw_ptr&& processor_wise_coords_list, - Coords::vector_raw_ptr&& ghosted_coords_list, - unsigned int Nprocessor_wise_vertex, - unsigned int Nprocessor_wise_edge, - unsigned int Nprocessor_wise_face, - unsigned int Nprocessor_wise_volume) + const GeometricElt::vector_shared_ptr& processor_wise_geo_element, + Coords::vector_raw_ptr&& processor_wise_coords_list, + Coords::vector_raw_ptr&& ghosted_coords_list, + unsigned int Nprocessor_wise_vertex, + unsigned int Nprocessor_wise_edge, + unsigned int Nprocessor_wise_face, + unsigned int Nprocessor_wise_volume) { geometric_elt_list_.Clear(); geometric_elt_list_.Init(processor_wise_geo_element, false); @@ -353,12 +353,12 @@ namespace MoReFEM void Mesh::Read(const std::string& mesh_file, - MeshNS::Format format, - const double space_unit, - GeometricElt::vector_shared_ptr& unsort_element_list, - Coords::vector_unique_ptr& coords_list, - MeshLabel::vector_const_shared_ptr& mesh_label_list) - { + MeshNS::Format format, + const double space_unit, + GeometricElt::vector_shared_ptr& unsort_element_list, + Coords::vector_unique_ptr& coords_list, + MeshLabel::vector_const_shared_ptr& mesh_label_list) + { unsigned int dimension_read = NumericNS::UninitializedIndex<unsigned int>(); diff --git a/Sources/Model/Model.hpp b/Sources/Model/Model.hpp index 35ae74b95252d3e9ee45f5739ee718b7bf83e67c..1867d9698cbc150cf679f56ea825146f424204e7 100644 --- a/Sources/Model/Model.hpp +++ b/Sources/Model/Model.hpp @@ -343,6 +343,7 @@ namespace MoReFEM print_banner do_print_banner_ = print_banner::yes; }; + } // namespace MoReFEM diff --git a/Sources/PostProcessing/RefineMeshQuadranglesSpectral/RefineMesh.cpp b/Sources/PostProcessing/RefineMeshQuadranglesSpectral/RefineMesh.cpp index 5fe31af661b44e5ba7aea2809d7cc36e948542b0..1d451ab89d2979cac9534b02a9169a454ed84557 100644 --- a/Sources/PostProcessing/RefineMeshQuadranglesSpectral/RefineMesh.cpp +++ b/Sources/PostProcessing/RefineMeshQuadranglesSpectral/RefineMesh.cpp @@ -79,7 +79,7 @@ namespace MoReFEM for (unsigned int node = 0u; node < n_nodes; ++node) { auto coords_ptr = Internal::CoordsNS::Factory::Origin(); - coords_ptr->SetIndex(node); + coords_ptr->SetIndex(node); // \todo Very suspect! (Index is format-dependant, and Medit starts as 1 for instance...) coords_list.emplace_back(std::move(coords_ptr)); } diff --git a/Sources/Test/Geometry/LoadPrepartitionedMesh/CMakeLists.txt b/Sources/Test/Geometry/LoadPrepartitionedMesh/CMakeLists.txt index ee6875f72fb434854a4cfab69d47288f4f17f592..f7aba78158f7da5c9aa8410361652e63a7f9d4f7 100644 --- a/Sources/Test/Geometry/LoadPrepartitionedMesh/CMakeLists.txt +++ b/Sources/Test/Geometry/LoadPrepartitionedMesh/CMakeLists.txt @@ -18,3 +18,4 @@ add_test(LoadPrepartitionedMesh -- ${MOREFEM_ROOT} ${MOREFEM_TEST_OUTPUT_DIR}) + diff --git a/Sources/Test/Geometry/LoadPrepartitionedMesh/Model.cpp b/Sources/Test/Geometry/LoadPrepartitionedMesh/Model.cpp index f8838fcc06609afd67ceee630c5a50536104c757..34bb5bbdd4dfca60b6ebbc9c91b25cea11b9b056 100644 --- a/Sources/Test/Geometry/LoadPrepartitionedMesh/Model.cpp +++ b/Sources/Test/Geometry/LoadPrepartitionedMesh/Model.cpp @@ -7,6 +7,8 @@ // */ +#include <sstream> + #include "ThirdParty/IncludeWithoutWarning/Boost/Test.hpp" #include "Test/Geometry/LoadPrepartitionedMesh/Model.hpp" @@ -27,30 +29,19 @@ namespace MoReFEM : parent(morefem_data) { } - - namespace // anonymous - { - - - - } // namespace anonymous - void Model::SupplInitialize() { + decltype(auto) mpi = parent::GetMpi(); + decltype(auto) mesh_manager = Internal::MeshNS::MeshManager::GetInstance(__FILE__, __LINE__); + decltype(auto) mesh = mesh_manager.GetMesh<1>(); - } - - - - - namespace // anonymous - { - - - - } // namespace anonymous + decltype(auto) output_dir = parent::GetOutputDirectory(); + std::ostringstream oconv; + oconv << output_dir << "/mesh_" << mpi.GetRank<int>() << ".mesh"; + mesh.Write<MeshNS::Format::Medit>(oconv.str()); + } void Model::Forward()