WARPXM v1.10.0
Loading...
Searching...
No Matches
wmvariable.h
Go to the documentation of this file.
1#ifndef wmvariable_h
2#define wmvariable_h
3
4// Wx includes
5#include "lib/wxobject.h"
6#include "lib/wxany.h"
7
8// Wm includes
9#include "lib/wmnametree.h"
10#include "lib/wmopaqueptr.h"
11#include "wmsimplearrays.h"
12#include "array/array.h"
13
14// STL includes
15#include <typeinfo>
16#include <utility>
17
18// forward declarations
19class WmSolverBase;
20
30class WmVariable : public WxObject
31{
32public:
36 virtual ~WmVariable();
37
61 virtual void setup(const WxCryptSet& wxc);
62
68 virtual void copy(const WmVariable& var);
69
74 virtual void fill(const std::vector<WxAny>& fillValues)
75 {
76 }
77
85 virtual void swap(WmVariable& otherVar);
86
93 virtual bool checkCompatible(const WmVariable& var) const;
94
103 virtual void dump(WxIoBase& io, WxIoNodeType& grpNode) const;
104
112 virtual void load(WxIoBase& io, const WxIoNodeType& grpNode);
113
120 bool hasComponent(const std::string& componentName) const;
121
131 virtual const std::type_info& getElementTypeForComponent(unsigned int index) const;
132
140 virtual const std::type_info& getElementType() const;
141
147 unsigned int getNumComponents() const;
148
155 typedef unsigned variableComponent_t;
156
163 std::vector<std::string> getComponentNames() const;
164
172 variableComponent_t getIndexForComponent(const std::string& componentName) const;
173
181 const std::string& getComponentName(const variableComponent_t index) const;
182
189 virtual const WxAny min(const int componentIndex) const
190 {
191 return WxAny();
192 }
193
202 virtual const WxAny absoluteMin(const int componentIndex) const
203 {
204 return WxAny();
205 }
206
207 // /**
208 // * Returns a list of subdomain names on which the variable exists
209 // *
210 // * @return vector of subdomain names
211 // */
212 // virtual std::vector<std::string> getSubdomainNames() const {return
213 // std::vector<std::string>();}
214
221 const WmSolverBase& getParent() const;
222
223protected:
230 WmVariable(const WmConstOpaquePtr& parent_solver);
231
240 WmVariable(const std::string& name,
241 const std::vector<std::string>& orderedComponentNames);
242
249 const std::type_info& getRealTypeID() const;
250
257 std::string getRealTypeStr() const;
258
260
263
264 std::vector<std::string> _orderedComponentNames;
265
266 struct SwapImpl
267 {
268 virtual void swap_impl(WmVariable& varA, WmVariable& varB) const;
269 virtual bool checkCompatible_impl(const WmVariable& varA,
270 const WmVariable& varB) const;
271 virtual ~SwapImpl() = default;
272 };
273
275
276private:
278 WmVariable& operator=(const WmVariable& var);
279 WmVariable(const WmVariable& var);
280
282 const WmSolverBase* _p_parent;
283 bool _hasBeenSetup;
284};
285
289class WmDistributedVariable : public virtual WmVariable
290{
291
292public:
298 virtual void setup(const WxCryptSet& wxc);
299
307 virtual void updateGhosts()
308 {
309 }
310
318 virtual void updateGhosts_register(const int key)
319 {
320 }
321
329 virtual void updateGhosts_nb(const int key)
330 {
331 }
332
342 virtual void updateGhosts_wait(const int key)
343 {
344 }
345
350 const std::vector<std::string>& subdomain_names() const
351 {
352 return _subdomain_names;
353 }
354
360 bool on_subdomain(const std::string& subdomain_name) const;
361
368 virtual wxm::array::patch_array_t& patch_array(const int component_index,
369 const int patch_index) = 0;
370
377 virtual const wxm::array::patch_array_t& patch_array(const int component_index,
378 const int patch_index) const = 0;
379
380protected:
382 std::vector<std::string> _subdomain_names;
383
385 std::vector<std::string> _virtual_names;
386
389
390 // /**
391 // * Constructor sets up basic distributed variable container, and all properties
392 // otherwise set through setup() method in the no-argument form.
393 // * Calls to setup() for this instance will have no affect.
394 // * Protected because direct WmDistributedVariable is not intended to be a complete
395 // type.
396 // * @param name name of this instance
397 // * @param orderedComponentNames name for each component of the variable
398 // */
399 // WmDistributedVariable(const std::string & name, const std::vector<std::string> &
400 // orderedComponentNames );
401
402private:
405
408
410 WmDistributedVariable& operator=(const WmDistributedVariable& other);
411};
412
413// namespace wxm
414//{
415// namespace variable
416//{
417// typedef WmVariable variable_t;
418// typedef WmDistributedVariable distributed_variable_t;
419//}
420//}
421
424#endif // wmvariable_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
virtual wxm::array::patch_array_t & patch_array(const int component_index, const int patch_index)=0
Aquire a patch array for a specified component.
virtual void updateGhosts_wait(const int key)
This is a registered sync wait call.
Definition: wmvariable.h:342
virtual void setup(const WxCryptSet &wxc)
Setup the distributed variable.
bool on_subdomain(const std::string &subdomain_name) const
Check if this distributed variable exists on a given subdomain.
virtual void updateGhosts_register(const int key)
This is a registered sync call register.
Definition: wmvariable.h:318
WmDistributedVariable(const WmConstOpaquePtr &parent_solver)
Forces the distributed variable to be a base class.
virtual const wxm::array::patch_array_t & patch_array(const int component_index, const int patch_index) const =0
Aquire a patch array for a specified component.
virtual void updateGhosts()
Update values in the extended regions from neighbor processes.
Definition: wmvariable.h:307
std::vector< std::string > _virtual_names
List of subdomains on which this distributed variable virtually exists.
Definition: wmvariable.h:385
const std::vector< std::string > & subdomain_names() const
Get a list of subdomains on which this distributed variable exists.
Definition: wmvariable.h:350
std::vector< std::string > _subdomain_names
List of subdomains on which this distributed variable exists.
Definition: wmvariable.h:382
virtual void updateGhosts_nb(const int key)
This is a registered sync call - non blocking.
Definition: wmvariable.h:329
Provides hierarchical container for T values according to unique string keys.
Definition: wmnametree.h:30
A base class for solvers in WARPM.
Definition: wmsolverbase.h:35
Base class for variables that store one or more components of data.
Definition: wmvariable.h:31
virtual void copy(const WmVariable &var)
Set the variable from supplied one.
virtual void swap(WmVariable &otherVar)
Swap the internal data storage of this variable with otherVar leaving the outer shell the same,...
const std::type_info & getRealTypeID() const
Get the type that real type aliases.
bool hasComponent(const std::string &componentName) const
Check if this variable has a component matching the name supplied.
virtual ~WmVariable()
Destroy object.
WmNameTree< variableComponent_t >::const_iterator component_const_iterator_t
Definition: wmvariable.h:259
WmVariable(const std::string &name, const std::vector< std::string > &orderedComponentNames)
Constructor sets up basic variable container, and all properties otherwise set through setup() method...
virtual void fill(const std::vector< WxAny > &fillValues)
For each component, apply a fill value throughout the domain.
Definition: wmvariable.h:74
std::string getRealTypeStr() const
Get the name for the type that real type aliases.
unsigned _numComponents
Definition: wmvariable.h:262
variableComponent_t getIndexForComponent(const std::string &componentName) const
Returns the component number associated with the componentName.
virtual const std::type_info & getElementTypeForComponent(unsigned int index) const
Returns a type_info reference for the most primative element type stored by the variable.
const WmSolverBase & getParent() const
Get the parent solver.
unsigned variableComponent_t
variableComponent serves as a sort of pointer to individual components of the variable and is the val...
Definition: wmvariable.h:155
virtual const WxAny absoluteMin(const int componentIndex) const
Returns the absolute minimum value for the component identified Absolute min is the closest value to ...
Definition: wmvariable.h:202
const std::string & getComponentName(const variableComponent_t index) const
Returns the component name for a given index.
WmVariable(const WmConstOpaquePtr &parent_solver)
Constructor sets up basic variable container, but no properties or specifics.
virtual void dump(WxIoBase &io, WxIoNodeType &grpNode) const
Dump object to file.
virtual void load(WxIoBase &io, const WxIoNodeType &grpNode)
Load object from file.
WmNameTree< variableComponent_t > _componentTree
Definition: wmvariable.h:261
virtual const std::type_info & getElementType() const
Returns a type_info reference for the most primative element type stored by the variable.
unsigned int getNumComponents() const
Returns number of components represented in the variable.
virtual void setup(const WxCryptSet &wxc)
Setup object using supplied crypset.
virtual const WxAny min(const int componentIndex) const
Returns the minimum value for the component identified.
Definition: wmvariable.h:189
virtual bool checkCompatible(const WmVariable &var) const
Compares this variable to another supplied WmVariable and report if they are swap compatible.
std::vector< std::string > getComponentNames() const
Get names of all components (alphabetical order)
std::vector< std::string > _orderedComponentNames
Definition: wmvariable.h:264
SwapImpl * p_impl
Definition: wmvariable.h:274
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
WxObject is a base class for WarpX classes which need to go through a creation/destruction cycle with...
Definition: wxobject.h:54
virtual std::string name() const
Get name of object.
Definition: array.h:190
Definition: wmvariable.h:267
virtual void swap_impl(WmVariable &varA, WmVariable &varB) const
virtual ~SwapImpl()=default
virtual bool checkCompatible_impl(const WmVariable &varA, const WmVariable &varB) const
Provides a means for derived messengers to return implimentation specific message status flags and da...
Definition: wxiotmpl.h:23