Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-tectonic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
agnumpde
dune-tectonic
Commits
d63d0b07
Commit
d63d0b07
authored
11 years ago
by
Elias Pipping
Committed by
Elias Pipping
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Algorit] Add damping to EulerPair
parent
e2b20f38
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/timestepping/eulerpair.cc
+45
-16
45 additions, 16 deletions
src/timestepping/eulerpair.cc
src/timestepping/eulerpair.hh
+2
-2
2 additions, 2 deletions
src/timestepping/eulerpair.hh
with
47 additions
and
18 deletions
src/timestepping/eulerpair.cc
+
45
−
16
View file @
d63d0b07
template
<
class
VectorType
,
class
MatrixType
,
class
FunctionType
,
int
dim
>
template
<
class
VectorType
,
class
MatrixType
,
class
FunctionType
,
int
dim
>
EulerPair
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>::
EulerPair
(
EulerPair
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>::
EulerPair
(
MatrixType
const
&
_A
,
MatrixType
const
&
_
B
,
VectorType
const
&
_u_initial
,
MatrixType
const
&
_A
,
MatrixType
const
&
_
M
,
VectorType
const
&
_u_initial
,
VectorType
const
&
_v_initial
,
VectorType
const
&
_v_initial
,
Dune
::
BitSetVector
<
dim
>
const
&
_dirichletNodes
,
Dune
::
BitSetVector
<
dim
>
const
&
_dirichletNodes
,
FunctionType
const
&
_dirichletFunction
)
FunctionType
const
&
_dirichletFunction
)
:
A
(
_A
),
:
A
(
_A
),
B
(
_
B
),
M
(
_
M
),
u
(
_u_initial
),
u
(
_u_initial
),
v
(
_v_initial
),
v
(
_v_initial
),
dirichletNodes
(
_dirichletNodes
),
dirichletNodes
(
_dirichletNodes
),
...
@@ -21,26 +20,56 @@ void EulerPair<VectorType, MatrixType, FunctionType, dim>::nextTimeStep() {
...
@@ -21,26 +20,56 @@ void EulerPair<VectorType, MatrixType, FunctionType, dim>::nextTimeStep() {
template
<
class
VectorType
,
class
MatrixType
,
class
FunctionType
,
int
dim
>
template
<
class
VectorType
,
class
MatrixType
,
class
FunctionType
,
int
dim
>
void
EulerPair
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>::
setup
(
void
EulerPair
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>::
setup
(
VectorType
const
&
ell
,
double
_tau
,
double
time
,
VectorType
&
problem_rhs
,
VectorType
const
&
ell
,
double
_tau
,
double
time
,
VectorType
&
problem_rhs
,
VectorType
&
problem_iterate
,
MatrixType
&
problem_A
B
)
{
VectorType
&
problem_iterate
,
MatrixType
&
problem_A
M
)
{
postProcessCalled
=
false
;
postProcessCalled
=
false
;
tau
=
_tau
;
tau
=
_tau
;
problem_rhs
=
ell
;
MatrixType
const
&
C
=
A
;
Arithmetic
::
addProduct
(
problem_rhs
,
1.0
/
tau
,
B
,
v_o
);
double
const
wc
=
0.0
;
Arithmetic
::
subtractProduct
(
problem_rhs
,
A
,
u_o
);
/* We start out with the formulation
M a + C v + A u = ell
Backward Euler means
a1 = 1.0/tau ( v1 - v0 )
u1 = tau v1 + u0
in summary, we get at time t=1
M [1.0/tau ( v1 - v0 )] + C v1
+ A [tau v1 + u0] = ell
or
1.0/tau M v1 + C v1 + tau A v1
= [1.0/tau M + C + tau A] v1
= ell + 1.0/tau M v0 - A u0
*/
// set up LHS (for fixed tau, we'd only really have to do this once)
{
Dune
::
MatrixIndexSet
indices
(
A
.
N
(),
A
.
M
());
indices
.
import
(
A
);
indices
.
import
(
M
);
indices
.
import
(
C
);
indices
.
exportIdx
(
problem_AM
);
}
problem_AM
=
0.0
;
Arithmetic
::
addProduct
(
problem_AM
,
(
1.0
-
wc
)
/
tau
,
M
);
Arithmetic
::
addProduct
(
problem_AM
,
wc
,
C
);
Arithmetic
::
addProduct
(
problem_AM
,
tau
,
A
);
// For fixed tau, we'd only really have to do this once
// set up RHS
Dune
::
MatrixIndexSet
indices
(
A
.
N
(),
A
.
M
());
{
indices
.
import
(
A
);
problem_rhs
=
ell
;
indices
.
import
(
B
);
Arithmetic
::
addProduct
(
problem_rhs
,
(
1.0
-
wc
)
/
tau
,
M
,
v_o
);
indices
.
exportIdx
(
problem_AB
);
Arithmetic
::
subtractProduct
(
problem_rhs
,
A
,
u_o
);
problem_AB
=
0.0
;
}
Arithmetic
::
addProduct
(
problem_AB
,
tau
,
A
);
Arithmetic
::
addProduct
(
problem_AB
,
1.0
/
tau
,
B
);
// v_o makes a good initial iterate; we could use anything, though
// v_o makes a good initial iterate; we could use anything, though
problem_iterate
=
v_o
;
problem_iterate
=
0.0
;
for
(
size_t
i
=
0
;
i
<
dirichletNodes
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
dirichletNodes
.
size
();
++
i
)
switch
(
dirichletNodes
[
i
].
count
())
{
switch
(
dirichletNodes
[
i
].
count
())
{
...
...
This diff is collapsed.
Click to expand it.
src/timestepping/eulerpair.hh
+
2
−
2
View file @
d63d0b07
...
@@ -5,7 +5,7 @@ template <class VectorType, class MatrixType, class FunctionType, int dim>
...
@@ -5,7 +5,7 @@ template <class VectorType, class MatrixType, class FunctionType, int dim>
class
EulerPair
class
EulerPair
:
public
TimeSteppingScheme
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>
{
:
public
TimeSteppingScheme
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>
{
public:
public:
EulerPair
(
MatrixType
const
&
_A
,
MatrixType
const
&
_
B
,
EulerPair
(
MatrixType
const
&
_A
,
MatrixType
const
&
_
M
,
VectorType
const
&
_u_initial
,
VectorType
const
&
_v_initial
,
VectorType
const
&
_u_initial
,
VectorType
const
&
_v_initial
,
Dune
::
BitSetVector
<
dim
>
const
&
_dirichletNodes
,
Dune
::
BitSetVector
<
dim
>
const
&
_dirichletNodes
,
FunctionType
const
&
_dirichletFunction
);
FunctionType
const
&
_dirichletFunction
);
...
@@ -19,7 +19,7 @@ class EulerPair
...
@@ -19,7 +19,7 @@ class EulerPair
private:
private:
MatrixType
const
&
A
;
MatrixType
const
&
A
;
MatrixType
const
&
B
;
MatrixType
const
&
M
;
VectorType
u
;
VectorType
u
;
VectorType
v
;
VectorType
v
;
Dune
::
BitSetVector
<
dim
>
const
&
dirichletNodes
;
Dune
::
BitSetVector
<
dim
>
const
&
dirichletNodes
;
...
...
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