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
7efed67c
Commit
7efed67c
authored
12 years ago
by
Elias Pipping
Committed by
Elias Pipping
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
u4 -> u, s4 -> alpha, b -> rhs
parent
c5bfc824
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/one-body-sample.cc
+36
-34
36 additions, 34 deletions
src/one-body-sample.cc
with
36 additions
and
34 deletions
src/one-body-sample.cc
+
36
−
34
View file @
7efed67c
...
@@ -189,20 +189,20 @@ int main(int argc, char *argv[]) {
...
@@ -189,20 +189,20 @@ int main(int argc, char *argv[]) {
leafView
,
p1Basis
,
frictionalNodes
);
leafView
,
p1Basis
,
frictionalNodes
);
// {{{ Initialise vectors
// {{{ Initialise vectors
VectorType
u
4
(
finestSize
);
VectorType
u
(
finestSize
);
u
4
=
0.0
;
// Has to be zero!
u
=
0.0
;
// Has to be zero!
SingletonVectorType
s4
_old
(
finestSize
);
SingletonVectorType
alpha
_old
(
finestSize
);
s4
_old
=
parset
.
get
<
double
>
(
"boundary.friction.state.initial"
);
alpha
_old
=
parset
.
get
<
double
>
(
"boundary.friction.state.initial"
);
VectorType
u
4
_diff
(
finestSize
);
VectorType
u_diff
(
finestSize
);
u
4
_diff
=
0.0
;
// Has to be zero!
u_diff
=
0.0
;
// Has to be zero!
auto
s4
_new
=
Dune
::
make_shared
<
SingletonVectorType
>
(
finestSize
);
auto
alpha
_new
=
Dune
::
make_shared
<
SingletonVectorType
>
(
finestSize
);
*
s4
_new
=
s4
_old
;
*
alpha
_new
=
alpha
_old
;
SingletonVectorType
vonMisesStress
;
SingletonVectorType
vonMisesStress
;
VectorType
b4
;
VectorType
rhs
;
// }}}
// }}}
typedef
MyConvexProblem
<
MatrixType
,
VectorType
>
MyConvexProblemType
;
typedef
MyConvexProblem
<
MatrixType
,
VectorType
>
MyConvexProblemType
;
...
@@ -253,13 +253,13 @@ int main(int argc, char *argv[]) {
...
@@ -253,13 +253,13 @@ int main(int argc, char *argv[]) {
{
{
assemble_neumann
<
GridType
,
GridView
,
SmallVector
,
P1Basis
>
(
assemble_neumann
<
GridType
,
GridView
,
SmallVector
,
P1Basis
>
(
leafView
,
p1Basis
,
neumannNodes
,
b4
,
neumannFunction
,
time
);
leafView
,
p1Basis
,
neumannNodes
,
rhs
,
neumannFunction
,
time
);
stiffnessMatrix
.
mmv
(
u
4
,
b4
);
stiffnessMatrix
.
mmv
(
u
,
rhs
);
// Apply Dirichlet condition
// Apply Dirichlet condition
for
(
size_t
i
=
0
;
i
<
finestSize
;
++
i
)
for
(
size_t
i
=
0
;
i
<
finestSize
;
++
i
)
if
(
ignoreNodes
[
i
].
count
()
==
dim
)
{
if
(
ignoreNodes
[
i
].
count
()
==
dim
)
{
dirichletFunction
.
evaluate
(
time
,
u
4
_diff
[
i
][
0
]);
dirichletFunction
.
evaluate
(
time
,
u_diff
[
i
][
0
]);
u
4
_diff
[
i
][
0
]
/=
refinement_factor
;
u_diff
[
i
][
0
]
/=
refinement_factor
;
}
}
for
(
size_t
state_fpi
=
0
;
for
(
size_t
state_fpi
=
0
;
...
@@ -268,15 +268,16 @@ int main(int argc, char *argv[]) {
...
@@ -268,15 +268,16 @@ int main(int argc, char *argv[]) {
++
state_fpi
)
{
++
state_fpi
)
{
auto
myGlobalNonlinearity
=
auto
myGlobalNonlinearity
=
assemble_nonlinearity
<
MatrixType
,
VectorType
>
(
assemble_nonlinearity
<
MatrixType
,
VectorType
>
(
parset
.
sub
(
"boundary.friction"
),
nodalIntegrals
,
s4_new
,
h
);
parset
.
sub
(
"boundary.friction"
),
nodalIntegrals
,
alpha_new
,
h
);
MyConvexProblemType
const
myConvexProblem
(
stiffnessMatrix
,
MyConvexProblemType
const
myConvexProblem
(
stiffnessMatrix
,
*
myGlobalNonlinearity
,
b4
);
*
myGlobalNonlinearity
,
rhs
);
MyBlockProblemType
myBlockProblem
(
parset
,
myConvexProblem
);
MyBlockProblemType
myBlockProblem
(
parset
,
myConvexProblem
);
auto
multigridStep
=
mySolver
.
getSolver
();
auto
multigridStep
=
mySolver
.
getSolver
();
multigridStep
->
setProblem
(
u
4
_diff
,
myBlockProblem
);
multigridStep
->
setProblem
(
u_diff
,
myBlockProblem
);
VectorType
const
u
4
_diff_old
=
u
4
_diff
;
VectorType
const
u_diff_old
=
u_diff
;
LoopSolver
<
VectorType
>
overallSolver
(
LoopSolver
<
VectorType
>
overallSolver
(
multigridStep
,
parset
.
get
<
size_t
>
(
"solver.tnnmg.maxiterations"
),
multigridStep
,
parset
.
get
<
size_t
>
(
"solver.tnnmg.maxiterations"
),
solver_tolerance
,
&
energyNorm
,
verbosity
,
solver_tolerance
,
&
energyNorm
,
verbosity
,
...
@@ -285,7 +286,7 @@ int main(int argc, char *argv[]) {
...
@@ -285,7 +286,7 @@ int main(int argc, char *argv[]) {
for
(
size_t
i
=
0
;
i
<
frictionalNodes
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
frictionalNodes
.
size
();
++
i
)
{
if
(
frictionalNodes
[
i
][
0
])
{
if
(
frictionalNodes
[
i
][
0
])
{
double
const
unorm
=
u
4
_diff
[
i
].
two_norm
();
double
const
unorm
=
u_diff
[
i
].
two_norm
();
// // the (logarithmic) steady state corresponding to the
// // the (logarithmic) steady state corresponding to the
// // current velocity
// // current velocity
...
@@ -294,11 +295,12 @@ int main(int argc, char *argv[]) {
...
@@ -294,11 +295,12 @@ int main(int argc, char *argv[]) {
switch
(
parset
.
get
<
Config
::
state_model
>
(
switch
(
parset
.
get
<
Config
::
state_model
>
(
"boundary.friction.state.model"
))
{
"boundary.friction.state.model"
))
{
case
Config
::
Dieterich
:
case
Config
::
Dieterich
:
(
*
s4
_new
)[
i
]
=
(
*
alpha
_new
)[
i
]
=
state_update_dieterich
(
h
,
unorm
/
L
,
s4
_old
[
i
]);
state_update_dieterich
(
h
,
unorm
/
L
,
alpha
_old
[
i
]);
break
;
break
;
case
Config
::
Ruina
:
case
Config
::
Ruina
:
(
*
s4_new
)[
i
]
=
state_update_ruina
(
h
,
unorm
/
L
,
s4_old
[
i
]);
(
*
alpha_new
)[
i
]
=
state_update_ruina
(
h
,
unorm
/
L
,
alpha_old
[
i
]);
break
;
break
;
}
}
}
}
...
@@ -307,7 +309,7 @@ int main(int argc, char *argv[]) {
...
@@ -307,7 +309,7 @@ int main(int argc, char *argv[]) {
std
::
cout
<<
'.'
;
std
::
cout
<<
'.'
;
std
::
cout
.
flush
();
std
::
cout
.
flush
();
}
}
if
(
energyNorm
.
diff
(
u
4
_diff_old
,
u
4
_diff
)
<
if
(
energyNorm
.
diff
(
u_diff_old
,
u_diff
)
<
parset
.
get
<
double
>
(
"solver.tnnmg.fixed_point_tolerance"
))
parset
.
get
<
double
>
(
"solver.tnnmg.fixed_point_tolerance"
))
break
;
break
;
}
}
...
@@ -317,8 +319,8 @@ int main(int argc, char *argv[]) {
...
@@ -317,8 +319,8 @@ int main(int argc, char *argv[]) {
if
(
parset
.
get
<
bool
>
(
"writeEvolution"
))
{
if
(
parset
.
get
<
bool
>
(
"writeEvolution"
))
{
double
out
;
double
out
;
neumannFunction
.
evaluate
(
time
,
out
);
neumannFunction
.
evaluate
(
time
,
out
);
octave_writer
<<
(
*
s4
_new
)[
first_frictional_node
][
0
]
<<
" "
octave_writer
<<
(
*
alpha
_new
)[
first_frictional_node
][
0
]
<<
" "
<<
u
4
[
first_frictional_node
][
0
]
*
1e6
<<
" "
<<
out
<<
u
[
first_frictional_node
][
0
]
*
1e6
<<
" "
<<
out
<<
std
::
endl
;
<<
std
::
endl
;
}
}
...
@@ -326,9 +328,9 @@ int main(int argc, char *argv[]) {
...
@@ -326,9 +328,9 @@ int main(int argc, char *argv[]) {
// with the Ruina state evolution law.
// with the Ruina state evolution law.
// Jumps at 120 and 360 timesteps; v1 = .6 * v2;
// Jumps at 120 and 360 timesteps; v1 = .6 * v2;
if
(
parset
.
get
<
bool
>
(
"printVelocitySteppingComparison"
))
{
if
(
parset
.
get
<
bool
>
(
"printVelocitySteppingComparison"
))
{
double
const
v
=
u
4
_diff
[
first_frictional_node
].
two_norm
()
/
h
/
L
;
double
const
v
=
u_diff
[
first_frictional_node
].
two_norm
()
/
h
/
L
;
double
const
euler
=
(
*
s4
_new
)[
first_frictional_node
];
double
const
euler
=
(
*
alpha
_new
)[
first_frictional_node
];
double
direct
;
double
direct
;
if
(
run
<
120
)
{
if
(
run
<
120
)
{
direct
=
euler
;
direct
=
euler
;
...
@@ -350,28 +352,28 @@ int main(int argc, char *argv[]) {
...
@@ -350,28 +352,28 @@ int main(int argc, char *argv[]) {
// Record the coefficient of friction at a fixed node
// Record the coefficient of friction at a fixed node
if
(
parset
.
get
<
bool
>
(
"printCoefficient"
))
{
if
(
parset
.
get
<
bool
>
(
"printCoefficient"
))
{
double
const
V
=
u
4
_diff
[
first_frictional_node
].
two_norm
();
double
const
V
=
u_diff
[
first_frictional_node
].
two_norm
();
double
const
state
=
(
*
s4
_new
)[
first_frictional_node
];
double
const
state
=
(
*
alpha
_new
)[
first_frictional_node
];
coefficient_writer
<<
(
mu
+
a
*
std
::
log
(
V
*
eta
)
+
coefficient_writer
<<
(
mu
+
a
*
std
::
log
(
V
*
eta
)
+
b
*
(
state
-
std
::
log
(
eta
*
L
)))
<<
std
::
endl
;
b
*
(
state
-
std
::
log
(
eta
*
L
)))
<<
std
::
endl
;
}
}
}
}
u
4
+=
u
4
_diff
;
u
+=
u_diff
;
s4
_old
=
*
s4
_new
;
alpha
_old
=
*
alpha
_new
;
// Compute von Mises stress and write everything to a file
// Compute von Mises stress and write everything to a file
if
(
parset
.
get
<
bool
>
(
"writeVTK"
))
{
if
(
parset
.
get
<
bool
>
(
"writeVTK"
))
{
VonMisesStressAssembler
<
GridType
>
localStressAssembler
(
VonMisesStressAssembler
<
GridType
>
localStressAssembler
(
E
,
nu
,
E
,
nu
,
Dune
::
make_shared
<
BasisGridFunction
<
P1Basis
,
VectorType
>
const
>
(
Dune
::
make_shared
<
BasisGridFunction
<
P1Basis
,
VectorType
>
const
>
(
p1Basis
,
u
4
));
p1Basis
,
u
));
FunctionalAssembler
<
P0Basis
>
(
p0Basis
)
FunctionalAssembler
<
P0Basis
>
(
p0Basis
)
.
assemble
(
localStressAssembler
,
vonMisesStress
,
true
);
.
assemble
(
localStressAssembler
,
vonMisesStress
,
true
);
writeVtk
<
P1Basis
,
P0Basis
,
VectorType
,
SingletonVectorType
,
GridView
>
(
writeVtk
<
P1Basis
,
P0Basis
,
VectorType
,
SingletonVectorType
,
GridView
>
(
p1Basis
,
u
4
,
*
s4
_new
,
p0Basis
,
vonMisesStress
,
leafView
,
p1Basis
,
u
,
*
alpha
_new
,
p0Basis
,
vonMisesStress
,
leafView
,
(
boost
::
format
(
"obs%d"
)
%
run
).
str
());
(
boost
::
format
(
"obs%d"
)
%
run
).
str
());
}
}
}
}
...
@@ -381,10 +383,10 @@ int main(int argc, char *argv[]) {
...
@@ -381,10 +383,10 @@ int main(int argc, char *argv[]) {
if
(
parset
.
get
<
bool
>
(
"printFrictionalBoundary"
))
{
if
(
parset
.
get
<
bool
>
(
"printFrictionalBoundary"
))
{
// Print displacement on frictional boundary
// Print displacement on frictional boundary
boost
::
format
const
formatter
(
"u
4
[%02d] = %+3e"
);
boost
::
format
const
formatter
(
"u[%02d] = %+3e"
);
for
(
size_t
i
=
0
;
i
<
frictionalNodes
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
frictionalNodes
.
size
();
++
i
)
if
(
frictionalNodes
[
i
][
0
])
if
(
frictionalNodes
[
i
][
0
])
std
::
cout
<<
(
boost
::
format
(
formatter
)
%
i
%
u
4
[
i
])
<<
std
::
endl
;
std
::
cout
<<
(
boost
::
format
(
formatter
)
%
i
%
u
[
i
])
<<
std
::
endl
;
}
}
octave_writer
.
close
();
octave_writer
.
close
();
...
...
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