Memosa-FVM  0.2
Field Class Reference

#include <Field.h>

Inheritance diagram for Field:
Collaboration diagram for Field:

Public Types

typedef map< const StorageSite
*, shared_ptr< ArrayBase > > 
ArrayMap
 
typedef map< const StorageSite
*, vector< const StorageSite * > * > 
ChildSitesMap
 
typedef pair< const
StorageSite *, const
StorageSite * > 
EntryIndex
 
typedef map< EntryIndex,
shared_ptr< ArrayBase > > 
GhostArrayMap
 

Public Member Functions

 Field (const string &name)
 
virtual ~Field ()
 
 DEFINE_TYPENAME ("Field")
 
Fieldoperator= (const Field &oField)
 
const ArrayBaseoperator[] (const StorageSite &) const
 
ArrayBaseoperator[] (const StorageSite &)
 
shared_ptr< ArrayBasegetArrayPtr (const StorageSite &)
 
void addArray (const StorageSite &, shared_ptr< ArrayBase > a)
 
void removeArray (const StorageSite &)
 
void removeArrays (const StorageSiteList &sites)
 
virtual void copyFrom (const IContainer &a)
 
virtual void zero ()
 
virtual shared_ptr< IContainernewCopy () const
 
virtual shared_ptr< IContainernewClone () const
 
bool hasArray (const StorageSite &s) const
 
void syncLocal ()
 
ArrayMapgetArrayMap ()
 
GhostArrayMapgetGhostArrayMap ()
 
GhostArrayMapgetGhostArrayMapLevel1 ()
 
const string getName () const
 
void clear ()
 
- Public Member Functions inherited from IContainer
 IContainer ()
 
virtual ~IContainer ()
 
IContaineroperator= (const IContainer &oc)
 

Static Public Member Functions

static void syncLocalVectorFields (std::vector< Field * > &dsf)
 

Private Member Functions

 Field (const Field &)
 
void createSyncGatherArrays (const StorageSite &site)
 
void syncScatter (const StorageSite &site)
 
void syncGather (const StorageSite &site)
 
void createSyncGatherArraysLevel1 (const StorageSite &site)
 
void syncScatterLevel1 (const StorageSite &site)
 
void syncGatherLevel1 (const StorageSite &site)
 
int get_request_size ()
 
int get_request_size_scatter_level1 ()
 
int get_request_size_gather_level1 ()
 
void syncLocalLevel1 ()
 
ArrayBase_create (const StorageSite &site)
 

Static Private Member Functions

static void createSyncGatherArraysVectorFields (const StorageSite &site, Field &field, const size_t numDir)
 
static void syncScatterVectorFields (const StorageSite &site, std::vector< Field * > &dsf)
 
static void syncGatherVectorFields (const StorageSite &site, std::vector< Field * > &dsf)
 
static void createSyncGatherArraysVectorFieldsLevel1 (const StorageSite &site, Field &field, const size_t numDir)
 
static void syncScatterVectorFieldsLevel1 (const StorageSite &site, std::vector< Field * > &dsf)
 
static void syncGatherVectorFieldsLevel1 (const StorageSite &site, std::vector< Field * > &dsf)
 
static int get_request_size (Field &field)
 
static int get_request_size_level1 (Field &field)
 
static void syncLocalVectorFieldsLevel1 (std::vector< Field * > &dsf)
 

Private Attributes

const string _name
 
ArrayMap _arrays
 
GhostArrayMap _ghostArrays
 
GhostArrayMap _ghostArraysLevel1
 
ChildSitesMap _childSitesMap
 

Detailed Description

Definition at line 14 of file Field.h.

Member Typedef Documentation

typedef map<const StorageSite*, shared_ptr<ArrayBase> > Field::ArrayMap

Definition at line 17 of file Field.h.

typedef map<const StorageSite*, vector<const StorageSite*>* > Field::ChildSitesMap

Definition at line 18 of file Field.h.

typedef pair<const StorageSite*, const StorageSite*> Field::EntryIndex

Definition at line 19 of file Field.h.

typedef map<EntryIndex, shared_ptr<ArrayBase> > Field::GhostArrayMap

Definition at line 20 of file Field.h.

Constructor & Destructor Documentation

Field::Field ( const string &  name)

Definition at line 22 of file Field.cpp.

References logCtor.

Referenced by newClone(), and newCopy().

22  :
23  IContainer(),
24  _name(name),
25  _arrays()
26 {
27  logCtor();
28 }
const string _name
Definition: Field.h:90
ArrayMap _arrays
Definition: Field.h:91
#define logCtor()
Definition: RLogInterface.h:26
Field::~Field ( )
virtual

Definition at line 30 of file Field.cpp.

References logDtor.

31 {
32  logDtor();
33 }
#define logDtor()
Definition: RLogInterface.h:33
Field::Field ( const Field )
private

Member Function Documentation

ArrayBase & Field::_create ( const StorageSite site)
private

Definition at line 114 of file Field.cpp.

References _arrays, _childSitesMap, ArrayBase::createOffsetArray(), StorageSite::getCount(), StorageSite::getOffset(), StorageSite::getParent(), and operator[]().

Referenced by getArrayPtr(), and operator[]().

115 {
116  const StorageSite* parentSite = s.getParent();
117  if (parentSite)
118  {
119  ArrayBase& parentArray = operator[](*parentSite);
120  shared_ptr<ArrayBase> anew = parentArray.createOffsetArray(s.getOffset(),
121  s.getCount());
122  _arrays[&s]=anew;
123 
124  if (_childSitesMap.find(parentSite) == _childSitesMap.end())
125  _childSitesMap[parentSite] = new vector<const StorageSite*>();
126 
127  vector<const StorageSite*>& childSites = *_childSitesMap[parentSite];
128  childSites.push_back(&s);
129  return *anew;
130  }
131  else
132  {
133  ostringstream e;
134  e << "Field::operator[] No array found and no creator defined for "
135  << &s << endl;
136  throw CException(e.str());
137  }
138 }
virtual shared_ptr< ArrayBase > createOffsetArray(const int offset, const int size)=0
ArrayMap _arrays
Definition: Field.h:91
ChildSitesMap _childSitesMap
Definition: Field.h:95
const ArrayBase & operator[](const StorageSite &) const
Definition: Field.cpp:44
const StorageSite *const getParent() const
Definition: StorageSite.h:86
void Field::addArray ( const StorageSite s,
shared_ptr< ArrayBase a 
)

Definition at line 72 of file Field.cpp.

References _arrays, and removeArray().

