Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
agnumpde
dune-tnnmg
Commits
126a6e5a
Commit
126a6e5a
authored
Oct 19, 2020
by
oliver.sander_at_tu-dresden.de
Browse files
Make trescafrictionfunctionaltest build
parent
bad6d74c
Changes
2
Hide whitespace changes
Inline
Side-by-side
dune/tnnmg/functionals/trescafrictionfunctional.hh
View file @
126a6e5a
...
...
@@ -271,7 +271,7 @@ public:
{
auto
p
=
(
*
origin_
)[
row
];
p
.
axpy
(
v
,
(
*
direction_
)[
row
]);
result
+=
(
*
coefficients_
)[
row
]
*
tangentialPart
(
p
).
two_norm
();
result
+=
(
*
coefficients_
)[
row
]
[
0
]
*
tangentialPart
(
p
).
two_norm
();
}
return
result
;
...
...
dune/tnnmg/test/trescafrictionfunctionaltest.cc
View file @
126a6e5a
...
...
@@ -80,11 +80,10 @@ void testCoordinateRestrictionSubdifferential(const Functional& functional,
for
(
auto
v
:
testParameters
)
{
// Test the subdifferential of the restriction
Solvers
::
Interval
<
double
>
subDifferential
;
restriction
.
subDiff
(
v
,
subDifferential
);
Solvers
::
Interval
<
double
>
subDifferential
=
restriction
.
subDifferential
(
v
);
// Step size. Best value: square root of the machine precision
const
expr
double
eps
=
std
::
sqrt
(
std
::
numeric_limits
<
double
>::
epsilon
());
const
double
eps
=
std
::
sqrt
(
std
::
numeric_limits
<
double
>::
epsilon
());
auto
forwardFDGradient
=
(
restriction
(
v
+
eps
)
-
restriction
(
v
))
/
eps
;
auto
backwardFDGradient
=
(
restriction
(
v
)
-
restriction
(
v
-
eps
))
/
eps
;
...
...
@@ -112,36 +111,14 @@ int main(int argc, char* argv[]) try
// Create a Tresca friction functional on a grid with three vertices for testing
using
M
=
Matrix
<
FieldMatrix
<
double
,
2
,
2
>
>
;
using
Vector
=
BlockVector
<
FieldVector
<
double
,
2
>
>
;
// TODO: You would really want something like std::vector<double> for the weights W,
// But that would mean different levels of nestedness for the different containers,
// and it is not clear to me how coordinate restrictions would work in this situation.
using
W
=
BlockVector
<
FieldVector
<
double
,
1
>
>
;
//using W = std::vector<double>;
M
matrix
(
3
,
3
);
matrix
[
0
][
0
]
=
ScaledIdentityMatrix
<
double
,
2
>
(
1
);
matrix
[
0
][
1
]
=
0
;
matrix
[
0
][
2
]
=
0
;
// TODO: TrescaFrictionFunctional currently uses the coefficient vector type
// for the weights, too. That's of course inappropriate, because there is
// really only a scalar weight per Lagrange point.
// Let's hack around that by simply having the same number twice for each Lagrange point.
Vector
weights
=
{{
2.0
,
2.0
},
{
3.0
,
3.0
},
{
4.0
,
4.0
}};
matrix
[
1
][
0
]
=
0
;
matrix
[
1
][
1
]
=
ScaledIdentityMatrix
<
double
,
2
>
(
2
);
matrix
[
1
][
2
]
=
ScaledIdentityMatrix
<
double
,
2
>
(
-
1
);
matrix
[
2
][
0
]
=
0
;
matrix
[
2
][
1
]
=
ScaledIdentityMatrix
<
double
,
2
>
(
-
1
);
matrix
[
2
][
2
]
=
ScaledIdentityMatrix
<
double
,
2
>
(
1
);
Vector
linearPart
=
{{
1
,
2
},{
3
,
4
},
{
5
,
6
}};
Vector
lower
=
{{
-
1000000
,
-
1000000
},{
-
1000000
,
-
1000000
},
{
-
1000000
,
-
1000000
}};
Vector
upper
=
{{
1000000
,
1000000
},{
1000000
,
1000000
},
{
1000000
,
1000000
}};
W
weights
=
{
2.0
,
3.0
,
4.0
};
TrescaFrictionFunctional
<
M
,
Vector
,
Vector
,
Vector
,
W
>
functional
(
matrix
,
linearPart
,
lower
,
upper
,
weights
);
TrescaFrictionFunctional
<
Vector
>
functional
(
weights
);
// A set of local test points, i.e., values for a single vector block
std
::
vector
<
Vector
::
value_type
>
localTestPoints
=
{{
0
,
0
},
...
...
@@ -183,7 +160,7 @@ int main(int argc, char* argv[]) try
testCoordinateRestrictionSubdifferential
(
functional
,
testPoints
,
{
-
3
,
-
2
,
-
1
,
0
,
1
,
2
,
3
});
return
0
;
}
catch
(
Exception
e
)
}
catch
(
Exception
&
e
)
{
std
::
cout
<<
e
.
what
()
<<
std
::
endl
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment