Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
amdis
Commits
1e0015b3
Commit
1e0015b3
authored
Oct 30, 2016
by
Praetorius, Simon
Browse files
Merge branch 'master' of
https://gitlab.math.tu-dresden.de/iwr/amdis
parents
6a705e50
1ded5c55
Pipeline
#606
passed with stages
in 79 minutes and 29 seconds
Changes
57
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/config/Config_defaults.h
View file @
1e0015b3
...
...
@@ -63,8 +63,8 @@ typedef size_t aligned_size_t;
// C++11 features
// --------------
#ifndef HAS_CXX11
#define HAS_CXX11 0
#ifndef
AMDIS_
HAS_CXX11
#define
AMDIS_
HAS_CXX11 0
#endif
#ifndef HAS_VARIADIC_TEMPLATES
...
...
AMDiS/src/config/Config_gcc.h
View file @
1e0015b3
...
...
@@ -47,7 +47,7 @@ typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE)));
// C++11 features
// --------------
#if HAS_CXX11
#if
AMDIS_
HAS_CXX11
#if GCC_VERSION >= 40300 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1
...
...
AMDiS/src/config/Config_intel.h
View file @
1e0015b3
...
...
@@ -51,7 +51,7 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t;
// C++11 features
// --------------
#if HAS_CXX11
#if
AMDIS_
HAS_CXX11
#if INTEL_VERSION >= 1201 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1
...
...
AMDiS/src/config/Config_msc.h
View file @
1e0015b3
...
...
@@ -52,6 +52,19 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t;
#define ALWAYS_INLINE __forceinline
#define OPENMODE std::ios::open_mode
#ifdef max
#undef max
#undef min
#endif
#ifdef NONE
#undef NONE
#endif
#ifdef THIS
#undef THIS
#endif
#if MSC_VERSION >= 1800 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1
#endif
...
...
AMDiS/src/io/FileWriter.hh
View file @
1e0015b3
...
...
@@ -233,7 +233,7 @@ namespace AMDiS
if
(
writeParaViewVectorFormat
)
{
io
::
VtkVectorWriter
::
Aux
<
T
>
vtkVectorWriter
(
&
dataCollectors
,
writeAs3dVector
);
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
vtkVectorWriter
.
setCompression
(
compression
);
#endif
vtkVectorWriter
.
writeFile
(
fn
+
paraviewFileExt
);
...
...
AMDiS/src/io/detail/Arh2Reader.cc
View file @
1e0015b3
...
...
@@ -10,7 +10,7 @@
#include
<boost/filesystem.hpp>
#include
<boost/iostreams/filtering_streambuf.hpp>
#include
<boost/iostreams/copy.hpp>
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
#include
<boost/iostreams/filter/zlib.hpp>
#endif
...
...
@@ -242,12 +242,12 @@ namespace AMDiS { namespace io {
if
(
minor
>=
1
)
file
.
read
(
const_cast
<
char
*>
(
cps
.
data
()),
4
);
#if
def HAVE
_COMPRESSION
#if
HAMDIS_HAS
_COMPRESSION
TEST_EXIT
(
cps
==
"null"
||
cps
==
"zlib"
)
(
"Cannot read Arh2 file. Currently only support zlib compression.
\n
"
);
#else
TEST_EXIT
(
cps
==
"null"
)
(
"
HAVE
_COMPRESSION
OFF. Cannot read compressed Arh2 file.
\n
"
);
(
"
AMDIS_HAS
_COMPRESSION
==
OFF. Cannot read compressed Arh2 file.
\n
"
);
#endif
TEST_EXIT
(
dow
==
(
unsigned
)
mesh
->
getGeo
(
WORLD
))
...
...
@@ -371,7 +371,7 @@ namespace AMDiS { namespace io {
file
.
read
(
buffer
,
size
);
dataStream
.
write
(
buffer
,
size
);
delete
[]
buffer
;
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
if
(
cps
==
"zlib"
)
{
stringstream
tmp
(
ios
::
out
|
ios
::
in
);
boost
::
iostreams
::
filtering_streambuf
<
boost
::
iostreams
::
input
>
in
;
...
...
@@ -554,12 +554,12 @@ namespace AMDiS { namespace io {
if
(
minor
>
0
)
file
.
read
(
const_cast
<
char
*>
(
cps
.
data
()),
4
);
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
TEST_EXIT
(
cps
==
"null"
||
cps
==
"zlib"
)
(
"Cannot read Arh2 file. Currently only support zlib compression.
\n
"
);
#else
TEST_EXIT
(
cps
==
"null"
)
(
"
HAVE
_COMPRESSION OFF. Cannot read compressed Arh2 file.
\n
"
);
(
"
AMDIS_HAS
_COMPRESSION OFF. Cannot read compressed Arh2 file.
\n
"
);
#endif
vector
<
int
>
macroElIndex
(
nMacroElements
);
...
...
@@ -600,7 +600,7 @@ namespace AMDiS { namespace io {
dataStream
.
write
(
buffer
,
size
);
delete
[]
buffer
;
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
if
(
cps
==
"zlib"
)
{
stringstream
tmp
(
ios
::
out
|
ios
::
in
);
boost
::
iostreams
::
filtering_streambuf
<
boost
::
iostreams
::
input
>
in
;
...
...
AMDiS/src/io/detail/Arh2Writer.cc
View file @
1e0015b3
...
...
@@ -11,7 +11,7 @@
#include
<boost/iostreams/filtering_streambuf.hpp>
#include
<boost/iostreams/copy.hpp>
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
#include
<boost/iostreams/filter/zlib.hpp>
#endif
...
...
@@ -151,7 +151,7 @@ namespace AMDiS { namespace io {
namesLen
+
//value vector table
nValueVectors
*
8
;
//also value vector table
string
typeId
=
"arh2"
,
cps
(
"null"
);
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
cps
=
"zlib"
;
#endif
uint8_t
*
major
=
const_cast
<
uint8_t
*>
(
&
(
AMDiS
::
io
::
Arh2Writer
::
MAJOR
));
...
...
@@ -426,7 +426,7 @@ namespace AMDiS { namespace io {
}
stringstream
tmp
(
ios
::
out
|
ios
::
in
|
ios
::
binary
);
boost
::
iostreams
::
filtering_streambuf
<
boost
::
iostreams
::
input
>
in
;
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
in
.
push
(
boost
::
iostreams
::
zlib_compressor
());
#endif
in
.
push
(
dataStream
);
...
...
AMDiS/src/io/detail/Arh3Reader.cc
View file @
1e0015b3
...
...
@@ -14,7 +14,7 @@
#include
<boost/filesystem.hpp>
#include
<boost/iostreams/filtering_streambuf.hpp>
#include
<boost/iostreams/copy.hpp>
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
#include
<boost/iostreams/filter/zlib.hpp>
#include
<boost/iostreams/filter/bzip2.hpp>
#endif
...
...
@@ -251,14 +251,14 @@ namespace AMDiS { namespace io {
file
.
read
(
reinterpret_cast
<
char
*>
(
&
cpsflag
),
4
);
cps
=
static_cast
<
Cpsformat
::
Value
>
(
cpsflag
);
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
TEST_EXIT
(
cps
==
Cpsformat
::
ZLIB
||
cps
==
Cpsformat
::
BZIP2
||
cps
==
Cpsformat
::
NONE
)
(
"Cannot read Arh3 file. Currently only support zlib and bzip2 compression.
\n
"
);
#else
TEST_EXIT
(
cps
==
Cpsformat
::
NONE
)
(
"
HAVE
_COMPRESSION OFF. Cannot read compressed Arh3 file.
\n
"
);
(
"
AMDIS_HAS
_COMPRESSION OFF. Cannot read compressed Arh3 file.
\n
"
);
#endif
TEST_EXIT
(
dow
==
(
unsigned
)
mesh
->
getGeo
(
WORLD
))
...
...
@@ -421,7 +421,7 @@ namespace AMDiS { namespace io {
file
.
read
(
buffer
,
size
);
dataStream
.
write
(
buffer
,
size
);
delete
[]
buffer
;
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
stringstream
tmp
(
ios
::
out
|
ios
::
in
);
boost
::
iostreams
::
filtering_streambuf
<
boost
::
iostreams
::
input
>
in
;
switch
(
cps
)
...
...
@@ -649,14 +649,14 @@ namespace AMDiS { namespace io {
file
.
read
(
reinterpret_cast
<
char
*>
(
&
cpsflag
),
4
);
cps
=
static_cast
<
Cpsformat
::
Value
>
(
cpsflag
);
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
TEST_EXIT
(
cps
==
Cpsformat
::
ZLIB
||
cps
==
Cpsformat
::
BZIP2
||
cps
==
Cpsformat
::
NONE
)
(
"Cannot read Arh3 file. Currently only support zlib and bzip2 compression.
\n
"
);
#else
TEST_EXIT
(
cps
==
Cpsformat
::
NONE
)
(
"
HAVE
_COMPRESSION OFF. Cannot read compressed Arh3 file.
\n
"
);
(
"
AMDIS_HAS
_COMPRESSION OFF. Cannot read compressed Arh3 file.
\n
"
);
#endif
vector
<
int
>
macroElIndex
(
nMacroElements
);
...
...
@@ -715,7 +715,7 @@ namespace AMDiS { namespace io {
dataStream
.
write
(
buffer
,
size
);
delete
[]
buffer
;
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
stringstream
tmp
(
ios
::
out
|
ios
::
in
);
boost
::
iostreams
::
filtering_streambuf
<
boost
::
iostreams
::
input
>
in
;
switch
(
cps
)
...
...
AMDiS/src/io/detail/Arh3Writer.cc
View file @
1e0015b3
...
...
@@ -15,7 +15,7 @@
#include
<boost/iostreams/filtering_streambuf.hpp>
#include
<boost/iostreams/device/file_descriptor.hpp>
#include
<boost/iostreams/copy.hpp>
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
#include
<boost/iostreams/filter/zlib.hpp>
#include
<boost/iostreams/filter/bzip2.hpp>
#endif
...
...
@@ -140,7 +140,7 @@ namespace AMDiS { namespace io {
macroFilename
+
';'
+
perFilename
;
macroFile_nl
=
macroFile
.
length
();
}
else
if
(
writeMacro
==
Macroformat
::
THIS
)
{
}
else
if
(
writeMacro
==
Macroformat
::
SELF
)
{
macroFile_nl
=
13
;
readFileToString
(
macroFilename
,
macroData
);
...
...
@@ -163,7 +163,7 @@ namespace AMDiS { namespace io {
}
// write macro and periodic file
if
(
writeMacro
==
Macroformat
::
THIS
&&
macroFilename
.
length
())
{
if
(
writeMacro
==
Macroformat
::
SELF
&&
macroFilename
.
length
())
{
file
.
seekp
(
0
,
ios_base
::
end
);
long
macroPos
=
file
.
tellp
(),
perPos
=
0
;
file
.
write
(
macroData
.
c_str
(),
macroData
.
length
());
...
...
@@ -354,7 +354,7 @@ namespace AMDiS { namespace io {
macroFilename
+
';'
+
perFilename
;
macroFile_nl
=
macroFile
.
length
();
}
else
if
(
writeMacro
==
Macroformat
::
THIS
)
{
}
else
if
(
writeMacro
==
Macroformat
::
SELF
)
{
macroFile_nl
=
perFilename
.
length
()
?
27
:
13
;
macroFile
.
resize
(
macroFile_nl
,
' '
);
}
...
...
@@ -371,7 +371,7 @@ namespace AMDiS { namespace io {
4
+
//macroFile_nl
macroFile_nl
;
//macroFile
string
typeId
=
"sarh"
;
#if
ndef HAVE
_COMPRESSION
#if
!AMDIS_HAS
_COMPRESSION
cps
=
Cpsformat
::
NONE
;
#endif
uint8_t
*
major
=
const_cast
<
uint8_t
*>
(
&
(
AMDiS
::
io
::
Arh3Reader
::
MAJOR
));
...
...
@@ -604,7 +604,7 @@ namespace AMDiS { namespace io {
//reset the macro positions in file
setMacrosPos
(
file
,
headerLen
,
macroSize
);
if
(
writeMacro
==
Macroformat
::
THIS
)
if
(
writeMacro
==
Macroformat
::
SELF
)
setMacroFile
(
file
,
headerLen
,
mesh
,
writeMacro
);
file
.
close
();
...
...
@@ -634,8 +634,8 @@ namespace AMDiS { namespace io {
{
FUNCNAME
(
"setMacroFile()"
);
TEST_EXIT
(
writeMacro
==
Macroformat
::
THIS
)
(
"This function should only be called under Macroformat::
THIS
.
\n
"
);
TEST_EXIT
(
writeMacro
==
Macroformat
::
SELF
)
(
"This function should only be called under Macroformat::
SELF
.
\n
"
);
string
macroFilename
=
""
,
perFilename
=
""
;
string
macroData
=
""
,
periodicData
=
""
;
...
...
@@ -716,7 +716,7 @@ namespace AMDiS { namespace io {
}
stringstream
tmp
(
ios
::
out
|
ios
::
in
|
ios
::
binary
);
boost
::
iostreams
::
filtering_streambuf
<
boost
::
iostreams
::
input
>
in
;
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
switch
(
cps
)
{
case
Cpsformat
::
ZLIB
:
...
...
AMDiS/src/io/detail/Arh3Writer.h
View file @
1e0015b3
...
...
@@ -27,7 +27,7 @@ namespace AMDiS { namespace io {
typedef
enum
{
NONE
=
0
,
// no macro
PT_MACROFILE
=
1
,
// pointer to macro file
THIS
=
2
// pointer to this file, at the end of this file
SELF
=
2
// pointer to this file, at the end of this file
}
Value
;
};
...
...
AMDiS/src/io/detail/VtkReader.h
View file @
1e0015b3
...
...
@@ -32,7 +32,7 @@
#include
<boost/archive/iterators/transform_width.hpp>
#include
<boost/iostreams/filtering_streambuf.hpp>
#include
<boost/iostreams/copy.hpp>
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
#include
<boost/iostreams/filter/zlib.hpp>
#endif
#include
"DOFVector.h"
...
...
@@ -95,7 +95,7 @@ namespace AMDiS
return
result
;
}
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
inline
std
::
string
decompress
(
std
::
string
text
)
{
std
::
stringstream
tmp1
,
tmp2
;
...
...
@@ -120,7 +120,7 @@ namespace AMDiS
string
header
=
""
,
body
=
""
,
data
=
""
;
if
(
zlib
)
{
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
string
s
=
input
.
substr
(
0
,
8
);
if
(
base64
)
s
=
detail
::
base64ToStr
(
s
);
...
...
@@ -151,7 +151,7 @@ namespace AMDiS
offset
+=
*
ptr
;
}
#else
ERROR_EXIT
(
"
HAVE
_COMPRESSION OFF. VtkReader cannot read APPENDED_COMPRESSED vtu files.
\n
"
);
ERROR_EXIT
(
"
AMDIS_HAS
_COMPRESSION OFF. VtkReader cannot read APPENDED_COMPRESSED vtu files.
\n
"
);
#endif
}
else
{
header
=
(
base64
)
?
detail
::
base64ToStr
(
input
)
:
input
;
...
...
AMDiS/src/io/detail/VtkVectorWriter.h
View file @
1e0015b3
...
...
@@ -28,7 +28,7 @@
#include
"io/DataCollector.h"
#include
"SystemVector.h"
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
#include
"io/FileCompression.h"
#endif
...
...
@@ -43,7 +43,7 @@ namespace AMDiS
struct
Aux
{
Aux
(
std
::
vector
<
DataCollector
<
S
>*>
*
dc
,
bool
writeAs3dVector_
=
false
)
:
dataCollector
(
dc
)
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
,
compress
(
NONE
)
#endif
,
writeAs3dVector
(
writeAs3dVector_
)
...
...
@@ -61,7 +61,7 @@ namespace AMDiS
std
::
string
fnPrefix
,
std
::
string
fnPostfix
);
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
/// Set a compressing method for file output.
void
setCompression
(
FileCompression
c
)
{
...
...
@@ -154,7 +154,7 @@ namespace AMDiS
/// List of DataCollectors, for each component of the problem one.
std
::
vector
<
DataCollector
<
S
>*>
*
dataCollector
;
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
/** \brief
* Defines if the file has to be compressed for ouput, and with which
* kind of compress method.
...
...
AMDiS/src/io/detail/VtkVectorWriter.hh
View file @
1e0015b3
...
...
@@ -42,7 +42,7 @@
#include
<boost/iostreams/device/file_descriptor.hpp>
#include
<boost/lexical_cast.hpp>
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
// #include <boost/iostreams/filter/gzip.hpp>
// #include <boost/iostreams/filter/bzip2.hpp>
#endif
...
...
@@ -67,7 +67,7 @@ namespace AMDiS
FUNCNAME
(
"Aux<S>::writeFile()"
);
boost
::
iostreams
::
filtering_ostream
file
;
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
// switch (compress) {
// case GZIP:
// file.push(boost::iostreams::gzip_compressor());
...
...
AMDiS/src/io/detail/VtkWriter.cc
View file @
1e0015b3
...
...
@@ -33,7 +33,7 @@
#include
<boost/iostreams/filtering_stream.hpp>
#include
<boost/iostreams/device/file_descriptor.hpp>
#include
<boost/iostreams/copy.hpp>
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
#include
<boost/iostreams/filter/zlib.hpp>
#endif
#include
"AdaptInfo.h"
...
...
@@ -86,7 +86,7 @@ namespace AMDiS { namespace io {
break
;
}
case
APPENDED_COMPRESSED
:
{
#ifdef
HAVE
_COMPRESSION
#ifdef
AMDIS_HAS
_COMPRESSION
BinaryStream
hstream
;
int
nBlocks
=
bstream
.
getSize
()
/
AMDIS_ZLIB_BLOCK_SIZE
+
1
;
int
finalsize
=
bstream
.
getSize
()
%
AMDIS_ZLIB_BLOCK_SIZE
;
...
...
@@ -232,7 +232,7 @@ namespace AMDiS { namespace io {
FUNCNAME
(
"writeParallelFile()"
);
using
boost
::
lexical_cast
;
#ifndef
HAVE
_COMPRESSION
#ifndef
AMDIS_HAS
_COMPRESSION
if
(
format
==
APPENDED_COMPRESSED
)
format
=
APPENDED
;
#endif
...
...
AMDiS/src/io/detail/VtkWriter.h
View file @
1e0015b3
...
...
@@ -119,11 +119,11 @@ namespace AMDiS { namespace io {
bstream
(
hp
),
writeAsVector
(
writeAsVector_
)
{
#ifndef
HAVE
_COMPRESSION
#ifndef
AMDIS_HAS
_COMPRESSION
FUNCNAME
(
"VtkWriter::Aux::Aux()"
);
if
(
f
==
APPENDED_COMPRESSED
)
{
f
=
APPENDED
;
WARNING
(
"
HAVE
_COMPRESSION OFF. So vtuformat is automatically changed from APPENDED_COMPRESSED to APPENDED.
\n
"
);
WARNING
(
"
AMDIS_HAS
_COMPRESSION OFF. So vtuformat is automatically changed from APPENDED_COMPRESSED to APPENDED.
\n
"
);
}
#endif
degree
=
(
*
dataCollector
)[
0
]
->
getFeSpace
()
->
getBasisFcts
()
->
getDegree
();
...
...
AMDiS/src/parallel/PetscHelper.cc
View file @
1e0015b3
...
...
@@ -304,16 +304,12 @@ namespace AMDiS
PCSetFromOptions
(
pc
);
#ifndef NDEBUG
MSG
(
"PetscOptionsView:
\n
"
);
PetscViewer
viewer
;
PetscViewerCreate
(
PETSC_COMM_WORLD
,
&
viewer
);
PetscViewerSetType
(
viewer
,
PETSCVIEWERASCII
);
#if (PETSC_VERSION_MINOR >= 7)
PetscOptionsView
(
PETSC_NULL
,
viewer
);
#else
PetscOptionsView
(
viewer
);
#endif
PetscViewerDestroy
(
&
viewer
);
MSG
(
"PetscOptionsView:
\n
"
);
PetscViewer
viewer
;
PetscViewerCreate
(
PETSC_COMM_WORLD
,
&
viewer
);
PetscViewerSetType
(
viewer
,
PETSCVIEWERASCII
);
petsc
::
options_view
(
viewer
);
PetscViewerDestroy
(
&
viewer
);
#endif
}
...
...
@@ -334,19 +330,15 @@ namespace AMDiS
void
createSolver
(
MPI
::
Intracomm
comm
,
KSP
&
ksp
,
Mat
m
,
std
::
string
kspPrefix
,
int
info
)
{
KSPCreate
(
comm
,
&
ksp
);
#if (PETSC_VERSION_MINOR >= 5)
KSPSetOperators
(
ksp
,
m
,
m
);
#else
KSPSetOperators
(
ksp
,
m
,
m
,
SAME_NONZERO_PATTERN
);
#endif
petsc
::
ksp_set_operators
(
ksp
,
m
,
m
);
KSPSetTolerances
(
ksp
,
0.0
,
1e-8
,
PETSC_DEFAULT
,
PETSC_DEFAULT
);
KSPSetType
(
ksp
,
KSPBCGS
);
KSPSetOptionsPrefix
(
ksp
,
kspPrefix
.
c_str
());
if
(
info
>=
10
)
KSPM
onitor
S
et
(
ksp
,
PETSC_MONITOR_CAST
(
KSPMonitorDefault
),
PETSC_NULL
,
PETSC_NULL
);
petsc
::
ksp_m
onitor
_s
et
(
ksp
,
KSPMonitorDefault
);
else
if
(
info
>=
20
)
KSPM
onitor
S
et
(
ksp
,
PETSC_MONITOR_CAST
(
KSPMonitorTrueResidualNorm
)
,
PETSC_NULL
,
PETSC_NULL
)
;
petsc
::
ksp_m
onitor
_s
et
(
ksp
,
KSPMonitorTrueResidualNorm
);
}
}
// end namespace petsc_helper
...
...
AMDiS/src/parallel/PetscHelper.h
View file @
1e0015b3
...
...
@@ -31,13 +31,6 @@
#include
<petsc.h>
#include
"AMDiS_fwd.h"
#if (PETSC_VERSION_MINOR >= 7)
#define PETSC_MONITOR_CAST(...) \
(PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*))(__VA_ARGS__)
#else
#define PETSC_MONITOR_CAST(...) __VA_ARGS__
#endif
namespace
AMDiS
{
namespace
Parallel
...
...
@@ -126,7 +119,82 @@ namespace AMDiS
void
createSolver
(
MPI
::
Intracomm
comm
,
KSP
&
ksp
,
Mat
m
,
std
::
string
kspPrefix
=
""
,
int
info
=
0
);
}
// end namespace petsc_helper
}
// end namespace Parallel
// functions for PETSc API changes
namespace
petsc
{
inline
PetscErrorCode
options_view
(
PetscViewer
viewer
)
{
#if (PETSC_VERSION_MINOR >= 7)
return
PetscOptionsView
(
PETSC_NULL
,
viewer
);
#else
return
PetscOptionsView
(
viewer
);
#endif
}
inline
PetscErrorCode
options_insert_string
(
const
char
in_str
[])
{
#if (PETSC_VERSION_MINOR >= 7)
return
PetscOptionsInsertString
(
PETSC_NULL
,
in_str
);
#else
return
PetscOptionsInsertString
(
in_str
);
#endif
}
inline
PetscErrorCode
ksp_set_operators
(
KSP
ksp
,
Mat
Amat
,
Mat
Pmat
)
{
#if (PETSC_VERSION_MINOR >= 5)
return
KSPSetOperators
(
ksp
,
Amat
,
Pmat
);
#else
return
KSPSetOperators
(
ksp
,
Amat
,
Pmat
,
SAME_NONZERO_PATTERN
);
#endif
}
inline
PetscErrorCode
ksp_get_operators
(
KSP
ksp
,
Mat
*
Amat
,
Mat
*
Pmat
)
{
#if (PETSC_VERSION_MINOR >= 5)
return
KSPGetOperators
(
ksp
,
Amat
,
Pmat
);
#else
return
KSPGetOperators
(
ksp
,
Amat
,
Pmat
,
SAME_NONZERO_PATTERN
);
#endif
}
template
<
class
Monitor
>
inline
PetscErrorCode
ksp_monitor_set
(
KSP
ksp
,
Monitor
monitor
)
{
#if (PETSC_VERSION_MINOR >= 7)
PetscViewerAndFormat
*
vf
;
PetscErrorCode
ierr
;
ierr
=
PetscViewerAndFormatCreate
(
PETSC_VIEWER_STDOUT_WORLD
,
PETSC_VIEWER_DEFAULT
,
&
vf
);
CHKERRQ
(
ierr
);
ierr
=
KSPMonitorSet
(
ksp
,(
PetscErrorCode
(
*
)(
KSP
,
PetscInt
,
PetscReal
,
void
*
))
monitor
,
vf
,(
PetscErrorCode
(
*
)(
void
**
))
PetscViewerAndFormatDestroy
);
CHKERRQ
(
ierr
);
return
ierr
;
#else
return
KSPMonitorSet
(
ksp
,
monitor
,
PETSC_NULL
,
PETSC_NULL
);
#endif
}
inline
PetscErrorCode
mat_create_vecs
(
Mat
mat
,
Vec
*
right
,
Vec
*
left
)
{
#if (PETSC_VERSION_MINOR >= 6)
return
MatCreateVecs
(
mat
,
right
,
left
);
#else
return
MatGetVecs
(
mat
,
right
,
left
);
#endif
}
inline
PetscErrorCode
mat_nullspace_remove
(
MatNullSpace
sp
,
Vec
vec
)
{
#if (PETSC_VERSION_MINOR >= 5)
return
MatNullSpaceRemove
(
sp
,
vec
);
#else
return
MatNullSpaceRemove
(
sp
,
vec
,
PETSC_NULL
);
#endif
}
}
// end namespace petsc
}
// end namespace AMDiS
#endif
AMDiS/src/parallel/PetscSolver.cc
View file @
1e0015b3
...
...
@@ -26,6 +26,7 @@
#include
"parallel/MeshDistributor.h"
#include
"parallel/MpiHelper.h"
#include
"parallel/ParallelDofMapping.h"
#include
"parallel/PetscHelper.h"
#include
"parallel/PetscSolver.h"
#include
"parallel/StdMpi.h"
...
...
@@ -49,7 +50,7 @@ namespace AMDiS { namespace Parallel {
Parameters
::
get
(
name
+
"->ksp"
,
kspStr
);
if
(
kspStr
!=
""
)
petsc
_
options_insert_string
(
kspStr
.
c_str
());
petsc
::
options_insert_string
(
kspStr
.
c_str
());
Parameters
::
get
(
name
+
"->remove rhs null space"
,
removeRhsNullspace
);
Parameters
::
get
(
name
+
"->has constant null space"
,
hasConstantNullspace
);
...
...
AMDiS/src/parallel/PetscSolverCahnHilliard.cc
View file @
1e0015b3
...
...
@@ -85,15 +85,11 @@ namespace AMDiS { namespace Parallel {
{
// Create FGMRES based outer solver
KSPCreate
(
meshDistributor
->
getMpiComm
(
0
),
&
ksp
);
#if (PETSC_VERSION_MINOR >= 5)
KSPSetOperators
(
ksp
,
getMatInterior
(),
getMatInterior
());
#else
KSPSetOperators
(
ksp
,
getMatInterior
(),
getMatInterior
(),
SAME_NONZERO_PATTERN
);
#endif
petsc
::
ksp_set_operators
(
ksp
,
getMatInterior
(),
getMatInterior
());
if
(
getInfo
()
>=
10
)
KSPM
onitor
S
et
(
ksp
,
PETSC_MONITOR_CAST
(
KSPMonitorDefault
),
PETSC_NULL
,
PETSC_NULL
);
petsc
::
ksp_m
onitor
_s
et
(
ksp
,
KSPMonitorDefault
);
else
if
(
getInfo
()
>=
20
)
KSPM
onitor
S
et
(
ksp
,
PETSC_MONITOR_CAST
(
KSPMonitorTrueResidualNorm
)
,
PETSC_NULL
,
PETSC_NULL
)
;
petsc
::
ksp_m
onitor
_s
et
(
ksp
,
KSPMonitorTrueResidualNorm
);
petsc_helper
::
setSolver
(
ksp
,
"ch_"
,
KSPFGMRES
,
PCNONE
,
getRelative
(),
getTolerance
(),
getMaxIterations
());
KSPSetFromOptions
(
ksp
);
...
...
AMDiS/src/parallel/PetscSolverCahnHilliard2.cc
View file @
1e0015b3
...
...
@@ -67,11 +67,7 @@ namespace AMDiS { namespace Parallel {
/// create new solver for S
KSP
kspS
;
KSPCreate
(
*
data
->
mpiCommGlobal
,
&
kspS
);
#if (PETSC_VERSION_MINOR >= 5)
KSPSetOperators
(
kspS
,
S
,
S
);
#else
KSPSetOperators
(
kspS
,
S
,
S
,
SAME_NONZERO_PATTERN
);
#endif
petsc
::
ksp_set_operators
(
kspS
,
S
,
S
);
petsc_helper
::
setSolver
(
kspS
,
"S_"
,
KSPFGMRES
,
PCSHELL
,
1e-6
,
1e-8
,
1
);
{
PC
pc
;
...
...
@@ -117,15 +113,11 @@ namespace AMDiS { namespace Parallel {