Skip to content
GitLab
Menu
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
f624d7ca
Commit
f624d7ca
authored
Jun 12, 2012
by
Thomas Witkowski
Browse files
Added nullspace support.
parent
705566b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/parallel/BddcMlSolver.cc
View file @
f624d7ca
...
...
@@ -323,7 +323,7 @@ namespace AMDiS {
int
use_defaults_int
=
1
;
int
parallel_division_int
=
1
;
int
use_arithmetic_int
=
1
;
int
use_arithmetic_int
=
0
;
int
use_adaptive_int
=
0
;
// MSG("call to \"bddcml_setup_preconditioner\" with the following arguments (each in one line):\n");
// MSG(" %d\n", matrixtype);
...
...
AMDiS/src/parallel/PetscSolver.cc
View file @
f624d7ca
...
...
@@ -27,14 +27,16 @@ namespace AMDiS {
coarseSpaceMap
(
NULL
),
mpiRank
(
-
1
),
kspPrefix
(
""
),
removeRhsNullSpace
(
false
)
removeRhsNullspace
(
false
),
hasConstantNullspace
(
false
)
{
string
kspStr
=
""
;
Parameters
::
get
(
"parallel->solver->petsc->ksp"
,
kspStr
);
if
(
kspStr
!=
""
)
PetscOptionsInsertString
(
kspStr
.
c_str
());
Parameters
::
get
(
"parallel->remove rhs null space"
,
removeRhsNullSpace
);
Parameters
::
get
(
"parallel->remove rhs null space"
,
removeRhsNullspace
);
Parameters
::
get
(
"parallel->has constant null space"
,
hasConstantNullspace
);
}
...
...
AMDiS/src/parallel/PetscSolver.h
View file @
f624d7ca
...
...
@@ -116,9 +116,9 @@ namespace AMDiS {
kspPrefix
=
s
;
}
void
setRemoveRhsNull
S
pace
(
bool
b
)
void
setRemoveRhsNull
s
pace
(
bool
b
)
{
removeRhsNull
S
pace
=
b
;
removeRhsNull
s
pace
=
b
;
}
/// Adds a new vector to the basis of the operator's nullspace.
...
...
@@ -253,7 +253,9 @@ namespace AMDiS {
/// If true, the constant null space is projected out of the RHS vector. It
/// depends on the specific PETSc solver if it considers this value.
bool
removeRhsNullSpace
;
bool
removeRhsNullspace
;
bool
hasConstantNullspace
;
};
...
...
AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
View file @
f624d7ca
...
...
@@ -363,19 +363,7 @@ namespace AMDiS {
// === Remove Dirichlet BC DOFs. ===
// removeDirichletBcDofs(vec);
// === Remove null space, if requested. ===
if
(
removeRhsNullSpace
)
{
TEST_EXIT_DBG
(
coarseSpaceMap
==
NULL
)(
"Not supported!
\n
"
);
MSG
(
"Remove constant null space from the RHS!
\n
"
);
MatNullSpace
sp
;
MatNullSpaceCreate
(
mpiCommGlobal
,
PETSC_TRUE
,
0
,
PETSC_NULL
,
&
sp
);
MatNullSpaceRemove
(
sp
,
rhsInterior
,
PETSC_NULL
);
MatNullSpaceDestroy
(
&
sp
);
}
}
...
...
@@ -397,35 +385,53 @@ namespace AMDiS {
VecAssemblyEnd
(
petscSolVec
);
}
MatNullSpace
matNullSpace
;
MatNullSpace
matNullspace
;
Vec
nullspaceBasis
;
if
(
nullspace
.
size
()
>
0
)
{
TEST_EXIT_DBG
(
nullspace
.
size
()
=
=
1
)(
"Not yet implemented!
\n
"
);
if
(
nullspace
.
size
()
>
0
||
hasConstantNullspace
)
{
TEST_EXIT_DBG
(
nullspace
.
size
()
<
=
1
)(
"Not yet implemented!
\n
"
);
VecDuplicate
(
petscSolVec
,
&
nullspaceBasis
);
if
(
nullspace
.
size
()
>
0
)
{
VecDuplicate
(
petscSolVec
,
&
nullspaceBasis
);
for
(
int
i
=
0
;
i
<
nComponents
;
i
++
)
setDofVector
(
nullspaceBasis
,
nullspace
[
0
]
->
getDOFVector
(
i
),
i
,
true
);
VecAssemblyBegin
(
nullspaceBasis
);
VecAssemblyEnd
(
nullspaceBasis
);
MatNullSpaceCreate
(
mpiCommGlobal
,
(
hasConstantNullspace
?
PETSC_TRUE
:
PETSC_FALSE
),
1
,
&
nullspaceBasis
,
&
matNullspace
);
for
(
int
i
=
0
;
i
<
nComponents
;
i
++
)
setDofVector
(
nullspaceBasis
,
nullspace
[
0
]
->
getDOFVector
(
i
),
i
,
true
);
MatMult
(
matIntInt
,
nullspaceBasis
,
petscSolVec
);
PetscReal
n
;
VecNorm
(
petscSolVec
,
NORM_2
,
&
n
);
MSG
(
"NORM IS: %e
\n
"
,
n
);
}
else
{
MatNullSpaceCreate
(
mpiCommGlobal
,
PETSC_TRUE
,
0
,
PETSC_NULL
,
&
matNullspace
);
}
VecAssemblyBegin
(
nullspaceBasis
);
VecAssemblyEnd
(
nullspaceBasis
);
KSPSetNullSpace
(
kspInterior
,
matNullspace
);
MatNullSpaceCreate
(
mpiCommGlobal
,
PETSC_FALSE
,
1
,
&
nullspaceBasis
,
&
matNullSpace
);
KSPSetNullSpace
(
kspInterior
,
matNullSpace
);
// === Remove null space, if requested. ===
MatMult
(
matIntInt
,
nullspaceBasis
,
petscSolVec
);
PetscReal
n
;
VecNorm
(
petscSolVec
,
NORM_2
,
&
n
);
MSG
(
"NORM IS: %e
\n
"
,
n
);
if
(
removeRhsNullspace
)
{
TEST_EXIT_DBG
(
coarseSpaceMap
==
NULL
)(
"Not supported!
\n
"
);
MatNullSpaceRemove
(
matNullspace
,
rhsInterior
,
PETSC_NULL
);
}
}
else
{
TEST_EXIT
(
removeRhsNullspace
==
false
)
(
"No nullspace provided that should be removed from rhs!
\n
"
);
}
// PETSc.
solve
(
rhsInterior
,
petscSolVec
);
if
(
nullspace
.
size
()
>
0
)
{
MatNullSpaceDestroy
(
&
matNull
S
pace
);
MatNullSpaceDestroy
(
&
matNull
s
pace
);
VecDestroy
(
&
nullspaceBasis
);
}
...
...
Write
Preview
Supports
Markdown
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