Referenced by GradientModel< Vector< T, 3 > >::compute(), COMETModel< T >::ComputeCoarseMacroparameters(), COMETModel< T >::ComputeFineMacroparameters(), KineticModel< T >::computeIBFaceDsf(), COMETModel< T >::computeIBFaceDsf(), KineticModel< T >::computeSolidFaceDsf(), COMETModel< T >::computeSolidFaceDsf(), KineticModel< T >::computeSolidFacePressure(), COMETModel< T >::computeSolidFacePressure(), KineticModel< T >::computeSurfaceForce(), COMETModel< T >::computeSurfaceForce(), KineticModel< T >::ConservationofMFSolid(), DistFunctFields< X >::DistFunctFields(), COMETModel< T >::FinishCoarseMesh(), Grid::Grid(), SpeciesModel< T >::Impl::init(), PhononModel< T >::init(), KineticModel< T >::init(), BatteryModel< T >::Impl::init(), COMETModel< T >::init(), PlateDeformationModel< T >::init(), StructureDeformationModel< T >::init(), MovingMeshModel< T >::init(), COMETModel< T >::initCoarse(), COMETModel< T >::makeCellColors(), COMETModel< T >::MakeCoarseIndex(), COMETModel< T >::MakeCoarseMesh2(), COMETModel< T >::MakeIBCoarseModel(), COMETModel< T >::makePlotColors(), StructureDeformationModel< T >::updateBoundaryMesh(), PlateDeformationModel< T >::updateBoundaryMesh(), PhononModel< T >::updateHeatFlux(), and VTKWriter< T >::VTKWriter().

73 {
74  removeArray(s);
75  _arrays[&s]=a;
76 }
ArrayMap _arrays
Definition: Field.h:91
void removeArray(const StorageSite &)
Definition: Field.cpp:79
void Field::clear ( )

Definition at line 105 of file Field.cpp.

References _arrays, _childSitesMap, _ghostArrays, and _ghostArraysLevel1.

106 {
107  _arrays.clear();
108  _childSitesMap.clear();
109  _ghostArrays.clear();
110  _ghostArraysLevel1.clear();
111 }
ArrayMap _arrays
Definition: Field.h:91
ChildSitesMap _childSitesMap
Definition: Field.h:95
GhostArrayMap _ghostArraysLevel1
Definition: Field.h:93
GhostArrayMap _ghostArrays
Definition: Field.h:92
void Field::copyFrom ( const IContainer a)
virtual

Implements IContainer.

Definition at line 187 of file Field.cpp.

References operator=().

188 {
189  const Field& other = dynamic_cast<const Field&>(oc);
190  operator=(other);
191 }
Field & operator=(const Field &oField)
Definition: Field.cpp:177
Definition: Field.h:14
void Field::createSyncGatherArrays ( const StorageSite site)
private

Definition at line 195 of file Field.cpp.

References _ghostArrays, StorageSite::getGatherMap(), Array< T >::getLength(), ArrayBase::newSizedClone(), and operator[]().

Referenced by syncLocal().

196 {
197  ArrayBase& thisArray = operator[](site);
198 
199  const StorageSite::GatherMap& gatherMap = site.getGatherMap();
200 
201  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap)
202  {
203  const StorageSite& oSite = *mpos.first;
204  EntryIndex e(&oSite, &site);
205  const Array<int>& toIndices = *(mpos.second);
206  if (_ghostArrays.find(e) == _ghostArrays.end())
207  {
208  _ghostArrays[e] = thisArray.newSizedClone(toIndices.getLength());
209  }
210  }
211 }
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
const ArrayBase & operator[](const StorageSite &) const
Definition: Field.cpp:44
GhostArrayMap _ghostArrays
Definition: Field.h:92
virtual shared_ptr< ArrayBase > newSizedClone(const int size) const =0
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
int getLength() const
Definition: Array.h:87
void Field::createSyncGatherArraysLevel1 ( const StorageSite site)
private

Definition at line 214 of file Field.cpp.

References _ghostArraysLevel1, StorageSite::getGatherMapLevel1(), Array< T >::getLength(), ArrayBase::newSizedClone(), and operator[]().

Referenced by syncLocalLevel1().

215 {
216  ArrayBase& thisArray = operator[](site);
217 
218  const StorageSite::GatherMap& gatherMap = site.getGatherMapLevel1();
219 
220  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap)
221  {
222  const StorageSite& oSite = *mpos.first;
223  EntryIndex e(&oSite, &site);
224  const Array<int>& toIndices = *(mpos.second);
225  if (_ghostArraysLevel1.find(e) == _ghostArraysLevel1.end())
226  {
227  _ghostArraysLevel1[e] = thisArray.newSizedClone(toIndices.getLength());
228  }
229  }
230 }
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
GhostArrayMap _ghostArraysLevel1
Definition: Field.h:93
const ArrayBase & operator[](const StorageSite &) const
Definition: Field.cpp:44
virtual shared_ptr< ArrayBase > newSizedClone(const int size) const =0
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
int getLength() const
Definition: Array.h:87
void Field::createSyncGatherArraysVectorFields ( const StorageSite site,
Field field,
const size_t  numDir 
)
staticprivate

Definition at line 528 of file Field.cpp.

References StorageSite::getGatherMap(), getGhostArrayMap(), Array< T >::getLength(), and ArrayBase::newSizedClone().

Referenced by syncLocalVectorFields().

529 {
530  ArrayBase& thisArray = field[site];
531  GhostArrayMap& ghostArrays = field.getGhostArrayMap();
532 
533  const StorageSite::GatherMap& gatherMap = site.getGatherMap();
534 
535  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap)
536  {
537  const StorageSite& oSite = *mpos.first;
538  EntryIndex e(&oSite, &site);
539  const Array<int>& toIndices = *(mpos.second);
540  if (ghostArrays.find(e) == ghostArrays.end())
541  {
542  ghostArrays[e] = thisArray.newSizedClone(toIndices.getLength() * numDir);
543  }
544  }
545 }
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
map< EntryIndex, shared_ptr< ArrayBase > > GhostArrayMap
Definition: Field.h:20
virtual shared_ptr< ArrayBase > newSizedClone(const int size) const =0
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
GhostArrayMap & getGhostArrayMap()
Definition: Field.h:50
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
int getLength() const
Definition: Array.h:87
void Field::createSyncGatherArraysVectorFieldsLevel1 ( const StorageSite site,
Field field,
const size_t  numDir 
)
staticprivate

Definition at line 548 of file Field.cpp.

References StorageSite::getGatherMapLevel1(), getGhostArrayMapLevel1(), Array< T >::getLength(), and ArrayBase::newSizedClone().

Referenced by syncLocalVectorFieldsLevel1().

549 {
550  ArrayBase& thisArray = field[site];
551  GhostArrayMap& ghostArrays = field.getGhostArrayMapLevel1();
552 
553  const StorageSite::GatherMap& gatherMap = site.getGatherMapLevel1();
554 
555  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap)
556  {
557  const StorageSite& oSite = *mpos.first;
558  EntryIndex e(&oSite, &site);
559  const Array<int>& toIndices = *(mpos.second);
560  if (ghostArrays.find(e) == ghostArrays.end())
561  {
562  ghostArrays[e] = thisArray.newSizedClone(toIndices.getLength() * numDir);
563  }
564  }
565 }
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
map< EntryIndex, shared_ptr< ArrayBase > > GhostArrayMap
Definition: Field.h:20
GhostArrayMap & getGhostArrayMapLevel1()
Definition: Field.h:51
virtual shared_ptr< ArrayBase > newSizedClone(const int size) const =0
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
int getLength() const
Definition: Array.h:87
Field::DEFINE_TYPENAME ( "Field"  )
int Field::get_request_size ( )
private

