5#ifndef OPENFPM_NUMERICS_BOUNDARYCONDITIONS_METHODOFIMAGES_HPP
6#define OPENFPM_NUMERICS_BOUNDARYCONDITIONS_METHODOFIMAGES_HPP
10#include "Vector/vector_dist_subset.hpp"
12#define PID_VECTOR_TYPE openfpm::vector<aggregate<int>>
13#define KEY_VECTOR_TYPE openfpm::vector<vect_dist_key_dx>
24template <
size_t SurfaceNormal,
typename vd_type>
69 auto lastReal = vd.size_local();
74 size_t id_source = key_source.getKey();
75 size_t id_mirror = lastReal + i;
78 point_type n = vd.template getProp<SurfaceNormal>(key_source);
82 if(!point_lies_on_this_processor(vd, xm))
84 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error: Ghost layer is too small. Source and mirror"
85 " particles that belong together must lie on the same"
87 " Create a bigger ghost layer which is bigger than the"
88 " mirror particle layer. Aborting..." << std::endl;
94 for (
size_t d = 0; d < vd_type::dims; d++)
96 vd.getLastPos()[d] = xm[d];
100 key_map_source_mirror.add(pair);
104 vd.template ghost_get();
110 check_size_mirror_source_equal();
120 template <
size_t PropToMirror>
123 vd.template ghost_get<PropToMirror>(KEEP_PROPERTIES);
125 for(
int i = 0; i < key_map_source_mirror.
size(); ++i)
129 key_source.
setKey(row.get(0));
130 key_mirror.
setKey(row.get(1));
131 vd.template getProp<PropToMirror>(key_mirror) = vd.template getProp<PropToMirror>(key_source);
145 for(
int d=0; d<vd_type::dims; d++)
147 if (vd.getDecomposition().getGhost().getLow(0) != vd.getDecomposition().getGhost().getLow(d))
149 std::cerr << __FILE__ <<
":" << __LINE__ <<
"Ghost layer doesn't have the same size in all dimensions"
150 ". Use an isometric ghost layer. Aborting..."
165 bool point_lies_on_this_processor(vd_type & vd, point_type p)
167 double g_width = fabs(vd.getDecomposition().getGhost().getLow(0));
170 auto & subs = vd.getDecomposition().getSubDomains();
172 bool is_inside =
false;
174 for (
int i = 0 ; i < subs.size() ; i++)
181 if (!is_inside) {std::cout <<
"Processor does not have the point" << std::endl;}
189 void check_size_mirror_source_equal()
193 std::cout <<
"pid_mirror.size() = " <<
pid_mirror.size() <<
", keys_source.size() = " <<
keys_source.size()
195 std::cerr << __FILE__ <<
":" << __LINE__
196 <<
" Error: Local vector of source-IDs has different size than local vector of mirror-IDs. Matching "
197 "source and mirror particle IDs must be stored on same processor." << std::endl;
__host__ __device__ bool isInside(const Point< dim, T > &p) const
Check if the point is inside the box.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
Class for getting mirror particles to impose Neumann BCs.
void check_if_ghost_isometric(vd_type &vd)
Checks if the ghost layer has the same size in all dimensions. This is required to ensure that the gh...
vd_subset_type Mirror
Subset containing the mirror particles.
MethodOfImages(vd_type &vd, const KEY_VECTOR_TYPE &keys_source, const size_t subset_id_real=0, const size_t subset_id_mirror=1)
Constructor.
void get_mirror_particles(vd_type &vd)
Place mirror particles along the surface normal.
size_t subset_id_real
ID of subset containing the real particles (default=0).
PID_VECTOR_TYPE pid_mirror
Vector containing indices of mirror particles.
KEY_VECTOR_TYPE keys_source
Vector containing keys of source particles.
void apply_noflux(vd_type &vd)
Copies the values stored in PropToMirror from each source particle to its respective mirror particles...
size_t subset_id_mirror
ID of subset containing the mirror particles (default=1).
This class implement the point shape in an N-dimensional space.
This class represent an N-dimensional box.
Implementation of 1-D std::vector like structure.
Grid key for a distributed grid.
__device__ __host__ void setKey(size_t key)
set the key
void update()
Update the subset indexes.
openfpm::vector< aggregate< int > > & getIds()
Return the ids.