Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Romin Tomasetti
gmsh
Commits
423a8b02
Commit
423a8b02
authored
11 years ago
by
Sebastien Blaise
Browse files
Options
Downloads
Patches
Plain Diff
Faster linearSystemPETScBlock by removing transpose
parent
13036385
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
Solver/linearSystemPETSc.cpp
+6
-22
6 additions, 22 deletions
Solver/linearSystemPETSc.cpp
Solver/linearSystemPETSc.h
+3
-3
3 additions, 3 deletions
Solver/linearSystemPETSc.h
Solver/linearSystemPETSc.hpp
+1
-0
1 addition, 0 deletions
Solver/linearSystemPETSc.hpp
with
10 additions
and
25 deletions
Solver/linearSystemPETSc.cpp
+
6
−
22
View file @
423a8b02
// Gmsh - Copyright (C) 1997-2014 C. Geuzaine, J.-F. Remacle
//
//
S
ee the LICENSE.txt file for license information. Please report all
// ee the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#include
"GmshConfig.h"
...
...
@@ -35,35 +35,19 @@ void linearSystemPETSc<fullMatrix<double> >::addToMatrix(int row, int col,
{
if
(
!
_entriesPreAllocated
)
preAllocateEntries
();
PetscInt
i
=
row
,
j
=
col
;
#ifdef PETSC_USE_COMPLEX
fullMatrix
<
std
::
complex
<
double
>
>
modval
(
val
.
size1
(),
val
.
size2
());
for
(
int
ii
=
0
;
ii
<
val
.
size1
();
ii
++
)
{
for
(
int
jj
=
0
;
jj
<
val
.
size1
();
jj
++
)
{
modval
(
ii
,
jj
)
=
val
(
jj
,
ii
);
modval
(
jj
,
ii
)
=
val
(
ii
,
jj
);
modval
(
ii
,
jj
)
=
val
(
ii
,
jj
);
}
}
MatSetValuesBlocked
(
_a
,
1
,
&
i
,
1
,
&
j
,
modval
.
getDataPtr
(),
ADD_VALUES
);
#else
fullMatrix
<
double
>
&
modval
=
*
const_cast
<
fullMatrix
<
double
>
*>
(
&
val
);
for
(
int
ii
=
0
;
ii
<
val
.
size1
();
ii
++
)
{
for
(
int
jj
=
0
;
jj
<
ii
;
jj
++
)
{
PetscScalar
buff
=
modval
(
ii
,
jj
);
modval
(
ii
,
jj
)
=
modval
(
jj
,
ii
);
modval
(
jj
,
ii
)
=
buff
;
}
}
#endif
PetscInt
i
=
row
,
j
=
col
;
MatSetValuesBlocked
(
_a
,
1
,
&
i
,
1
,
&
j
,
&
modval
(
0
,
0
),
ADD_VALUES
);
//transpose back so that the original matrix is not modified
#ifndef PETSC_USE_COMPLEX
for
(
int
ii
=
0
;
ii
<
val
.
size1
();
ii
++
)
for
(
int
jj
=
0
;
jj
<
ii
;
jj
++
)
{
PetscScalar
buff
=
modval
(
ii
,
jj
);
modval
(
ii
,
jj
)
=
modval
(
jj
,
ii
);
modval
(
jj
,
ii
)
=
buff
;
}
MatSetValuesBlocked
(
_a
,
1
,
&
i
,
1
,
&
j
,
val
.
getDataPtr
(),
ADD_VALUES
);
#endif
_valuesNotAssembled
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
Solver/linearSystemPETSc.h
+
3
−
3
View file @
423a8b02
...
...
@@ -86,7 +86,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
void
insertInSparsityPattern
(
int
i
,
int
j
);
bool
isAllocated
()
const
{
return
_isAllocated
;
}
void
preAllocateEntries
();
void
allocate
(
int
nbRows
);
virtual
void
allocate
(
int
nbRows
);
void
print
();
void
clear
();
void
getFromMatrix
(
int
row
,
int
col
,
scalar
&
val
)
const
;
...
...
@@ -100,7 +100,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
void
zeroRightHandSide
();
void
zeroSolution
();
void
printMatlab
(
const
char
*
filename
)
const
;
int
systemSolve
();
virtual
int
systemSolve
();
Mat
&
getMatrix
(){
return
_a
;
}
//std::vector<scalar> getData();
//std::vector<int> getRowPointers();
...
...
@@ -133,7 +133,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
void
zeroRightHandSide
()
{}
void
zeroSolution
()
{}
void
printMatlab
(
const
char
*
filename
)
const
{};
int
systemSolve
()
{
return
0
;
}
virtual
int
systemSolve
()
{
return
0
;
}
double
normInfRightHandSide
()
const
{
return
0
;}
};
#endif
...
...
This diff is collapsed.
Click to expand it.
Solver/linearSystemPETSc.hpp
+
1
−
0
View file @
423a8b02
...
...
@@ -156,6 +156,7 @@ void linearSystemPETSc<scalar>::allocate(int nbRows)
else
{
MatSetType
(
_a
,
MATSEQBAIJ
);
}
MatSetOption
(
_a
,
MAT_ROW_ORIENTED
,
PETSC_FALSE
);
}
// override the default options with the ones from the option
// database (if any)
...
...
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