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
7618fbe0
Commit
7618fbe0
authored
15 years ago
by
Oliver Sander
Committed by
sander@PCPOOL.MI.FU-BERLIN.DE
15 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add methods to assemble the gradient and the Hesse matrix
[[Imported from SVN: r4030]]
parent
ec031b6b
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/geodesicfeassembler.hh
+90
-5
90 additions, 5 deletions
src/geodesicfeassembler.hh
with
90 additions
and
5 deletions
src/geodesicfeassembler.hh
+
90
−
5
View file @
7618fbe0
...
@@ -29,7 +29,7 @@ class GeodesicFEAssembler {
...
@@ -29,7 +29,7 @@ class GeodesicFEAssembler {
const
GridView
gridView_
;
const
GridView
gridView_
;
const
LocalGeodesicFEStiffness
<
GridView
,
TargetSpace
>*
localStiffness_
;
LocalGeodesicFEStiffness
<
GridView
,
TargetSpace
>*
localStiffness_
;
public
:
public
:
...
@@ -65,14 +65,14 @@ template <class GridView, class TargetSpace>
...
@@ -65,14 +65,14 @@ template <class GridView, class TargetSpace>
void
GeodesicFEAssembler
<
GridView
,
TargetSpace
>::
void
GeodesicFEAssembler
<
GridView
,
TargetSpace
>::
getNeighborsPerVertex
(
Dune
::
MatrixIndexSet
&
nb
)
const
getNeighborsPerVertex
(
Dune
::
MatrixIndexSet
&
nb
)
const
{
{
const
typename
GridView
::
IndexSet
&
indexSet
=
gridView_
->
indexSet
();
const
typename
GridView
::
IndexSet
&
indexSet
=
gridView_
.
indexSet
();
int
n
=
gridView_
->
size
(
gridDim
);
int
n
=
gridView_
.
size
(
gridDim
);
nb
.
resize
(
n
,
n
);
nb
.
resize
(
n
,
n
);
ElementIterator
it
=
gridView_
->
template
begin
<
0
>();
ElementIterator
it
=
gridView_
.
template
begin
<
0
>();
ElementIterator
endit
=
gridView_
->
template
end
<
0
>
();
ElementIterator
endit
=
gridView_
.
template
end
<
0
>
();
for
(;
it
!=
endit
;
++
it
)
{
for
(;
it
!=
endit
;
++
it
)
{
...
@@ -93,6 +93,91 @@ getNeighborsPerVertex(Dune::MatrixIndexSet& nb) const
...
@@ -93,6 +93,91 @@ getNeighborsPerVertex(Dune::MatrixIndexSet& nb) const
}
}
template
<
class
GridView
,
class
TargetSpace
>
void
GeodesicFEAssembler
<
GridView
,
TargetSpace
>::
assembleMatrix
(
const
std
::
vector
<
TargetSpace
>&
sol
,
Dune
::
BCRSMatrix
<
MatrixBlock
>&
matrix
)
const
{
const
typename
GridView
::
IndexSet
&
indexSet
=
gridView_
.
indexSet
();
Dune
::
MatrixIndexSet
neighborsPerVertex
;
getNeighborsPerVertex
(
neighborsPerVertex
);
matrix
=
0
;
ElementIterator
it
=
gridView_
.
template
begin
<
0
>();
ElementIterator
endit
=
gridView_
.
template
end
<
0
>
();
for
(
;
it
!=
endit
;
++
it
)
{
const
int
numOfBaseFct
=
it
->
template
count
<
gridDim
>();
// Extract local solution
std
::
vector
<
TargetSpace
>
localSolution
(
numOfBaseFct
);
for
(
int
i
=
0
;
i
<
numOfBaseFct
;
i
++
)
localSolution
[
i
]
=
sol
[
indexSet
.
subIndex
(
*
it
,
i
,
gridDim
)];
// setup matrix
localStiffness_
->
assemble
(
*
it
,
localSolution
);
// Add element matrix to global stiffness matrix
for
(
int
i
=
0
;
i
<
numOfBaseFct
;
i
++
)
{
int
row
=
indexSet
.
subIndex
(
*
it
,
i
,
gridDim
);
for
(
int
j
=
0
;
j
<
numOfBaseFct
;
j
++
)
{
int
col
=
indexSet
.
subIndex
(
*
it
,
j
,
gridDim
);
matrix
[
row
][
col
]
+=
localStiffness_
->
mat
(
i
,
j
);
}
}
}
}
template
<
class
GridView
,
class
TargetSpace
>
void
GeodesicFEAssembler
<
GridView
,
TargetSpace
>::
assembleGradient
(
const
std
::
vector
<
TargetSpace
>&
sol
,
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
blocksize
>
>&
grad
)
const
{
const
typename
GridView
::
IndexSet
&
indexSet
=
gridView_
.
indexSet
();
if
(
sol
.
size
()
!=
gridView_
.
size
(
gridDim
))
DUNE_THROW
(
Dune
::
Exception
,
"Solution vector doesn't match the grid!"
);
grad
.
resize
(
sol
.
size
());
grad
=
0
;
ElementIterator
it
=
gridView_
->
template
begin
<
0
>();
ElementIterator
endIt
=
gridView_
->
template
end
<
0
>();
// Loop over all elements
for
(;
it
!=
endIt
;
++
it
)
{
// A 1d grid has two vertices
const
int
nDofs
=
it
->
template
count
<
gridDim
>();
// Extract local solution
std
::
vector
<
TargetSpace
>
localSolution
(
nDofs
);
for
(
int
i
=
0
;
i
<
nDofs
;
i
++
)
localSolution
[
i
]
=
sol
[
indexSet
.
subIndex
(
*
it
,
i
,
gridDim
)];
// Assemble local gradient
std
::
vector
<
Dune
::
FieldVector
<
double
,
blocksize
>
>
localGradient
(
nDofs
);
localStiffness_
->
assembleGradient
(
*
it
,
localSolution
,
localGradient
);
// Add to global gradient
for
(
int
i
=
0
;
i
<
nDofs
;
i
++
)
grad
[
indexSet
.
subIndex
(
*
it
,
i
,
gridDim
)]
+=
localGradient
[
i
];
}
}
template
<
class
GridView
,
class
TargetSpace
>
template
<
class
GridView
,
class
TargetSpace
>
...
...
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