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
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
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
podlesny
dune-tectonic
Commits
c6387cb6
Commit
c6387cb6
authored
12 years ago
by
Elias Pipping
Committed by
Elias Pipping
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Move u_old_old_ptr from TimeSteppingScheme
parent
39ceb452
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/timestepping.cc
+26
-22
26 additions, 22 deletions
src/timestepping.cc
with
26 additions
and
22 deletions
src/timestepping.cc
+
26
−
22
View file @
c6387cb6
...
@@ -2,14 +2,13 @@ template <class VectorType, class MatrixType, class FunctionType, int dim>
...
@@ -2,14 +2,13 @@ template <class VectorType, class MatrixType, class FunctionType, int dim>
class
TimeSteppingScheme
{
class
TimeSteppingScheme
{
public:
public:
TimeSteppingScheme
(
VectorType
const
&
_ell
,
MatrixType
const
&
_A
,
TimeSteppingScheme
(
VectorType
const
&
_ell
,
MatrixType
const
&
_A
,
VectorType
const
&
_u_old
,
VectorType
const
*
_u_old_old_ptr
,
VectorType
const
&
_u_old
,
Dune
::
BitSetVector
<
dim
>
const
&
_dirichletNodes
,
Dune
::
BitSetVector
<
dim
>
const
&
_dirichletNodes
,
FunctionType
const
&
_dirichletFunction
,
double
_time
,
FunctionType
const
&
_dirichletFunction
,
double
_time
,
double
_tau
)
double
_tau
)
:
ell
(
_ell
),
:
ell
(
_ell
),
A
(
_A
),
A
(
_A
),
u_old
(
_u_old
),
u_old
(
_u_old
),
u_old_old_ptr
(
_u_old_old_ptr
),
dirichletNodes
(
_dirichletNodes
),
dirichletNodes
(
_dirichletNodes
),
dirichletFunction
(
_dirichletFunction
),
dirichletFunction
(
_dirichletFunction
),
time
(
_time
),
time
(
_time
),
...
@@ -30,7 +29,6 @@ class TimeSteppingScheme {
...
@@ -30,7 +29,6 @@ class TimeSteppingScheme {
VectorType
const
&
ell
;
VectorType
const
&
ell
;
MatrixType
const
&
A
;
MatrixType
const
&
A
;
VectorType
const
&
u_old
;
VectorType
const
&
u_old
;
VectorType
const
*
u_old_old_ptr
;
Dune
::
BitSetVector
<
dim
>
const
&
dirichletNodes
;
Dune
::
BitSetVector
<
dim
>
const
&
dirichletNodes
;
FunctionType
const
&
dirichletFunction
;
FunctionType
const
&
dirichletFunction
;
double
const
time
;
double
const
time
;
...
@@ -45,14 +43,14 @@ template <class VectorType, class MatrixType, class FunctionType, int dim>
...
@@ -45,14 +43,14 @@ template <class VectorType, class MatrixType, class FunctionType, int dim>
class
ImplicitEuler
class
ImplicitEuler
:
public
TimeSteppingScheme
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>
{
:
public
TimeSteppingScheme
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>
{
public:
public:
ImplicitEuler
(
VectorType
const
&
_ell
,
MatrixType
const
&
_A
,
ImplicitEuler
(
VectorType
const
&
_
u_old
,
VectorType
const
*
_u_old
_old_ptr
,
VectorType
const
&
_
ell
,
MatrixType
const
&
_A
,
VectorType
const
&
_u_old
,
Dune
::
BitSet
Vector
<
dim
>
const
&
_dirichletNodes
,
Vector
Type
const
*
_u_old_old_ptr
,
// FIXME: this should not be necessary
FunctionType
const
&
_dirichletFunction
,
double
_time
,
Dune
::
BitSetVector
<
dim
>
const
&
_dirichletNodes
,
double
_tau
)
FunctionType
const
&
_dirichletFunction
,
double
_time
,
double
_tau
)
:
TimeSteppingScheme
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>
(
:
TimeSteppingScheme
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>
(
_ell
,
_A
,
_u_old
,
_
u_old_old_ptr
,
_dirichletNodes
,
_ell
,
_A
,
_u_old
,
_
dirichletNodes
,
_dirichletFunction
,
_time
,
_tau
)
,
_dirichletFunction
,
_time
,
_tau
)
{}
u_old_old_ptr
(
_u_old_old_ptr
)
{}
void
virtual
setup
(
VectorType
&
problem_rhs
,
VectorType
&
problem_iterate
,
void
virtual
setup
(
VectorType
&
problem_rhs
,
VectorType
&
problem_iterate
,
MatrixType
&
problem_A
)
const
{
MatrixType
&
problem_A
)
const
{
...
@@ -64,8 +62,8 @@ class ImplicitEuler
...
@@ -64,8 +62,8 @@ class ImplicitEuler
// Treat as Delta u_n for now
// Treat as Delta u_n for now
problem_iterate
=
this
->
u_old
;
problem_iterate
=
this
->
u_old
;
if
(
this
->
u_old_old_ptr
)
if
(
u_old_old_ptr
)
problem_iterate
-=
*
this
->
u_old_old_ptr
;
problem_iterate
-=
*
u_old_old_ptr
;
for
(
size_t
i
=
0
;
i
<
this
->
dirichletNodes
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
this
->
dirichletNodes
.
size
();
++
i
)
if
(
this
->
dirichletNodes
[
i
].
count
()
==
dim
)
{
if
(
this
->
dirichletNodes
[
i
].
count
()
==
dim
)
{
...
@@ -91,6 +89,9 @@ class ImplicitEuler
...
@@ -91,6 +89,9 @@ class ImplicitEuler
VectorType
&
velocity
)
const
{
VectorType
&
velocity
)
const
{
velocity
=
problem_iterate
;
velocity
=
problem_iterate
;
}
}
private
:
VectorType
const
*
u_old_old_ptr
;
};
};
// two-Stage implicit algorithm
// two-Stage implicit algorithm
...
@@ -104,21 +105,21 @@ class ImplicitTwoStep
...
@@ -104,21 +105,21 @@ class ImplicitTwoStep
FunctionType
const
&
_dirichletFunction
,
double
_time
,
FunctionType
const
&
_dirichletFunction
,
double
_time
,
double
_tau
)
double
_tau
)
:
TimeSteppingScheme
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>
(
:
TimeSteppingScheme
<
VectorType
,
MatrixType
,
FunctionType
,
dim
>
(
_ell
,
_A
,
_u_old
,
_
u_old_old_ptr
,
_dirichletNodes
,
_ell
,
_A
,
_u_old
,
_
dirichletNodes
,
_dirichletFunction
,
_time
,
_tau
)
,
_dirichletFunction
,
_time
,
_tau
)
{}
u_old_old_ptr
(
_u_old_old_ptr
)
{}
void
virtual
setup
(
VectorType
&
problem_rhs
,
VectorType
&
problem_iterate
,
void
virtual
setup
(
VectorType
&
problem_rhs
,
VectorType
&
problem_iterate
,
MatrixType
&
problem_A
)
const
{
MatrixType
&
problem_A
)
const
{
problem_rhs
=
this
->
ell
;
problem_rhs
=
this
->
ell
;
this
->
A
.
usmv
(
-
4.0
/
3.0
,
this
->
u_old
,
problem_rhs
);
this
->
A
.
usmv
(
-
4.0
/
3.0
,
this
->
u_old
,
problem_rhs
);
this
->
A
.
usmv
(
+
1.0
/
3.0
,
*
this
->
u_old_old_ptr
,
problem_rhs
);
this
->
A
.
usmv
(
+
1.0
/
3.0
,
*
u_old_old_ptr
,
problem_rhs
);
problem_A
=
this
->
A
;
problem_A
=
this
->
A
;
problem_A
*=
2.0
/
3.0
*
this
->
tau
;
problem_A
*=
2.0
/
3.0
*
this
->
tau
;
// The finite difference makes a good start (treat it as such for now)
// The finite difference makes a good start (treat it as such for now)
problem_iterate
=
this
->
u_old
;
problem_iterate
=
this
->
u_old
;
problem_iterate
-=
*
this
->
u_old_old_ptr
;
problem_iterate
-=
*
u_old_old_ptr
;
for
(
size_t
i
=
0
;
i
<
this
->
dirichletNodes
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
this
->
dirichletNodes
.
size
();
++
i
)
if
(
this
->
dirichletNodes
[
i
].
count
()
==
dim
)
{
if
(
this
->
dirichletNodes
[
i
].
count
()
==
dim
)
{
...
@@ -126,13 +127,13 @@ class ImplicitTwoStep
...
@@ -126,13 +127,13 @@ class ImplicitTwoStep
this
->
dirichletFunction
.
evaluate
(
this
->
time
,
val
);
this
->
dirichletFunction
.
evaluate
(
this
->
time
,
val
);
problem_iterate
[
i
]
=
0
;
problem_iterate
[
i
]
=
0
;
problem_iterate
[
i
].
axpy
(
-
2
,
this
->
u_old
[
i
]);
problem_iterate
[
i
].
axpy
(
-
2
,
this
->
u_old
[
i
]);
problem_iterate
[
i
].
axpy
(
.5
,
(
*
this
->
u_old_old_ptr
)[
i
]);
problem_iterate
[
i
].
axpy
(
.5
,
(
*
u_old_old_ptr
)[
i
]);
problem_iterate
[
i
][
0
]
=
1.5
*
val
-
2
*
this
->
u_old
[
i
][
0
]
+
problem_iterate
[
i
][
0
]
=
.5
*
(
*
this
->
u_old_old_ptr
)[
i
][
0
];
1.5
*
val
-
2
*
this
->
u_old
[
i
][
0
]
+
.5
*
(
*
u_old_old_ptr
)[
i
][
0
];
}
else
if
(
this
->
dirichletNodes
[
i
][
1
])
}
else
if
(
this
->
dirichletNodes
[
i
][
1
])
// Y direction described
// Y direction described
problem_iterate
[
i
][
1
]
=
problem_iterate
[
i
][
1
]
=
-
2
*
this
->
u_old
[
i
][
1
]
+
.5
*
(
*
this
->
u_old_old_ptr
)[
i
][
1
];
-
2
*
this
->
u_old
[
i
][
1
]
+
.5
*
(
*
u_old_old_ptr
)[
i
][
1
];
// Now treat it as a velocity
// Now treat it as a velocity
problem_iterate
/=
this
->
tau
;
problem_iterate
/=
this
->
tau
;
}
}
...
@@ -142,7 +143,7 @@ class ImplicitTwoStep
...
@@ -142,7 +143,7 @@ class ImplicitTwoStep
solution
=
problem_iterate
;
solution
=
problem_iterate
;
solution
*=
this
->
tau
;
solution
*=
this
->
tau
;
solution
.
axpy
(
2
,
this
->
u_old
);
solution
.
axpy
(
2
,
this
->
u_old
);
solution
.
axpy
(
-
.5
,
*
this
->
u_old_old_ptr
);
solution
.
axpy
(
-
.5
,
*
u_old_old_ptr
);
solution
*=
2.0
/
3.0
;
solution
*=
2.0
/
3.0
;
// Check if we split correctly
// Check if we split correctly
...
@@ -151,7 +152,7 @@ class ImplicitTwoStep
...
@@ -151,7 +152,7 @@ class ImplicitTwoStep
test
*=
this
->
tau
;
test
*=
this
->
tau
;
test
.
axpy
(
-
1.5
,
solution
);
test
.
axpy
(
-
1.5
,
solution
);
test
.
axpy
(
+
2
,
this
->
u_old
);
test
.
axpy
(
+
2
,
this
->
u_old
);
test
.
axpy
(
-
.5
,
*
this
->
u_old_old_ptr
);
test
.
axpy
(
-
.5
,
*
u_old_old_ptr
);
assert
(
test
.
two_norm
()
<
1e-10
);
assert
(
test
.
two_norm
()
<
1e-10
);
}
}
}
}
...
@@ -160,4 +161,7 @@ class ImplicitTwoStep
...
@@ -160,4 +161,7 @@ class ImplicitTwoStep
VectorType
&
velocity
)
const
{
VectorType
&
velocity
)
const
{
velocity
=
problem_iterate
;
velocity
=
problem_iterate
;
}
}
private
:
VectorType
const
*
u_old_old_ptr
;
};
};
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