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
a62f61c7
Commit
a62f61c7
authored
14 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
unlock linearSystemPETScBlockDouble when PETSC_USE_COMPLEX
parent
d21b356a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Solver/linearSystemPETSc.cpp
+32
-9
32 additions, 9 deletions
Solver/linearSystemPETSc.cpp
Solver/linearSystemPETSc.h
+0
-2
0 additions, 2 deletions
Solver/linearSystemPETSc.h
with
32 additions
and
11 deletions
Solver/linearSystemPETSc.cpp
+
32
−
9
View file @
a62f61c7
...
...
@@ -5,7 +5,6 @@
#include
"fullMatrix.h"
#include
<stdlib.h>
#include
"GmshMessage.h"
#if not defined(PETSC_USE_COMPLEX)
void
linearSystemPETScBlockDouble
::
_kspCreate
()
{
KSPCreate
(
PETSC_COMM_WORLD
,
&
_ksp
);
if
(
this
->
_parameters
.
count
(
"petscPrefix"
))
...
...
@@ -14,29 +13,42 @@ void linearSystemPETScBlockDouble::_kspCreate() {
_kspAllocated
=
true
;
}
void
linearSystemPETScBlockDouble
::
addToMatrix
(
int
row
,
int
col
,
const
fullMatrix
<
PetscScalar
>
&
val
)
void
linearSystemPETScBlockDouble
::
addToMatrix
(
int
row
,
int
col
,
const
fullMatrix
<
double
>
&
val
)
{
if
(
!
_entriesPreAllocated
)
preAllocateEntries
();
fullMatrix
<
PetscScalar
>
&
modval
=
*
const_cast
<
fullMatrix
<
PetscScalar
>
*>
(
&
val
);
for
(
int
ii
=
0
;
ii
<
val
.
size1
();
ii
++
)
#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
);
}
}
#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
;
}
#endif
}
void
linearSystemPETScBlockDouble
::
addToRightHandSide
(
int
row
,
const
fullMatrix
<
PetscScalar
>
&
val
)
void
linearSystemPETScBlockDouble
::
addToRightHandSide
(
int
row
,
const
fullMatrix
<
double
>
&
val
)
{
for
(
int
ii
=
0
;
ii
<
_blockSize
;
ii
++
)
{
PetscInt
i
=
row
*
_blockSize
+
ii
;
...
...
@@ -45,24 +57,36 @@ void linearSystemPETScBlockDouble::addToRightHandSide(int row, const fullMatrix<
}
}
void
linearSystemPETScBlockDouble
::
getFromMatrix
(
int
row
,
int
col
,
fullMatrix
<
PetscScalar
>
&
val
)
const
void
linearSystemPETScBlockDouble
::
getFromMatrix
(
int
row
,
int
col
,
fullMatrix
<
double
>
&
val
)
const
{
Msg
::
Error
(
"getFromMatrix not implemented for PETSc"
);
}
void
linearSystemPETScBlockDouble
::
getFromRightHandSide
(
int
row
,
fullMatrix
<
PetscScalar
>
&
val
)
const
void
linearSystemPETScBlockDouble
::
getFromRightHandSide
(
int
row
,
fullMatrix
<
double
>
&
val
)
const
{
for
(
int
i
=
0
;
i
<
_blockSize
;
i
++
)
{
int
ii
=
row
*
_blockSize
+
i
;
#ifdef PETSC_USE_COMPLEX
PetscScalar
s
;
VecGetValues
(
_b
,
1
,
&
ii
,
&
s
);
val
(
i
,
0
)
=
s
.
real
();
#else
VecGetValues
(
_b
,
1
,
&
ii
,
&
val
(
i
,
0
));
#endif
}
}
void
linearSystemPETScBlockDouble
::
getFromSolution
(
int
row
,
fullMatrix
<
PetscScalar
>
&
val
)
const
void
linearSystemPETScBlockDouble
::
getFromSolution
(
int
row
,
fullMatrix
<
double
>
&
val
)
const
{
for
(
int
i
=
0
;
i
<
_blockSize
;
i
++
)
{
int
ii
=
row
*
_blockSize
+
i
;
#ifdef PETSC_USE_COMPLEX
PetscScalar
s
;
VecGetValues
(
_x
,
1
,
&
ii
,
&
s
);
val
(
i
,
0
)
=
s
.
real
();
#else
VecGetValues
(
_x
,
1
,
&
ii
,
&
val
(
i
,
0
));
#endif
}
}
...
...
@@ -205,7 +229,6 @@ double linearSystemPETScBlockDouble::normInfRightHandSide() const
VecNorm
(
_b
,
NORM_INFINITY
,
&
nor
);
return
nor
;
}
#endif
#include
"Bindings.h"
void
linearSystemPETScRegisterBindings
(
binding
*
b
)
...
...
This diff is collapsed.
Click to expand it.
Solver/linearSystemPETSc.h
+
0
−
2
View file @
a62f61c7
...
...
@@ -266,7 +266,6 @@ class linearSystemPETSc : public linearSystem<scalar> {
class
binding
;
void
linearSystemPETScRegisterBindings
(
binding
*
b
);
#if not defined(PETSC_USE_COMPLEX)
class
linearSystemPETScBlockDouble
:
public
linearSystem
<
fullMatrix
<
double
>
>
{
bool
_entriesPreAllocated
,
_isAllocated
,
_kspAllocated
;
sparsityPattern
_sparsity
;
...
...
@@ -291,7 +290,6 @@ class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > {
double
normInfRightHandSide
()
const
;
linearSystemPETScBlockDouble
();
};
#endif
#else
...
...
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