Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Backofen, Rainer
amdis
Commits
24b520f6
Commit
24b520f6
authored
Oct 21, 2016
by
Praetorius, Simon
Browse files
added implementation for PetscOptionsInsertString with switch on PETSC_VERSION
parent
a72ec8f7
Changes
5
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/parallel/PetscSolver.cc
View file @
24b520f6
...
...
@@ -49,7 +49,7 @@ namespace AMDiS { namespace Parallel {
Parameters
::
get
(
name
+
"->ksp"
,
kspStr
);
if
(
kspStr
!=
""
)
P
etsc
O
ptions
I
nsert
S
tring
(
kspStr
.
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
(
kspStr
.
c_str
());
Parameters
::
get
(
name
+
"->remove rhs null space"
,
removeRhsNullspace
);
Parameters
::
get
(
name
+
"->has constant null space"
,
hasConstantNullspace
);
...
...
AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
View file @
24b520f6
...
...
@@ -50,15 +50,15 @@ namespace AMDiS { namespace Parallel {
if
(
params
.
matSolverPackage
.
find
(
kspSolver
)
!=
params
.
matSolverPackage
.
end
())
{
// direct solvers
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_type preonly"
).
c_str
());
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"pc_type lu"
).
c_str
());
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"pc_factor_mat_solver_package "
+
kspSolver
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_type preonly"
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"pc_type lu"
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"pc_factor_mat_solver_package "
+
kspSolver
).
c_str
());
setMaxIterations
(
1
);
zeroStartVector
=
true
;
matSolverPackage
=
true
;
}
else
if
(
params
.
emptyParam
.
find
(
kspSolver
)
==
params
.
emptyParam
.
end
()
&&
solverName
!=
"petsc"
)
{
// other solvers
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_type "
+
kspSolver
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_type "
+
kspSolver
).
c_str
());
}
// set the preconditioner
...
...
@@ -70,17 +70,17 @@ namespace AMDiS { namespace Parallel {
Parameters
::
get
(
name
+
"->right precon"
,
precon
);
if
(
!
matSolverPackage
&&
params
.
emptyParam
.
find
(
precon
)
==
params
.
emptyParam
.
end
())
{
precon
=
(
params
.
preconMap
.
find
(
precon
)
!=
params
.
preconMap
.
end
()
?
params
.
preconMap
[
precon
]
:
precon
);
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"pc_type "
+
precon
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"pc_type "
+
precon
).
c_str
());
}
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_max_it "
+
boost
::
lexical_cast
<
std
::
string
>
(
getMaxIterations
())).
c_str
());
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_rtol "
+
boost
::
lexical_cast
<
std
::
string
>
(
getRelative
())).
c_str
());
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_atol "
+
boost
::
lexical_cast
<
std
::
string
>
(
getTolerance
())).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_max_it "
+
boost
::
lexical_cast
<
std
::
string
>
(
getMaxIterations
())).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_rtol "
+
boost
::
lexical_cast
<
std
::
string
>
(
getRelative
())).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_atol "
+
boost
::
lexical_cast
<
std
::
string
>
(
getTolerance
())).
c_str
());
if
(
getInfo
()
>=
20
)
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_monitor_true_residual"
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_monitor_true_residual"
).
c_str
());
else
if
(
getInfo
()
>=
10
)
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_monitor"
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_monitor"
).
c_str
());
}
if
(
!
matSolverPackage
)
{
Parameters
::
get
(
name
+
"->use zero start vector"
,
zeroStartVector
);
...
...
AMDiS/src/solver/PetscSolver.h
View file @
24b520f6
...
...
@@ -58,7 +58,7 @@ namespace AMDiS {
virtual
void
init
(
PC
pc
,
const
SolverMatrix
<
Matrix
<
DOFMatrix
*>
>&
A
,
const
MatrixType
&
fullMatrix
)
{
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
prefix
+
"pc_type "
+
name
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
prefix
+
"pc_type "
+
name
).
c_str
());
PCSetFromOptions
(
pc
);
}
...
...
AMDiS/src/solver/PetscSolver.hh
View file @
24b520f6
...
...
@@ -47,30 +47,30 @@ namespace AMDiS {
if
(
params
.
matSolverPackage
[
kspSolver
])
{
// direct solvers
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_type preonly"
).
c_str
());
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"pc_type lu"
).
c_str
());
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"pc_factor_mat_solver_package "
+
(
kspSolver
!=
"direct"
?
kspSolver
:
"umfpack"
)).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_type preonly"
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"pc_type lu"
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"pc_factor_mat_solver_package "
+
(
kspSolver
!=
"direct"
?
kspSolver
:
"umfpack"
)).
c_str
());
oem
.
setMaxIterations
(
1
);
zeroStartVector
=
true
;
matSolverPackage
=
true
;
}
else
if
(
!
params
.
emptyParam
[
kspSolver
])
{
// other solvers
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_type "
+
kspSolver
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_type "
+
kspSolver
).
c_str
());
}
// set the preconditioner
setPrecon
();
if
(
oem
.
getInfo
()
>=
20
)
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_monitor_true_residual"
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_monitor_true_residual"
).
c_str
());
else
if
(
oem
.
getInfo
()
>=
10
)
P
etsc
O
ptions
I
nsert
S
tring
((
"-"
+
kspPrefix
+
"ksp_monitor"
).
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
((
"-"
+
kspPrefix
+
"ksp_monitor"
).
c_str
());
// command line string
std
::
string
kspString
=
""
;
Parameters
::
get
(
oem
.
getName
()
+
"->ksp"
,
kspString
);
if
(
kspString
!=
""
)
P
etsc
O
ptions
I
nsert
S
tring
(
kspString
.
c_str
());
p
etsc
_o
ptions
_i
nsert
_s
tring
(
kspString
.
c_str
());
}
...
...
AMDiS/src/solver/PetscTypes.h
View file @
24b520f6
...
...
@@ -31,6 +31,7 @@
#include
<petsc.h>
#include
<petscmat.h>
#include
<petscvec.h>
#include
<options.h>
namespace
AMDiS
{
...
...
@@ -143,6 +144,17 @@ namespace AMDiS {
template
<
typename
Mapper
>
void
operator
>>
(
const
PetscVectorNested
&
dest
,
VecMap
<
SystemVector
,
Mapper
>&
rhs
);
PetscErrorCode
petsc_options_insert_string
(
const
char
in_str
[])
{
#if (PETSC_VERSION_MINOR >= 7)
return
PetscOptionsInsertString
(
NULL
,
in_str
);
#else
return
PetscOptionsInsertString
(
in_str
);
#endif
}
}
// end namespace AMDiS
#include
"solver/PetscTypes.hh"
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment