Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chaofan Chen
ogs
Commits
a8dc6e61
Commit
a8dc6e61
authored
3 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[T/MaL] Adjustment to new LinearSolverOptionsParser.
parent
bee0ed51
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Tests/MathLib/TestLinearSolver.cpp
+18
-8
18 additions, 8 deletions
Tests/MathLib/TestLinearSolver.cpp
Tests/NumLib/TestODEInt.cpp
+19
-11
19 additions, 11 deletions
Tests/NumLib/TestODEInt.cpp
Tests/NumLib/TestSerialLinearSolver.cpp
+6
-1
6 additions, 1 deletion
Tests/NumLib/TestSerialLinearSolver.cpp
with
43 additions
and
20 deletions
Tests/MathLib/TestLinearSolver.cpp
+
18
−
8
View file @
a8dc6e61
...
@@ -20,19 +20,18 @@
...
@@ -20,19 +20,18 @@
#include
"MathLib/LinAlg/Eigen/EigenLinearSolver.h"
#include
"MathLib/LinAlg/Eigen/EigenLinearSolver.h"
#include
"MathLib/LinAlg/Eigen/EigenMatrix.h"
#include
"MathLib/LinAlg/Eigen/EigenMatrix.h"
#include
"MathLib/LinAlg/Eigen/EigenVector.h"
#include
"MathLib/LinAlg/Eigen/EigenVector.h"
#include
"MathLib/LinAlg/Eigen/LinearSolverOptionsParser.h"
#include
"MathLib/LinAlg/FinalizeMatrixAssembly.h"
#include
"MathLib/LinAlg/FinalizeMatrixAssembly.h"
#include
"MathLib/LinAlg/LinAlg.h"
#include
"MathLib/LinAlg/LinAlg.h"
#if defined(USE_LIS)
#include
"MathLib/LinAlg/EigenLis/EigenLisLinearSolver.h"
#endif
#ifdef USE_LIS
#ifdef USE_LIS
#include
"MathLib/LinAlg/Lis/LisLinearSolver.h"
#include
"MathLib/LinAlg/EigenLis/EigenLisLinearSolver.h"
#include
"MathLib/LinAlg/EigenLis/LinearSolverOptionsParser.h"
#include
"MathLib/LinAlg/Lis/LisVector.h"
#include
"MathLib/LinAlg/Lis/LisVector.h"
#endif
#endif
#ifdef USE_PETSC
#ifdef USE_PETSC
#include
"MathLib/LinAlg/PETSc/LinearSolverOptionsParser.h"
#include
"MathLib/LinAlg/PETSc/PETScLinearSolver.h"
#include
"MathLib/LinAlg/PETSc/PETScLinearSolver.h"
#include
"MathLib/LinAlg/PETSc/PETScMatrix.h"
#include
"MathLib/LinAlg/PETSc/PETScMatrix.h"
#include
"MathLib/LinAlg/PETSc/PETScVector.h"
#include
"MathLib/LinAlg/PETSc/PETScVector.h"
...
@@ -208,8 +207,12 @@ void checkLinearSolverInterface(T_MATRIX& A,
...
@@ -208,8 +207,12 @@ void checkLinearSolverInterface(T_MATRIX& A,
MathLib
::
finalizeMatrixAssembly
(
A
);
MathLib
::
finalizeMatrixAssembly
(
A
);
// solve
auto
const
linear_solver_parser
=
T_LINEAR_SOLVER
ls
(
"dummy_name"
,
&
ls_option
);
MathLib
::
LinearSolverOptionsParser
<
T_LINEAR_SOLVER
>
{};
auto
const
solver_options
=
linear_solver_parser
.
parseNameAndOptions
(
""
,
&
ls_option
);
T_LINEAR_SOLVER
ls
{
std
::
get
<
0
>
(
solver_options
),
std
::
get
<
1
>
(
solver_options
)};
ls
.
solve
(
A
,
rhs
,
x
);
ls
.
solve
(
A
,
rhs
,
x
);
ASSERT_ARRAY_NEAR
(
ex1
.
exH
,
x
,
ex1
.
dim_eqs
,
1e-5
);
ASSERT_ARRAY_NEAR
(
ex1
.
exH
,
x
,
ex1
.
dim_eqs
,
1e-5
);
...
@@ -273,7 +276,12 @@ void checkLinearSolverInterface(T_MATRIX& A, T_VECTOR& b,
...
@@ -273,7 +276,12 @@ void checkLinearSolverInterface(T_MATRIX& A, T_VECTOR& b,
// solve
// solve
T_VECTOR
y
(
b
,
deep_copy
);
T_VECTOR
y
(
b
,
deep_copy
);
y
.
setZero
();
y
.
setZero
();
T_LINEAR_SOLVER
ls
(
prefix_name
,
&
ls_option
);
std
::
string
temp_prefix_name
=
prefix_name
;
auto
const
solver_options
=
MathLib
::
LinearSolverOptionsParser
<
T_LINEAR_SOLVER
>
{}
.
parseNameAndOptions
(
std
::
move
(
temp_prefix_name
),
&
ls_option
);
T_LINEAR_SOLVER
ls
(
std
::
get
<
0
>
(
solver_options
),
std
::
get
<
1
>
(
solver_options
));
EXPECT_TRUE
(
ls
.
solve
(
A
,
b
,
y
));
EXPECT_TRUE
(
ls
.
solve
(
A
,
b
,
y
));
EXPECT_GT
(
ls
.
getNumberOfIterations
(),
0u
);
EXPECT_GT
(
ls
.
getNumberOfIterations
(),
0u
);
...
@@ -286,6 +294,7 @@ void checkLinearSolverInterface(T_MATRIX& A, T_VECTOR& b,
...
@@ -286,6 +294,7 @@ void checkLinearSolverInterface(T_MATRIX& A, T_VECTOR& b,
}
// end namespace
}
// end namespace
#if not defined(USE_LIS) and not defined(USE_PETSC)
TEST
(
Math
,
CheckInterface_Eigen
)
TEST
(
Math
,
CheckInterface_Eigen
)
{
{
// set solver options using Boost property tree
// set solver options using Boost property tree
...
@@ -305,6 +314,7 @@ TEST(Math, CheckInterface_Eigen)
...
@@ -305,6 +314,7 @@ TEST(Math, CheckInterface_Eigen)
checkLinearSolverInterface
<
MathLib
::
EigenMatrix
,
MathLib
::
EigenVector
,
checkLinearSolverInterface
<
MathLib
::
EigenMatrix
,
MathLib
::
EigenVector
,
MathLib
::
EigenLinearSolver
,
IntType
>
(
A
,
conf
);
MathLib
::
EigenLinearSolver
,
IntType
>
(
A
,
conf
);
}
}
#endif
#if defined(USE_LIS)
#if defined(USE_LIS)
TEST
(
Math
,
CheckInterface_EigenLis
)
TEST
(
Math
,
CheckInterface_EigenLis
)
...
...
This diff is collapsed.
Click to expand it.
Tests/NumLib/TestODEInt.cpp
+
19
−
11
View file @
a8dc6e61
...
@@ -25,23 +25,31 @@
...
@@ -25,23 +25,31 @@
namespace
TestODEInt
namespace
TestODEInt
{
{
#ifndef USE_PETSC
#if defined(USE_PETSC)
std
::
unique_ptr
<
GlobalLinearSolver
>
createLinearSolver
()
{
std
::
string
const
petsc_options
=
"-ksp_type bcgs -pc_type sor -ksp_rtol 1e-24 -ksp_max_it 100 "
"-ksp_initial_guess_nonzero false"
;
return
std
::
make_unique
<
GlobalLinearSolver
>
(
""
,
petsc_options
);
}
#elif defined(USE_LIS)
std
::
unique_ptr
<
GlobalLinearSolver
>
createLinearSolver
()
std
::
unique_ptr
<
GlobalLinearSolver
>
createLinearSolver
()
{
{
return
std
::
make_unique
<
GlobalLinearSolver
>
(
""
,
nullptr
);
auto
const
solver_options
=
MathLib
::
LinearSolverOptionsParser
<
GlobalLinearSolver
>
{}
.
parseNameAndOptions
(
""
,
nullptr
);
return
std
::
make_unique
<
GlobalLinearSolver
>
(
std
::
get
<
0
>
(
solver_options
),
std
::
get
<
1
>
(
solver_options
));
}
}
#else
#else
std
::
unique_ptr
<
GlobalLinearSolver
>
createLinearSolver
()
std
::
unique_ptr
<
GlobalLinearSolver
>
createLinearSolver
()
{
{
const
char
xml
[]
=
auto
const
solver_options
=
"<petsc><parameters>"
MathLib
::
LinearSolverOptionsParser
<
GlobalLinearSolver
>
{}
"-ksp_type bcgs -pc_type sor -ksp_rtol 1e-24 -ksp_max_it 100 "
.
parseNameAndOptions
(
""
,
nullptr
);
"-ksp_initial_guess_nonzero false"
return
std
::
make_unique
<
GlobalLinearSolver
>
(
std
::
get
<
0
>
(
solver_options
),
"</parameters></petsc>"
;
std
::
get
<
1
>
(
solver_options
));
auto
const
ptree
=
Tests
::
readXml
(
xml
);
BaseLib
::
ConfigTree
config
(
ptree
,
""
,
BaseLib
::
ConfigTree
::
onerror
,
BaseLib
::
ConfigTree
::
onwarning
);
return
std
::
make_unique
<
GlobalLinearSolver
>
(
""
,
&
config
);
}
}
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
Tests/NumLib/TestSerialLinearSolver.cpp
+
6
−
1
View file @
a8dc6e61
...
@@ -127,7 +127,12 @@ TEST(NumLibSerialLinearSolver, Steady2DdiffusionQuadElem)
...
@@ -127,7 +127,12 @@ TEST(NumLibSerialLinearSolver, Steady2DdiffusionQuadElem)
BaseLib
::
ConfigTree
conf
(
t_root
,
""
,
BaseLib
::
ConfigTree
::
onerror
,
BaseLib
::
ConfigTree
conf
(
t_root
,
""
,
BaseLib
::
ConfigTree
::
onerror
,
BaseLib
::
ConfigTree
::
onwarning
);
BaseLib
::
ConfigTree
::
onwarning
);
GlobalLinearSolver
ls
(
"solver_name"
,
&
conf
);
auto
const
linear_solver_parser
=
MathLib
::
LinearSolverOptionsParser
<
GlobalLinearSolver
>
{};
auto
const
solver_options
=
linear_solver_parser
.
parseNameAndOptions
(
""
,
&
conf
);
GlobalLinearSolver
ls
{
std
::
get
<
0
>
(
solver_options
),
std
::
get
<
1
>
(
solver_options
)};
ls
.
solve
(
*
A
,
*
rhs
,
*
x
);
ls
.
solve
(
*
A
,
*
rhs
,
*
x
);
// copy solution to double vector
// copy solution to double vector
...
...
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