Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Leibner
dune-common
Commits
05656982
Commit
05656982
authored
20 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
implementation uses the prolongation matrix instead of the restriction matrix
[[Imported from SVN: r927]]
parent
33d975a7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fem/transfer/mgtransfer.cc
+24
-49
24 additions, 49 deletions
fem/transfer/mgtransfer.cc
with
24 additions
and
49 deletions
fem/transfer/mgtransfer.cc
+
24
−
49
View file @
05656982
...
...
@@ -15,8 +15,8 @@ void Dune::MGTransfer<DiscFuncType>::setup(const FunctionSpaceType& fS, int cL,
typedef
typename
FunctionSpaceType
::
GridType
GridType
;
int
rows
=
fS
.
size
(
coars
eLevel
);
int
cols
=
fS
.
size
(
fin
eLevel
);
int
rows
=
fS
.
size
(
fin
eLevel
);
int
cols
=
fS
.
size
(
coars
eLevel
);
GridType
&
grid
=
fS
.
getGrid
();
...
...
@@ -78,7 +78,7 @@ void Dune::MGTransfer<DiscFuncType>::setup(const FunctionSpaceType& fS, int cL,
//std::cout << "value: " << value << "\n";
matrix_
.
set
(
global
Coars
e
,
global
Fin
e
,
value
[
0
]);
matrix_
.
set
(
global
Fin
e
,
global
Coars
e
,
value
[
0
]);
}
...
...
@@ -88,22 +88,20 @@ void Dune::MGTransfer<DiscFuncType>::setup(const FunctionSpaceType& fS, int cL,
}
//matrix_.print(std::cout);
}
template
<
class
DiscFuncType
>
void
Dune
::
MGTransfer
<
DiscFuncType
>::
restrict
(
const
DiscFuncType
&
f
,
DiscFuncType
&
t
)
const
void
Dune
::
MGTransfer
<
DiscFuncType
>::
prolong
(
const
DiscFuncType
&
f
,
DiscFuncType
&
t
)
const
{
assert
(
t
.
getFunctionSpace
().
size
(
coars
eLevel
)
==
matrix_
.
rows
());
assert
(
f
.
getFunctionSpace
().
size
(
fin
eLevel
)
==
matrix_
.
cols
());
assert
(
t
.
getFunctionSpace
().
size
(
fin
eLevel
)
==
matrix_
.
rows
());
assert
(
f
.
getFunctionSpace
().
size
(
coars
eLevel
)
==
matrix_
.
cols
());
typedef
typename
DiscFuncType
::
DofIteratorType
DofIteratorType
;
typedef
typename
SparseRowMatrix
<
double
>::
ColumnIterator
ColumnIterator
;
DofIteratorType
tIt
=
t
.
dbegin
(
coarseLevel
);
DofIteratorType
fIt
=
f
.
dbegin
(
fineLevel
);
DofIteratorType
tIt
=
t
.
dbegin
(
fineLevel
);
DofIteratorType
fIt
=
f
.
dbegin
(
coarseLevel
);
for
(
int
row
=
0
;
row
<
matrix_
.
rows
();
row
++
)
{
...
...
@@ -121,18 +119,18 @@ void Dune::MGTransfer<DiscFuncType>::restrict (const DiscFuncType & f, DiscFuncT
}
template
<
class
DiscFuncType
>
void
Dune
::
MGTransfer
<
DiscFuncType
>::
prolong
(
const
DiscFuncType
&
f
,
DiscFuncType
&
t
)
const
void
Dune
::
MGTransfer
<
DiscFuncType
>::
restrict
(
const
DiscFuncType
&
f
,
DiscFuncType
&
t
)
const
{
assert
(
f
.
getFunctionSpace
().
size
(
coars
eLevel
)
==
matrix_
.
rows
());
assert
(
t
.
getFunctionSpace
().
size
(
fin
eLevel
)
==
matrix_
.
cols
());
assert
(
f
.
getFunctionSpace
().
size
(
fin
eLevel
)
==
matrix_
.
rows
());
assert
(
t
.
getFunctionSpace
().
size
(
coars
eLevel
)
==
matrix_
.
cols
());
typedef
typename
DiscFuncType
::
DofIteratorType
DofIteratorType
;
typedef
typename
SparseRowMatrix
<
double
>::
ColumnIterator
ColumnIterator
;
t
.
clearLevel
(
fin
eLevel
);
t
.
clearLevel
(
coars
eLevel
);
DofIteratorType
tIt
=
t
.
dbegin
(
fin
eLevel
);
DofIteratorType
fIt
=
f
.
dbegin
(
coars
eLevel
);
DofIteratorType
tIt
=
t
.
dbegin
(
coars
eLevel
);
DofIteratorType
fIt
=
f
.
dbegin
(
fin
eLevel
);
for
(
int
row
=
0
;
row
<
matrix_
.
rows
();
row
++
)
{
...
...
@@ -145,6 +143,7 @@ void Dune::MGTransfer<DiscFuncType>::prolong(const DiscFuncType& f, DiscFuncType
tIt
[
cIt
.
col
()]
+=
fIt
[
row
]
*
(
*
cIt
);
}
}
...
...
@@ -152,59 +151,35 @@ template<class DiscFuncType>
Dune
::
SparseRowMatrix
<
double
>
Dune
::
MGTransfer
<
DiscFuncType
>::
galerkinRestrict
(
const
Dune
::
SparseRowMatrix
<
double
>&
fineMat
)
const
{
typedef
typename
SparseRowMatrix
<
double
>::
ColumnIterator
ColumnIterator
;
//return matrix_.applyFromLeftAndRightTo(fineMat);
// Hack: We need the transposed matrix
SparseRowMatrix
<
double
>
transpose
(
matrix_
.
cols
(),
matrix_
.
rows
(),
matrix_
.
numNonZeros
());
for
(
int
row
=
0
;
row
<
matrix_
.
rows
();
row
++
)
{
/** \todo Remove casts */
ColumnIterator
cIt
=
const_cast
<
SparseRowMatrix
<
double
>&>
(
matrix_
).
template
rbegin
(
row
);
ColumnIterator
cEndIt
=
const_cast
<
SparseRowMatrix
<
double
>&>
(
matrix_
).
template
rend
(
row
);
for
(;
cIt
!=
cEndIt
;
++
cIt
)
transpose
.
set
(
cIt
.
col
(),
row
,
*
cIt
);
}
typedef
typename
SparseRowMatrix
<
double
>::
ColumnIterator
ColumnIterator
;
SparseRowMatrix
<
double
>
result
(
matrix_
.
row
s
()
,
matrix_
.
row
s
()
,
fineMat
.
numNonZeros
());
SparseRowMatrix
<
double
>
result
(
matrix_
.
col
s
()
,
matrix_
.
col
s
()
,
fineMat
.
numNonZeros
());
//for (v=FIRSTVECTOR(FineGrid); v!=NULL; v=SUCCVC(v))
for
(
int
row
=
0
;
row
<
fineMat
.
rows
();
row
++
)
{
// for (m=VSTART(v); m!=NULL; m=MNEXT(m)) {
// w = MDEST(m);
ColumnIterator
cIt
=
const_cast
<
SparseRowMatrix
<
double
>&>
(
fineMat
).
template
rbegin
(
row
);
ColumnIterator
cEndIt
=
const_cast
<
SparseRowMatrix
<
double
>&>
(
fineMat
).
template
rend
(
row
);
for
(;
cIt
!=
cEndIt
;
++
cIt
)
{
//mvalue = MVALUE(m,mc);
double
mvalue
=
*
cIt
;
ColumnIterator
tciIt
=
transpose
.
template
rbegin
(
row
);
ColumnIterator
tciEndIt
=
transpose
.
template
rend
(
row
);
ColumnIterator
tciIt
=
const_cast
<
SparseRowMatrix
<
double
>&>
(
matrix_
)
.
template
rbegin
(
row
);
ColumnIterator
tciEndIt
=
const_cast
<
SparseRowMatrix
<
double
>&>
(
matrix_
)
.
template
rend
(
row
);
//for (im=VISTART(v); im!= NULL; im = NEXT(im)) {
for
(;
tciIt
!=
tciEndIt
;
++
tciIt
)
{
//fac = mvalue*MVALUE(im,0);
double
fac
=
mvalue
*
(
*
tciIt
);
ColumnIterator
tcjIt
=
transpose
.
template
rbegin
(
cIt
.
col
());
ColumnIterator
tcjEndIt
=
transpose
.
template
rend
(
cIt
.
col
());
ColumnIterator
tcjIt
=
const_cast
<
SparseRowMatrix
<
double
>&>
(
matrix_
)
.
template
rbegin
(
cIt
.
col
());
ColumnIterator
tcjEndIt
=
const_cast
<
SparseRowMatrix
<
double
>&>
(
matrix_
)
.
template
rend
(
cIt
.
col
());
//for (jm=VISTART(v); jm!= NULL; jm = NEXT(jm)) {
for
(;
tcjIt
!=
tcjEndIt
;
++
tcjIt
)
{
// jv = MDEST(jm);
// cm = GetMatrix(iv,jv);
// MVALUE(cm,mc) +=
// fac * MVALUE(jm,0);
result
.
add
(
tciIt
.
col
(),
tcjIt
.
col
(),
fac
*
(
*
tcjIt
));
//result.add( tciIt.col(), tcjIt.col(), fac* (*tcjIt));
result
.
add
(
tcjIt
.
col
(),
tciIt
.
col
(),
fac
*
(
*
tcjIt
));
}
}
...
...
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