Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Backofen, Rainer
amdis
Commits
a9ba2f66
Commit
a9ba2f66
authored
Feb 18, 2009
by
Thomas Witkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* UMFPack solver can now deal with muliple componets having different number of nodes
parent
493f4b49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
18 deletions
+41
-18
AMDiS/src/UmfPackSolver.hh
AMDiS/src/UmfPackSolver.hh
+41
-18
No files found.
AMDiS/src/UmfPackSolver.hh
View file @
a9ba2f66
...
...
@@ -44,8 +44,22 @@ namespace AMDiS {
// Number of systems.
int
nComponents
=
m
->
getSize
();
// Size of the new composed matrix.
int
newMatrixSize
=
((
*
m
)[
0
][
0
])
->
getFESpace
()
->
getAdmin
()
->
getUsedSize
()
*
nComponents
;
// Calculate size of the new composed matrix.
int
newMatrixSize
=
0
;
std
::
vector
<
int
>
matricesSize
(
nComponents
);
for
(
int
i
=
0
;
i
<
nComponents
;
i
++
)
{
for
(
int
j
=
0
;
j
<
nComponents
;
j
++
)
{
if
((
*
m
)[
i
][
j
])
{
matricesSize
[
i
]
=
((
*
m
)[
i
][
j
])
->
getFESpace
()
->
getAdmin
()
->
getUsedSize
();
newMatrixSize
+=
matricesSize
[
i
];
break
;
}
}
}
// int newMatrixSize = ((*m)[0][0])->getFESpace()->getAdmin()->getUsedSize() * nComponents;
// The new matrix has to be stored in compressed col format, therefore
// the cols are collected.
...
...
@@ -54,34 +68,44 @@ namespace AMDiS {
// Counter for the number of non-zero elements in the new matrix.
int
nElements
=
0
;
for
(
int
stencilRow
=
0
;
stencilRow
<
nComponents
;
stencilRow
++
)
{
for
(
int
stencilRow
=
0
,
shiftRow
=
0
;
stencilRow
<
nComponents
;
stencilRow
++
)
{
int
shiftCol
=
0
;
for
(
int
stencilCol
=
0
;
stencilCol
<
nComponents
;
stencilCol
++
)
{
if
(
!
(
*
m
)[
stencilRow
][
stencilCol
])
{
shiftCol
+=
matricesSize
[
stencilCol
];
continue
;
}
DOFMatrix
::
Iterator
matrixRow
((
*
m
)[
stencilRow
][
stencilCol
],
USED_DOFS
);
int
rowIndex
=
0
;
for
(
matrixRow
.
reset
();
!
matrixRow
.
end
();
matrixRow
++
,
rowIndex
++
)
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
((
*
matrixRow
).
size
());
i
++
)
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
((
*
matrixRow
).
size
());
i
++
)
{
if
((
*
matrixRow
)[
i
].
col
>=
0
)
{
MatEntry
me
;
me
.
entry
=
(
*
matrixRow
)[
i
].
entry
;
// The col field is used to store the row number of the new element.
me
.
col
=
(
rowIndex
*
nComponents
)
+
stencilRow
;
me
.
col
=
rowIndex
+
shiftRow
;
// And save the new element in the corresponding column.
cols
[(
(
*
matrixRow
)[
i
].
col
*
nComponents
)
+
stencil
Col
].
push_back
(
me
);
cols
[(
*
matrixRow
)[
i
].
col
+
shift
Col
].
push_back
(
me
);
nElements
++
;
}
}
}
}
}
shiftCol
+=
matricesSize
[
stencilCol
];
}
shiftRow
+=
matricesSize
[
stencilRow
];
}
// Data fields for UMFPack.
int
*
Ap
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
(
newMatrixSize
+
1
));
int
*
Ai
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
nElements
);
...
...
@@ -90,15 +114,15 @@ namespace AMDiS {
double
*
xvec
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
newMatrixSize
);
// Resort the right hand side of the linear system.
for
(
int
i
=
0
;
i
<
b
->
getSize
();
i
++
)
{
for
(
int
i
=
0
,
counter
=
0
;
i
<
b
->
getSize
();
i
++
)
{
DOFVector
<
double
>::
Iterator
it
(
b
->
getDOFVector
(
i
),
USED_DOFS
);
int
counter
=
0
;
for
(
it
.
reset
();
!
it
.
end
();
++
it
,
counter
++
)
{
bvec
[
counter
*
nComponents
+
i
]
=
*
it
;
for
(
it
.
reset
();
!
it
.
end
();
++
it
)
{
bvec
[
counter
++
]
=
*
it
;
}
}
// Create fields Ap, Ai and Ax.
int
elCounter
=
0
;
Ap
[
0
]
=
0
;
...
...
@@ -164,12 +188,11 @@ namespace AMDiS {
// Copy and resort solution.
for
(
int
i
=
0
;
i
<
x
->
getSize
();
i
++
)
{
for
(
int
i
=
0
,
counter
=
0
;
i
<
x
->
getSize
();
i
++
)
{
DOFVector
<
double
>::
Iterator
it
(
x
->
getDOFVector
(
i
),
USED_DOFS
);
int
counter
=
0
;
for
(
it
.
reset
();
!
it
.
end
();
it
++
,
counter
++
)
{
*
it
=
xvec
[
counter
*
nComponents
+
i
];
for
(
it
.
reset
();
!
it
.
end
();
it
++
)
{
*
it
=
xvec
[
counter
++
];
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment