Commit 3a2e931c authored by GILLES Sebastien's avatar GILLES Sebastien

#1538 Use optional instead of unique_ptr for behaviour in FilesystemNS::Directory constructor.

parent 37533b56
......@@ -53,7 +53,7 @@ namespace MoReFEM
FilesystemNS::Directory output_mesh_directory(mesh_directory,
"OutputDeformedMesh_" + std::to_string(output_mesh_index),
__FILE__, __LINE__,
std::make_unique<FilesystemNS::behaviour>(FilesystemNS::behaviour::overwrite));
FilesystemNS::behaviour::overwrite);
const auto mesh_dimension = mesh.GetDimension();
const auto unique_id_output_mesh = mesh_manager.GenerateUniqueId();
......
......@@ -162,7 +162,7 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
ensight_directory_smart_ptr = std::make_unique<FilesystemNS::Directory>(mesh_directory,
"Ensight6",
__FILE__, __LINE__,
std::make_unique<FilesystemNS::behaviour>(FilesystemNS::behaviour::overwrite));
FilesystemNS::behaviour::overwrite);
ensight_directory_ptr = ensight_directory_smart_ptr.get();
}
......
......@@ -105,7 +105,7 @@ namespace MoReFEM
FilesystemNS::Directory root_dir(GetDataDirectory(),
"..",
__FILE__, __LINE__,
std::make_unique<FilesystemNS::behaviour>(FilesystemNS::behaviour::read));
FilesystemNS::behaviour::read);
// Assumes number of processors has been retrieved earlier; constructor is built to ensure this is the
// case.
......
......@@ -64,12 +64,11 @@ namespace MoReFEM::TestNS::LoadPrepartitionedMeshNS
// Write the interfaces.hhdata file for the reconstructed mesh.
// Used for development purposes - the actual test is done on objects in memory.
{
auto behaviour = std::make_unique<FilesystemNS::behaviour>(FilesystemNS::behaviour::create);
auto reconstructed_dir =
std::make_unique<const FilesystemNS::Directory>(parent::GetOutputDirectory(),
"reconstructed",
__FILE__, __LINE__,
std::move(behaviour));
FilesystemNS::behaviour::create);
WriteInterfaceList({reconstructed_mesh_index, std::move(reconstructed_dir)});
}
......
......@@ -164,14 +164,6 @@ namespace MoReFEM::TestNS::GlobalCoordsQuadPt
}
}
if (topology_identifier == RefGeomEltNS::TopologyNS::Type::tetrahedron
|| topology_identifier == RefGeomEltNS::TopologyNS::Type::triangle)
{
// Integration interval is already defined on [0., 1.]^n for these topologies.
expected_value = local_coords;
}
else
expected_global_coords.push_back(expected_value);
}
......@@ -184,7 +176,6 @@ namespace MoReFEM::TestNS::GlobalCoordsQuadPt
}
void CheckQuadratureRule(const QuadratureRulePerTopology& quadrature_rule_per_topology,
const ParameterAtQuadraturePoint<ParameterNS::Type::vector>& obtained_global_coords,
const FilesystemNS::Directory& result_directory_path,
......@@ -213,10 +204,12 @@ namespace MoReFEM::TestNS::GlobalCoordsQuadPt
FilesystemNS::Directory output_directory(result_directory_path,
ref_geom_elt.GetTopologyName(),
__FILE__, __LINE__);
__FILE__, __LINE__,
FilesystemNS::behaviour::create_if_necessary);
const std::string output_file = output_directory.AddFile(quadrature_order);
obtained_global_coords.Write(output_file);
std::cout << "OUT = " << output_file << std::endl;
// Read from output and compare results.
std::ifstream file_stream;
......
......@@ -14,6 +14,7 @@
# include <string>
# include <sstream>
# include <memory>
# include <optional>
# include "Utilities/Exceptions/Exception.hpp"
# include "Utilities/Filesystem/Advanced/Directory.hpp"
......@@ -140,7 +141,7 @@ namespace MoReFEM::FilesystemNS
* \param[in] parent_directory The directory into which the new one is created (or read - depends on behaviour).
* The constructed directory takes the same attributes than its parent directory - except obviously for the path.
* \copydoc doxygen_hide_invoking_file_and_line
* \param[in] directory_behaviour_ptr Pointer to directory behaviour; if nullptr the behaviour of the parent
* \param[in] directory_behaviour Directory behaviour; if \a nullopt the behaviour of the parent
* directory is used (you should stick with this choice most of the time),
*
* \tparam StringT Type of \a subdirectory, which may actually be anything for which operator<< has been
......@@ -157,7 +158,7 @@ namespace MoReFEM::FilesystemNS
explicit Directory(const Directory& parent_directory,
const StringT& subdirectory,
const char* invoking_file, int invoking_line,
std::unique_ptr<behaviour> directory_behaviour_ptr = nullptr);
std::optional<behaviour> directory_behaviour = std::nullopt);
/*!
* \brief Constructor of a \a Directory which is several layers of directories inside an already existing
......@@ -171,7 +172,7 @@ namespace MoReFEM::FilesystemNS
explicit Directory(const Directory& parent_directory,
const std::vector<StringT>& layers,
const char* invoking_file, int invoking_line,
std::unique_ptr<behaviour> directory_behaviour_ptr = nullptr);
std::optional<behaviour> directory_behaviour = std::nullopt);
//! Destructor.
~Directory() = default;
......
......@@ -20,9 +20,9 @@ namespace MoReFEM::FilesystemNS
Directory::Directory(const Directory& parent_directory,
const StringT& subdirectory,
const char* invoking_file, int invoking_line,
std::unique_ptr<behaviour> directory_behaviour_ptr)
std::optional<behaviour> directory_behaviour)
: mpi_(parent_directory.GetMpiPtr()),
directory_behaviour_(directory_behaviour_ptr == nullptr ? parent_directory.GetBehaviour() : *directory_behaviour_ptr),
directory_behaviour_(directory_behaviour.has_value() ? directory_behaviour.value() : parent_directory.GetBehaviour()),
with_rank_(parent_directory.IsWithRank())
{
Internal::FilesystemNS::CheckForSubdirectoryConstructor(parent_directory, invoking_file, invoking_line);
......@@ -39,9 +39,9 @@ namespace MoReFEM::FilesystemNS
Directory::Directory(const Directory& parent_directory,
const std::vector<StringT>& subdirectories,
const char* invoking_file, int invoking_line,
std::unique_ptr<behaviour> directory_behaviour_ptr)
std::optional<behaviour> directory_behaviour)
: mpi_(parent_directory.GetMpiPtr()),
directory_behaviour_(directory_behaviour_ptr == nullptr ? parent_directory.GetBehaviour() : *directory_behaviour_ptr),
directory_behaviour_(directory_behaviour.has_value() ? directory_behaviour.value() : parent_directory.GetBehaviour()),
with_rank_(parent_directory.IsWithRank())
{
Internal::FilesystemNS::CheckForSubdirectoryConstructor(parent_directory, invoking_file, invoking_line);
......
......@@ -41,7 +41,7 @@ namespace MoReFEM::Internal::FilesystemNS
Directory one_step_above(root_directory,
"..",
__FILE__, __LINE__,
std::make_unique<behaviour>(behaviour::read));
behaviour::read);
Directory ret(one_step_above,
"Rank_" + std::to_string(rank),
......
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