Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-gfe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Sander, Oliver
dune-gfe
Commits
8ad69069
Commit
8ad69069
authored
13 years ago
by
Oliver Sander
Committed by
sander@FU-BERLIN.DE
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
make the measuring code work
[[Imported from SVN: r7394]]
parent
9ffee22e
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
harmonicmaps.cc
+52
-28
52 additions, 28 deletions
harmonicmaps.cc
with
52 additions
and
28 deletions
harmonicmaps.cc
+
52
−
28
View file @
8ad69069
...
@@ -2,11 +2,13 @@
...
@@ -2,11 +2,13 @@
#include
<fenv.h>
#include
<fenv.h>
//#define LAPLACE_DEBUG
//#define HARMONIC_ENERGY_FD_GRADIENT
//#define HARMONIC_ENERGY_FD_GRADIENT
#define UNITVECTOR2
//
#define UNITVECTOR2
//
#define UNITVECTOR3
#define UNITVECTOR3
//#define ROTATION2
//#define ROTATION2
//#define ROTATION3
//#define REALTUPLE1
//#define REALTUPLE1
#include
<dune/common/bitsetvector.hh>
#include
<dune/common/bitsetvector.hh>
...
@@ -37,6 +39,9 @@ const int dim = 2;
...
@@ -37,6 +39,9 @@ const int dim = 2;
#ifdef ROTATION2
#ifdef ROTATION2
typedef
Rotation
<
2
,
double
>
TargetSpace
;
typedef
Rotation
<
2
,
double
>
TargetSpace
;
#endif
#endif
#ifdef ROTATION3
typedef
Rotation
<
3
,
double
>
TargetSpace
;
#endif
#ifdef UNITVECTOR2
#ifdef UNITVECTOR2
typedef
UnitVector
<
2
>
TargetSpace
;
typedef
UnitVector
<
2
>
TargetSpace
;
#endif
#endif
...
@@ -52,6 +57,19 @@ const int blocksize = TargetSpace::TangentVector::size;
...
@@ -52,6 +57,19 @@ const int blocksize = TargetSpace::TangentVector::size;
using
namespace
Dune
;
using
namespace
Dune
;
BlockVector
<
FieldVector
<
double
,
3
>
>
computeEmbeddedDifference
(
const
std
::
vector
<
TargetSpace
>&
a
,
const
std
::
vector
<
TargetSpace
>&
b
)
{
assert
(
a
.
size
()
==
b
.
size
());
BlockVector
<
FieldVector
<
double
,
3
>
>
difference
(
a
.
size
());
for
(
int
i
=
0
;
i
<
a
.
size
();
i
++
)
difference
[
i
]
=
a
[
i
].
globalCoordinates
()
-
b
[
i
].
globalCoordinates
();
return
difference
;
}
int
main
(
int
argc
,
char
*
argv
[])
try
int
main
(
int
argc
,
char
*
argv
[])
try
{
{
//feenableexcept(FE_INVALID)
;
//feenableexcept(FE_INVALID)
;
...
@@ -89,7 +107,7 @@ int main (int argc, char *argv[]) try
...
@@ -89,7 +107,7 @@ int main (int argc, char *argv[]) try
// ///////////////////////////////////////
// ///////////////////////////////////////
typedef
std
::
conditional
<
dim
==
1
,
OneDGrid
,
UGGrid
<
dim
>
>::
type
GridType
;
typedef
std
::
conditional
<
dim
==
1
,
OneDGrid
,
UGGrid
<
dim
>
>::
type
GridType
;
array
<
unsigned
int
,
dim
>
elements
;
array
<
unsigned
int
,
dim
>
elements
;
elements
.
fill
(
4
);
elements
.
fill
(
3
);
shared_ptr
<
GridType
>
gridPtr
=
StructuredGridFactory
<
GridType
>::
createSimplexGrid
(
FieldVector
<
double
,
dim
>
(
0
),
shared_ptr
<
GridType
>
gridPtr
=
StructuredGridFactory
<
GridType
>::
createSimplexGrid
(
FieldVector
<
double
,
dim
>
(
0
),
FieldVector
<
double
,
dim
>
(
1
),
FieldVector
<
double
,
dim
>
(
1
),
elements
);
elements
);
...
@@ -152,7 +170,7 @@ int main (int argc, char *argv[]) try
...
@@ -152,7 +170,7 @@ int main (int argc, char *argv[]) try
v
[
1
]
=
std
::
cos
(
pos
[
0
]
*
M_PI
);
v
[
1
]
=
std
::
cos
(
pos
[
0
]
*
M_PI
);
#endif
#endif
#if defined ROTATION2 || defined REALTUPLE1
#if defined ROTATION2 || defined REALTUPLE1
v
[
0
]
=
pos
[
0
]
*
M_PI
;
v
[
0
]
=
pos
[
0
]
/
*M_PI
*/
;
#endif
#endif
}
else
{
}
else
{
#ifdef UNITVECTOR2
#ifdef UNITVECTOR2
...
@@ -221,6 +239,10 @@ int main (int argc, char *argv[]) try
...
@@ -221,6 +239,10 @@ int main (int argc, char *argv[]) try
x
=
solver
.
getSol
();
x
=
solver
.
getSol
();
// //////////////////////////////
// Output result
// //////////////////////////////
BlockVector
<
FieldVector
<
double
,
3
>
>
xEmbedded
(
x
.
size
());
BlockVector
<
FieldVector
<
double
,
3
>
>
xEmbedded
(
x
.
size
());
for
(
int
i
=
0
;
i
<
x
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
x
.
size
();
i
++
)
{
#ifdef UNITVECTOR2
#ifdef UNITVECTOR2
...
@@ -250,28 +272,28 @@ int main (int argc, char *argv[]) try
...
@@ -250,28 +272,28 @@ int main (int argc, char *argv[]) try
amiramesh
.
addVertexData
(
xEmbedded
,
grid
.
leafView
());
amiramesh
.
addVertexData
(
xEmbedded
,
grid
.
leafView
());
amiramesh
.
write
(
"resultGrid"
,
1
);
amiramesh
.
write
(
"resultGrid"
,
1
);
// //////////////////////////////
// Output result
// //////////////////////////////
#if 0
writeRod(x, resultPath + "rod3d.result");
#endif
exit
(
0
);
// //////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////
// Recompute and compare against exact solution
// Recompute and compare against exact solution
// //////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////
SolutionType
exactSolution
=
x
;
SolutionType
exactSolution
=
x
;
// //////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////
// Compute hessian of the rod functional at the exact solution
// Compute mass matrix and laplace matrix to emulate L2 and H1 norms
// for use of the energy norm it creates.
// //////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////
BCRSMatrix
<
FieldMatrix
<
double
,
blocksize
,
blocksize
>
>
hessian
;
typedef
P1NodalBasis
<
GridType
::
LeafGridView
,
double
>
FEBasis
;
assembler
.
assembleMatrix
(
exactSolution
,
hessian
);
FEBasis
basis
(
grid
.
leafView
());
OperatorAssembler
<
FEBasis
,
FEBasis
>
operatorAssembler
(
basis
,
basis
);
LaplaceAssembler
<
GridType
,
FEBasis
::
LocalFiniteElement
,
FEBasis
::
LocalFiniteElement
>
laplaceLocalAssembler
;
MassAssembler
<
GridType
,
FEBasis
::
LocalFiniteElement
,
FEBasis
::
LocalFiniteElement
>
massMatrixLocalAssembler
;
typedef
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
1
,
1
>
>
ScalarMatrixType
;
ScalarMatrixType
laplaceMatrix
,
massMatrix
;
operatorAssembler
.
assemble
(
laplaceLocalAssembler
,
laplaceMatrix
);
operatorAssembler
.
assemble
(
massMatrixLocalAssembler
,
massMatrix
);
double
error
=
std
::
numeric_limits
<
double
>::
max
();
double
error
=
std
::
numeric_limits
<
double
>::
max
();
...
@@ -282,11 +304,14 @@ int main (int argc, char *argv[]) try
...
@@ -282,11 +304,14 @@ int main (int argc, char *argv[]) try
std
::
ofstream
statisticsFile
((
resultPath
+
"trStatistics"
).
c_str
());
std
::
ofstream
statisticsFile
((
resultPath
+
"trStatistics"
).
c_str
());
// Compute error of the initial iterate
// Compute error of the initial iterate
typedef
BlockVector
<
FieldVector
<
double
,
blocksize
>
>
DifferenceType
;
typedef
BlockVector
<
FieldVector
<
double
,
3
>
>
DifferenceType
;
#warning computeGeodesicDifference outcommented
DifferenceType
difference
=
computeEmbeddedDifference
(
exactSolution
,
initialIterate
);
DifferenceType
geodesicDifference
=
DifferenceType
(
0
);
//computeGeodesicDifference(exactSolution, initialIterate);
double
oldError
=
std
::
sqrt
(
EnergyNorm
<
BCRSMatrix
<
FieldMatrix
<
double
,
blocksize
,
blocksize
>
>
,
BlockVector
<
FieldVector
<
double
,
blocksize
>
>
>::
normSquared
(
geodesicDifference
,
hessian
));
H1SemiNorm
<
BlockVector
<
TargetSpace
::
CoordinateType
>
>
h1Norm
(
laplaceMatrix
);
H1SemiNorm
<
BlockVector
<
TargetSpace
::
CoordinateType
>
>
l2Norm
(
massMatrix
);
//double oldError = std::sqrt(EnergyNorm<BCRSMatrix<FieldMatrix<double, blocksize, blocksize> >, BlockVector<FieldVector<double,blocksize> > >::normSquared(geodesicDifference, hessian));
double
oldError
=
h1Norm
(
difference
);
int
i
;
int
i
;
for
(
i
=
0
;
i
<
maxTrustRegionSteps
;
i
++
)
{
for
(
i
=
0
;
i
<
maxTrustRegionSteps
;
i
++
)
{
...
@@ -300,7 +325,7 @@ int main (int argc, char *argv[]) try
...
@@ -300,7 +325,7 @@ int main (int argc, char *argv[]) try
if
(
!
fp
)
if
(
!
fp
)
DUNE_THROW
(
IOError
,
"Couldn't open intermediate solution '"
<<
iSolFilename
<<
"'"
);
DUNE_THROW
(
IOError
,
"Couldn't open intermediate solution '"
<<
iSolFilename
<<
"'"
);
for
(
int
j
=
0
;
j
<
intermediateSolution
.
size
();
j
++
)
{
for
(
int
j
=
0
;
j
<
intermediateSolution
.
size
();
j
++
)
{
fread
(
&
intermediateSolution
[
j
],
sizeof
(
doubl
e
),
4
,
fp
);
fread
(
&
intermediateSolution
[
j
],
sizeof
(
TargetSpac
e
),
1
,
fp
);
}
}
fclose
(
fp
);
fclose
(
fp
);
...
@@ -309,11 +334,10 @@ int main (int argc, char *argv[]) try
...
@@ -309,11 +334,10 @@ int main (int argc, char *argv[]) try
// Compute error
// Compute error
// /////////////////////////////////////////////////////
// /////////////////////////////////////////////////////
#warning computeGeodesicDifference outcommented
difference
=
computeEmbeddedDifference
(
exactSolution
,
intermediateSolution
);
geodesicDifference
=
DifferenceType
(
0
);
//computeGeodesicDifference(exactSolution, intermediateSolution);
error
=
std
::
sqrt
(
EnergyNorm
<
BCRSMatrix
<
FieldMatrix
<
double
,
blocksize
,
blocksize
>
>
,
BlockVector
<
FieldVector
<
double
,
blocksize
>
>
>::
normSquared
(
geodesicDifference
,
hessian
));
//error = std::sqrt(EnergyNorm<BCRSMatrix<FieldMatrix<double, blocksize, blocksize> >, BlockVector<FieldVector<double,blocksize> > >::normSquared(geodesicDifference, hessian));
error
=
h1Norm
(
difference
);
double
convRate
=
error
/
oldError
;
double
convRate
=
error
/
oldError
;
...
...
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