Definition at line 397 of file Field.cpp.

References _arrays, StorageSite::getGatherProcID(), and StorageSite::getScatterMap().

Referenced by syncLocal(), and syncLocalVectorFields().

398 {
399  int indx = 0;
400  foreach(ArrayMap::value_type& pos, _arrays){
401  const StorageSite& site = *pos.first;
402  const StorageSite::ScatterMap& scatterMap = site.getScatterMap();
403  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
404  const StorageSite& oSite = *mpos.first;
405  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
406  if ( oSite.getGatherProcID() != -1 )
407  indx++;
408  }
409  }
410  return indx;
411 
412 }
ArrayMap _arrays
Definition: Field.h:91
int getGatherProcID() const
Definition: StorageSite.h:83
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
int Field::get_request_size ( Field field)
staticprivate

Definition at line 843 of file Field.cpp.

References getArrayMap(), StorageSite::getGatherProcID(), and StorageSite::getScatterMap().

844 {
845  ArrayMap& arrays = field.getArrayMap();
846  int indx = 0;
847  foreach(ArrayMap::value_type& pos, arrays){
848  const StorageSite& site = *pos.first;
849  const StorageSite::ScatterMap& scatterMap = site.getScatterMap();
850  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
851  const StorageSite& oSite = *mpos.first;
852  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
853  if ( oSite.getGatherProcID() != -1 )
854  indx++;
855  }
856  }
857  return indx;
858 
859 }
ArrayMap & getArrayMap()
Definition: Field.h:48
int getGatherProcID() const
Definition: StorageSite.h:83
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
map< const StorageSite *, shared_ptr< ArrayBase > > ArrayMap
Definition: Field.h:17
int Field::get_request_size_gather_level1 ( )
private

Definition at line 506 of file Field.cpp.

References _arrays, StorageSite::getGatherMapLevel1(), and StorageSite::getGatherProcID().

Referenced by syncLocalLevel1().

507 {
508  int indx = 0;
509  foreach(ArrayMap::value_type& pos, _arrays){
510  const StorageSite& site = *pos.first;
511  const StorageSite::GatherMap& gatherMap = site.getGatherMapLevel1();
512  if ( pos.second->getLength() == pos.first->getCountLevel1() ){
513  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap){
514  const StorageSite& oSite = *mpos.first;
515  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
516  if ( oSite.getGatherProcID() != -1 )
517  indx++;
518  }
519  }
520  }
521  return indx;
522 
523 }
ArrayMap _arrays
Definition: Field.h:91
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
int getGatherProcID() const
Definition: StorageSite.h:83
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
int Field::get_request_size_level1 ( Field field)
staticprivate

Definition at line 863 of file Field.cpp.

References getArrayMap(), StorageSite::getGatherProcID(), and StorageSite::getScatterMapLevel1().

Referenced by syncLocalVectorFieldsLevel1().

864 {
865  ArrayMap& arrays = field.getArrayMap();
866  int indx = 0;
867  foreach(ArrayMap::value_type& pos, arrays){
868  const StorageSite& site = *pos.first;
869  const StorageSite::ScatterMap& scatterMap = site.getScatterMapLevel1();
870  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
871  const StorageSite& oSite = *mpos.first;
872  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
873  if ( oSite.getGatherProcID() != -1 )
874  indx++;
875  }
876  }
877  return indx;
878 
879 }
ArrayMap & getArrayMap()
Definition: Field.h:48
const ScatterMap & getScatterMapLevel1() const
Definition: StorageSite.h:73
int getGatherProcID() const
Definition: StorageSite.h:83
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
map< const StorageSite *, shared_ptr< ArrayBase > > ArrayMap
Definition: Field.h:17
int Field::get_request_size_scatter_level1 ( )
private

Definition at line 486 of file Field.cpp.

References _arrays, StorageSite::getGatherProcID(), and StorageSite::getScatterMapLevel1().

Referenced by syncLocalLevel1().

487 {
488  int indx = 0;
489  foreach(ArrayMap::value_type& pos, _arrays){
490  const StorageSite& site = *pos.first;
491  const StorageSite::ScatterMap& scatterMap = site.getScatterMapLevel1();
492  if ( pos.second->getLength() == pos.first->getCountLevel1() ){
493  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
494  const StorageSite& oSite = *mpos.first;
495  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
496  if ( oSite.getGatherProcID() != -1 )
497  indx++;
498  }
499  }
500  }
501  return indx;
502 
503 }
ArrayMap _arrays
Definition: Field.h:91
const ScatterMap & getScatterMapLevel1() const
Definition: StorageSite.h:73
int getGatherProcID() const
Definition: StorageSite.h:83
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
ArrayMap& Field::getArrayMap ( )
inline

Definition at line 48 of file Field.h.

References _arrays.

Referenced by get_request_size(), get_request_size_level1(), syncLocalVectorFields(), and syncLocalVectorFieldsLevel1().

48 { return _arrays;}
ArrayMap _arrays
Definition: Field.h:91
GhostArrayMap& Field::getGhostArrayMap ( )
inline

Definition at line 50 of file Field.h.

References _ghostArrays.

Referenced by createSyncGatherArraysVectorFields(), syncGatherVectorFields(), syncLocalVectorFields(), and syncScatterVectorFields().

50 { return _ghostArrays;}
GhostArrayMap _ghostArrays
Definition: Field.h:92
GhostArrayMap& Field::getGhostArrayMapLevel1 ( )
inline
const string Field::getName ( ) const
inline

Definition at line 57 of file Field.h.

References _name.

57 {return _name;}
const string _name
Definition: Field.h:90
shared_ptr< IContainer > Field::newClone ( ) const
virtual

Implements IContainer.

Definition at line 141 of file Field.cpp.

References _arrays, _name, and Field().

142 {
143  shared_ptr<Field> c(new Field(_name));
144 
145  foreach(const ArrayMap::value_type& pos, _arrays)
146  {
147  c->addArray(*(pos.first),
148  dynamic_pointer_cast<ArrayBase>(pos.second->newClone()));
149  }
150  return c;
151 }
Field(const string &name)
Definition: Field.cpp:22
const string _name
Definition: Field.h:90
ArrayMap _arrays
Definition: Field.h:91
shared_ptr< IContainer > Field::newCopy ( ) const
virtual

Implements IContainer.

Definition at line 155 of file Field.cpp.

References _arrays, _name, and Field().

