From 2c3f1f47ebcdc809256fd0593b6300d082af0b5a Mon Sep 17 00:00:00 2001 From: Sebastien Gilles Date: Thu, 18 Jun 2020 17:21:08 +0200 Subject: [PATCH] #1531 FromVertexMatching: add a method to print what is required to rebuild an object. --- .../FromVertexMatching/FromVertexMatching.cpp | 27 +++++++++++++++++++ .../FromVertexMatching/FromVertexMatching.hpp | 17 +++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Sources/OperatorInstances/NonConformInterpolator/FromVertexMatching/FromVertexMatching.cpp b/Sources/OperatorInstances/NonConformInterpolator/FromVertexMatching/FromVertexMatching.cpp index 451c3e27b..9d1e47daf 100644 --- a/Sources/OperatorInstances/NonConformInterpolator/FromVertexMatching/FromVertexMatching.cpp +++ b/Sources/OperatorInstances/NonConformInterpolator/FromVertexMatching/FromVertexMatching.cpp @@ -219,6 +219,33 @@ namespace MoReFEM interpolation_matrix.Assembly(__FILE__, __LINE__); } + + + void FromVertexMatching::Print(const Wrappers::Mpi& mpi, + const FilesystemNS::Directory& directory) const + { + const auto matrix_file = directory.AddFile("matrix.m"); + + GetInterpolationMatrix().View(mpi, + matrix_file, + __FILE__, __LINE__, + PETSC_VIEWER_ASCII_MATLAB); + + if (matrix_pattern_ != nullptr) + { + const auto matrix_pattern_file = directory.AddFile("matrix_pattern.lua"); + + std::ofstream out; + + FilesystemNS::File::Create(out, matrix_pattern_file, __FILE__, __LINE__); + + out << "iCSR = "; + Utilities::PrintContainer<>::Do(matrix_pattern_->GetICsr(), out, ", ", "{", "}"); + + out << "\njCSR = "; + Utilities::PrintContainer<>::Do(matrix_pattern_->GetJCsr(), out, ", ", "{", "}"); + } + } } // namespace NonConformInterpolatorNS diff --git a/Sources/OperatorInstances/NonConformInterpolator/FromVertexMatching/FromVertexMatching.hpp b/Sources/OperatorInstances/NonConformInterpolator/FromVertexMatching/FromVertexMatching.hpp index 7cee6dc49..1106b2d47 100644 --- a/Sources/OperatorInstances/NonConformInterpolator/FromVertexMatching/FromVertexMatching.hpp +++ b/Sources/OperatorInstances/NonConformInterpolator/FromVertexMatching/FromVertexMatching.hpp @@ -18,6 +18,8 @@ # include # include +# include "Utilities/Filesystem/Directory.hpp" + # include "Core/LinearAlgebra/GlobalMatrix.hpp" # include "Geometry/Interpolator/VertexMatching.hpp" @@ -128,7 +130,7 @@ namespace MoReFEM * * \copydoc doxygen_hide_input_data_arg * \copydetails doxygen_hide_from_vertex_matching_constructor_arg - */ + */ template explicit FromVertexMatching(const InputDataT& input_data, unsigned int source_index, @@ -165,6 +167,19 @@ namespace MoReFEM */ const Wrappers::Petsc::MatrixPattern& GetMatrixPattern() const noexcept; + /*! + * \brief Write in the chosen directory the interpolation matrix and if relevant the matrix pattern. + * + * By convention: + * - The interpolation matrix is named "matrix.m" + * - The mattrix pattern is named "matrix_pattern.lua" (it is a Lua file which give the fields iCSR and jCSR. + * + * \param[in] directory Directory in which the file(s) will be created. It must exist and allows the creation of the files inside. + * \copydoc doxygen_hide_mpi_param + */ + void Print(const Wrappers::Mpi& mpi, + const FilesystemNS::Directory& directory) const; + private: /*! -- GitLab