Commit 386aae41 authored by GILLES Sebastien's avatar GILLES Sebastien

#1473 - #1474: Make parallelism_ truly an optional parameter in MoReFEMData.

parent d4582da6
......@@ -32,6 +32,7 @@
# include "Core/InputData/Instances/Result.hpp"
# include "Core/InitTimeKeepLog.hpp"
# include "Core/InputData/Instances/Parallelism/Parallelism.hpp"
# include "Core/MoReFEMData/Internal/Parallelism.hpp"
......
......@@ -178,7 +178,10 @@ namespace MoReFEM
mpi,
DoTrackUnusedFieldsT);
parallelism_ = std::make_unique<Internal::Parallelism>(*input_data_);
// Parallelism is an optional field: it might not be present in the Lua file (for tests for instance it is not
// meaningful).
if constexpr (InputDataT::template Find<InputDataNS::Parallelism>())
parallelism_ = std::make_unique<Internal::Parallelism>(*input_data_);
namespace ipl = Utilities::InputDataNS;
using Result = InputDataNS::Result;
......@@ -286,7 +289,9 @@ namespace MoReFEM
const Internal::Parallelism* MoReFEMData<InputDataT, DoTrackUnusedFieldsT, AdditionalCommandLineArgumentsPolicyT>
::GetParallelismPtr() const noexcept
{
assert(!(!parallelism_));
if (!parallelism_)
return nullptr;
return parallelism_.get();
}
......
......@@ -876,9 +876,9 @@ namespace MoReFEM
}
// Write if required the parallelism strategy.
if (IsParallelismStrategy())
{
decltype(auto) parallelism = GetParallelism();
const auto parallelism_strategy = parallelism.GetParallelismStrategy();
decltype(auto) mesh = GetMesh();
......@@ -890,12 +890,9 @@ namespace MoReFEM
{
const auto parallelism_directory = GetOutputDirectory() + "/Parallelism";
std::cout << "CHECK = " << parallelism_directory << std::endl;
FilesystemNS::Folder::Create(parallelism_directory, __FILE__, __LINE__);
Advanced::MeshNS::WritePrepartitionedData partition_data_facility(mpi,
mesh,
Advanced::MeshNS::WritePrepartitionedData partition_data_facility(mesh,
parallelism_directory,
mesh.GetInitialFormat());
......
......@@ -427,6 +427,9 @@ namespace MoReFEM
*/
auto GetIteratorFEltSpace(unsigned int unique_id) const;
//! Whether parallelism object is activated or not for the current model.
bool IsParallelismStrategy() const noexcept;
//! Access to internal object in charge of parallelism strategy.
const Internal::Parallelism& GetParallelism() const noexcept;
......
......@@ -276,6 +276,12 @@ namespace MoReFEM
}
inline bool GodOfDof::IsParallelismStrategy() const noexcept
{
return parallelism_ != nullptr;
}
} // namespace MoReFEM
......
......@@ -13,8 +13,6 @@
#include "Utilities/Filesystem/File.hpp"
#include "ThirdParty/Wrappers/Mpi/Mpi.hpp"
#include "Geometry/Mesh/Mesh.hpp"
#include "Geometry/Mesh/Advanced/WritePrepartitionedData.hpp"
#include "Geometry/Mesh/Internal/Format/Medit.hpp"
......@@ -37,8 +35,7 @@ namespace MoReFEM::Advanced::MeshNS
} // namespace anonymous
WritePrepartitionedData::WritePrepartitionedData(const Wrappers::Mpi& mpi,
const Mesh& mesh,
WritePrepartitionedData::WritePrepartitionedData(const Mesh& mesh,
const std::string& output_directory,
::MoReFEM::MeshNS::Format format)
{
......
......@@ -66,18 +66,15 @@ namespace MoReFEM
/*!
* \brief Constructor.
*
* \copydetails doxygen_hide_mpi_param
* \param[in] mesh \a Mesh which partitioning will be written on disk.
* \param[in] output_directory Directory into which the model result data are written. The two generated
* files will actually be put in a subdirectory named "Mesh_*" where '*' is the unique identifier of the
* mesh.
* \param[in] output_directory Directory into which the data are written for a given \a Mesh and a given
* mpi rank. Typically something like /Volumes/Data/${USER}/MoReFEM/Results/MyModel/Rank_0/Mesh_1.
* \param[in] format Format into which write the reduced mesh. Should be the same as the format used
* to read the original mesh (this way you're sure the operation is possible - some types of geometric
* element are not supported by all formats).
*
*/
explicit WritePrepartitionedData(const Wrappers::Mpi& mpi,
const Mesh& mesh,
explicit WritePrepartitionedData(const Mesh& mesh,
const std::string& output_directory,
::MoReFEM::MeshNS::Format format);
......
......@@ -42,8 +42,7 @@ namespace MoReFEM::TestNS::LoadPrepartitionedMeshNS
Internal::MeshNS::FormatNS::GetType(Utilities::InputDataNS
::Extract<InputDataNS::Mesh<1>::Format>::Value(input_data));
Advanced::MeshNS::WritePrepartitionedData partition_data_facility(mpi,
mesh,
Advanced::MeshNS::WritePrepartitionedData partition_data_facility(mesh,
output_dir,
format);
......
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