156 {
157  shared_ptr<Field> c(new Field(_name));
158  foreach(const ArrayMap::value_type& pos, _arrays)
159  {
160  c->addArray(*(pos.first),
161  dynamic_pointer_cast<ArrayBase>(pos.second->newCopy()));
162  }
163  return c;
164 }
Field(const string &name)
Definition: Field.cpp:22
const string _name
Definition: Field.h:90
ArrayMap _arrays
Definition: Field.h:91
Field & Field::operator= ( const Field oField)

Definition at line 177 of file Field.cpp.

References _arrays.

Referenced by copyFrom().

178 {
179  foreach(ArrayMap::value_type& pos, _arrays)
180  {
181  *pos.second = oField[*pos.first];
182  }
183  return *this;
184 }
ArrayMap _arrays
Definition: Field.h:91
const ArrayBase & Field::operator[] ( const StorageSite s) const

Definition at line 44 of file Field.cpp.

References _arrays.

Referenced by _create(), createSyncGatherArrays(), createSyncGatherArraysLevel1(), syncGather(), syncGatherLevel1(), syncScatter(), and syncScatterLevel1().

45 {
46  ArrayMap::const_iterator pos = _arrays.find(&s);
47  if (pos != _arrays.end())
48  return *pos->second;
49  return const_cast<Field&>(*this)._create(s);
50 }
ArrayMap _arrays
Definition: Field.h:91
ArrayBase & Field::operator[] ( const StorageSite s)

Definition at line 53 of file Field.cpp.

References _arrays, and _create().

54 {
55  ArrayMap::iterator pos = _arrays.find(&s);
56  if (pos != _arrays.end())
57  return *pos->second;
58 
59  return _create(s);
60 }
ArrayMap _arrays
Definition: Field.h:91
ArrayBase & _create(const StorageSite &site)
Definition: Field.cpp:114
void Field::removeArray ( const StorageSite s)

Definition at line 79 of file Field.cpp.

References _arrays, and _childSitesMap.

Referenced by addArray(), and removeArrays().

80 {
81  if (_childSitesMap.find(&s) != _childSitesMap.end())
82  {
83  vector<const StorageSite*>& childSites = *_childSitesMap[&s];
84  foreach (const StorageSite* site,childSites)
85  {
86  removeArray(*site);
87  }
88  delete &childSites;
89  _childSitesMap.erase(&s);
90 
91  }
92  _arrays.erase(&s);
93 }
ArrayMap _arrays
Definition: Field.h:91
ChildSitesMap _childSitesMap
Definition: Field.h:95
void removeArray(const StorageSite &)
Definition: Field.cpp:79
void Field::removeArrays ( const StorageSiteList sites)

Definition at line 96 of file Field.cpp.

References removeArray().

97 {
98  foreach(const StorageSite* s, sites)
99  {
100  removeArray(*s);
101  }
102 }
void removeArray(const StorageSite &)
Definition: Field.cpp:79
void Field::syncGather ( const StorageSite site)
private

Definition at line 280 of file Field.cpp.

References _ghostArrays, ArrayBase::gather(), StorageSite::getGatherMap(), and operator[]().

Referenced by syncLocal().

281 {
282  ArrayBase& thisArray = operator[](site);
283 
284  const StorageSite::GatherMap& gatherMap = site.getGatherMap();
285 
286  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap)
287  {
288  const StorageSite& oSite = *mpos.first;
289  const Array<int>& toIndices = *(mpos.second);
290  EntryIndex e(&oSite, &site);
291 
292  if (_ghostArrays.find(e) == _ghostArrays.end())
293  {
294  ostringstream e;
295  e << "Field::syncScatter: ghost array not found for"
296  << &oSite << endl;
297  throw CException(e.str());
298  }
299 
300  const ArrayBase& ghostArray = *_ghostArrays[e];
301  thisArray.gather(ghostArray,toIndices);
302  }
303 }
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
const ArrayBase & operator[](const StorageSite &) const
Definition: Field.cpp:44
GhostArrayMap _ghostArrays
Definition: Field.h:92
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
virtual void gather(const ArrayBase &other_, const ArrayBase &indices, const int offset=0)=0
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
void Field::syncGatherLevel1 ( const StorageSite site)
private

Definition at line 307 of file Field.cpp.

References _ghostArraysLevel1, ArrayBase::gather(), StorageSite::getGatherMapLevel1(), and operator[]().

Referenced by syncLocalLevel1().

308 {
309  ArrayBase& thisArray = operator[](site);
310 
311  const StorageSite::GatherMap& gatherMap = site.getGatherMapLevel1();
312 
313  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap)
314  {
315  const StorageSite& oSite = *mpos.first;
316  const Array<int>& toIndices = *(mpos.second);
317  EntryIndex e(&oSite, &site);
318 
319  if (_ghostArraysLevel1.find(e) == _ghostArraysLevel1.end())
320  {
321  ostringstream e;
322  e << "Field::syncScatter: ghost array not found for"
323  << &oSite << endl;
324  throw CException(e.str());
325  }
326 
327  const ArrayBase& ghostArray = *_ghostArraysLevel1[e];
328  thisArray.gather(ghostArray,toIndices);
329  }
330 }
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
GhostArrayMap _ghostArraysLevel1
Definition: Field.h:93
const ArrayBase & operator[](const StorageSite &) const
Definition: Field.cpp:44
virtual void gather(const ArrayBase &other_, const ArrayBase &indices, const int offset=0)=0
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
void Field::syncGatherVectorFields ( const StorageSite site,
std::vector< Field * > &  dsf 
)
staticprivate

Definition at line 633 of file Field.cpp.

References ArrayBase::gather(), StorageSite::getGatherMap(), getGhostArrayMap(), and Array< T >::getLength().

Referenced by syncLocalVectorFields().

634 {
635 
636  const size_t numDir = dsf.size();
637  Field& field0 = *dsf[0];
638  GhostArrayMap& ghostArrays = field0.getGhostArrayMap();
639 
640  const StorageSite::GatherMap& gatherMap = site.getGatherMap();
641 
642  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap)
643  {
644  const StorageSite& oSite = *mpos.first;
645  const Array<int>& toIndices = *(mpos.second);
646  EntryIndex e(&oSite, &site);
647 
648  if (ghostArrays.find(e) == ghostArrays.end())
649  {
650  ostringstream e;
651  e << "Field::syncScatter: ghost array not found for"
652  << &oSite << endl;
653  throw CException(e.str());
654  }
655 
656  const ArrayBase& ghostArray = *ghostArrays[e];
657  const int chunkSize = toIndices.getLength();
658  for (size_t dir = 0; dir < numDir; dir++){
659  Field& field = *dsf[dir];
660  ArrayBase& thisArray = field[site];
661  const size_t offset = dir * chunkSize;
662  thisArray.gather(ghostArray,toIndices, offset);
663  }
664  }
665 }
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
Definition: Field.h:14
map< EntryIndex, shared_ptr< ArrayBase > > GhostArrayMap
Definition: Field.h:20
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
virtual void gather(const ArrayBase &other_, const ArrayBase &indices, const int offset=0)=0
GhostArrayMap & getGhostArrayMap()
Definition: Field.h:50
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
int getLength() const
Definition: Array.h:87
void Field::syncGatherVectorFieldsLevel1 ( const StorageSite site,
std::vector< Field * > &  dsf 
)
staticprivate

