Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
0b6aead1
Commit
0b6aead1
authored
4 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for LinearSolverOptions
parent
37d7f94d
No related branches found
No related tags found
1 merge request
!64
Feature/algebra coverage
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/test_LinearSolverOptions.cpp
+177
-0
177 additions, 0 deletions
tests/test_LinearSolverOptions.cpp
with
178 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
0b6aead1
...
@@ -73,6 +73,7 @@ add_executable (unit_tests
...
@@ -73,6 +73,7 @@ add_executable (unit_tests
test_IncDecExpressionProcessor.cpp
test_IncDecExpressionProcessor.cpp
test_INodeProcessor.cpp
test_INodeProcessor.cpp
test_ItemType.cpp
test_ItemType.cpp
test_LinearSolverOptions.cpp
test_ListAffectationProcessor.cpp
test_ListAffectationProcessor.cpp
test_MathModule.cpp
test_MathModule.cpp
test_NameProcessor.cpp
test_NameProcessor.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/test_LinearSolverOptions.cpp
0 → 100644
+
177
−
0
View file @
0b6aead1
#include
<catch2/catch.hpp>
#include
<algebra/LinearSolverOptions.hpp>
#include
<sstream>
// clazy:excludeall=non-pod-global-static
TEST_CASE
(
"LinearSolverOptions"
,
"[algebra]"
)
{
SECTION
(
"print options"
)
{
SECTION
(
"first set"
)
{
LinearSolverOptions
options
;
options
.
verbose
()
=
true
;
options
.
library
()
=
LSLibrary
::
builtin
;
options
.
method
()
=
LSMethod
::
cg
;
options
.
precond
()
=
LSPrecond
::
incomplete_choleski
;
options
.
epsilon
()
=
1E-3
;
options
.
maximumIteration
()
=
100
;
std
::
stringstream
os
;
os
<<
'\n'
<<
options
;
std
::
stringstream
expected_output
;
expected_output
<<
R"(
library: builtin
method : CG
precond: ICholeski
epsilon: )"
<<
1E-3
<<
R"(
maxiter: 100
verbose: true
)"
;
REQUIRE
(
os
.
str
()
==
expected_output
.
str
());
}
SECTION
(
"second set"
)
{
LinearSolverOptions
options
;
options
.
verbose
()
=
false
;
options
.
library
()
=
LSLibrary
::
petsc
;
options
.
method
()
=
LSMethod
::
gmres
;
options
.
precond
()
=
LSPrecond
::
incomplete_LU
;
options
.
epsilon
()
=
1E-6
;
options
.
maximumIteration
()
=
200
;
std
::
stringstream
os
;
os
<<
'\n'
<<
options
;
std
::
stringstream
expected_output
;
expected_output
<<
R"(
library: PETSc
method : GMRES
precond: ILU
epsilon: )"
<<
1E-6
<<
R"(
maxiter: 200
verbose: false
)"
;
REQUIRE
(
os
.
str
()
==
expected_output
.
str
());
}
}
SECTION
(
"library name"
)
{
REQUIRE
(
name
(
LSLibrary
::
builtin
)
==
"builtin"
);
REQUIRE
(
name
(
LSLibrary
::
petsc
)
==
"PETSc"
);
REQUIRE_THROWS_WITH
(
name
(
LSLibrary
::
LS__end
),
"unexpected error: Linear system library name is not defined!"
);
}
SECTION
(
"method name"
)
{
REQUIRE
(
name
(
LSMethod
::
cg
)
==
"CG"
);
REQUIRE
(
name
(
LSMethod
::
bicgstab
)
==
"BICGStab"
);
REQUIRE
(
name
(
LSMethod
::
bicgstab2
)
==
"BICGStab2"
);
REQUIRE
(
name
(
LSMethod
::
gmres
)
==
"GMRES"
);
REQUIRE
(
name
(
LSMethod
::
lu
)
==
"LU"
);
REQUIRE
(
name
(
LSMethod
::
choleski
)
==
"Choleski"
);
REQUIRE_THROWS_WITH
(
name
(
LSMethod
::
LS__end
),
"unexpected error: Linear system method name is not defined!"
);
}
SECTION
(
"precond name"
)
{
REQUIRE
(
name
(
LSPrecond
::
none
)
==
"none"
);
REQUIRE
(
name
(
LSPrecond
::
diagonal
)
==
"diagonal"
);
REQUIRE
(
name
(
LSPrecond
::
incomplete_choleski
)
==
"ICholeski"
);
REQUIRE
(
name
(
LSPrecond
::
incomplete_LU
)
==
"ILU"
);
REQUIRE
(
name
(
LSPrecond
::
amg
)
==
"AMG"
);
REQUIRE_THROWS_WITH
(
name
(
LSPrecond
::
LS__end
),
"unexpected error: Linear system preconditioner name is not defined!"
);
}
SECTION
(
"library from name"
)
{
REQUIRE
(
LSLibrary
::
builtin
==
getLSEnumFromName
<
LSLibrary
>
(
"builtin"
));
REQUIRE
(
LSLibrary
::
petsc
==
getLSEnumFromName
<
LSLibrary
>
(
"PETSc"
));
REQUIRE_THROWS_WITH
(
getLSEnumFromName
<
LSLibrary
>
(
"__invalid_lib"
),
"error: could not find '__invalid_lib' associate type!"
);
}
SECTION
(
"method from name"
)
{
REQUIRE
(
LSMethod
::
cg
==
getLSEnumFromName
<
LSMethod
>
(
"CG"
));
REQUIRE
(
LSMethod
::
bicgstab
==
getLSEnumFromName
<
LSMethod
>
(
"BICGStab"
));
REQUIRE
(
LSMethod
::
bicgstab2
==
getLSEnumFromName
<
LSMethod
>
(
"BICGStab2"
));
REQUIRE
(
LSMethod
::
lu
==
getLSEnumFromName
<
LSMethod
>
(
"LU"
));
REQUIRE
(
LSMethod
::
choleski
==
getLSEnumFromName
<
LSMethod
>
(
"Choleski"
));
REQUIRE
(
LSMethod
::
gmres
==
getLSEnumFromName
<
LSMethod
>
(
"GMRES"
));
REQUIRE_THROWS_WITH
(
getLSEnumFromName
<
LSMethod
>
(
"__invalid_method"
),
"error: could not find '__invalid_method' associate type!"
);
}
SECTION
(
"precond from name"
)
{
REQUIRE
(
LSPrecond
::
none
==
getLSEnumFromName
<
LSPrecond
>
(
"none"
));
REQUIRE
(
LSPrecond
::
diagonal
==
getLSEnumFromName
<
LSPrecond
>
(
"diagonal"
));
REQUIRE
(
LSPrecond
::
incomplete_choleski
==
getLSEnumFromName
<
LSPrecond
>
(
"ICholeski"
));
REQUIRE
(
LSPrecond
::
incomplete_LU
==
getLSEnumFromName
<
LSPrecond
>
(
"ILU"
));
REQUIRE_THROWS_WITH
(
getLSEnumFromName
<
LSPrecond
>
(
"__invalid_precond"
),
"error: could not find '__invalid_precond' associate type!"
);
}
SECTION
(
"library list"
)
{
std
::
stringstream
os
;
os
<<
'\n'
;
printLSEnumListNames
<
LSLibrary
>
(
os
);
const
std
::
string
library_list
=
R"(
- builtin
- PETSc
)"
;
REQUIRE
(
os
.
str
()
==
library_list
);
}
SECTION
(
"method list"
)
{
std
::
stringstream
os
;
os
<<
'\n'
;
printLSEnumListNames
<
LSMethod
>
(
os
);
const
std
::
string
library_list
=
R"(
- CG
- BICGStab
- BICGStab2
- GMRES
- LU
- Choleski
)"
;
REQUIRE
(
os
.
str
()
==
library_list
);
}
SECTION
(
"precond list"
)
{
std
::
stringstream
os
;
os
<<
'\n'
;
printLSEnumListNames
<
LSPrecond
>
(
os
);
const
std
::
string
library_list
=
R"(
- none
- diagonal
- ICholeski
- ILU
- AMG
)"
;
REQUIRE
(
os
.
str
()
==
library_list
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment