WARPXM v1.10.0
Loading...
Searching...
No Matches
wmvariableparser.h
Go to the documentation of this file.
1
2#ifndef __wmvariableparser__h__
3#define __wmvariableparser__h__
4
5// STL Libraries
6#include <iostream>
7#include <vector>
8#include <map>
9
10// WarpX/M Libraries
11#include "lib/wxexcept.h"
12#include "solver/wmsolverbase.h"
13#include "lib/wxany.h"
15#include "wmudgfunctions.h"
16
23int _factorial(int n);
24
25// These are typecheck bit flags
26
27enum
28{
29 // Unknown
30 WMKERNELVARIABLE_NONE = 1 << 1, // Unknown
31
32 // Never allocated
34 1 << 2, // Constant in space and time - directly written into kernel
35
36 // Allocated on its own or within structure/array
37 // WMKERNELVARIABLE_WMSCALAR = 1 << 3, // Constant in space - linked to
38 // WmScalar
39 // WMKERNELVARIABLE_WMARRAY = 1 << 4, // Constant in space - linked to
40 // WmArray
41 // WMKERNELVARIABLE_WMDARRAY = 1 << 5, // linked to distributed array
42 WMKERNELVARIABLE_WMUARRAY = 1 << 6, // linked to unstructured array
43 WMKERNELVARIABLE_OCLMEM = 1 << 7, // linked to OpenCL Memory object: cl_mem
44 WMKERNELVARIABLE_ANY = 1 << 8, // Constant in space - linked to WxAny (by pointer)
45
46 // Structure of allocations
48
49 // Tensor allocation - all of same type - don't try to interface with it outside of
50 // the kernel - not initialized
53 1 << 11, // used to link variable to function call or complex initialization
54
55 // Array allocation - rank 1 tensor, can be filled with structures/allocations of the
56 // same type
58
59};
60
62{
63 std::string _variableName;
66 std::string _typeString;
67
68 // just in case this is actually a constant
70};
71
72class WmSolverBase;
73
74typedef std::vector<variableType_t> variableTypeList_t;
75
77{
78public:
79 typedef std::map<std::string, std::string> constantsMap_t;
80
82 {
83 public:
84 // Variable
86
87 // Variable name
88 std::string _variableName;
89
90 // ComponentIndex;
92 };
93
94 typedef std::vector<component_t> componentList_t;
95
97
99
100 void setParentSolver(const WmSolverBase* solver)
101 {
102 _parentSolver = solver;
103 }
104
106 const std::string& fieldName);
107
108protected:
109 // Protected Functions
110
112
113 bool hasVariable(const WxCryptSet& wxc, const std::string& varName) const;
114 bool hasVariableVector(const WxCryptSet& wxc, const std::string& varName) const;
115
116 static std::string itos(int value);
117 static std::string getAnyString(const WxAny& any);
118 static std::string getTypeString(const std::type_info& type);
119 static size_t getTypeSize(const std::type_info& typeinfo);
120
121 // Parsing function
122 componentList_t parseVariableNameIntoComponents(const std::string& fullVarName);
123
124 // Protected Variables
125
128
129private:
130};
131
133#endif
A base class for solvers in WARPM.
Definition: wmsolverbase.h:35
Definition: wmvariableparser.h:82
int _componentIndex
Definition: wmvariableparser.h:91
std::string _variableName
Definition: wmvariableparser.h:88
wxm::variable::variable_t * _variable
Definition: wmvariableparser.h:85
Definition: wmvariableparser.h:77
static std::string itos(int value)
static size_t getTypeSize(const std::type_info &typeinfo)
WxLogStream _debStrm
Definition: wmvariableparser.h:127
virtual ~WmVariableParser()
void setParentSolver(const WmSolverBase *solver)
Definition: wmvariableparser.h:100
static std::string getAnyString(const WxAny &any)
bool hasVariable(const WxCryptSet &wxc, const std::string &varName) const
variableTypeList_t decomposeVariableName(const WxAny &varName) const
std::map< std::string, std::string > constantsMap_t
Definition: wmvariableparser.h:79
std::vector< component_t > componentList_t
Definition: wmvariableparser.h:94
componentList_t parseVariableNameIntoComponents(const std::string &fullVarName)
static std::string getTypeString(const std::type_info &type)
componentList_t parseVariablesFromCryptset(const WxCryptSet &wxe, const std::string &fieldName)
bool hasVariableVector(const WxCryptSet &wxc, const std::string &varName) const
const WmSolverBase * _parentSolver
Definition: wmvariableparser.h:126
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 interface to streaming iostreams to logs.
Definition: wxlogstream.h:19
Definition: variable.h:22
Definition: wmvariableparser.h:62
std::string _variableName
Definition: wmvariableparser.h:63
int _componentIndex
Definition: wmvariableparser.h:64
int _kernelVariableType
Definition: wmvariableparser.h:65
std::string _typeString
Definition: wmvariableparser.h:66
WxAny _value
Definition: wmvariableparser.h:69
int _factorial(int n)
Every class and word in this file needs to be deleted and replaced with modern alternatives.
std::vector< variableType_t > variableTypeList_t
Definition: wmvariableparser.h:74
@ WMKERNELVARIABLE_ARRAY
Definition: wmvariableparser.h:57
@ WMKERNELVARIABLE_OCLMEM
Definition: wmvariableparser.h:43
@ WMKERNELVARIABLE_WMUARRAY
Definition: wmvariableparser.h:42
@ WMKERNELVARIABLE_STRUCTURE
Definition: wmvariableparser.h:47
@ WMKERNELVARIABLE_TENSOR
Definition: wmvariableparser.h:51
@ WMKERNELVARIABLE_CONSTANT
Definition: wmvariableparser.h:33
@ WMKERNELVARIABLE_ANY
Definition: wmvariableparser.h:44
@ WMKERNELVARIABLE_VALUE
Definition: wmvariableparser.h:52
@ WMKERNELVARIABLE_NONE
Definition: wmvariableparser.h:30