Definition at line 668 of file Field.cpp.

References ArrayBase::gather(), StorageSite::getGatherMapLevel1(), getGhostArrayMapLevel1(), and Array< T >::getLength().

Referenced by syncLocalVectorFieldsLevel1().

669 {
670 
671  const size_t numDir = dsf.size();
672  Field& field0 = *dsf[0];
673  GhostArrayMap& ghostArrays = field0.getGhostArrayMapLevel1();
674 
675  const StorageSite::GatherMap& gatherMap = site.getGatherMapLevel1();
676 
677  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap)
678  {
679  const StorageSite& oSite = *mpos.first;
680  const Array<int>& toIndices = *(mpos.second);
681  EntryIndex e(&oSite, &site);
682 
683  if (ghostArrays.find(e) == ghostArrays.end())
684  {
685  ostringstream e;
686  e << "Field::syncScatter: ghost array not found for"
687  << &oSite << endl;
688  throw CException(e.str());
689  }
690 
691  const ArrayBase& ghostArray = *ghostArrays[e];
692  const int chunkSize = toIndices.getLength();
693  for (size_t dir = 0; dir < numDir; dir++){
694  Field& field = *dsf[dir];
695  ArrayBase& thisArray = field[site];
696  const size_t offset = dir * chunkSize;
697  thisArray.gather(ghostArray,toIndices, offset);
698  }
699  }
700 }
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
Definition: Field.h:14
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
map< EntryIndex, shared_ptr< ArrayBase > > GhostArrayMap
Definition: Field.h:20
GhostArrayMap & getGhostArrayMapLevel1()
Definition: Field.h:51
virtual void gather(const ArrayBase &other_, const ArrayBase &indices, const int offset=0)=0
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
int getLength() const
Definition: Array.h:87
void Field::syncLocal ( )

Definition at line 334 of file Field.cpp.

References _arrays, _ghostArrays, createSyncGatherArrays(), get_request_size(), ArrayBase::getData(), ArrayBase::getDataSize(), StorageSite::getGatherMap(), StorageSite::getGatherProcID(), StorageSite::getScatterMap(), StorageSite::getTag(), syncGather(), syncLocalLevel1(), and syncScatter().

Referenced by GradientModel< Vector< T, 3 > >::compute(), SpeciesModel< T >::Impl::init(), BatteryModel< T >::Impl::init(), COMETModel< T >::init(), BatteryModel< T >::Impl::linearizeSpecies(), COMETModel< T >::MakeCoarseModel(), COMETModel< T >::MakeIBCoarseModel(), COMETModel< T >::MakeParallel(), and IBManager::update().

335 {
336  // scatter first (prepare ship packages)
337  foreach(ArrayMap::value_type& pos, _arrays)
338  syncScatter(*pos.first);
339 
340  foreach(ArrayMap::value_type& pos, _arrays)
341  createSyncGatherArrays(*pos.first);
342 
343 #ifdef FVM_PARALLEL
344  //SENDING
345  MPI::Request request_send[ get_request_size() ];
346  MPI::Request request_recv[ get_request_size() ];
347  int indxSend = 0;
348  int indxRecv = 0;
349  foreach(ArrayMap::value_type& pos, _arrays){
350  const StorageSite& site = *pos.first;
351  const StorageSite::ScatterMap& scatterMap = site.getScatterMap();
352  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
353  const StorageSite& oSite = *mpos.first;
354  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
355  EntryIndex e(&site,&oSite);
356  ArrayBase& sendArray = *_ghostArrays[e];
357  int to_where = oSite.getGatherProcID();
358  if ( to_where != -1 ){
359  int mpi_tag = oSite.getTag();
360  request_send[indxSend++] =
361  MPI::COMM_WORLD.Isend( sendArray.getData(), sendArray.getDataSize(), MPI::BYTE, to_where, mpi_tag );
362  }
363  }
364  //RECIEVING
365  //getting values from other meshes to fill g
366  const StorageSite::GatherMap& gatherMap = site.getGatherMap();
367  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap){
368  const StorageSite& oSite = *mpos.first;
369  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
370  EntryIndex e(&oSite,&site);
371  ArrayBase& recvArray = *_ghostArrays[e];
372  int from_where = oSite.getGatherProcID();
373  if ( from_where != -1 ){
374  int mpi_tag = oSite.getTag();
375  request_recv[indxRecv++] =
376  MPI::COMM_WORLD.Irecv( recvArray.getData(), recvArray.getDataSize(), MPI::BYTE, from_where, mpi_tag );
377  }
378  }
379  }
380 
381  int count = get_request_size();
382  MPI::Request::Waitall( count, request_recv );
383  MPI::Request::Waitall( count, request_send );
384 #endif
385 
386  // gather
387  foreach(ArrayMap::value_type& pos, _arrays)
388  syncGather(*pos.first);
389 
390 
391  //sycnLocal1
392  syncLocalLevel1();
393 
394 }
virtual int getDataSize() const =0
ArrayMap _arrays
Definition: Field.h:91
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
void syncScatter(const StorageSite &site)
Definition: Field.cpp:234
int get_request_size()
Definition: Field.cpp:397
int getTag() const
Definition: StorageSite.h:84
int getGatherProcID() const
Definition: StorageSite.h:83
void syncGather(const StorageSite &site)
Definition: Field.cpp:280
void createSyncGatherArrays(const StorageSite &site)
Definition: Field.cpp:195
GhostArrayMap _ghostArrays
Definition: Field.h:92
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
virtual void * getData() const =0
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
void syncLocalLevel1()
Definition: Field.cpp:417
void Field::syncLocalLevel1 ( )
private

Definition at line 417 of file Field.cpp.

References _arrays, _ghostArraysLevel1, createSyncGatherArraysLevel1(), get_request_size_gather_level1(), get_request_size_scatter_level1(), ArrayBase::getData(), ArrayBase::getDataSize(), StorageSite::getGatherMapLevel1(), StorageSite::getGatherProcID(), StorageSite::getScatterMapLevel1(), StorageSite::getTag(), syncGatherLevel1(), and syncScatterLevel1().

Referenced by syncLocal().

