Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dune-mmdg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hörl, Maximilian
dune-mmdg
Commits
d74c68d2
Commit
d74c68d2
authored
Jan 18, 2020
by
Hörl, Maximilian
Browse files
Options
Downloads
Patches
Plain Diff
transfer output to separate method, add check hasExactSolution() in dg.hh
parent
a0c1abd6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/mmdg/dg.hh
+57
-44
57 additions, 44 deletions
dune/mmdg/dg.hh
with
57 additions
and
44 deletions
dune/mmdg/dg.hh
+
57
−
44
View file @
d74c68d2
...
@@ -20,6 +20,9 @@ public:
...
@@ -20,6 +20,9 @@ public:
static
constexpr
int
dim
=
GridView
::
dimension
;
static
constexpr
int
dim
=
GridView
::
dimension
;
using
Matrix
=
Dune
::
DynamicMatrix
<
Scalar
>
;
//NOTE: what is an appropriate sparse matrix type? -> BCRS
using
Matrix
=
Dune
::
DynamicMatrix
<
Scalar
>
;
//NOTE: what is an appropriate sparse matrix type? -> BCRS
using
Vector
=
Dune
::
DynamicVector
<
Scalar
>
;
using
Vector
=
Dune
::
DynamicVector
<
Scalar
>
;
using
VTKFunction
=
Dune
::
VTKFunction
<
GridView
>
;
using
P1Function
=
Dune
::
NonconformingP1VTKFunction
<
GridView
,
Dune
::
DynamicVector
<
double
>>
;
//constructor
//constructor
DG
(
const
GridView
&
gridView
,
const
Mapper
&
mapper
,
DG
(
const
GridView
&
gridView
,
const
Mapper
&
mapper
,
...
@@ -40,50 +43,8 @@ public:
...
@@ -40,50 +43,8 @@ public:
//NOTE: what would be an appropiate solver here?
//NOTE: what would be an appropiate solver here?
A
.
solve
(
d
,
b
);
A
.
solve
(
d
,
b
);
//storage for pressure data, for each element we store the
//write solution to a vtk file
//pressure at the corners of the element, the VTKFunction will
writeVTKoutput
();
//create the output using a linear interpolation for each element
Dune
::
DynamicVector
<
Scalar
>
pressure
(
dof
,
0.0
);
Dune
::
DynamicVector
<
double
>
exactPressure
(
dof
,
0.0
);
for
(
const
auto
&
elem
:
elements
(
gridView_
))
{
const
int
elemIdxSLE
=
(
dim
+
1
)
*
mapper_
.
index
(
elem
);
const
auto
&
geo
=
elem
.
geometry
();
for
(
int
k
=
0
;
k
<
geo
.
corners
();
k
++
)
{
exactPressure
[
elemIdxSLE
+
k
]
=
problem_
.
exactSolution
(
geo
.
corner
(
k
));
//contribution of the basis function
// phi_elem,0 (x) = indicator(elem);
//at the kth corner of elem
pressure
[
elemIdxSLE
+
k
]
=
d
[
elemIdxSLE
];
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
{
//contribution of the basis function
// phi_elem,i (x) = x[i]*indicator(elem);
//at the kth corner of elem
pressure
[
elemIdxSLE
+
k
]
+=
d
[
elemIdxSLE
+
i
+
1
]
*
geo
.
corner
(
k
)[
i
];
}
}
}
//create output directory if necessary
mkdir
(
"data"
,
S_IRWXU
|
S_IRWXG
|
S_IROTH
|
S_IXOTH
);
Dune
::
VTKWriter
<
GridView
>
vtkWriter
(
gridView_
,
Dune
::
VTK
::
nonconforming
);
using
VTKFunction
=
Dune
::
VTKFunction
<
GridView
>
;
using
P1Function
=
Dune
::
NonconformingP1VTKFunction
<
GridView
,
Dune
::
DynamicVector
<
double
>>
;
vtkWriter
.
addVertexData
(
std
::
shared_ptr
<
const
VTKFunction
>
(
new
P1Function
(
gridView_
,
pressure
,
"pressure"
)));
vtkWriter
.
addVertexData
(
std
::
shared_ptr
<
const
VTKFunction
>
(
new
P1Function
(
gridView_
,
exactPressure
,
"exactPressure"
)));
vtkWriter
.
pwrite
(
"pressureData"
,
""
,
"data"
);
}
}
const
GridView
&
gridView_
;
const
GridView
&
gridView_
;
...
@@ -381,6 +342,58 @@ private:
...
@@ -381,6 +342,58 @@ private:
std
::
cout
<<
i
<<
", "
<<
j
<<
std
::
endl
;
std
::
cout
<<
i
<<
", "
<<
j
<<
std
::
endl
;
}
}
//writes the solution to a vtk file
void
writeVTKoutput
()
const
{
//storage for pressure data, for each element we store the
//pressure at the corners of the element, the VTKFunction will
//create the output using a linear interpolation for each element
Dune
::
DynamicVector
<
Scalar
>
pressure
(
dof
,
0.0
);
Dune
::
DynamicVector
<
Scalar
>
exactPressure
(
dof
,
0.0
);
for
(
const
auto
&
elem
:
elements
(
gridView_
))
{
const
int
elemIdxSLE
=
(
dim
+
1
)
*
mapper_
.
index
(
elem
);
const
auto
&
geo
=
elem
.
geometry
();
for
(
int
k
=
0
;
k
<
geo
.
corners
();
k
++
)
{
if
(
problem_
.
hasExactSolution
())
{
exactPressure
[
elemIdxSLE
+
k
]
=
problem_
.
exactSolution
(
geo
.
corner
(
k
));
}
//contribution of the basis function
// phi_elem,0 (x) = indicator(elem);
//at the kth corner of elem
pressure
[
elemIdxSLE
+
k
]
=
d
[
elemIdxSLE
];
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
{
//contribution of the basis function
// phi_elem,i (x) = x[i]*indicator(elem);
//at the kth corner of elem
pressure
[
elemIdxSLE
+
k
]
+=
d
[
elemIdxSLE
+
i
+
1
]
*
geo
.
corner
(
k
)[
i
];
}
}
}
//create output directory if necessary
mkdir
(
"data"
,
S_IRWXU
|
S_IRWXG
|
S_IROTH
|
S_IXOTH
);
Dune
::
VTKWriter
<
GridView
>
vtkWriter
(
gridView_
,
Dune
::
VTK
::
nonconforming
);
vtkWriter
.
addVertexData
(
std
::
shared_ptr
<
const
VTKFunction
>
(
new
P1Function
(
gridView_
,
pressure
,
"pressure"
)));
if
(
problem_
.
hasExactSolution
())
{
vtkWriter
.
addVertexData
(
std
::
shared_ptr
<
const
VTKFunction
>
(
new
P1Function
(
gridView_
,
exactPressure
,
"exactPressure"
)));
}
vtkWriter
.
pwrite
(
"pressureData"
,
""
,
"data"
);
}
Matrix
A
;
//stiffness matrix
Matrix
A
;
//stiffness matrix
Vector
b
;
//load vector
Vector
b
;
//load vector
...
...
...
...
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
sign in
to comment