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
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
argupta
openfpm_numerics
Commits
3385f02c
Commit
3385f02c
authored
Nov 11, 2015
by
incardon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addimg METIS detection
parent
70629390
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
210 additions
and
182 deletions
+210
-182
m4/immdx_lib_metis.m4
m4/immdx_lib_metis.m4
+82
-0
src/FiniteDifference/Derivative.hpp
src/FiniteDifference/Derivative.hpp
+8
-7
src/FiniteDifference/FDScheme.hpp
src/FiniteDifference/FDScheme.hpp
+13
-6
src/FiniteDifference/FDScheme_unit_tests.hpp
src/FiniteDifference/FDScheme_unit_tests.hpp
+44
-160
src/FiniteDifference/Laplacian.hpp
src/FiniteDifference/Laplacian.hpp
+2
-2
src/FiniteDifference/eq.hpp
src/FiniteDifference/eq.hpp
+4
-1
src/FiniteDifference/eq_unit_test.hpp
src/FiniteDifference/eq_unit_test.hpp
+3
-3
src/FiniteDifference/sum.hpp
src/FiniteDifference/sum.hpp
+4
-3
src/util/grid_dist_testing.hpp
src/util/grid_dist_testing.hpp
+50
-0
No files found.
m4/immdx_lib_metis.m4
0 → 100644
View file @
3385f02c
AC_DEFUN([IMMDX_LIB_METIS], [
AC_MSG_CHECKING(for METIS library)
AC_REQUIRE([AC_PROG_CC])
#
# User hints...
#
AC_ARG_VAR([METIS], [METIS library location])
AC_ARG_WITH([metis],
[AC_HELP_STRING([--with-metis],
[user defined path to METIS library])],
[
if test -n "$METIS" ; then
AC_MSG_RESULT(yes)
with_metis=$METIS
elif test "$withval" != no ; then
AC_MSG_RESULT(yes)
with_metis=$withval
else
AC_MSG_RESULT(no)
fi
],
[
if test -n "$METIS" ; then
with_metis=$METIS
AC_MSG_RESULT(yes)
else
with_metis=/usr
if test ! -f "$with_metis/include/metis.h" ; then
with_metis=/usr/local
if test ! -f "$with_metis/include/metis.h" ; then
with_metis=""
AC_MSG_RESULT(failed)
else
AC_MSG_RESULT(yes)
fi
else
AC_MSG_RESULT(yes)
fi
fi
])
#
# locate METIS library
#
if test -n "$with_metis" ; then
old_CFLAGS=$CFLAGS
old_LDFLAGS=$LDFLAGS
CFLAGS="-I$with_metis/include"
LDFLAGS="-L$with_metis/lib"
AC_LANG_SAVE
AC_LANG_C
AC_CHECK_LIB(metis, METIS_PartMeshDual,
[metis_lib=yes], [metis_lib=yes], [-lm])
AC_CHECK_HEADER(metis.h, [metis_h=yes],
[metis_h=no], [/* check */])
AC_LANG_RESTORE
CFLAGS=$old_CFLAGS
LDFLAGS=$old_LDFLAGS
AC_MSG_CHECKING(METIS in $with_metis)
if test "$metis_lib" = "yes" -a "$metis_h" = "yes" ; then
AC_SUBST(METIS_INCLUDE, [-I$with_metis/include])
AC_SUBST(METIS_LIB, [-L$with_metis/lib])
AC_MSG_RESULT(ok)
else
AC_MSG_RESULT(failed)
fi
fi
#
#
#
if test x = x"$METIS_LIB" ; then
ifelse([$2],,[AC_MSG_ERROR(Failed to find valid METIS library)],[$2])
:
else
ifelse([$1],,[AC_DEFINE(HAVE_METIS,1,[Define if you have METIS library])],[$1])
:
fi
])dnl IMMDX_LIB_METIS
src/FiniteDifference/Derivative.hpp
View file @
3385f02c
...
...
@@ -16,6 +16,7 @@
#include "Vector/map_vector.hpp"
#include "Grid/comb.hpp"
#include "FiniteDifference/util/common.hpp"
#include "util/util_num.hpp"
/*! \brief Derivative second order on h (spacing)
*
...
...
@@ -62,7 +63,7 @@ class D<d,arg,Sys_eqs,CENTRAL>
*
*
*/
inline
static
void
value
(
const
grid_dist_id
<
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
scalar
<
size_t
>
,
typename
Sys_eqs
::
b_grid
::
decomposition
>
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
inline
static
void
value
(
const
typename
stub_or_real
<
Sys_eqs
,
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
typename
Sys_eqs
::
b_grid
::
decomposition
>::
type
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
{
// if the system is staggered the CENTRAL derivative is equivalent to a forward derivative
if
(
is_grid_staggered
<
Sys_eqs
>::
value
()
==
true
)
...
...
@@ -133,7 +134,7 @@ public:
*
*
*/
static
void
value
(
const
grid_dist_id
<
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
scalar
<
size_t
>
,
typename
Sys_eqs
::
b_grid
::
decomposition
>
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
static
void
value
(
const
typename
stub_or_real
<
Sys_eqs
,
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
typename
Sys_eqs
::
b_grid
::
decomposition
>::
type
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
{
#ifdef SE_CLASS1
if
(
Sys_eqs
::
boundary
[
d
]
==
PERIODIC
)
...
...
@@ -144,7 +145,7 @@ public:
if
(
pos
.
get
(
d
)
==
(
long
int
)
gs
.
size
(
d
)
-
1
)
{
arg
::
value
(
pos
,
gs
,
cols
,
1.5
*
coeff
);
arg
::
value
(
g_map
,
kmap
,
gs
,
cols
,
1.5
*
coeff
);
long
int
old_val
=
kmap
.
getKeyRef
().
get
(
d
);
kmap
.
getKeyRef
().
set_d
(
d
,
kmap
.
getKeyRef
().
get
(
d
)
-
1
);
...
...
@@ -152,13 +153,13 @@ public:
kmap
.
getKeyRef
().
set_d
(
d
,
old_val
);
old_val
=
kmap
.
getKeyRef
().
get
(
d
);
pos
.
set_d
(
d
,
kmap
.
getKeyRef
().
get
(
d
)
-
2
);
kmap
.
getKeyRef
()
.
set_d
(
d
,
kmap
.
getKeyRef
().
get
(
d
)
-
2
);
arg
::
value
(
g_map
,
kmap
,
gs
,
cols
,
0.5
*
coeff
);
kmap
.
getKeyRef
().
set_d
(
d
,
old_val
);
}
else
if
(
pos
.
get
(
d
)
==
0
)
{
arg
::
value
(
pos
,
gs
,
cols
,
-
1.5
*
coeff
);
arg
::
value
(
g_map
,
kmap
,
gs
,
cols
,
-
1.5
*
coeff
);
long
int
old_val
=
kmap
.
getKeyRef
().
get
(
d
);
kmap
.
getKeyRef
().
set_d
(
d
,
kmap
.
getKeyRef
().
get
(
d
)
+
1
);
...
...
@@ -166,7 +167,7 @@ public:
kmap
.
getKeyRef
().
set_d
(
d
,
old_val
);
old_val
=
kmap
.
getKeyRef
().
get
(
d
);
pos
.
set_d
(
d
,
kmap
.
getKeyRef
().
get
(
d
)
+
2
);
kmap
.
getKeyRef
()
.
set_d
(
d
,
kmap
.
getKeyRef
().
get
(
d
)
+
2
);
arg
::
value
(
g_map
,
kmap
,
gs
,
cols
,
-
0.5
*
coeff
);
kmap
.
getKeyRef
().
set_d
(
d
,
old_val
);
}
...
...
@@ -229,7 +230,7 @@ class D<d,arg,Sys_eqs,FORWARD>
*
*
*/
inline
static
void
value
(
const
grid_dist_id
<
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
scalar
<
size_t
>
,
typename
Sys_eqs
::
b_grid
::
decomposition
>
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
inline
static
void
value
(
const
typename
stub_or_real
<
Sys_eqs
,
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
typename
Sys_eqs
::
b_grid
::
decomposition
>::
type
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
{
long
int
old_val
=
kmap
.
getKeyRef
().
get
(
d
);
...
...
src/FiniteDifference/FDScheme.hpp
View file @
3385f02c
...
...
@@ -17,8 +17,8 @@
/*! \brief Finite Differences
*
* This class is able to discreatize on a Matrix any operator. In order to create a consistent
* Matrix it is required that each processor must contain a contiguo
i
s range on grid points without
* hole. In order to ensure this, each processor produce a contiguos local labelling of its local
* Matrix it is required that each processor must contain a contiguos range on grid points without
* hole
s
. In order to ensure this, each processor produce a contiguos local labelling of its local
* points. Each processor also add an offset equal to the number of local
* points of the processors with id smaller than him, to produce a global and non overlapping
* labelling. An example is shown in the figures down, here we have
...
...
@@ -142,6 +142,16 @@ class FDScheme
}
}
/*! \brief Convert from integer ghost to continuos
*
* \return the continuos version of the ghost
*
*/
Ghost
<
dim
,
Sys_eqs
::
stype
>
convert_into_cg
()
{
}
public:
/*! \brief Constructor
...
...
@@ -151,7 +161,7 @@ public:
*
*/
FDScheme
(
Padding
<
Sys_eqs
::
dims
>
&
pd
,
const
Box
<
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
>
&
domain
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
typename
Sys_eqs
::
b_grid
::
decomposition
&
dec
,
Vcluster
&
v_cl
)
:
pd
(
pd
),
gs
(
gs
),
g_map
(
dec
,
gs
.
getSize
(),
domain
,
Ghost
<
Sys_eqs
::
dims
,
size_t
>
(
1
)
)
:
pd
(
pd
),
gs
(
gs
),
g_map
(
dec
.
duplicate
(
Ghost
<
Sys_eqs
::
dims
,
long
int
>
(
1
)),
gs
.
getSize
(),
domain
)
{
// Calculate the size of the local domain
size_t
sz
=
g_map
.
getLocalDomainSize
();
...
...
@@ -204,9 +214,6 @@ public:
// get the position
auto
key
=
it
.
get
();
// convert into global coordinate the position
auto
keyg
=
it
.
getGKey
(
key
);
// Calculate the non-zero colums
T
::
value
(
g_map
,
key
,
gs
,
cols
,
1.0
);
...
...
src/FiniteDifference/FDScheme_unit_tests.hpp
View file @
3385f02c
...
...
@@ -11,6 +11,7 @@
#include "FiniteDifference/Derivative.hpp"
#include "FiniteDifference/Laplacian.hpp"
#include "Decomposition/CartDecomposition.hpp"
#include "util/grid_dist_testing.hpp"
constexpr
unsigned
int
x
=
0
;
constexpr
unsigned
int
y
=
1
;
...
...
@@ -117,21 +118,24 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
// grid size
size_t
sz
[
2
]
=
{
16
,
16
};
// grid_dist_testing
grid_dist_testing
<
2
>
g_map
(
sz
);
// grid_sm
grid_sm
<
2
,
void
>
ginfo
(
sz
);
// Create
a derivative row Matrix
grid_
key_dx
<
2
>
key11
(
1
,
1
);
grid_
key_dx
<
2
>
key00
(
0
,
0
);
grid_
key_dx
<
2
>
key22
(
2
,
2
);
grid_
key_dx
<
2
>
key1515
(
15
,
15
);
// Create
several keys
grid_
dist_key_dx
<
2
>
key11
(
0
,
grid_key_dx
<
2
>
(
1
,
1
)
);
grid_
dist_key_dx
<
2
>
key00
(
0
,
grid_key_dx
<
2
>
(
0
,
0
)
);
grid_
dist_key_dx
<
2
>
key22
(
0
,
grid_key_dx
<
2
>
(
2
,
2
)
);
grid_
dist_key_dx
<
2
>
key1515
(
0
,
grid_key_dx
<
2
>
(
15
,
15
)
);
// filled colums
std
::
unordered_map
<
long
int
,
float
>
cols_x
;
std
::
unordered_map
<
long
int
,
float
>
cols_y
;
/* D<x,Field<V,sys_nn>,sys_nn>::value(
key11,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn>::value(key11,ginfo,cols_y,1);
D
<
x
,
Field
<
V
,
sys_nn
>
,
sys_nn
>::
value
(
g_map
,
key11
,
ginfo
,
cols_x
,
1
);
D
<
y
,
Field
<
V
,
sys_nn
>
,
sys_nn
>::
value
(
g_map
,
key11
,
ginfo
,
cols_y
,
1
);
BOOST_REQUIRE_EQUAL
(
cols_x
.
size
(),
2
);
BOOST_REQUIRE_EQUAL
(
cols_y
.
size
(),
2
);
...
...
@@ -151,10 +155,10 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
// Composed derivative
D<x,D<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(key22,ginfo,cols_xx,1);
D<x,D<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(key22,ginfo,cols_xy,1);
D<y,D<x,Field<V,sys_nn>,sys_nn>,sys_nn>::value(key22,ginfo,cols_yx,1);
D<y,D<y,Field<V,sys_nn>,sys_nn>,sys_nn>::value(key22,ginfo,cols_yy,1);
D
<
x
,
D
<
x
,
Field
<
V
,
sys_nn
>
,
sys_nn
>
,
sys_nn
>::
value
(
g_map
,
key22
,
ginfo
,
cols_xx
,
1
);
D
<
x
,
D
<
y
,
Field
<
V
,
sys_nn
>
,
sys_nn
>
,
sys_nn
>::
value
(
g_map
,
key22
,
ginfo
,
cols_xy
,
1
);
D
<
y
,
D
<
x
,
Field
<
V
,
sys_nn
>
,
sys_nn
>
,
sys_nn
>::
value
(
g_map
,
key22
,
ginfo
,
cols_yx
,
1
);
D
<
y
,
D
<
y
,
Field
<
V
,
sys_nn
>
,
sys_nn
>
,
sys_nn
>::
value
(
g_map
,
key22
,
ginfo
,
cols_yy
,
1
);
BOOST_REQUIRE_EQUAL
(
cols_xx
.
size
(),
3
);
BOOST_REQUIRE_EQUAL
(
cols_xy
.
size
(),
4
);
...
...
@@ -184,8 +188,8 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
cols_x
.
clear
();
cols_y
.
clear
();
D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key11,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key11,ginfo,cols_y,1);
D
<
x
,
Field
<
V
,
sys_nn
>
,
sys_nn
,
CENTRAL_B_ONE_SIDE
>::
value
(
g_map
,
key11
,
ginfo
,
cols_x
,
1
);
D
<
y
,
Field
<
V
,
sys_nn
>
,
sys_nn
,
CENTRAL_B_ONE_SIDE
>::
value
(
g_map
,
key11
,
ginfo
,
cols_y
,
1
);
BOOST_REQUIRE_EQUAL
(
cols_x
.
size
(),
2
);
BOOST_REQUIRE_EQUAL
(
cols_y
.
size
(),
2
);
...
...
@@ -201,8 +205,8 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
cols_x
.
clear
();
cols_y
.
clear
();
D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key00,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key00,ginfo,cols_y,1);
D
<
x
,
Field
<
V
,
sys_nn
>
,
sys_nn
,
CENTRAL_B_ONE_SIDE
>::
value
(
g_map
,
key00
,
ginfo
,
cols_x
,
1
);
D
<
y
,
Field
<
V
,
sys_nn
>
,
sys_nn
,
CENTRAL_B_ONE_SIDE
>::
value
(
g_map
,
key00
,
ginfo
,
cols_y
,
1
);
BOOST_REQUIRE_EQUAL
(
cols_x
.
size
(),
3
);
BOOST_REQUIRE_EQUAL
(
cols_y
.
size
(),
3
);
...
...
@@ -220,8 +224,8 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
cols_x
.
clear
();
cols_y
.
clear
();
D<x,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key1515,ginfo,cols_x,1);
D<y,Field<V,sys_nn>,sys_nn,CENTRAL_B_ONE_SIDE>::value(key1515,ginfo,cols_y,1);
D
<
x
,
Field
<
V
,
sys_nn
>
,
sys_nn
,
CENTRAL_B_ONE_SIDE
>::
value
(
g_map
,
key1515
,
ginfo
,
cols_x
,
1
);
D
<
y
,
Field
<
V
,
sys_nn
>
,
sys_nn
,
CENTRAL_B_ONE_SIDE
>::
value
(
g_map
,
key1515
,
ginfo
,
cols_y
,
1
);
BOOST_REQUIRE_EQUAL
(
cols_x
.
size
(),
3
);
BOOST_REQUIRE_EQUAL
(
cols_y
.
size
(),
3
);
...
...
@@ -232,106 +236,9 @@ BOOST_AUTO_TEST_CASE( fd_test_use_non_periodic)
BOOST_REQUIRE_EQUAL
(
cols_y
[
15
*
16
+
15
],
1.5
);
BOOST_REQUIRE_EQUAL
(
cols_y
[
14
*
16
+
15
],
-
2
);
BOOST_REQUIRE_EQUAL(cols_y[13*16+15],0.5);
*/
BOOST_REQUIRE_EQUAL
(
cols_y
[
13
*
16
+
15
],
0.5
);
}
BOOST_AUTO_TEST_CASE
(
fd_test_use_periodic
)
{
// grid size
size_t
sz
[
2
]
=
{
16
,
16
};
// grid_sm
grid_sm
<
2
,
void
>
ginfo
(
sz
);
// Create a derivative row Matrix
grid_key_dx
<
2
>
key11
(
1
,
1
);
grid_key_dx
<
2
>
key00
(
0
,
0
);
grid_key_dx
<
2
>
key22
(
2
,
2
);
grid_key_dx
<
2
>
key1515
(
15
,
15
);
// filled colums
std
::
unordered_map
<
long
int
,
float
>
cols_x
;
std
::
unordered_map
<
long
int
,
float
>
cols_y
;
/* D<x,Field<V,sys_pp>,sys_pp>::value(key11,ginfo,cols_x,1);
D<y,Field<V,sys_pp>,sys_pp>::value(key11,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
BOOST_REQUIRE_EQUAL(cols_x[17+1],1);
BOOST_REQUIRE_EQUAL(cols_x[17-1],-1);
BOOST_REQUIRE_EQUAL(cols_y[17+16],1);
BOOST_REQUIRE_EQUAL(cols_y[17-16],-1);
cols_x.clear();
cols_y.clear();
D<x,Field<V,sys_pp>,sys_pp>::value(key00,ginfo,cols_x,1);
D<y,Field<V,sys_pp>,sys_pp>::value(key00,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
BOOST_REQUIRE_EQUAL(cols_x[1],1);
BOOST_REQUIRE_EQUAL(cols_x[15],-1);
BOOST_REQUIRE_EQUAL(cols_y[16],1);
BOOST_REQUIRE_EQUAL(cols_y[16*15],-1);
// periodic composed derivative
std::unordered_map<long int,float> cols_xx;
std::unordered_map<long int,float> cols_xy;
std::unordered_map<long int,float> cols_yx;
std::unordered_map<long int,float> cols_yy;
D<x,D<x,Field<V,sys_pp>,sys_pp>,sys_pp>::value(key00,ginfo,cols_xx,1);
D<x,D<y,Field<V,sys_pp>,sys_pp>,sys_pp>::value(key00,ginfo,cols_xy,1);
D<y,D<x,Field<V,sys_pp>,sys_pp>,sys_pp>::value(key00,ginfo,cols_yx,1);
D<y,D<y,Field<V,sys_pp>,sys_pp>,sys_pp>::value(key00,ginfo,cols_yy,1);
BOOST_REQUIRE_EQUAL(cols_xx.size(),3);
BOOST_REQUIRE_EQUAL(cols_xy.size(),4);
BOOST_REQUIRE_EQUAL(cols_yx.size(),4);
BOOST_REQUIRE_EQUAL(cols_yy.size(),3);
BOOST_REQUIRE_EQUAL(cols_xx[14],1);
BOOST_REQUIRE_EQUAL(cols_xx[0],-2);
BOOST_REQUIRE_EQUAL(cols_xx[2],1);
BOOST_REQUIRE_EQUAL(cols_xy[17],1);
BOOST_REQUIRE_EQUAL(cols_xy[16+15],-1);
BOOST_REQUIRE_EQUAL(cols_xy[15*16+1],-1);
BOOST_REQUIRE_EQUAL(cols_xy[15*16+15],1);
BOOST_REQUIRE_EQUAL(cols_yx[17],1);
BOOST_REQUIRE_EQUAL(cols_yx[16+15],-1);
BOOST_REQUIRE_EQUAL(cols_yx[15*16+1],-1);
BOOST_REQUIRE_EQUAL(cols_xy[15*16+15],1);
BOOST_REQUIRE_EQUAL(cols_yy[32],1);
BOOST_REQUIRE_EQUAL(cols_yy[0],-2);
BOOST_REQUIRE_EQUAL(cols_yy[14*16],1);
// Border Top right
cols_x.clear();
cols_y.clear();
D<x,Field<V,sys_pp>,sys_pp>::value(key1515,ginfo,cols_x,1);
D<y,Field<V,sys_pp>,sys_pp>::value(key1515,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
BOOST_REQUIRE_EQUAL(cols_x[15*16+0],1);
BOOST_REQUIRE_EQUAL(cols_x[15*16+14],-1);
BOOST_REQUIRE_EQUAL(cols_y[0*16+15],1);
BOOST_REQUIRE_EQUAL(cols_y[14*16+15],-1);*/
}
BOOST_AUTO_TEST_CASE
(
fd_test_use_staggered_non_periodic
)
{
...
...
@@ -341,18 +248,20 @@ BOOST_AUTO_TEST_CASE( fd_test_use_staggered_non_periodic)
// grid_sm
grid_sm
<
2
,
void
>
ginfo
(
sz
);
// Create a derivative row Matrix
grid_key_dx
<
2
>
key11
(
1
,
1
);
grid_key_dx
<
2
>
key00
(
0
,
0
);
grid_key_dx
<
2
>
key22
(
2
,
2
);
grid_key_dx
<
2
>
key1515
(
15
,
15
);
// grid_dist_testing
grid_dist_testing
<
2
>
g_map
(
sz
);
// Create several keys
grid_dist_key_dx
<
2
>
key11
(
0
,
grid_key_dx
<
2
>
(
1
,
1
));
grid_dist_key_dx
<
2
>
key22
(
0
,
grid_key_dx
<
2
>
(
2
,
2
));
grid_dist_key_dx
<
2
>
key1515
(
0
,
grid_key_dx
<
2
>
(
15
,
15
));
// filled colums
std
::
unordered_map
<
long
int
,
float
>
cols_x
;
std
::
unordered_map
<
long
int
,
float
>
cols_y
;
/* D<x,Field<V,syss_pp>,syss_pp>::value(
key11,ginfo,cols_x,1);
D<y,Field<V,syss_pp>,syss_pp>::value(key11,ginfo,cols_y,1);
D
<
x
,
Field
<
V
,
syss_pp
>
,
syss_pp
>::
value
(
g_map
,
key11
,
ginfo
,
cols_x
,
1
);
D
<
y
,
Field
<
V
,
syss_pp
>
,
syss_pp
>::
value
(
g_map
,
key11
,
ginfo
,
cols_y
,
1
);
BOOST_REQUIRE_EQUAL
(
cols_x
.
size
(),
2
);
BOOST_REQUIRE_EQUAL
(
cols_y
.
size
(),
2
);
...
...
@@ -365,18 +274,6 @@ BOOST_AUTO_TEST_CASE( fd_test_use_staggered_non_periodic)
cols_x
.
clear
();
cols_y
.
clear
();
D<x,Field<V,syss_pp>,syss_pp>::value(key00,ginfo,cols_x,1);
D<y,Field<V,syss_pp>,syss_pp>::value(key00,ginfo,cols_y,1);
BOOST_REQUIRE_EQUAL(cols_x.size(),2);
BOOST_REQUIRE_EQUAL(cols_y.size(),2);
BOOST_REQUIRE_EQUAL(cols_x[1],1);
BOOST_REQUIRE_EQUAL(cols_x[0],-1);
BOOST_REQUIRE_EQUAL(cols_y[16],1);
BOOST_REQUIRE_EQUAL(cols_y[0],-1);*/
}
/////////////// Laplacian test
...
...
@@ -389,16 +286,18 @@ BOOST_AUTO_TEST_CASE( fd_test_lap_use_periodic)
// grid_sm
grid_sm
<
2
,
void
>
ginfo
(
sz
);
// Create a derivative row Matrix
grid_key_dx
<
2
>
key11
(
1
,
1
);
grid_key_dx
<
2
>
key00
(
0
,
0
);
grid_key_dx
<
2
>
key22
(
2
,
2
);
grid_key_dx
<
2
>
key1515
(
15
,
15
);
// grid_dist_testing
grid_dist_testing
<
2
>
g_map
(
sz
);
// Create several keys
grid_dist_key_dx
<
2
>
key11
(
0
,
grid_key_dx
<
2
>
(
1
,
1
));
grid_dist_key_dx
<
2
>
key22
(
0
,
grid_key_dx
<
2
>
(
2
,
2
));
grid_dist_key_dx
<
2
>
key1414
(
0
,
grid_key_dx
<
2
>
(
14
,
14
));
// filled colums
std
::
unordered_map
<
long
int
,
float
>
cols
;
/* Lap<Field<V,sys_pp>,sys_pp>::value(
key11,ginfo,cols,1);
Lap
<
Field
<
V
,
sys_pp
>
,
sys_pp
>::
value
(
g_map
,
key11
,
ginfo
,
cols
,
1
);
BOOST_REQUIRE_EQUAL
(
cols
.
size
(),
5
);
...
...
@@ -411,31 +310,16 @@ BOOST_AUTO_TEST_CASE( fd_test_lap_use_periodic)
cols
.
clear
();
Lap<Field<V,sys_pp>,sys_pp>::value(
key00
,ginfo,cols,1);
Lap
<
Field
<
V
,
sys_pp
>
,
sys_pp
>::
value
(
g_map
,
key1414
,
ginfo
,
cols
,
1
);
BOOST_REQUIRE_EQUAL
(
cols
.
size
(),
5
);
BOOST_REQUIRE_EQUAL(cols[1],1);
BOOST_REQUIRE_EQUAL(cols[15],1);
BOOST_REQUIRE_EQUAL(cols[16],1);
BOOST_REQUIRE_EQUAL(cols[15*16],1);
BOOST_REQUIRE_EQUAL(cols[0],-4);
// Border Top right
cols.clear();
Lap<Field<V,sys_pp>,sys_pp>::value(key1515,ginfo,cols,1);
BOOST_REQUIRE_EQUAL(cols.size(),5);
BOOST_REQUIRE_EQUAL(cols[15*16+14],1);
BOOST_REQUIRE_EQUAL(cols[15*16],1);
BOOST_REQUIRE_EQUAL
(
cols
[
14
*
16
+
13
],
1
);
BOOST_REQUIRE_EQUAL
(
cols
[
14
*
16
+
15
],
1
);
BOOST_REQUIRE_EQUAL(cols[15],1);
BOOST_REQUIRE_EQUAL
(
cols
[
13
*
16
+
14
],
1
);
BOOST_REQUIRE_EQUAL
(
cols
[
15
*
16
+
14
],
1
);
BOOST_REQUIRE_EQUAL(cols[1
5*16+15],-4);*/
BOOST_REQUIRE_EQUAL
(
cols
[
1
4
*
16
+
14
],
-
4
);
}
//////////////// Position ////////////////////
...
...
src/FiniteDifference/Laplacian.hpp
View file @
3385f02c
...
...
@@ -23,7 +23,7 @@ class Lap
* \tparam ord
*
*/
inline
static
void
value
(
const
grid_dist_id
<
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
scalar
<
size_t
>
,
typename
Sys_eqs
::
b_grid
::
decomposition
>
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
inline
static
void
value
(
const
typename
stub_or_real
<
Sys_eqs
,
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
typename
Sys_eqs
::
b_grid
::
decomposition
>::
type
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
{
std
::
cerr
<<
"Error "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" only CENTRAL, FORWARD, BACKWARD derivative are defined"
;
}
...
...
@@ -53,7 +53,7 @@ public:
*
*
*/
inline
static
void
value
(
const
grid_dist_id
<
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
scalar
<
size_t
>
,
typename
Sys_eqs
::
b_grid
::
decomposition
>
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
inline
static
void
value
(
const
typename
stub_or_real
<
Sys_eqs
,
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
typename
Sys_eqs
::
b_grid
::
decomposition
>::
type
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
{
// for each dimension
for
(
size_t
i
=
0
;
i
<
Sys_eqs
::
dims
;
i
++
)
...
...
src/FiniteDifference/eq.hpp
View file @
3385f02c
...
...
@@ -18,6 +18,7 @@
#define NON_PERIODIC false
#include "data_type/scalar.hpp"
#include "util/util_num.hpp"
/*! \brief Equation
*
...
...
@@ -125,13 +126,15 @@ struct pos_val
template
<
unsigned
int
f
,
typename
Sys_eqs
>
class
Field
{
typedef
typename
stub_or_real
<
Sys_eqs
,
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
typename
Sys_eqs
::
b_grid
::
decomposition
>::
type
map_grid
;
public:
/*! \brief fill the row
*
*
*/
static
void
value
(
const
grid_dist_id
<
Sys_eqs
::
dims
,
typename
Sys_eqs
::
stype
,
scalar
<
size_t
>
,
typename
Sys_eqs
::
b_grid
::
decomposition
>
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
static
void
value
(
const
map_grid
&
g_map
,
grid_dist_key_dx
<
Sys_eqs
::
dims
>
&
kmap
,
const
grid_sm
<
Sys_eqs
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
Sys_eqs
::
stype
>
&
cols
,
typename
Sys_eqs
::
stype
coeff
)
{
if
(
Sys_eqs
::
ord
==
EQS_FIELD
)
cols
[
g_map
.
template
get
<
0
>(
kmap
)
*
Sys_eqs
::
nvar
+
f
]
+=
coeff
;
...
...
src/FiniteDifference/eq_unit_test.hpp
View file @
3385f02c
...
...
@@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE( lid_driven_cavity )
// Ghost
Ghost
<
2
,
float
>
g
(
0.01
);
size_t
sz
[]
=
{
32
,
32
};
size_t
sz
[]
=
{
256
,
256
};
Padding
<
2
>
pd
({
1
,
2
},{
1
,
2
});
// Initialize the global VCluster
...
...
@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE( lid_driven_cavity )
FDScheme
<
lid_nn
>
fd
(
pd
,
domain
,
g_dist
.
getGridInfo
(),
g_dist
.
getDecomposition
(),
g_dist
.
getVC
());
// start and end of the bulk
grid_key_dx
<
2
>
bulk_start
(
0
,
0
);
/*
grid_key_dx<2> bulk_start(0,0);
grid_key_dx<2> bulk_end(sz[0],sz[1]);
// Impose the vx and vy equation in the bulk
...
...
@@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE( lid_driven_cavity )
grid_key_dx<2> pvtop_start(0,33);
grid_key_dx<2> pvtop_end(31,33);
fd.imposeA(v_x(), g_dist.getSubDomainIterator(pvtop_start,pvtop_end));
fd
.
imposeB
(
0.0
,
g_dist
.
getSubDomainIterator
(
pvtop_start
,
pvtop_end
));
fd.imposeB(0.0, g_dist.getSubDomainIterator(pvtop_start,pvtop_end));
*/
}
BOOST_AUTO_TEST_SUITE_END
()
...
...
src/FiniteDifference/sum.hpp
View file @
3385f02c
...
...
@@ -25,14 +25,15 @@ struct sum_functor_value
//! sum functor
std
::
unordered_map
<
long
int
,
typename
last
::
stype
>
&
cols
;
//! Grid info
const
grid_sm
<
last
::
dims
,
void
>
&
gs
;
// grid mapping
const
grid_dist_id
<
last
::
dims
,
typename
last
::
stype
,
scalar
<
size_t
>
,
typename
last
::
b_grid
::
decomposition
>
&
g_map
;
// grid position
grid_dist_key_dx
<
last
::
dims
>
&
kmap
;
const
grid_sm
<
last
::
dims
,
void
>
&
gs
;
//! position
grid_key_dx
<
last
::
dims
>
&
key
;
...
...
@@ -43,7 +44,7 @@ struct sum_functor_value
*
*/
sum_functor_value
(
const
grid_dist_id
<
last
::
dims
,
typename
last
::
stype
,
scalar
<
size_t
>
,
typename
last
::
b_grid
::
decomposition
>
&
g_map
,
grid_dist_key_dx
<
last
::
dims
>
&
kmap
,
const
grid_sm
<
last
::
dims
,
void
>
&
gs
,
std
::
unordered_map
<
long
int
,
typename
last
::
stype
>
&
cols
,
typename
last
::
stype
coeff
)
:
g_map
(
g_map
),
kmap
(
kmap
),
cols
(
cols
),
gs
(
gs
),
key
(
key
),
coeff
(
coeff
)
:
cols
(
cols
),
gs
(
gs
),
g_map
(
g_map
),
kmap
(
kmap
),
key
(
key
),
coeff
(
coeff
)
{};
...
...
src/util/grid_dist_testing.hpp
View file @
3385f02c
...
...
@@ -12,6 +12,56 @@ template<unsigned int dim>
class
grid_dist_testing
{
grid_cpu
<
dim
,
scalar
<
size_t
>>
grid_test
;
public:
/*! \brief It create a test map suitable for testing
*
* \param size of the grid with padding
*
*/
grid_dist_testing
(
const
size_t
(
&
g_sz
)[
dim
])
:
grid_test
(
g_sz
)
{
grid_test
.
setMemory
();
// We fill the testing map
auto
dom
=
grid_test
.
getIterator
();
const
auto
&
gs
=
grid_test
.
getGrid
();