418 {
419 
420  // scatter first (prepare ship packages)
421  foreach(ArrayMap::value_type& pos, _arrays){
422  if ( pos.second->getLength() == pos.first->getCountLevel1() )
423  syncScatterLevel1(*pos.first);
424  }
425 
426  foreach(ArrayMap::value_type& pos, _arrays){
427  if ( pos.second->getLength() == pos.first->getCountLevel1() )
428  createSyncGatherArraysLevel1(*pos.first);
429  }
430 
431 #ifdef FVM_PARALLEL
432  //SENDING
433  int countScatter = get_request_size_scatter_level1();
434  int countGather = get_request_size_gather_level1();
435  MPI::Request request_send[ countScatter ];
436  MPI::Request request_recv[ countGather ];
437  int indxSend = 0;
438  int indxRecv = 0;
439  foreach(ArrayMap::value_type& pos, _arrays){
440  const StorageSite& site = *pos.first;
441  if ( pos.second->getLength() == pos.first->getCountLevel1() ){
442  const StorageSite::ScatterMap& scatterMap = site.getScatterMapLevel1();
443  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
444  const StorageSite& oSite = *mpos.first;
445  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
446  EntryIndex e(&site,&oSite);
447  ArrayBase& sendArray = *_ghostArraysLevel1[e];
448  int to_where = oSite.getGatherProcID();
449  if ( to_where != -1 ){
450  int mpi_tag = oSite.getTag();
451  request_send[indxSend++] =
452  MPI::COMM_WORLD.Isend( sendArray.getData(), sendArray.getDataSize(), MPI::BYTE, to_where, mpi_tag );
453  }
454  }
455  //RECIEVING
456  //getting values from other meshes to fill g
457  const StorageSite::GatherMap& gatherMap = site.getGatherMapLevel1();
458  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap){
459  const StorageSite& oSite = *mpos.first;
460  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
461  EntryIndex e(&oSite,&site);
462  ArrayBase& recvArray = *_ghostArraysLevel1[e];
463  int from_where = oSite.getGatherProcID();
464  if ( from_where != -1 ){
465  int mpi_tag = oSite.getTag();
466  request_recv[indxRecv++] =
467  MPI::COMM_WORLD.Irecv( recvArray.getData(), recvArray.getDataSize(), MPI::BYTE, from_where, mpi_tag );
468  }
469  }
470 
471  }
472  }
473 
474  MPI::Request::Waitall( countGather, request_recv );
475  MPI::Request::Waitall( countScatter, request_send );
476 #endif
477 
478  // gather
479  foreach(ArrayMap::value_type& pos, _arrays){
480  if ( pos.second->getLength() == pos.first->getCountLevel1() )
481  syncGatherLevel1(*pos.first);
482  }
483 }
virtual int getDataSize() const =0
ArrayMap _arrays
Definition: Field.h:91
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
const ScatterMap & getScatterMapLevel1() const
Definition: StorageSite.h:73
GhostArrayMap _ghostArraysLevel1
Definition: Field.h:93
int getTag() const
Definition: StorageSite.h:84
int getGatherProcID() const
Definition: StorageSite.h:83
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
void syncScatterLevel1(const StorageSite &site)
Definition: Field.cpp:257
int get_request_size_scatter_level1()
Definition: Field.cpp:486
void syncGatherLevel1(const StorageSite &site)
Definition: Field.cpp:307
int get_request_size_gather_level1()
Definition: Field.cpp:506
virtual void * getData() const =0
void createSyncGatherArraysLevel1(const StorageSite &site)
Definition: Field.cpp:214
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
void Field::syncLocalVectorFields ( std::vector< Field * > &  dsf)
static

Definition at line 702 of file Field.cpp.

References createSyncGatherArraysVectorFields(), get_request_size(), getArrayMap(), ArrayBase::getData(), ArrayBase::getDataSize(), StorageSite::getGatherMap(), StorageSite::getGatherProcID(), getGhostArrayMap(), StorageSite::getScatterMap(), StorageSite::getTag(), syncGatherVectorFields(), syncLocalVectorFieldsLevel1(), and syncScatterVectorFields().

Referenced by COMETModel< T >::MakeParallel().

703 {
704  // scatter first (prepare ship packages)
705  Field& field0 = *dsf[0];
706  ArrayMap& arrays = field0.getArrayMap();
707  foreach(ArrayMap::value_type& pos, arrays)
708  Field::syncScatterVectorFields(*pos.first, dsf);
709 
710  const size_t numDir = dsf.size();
711  foreach(ArrayMap::value_type& pos, arrays)
712  Field::createSyncGatherArraysVectorFields(*pos.first, field0, numDir );
713 
714  GhostArrayMap& ghostArrays = field0.getGhostArrayMap();
715 
716 #ifdef FVM_PARALLEL
717  //SENDING
718  MPI::Request request_send[ Field::get_request_size(field0) ];
719  MPI::Request request_recv[ Field::get_request_size(field0) ];
720  int indxSend = 0;
721  int indxRecv = 0;
722  foreach(ArrayMap::value_type& pos, arrays){
723  const StorageSite& site = *pos.first;
724  const StorageSite::ScatterMap& scatterMap = site.getScatterMap();
725  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
726  const StorageSite& oSite = *mpos.first;
727  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
728  EntryIndex e(&site,&oSite);
729  ArrayBase& sendArray = *ghostArrays[e];
730  int to_where = oSite.getGatherProcID();
731  if ( to_where != -1 ){
732  int mpi_tag = oSite.getTag();
733  request_send[indxSend++] =
734  MPI::COMM_WORLD.Isend( sendArray.getData(), sendArray.getDataSize(), MPI::BYTE, to_where, mpi_tag );
735  }
736  }
737  //RECIEVING
738  //getting values from other meshes to fill g
739  const StorageSite::GatherMap& gatherMap = site.getGatherMap();
740  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap){
741  const StorageSite& oSite = *mpos.first;
742  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
743  EntryIndex e(&oSite,&site);
744  ArrayBase& recvArray = *ghostArrays[e];
745  int from_where = oSite.getGatherProcID();
746  if ( from_where != -1 ){
747  int mpi_tag = oSite.getTag();
748  request_recv[indxRecv++] =
749  MPI::COMM_WORLD.Irecv( recvArray.getData(), recvArray.getDataSize(), MPI::BYTE, from_where, mpi_tag );
750  }
751  }
752  }
753 
754  int count = Field::get_request_size(field0);
755  MPI::Request::Waitall( count, request_recv );
756  MPI::Request::Waitall( count, request_send );
757 #endif
758 
759  // gather
760  foreach(ArrayMap::value_type& pos, arrays)
761  Field::syncGatherVectorFields(*pos.first, dsf);
762 
763 
764  //sycnLocal1
765 
767 }
virtual int getDataSize() const =0
static void syncScatterVectorFields(const StorageSite &site, std::vector< Field * > &dsf)
Definition: Field.cpp:569
static void syncGatherVectorFields(const StorageSite &site, std::vector< Field * > &dsf)
Definition: Field.cpp:633
ArrayMap & getArrayMap()
Definition: Field.h:48
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
Definition: Field.h:14
static void createSyncGatherArraysVectorFields(const StorageSite &site, Field &field, const size_t numDir)
Definition: Field.cpp:528
map< EntryIndex, shared_ptr< ArrayBase > > GhostArrayMap
Definition: Field.h:20
static void syncLocalVectorFieldsLevel1(std::vector< Field * > &dsf)
Definition: Field.cpp:770
int get_request_size()
Definition: Field.cpp:397
int getTag() const
Definition: StorageSite.h:84
int getGatherProcID() const
Definition: StorageSite.h:83
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
const GatherMap & getGatherMap() const
Definition: StorageSite.h:59
virtual void * getData() const =0
GhostArrayMap & getGhostArrayMap()
Definition: Field.h:50
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
map< const StorageSite *, shared_ptr< ArrayBase > > ArrayMap
Definition: Field.h:17
void Field::syncLocalVectorFieldsLevel1 ( std::vector< Field * > &  dsf)
staticprivate

