Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_pdata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_pdata
Commits
44232a31
Commit
44232a31
authored
9 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Fixing staggered grid checking
parent
237fef5f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Grid/staggered_dist_grid.hpp
+13
-3
13 additions, 3 deletions
src/Grid/staggered_dist_grid.hpp
src/Grid/staggered_grid_dist_unit_test.hpp
+30
-36
30 additions, 36 deletions
src/Grid/staggered_grid_dist_unit_test.hpp
with
43 additions
and
39 deletions
src/Grid/staggered_dist_grid.hpp
+
13
−
3
View file @
44232a31
...
...
@@ -61,6 +61,7 @@
template
<
unsigned
int
dim
,
typename
St
,
typename
T
,
typename
Decomposition
,
typename
Memory
=
HeapMemory
,
typename
device_grid
=
grid_cpu
<
dim
,
T
>
>
class
staggered_grid_dist
:
public
grid_dist_id
<
dim
,
St
,
T
,
Decomposition
,
Memory
,
device_grid
>
{
openfpm
::
vector
<
comb
<
dim
>>
c_prp
[
T
::
max_prop
];
public:
...
...
@@ -70,10 +71,9 @@ public:
:
grid_dist_id
<
dim
,
St
,
T
,
Decomposition
,
Memory
,
device_grid
>
(
g_sz
,
domain
,
ghost
)
{}
openfpm
::
vector
<
comb
<
dim
>>
c_prp
[
T
::
max_prop
];
/*! \brief Set the staggered positions
/*! \brief Get the staggered positions
*
* \return a vector of combination
*
*/
template
<
unsigned
int
p
>
void
setStagPosition
(
openfpm
::
vector
<
comb
<
dim
>>
&
cmb
)
...
...
@@ -97,6 +97,16 @@ public:
boost
::
mpl
::
for_each_ref
<
boost
::
mpl
::
range_c
<
int
,
0
,
T
::
max_prop
>
>
(
ssp
);
}
/*! \brief Get the staggered positions
*
* \return The vector of the staggered positions
*
*/
const
openfpm
::
vector
<
comb
<
dim
>>
(
&
getStagPositions
())
[
T
::
max_prop
]
{
return
c_prp
;
}
/*! \brief Write a vtk file with the information of the staggered grid
*
* \param str vtk output file
...
...
This diff is collapsed.
Click to expand it.
src/Grid/staggered_grid_dist_unit_test.hpp
+
30
−
36
View file @
44232a31
...
...
@@ -23,42 +23,36 @@ BOOST_AUTO_TEST_CASE( staggered_grid_dist_unit_test)
size_t
k
=
1024
;
/* for (size_t k = 1024 ; k >= 2 ; k--)
{*/
BOOST_TEST_CHECKPOINT
(
"Testing grid k="
<<
k
);
// grid size
size_t
sz
[
2
];
sz
[
0
]
=
k
;
sz
[
1
]
=
k
;
// Ghost
Ghost
<
2
,
float
>
g
(
0.01
);
staggered_grid_dist
<
2
,
float
,
Point2D_test
<
float
>
,
CartDecomposition
<
2
,
float
>>
sg
(
sz
,
domain
,
g
);
sg
.
setDefaultStagPosition
();
auto
it
=
sg
.
getDomainIterator
();
while
(
it
.
isNext
())
{
auto
key
=
it
.
get
();
sg
.
template
get
<
p
::
s
>(
key
)
=
1
;
sg
.
template
get
<
p
::
v
>(
key
)[
0
]
=
0
;
sg
.
template
get
<
p
::
v
>(
key
)[
1
]
=
1
;
sg
.
template
get
<
p
::
t
>(
key
)[
0
][
0
]
=
0
;
sg
.
template
get
<
p
::
t
>(
key
)[
0
][
1
]
=
1
;
sg
.
template
get
<
p
::
t
>(
key
)[
1
][
0
]
=
2
;
sg
.
template
get
<
p
::
t
>(
key
)[
1
][
1
]
=
3
;
++
it
;
}
/* }*/
// grid size
size_t
sz
[
2
]
=
{
k
,
k
};
// Ghost
Ghost
<
2
,
float
>
g
(
0.0
);
staggered_grid_dist
<
2
,
float
,
Point2D_test
<
float
>
,
CartDecomposition
<
2
,
float
>>
sg
(
sz
,
domain
,
g
);
sg
.
setDefaultStagPosition
();
// We check that the staggered position is correct
const
openfpm
::
vector
<
comb
<
2
>>
(
&
cmbs
)[
6
]
=
sg
.
getStagPositions
();
BOOST_REQUIRE_EQUAL
(
cmbs
[
0
].
size
(),
1ul
);
BOOST_REQUIRE_EQUAL
(
cmbs
[
1
].
size
(),
1ul
);
BOOST_REQUIRE_EQUAL
(
cmbs
[
2
].
size
(),
1ul
);
BOOST_REQUIRE_EQUAL
(
cmbs
[
3
].
size
(),
1ul
);
BOOST_REQUIRE_EQUAL
(
cmbs
[
4
].
size
(),
2ul
);
BOOST_REQUIRE_EQUAL
(
cmbs
[
5
].
size
(),
4ul
);
BOOST_REQUIRE
(
cmbs
[
0
].
get
(
0
)
==
comb
<
2
>
({
0
,
0
}));
BOOST_REQUIRE
(
cmbs
[
1
].
get
(
0
)
==
comb
<
2
>
({
0
,
0
}));
BOOST_REQUIRE
(
cmbs
[
2
].
get
(
0
)
==
comb
<
2
>
({
0
,
0
}));
BOOST_REQUIRE
(
cmbs
[
3
].
get
(
0
)
==
comb
<
2
>
({
0
,
0
}));
BOOST_REQUIRE
(
cmbs
[
4
].
get
(
0
)
==
comb
<
2
>
({
0
,
-
1
}));
BOOST_REQUIRE
(
cmbs
[
4
].
get
(
1
)
==
comb
<
2
>
({
-
1
,
0
}));
BOOST_REQUIRE
(
cmbs
[
5
].
get
(
0
)
==
comb
<
2
>
({
0
,
0
}));
BOOST_REQUIRE
(
cmbs
[
5
].
get
(
1
)
==
comb
<
2
>
({
-
1
,
-
1
}));
BOOST_REQUIRE
(
cmbs
[
5
].
get
(
2
)
==
comb
<
2
>
({
-
1
,
-
1
}));
BOOST_REQUIRE
(
cmbs
[
5
].
get
(
3
)
==
comb
<
2
>
({
0
,
0
}));
}
BOOST_AUTO_TEST_SUITE_END
()
...
...
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