Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-elasticity
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
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Ansgar Burchardt
dune-elasticity
Commits
a892646e
Commit
a892646e
authored
6 years ago
by
oliver.sander_at_tu-dresden.de
Browse files
Options
Downloads
Patches
Plain Diff
Some C++ modernization
parent
c2eb7c82
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/elasticity/assemblers/feassembler.hh
+18
-28
18 additions, 28 deletions
dune/elasticity/assemblers/feassembler.hh
with
18 additions
and
28 deletions
dune/elasticity/assemblers/feassembler.hh
+
18
−
28
View file @
a892646e
...
...
@@ -15,7 +15,6 @@ template <class Basis, class VectorType>
class
FEAssembler
{
typedef
typename
Basis
::
GridView
GridView
;
typedef
typename
GridView
::
template
Codim
<
0
>
::
template
Partition
<
Dune
::
Interior_Partition
>
::
Iterator
ElementIterator
;
//! Dimension of the grid.
enum
{
gridDim
=
GridView
::
dimension
};
...
...
@@ -72,19 +71,16 @@ getNeighborsPerVertex(Dune::MatrixIndexSet& nb) const
nb
.
resize
(
n
,
n
);
ElementIterator
it
=
basis_
.
getGridView
().
template
begin
<
0
,
Dune
::
Interior_Partition
>();
ElementIterator
endit
=
basis_
.
getGridView
().
template
end
<
0
,
Dune
::
Interior_Partition
>
();
for
(;
it
!=
endit
;
++
it
)
{
const
typename
Basis
::
LocalFiniteElement
&
lfe
=
basis_
.
getLocalFiniteElement
(
*
it
);
for
(
const
auto
&
element
:
elements
(
basis_
.
getGridView
(),
Dune
::
Partitions
::
interior
))
{
const
typename
Basis
::
LocalFiniteElement
&
lfe
=
basis_
.
getLocalFiniteElement
(
element
);
for
(
size_t
i
=
0
;
i
<
lfe
.
localBasis
().
size
();
i
++
)
{
for
(
size_t
j
=
0
;
j
<
lfe
.
localBasis
().
size
();
j
++
)
{
int
iIdx
=
basis_
.
index
(
*
i
t
,
i
);
int
jIdx
=
basis_
.
index
(
*
i
t
,
j
);
int
iIdx
=
basis_
.
index
(
elemen
t
,
i
);
int
jIdx
=
basis_
.
index
(
elemen
t
,
j
);
nb
.
add
(
iIdx
,
jIdx
);
...
...
@@ -116,33 +112,30 @@ assembleGradientAndHessian(const VectorType& sol,
gradient
.
resize
(
sol
.
size
());
gradient
=
0
;
ElementIterator
it
=
basis_
.
getGridView
().
template
begin
<
0
,
Dune
::
Interior_Partition
>();
ElementIterator
endit
=
basis_
.
getGridView
().
template
end
<
0
,
Dune
::
Interior_Partition
>
();
for
(
;
it
!=
endit
;
++
it
)
{
const
int
numOfBaseFct
=
basis_
.
getLocalFiniteElement
(
*
it
).
localBasis
().
size
();
for
(
const
auto
&
element
:
elements
(
basis_
.
getGridView
(),
Dune
::
Partitions
::
interior
))
{
const
int
numOfBaseFct
=
basis_
.
getLocalFiniteElement
(
element
).
localBasis
().
size
();
// Extract local solution
VectorType
localSolution
(
numOfBaseFct
);
VectorType
localPointLoads
(
numOfBaseFct
);
for
(
int
i
=
0
;
i
<
numOfBaseFct
;
i
++
)
localSolution
[
i
]
=
sol
[
basis_
.
index
(
*
i
t
,
i
)];
localSolution
[
i
]
=
sol
[
basis_
.
index
(
elemen
t
,
i
)];
VectorType
localGradient
(
numOfBaseFct
);
// setup local matrix and gradient
localStiffness_
->
assembleGradientAndHessian
(
*
i
t
,
basis_
.
getLocalFiniteElement
(
*
i
t
),
localSolution
,
localGradient
);
localStiffness_
->
assembleGradientAndHessian
(
elemen
t
,
basis_
.
getLocalFiniteElement
(
elemen
t
),
localSolution
,
localGradient
);
// Add element matrix to global stiffness matrix
for
(
int
i
=
0
;
i
<
numOfBaseFct
;
i
++
)
{
int
row
=
basis_
.
index
(
*
i
t
,
i
);
int
row
=
basis_
.
index
(
elemen
t
,
i
);
for
(
int
j
=
0
;
j
<
numOfBaseFct
;
j
++
)
{
int
col
=
basis_
.
index
(
*
i
t
,
j
);
int
col
=
basis_
.
index
(
elemen
t
,
j
);
hessian
[
row
][
col
]
+=
localStiffness_
->
A_
[
i
][
j
];
}
...
...
@@ -150,7 +143,7 @@ assembleGradientAndHessian(const VectorType& sol,
// Add local gradient to global gradient
for
(
int
i
=
0
;
i
<
numOfBaseFct
;
i
++
)
gradient
[
basis_
.
index
(
*
i
t
,
i
)]
+=
localGradient
[
i
];
gradient
[
basis_
.
index
(
elemen
t
,
i
)]
+=
localGradient
[
i
];
}
...
...
@@ -166,21 +159,18 @@ computeEnergy(const VectorType& sol) const
if
(
sol
.
size
()
!=
basis_
.
size
())
DUNE_THROW
(
Dune
::
Exception
,
"Solution vector doesn't match the basis!"
);
ElementIterator
it
=
basis_
.
getGridView
().
template
begin
<
0
,
Dune
::
Interior_Partition
>();
ElementIterator
endIt
=
basis_
.
getGridView
().
template
end
<
0
,
Dune
::
Interior_Partition
>();
// Loop over all elements
for
(
;
it
!=
endIt
;
++
it
)
{
for
(
const
auto
&
element
:
elements
(
basis_
.
getGridView
(),
Dune
::
Partitions
::
interior
))
{
// Number of degrees of freedom on this element
size_t
nDofs
=
basis_
.
getLocalFiniteElement
(
*
i
t
).
localBasis
().
size
();
size_t
nDofs
=
basis_
.
getLocalFiniteElement
(
elemen
t
).
localBasis
().
size
();
VectorType
localSolution
(
nDofs
);
for
(
size_t
i
=
0
;
i
<
nDofs
;
i
++
)
localSolution
[
i
]
=
sol
[
basis_
.
index
(
*
i
t
,
i
)];
localSolution
[
i
]
=
sol
[
basis_
.
index
(
elemen
t
,
i
)];
energy
+=
localStiffness_
->
energy
(
*
i
t
,
basis_
.
getLocalFiniteElement
(
*
i
t
),
localSolution
);
energy
+=
localStiffness_
->
energy
(
elemen
t
,
basis_
.
getLocalFiniteElement
(
elemen
t
),
localSolution
);
}
...
...
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