Definition at line 770 of file Field.cpp.

References createSyncGatherArraysVectorFieldsLevel1(), get_request_size_level1(), getArrayMap(), ArrayBase::getData(), ArrayBase::getDataSize(), StorageSite::getGatherMapLevel1(), StorageSite::getGatherProcID(), getGhostArrayMapLevel1(), StorageSite::getScatterMapLevel1(), StorageSite::getTag(), syncGatherVectorFieldsLevel1(), and syncScatterVectorFieldsLevel1().

Referenced by syncLocalVectorFields().

771 {
772  // scatter first (prepare ship packages)
773  Field& field0 = *dsf[0];
774  ArrayMap& arrays = field0.getArrayMap();
775  foreach(ArrayMap::value_type& pos, arrays){
776  if ( pos.second->getLength() == pos.first->getCountLevel1() )
777  Field::syncScatterVectorFieldsLevel1(*pos.first, dsf);
778  }
779 
780  const size_t numDir = dsf.size();
781  foreach(ArrayMap::value_type& pos, arrays){
782  if ( pos.second->getLength() == pos.first->getCountLevel1() )
783  Field::createSyncGatherArraysVectorFieldsLevel1(*pos.first, field0, numDir );
784  }
785 
786  GhostArrayMap& ghostArrays = field0.getGhostArrayMapLevel1();
787 
788 #ifdef FVM_PARALLEL
789  //SENDING
790  MPI::Request request_send[ Field::get_request_size_level1(field0) ];
791  MPI::Request request_recv[ Field::get_request_size_level1(field0) ];
792  int indxSend = 0;
793  int indxRecv = 0;
794  foreach(ArrayMap::value_type& pos, arrays){
795  const StorageSite& site = *pos.first;
796  const StorageSite::ScatterMap& scatterMap = site.getScatterMapLevel1();
797  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap){
798  const StorageSite& oSite = *mpos.first;
799  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
800  EntryIndex e(&site,&oSite);
801  ArrayBase& sendArray = *ghostArrays[e];
802  int to_where = oSite.getGatherProcID();
803  if ( to_where != -1 ){
804  int mpi_tag = oSite.getTag();
805  request_send[indxSend++] =
806  MPI::COMM_WORLD.Isend( sendArray.getData(), sendArray.getDataSize(), MPI::BYTE, to_where, mpi_tag );
807  }
808  }
809  //RECIEVING
810  //getting values from other meshes to fill g
811  const StorageSite::GatherMap& gatherMap = site.getGatherMapLevel1();
812  foreach(const StorageSite::GatherMap::value_type& mpos, gatherMap){
813  const StorageSite& oSite = *mpos.first;
814  //checking if storage site is only site or ghost site, we only communicate ghost site ( oSite.getCount() == -1 )
815  EntryIndex e(&oSite,&site);
816  ArrayBase& recvArray = *ghostArrays[e];
817  int from_where = oSite.getGatherProcID();
818  if ( from_where != -1 ){
819  int mpi_tag = oSite.getTag();
820  request_recv[indxRecv++] =
821  MPI::COMM_WORLD.Irecv( recvArray.getData(), recvArray.getDataSize(), MPI::BYTE, from_where, mpi_tag );
822  }
823  }
824  }
825 
826  int count = Field::get_request_size_level1(field0);
827  MPI::Request::Waitall( count, request_recv );
828  MPI::Request::Waitall( count, request_send );
829 #endif
830 
831  // gather
832  foreach(ArrayMap::value_type& pos, arrays){
833  if ( pos.second->getLength() == pos.first->getCountLevel1() )
834  Field::syncGatherVectorFieldsLevel1(*pos.first, dsf);
835  }
836 
837 
838 
839 }
virtual int getDataSize() const =0
ArrayMap & getArrayMap()
Definition: Field.h:48
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
Definition: Field.h:14
const GatherMap & getGatherMapLevel1() const
Definition: StorageSite.h:74
const ScatterMap & getScatterMapLevel1() const
Definition: StorageSite.h:73
map< EntryIndex, shared_ptr< ArrayBase > > GhostArrayMap
Definition: Field.h:20
static void syncGatherVectorFieldsLevel1(const StorageSite &site, std::vector< Field * > &dsf)
Definition: Field.cpp:668
static void createSyncGatherArraysVectorFieldsLevel1(const StorageSite &site, Field &field, const size_t numDir)
Definition: Field.cpp:548
int getTag() const
Definition: StorageSite.h:84
int getGatherProcID() const
Definition: StorageSite.h:83
GhostArrayMap & getGhostArrayMapLevel1()
Definition: Field.h:51
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
virtual void * getData() const =0
static void syncScatterVectorFieldsLevel1(const StorageSite &site, std::vector< Field * > &dsf)
Definition: Field.cpp:600
map< const StorageSite *, shared_ptr< Array< int > > > GatherMap
Definition: StorageSite.h:24
map< const StorageSite *, shared_ptr< ArrayBase > > ArrayMap
Definition: Field.h:17
static int get_request_size_level1(Field &field)
Definition: Field.cpp:863
void Field::syncScatter ( const StorageSite site)
private

Definition at line 234 of file Field.cpp.

References _ghostArrays, Array< T >::getLength(), StorageSite::getScatterMap(), ArrayBase::newSizedClone(), operator[](), and ArrayBase::scatter().

Referenced by syncLocal().

235 {
236  const ArrayBase& thisArray = operator[](site);
237 
238  const StorageSite::ScatterMap& scatterMap = site.getScatterMap();
239 
240  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap)
241  {
242  const StorageSite& oSite = *mpos.first;
243  EntryIndex e(&site, &oSite);
244  const Array<int>& fromIndices = *(mpos.second);
245  if (_ghostArrays.find(e) == _ghostArrays.end()){
246  _ghostArrays[e] = thisArray.newSizedClone( fromIndices.getLength() );
247  }
248 
249  ArrayBase& ghostArray = *_ghostArrays[e];
250  thisArray.scatter(ghostArray,fromIndices);
251 
252  }
253 }
virtual void scatter(ArrayBase &other_, const ArrayBase &indices, const int offset=0) const =0
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
const ArrayBase & operator[](const StorageSite &) const
Definition: Field.cpp:44
GhostArrayMap _ghostArrays
Definition: Field.h:92
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
virtual shared_ptr< ArrayBase > newSizedClone(const int size) const =0
int getLength() const
Definition: Array.h:87
void Field::syncScatterLevel1 ( const StorageSite site)
private

