Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
O
openfpm_numerics
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openfpm
openfpm_numerics
Commits
58c0aea7
Commit
58c0aea7
authored
Jun 30, 2017
by
incardon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes on AMG + documentation + AMG report
parent
43a521cb
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
642 additions
and
194 deletions
+642
-194
src/FiniteDifference/Derivative.hpp
src/FiniteDifference/Derivative.hpp
+1
-5
src/FiniteDifference/FDScheme_unit_tests.hpp
src/FiniteDifference/FDScheme_unit_tests.hpp
+28
-20
src/FiniteDifference/Laplacian.hpp
src/FiniteDifference/Laplacian.hpp
+3
-0
src/FiniteDifference/eq_unit_test_3d.hpp
src/FiniteDifference/eq_unit_test_3d.hpp
+1
-2
src/Makefile.am
src/Makefile.am
+1
-1
src/Matrix/SparseMatrix_petsc.hpp
src/Matrix/SparseMatrix_petsc.hpp
+11
-4
src/Solvers/petsc_solver.hpp
src/Solvers/petsc_solver.hpp
+553
-146
src/Solvers/umfpack_solver.hpp
src/Solvers/umfpack_solver.hpp
+10
-2
src/Vector/Vector_petsc.hpp
src/Vector/Vector_petsc.hpp
+32
-13
src/util/petsc_util.hpp
src/util/petsc_util.hpp
+2
-1
No files found.
src/FiniteDifference/Derivative.hpp
View file @
58c0aea7
...
...
@@ -8,11 +8,6 @@
#ifndef OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_DERIVATIVE_HPP_
#define OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_DERIVATIVE_HPP_
#define CENTRAL 0
#define CENTRAL_B_ONE_SIDE 1
#define FORWARD 2
#define BACKWARD 3
#define CENTRAL_SYM 4
#include "util/mathutil.hpp"
#include "Vector/map_vector.hpp"
...
...
@@ -20,6 +15,7 @@
#include "FiniteDifference/util/common.hpp"
#include "util/util_num.hpp"
#include <unordered_map>
#include "FD_util_include.hpp"
/*! \brief Derivative second order on h (spacing)
*
...
...
src/FiniteDifference/FDScheme_unit_tests.hpp
View file @
58c0aea7
...
...
@@ -23,21 +23,23 @@ constexpr unsigned int V = 0;
struct
sys_nn
{
// dimensionaly of the equation (2D problem 3D problem ...)
//
!
dimensionaly of the equation (2D problem 3D problem ...)
static
const
unsigned
int
dims
=
2
;
//
number of fields in the system
//
! number of degree of freedoms
static
const
unsigned
int
nvar
=
1
;
static
const
unsigned
int
ord
=
EQS_FIELD
;
// boundary at X and Y
//
!
boundary at X and Y
static
const
bool
boundary
[];
// type of space float, double, ...
//
!
type of space float, double, ...
typedef
float
stype
;
// Base grid
//
!
Base grid
typedef
grid_dist_id
<
dims
,
stype
,
scalar
<
float
>
,
CartDecomposition
<
2
,
stype
>
>
b_grid
;
//! specify that we are on testing
typedef
void
testing
;
};
...
...
@@ -45,21 +47,22 @@ const bool sys_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC};
struct
sys_pp
{
// dimensionaly of the equation (2D problem 3D problem ...)
//
!
dimensionaly of the equation (2D problem 3D problem ...)
static
const
unsigned
int
dims
=
2
;
//
number of fields
in the system
//
! number of degree of freedom
in the system
static
const
unsigned
int
nvar
=
1
;
static
const
unsigned
int
ord
=
EQS_FIELD
;
// boundary at X and Y
//
!
boundary at X and Y
static
const
bool
boundary
[];
// type of space float, double, ...
//
!
type of space float, double, ...
typedef
float
stype
;
// Base grid
//
!
Base grid
typedef
grid_dist_id
<
dims
,
stype
,
scalar
<
float
>
,
CartDecomposition
<
2
,
stype
>
>
b_grid
;
//! Indicate we are on testing
typedef
void
testing
;
};
...
...
@@ -69,23 +72,26 @@ const bool sys_pp::boundary[] = {PERIODIC,PERIODIC};
struct
syss_nn
{
// dimensionaly of the equation (2D problem 3D problem ...)
//
!
dimensionaly of the equation (2D problem 3D problem ...)
static
const
unsigned
int
dims
=
2
;
//
number of fields
in the system
//
! Degree of freedom
in the system
static
const
unsigned
int
nvar
=
1
;
static
const
unsigned
int
ord
=
EQS_FIELD
;
//! Indicate that the type of grid is staggered
static
const
unsigned
int
grid_type
=
STAGGERED_GRID
;
// boundary at X and Y
//
!
boundary at X and Y
static
const
bool
boundary
[];
// type of space float, double, ...
//
!
type of space float, double, ...
typedef
float
stype
;
// Base grid
//
!
Base grid
typedef
grid_dist_id
<
dims
,
stype
,
scalar
<
float
>
,
CartDecomposition
<
2
,
stype
>
>
b_grid
;
//! Indicate we are on testing
typedef
void
testing
;
};
...
...
@@ -93,23 +99,25 @@ const bool syss_nn::boundary[] = {NON_PERIODIC,NON_PERIODIC};
struct
syss_pp
{
// dimensionaly of the equation (2D problem 3D problem ...)
//
!
dimensionaly of the equation (2D problem 3D problem ...)
static
const
unsigned
int
dims
=
2
;
// number of fields in the system
//
!
number of fields in the system
static
const
unsigned
int
nvar
=
1
;
static
const
unsigned
int
ord
=
EQS_FIELD
;
//! Indicate the grid is staggered
static
const
unsigned
int
grid_type
=
STAGGERED_GRID
;
// boundary at X and Y
//
!
boundary at X and Y
static
const
bool
boundary
[];
// type of space float, double, ...
//
!
type of space float, double, ...
typedef
float
stype
;
// Base grid
//
!
Base grid
typedef
grid_dist_id
<
dims
,
stype
,
scalar
<
float
>
,
CartDecomposition
<
2
,
stype
>
>
b_grid
;
//! Indicate we are on testing
typedef
void
testing
;
};
...
...
src/FiniteDifference/Laplacian.hpp
View file @
58c0aea7
...
...
@@ -8,6 +8,9 @@
#ifndef OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_LAPLACIAN_HPP_
#define OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_LAPLACIAN_HPP_
#include "FD_util_include.hpp"
#include "util/util_num.hpp"
#include "FiniteDifference/eq.hpp"
/*! \brief Laplacian second order on h (spacing)
*
...
...
src/FiniteDifference/eq_unit_test_3d.hpp
View file @
58c0aea7
...
...
@@ -193,8 +193,7 @@ template<typename solver_type,typename lid_nn_3d> void lid_driven_cavity_3d()
fd
.
impose
(
v_z
(),
0.0
,
EQ_3
,
{
-
1
,
-
1
,
-
1
},{
sz
[
0
]
-
1
,
sz
[
1
]
-
1
,
-
1
});
solver_type
solver
;
solver
.
best_solve
();
auto
x
=
solver
.
solve
(
fd
.
getA
(),
fd
.
getB
());
auto
x
=
solver
.
try_solve
(
fd
.
getA
(),
fd
.
getB
());
// Bring the solution to grid
fd
.
template
copy
<
velocity
,
pressure
>(
x
,{
0
,
0
},{
sz
[
0
]
-
1
,
sz
[
1
]
-
1
,
sz
[
2
]
-
1
},
g_dist
);
...
...
src/Makefile.am
View file @
58c0aea7
...
...
@@ -2,7 +2,7 @@
LINKLIBS
=
$(HDF5_LDFLAGS)
$(HDF5_LIBS)
$(OPENMP_LDFLAGS)
$(LIBHILBERT_LIB)
$(PETSC_LIB)
$(SUITESPARSE_LIBS)
$(LAPACK_LIBS)
$(BLAS_LIBS)
$(METIS_LIB)
$(PARMETIS_LIB)
$(DEFAULT_LIB)
$(PTHREAD_LIBS)
$(OPT_LIBS)
$(BOOST_LDFLAGS)
$(BOOST_PROGRAM_OPTIONS_LIB)
$(BOOST_IOSTREAMS_LIB)
$(LIBQUADMATH)
$(OPENMP_LDFLAGS)
$(LIBIFCORE)
noinst_PROGRAMS
=
numerics
numerics_SOURCES
=
main.cpp ../../openfpm_vcluster/src/VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp
numerics_SOURCES
=
main.cpp
Solvers/petsc_solver_unit_tests.cpp
../../openfpm_vcluster/src/VCluster/VCluster.cpp ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp
numerics_CXXFLAGS
=
$(HDF5_CPPFLAGS)
$(OPENMP_CFLAGS)
$(LIBHILBERT_INCLUDE)
$(AM_CXXFLAGS)
$(INCLUDES_PATH)
$(BOOST_CPPFLAGS)
$(SUITESPARSE_INCLUDE)
$(METIS_INCLUDE)
$(PARMETIS_INCLUDE)
$(EIGEN_INCLUDE)
$(PETSC_INCLUDE)
-Wno-deprecated-declarations
-Wno-unused-local-typedefs
numerics_CFLAGS
=
$(CUDA_CFLAGS)
numerics_LDADD
=
$(LINKLIBS)
-lparmetis
-lmetis
...
...
src/Matrix/SparseMatrix_petsc.hpp
View file @
58c0aea7
...
...
@@ -83,7 +83,7 @@ public:
triplet
()
{};
};
/*
! \brief Sparse Matrix implementation, that map over Eigen
/*! \brief Sparse Matrix implementation, that map over Eigen
*
* \tparam T Type of the sparse Matrix store on each row,colums
* \tparam id_t type of id
...
...
@@ -194,6 +194,8 @@ private:
PETSC_SAFE_CALL
(
MatAssemblyBegin
(
mat
,
MAT_FINAL_ASSEMBLY
));
PETSC_SAFE_CALL
(
MatAssemblyEnd
(
mat
,
MAT_FINAL_ASSEMBLY
));
m_created
=
true
;
}
...
...
@@ -207,7 +209,7 @@ public:
*
*/
SparseMatrix
(
size_t
N1
,
size_t
N2
,
size_t
n_row_local
)
:
l_row
(
n_row_local
),
l_col
(
n_row_local
)
:
g_row
(
N1
),
g_col
(
N2
),
l_row
(
n_row_local
),
l_col
(
n_row_local
)
{
PETSC_SAFE_CALL
(
MatCreate
(
PETSC_COMM_WORLD
,
&
mat
));
PETSC_SAFE_CALL
(
MatSetType
(
mat
,
MATMPIAIJ
));
...
...
@@ -230,6 +232,7 @@ public:
*
*/
SparseMatrix
()
:
g_row
(
0
),
g_col
(
0
),
l_row
(
0l
),
l_col
(
0
),
start_row
(
0
)
{
PETSC_SAFE_CALL
(
MatCreate
(
PETSC_COMM_WORLD
,
&
mat
));
PETSC_SAFE_CALL
(
MatSetType
(
mat
,
MATMPIAIJ
));
...
...
@@ -251,6 +254,8 @@ public:
*/
openfpm
::
vector
<
triplet_type
>
&
getMatrixTriplets
()
{
m_created
=
false
;
return
this
->
trpl
;
}
...
...
@@ -261,7 +266,8 @@ public:
*/
const
Mat
&
getMat
()
const
{
fill_petsc
();
if
(
m_created
==
false
)
{
fill_petsc
();}
return
mat
;
}
...
...
@@ -273,7 +279,8 @@ public:
*/
Mat
&
getMat
()
{
fill_petsc
();
if
(
m_created
==
false
)
{
fill_petsc
();}
return
mat
;
}
...
...
src/Solvers/petsc_solver.hpp
View file @
58c0aea7
This diff is collapsed.
Click to expand it.
src/Solvers/umfpack_solver.hpp
View file @
58c0aea7
...
...
@@ -46,11 +46,19 @@ class umfpack_solver<double>
public:
/*! \brief No nothing
/*! \brief Here we invert the matrix and solve the system
*
* \warning umfpack is not a parallel solver, this function work only with one processor
*
* \note if you want to use umfpack in a NON parallel, but on a distributed data, use solve with triplet
*
* \tparam impl Implementation of the SparseMatrix
*
*/
void
best_solve
()
{};
static
Vector
<
double
,
EIGEN_BASE
>
try_solve
(
SparseMatrix
<
double
,
int
,
EIGEN_BASE
>
&
A
,
const
Vector
<
double
,
EIGEN_BASE
>
&
b
,
size_t
opt
=
UMFPACK_NONE
)
{
return
solve
(
A
,
b
,
opt
);
}
/*! \brief Here we invert the matrix and solve the system
*
...
...
src/Vector/Vector_petsc.hpp
View file @
58c0aea7
...
...
@@ -9,6 +9,7 @@
#define OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_PETSC_HPP_
#include "Vector/map_vector.hpp"
#include "Vector/vector_def.hpp"
#include <boost/mpl/int.hpp>
#include <petscvec.h>
#include "util/petsc_util.hpp"
...
...
@@ -32,18 +33,30 @@ public:
//! structure that store the data of the point
type
data
;
//! Property id
of the point
//! Property id
for the row
static
const
unsigned
int
row
=
0
;
//! Property id for the value
static
const
unsigned
int
value
=
1
;
//! This object has 2 properties
static
const
unsigned
int
max_prop
=
2
;
// Get the row
/*! \brief Get the row
*
* \return the row
*
*/
long
int
&
rw
()
{
return
boost
::
fusion
::
at_c
<
row
>
(
data
);
}
// Get the value
/*! \brief Get the value
*
* \return the value
*
*/
T
&
val
()
{
return
boost
::
fusion
::
at_c
<
value
>
(
data
);
...
...
@@ -54,7 +67,7 @@ public:
*/
rval
()
{}
/*! \brief Constructor from row, colum and value
/*! \brief Constructor from row, colum
n
and value
*
* \param i row
* \param val value
...
...
@@ -70,28 +83,34 @@ public:
constexpr
unsigned
int
row_id
=
0
;
constexpr
unsigned
int
val_id
=
1
;
/*! \brief PETSC vector for linear algebra
*
* This vector wrap the PETSC vector for solving linear systems
*
*/
template
<
typename
T
>
class
Vector
<
T
,
PETSC_BASE
>
{
//
n_row
//
! Number of row the petsc vector has
size_t
n_row
;
// Number of local rows
//
!
Number of local rows
size_t
n_row_local
;
// Indicate if v has been allocated
bool
v_created
=
false
;
//
!
Indicate if v has been allocated
mutable
bool
v_created
=
false
;
// Mutable vector
//
!
Mutable vector
mutable
Vec
v
;
// Mutable row value vector
//
!
Mutable row value vector
mutable
openfpm
::
vector
<
rval
<
PetscScalar
,
PETSC_RVAL
>
,
HeapMemory
,
typename
memory_traits_inte
<
rval
<
PetscScalar
,
PETSC_RVAL
>>::
type
>
row_val
;
// Global to local map
//
!
Global to local map
mutable
std
::
unordered_map
<
size_t
,
size_t
>
map
;
// invalid
//
!
invalid
T
invalid
;
/*! \brief Set the Eigen internal vector
...
...
@@ -112,7 +131,7 @@ class Vector<T,PETSC_BASE>
PETSC_SAFE_CALL
(
VecAssemblyBegin
(
v
));
PETSC_SAFE_CALL
(
VecAssemblyEnd
(
v
));
v_created
=
true
;
}
public:
...
...
src/util/petsc_util.hpp
View file @
58c0aea7
...
...
@@ -15,7 +15,8 @@
if (err != 0) {\
std::string msg("Petsc error: ");\
msg += std::string(__FILE__) + std::string(" ") + std::to_string(__LINE__);\
PetscError(MPI_COMM_WORLD,__LINE__,__FUNCT__,__FILE__,err,PETSC_ERROR_INITIAL,"Error petsc");\
PetscInt ln = __LINE__;\
PetscError(MPI_COMM_WORLD,ln,__FUNCT__,__FILE__,err,PETSC_ERROR_INITIAL,"Error petsc");\
}\
}
...
...
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