Commit 47964047 authored by Pietro Incardona's avatar Pietro Incardona

Semiworking periodic boundary conditions

parent 6e8741cf
openfpm_data @ 0572e97f
Subproject commit fb93d17019fdfb1f7c65c463143f5100d506d6d2 Subproject commit 0572e97f47cfe83ca1b3f66e05c47cda85946345
openfpm_devices @ 52cee143
Subproject commit ec5abaf0d363649dfa1d5831ac6784868ce418f2 Subproject commit 52cee143052e1b6ce4bdb0d6061d0e8095829643
openfpm_io @ 7988298e
Subproject commit c54eca6ee2e0bbfefda778df50b369ce9a90323f Subproject commit 7988298e26138d0470851e9053e6640511793363
openfpm_vcluster @ e4f99633
Subproject commit d052b0d75a49835b24419cc4938485d6dc514393 Subproject commit e4f9963378be88d411b56d07afbeed05df994d9b
...@@ -489,6 +489,48 @@ public: ...@@ -489,6 +489,48 @@ public:
} }
}; };
/*! \brief Apply boundary condition to the point
*
* \param p Point to apply the boundary condition
*
*/
void applyPointBC(float (& pt)[dim]) const
{
for (size_t i = 0 ; i < dim ; i++)
{
if (bc[i] == PERIODIC)
pt[i] = openfpm::math::periodic_l(pt[i],domain.getHigh(i),domain.getLow(i));
}
}
/*! \brief Apply boundary condition to the point
*
* \param p Point to apply the boundary condition
*
*/
void applyPointBC(Point<dim,T> & pt) const
{
for (size_t i = 0 ; i < dim ; i++)
{
if (bc[i] == PERIODIC)
pt.get(i) = openfpm::math::periodic_l(pt.get(i),domain.getHigh(i),domain.getLow(i));
}
}
/*! \brief Apply boundary condition to the point
*
* \param encapsulated object
*
*/
template<typename Mem> void applyPointBC(encapc<1,Point<dim,T>,Mem> && pt) const
{
for (size_t i = 0 ; i < dim ; i++)
{
if (bc[i] == PERIODIC)
pt.template get<0>()[i] = openfpm::math::periodic_l(pt.template get<0>()[i],domain.getHigh(i),domain.getLow(i));
}
}
/*! It calculate the internal ghost boxes /*! It calculate the internal ghost boxes
* *
* Example: Processor 10 calculate * Example: Processor 10 calculate
...@@ -789,6 +831,51 @@ p1[0]<-----+ +----> p2[0] ...@@ -789,6 +831,51 @@ p1[0]<-----+ +----> p2[0]
return fine_s.get(cd.getCell(p)); return fine_s.get(cd.getCell(p));
} }
/*! \brief Given a point return in which processor the particle should go
*
* Boundary conditions are considered
*
* \return processorID
*
*/
template<typename Mem> size_t inline processorIDBC(encapc<1, Point<dim,T>, Mem> p)
{
Point<dim,T> pt = p;
applyPointBC(pt);
return fine_s.get(cd.getCell(pt));
}
/*! \brief Given a point return in which processor the particle should go
*
* Boundary conditions are considered
*
* \return processorID
*
*/
size_t inline processorIDBC(const Point<dim,T> &p) const
{
Point<dim,T> pt = p;
applyPointBC(pt);
return fine_s.get(cd.getCell(p));
}
/*! \brief Given a point return in which processor the particle should go
*
* Boundary consition are considered
*
* \return processorID
*
*/
size_t inline processorIDBC(const T (&p)[dim]) const
{
Point<dim,T> pt = p;
applyPointBC(pt);
return fine_s.get(cd.getCell(p));
}
/*! \brief Get the smallest subdivision of the domain on each direction /*! \brief Get the smallest subdivision of the domain on each direction
* *
* \return a box p1 is set to zero * \return a box p1 is set to zero
...@@ -879,7 +966,7 @@ p1[0]<-----+ +----> p2[0] ...@@ -879,7 +966,7 @@ p1[0]<-----+ +----> p2[0]
* \return The physical domain * \return The physical domain
* *
*/ */
Domain<dim,T> & getDomain() const Domain<dim,T> & getDomain()
{ {
return domain; return domain;
} }
......
...@@ -191,7 +191,8 @@ struct N_box ...@@ -191,7 +191,8 @@ struct N_box
openfpm::vector<comb<dim>> pos; openfpm::vector<comb<dim>> pos;
//! Default constructor //! Default constructor
N_box() {}; N_box()
{};
//! Copy constructor //! Copy constructor
N_box(const N_box<dim,T> & b) N_box(const N_box<dim,T> & b)
...@@ -213,8 +214,8 @@ struct N_box ...@@ -213,8 +214,8 @@ struct N_box
N_box<dim,T> & operator=(const N_box<dim,T> & ele) N_box<dim,T> & operator=(const N_box<dim,T> & ele)
{ {
id = ele.id; id = ele.id;
bx = ele.bx; bx = ele.bx;
pos = ele.pos;
return * this; return * this;
} }
...@@ -227,8 +228,8 @@ struct N_box ...@@ -227,8 +228,8 @@ struct N_box
N_box<dim,T> & operator=(N_box<dim,T> && ele) N_box<dim,T> & operator=(N_box<dim,T> && ele)
{ {
id = ele.id; id = ele.id;
bx.swap(ele.bx); bx.swap(ele.bx);
pos = ele.pos;
return * this; return * this;
} }
...@@ -243,6 +244,9 @@ struct N_box ...@@ -243,6 +244,9 @@ struct N_box
if (id != ele.id) if (id != ele.id)
return false; return false;
if (pos != ele.pos)
return false;
return bx == ele.bx; return bx == ele.bx;
} }
......
...@@ -156,13 +156,13 @@ protected: ...@@ -156,13 +156,13 @@ protected:
switch (cmbs[j][k]) switch (cmbs[j][k])
{ {
case 1: case 1:
shifts.get(cmbs[j].lin()).template get<0>()[0] = -domain.getHigh(k); shifts.get(cmbs[j].lin()).template get<0>()[k] = -domain.getHigh(k);
break; break;
case 0: case 0:
shifts.get(cmbs[j].lin()).template get<0>()[0] = 0; shifts.get(cmbs[j].lin()).template get<0>()[k] = 0;
break; break;
case -1: case -1:
shifts.get(cmbs[j].lin()).template get<0>()[0] = domain.getHigh(k); shifts.get(cmbs[j].lin()).template get<0>()[k] = domain.getHigh(k);
break; break;
} }
} }
...@@ -395,7 +395,7 @@ public: ...@@ -395,7 +395,7 @@ public:
/*! It return the shift vector /*! It return the shift vector
* *
* Consider a domain with some ghost, at the border of the domain the * Consider a domain with some ghost, at the border of the domain the
* ghost must be threated in a special way depending on the periodicity * ghost must be treated in a special way, depending on the periodicity
* of the boundary * of the boundary
* *
\verbatim \verbatim
...@@ -637,7 +637,7 @@ public: ...@@ -637,7 +637,7 @@ public:
* can produce more entry with the same processor, the UNIQUE option eliminate double entries * can produce more entry with the same processor, the UNIQUE option eliminate double entries
* (UNIQUE) is for particle data (MULTIPLE) is for grid data [default MULTIPLE] * (UNIQUE) is for particle data (MULTIPLE) is for grid data [default MULTIPLE]
* *
* \param return the processor ids * \param return the processor ids (not the rank, the id in the near processor list)
* *
*/ */
template <typename id1, typename id2> inline const openfpm::vector<std::pair<size_t,size_t>> ghost_processorID_pair(Point<dim,T> & p, const int opt = MULTIPLE) template <typename id1, typename id2> inline const openfpm::vector<std::pair<size_t,size_t>> ghost_processorID_pair(Point<dim,T> & p, const int opt = MULTIPLE)
......
...@@ -282,6 +282,16 @@ public: ...@@ -282,6 +282,16 @@ public:
return *this; return *this;
} }
/*! \brief Get the number of local sub-domains
*
* \return the number of local sub-domains
*
*/
inline size_t getNLocalSub()
{
return loc_ghost_box.size();
}
/*! \brief Get the number of external local ghost box for each sub-domain /*! \brief Get the number of external local ghost box for each sub-domain
* *
* \param id sub-domain id * \param id sub-domain id
...@@ -337,6 +347,61 @@ public: ...@@ -337,6 +347,61 @@ public:
return loc_ghost_box.get(i).ibx.get(j).bx; return loc_ghost_box.get(i).ibx.get(j).bx;
} }
/*! \brief Get the j internal local ghost box boundary position for the i sub-domain of the local processor
*
* \note For the sub-domain i intersected with the sub-domain j enlarged, the associated
* external ghost box is located in getLocalIGhostBox(j,k) with
* getLocalIGhostSub(j,k) == i
*
* To get k use getLocalIGhostE
*
* \see getLocalIGhostE
*
* Some of the intersection boxes has special position, because they are at the boundary, this function
* return their position at the border
*
\verbatim
[1,1]
+---------+------------------------+---------+
| (1,-1) | | (1,1) |
| | | (1,0) --> 7 | | |
| v | | v |
| 6 | | 8 |
+--------------------------------------------+
| | | |
| | | |
| | | |
| (-1,0) | | (1,0) |
| | | | | |
| v | (0,0) --> 4 | v |
| 3 | | 5 |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
+--------------------------------------------+
| (-1,-1) | | (-1,1) |
| | | (-1,0) --> 1 | | |
| v | | v |
| 0 | | 2 |
+---------+------------------------+---------+
\endverbatim
*
* \param i sub-domain
* \param j box
* \return the box
*
*/
inline const comb<dim> & getLocalIGhostPos(size_t i, size_t j) const
{
return loc_ghost_box.get(i).ibx.get(j).cmb;
}
/*! \brief Get the j external local ghost box for the local processor /*! \brief Get the j external local ghost box for the local processor
* *
* \param i sub-domain * \param i sub-domain
......
...@@ -66,7 +66,6 @@ class nn_prcs ...@@ -66,7 +66,6 @@ class nn_prcs
// cast the pointer // cast the pointer
nn_prcs<dim,T> * cd = static_cast< nn_prcs<dim,T> *>(ptr); nn_prcs<dim,T> * cd = static_cast< nn_prcs<dim,T> *>(ptr);
// Resize the memory
cd->nn_processor_subdomains[i].bx.resize(msg_i / sizeof(::Box<dim,T>) ); cd->nn_processor_subdomains[i].bx.resize(msg_i / sizeof(::Box<dim,T>) );
// Return the receive pointer // Return the receive pointer
...@@ -260,7 +259,7 @@ public: ...@@ -260,7 +259,7 @@ public:
{ {
for (size_t p = 0 ; p < getNNProcessors() ; p++) for (size_t p = 0 ; p < getNNProcessors() ; p++)
{ {
auto list_p_box = getNearSubdomains(IDtoProc(p)); const openfpm::vector< ::Box<dim,T> > & list_p_box = getNearSubdomains(IDtoProc(p));
// Create the smallest box contained in all sub-domain // Create the smallest box contained in all sub-domain
for (size_t b = 0 ; b < list_p_box.size() ; b++) for (size_t b = 0 ; b < list_p_box.size() ; b++)
...@@ -328,6 +327,8 @@ public: ...@@ -328,6 +327,8 @@ public:
} }
} }
nn_processor_subdomains.reserve(nn_processors.size());
// Get the sub-domains of the near processors // Get the sub-domains of the near processors
v_cl.sendrecvMultipleMessagesNBX(nn_processors,boxes,nn_prcs<dim,T>::message_alloc, this ,NEED_ALL_SIZE); v_cl.sendrecvMultipleMessagesNBX(nn_processors,boxes,nn_prcs<dim,T>::message_alloc, this ,NEED_ALL_SIZE);
...@@ -386,6 +387,7 @@ public: ...@@ -386,6 +387,7 @@ public:
std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " error this process rank is not adjacent to the local processor"; std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " error this process rank is not adjacent to the local processor";
} }
#endif #endif
return key->second.bx; return key->second.bx;
} }
......
This diff is collapsed.
...@@ -11,18 +11,13 @@ ...@@ -11,18 +11,13 @@
#include "vector_dist_key.hpp" #include "vector_dist_key.hpp"
#include "VCluster.hpp" #include "VCluster.hpp"
template<typename device_v>
class vector_dist_iterator class vector_dist_iterator
{ {
//! vector list counter
size_t v_c;
//! List of the grids we are going to iterate
Vcluster_object_array<device_v> & vList;
//! Actual iterator //! Actual iterator
size_t v_it; size_t v_it;
size_t stop;
public: public:
/*! \brief Constructor of the distributed grid /*! \brief Constructor of the distributed grid
...@@ -31,11 +26,9 @@ class vector_dist_iterator ...@@ -31,11 +26,9 @@ class vector_dist_iterator
* \param offset iterator starting point * \param offset iterator starting point
* *
*/ */
vector_dist_iterator(Vcluster_object_array<device_v> & gk, size_t offset = 0) vector_dist_iterator(size_t start, size_t stop)
:v_c(0),vList(gk),v_it(offset) :v_it(start),stop(stop)
{ {
if ( offset >= vList.get(0).size() )
v_c++;
} }
// Destructor // Destructor
...@@ -43,46 +36,16 @@ class vector_dist_iterator ...@@ -43,46 +36,16 @@ class vector_dist_iterator
{ {
} }
/*! \brief operator=
*
* assign
*
*/
vector_dist_iterator<device_v> & operator=(const vector_dist_iterator<device_v> & vdi)
{
v_c = vdi.v_c;
vList = vdi.vList;
v_it = vdi.v_it;
return *this;
}
/*! \brief Get the next element /*! \brief Get the next element
* *
* \return the next grid_key * \return the next grid_key
* *
*/ */
vector_dist_iterator<device_v> operator++() vector_dist_iterator operator++()
{ {
++v_it; ++v_it;
// check if a_it is at the end
if (v_it < vList.get(v_c).size())
return *this;
else
{
// switch to the new grid
v_c++;
// get the next grid iterator
if (v_c < vList.size())
v_it = 0;
}
return *this; return *this;
} }
...@@ -96,7 +59,7 @@ class vector_dist_iterator ...@@ -96,7 +59,7 @@ class vector_dist_iterator
{ {
// If there are no other grid stop // If there are no other grid stop
if (v_c >= vList.size()) if (v_it >= stop)
return false; return false;
return true; return true;
...@@ -109,7 +72,7 @@ class vector_dist_iterator ...@@ -109,7 +72,7 @@ class vector_dist_iterator
*/ */
vect_dist_key_dx get() vect_dist_key_dx get()
{ {
return vect_dist_key_dx(v_c,v_it); return vect_dist_key_dx(v_it);
} }
}; };
......
...@@ -18,26 +18,12 @@ ...@@ -18,26 +18,12 @@
class vect_dist_key_dx class vect_dist_key_dx
{ {
//! grid list counter
size_t v_c;
//! Local grid iterator //! Local grid iterator
size_t key; size_t key;
public: public:
/*! \brief Get the local grid
*
* \return the id of the local grid
*
*/
size_t getSub()
{
return v_c;
}
/*! \brief Get the key /*! \brief Get the key
* *
* \return the local key * \return the local key
...@@ -60,8 +46,8 @@ public: ...@@ -60,8 +46,8 @@ public:
return ts.str(); return ts.str();
} }
vect_dist_key_dx(int v_c, size_t key) vect_dist_key_dx(size_t key)
:v_c(v_c),key(key) :key(key)
{ {
} }
}; };
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment