Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis
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
Container registry
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iwr
amdis
Commits
0b697d70
Commit
0b697d70
authored
11 years ago
by
Sebastian Aland
Browse files
Options
Downloads
Patches
Plain Diff
PetscSolverCahnHilliard can now handle Dirichlet BC for phi
parent
0ab547c6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AMDiS/src/parallel/PetscSolverCahnHilliard.cc
+23
-4
23 additions, 4 deletions
AMDiS/src/parallel/PetscSolverCahnHilliard.cc
AMDiS/src/parallel/PetscSolverCahnHilliard.h
+2
-2
2 additions, 2 deletions
AMDiS/src/parallel/PetscSolverCahnHilliard.h
with
25 additions
and
6 deletions
AMDiS/src/parallel/PetscSolverCahnHilliard.cc
+
23
−
4
View file @
0b697d70
...
...
@@ -56,7 +56,7 @@ namespace AMDiS { namespace Parallel {
KSPSolve
(
data
->
kspLaplace
,
x1
,
y2
);
// (M+eps*sqrt(delta))*y2 = x1
MatMult
(
data
->
matM
,
y2
,
x1
);
// x1 := M*y2
KSPSolve
(
data
->
kspLaplace
,
x1
,
x2
);
// (M+eps*sqrt(delta))*x2 = x1
KSPSolve
(
data
->
kspLaplace
2
,
x1
,
x2
);
// (M+eps*sqrt(delta))*x2 = x1
double
factor
=
(
*
data
->
eps
)
/
sqrt
(
*
data
->
delta
);
VecCopy
(
x2
,
x1
);
// x1 := x2
VecAXPBYPCZ
(
x1
,
1.0
,
factor
,
-
factor
,
y1
,
y2
);
// x1 = 1*y1 + factor*y2 - factor*x1
...
...
@@ -144,6 +144,8 @@ namespace AMDiS { namespace Parallel {
DOFMatrix
deltaKMatrix
(
feSpace
,
feSpace
);
Operator
laplaceOp2
(
feSpace
,
feSpace
);
DOFMatrix
massMatrix2
(
feSpace
,
feSpace
);
if
(
phase
)
{
VecAtQP_ZOT
zot
(
phase
,
NULL
);
massOp
.
addTerm
(
&
zot
);
...
...
@@ -156,6 +158,10 @@ namespace AMDiS { namespace Parallel {
massMatrixSolver
=
createSubSolver
(
0
,
"mass_"
);
massMatrixSolver
->
fillPetscMatrix
(
&
massMatrix
);
massMatrix2
.
assembleOperator
(
massOp
);
massMatrixSolver2
=
createSubSolver
(
0
,
"laplace_"
);
massMatrixSolver2
->
fillPetscMatrix
(
&
massMatrix2
);
// === matrix (M + eps*sqrt(delta)*K) ===
laplaceMatrix
.
assembleOperator
(
laplaceOp
);
laplaceMatrixSolver
=
createSubSolver
(
0
,
"laplace_"
);
...
...
@@ -180,6 +186,10 @@ namespace AMDiS { namespace Parallel {
massMatrixSolver
=
createSubSolver
(
0
,
"mass_"
);
massMatrixSolver
->
fillPetscMatrix
(
&
massMatrix
);
massMatrix2
.
assembleOperator
(
massOp
);
massMatrixSolver2
=
createSubSolver
(
0
,
"laplace_"
);
massMatrixSolver2
->
fillPetscMatrix
(
&
massMatrix2
);
// === matrix (M + eps*sqrt(delta)*K) ===
laplaceMatrix
.
assembleOperator
(
laplaceOp
);
laplaceMatrixSolver
=
createSubSolver
(
0
,
"laplace_"
);
...
...
@@ -190,8 +200,10 @@ namespace AMDiS { namespace Parallel {
deltaKMatrixSolver
=
createSubSolver
(
0
,
"laplace2_"
);
deltaKMatrixSolver
->
fillPetscMatrix
(
&
deltaKMatrix
);
}
Mat
matK0MalMinusEps2
;
MatNestGetSubMat
(
mat
[
0
][
0
],
0
,
1
,
&
(
matK0MalMinusEps2
));
MatAXPY
(
massMatrixSolver2
->
getMatInterior
(),
-
sqrt
(
*
delta
)
/
(
*
eps
),
matK0MalMinusEps2
,
DIFFERENT_NONZERO_PATTERN
);
// === Setup solver ===
...
...
@@ -199,6 +211,7 @@ namespace AMDiS { namespace Parallel {
matShellContext
.
kspLaplace
=
laplaceMatrixSolver
->
getSolver
();
matShellContext
.
matM
=
massMatrixSolver
->
getMatInterior
();
matShellContext
.
matMinusDeltaK
=
deltaKMatrixSolver
->
getMatInterior
();
matShellContext
.
kspLaplace2
=
massMatrixSolver2
->
getSolver
();
matShellContext
.
eps
=
eps
;
matShellContext
.
delta
=
delta
;
...
...
@@ -213,6 +226,8 @@ namespace AMDiS { namespace Parallel {
// }
petsc_helper
::
setSolver
(
matShellContext
.
kspLaplace
,
"laplace_"
,
KSPRICHARDSON
,
PCHYPRE
,
0.0
,
1e-14
,
2
);
petsc_helper
::
setSolver
(
matShellContext
.
kspLaplace2
,
"laplace_"
,
KSPRICHARDSON
,
PCHYPRE
,
0.0
,
1e-14
,
2
);
// petsc_helper::setSolver(matShellContext.kspLaplace, "laplace_", KSPRICHARDSON, PCLU, 0.0, 1e-14, 1);
// {
// PC pc;
...
...
@@ -250,15 +265,19 @@ namespace AMDiS { namespace Parallel {
massMatrixSolver
->
destroyMatrixData
();
laplaceMatrixSolver
->
destroyMatrixData
();
deltaKMatrixSolver
->
destroyMatrixData
();
massMatrixSolver2
->
destroyMatrixData
();
massMatrixSolver
->
destroyVectorData
();
laplaceMatrixSolver
->
destroyVectorData
();
deltaKMatrixSolver
->
destroyVectorData
();
massMatrixSolver2
->
destroyVectorData
();
delete
massMatrixSolver
;
massMatrixSolver
=
NULL
;
delete
massMatrixSolver2
;
massMatrixSolver2
=
NULL
;
delete
laplaceMatrixSolver
;
laplaceMatrixSolver
=
NULL
;
...
...
This diff is collapsed.
Click to expand it.
AMDiS/src/parallel/PetscSolverCahnHilliard.h
+
2
−
2
View file @
0b697d70
...
...
@@ -32,7 +32,7 @@ namespace AMDiS { namespace Parallel {
using
namespace
std
;
struct
CahnHilliardData
{
KSP
kspMass
,
kspLaplace
;
KSP
kspMass
,
kspLaplace
,
kspLaplace2
;
Mat
matM
,
matMinusDeltaK
;
double
*
eps
,
*
delta
;
MPI
::
Intracomm
*
mpiCommGlobal
;
...
...
@@ -79,7 +79,7 @@ namespace AMDiS { namespace Parallel {
private
:
int
pressureComponent
;
PetscSolver
*
massMatrixSolver
,
*
laplaceMatrixSolver
,
*
deltaKMatrixSolver
;
PetscSolver
*
massMatrixSolver
,
*
massMatrixSolver2
,
*
laplaceMatrixSolver
,
*
deltaKMatrixSolver
;
CahnHilliardData
matShellContext
;
...
...
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