Definition at line 257 of file Field.cpp.

References _ghostArraysLevel1, Array< T >::getLength(), StorageSite::getScatterMapLevel1(), ArrayBase::newSizedClone(), operator[](), and ArrayBase::scatter().

Referenced by syncLocalLevel1().

258 {
259  const ArrayBase& thisArray = operator[](site);
260 
261  const StorageSite::ScatterMap& scatterMap = site.getScatterMapLevel1();
262 
263  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap)
264  {
265  const StorageSite& oSite = *mpos.first;
266  EntryIndex e(&site, &oSite);
267  const Array<int>& fromIndices = *(mpos.second);
268  if (_ghostArraysLevel1.find(e) == _ghostArraysLevel1.end()){
269  _ghostArraysLevel1[e] = thisArray.newSizedClone( fromIndices.getLength() );
270  }
271 
272  ArrayBase& ghostArray = *_ghostArraysLevel1[e];
273  thisArray.scatter(ghostArray,fromIndices);
274 
275  }
276 }
virtual void scatter(ArrayBase &other_, const ArrayBase &indices, const int offset=0) const =0
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
const ScatterMap & getScatterMapLevel1() const
Definition: StorageSite.h:73
GhostArrayMap _ghostArraysLevel1
Definition: Field.h:93
const ArrayBase & operator[](const StorageSite &) const
Definition: Field.cpp:44
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
virtual shared_ptr< ArrayBase > newSizedClone(const int size) const =0
int getLength() const
Definition: Array.h:87
void Field::syncScatterVectorFields ( const StorageSite site,
std::vector< Field * > &  dsf 
)
staticprivate

Definition at line 569 of file Field.cpp.

References getGhostArrayMap(), Array< T >::getLength(), StorageSite::getScatterMap(), ArrayBase::newSizedClone(), and ArrayBase::scatter().

Referenced by syncLocalVectorFields().

570 {
571 
572  const size_t numDir = dsf.size();
573  Field& field0 = *dsf[0];
574  ArrayBase& thisArray0 = field0[site];
575  GhostArrayMap& ghostArrays = field0.getGhostArrayMap();
576 
577  const StorageSite::ScatterMap& scatterMap = site.getScatterMap();
578 
579  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap)
580  {
581  const StorageSite& oSite = *mpos.first;
582  EntryIndex e(&site, &oSite);
583  const Array<int>& fromIndices = *(mpos.second);
584  if (ghostArrays.find(e) == ghostArrays.end()){
585  ghostArrays[e] = thisArray0.newSizedClone( fromIndices.getLength() * numDir );
586  }
587 
588  const int chunkSize = fromIndices.getLength();
589  ArrayBase& ghostArray = *ghostArrays[e];
590  for (size_t dir=0; dir < numDir; dir++){
591  Field& field = *dsf[dir];
592  const ArrayBase& thisArray = field[site];
593  const int offset = chunkSize * dir;
594  thisArray.scatter(ghostArray,fromIndices, offset);
595  }
596  }
597 }
virtual void scatter(ArrayBase &other_, const ArrayBase &indices, const int offset=0) const =0
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
Definition: Field.h:14
map< EntryIndex, shared_ptr< ArrayBase > > GhostArrayMap
Definition: Field.h:20
const ScatterMap & getScatterMap() const
Definition: StorageSite.h:58
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
virtual shared_ptr< ArrayBase > newSizedClone(const int size) const =0
GhostArrayMap & getGhostArrayMap()
Definition: Field.h:50
int getLength() const
Definition: Array.h:87
void Field::syncScatterVectorFieldsLevel1 ( const StorageSite site,
std::vector< Field * > &  dsf 
)
staticprivate

Definition at line 600 of file Field.cpp.

References getGhostArrayMapLevel1(), Array< T >::getLength(), StorageSite::getScatterMapLevel1(), ArrayBase::newSizedClone(), and ArrayBase::scatter().

Referenced by syncLocalVectorFieldsLevel1().

601 {
602 
603  const size_t numDir = dsf.size();
604  Field& field0 = *dsf[0];
605  ArrayBase& thisArray0 = field0[site];
606  GhostArrayMap& ghostArrays = field0.getGhostArrayMapLevel1();
607 
608  const StorageSite::ScatterMap& scatterMap = site.getScatterMapLevel1();
609 
610  foreach(const StorageSite::ScatterMap::value_type& mpos, scatterMap)
611  {
612  const StorageSite& oSite = *mpos.first;
613  EntryIndex e(&site, &oSite);
614  const Array<int>& fromIndices = *(mpos.second);
615  if (ghostArrays.find(e) == ghostArrays.end()){
616  ghostArrays[e] = thisArray0.newSizedClone( fromIndices.getLength() * numDir );
617  }
618 
619  const int chunkSize = fromIndices.getLength();
620  ArrayBase& ghostArray = *ghostArrays[e];
621  for (size_t dir=0; dir < numDir; dir++){
622  Field& field = *dsf[dir];
623  const ArrayBase& thisArray = field[site];
624  const int offset = chunkSize * dir;
625  thisArray.scatter(ghostArray,fromIndices, offset);
626  }
627  }
628 }
virtual void scatter(ArrayBase &other_, const ArrayBase &indices, const int offset=0) const =0
pair< const StorageSite *, const StorageSite * > EntryIndex
Definition: Field.h:19
Definition: Field.h:14
const ScatterMap & getScatterMapLevel1() const
Definition: StorageSite.h:73
map< EntryIndex, shared_ptr< ArrayBase > > GhostArrayMap
Definition: Field.h:20
GhostArrayMap & getGhostArrayMapLevel1()
Definition: Field.h:51
map< const StorageSite *, shared_ptr< Array< int > > > ScatterMap
Definition: StorageSite.h:23
virtual shared_ptr< ArrayBase > newSizedClone(const int size) const =0
int getLength() const
Definition: Array.h:87
void Field::zero ( )
virtual

Implements IContainer.

Definition at line 168 of file Field.cpp.

References _arrays.

169 {
170  foreach(ArrayMap::value_type& pos, _arrays)
171  {
172  pos.second->zero();
173  }
174 }
ArrayMap _arrays
Definition: Field.h:91

Member Data Documentation

ChildSitesMap Field::_childSitesMap
private

Definition at line 95 of file Field.h.

Referenced by _create(), clear(), and removeArray().

GhostArrayMap Field::_ghostArrays
private
GhostArrayMap Field::_ghostArraysLevel1
private
const string Field::_name
private

Definition at line 90 of file Field.h.

Referenced by getName(), newClone(), and newCopy().


The documentation for this class was generated from the following files: