Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MoReFEM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
45
Issues
45
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MoReFEM
CoreLibrary
MoReFEM
Commits
5d20fa66
Commit
5d20fa66
authored
Jun 20, 2020
by
GILLES Sebastien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1532
MatrixIO: keep going: I am just before the step where MatLoad is called.
parent
23f7b68d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
91 deletions
+53
-91
Sources/Test/ThirdParty/PETSc/MatrixIO/ToyModel.cpp
Sources/Test/ThirdParty/PETSc/MatrixIO/ToyModel.cpp
+17
-73
Sources/Test/ThirdParty/PETSc/MatrixIO/ToyModel.hpp
Sources/Test/ThirdParty/PETSc/MatrixIO/ToyModel.hpp
+2
-8
Sources/Test/ThirdParty/PETSc/MatrixIO/main.cpp
Sources/Test/ThirdParty/PETSc/MatrixIO/main.cpp
+29
-9
Sources/ThirdParty/Wrappers/Petsc/Matrix/Matrix.hpp
Sources/ThirdParty/Wrappers/Petsc/Matrix/Matrix.hpp
+5
-1
No files found.
Sources/Test/ThirdParty/PETSc/MatrixIO/ToyModel.cpp
View file @
5d20fa66
...
...
@@ -33,28 +33,10 @@ namespace MoReFEM::TestNS::PetscNS::MatrixIONS
{
std
::
string
Compute
ProcessorWise
AsciiFile
(
const
ToyModel
&
model
)
std
::
string
ComputeAsciiFile
(
const
ToyModel
&
model
)
{
std
::
ostringstream
oconv
;
oconv
<<
model
.
GetOutputDirectory
()
<<
"/vector_"
<<
model
.
GetMpi
().
GetRank
<
int
>
()
<<
".hhdata"
;
return
oconv
.
str
();
}
std
::
string
ComputeProcessorWiseBinaryFile
(
const
ToyModel
&
model
)
{
std
::
ostringstream
oconv
;
oconv
<<
model
.
GetOutputDirectory
()
<<
"/vector_"
<<
model
.
GetMpi
().
GetRank
<
int
>
()
<<
".bin"
;
return
oconv
.
str
();
}
std
::
string
ComputeProgramWiseAsciiFile
(
const
ToyModel
&
model
)
{
std
::
ostringstream
oconv
;
oconv
<<
model
.
GetOutputDirectory
()
<<
"/program_wise_vector.m"
;
oconv
<<
model
.
GetOutputDirectory
()
<<
"/matrix.m"
;
std
::
string
ret
=
oconv
.
str
();
oconv
.
str
(
""
);
...
...
@@ -64,10 +46,10 @@ namespace MoReFEM::TestNS::PetscNS::MatrixIONS
}
std
::
string
Compute
ProgramWise
BinaryFile
(
const
ToyModel
&
model
)
std
::
string
ComputeBinaryFile
(
const
ToyModel
&
model
)
{
std
::
ostringstream
oconv
;
oconv
<<
model
.
GetOutputDirectory
()
<<
"/
program_wise_vector
.bin"
;
oconv
<<
model
.
GetOutputDirectory
()
<<
"/
matrix
.bin"
;
std
::
string
ret
=
oconv
.
str
();
oconv
.
str
(
""
);
...
...
@@ -130,69 +112,31 @@ namespace MoReFEM::TestNS::PetscNS::MatrixIONS
mass_op
.
Assemble
(
std
::
make_tuple
(
std
::
ref
(
matrix_with_coeff
)));
const
auto
matrix_file
=
GetOutputDirectory
().
AddFile
(
"matrix.txt"
);
std
::
cout
<<
"MATRIX = "
<<
matrix_file
<<
std
::
endl
;
matrix
.
View
(
mpi
,
matrix_file
,
__FILE__
,
__LINE__
);
// {
// const auto binary_file = GetProcessorWiseBinaryFile();
// if (FilesystemNS::File::DoExist(binary_file))
// FilesystemNS::File::Remove(binary_file, __FILE__, __LINE__);
// }
//
// {
// const auto ascii_file = GetProcessorWiseAsciiFile();
// if (FilesystemNS::File::DoExist(ascii_file))
// FilesystemNS::File::Remove(ascii_file, __FILE__, __LINE__);
// }
//
// if (mpi.IsRootProcessor())
// {
// {
// const auto binary_file = GetProgramWiseBinaryFile();
// if (FilesystemNS::File::DoExist(binary_file))
// FilesystemNS::File::Remove(binary_file, __FILE__, __LINE__);
// }
//
// {
// const auto ascii_file = GetProgramWiseAsciiFile();
// if (FilesystemNS::File::DoExist(ascii_file))
// FilesystemNS::File::Remove(ascii_file, __FILE__, __LINE__);
// }
// }
}
const
std
::
string
&
ToyModel
::
GetProcessorWiseBinaryFile
()
const
noexcept
{
static
auto
ret
=
ComputeProcessorWiseBinaryFile
(
*
this
);
return
ret
;
}
if
(
mpi
.
IsRootProcessor
())
{
const
auto
binary_file
=
GetBinaryFile
();
if
(
FilesystemNS
::
File
::
DoExist
(
binary_file
))
FilesystemNS
::
File
::
Remove
(
binary_file
,
__FILE__
,
__LINE__
);
const
std
::
string
&
ToyModel
::
GetProcessorWiseAsciiFile
()
const
noexcept
{
static
auto
ret
=
ComputeProcessorWiseAsciiFile
(
*
this
);
return
ret
;
const
auto
ascii_file
=
GetAsciiFile
();
if
(
FilesystemNS
::
File
::
DoExist
(
ascii_file
))
FilesystemNS
::
File
::
Remove
(
ascii_file
,
__FILE__
,
__LINE__
);
}
}
const
std
::
string
&
ToyModel
::
Get
ProgramWise
BinaryFile
()
const
noexcept
const
std
::
string
&
ToyModel
::
GetBinaryFile
()
const
noexcept
{
static
auto
ret
=
Compute
ProgramWise
BinaryFile
(
*
this
);
static
auto
ret
=
ComputeBinaryFile
(
*
this
);
return
ret
;
}
const
std
::
string
&
ToyModel
::
Get
ProgramWise
AsciiFile
()
const
noexcept
const
std
::
string
&
ToyModel
::
GetAsciiFile
()
const
noexcept
{
static
auto
ret
=
Compute
ProgramWise
AsciiFile
(
*
this
);
static
auto
ret
=
ComputeAsciiFile
(
*
this
);
return
ret
;
}
}
// namespace MoReFEM::TestNS::PetscNS::MatrixIONS
Sources/Test/ThirdParty/PETSc/MatrixIO/ToyModel.hpp
View file @
5d20fa66
...
...
@@ -85,17 +85,11 @@ namespace MoReFEM
//! Accessor to the matrix used for tests.
const
GlobalMatrix
&
GetMatrix
()
const
noexcept
;
//! Accessor to the path to the binary file for current rank.
const
std
::
string
&
GetProcessorWiseBinaryFile
()
const
noexcept
;
//! Accessor to the path to the ascii file for current rank.
const
std
::
string
&
GetProcessorWiseAsciiFile
()
const
noexcept
;
//! Accessor to the path to the program-wise binary file.
const
std
::
string
&
Get
ProgramWise
BinaryFile
()
const
noexcept
;
const
std
::
string
&
GetBinaryFile
()
const
noexcept
;
//! Accessor to the path to the program-wise ascii file.
const
std
::
string
&
Get
ProgramWise
AsciiFile
()
const
noexcept
;
const
std
::
string
&
GetAsciiFile
()
const
noexcept
;
private:
...
...
Sources/Test/ThirdParty/PETSc/MatrixIO/main.cpp
View file @
5d20fa66
...
...
@@ -59,12 +59,35 @@ PRAGMA_DIAGNOSTIC(push)
BOOST_FIXTURE_TEST_SUITE
(
program_wise
,
fixture_type
)
BOOST_FIXTURE_TEST_CASE
(
creation
,
fixture_type
)
{
decltype
(
auto
)
model
=
GetModel
();
}
BOOST_AUTO_TEST_CASE
(
creation
)
{
decltype
(
auto
)
model
=
GetModel
();
decltype
(
auto
)
mpi
=
model
.
GetMpi
();
BOOST_FIXTURE_TEST_CASE
(
load_ascii
,
fixture_type
)
{
decltype
(
auto
)
model
=
GetModel
();
decltype
(
auto
)
mpi
=
model
.
GetMpi
();
decltype
(
auto
)
matrix
=
model
.
GetMatrix
();
decltype
(
auto
)
ascii_file
=
model
.
GetAsciiFile
();
BOOST_CHECK
(
FilesystemNS
::
File
::
DoExist
(
ascii_file
)
==
false
);
matrix
.
View
(
mpi
,
ascii_file
,
__FILE__
,
__LINE__
);
if
(
mpi
.
IsRootProcessor
())
BOOST_CHECK
(
FilesystemNS
::
File
::
DoExist
(
ascii_file
)
==
true
);
}
// decltype(auto) vector = model.GetVector();
...
...
@@ -90,7 +113,7 @@ BOOST_FIXTURE_TEST_SUITE(program_wise, fixture_type)
// BOOST_CHECK(FilesystemNS::File::DoExist(ascii_file) == true);
// BOOST_CHECK(FilesystemNS::File::DoExist(binary_file) == true);
// }
}
// BOOST_AUTO_TEST_CASE(load_binary)
...
...
@@ -128,9 +151,6 @@ BOOST_FIXTURE_TEST_SUITE(program_wise, fixture_type)
// No load_ascii: not foreseen apparently in PETSc interface!
BOOST_AUTO_TEST_SUITE_END
()
PRAGMA_DIAGNOSTIC
(
pop
)
...
...
Sources/ThirdParty/Wrappers/Petsc/Matrix/Matrix.hpp
View file @
5d20fa66
...
...
@@ -513,13 +513,17 @@ namespace MoReFEM
/*!
* \brief Wrapper over MatView in the case the viewer is a file.
*
* \a MatView write the content of the matrix only on the root processor; if you need it on several you need to copy the file afterwards
* (for instance in the case of prepartitioned data).
*
* \copydoc doxygen_hide_mpi_param
* \param[in] format Format in which the matrix is written. See Petsc manual pages to get all the
* formats available; relevant ones so far are PETSC_VIEWER_DEFAULT and PETSC_VIEWER_ASCII_MATLAB.
* \param[in] output_file File into which the vector content will be written.
* \copydoc doxygen_hide_invoking_file_and_line
*/
void
View
(
const
Mpi
&
mpi
,
const
std
::
string
&
output_file
,
const
char
*
invoking_file
,
int
invoking_line
,
void
View
(
const
Mpi
&
mpi
,
const
std
::
string
&
output_file
,
const
char
*
invoking_file
,
int
invoking_line
,
PetscViewerFormat
format
=
PETSC_VIEWER_DEFAULT
)
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment