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
03c4b3ea
Commit
03c4b3ea
authored
9 years ago
by
Sander, Oliver
Browse files
Options
Downloads
Patches
Plain Diff
Fully implement measuring against an reference function given in closed form
parent
df3265d8
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/compute-disc-error.cc
+27
-28
27 additions, 28 deletions
src/compute-disc-error.cc
with
27 additions
and
28 deletions
src/compute-disc-error.cc
+
27
−
28
View file @
03c4b3ea
...
@@ -51,10 +51,9 @@ void measureEOC(const GridView gridView,
...
@@ -51,10 +51,9 @@ void measureEOC(const GridView gridView,
typedef
Dune
::
Functions
::
PQkNodalBasis
<
GridView
,
order
>
FEBasis
;
typedef
Dune
::
Functions
::
PQkNodalBasis
<
GridView
,
order
>
FEBasis
;
FEBasis
feBasis
(
gridView
);
FEBasis
feBasis
(
gridView
);
FEBasis
referenceFEBasis
(
referenceGridView
);
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Read the data whose error is to be measured
, and the reference data
// Read the data whose error is to be measured
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Input data
// Input data
...
@@ -71,26 +70,15 @@ void measureEOC(const GridView gridView,
...
@@ -71,26 +70,15 @@ void measureEOC(const GridView gridView,
for
(
size_t
i
=
0
;
i
<
x
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
x
.
size
();
i
++
)
x
[
i
]
=
TargetSpace
(
embeddedX
[
i
]);
x
[
i
]
=
TargetSpace
(
embeddedX
[
i
]);
// Reference configuration
EmbeddedVectorType
embeddedReferenceX
(
referenceFEBasis
.
size
());
inFile
.
open
(
parameterSet
.
get
<
std
::
string
>
(
"referenceData"
),
std
::
ios_base
::
binary
);
if
(
not
inFile
)
DUNE_THROW
(
IOError
,
"File "
<<
parameterSet
.
get
<
std
::
string
>
(
"referenceData"
)
<<
" could not be opened."
);
GenericVector
::
readBinary
(
inFile
,
embeddedReferenceX
);
SolutionType
referenceX
(
embeddedReferenceX
.
size
());
for
(
size_t
i
=
0
;
i
<
referenceX
.
size
();
i
++
)
referenceX
[
i
]
=
TargetSpace
(
embeddedReferenceX
[
i
]);
//CosseratVTKWriter<typename GridView::Grid>::template write<FEBasis>(feBasis,x, "cosserat_infile_" + std::to_string(gridView.grid().maxLevel()+1));
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Measure the discretization error
// Measure the discretization error
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
#if 0
if
(
parameterSet
.
get
<
std
::
string
>
(
"discretizationErrorMode"
)
==
"analytical"
)
if
(
parameterSet
.
get
<
std
::
string
>
(
"discretizationErrorMode"
)
==
"analytical"
)
{
{
using
FufemFEBasis
=
DuneFunctionsBasis
<
FEBasis
>
;
FufemFEBasis
fufemFEBasis
(
feBasis
);
// Read reference solution and its derivative into a PythonFunction
// Read reference solution and its derivative into a PythonFunction
typedef
VirtualDifferentiableFunction
<
FieldVector
<
double
,
dim
>
,
TargetSpace
::
CoordinateType
>
FBase
;
typedef
VirtualDifferentiableFunction
<
FieldVector
<
double
,
dim
>
,
TargetSpace
::
CoordinateType
>
FBase
;
...
@@ -98,33 +86,44 @@ void measureEOC(const GridView gridView,
...
@@ -98,33 +86,44 @@ void measureEOC(const GridView gridView,
auto
referenceSolution
=
module
.
get
(
"fdf"
).
toC
<
std
::
shared_ptr
<
FBase
>>
();
auto
referenceSolution
=
module
.
get
(
"fdf"
).
toC
<
std
::
shared_ptr
<
FBase
>>
();
// The numerical solution, as a grid function
// The numerical solution, as a grid function
GFE::EmbeddedGlobalGFEFunction<FufemFEBasis, TargetSpace> numericalSolution(f
e
Basis, x);
GFE
::
EmbeddedGlobalGFEFunction
<
FufemFEBasis
,
TargetSpace
>
numericalSolution
(
f
ufemFE
Basis
,
x
);
// QuadratureRule for the integral of the L^2 error
// QuadratureRule for the integral of the L^2 error
QuadratureRuleKey
quadKey
(
dim
,
6
);
QuadratureRuleKey
quadKey
(
dim
,
6
);
// Compute the embedded L^2 error
// Compute the embedded L^2 error
double l2Error = DiscretizationError<
GridType::Leaf
GridView>::computeL2Error(&numericalSolution,
double
l2Error
=
DiscretizationError
<
GridView
>::
computeL2Error
(
&
numericalSolution
,
referenceSolution.get(),
referenceSolution
.
get
(),
quadKey);
quadKey
);
// Compute the embedded H^1 error
// Compute the embedded H^1 error
double h1Error = DiscretizationError<
GridType::Leaf
GridView>::computeH1HalfNormDifferenceSquared(grid
->leafGrid
View
()
,
double
h1Error
=
DiscretizationError
<
GridView
>::
computeH1HalfNormDifferenceSquared
(
gridView
,
&numericalSolution,
&
numericalSolution
,
referenceSolution.get(),
referenceSolution
.
get
(),
quadKey);
quadKey
);
std::cout << "elements: " << grid
->leafGrid
View
()
.size(0)
std
::
cout
<<
"elements: "
<<
gridView
.
size
(
0
)
<<
" "
<<
" "
<<
"L^2 error: "
<<
l2Error
<<
"L^2 error: "
<<
l2Error
<<
" "
;
<<
" "
;
std
::
cout
<<
"H^1 error: "
<<
std
::
sqrt
(
l2Error
*
l2Error
+
h1Error
)
<<
std
::
endl
;
std
::
cout
<<
"H^1 error: "
<<
std
::
sqrt
(
l2Error
*
l2Error
+
h1Error
)
<<
std
::
endl
;
}
}
#endif
if
(
parameterSet
.
get
<
std
::
string
>
(
"discretizationErrorMode"
)
==
"discrete"
)
if
(
parameterSet
.
get
<
std
::
string
>
(
"discretizationErrorMode"
)
==
"discrete"
)
{
{
std
::
cout
<<
"FOO"
<<
std
::
endl
;
FEBasis
referenceFEBasis
(
referenceGridView
);
// Reference configuration
EmbeddedVectorType
embeddedReferenceX
(
referenceFEBasis
.
size
());
inFile
.
open
(
parameterSet
.
get
<
std
::
string
>
(
"referenceData"
),
std
::
ios_base
::
binary
);
if
(
not
inFile
)
DUNE_THROW
(
IOError
,
"File "
<<
parameterSet
.
get
<
std
::
string
>
(
"referenceData"
)
<<
" could not be opened."
);
GenericVector
::
readBinary
(
inFile
,
embeddedReferenceX
);
SolutionType
referenceX
(
embeddedReferenceX
.
size
());
for
(
size_t
i
=
0
;
i
<
referenceX
.
size
();
i
++
)
referenceX
[
i
]
=
TargetSpace
(
embeddedReferenceX
[
i
]);
using
FufemFEBasis
=
DuneFunctionsBasis
<
FEBasis
>
;
using
FufemFEBasis
=
DuneFunctionsBasis
<
FEBasis
>
;
FufemFEBasis
fufemReferenceFEBasis
(
referenceFEBasis
);
FufemFEBasis
fufemReferenceFEBasis
(
referenceFEBasis
);
FufemFEBasis
fufemFEBasis
(
feBasis
);
FufemFEBasis
fufemFEBasis
(
feBasis
);
...
...
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