Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_numerics
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_numerics
Commits
45f85b03
Commit
45f85b03
authored
8 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Add missing file
parent
f6725aee
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Vector/Vector_util.hpp
+125
-0
125 additions, 0 deletions
src/Vector/Vector_util.hpp
with
125 additions
and
0 deletions
src/Vector/Vector_util.hpp
0 → 100644
+
125
−
0
View file @
45f85b03
/*
* Vector_util.hpp
*
* Created on: Dec 7, 2015
* Author: i-bird
*/
#ifndef OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_UTIL_HPP_
#define OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_UTIL_HPP_
#include
"Grid/grid_dist_key.hpp"
#include
"Space/Shape/HyperCube.hpp"
#include
"util/mul_array_extents.hpp"
/*! \brief Copy scalar elements
*
* \tparam copy_type Type that should be copied
* \tparam T property id to copy
* \tparam Ev Type of source the Vector
* \tparam sa dimensionality of the array 0 is a scalar
*
*/
template
<
typename
copy_type
,
typename
T
,
typename
Ev
,
typename
Eqs_sys
,
int
sa
>
struct
copy_ele_sca_array
{
template
<
typename
Grid
>
inline
static
void
copy
(
Grid
&
grid_dst
,
const
grid_dist_key_dx
<
Eqs_sys
::
dims
>
&
key
,
const
Ev
&
x
,
size_t
lin_id
,
size_t
base_id
,
size_t
gs_size
)
{
grid_dst
.
template
get
<
T
::
value
>(
key
)
=
x
(
lin_id
*
Eqs_sys
::
nvar
+
base_id
);
}
};
/*! \brief Copy 1D array elements
*
* spacialization in case of 1D array
*
* \tparam copy_type Type that should be copied
* \tparam T property id to copy
* \tparam Ev Type of source the Vector
*
*/
template
<
typename
copy_type
,
typename
T
,
typename
Ev
,
typename
Eqs_sys
>
struct
copy_ele_sca_array
<
copy_type
,
T
,
Ev
,
Eqs_sys
,
1
>
{
template
<
typename
Grid
>
inline
static
void
copy
(
Grid
&
grid_dst
,
const
grid_dist_key_dx
<
Eqs_sys
::
dims
>
&
key
,
const
Ev
&
x
,
size_t
lin_id
,
size_t
base_id
,
size_t
gs_size
)
{
for
(
size_t
i
=
0
;
i
<
std
::
extent
<
copy_type
>::
value
;
i
++
)
{
grid_dst
.
template
get
<
T
::
value
>(
key
)[
i
]
=
x
(
lin_id
*
Eqs_sys
::
nvar
+
base_id
+
i
);
}
}
};
/*! \brief this class is a functor for "for_each" algorithm
*
* This class is a functor for "for_each" algorithm. For each
* element of the boost::vector the operator() is called.
* Is mainly used to copy from the Vector to the grid target
* \note properties can be scalars or arrays of C++ primitives
*
* \tparam Eqs_sys System of equation information
* \tparam S type of destination grid
* \tparam Ev type of vector
*
*/
template
<
typename
Eqs_sys
,
typename
S
,
typename
Ev
>
struct
copy_ele
{
//! destination grid element
const
grid_dist_key_dx
<
Eqs_sys
::
dims
>
key
;
//! destination grid
S
&
grid_dst
;
//! source element inside the vector
size_t
lin_id
;
//! counter
size_t
prp_id
;
//! It is basically the number of grid points the vector has inside
size_t
gs_size
;
//! source vector
const
Ev
&
x
;
/*! \brief constructor
*
* It define the copy parameters.
*
* \param key destination position
* \param grid_dst grid destination
* \param v Source vector
*
*/
inline
copy_ele
(
const
grid_dist_key_dx
<
Eqs_sys
::
dims
>
&
key
,
S
&
grid_dst
,
const
Ev
&
x
,
size_t
lin_id
,
size_t
gs_size
)
:
key
(
key
),
grid_dst
(
grid_dst
),
lin_id
(
lin_id
),
prp_id
(
0
),
gs_size
(
gs_size
),
x
(
x
){};
#ifdef SE_CLASS1
/*! \brief Constructor
*
* Calling this constructor produce an error. This class store the reference of the object,
* this mean that the object passed must not be a temporal object
*
*/
inline
copy_ele
(
grid_dist_key_dx
<
Eqs_sys
::
dims
>
&
key
,
S
&
grid_dst
,
Ev
&&
x
)
:
key
(
key
),
grid_dst
(
grid_dst
),
x
(
x
)
{
std
::
cerr
<<
"Error: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" Passing a temporal object"
;};
#endif
//! It call the copy function for each property
template
<
typename
T
>
inline
void
operator
()(
T
&
t
)
{
// This is the type of the object we have to copy
typedef
typename
boost
::
mpl
::
at_c
<
typename
S
::
value_type
::
type
,
T
::
value
>::
type
copy_type
;
copy_ele_sca_array
<
copy_type
,
T
,
Ev
,
Eqs_sys
,
std
::
is_array
<
copy_type
>::
value
>::
copy
(
grid_dst
,
key
,
x
,
lin_id
,
prp_id
,
gs_size
);
prp_id
+=
array_extents
<
copy_type
>::
mul
();
}
};
#endif
/* OPENFPM_NUMERICS_SRC_VECTOR_VECTOR_UTIL_HPP_ */
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