WARPXM v1.10.0
Loading...
Searching...
No Matches
wmunstructuredarray.h
Go to the documentation of this file.
1/*
2 * wmunstructuredarray.h
3 *
4 * Created on: Feb 23, 2012
5 * Author: smiller
6 */
7
8#ifndef WMUNSTRUCTUREDARRAY_H_
9#define WMUNSTRUCTUREDARRAY_H_
10
11// STD includes
12#include <iostream>
13#include <map>
14#include <vector>
15#include <typeinfo>
16#include <limits>
17
18// Wx includes
19#include "lib/wxlogger.h"
20#include "lib/wxlogstream.h"
21#include "lib/wxany.h"
22
23// Wm includes
24#include "solver/wmsolver.h"
28
29class WxIoBase;
30// class WxIoNodeType;
32class localTransfer_t;
33class sendRemoteTransfer_t;
34class recvRemoteTransfer_t;
35
42 // public WmVariable,
44{
45
46public:
53
59
67 virtual void setup(const WxCryptSet& wxc);
68
76 accessLocalArray(const unsigned int component, const std::string& subdomainName);
77
85 accessLocalArrayReadOnly(const unsigned int component,
86 const std::string& subdomainName) const;
87
95 accessPatchArray(const unsigned int component, int patchIndex);
96
104 accessPatchArrayReadOnly(const unsigned int component, int patchIndex) const;
105
111 {
112 return 0;
113 }
114
122 virtual void updateGhosts_register(const int key);
123
131 virtual void updateGhosts_nb(const int key);
132
142 virtual void updateGhosts_wait(const int key);
143
157 virtual void updatePatchGhosts(const int patchIndex);
158
167 virtual void updateGhosts();
168
178 virtual void
179 updateGhostsComponents(/* TODO: std::vector<some new type> componentList */)
180 {
181 throw WxExcept("WmUnstructuredArray::updateGhostsComponents: Not implemented for "
182 "unstructured arrays");
183 }
184
192 virtual void fill(const std::vector<WxAny>& fillVector);
193 virtual void fill(const std::map<std::string, WxAny>& fillMap);
194
200 bool is_alloc() const;
201
209 // virtual const std::type_info & getElementTypeForComponent(const std::string &
210 // componentName) const;
211
212 virtual const std::type_info&
213 getElementTypeForComponent(unsigned int componentIndex) const;
214
221 virtual void dump(WxIoBase& io, WxIoNodeType& grpNode) const;
222
230 virtual void load(WxIoBase& io, const WxIoNodeType& grpNode);
231
237 const WxAny min(const int componentIndex) const;
238
246 const WxAny absoluteMin(const int componentIndex) const;
247
253
259
265 const std::vector<std::string>& getSubdomainNames() const
266 {
267 return _onSubdomains;
268 }
269
275 bool onSubdomain(const std::string& subdomainName) const;
276
282 template<typename T>
283 const WmUnstructuredPatchArray<T>& getPatchArray(const int componentIndex,
284 const int patchIndex) const
285 {
286 // The WmUnstructuredSubdomainArray class makes this a pain...
287
288 const subdomainArrayMap_t& sam = (*_componentArrays)[componentIndex];
289 for (subdomainArrayMap_t::const_iterator itr0 = sam.begin(); itr0 != sam.end();
290 itr0++)
291 {
293 dynamic_cast<const WmUnstructuredSubdomainArray<T>&>(*(itr0->second));
294 if (usa.hasPatch(patchIndex))
295 {
296 return usa.getPatchArray(patchIndex);
297 }
298 }
299 throw WxExcept(
300 "WmUnstructuredArray::getPatchArray : Patch does not exist for component.\n");
301 }
302
303protected:
304 // void gather();
305
306 std::vector<std::string> _onSubdomains; // list of subdomains on which variable exists
307 // unsigned _numGhostLevels;
308
309 typedef std::vector<localTransfer_t*> localTransferList_t;
310 typedef std::map<int, sendRemoteTransfer_t*> sendMap_t;
311 typedef std::map<int, recvRemoteTransfer_t*> recvMap_t;
312
316
318 std::vector<int> _localPatchIndexes;
319
321 {
322
324 {
325 }
326
328 {
329 _key = other._key;
332 }
333
334 int _key;
337 };
338
339 typedef std::map<int, syncRegistry_t> rsyncMap_t;
341
343 {
353 virtual void swap_impl(WmVariable& varA, WmVariable& varB) const;
354
361 virtual bool checkCompatible_impl(const WmVariable& varA,
362 const WmVariable& varB) const;
363 };
364
370
371private:
373 WmUnstructuredArray& operator=(const WmUnstructuredArray& arr);
375
377 globalArray_t; // Component Arrays are global Arrays
378 typedef std::pair<std::string, globalArray_t> subdomainArrayPair_t;
379 typedef std::map<std::string, globalArray_t> subdomainArrayMap_t;
380 typedef std::vector<subdomainArrayMap_t>
381 componentVector_t; // Each Variable has a set of components
382 componentVector_t* _componentArrays;
383};
384
385#endif /* WMUNSTRUCTUREDARRAY_H_ */
Opaque Pointer object that carries the referenced data type, but does not expose this payload type as...
Definition: wmopaqueptr.h:81
Defines an interface for variables that exits over distributed memory.
Definition: wmvariable.h:290
Defines common interface for arrays of elements.
Definition: wmsimplearrays.h:23
Class for handling unstructured arrays.
Definition: wmunstructuredarray.h:44
virtual const WmTypeOpaqueArray< _WX_ROW_MAJOR_ORDER > & accessLocalArrayReadOnly(const unsigned int component, const std::string &subdomainName) const
Get the read-only array storage starting address without type specifics.
const WmUnstructuredPatchArray< T > & getPatchArray(const int componentIndex, const int patchIndex) const
Returns a patch array for a given component index and patch index.
Definition: wmunstructuredarray.h:283
virtual void fill(const std::map< std::string, WxAny > &fillMap)
bool onSubdomain(const std::string &subdomainName) const
Query if variable exists on subdomain.
virtual void updatePatchGhosts(const int patchIndex)
Update values in the extended regions from neighbor processes.
virtual void load(WxIoBase &io, const WxIoNodeType &grpNode)
Load object from file.
virtual void updateGhostsComponents()
Update values in the extended regions from neighbor processes.
Definition: wmunstructuredarray.h:179
void downloadInternalElementsFromBuffers()
Downloads internal element data from OpenCL buffer to global array.
virtual void updateGhosts_wait(const int key)
This is a registered sync wait call.
recvMap_t _recvTransfers
Definition: wmunstructuredarray.h:315
virtual WmTypeOpaqueArray< _WX_ROW_MAJOR_ORDER > & accessPatchArray(const unsigned int component, int patchIndex)
Get the array storage at patch starting address without type specifics.
std::vector< localTransfer_t * > localTransferList_t
Definition: wmunstructuredarray.h:309
const std::vector< std::string > & getSubdomainNames() const
Returns a list of subdomain names on which the variable exists.
Definition: wmunstructuredarray.h:265
const WxAny min(const int componentIndex) const
Returns the minimum value in global array.
~WmUnstructuredArray()
Destroy the WmDistributedArrays, including the member global arrays.
virtual void updateGhosts_register(const int key)
This is a registered sync call register.
virtual void fill(const std::vector< WxAny > &fillVector)
For each component, apply a fill value to all elements of the global array.
void synchronizeArrays()
Synchornizes the arrays for ghost sharing.
bool is_alloc() const
Has array allocated any data?
unsigned getNumGhostCells()
Returns number of ghost cells.
Definition: wmunstructuredarray.h:110
virtual const WmTypeOpaqueArray< _WX_ROW_MAJOR_ORDER > & accessPatchArrayReadOnly(const unsigned int component, int patchIndex) const
Get the read-only array at patch storage starting address without type specifics.
virtual void setup(const WxCryptSet &wxc)
Setup an array from input file block.
virtual void dump(WxIoBase &io, WxIoNodeType &grpNode) const
Write out the array to file.
localTransferList_t _localTransfers
Definition: wmunstructuredarray.h:313
rsyncMap_t _rsync
Definition: wmunstructuredarray.h:340
std::map< int, sendRemoteTransfer_t * > sendMap_t
Definition: wmunstructuredarray.h:310
void uploadInternalElementsToBuffers()
Uploads internal element data in global array to OpenCL buffer.
std::vector< std::string > _onSubdomains
Definition: wmunstructuredarray.h:306
virtual const std::type_info & getElementTypeForComponent(unsigned int componentIndex) const
Returns the element type stored by the component matching the name supplied.
virtual WmTypeOpaqueArray< _WX_ROW_MAJOR_ORDER > & accessLocalArray(const unsigned int component, const std::string &subdomainName)
Get the array storage starting address without type specifics.
virtual void updateGhosts()
Update values in the extended regions from neighbor processes.
std::vector< int > _localPatchIndexes
Definition: wmunstructuredarray.h:318
int _numPatchesSignedIn
Definition: wmunstructuredarray.h:317
sendMap_t _sendTransfers
Definition: wmunstructuredarray.h:314
WmUnstructuredArray(const WmConstOpaquePtr &parentPointer)
Create a new parallel array object but does not do any allocations or set dimensions.
std::map< int, syncRegistry_t > rsyncMap_t
Definition: wmunstructuredarray.h:339
std::map< int, recvRemoteTransfer_t * > recvMap_t
Definition: wmunstructuredarray.h:311
const WxAny absoluteMin(const int componentIndex) const
Returns the absolute minimum value in global array Absolute min is the closest value to zero Value wi...
virtual void updateGhosts_nb(const int key)
This is a registered sync call - non blocking.
Definition: wmunstructuredpatcharray.h:23
Definition: wmunstructuredsubdomainarray.h:27
Definition: wmunstructuredsubdomainarray.h:76
bool hasPatch(const int patchIndex) const
Check if subdomain array contains patch.
virtual WmUnstructuredPatchArray< T > & getPatchArray(int patchIndex)
Get patch array.
Base class for variables that store one or more components of data.
Definition: wmvariable.h:31
Class WxAny is based on the "any" class described in "Valued Conversion", Kevlin Henney,...
Definition: wxany.h:139
WxCryptSet extends WxCrypt by providing, in addition to name-value pairs, an set of named WxCryptSets...
Definition: wxcryptset.h:35
Provides an abstract interface for access to hierachical datasets.
Definition: wxiobase.h:25
Definition: wmunstructuredarray.h:343
virtual void swap_impl(WmVariable &varA, WmVariable &varB) const
Swap the internal data storage of varA and varB leaving the outer shell the same, given both have sam...
virtual bool checkCompatible_impl(const WmVariable &varA, const WmVariable &varB) const
Check the types and structure of varA and varB are compatible for swap.
Definition: wmunstructuredarray.h:321
int _numRegistered
Definition: wmunstructuredarray.h:335
int _numCalledIn
Definition: wmunstructuredarray.h:336
syncRegistry_t(const syncRegistry_t &other)
Definition: wmunstructuredarray.h:327
int _key
Definition: wmunstructuredarray.h:334
syncRegistry_t()
Definition: wmunstructuredarray.h:323
Definition: wmvariable.h:267
Provides a means for derived messengers to return implimentation specific message status flags and da...
Definition: wxiotmpl.h:23
wxm::lib::Except WxExcept
Definition: wxexcept.h:120