Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-fu-tutorial
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
graeser
dune-fu-tutorial
Commits
6aba9157
Commit
6aba9157
authored
5 years ago
by
graeser
Browse files
Options
Downloads
Patches
Plain Diff
Proper boundary handling
parent
3a8242e7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/07-poisson-problem-functions.cc
+32
-18
32 additions, 18 deletions
src/07-poisson-problem-functions.cc
with
32 additions
and
18 deletions
src/07-poisson-problem-functions.cc
+
32
−
18
View file @
6aba9157
...
@@ -190,36 +190,50 @@ int main(int argc, char** argv)
...
@@ -190,36 +190,50 @@ int main(int argc, char** argv)
using
Basis
=
typename
Dune
::
Functions
::
LagrangeBasis
<
GridView
,
4
>
;
using
Basis
=
typename
Dune
::
Functions
::
LagrangeBasis
<
GridView
,
4
>
;
Basis
basis
(
gridView
);
Basis
basis
(
gridView
);
std
::
vector
<
bool
>
isBoundary
;
isBoundary
.
resize
(
basis
.
size
(),
false
);
computeBoundaryVertices
(
gridView
,
isBoundary
,
basis
);
assemblePoissonProblem
(
gridView
,
A
,
rhs
,
rhsFunction
,
basis
);
assemblePoissonProblem
(
gridView
,
A
,
rhs
,
rhsFunction
,
basis
);
x
.
resize
(
basis
.
size
(),
0
);
x
.
resize
(
basis
.
size
());
x
=
0
;
auto
dirichletFunction
=
[](
auto
x
)
{
auto
dirichletFunction
=
[](
auto
x
)
{
return
sin
(
x
[
0
]
*
2.0
*
M_PI
)
*
.1
;
return
sin
(
x
[
0
]
*
2.0
*
M_PI
)
*
.1
;
};
};
Dune
::
Functions
::
interpolate
(
basis
,
x
,
dirichletFunction
);
Dune
::
Functions
::
interpolate
(
basis
,
x
,
dirichletFunction
,
isBoundary
);
std
::
vector
<
bool
>
isBoundary
;
A
.
mmv
(
x
,
rhs
);
isBoundary
.
resize
(
basis
.
size
(),
false
);
for
(
std
::
size_t
row
=
0
;
row
<
A
.
N
();
row
++
)
{
computeBoundaryVertices
(
gridView
,
isBoundary
,
basis
);
if
(
isBoundary
[
row
])
{
rhs
[
row
]
=
x
[
row
];
for
(
std
::
size_t
i
=
0
;
i
<
rhs
.
size
();
++
i
)
// loop over nonzero matrix entries in current row
{
auto
columnIt
=
A
[
row
].
begin
();
if
(
isBoundary
[
i
])
auto
columnEndIt
=
A
[
row
].
end
();
{
for
(;
columnIt
!=
columnEndIt
;
++
columnIt
)
for
(
auto
&
entry
:
A
[
i
])
if
(
row
==
columnIt
.
index
())
entry
=
0
;
*
columnIt
=
1.0
;
A
[
i
][
i
]
=
1
;
else
rhs
[
i
]
=
x
[
i
];
*
columnIt
=
0.0
;
}
else
{
// loop over nonzero matrix entries in current row
auto
columnIt
=
A
[
row
].
begin
();
auto
columnEndIt
=
A
[
row
].
end
();
for
(;
columnIt
!=
columnEndIt
;
++
columnIt
)
if
(
isBoundary
[
columnIt
.
index
()])
*
columnIt
=
0
;
}
}
}
}
Dune
::
MatrixAdapter
<
Matrix
,
Vector
,
Vector
>
op
(
A
);
Dune
::
MatrixAdapter
<
Matrix
,
Vector
,
Vector
>
op
(
A
);
Dune
::
SeqILU0
<
Matrix
,
Vector
,
Vector
>
ilu0
(
A
,
1.0
);
Dune
::
SeqSSOR
<
Matrix
,
Vector
,
Vector
>
preconditioner
(
A
,
1
,
1.0
);
Dune
::
SeqSSOR
<
Matrix
,
Vector
,
Vector
>
preconditioner
(
A
,
1
,
1.0
);
// Dune::SeqILDL<Matrix,Vector,Vector> preconditioner(A,1.0);
Dune
::
CGSolver
<
Vector
>
cg
(
op
,
Dune
::
CGSolver
<
Vector
>
cg
(
op
,
preconditioner
,
// preconditione
preconditioner
,
// preconditione
1e-
4
,
// desired residual reduction factor
1e-
10
,
// desired residual reduction factor
200
,
// maximum number of iterations
200
,
// maximum number of iterations
2
);
// verbosity of the solver
2
);
// verbosity of the solver
...
@@ -236,7 +250,7 @@ int main(int argc, char** argv)
...
@@ -236,7 +250,7 @@ int main(int argc, char** argv)
vtkWriter
.
addVertexData
(
xFunction
,
Dune
::
VTK
::
FieldInfo
(
"solution"
,
Dune
::
VTK
::
FieldInfo
::
Type
::
scalar
,
1
));
vtkWriter
.
addVertexData
(
xFunction
,
Dune
::
VTK
::
FieldInfo
(
"solution"
,
Dune
::
VTK
::
FieldInfo
::
Type
::
scalar
,
1
));
vtkWriter
.
write
(
"07-solution"
);
vtkWriter
.
write
(
"07-solution"
);
}
{
}
{
Dune
::
SubsamplingVTKWriter
<
GridView
>
vtkWriter
(
gridView
,
4
);
Dune
::
SubsamplingVTKWriter
<
GridView
>
vtkWriter
(
gridView
,
Dune
::
refinementLevels
(
4
)
);
vtkWriter
.
addVertexData
(
xFunction
,
Dune
::
VTK
::
FieldInfo
(
"solution"
,
Dune
::
VTK
::
FieldInfo
::
Type
::
scalar
,
1
));
vtkWriter
.
addVertexData
(
xFunction
,
Dune
::
VTK
::
FieldInfo
(
"solution"
,
Dune
::
VTK
::
FieldInfo
::
Type
::
scalar
,
1
));
vtkWriter
.
write
(
"07-solution-subsampled"
);
vtkWriter
.
write
(
"07-solution-subsampled"
);
}
}
...
...
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