Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
803fae22
There was an error fetching the commit references. Please try again later.
Commit
803fae22
authored
8 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Fixed UmfpackWrapper, added getters for raw data to CSR matrix
parent
a16d4530
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/TNL/Matrices/CSR.h
+32
-5
32 additions, 5 deletions
src/TNL/Matrices/CSR.h
src/TNL/Solvers/Linear/UmfpackWrapper.h
+7
-7
7 additions, 7 deletions
src/TNL/Solvers/Linear/UmfpackWrapper.h
src/TNL/Solvers/Linear/UmfpackWrapper_impl.h
+15
-15
15 additions, 15 deletions
src/TNL/Solvers/Linear/UmfpackWrapper_impl.h
with
54 additions
and
27 deletions
src/TNL/Matrices/CSR.h
+
32
−
5
View file @
803fae22
...
...
@@ -199,6 +199,38 @@ class CSR : public Sparse< Real, Device, Index >
int
gridIdx
)
const
;
#endif
// The following getters allow us to interface TNL with external C-like
// libraries such as UMFPACK or SuperLU, which need the raw data.
Index
*
getRowPointers
()
{
return
this
->
rowPointers
.
getData
();
}
const
Index
*
getRowPointers
()
const
{
return
this
->
rowPointers
.
getData
();
}
Index
*
getColumnIndexes
()
{
return
this
->
columnIndexes
.
getData
();
}
const
Index
*
getColumnIndexes
()
const
{
return
this
->
columnIndexes
.
getData
();
}
Real
*
getValues
()
{
return
this
->
values
.
getData
();
}
const
Real
*
getValues
()
const
{
return
this
->
values
.
getData
();
}
protected
:
Containers
::
Vector
<
Index
,
Device
,
Index
>
rowPointers
;
...
...
@@ -210,11 +242,6 @@ class CSR : public Sparse< Real, Device, Index >
typedef
CSRDeviceDependentCode
<
DeviceType
>
DeviceDependentCode
;
friend
class
CSRDeviceDependentCode
<
DeviceType
>
;
friend
class
tnlCusparseCSR
<
RealType
>
;
#ifdef HAVE_UMFPACK
template
<
typename
Matrix
,
typename
Preconditioner
>
friend
class
UmfpackWrapper
;
#endif
};
}
// namespace Matrices
...
...
This diff is collapsed.
Click to expand it.
src/TNL/Solvers/Linear/UmfpackWrapper.h
+
7
−
7
View file @
803fae22
...
...
@@ -9,7 +9,7 @@
#include
<TNL/Object.h>
#include
<TNL/Config/ConfigDescription.h>
#include
<TNL/Matrices/CSR.h>
#include
<TNL/Solvers/
p
reconditioners/Dummy.h>
#include
<TNL/Solvers/
Linear/P
reconditioners/Dummy.h>
#include
<TNL/Solvers/IterativeSolver.h>
#include
<TNL/Solvers/Linear/LinearResidueGetter.h>
...
...
@@ -25,16 +25,16 @@ struct is_csr_matrix
};
template
<
typename
Real
,
typename
Device
,
typename
Index
>
struct
is_csr_matrix
<
CSR
<
Real
,
Device
,
Index
>
>
struct
is_csr_matrix
<
Matrices
::
CSR
<
Real
,
Device
,
Index
>
>
{
static
const
bool
value
=
true
;
};
template
<
typename
Matrix
,
typename
Preconditioner
=
Dummy
<
typename
Matrix
::
RealType
,
typename
Matrix
::
DeviceType
,
typename
Matrix
::
IndexType
>
>
typename
Preconditioner
=
Preconditioners
::
Dummy
<
typename
Matrix
::
RealType
,
typename
Matrix
::
DeviceType
,
typename
Matrix
::
IndexType
>
>
class
UmfpackWrapper
:
public
Object
,
// just to ensure the same interface as other linear solvers
...
...
@@ -88,7 +88,7 @@ public:
template
<
typename
Preconditioner
>
class
UmfpackWrapper
<
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>
class
UmfpackWrapper
<
Matrices
::
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>
:
public
Object
,
// just to ensure the same interface as other linear solvers
public
IterativeSolver
<
double
,
int
>
...
...
@@ -97,7 +97,7 @@ public:
typedef
double
RealType
;
typedef
int
IndexType
;
typedef
Devices
::
Host
DeviceType
;
typedef
CSR
<
double
,
Devices
::
Host
,
int
>
MatrixType
;
typedef
Matrices
::
CSR
<
double
,
Devices
::
Host
,
int
>
MatrixType
;
typedef
Preconditioner
PreconditionerType
;
typedef
SharedPointer
<
const
MatrixType
,
DeviceType
,
true
>
MatrixPointer
;
typedef
SharedPointer
<
const
PreconditionerType
,
DeviceType
,
true
>
PreconditionerPointer
;
...
...
This diff is collapsed.
Click to expand it.
src/TNL/Solvers/Linear/UmfpackWrapper_impl.h
+
15
−
15
View file @
803fae22
...
...
@@ -11,13 +11,13 @@ namespace Solvers {
namespace
Linear
{
template
<
typename
Preconditioner
>
UmfpackWrapper
<
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
UmfpackWrapper
<
Matrices
::
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
UmfpackWrapper
()
{}
template
<
typename
Preconditioner
>
void
UmfpackWrapper
<
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
UmfpackWrapper
<
Matrices
::
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
configSetup
(
Config
::
ConfigDescription
&
config
,
const
String
&
prefix
)
{
...
...
@@ -25,7 +25,7 @@ configSetup( Config::ConfigDescription& config,
template
<
typename
Preconditioner
>
bool
UmfpackWrapper
<
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
UmfpackWrapper
<
Matrices
::
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
setup
(
const
Config
::
ParameterContainer
&
parameters
,
const
String
&
prefix
)
{
...
...
@@ -33,14 +33,14 @@ setup( const Config::ParameterContainer& parameters,
}
template
<
typename
Preconditioner
>
void
UmfpackWrapper
<
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
void
UmfpackWrapper
<
Matrices
::
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
setMatrix
(
const
MatrixPointer
&
matrix
)
{
this
->
matrix
=
matrix
;
}
template
<
typename
Preconditioner
>
void
UmfpackWrapper
<
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
void
UmfpackWrapper
<
Matrices
::
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
setPreconditioner
(
const
PreconditionerPointer
&
preconditioner
)
{
this
->
preconditioner
=
preconditioner
;
...
...
@@ -49,7 +49,7 @@ setPreconditioner( const PreconditionerPointer& preconditioner )
template
<
typename
Preconditioner
>
template
<
typename
Vector
,
typename
ResidueGetter
>
bool
UmfpackWrapper
<
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
bool
UmfpackWrapper
<
Matrices
::
CSR
<
double
,
Devices
::
Host
,
int
>
,
Preconditioner
>::
solve
(
const
Vector
&
b
,
Vector
&
x
)
{
...
...
@@ -77,9 +77,9 @@ solve( const Vector& b,
// symbolic reordering of the sparse matrix
status
=
umfpack_di_symbolic
(
size
,
size
,
matrix
->
r
owPointers
.
getData
(),
matrix
->
c
olumnIndexes
.
getData
(),
matrix
->
v
alues
.
getData
(),
matrix
->
getR
owPointers
(),
matrix
->
getC
olumnIndexes
(),
matrix
->
getV
alues
(),
&
Symbolic
,
Control
,
Info
);
if
(
status
!=
UMFPACK_OK
)
{
std
::
cerr
<<
"error: symbolic reordering failed"
<<
std
::
endl
;
...
...
@@ -87,9 +87,9 @@ solve( const Vector& b,
}
// numeric factorization
status
=
umfpack_di_numeric
(
matrix
->
r
owPointers
.
getData
(),
matrix
->
c
olumnIndexes
.
getData
(),
matrix
->
v
alues
.
getData
(),
status
=
umfpack_di_numeric
(
matrix
->
getR
owPointers
(),
matrix
->
getC
olumnIndexes
(),
matrix
->
getV
alues
(),
Symbolic
,
&
Numeric
,
Control
,
Info
);
if
(
status
!=
UMFPACK_OK
)
{
std
::
cerr
<<
"error: numeric factorization failed"
<<
std
::
endl
;
...
...
@@ -98,9 +98,9 @@ solve( const Vector& b,
// solve with specified right-hand-side
status
=
umfpack_di_solve
(
system_type
,
matrix
->
r
owPointers
.
getData
(),
matrix
->
c
olumnIndexes
.
getData
(),
matrix
->
v
alues
.
getData
(),
matrix
->
getR
owPointers
(),
matrix
->
getC
olumnIndexes
(),
matrix
->
getV
alues
(),
x
.
getData
(),
b
.
getData
(),
Numeric
,
Control
,
Info
);
...
...
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