Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F81817729
reference_manager_lammps.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Sep 8, 02:24
Size
7 KB
Mime Type
text/x-c++
Expires
Tue, Sep 10, 02:24 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20620811
Attached To
rLIBMULTISCALE LibMultiScale
reference_manager_lammps.cc
View Options
/**
* @file reference_manager_lammps.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Wed Mar 13 16:53:59 2013
*
* @brief This is the reference manager of the LAMMPS model which handles migrations
*
* @section LICENSE
*
* Copyright INRIA and CEA
*
* The LibMultiScale is a C++ parallel framework for the multiscale
* coupling methods dedicated to material simulations. This framework
* provides an API which makes it possible to program coupled simulations
* and integration of already existing codes.
*
* This Project was initiated in a collaboration between INRIA Futurs Bordeaux
* within ScAlApplix team and CEA/DPTA Ile de France.
* The project is now continued at the Ecole Polytechnique Fédérale de Lausanne
* within the LSMS/ENAC laboratory.
*
* This software is governed by the CeCILL-C license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL-C
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*
*/
/* -------------------------------------------------------------------------- */
#include "lm_common.hh"
#include "domain_lammps.hh"
#include "reference_manager_lammps.hh"
#include "trace_atom.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template <UInt Dim>
ReferenceManagerLammps<Dim>::
ReferenceManagerLammps(ContainerLammps<Dim> & global_container):
ReferenceManager<RefLammps<Dim> >(global_container){
}
/* -------------------------------------------------------------------------- */
template <UInt Dim>
void ReferenceManagerLammps<Dim>::sendAtom(UInt i,UInt proc){
if (!this->flag_need_check_movements) return;
RefLammps<Dim> refold(i);
IF_REF_TRACED(refold,
"sending atom to proc " << proc);
SET_REF_INTERNAL_TRACE_INDEX(refold,-1);
{
typename ReferenceManagerLammps<Dim>::MapRefToRef::iterator it = this->moved.begin();
typename ReferenceManagerLammps<Dim>::MapRefToRef::iterator end = this->moved.end();
while(it != end)
{
RefLammps<Dim> temp = (*it).first;
RefLammps<Dim> temp2 = (*it).second;
if (refold == temp2){
DUMP("l'atome que l'on veut envoyer a deja ete deplace de la ref "
<< temp << " vers " << temp2,DBG_DETAIL);
refold = temp;
this->moved.erase(temp);
LM_ASSERT(this->moved.count(temp) == 0,"pb avec la STL");
LM_ASSERT(refold.index_atom == temp.index_atom,"pb avec la STL");
break;
}
++it;
}
}
{
typename ReferenceManagerLammps<Dim>::MapRefToUInt::iterator it = this->sent.begin();
typename ReferenceManagerLammps<Dim>::MapRefToUInt::iterator end = this->sent.end();
while(it != end)
{
RefLammps<Dim> temp = (*it).first;
UInt proc2 = (*it).second;
if (refold == temp){
LM_FATAL("the atom " << refold
<< " that is requested to be sent was already sent to " << proc2
<< " and now it is to be sent to " << proc);
}
++it;
}
}
this->sent[refold] = proc;
this->sent_byproc[proc].push_back(refold);
this->have_changed = true;
}
/* -------------------------------------------------------------------------- */
template <UInt Dim>
void ReferenceManagerLammps<Dim>::moveAtom(UInt i,UInt j){
if (!this->flag_need_check_movements) return;
//pas la peine de faire un traitement si le deplacement ne fait rien
if (i == j){
return;
}
RefLammps<Dim> refold(i);
RefLammps<Dim> refnew(j);
IF_REF_TRACED(refnew,"atom moved in memory from " << i << " to " << j << " index");
SET_REF_INTERNAL_TRACE_INDEX(refnew,j);
DUMP("I move atom " << refold << " to "
<< refnew,DBG_INFO);
LM_ASSERT(!isnan(refnew.position0(0))
&& !isnan(refnew.position0(1))
&& !isnan(refnew.position0(2)),
"l'atome de reference " << refnew
<< " fait de la merde : pb de deplacement des atomes");
{
typename ReferenceManagerLammps<Dim>::MapUIntToRefList::iterator it = this->newatoms.begin();
typename ReferenceManagerLammps<Dim>::MapUIntToRefList::iterator end = this->newatoms.end();
while(it != end) {
std::vector<RefLammps<Dim> > & v = (*it).second;
#ifndef LM_OPTIMIZED
UInt proc = (*it).first;
#endif // LM_OPTIMIZED
for (UInt l = 0 ; l < v.size();++l){
DUMP("proc = " << proc << " v[" << l << "]="<< v[l],DBG_ALL);
LM_ASSERT(!(v[l] == refold),"houston on a un probleme " << v[l]
<< " was previously received from " << proc);
}
++it;
}
}
{
typename ReferenceManagerLammps<Dim>::MapRefToRef::iterator it = this->moved.begin();
typename ReferenceManagerLammps<Dim>::MapRefToRef::iterator end = this->moved.end();
while(it != end) {
RefLammps<Dim> temp = (*it).first;
RefLammps<Dim> temp2 = (*it).second;
if (refold == temp2){
DUMP("previously moved from " << temp << " to " << temp2
<< " : switching source from " << refold << " to "
<< temp ,DBG_DETAIL);
this->moved[temp]=refnew;
this->have_changed = true;
return;
}
++it;
}
}
this->moved[refold]=refnew;
this->have_changed = true;
}
/* -------------------------------------------------------------------------- */
template <UInt Dim>
void ReferenceManagerLammps<Dim>::acceptAtom(UInt i,UInt fromProc){
if (!this->flag_need_check_movements) return;
RefLammps<Dim> newref(i);
IF_REF_TRACED(newref,
"atom received from proc " << fromProc);
SET_REF_INTERNAL_TRACE_INDEX(newref,i);
this->newatoms[fromProc].push_back(newref);
DUMP("I accept atom " << newref << " from " << fromProc,DBG_ALL);
LM_ASSERT(!isnan(newref.position0(0))
&& !isnan(newref.position0(1))
&& !isnan(newref.position0(2)),
"l'atome de reference " << newref
<< "fait de la merde : pb dans la gestion des migrations "
<< "pour atome recu de " << fromProc);
{
typename ReferenceManagerLammps<Dim>::MapRefToRef::iterator it = this->moved.begin();
typename ReferenceManagerLammps<Dim>::MapRefToRef::iterator end = this->moved.end();
while(it != end) {
RefLammps<Dim> temp = (*it).first;
RefLammps<Dim> temp2 = (*it).second;
LM_ASSERT(!(newref == temp2),
"recois un atome a un emplacement deja utilise "
<< "par un deplacement depuis " << temp
<< " vers " << temp2);
++it;
}
}
LM_ASSERT(!isnan(newref.position0(0))
&& !isnan(newref.position0(1))
&& !isnan(newref.position0(2)),
"l'atome de reference " << newref
<< "fait de la merde : pb dans la gestion des migrations "
<< "pour atome recu de " << fromProc);
this->have_changed = true;
}
/* -------------------------------------------------------------------------- */
template class ReferenceManagerLammps<2>;
template class ReferenceManagerLammps<3>;
__END_LIBMULTISCALE__
Event Timeline
Log In to Comment