Go to the documentation of this file. 1 #ifndef PARFIS_DATASTRUCT_H
2 #define PARFIS_DATASTRUCT_H
12 #include <unordered_map>
21 #if defined(PARFIS_LOG_LEVEL)
22 #define LOG_LEVEL PARFIS_LOG_LEVEL
34 #define LOG(logger, level, msg) {Logger::log(logger, level, msg);}
36 #define LOG(logger, level, msg) {}
40 #if defined(STATE_TYPE_DOUBLE)
42 #define STATE_TYPE double
44 #define STATE_TYPE float
70 constexpr
static nodeFlag_t InsideGeo = 0b11111111;
71 constexpr
static nodeFlag_t NegZBound = 0b11110000;
72 constexpr
static nodeFlag_t PosZBound = 0b00001111;
155 return (lhs.
x == rhs.
x && lhs.
y == rhs.
y && lhs.
z == rhs.
z);
162 return (lhs.
x != rhs.
x || lhs.
y != rhs.
y || lhs.
z != rhs.
z);
173 os <<
'[' << vec.
x <<
", " << vec.
y <<
", " << vec.
z <<
']';
192 static std::vector<const char *> pyStrVec;
205 PyVec<T>& operator=(
const std::vector<T>& tVec) {
227 for (
auto & str: strVec) {
228 PyVecContainer::pyStrVec.push_back(str.c_str());
230 ptr = &PyVecContainer::pyStrVec.back();
231 size = strVec.size();
246 return (a.
x - b.
x)*(a.
x - b.
x) + (a.
y - b.
y)*(a.
y - b.
y);
397 std::function<double(
double)>
eval;
398 int loadData(
const std::string& fileName);
608 std::vector<cellId_t> cellIdVec;
663 Command(std::string name =
"") :
691 std::map<std::string, std::unique_ptr<Command>>
m_cmdMap;
710 std::string getValueString(
bool printType=
false);
712 std::map<std::string, std::unique_ptr<ParamBase>>
m_childMap;
714 void addChild(
const std::string& name);
715 static void setValueVec(
ParamBase* ppb,
const std::string& valstr);
729 void setValueVec(
const std::string& valstr);
736 inline Param<int>::Param() { m_type =
"int"; }
739 inline Param<std::string>::Param() { m_type =
"std::string"; }
752 std::map<std::string, std::unique_ptr<CommandChain>>& cmdChainMap)
753 : m_pLogger(&logger), m_pCfgData(&cfgData), m_pSimData(&simData),
754 m_pCmdChainMap(&cmdChainMap) { m_name = dname; };
757 virtual ~
Domain() =
default;
760 int initialize(
const std::string& cstr);
761 int configure(
const std::string& cstr);
763 virtual int loadSimData() = 0;
765 static std::unique_ptr<Domain> generateDomain(
const std::string& dname,
Logger& logger,
767 std::map<std::string, std::unique_ptr<CommandChain>>& cmdChainMap);
770 int getParamToValue(
const std::string& key, T& valRef);
773 void getParamToVector(
const std::string& key, std::vector<T>& vecRef);
787 #endif // PARFIS_DATASTRUCT_H
int setPySimData()
Sets the PySimData pointers to coresponding references from SimData.
Definition: datastruct.cpp:255
Vec3D< double > velInitDistMin
Minimal velocity value for initial distribution.
Definition: datastruct.h:327
Vec3D< state_t > pos
Position vector.
Definition: datastruct.h:298
uint32_t specieId
Id from the specie vector.
Definition: datastruct.h:479
const char * name
Collision name.
Definition: datastruct.h:475
Definition: datastruct.h:69
Wrapper for the FuncTable structure to be used by ctypes in python.
Definition: datastruct.h:406
uint32_t stateCount
Number of states;.
Definition: datastruct.h:341
std::vector< Gas > gasVec
Vector of gases.
Definition: datastruct.h:633
std::mt19937_64 randEngine_t
Type for random generator engine.
Definition: datastruct.h:62
cellId_t getAbsoluteCellId(Vec3D< cellPos_t > &cellPos)
Get absolute cell id from i,j,k.
Definition: datastruct.h:569
double temperature
Temperature in K.
Definition: datastruct.h:368
uint32_t gasCollisionProbId
Id for the total collision probability matrix, from gasCollisionProbVec.
Definition: datastruct.h:351
void initialize(const std::string &fname)
Initializes log string and file name.
Definition: datastruct.cpp:484
std::vector< double > yVec
Y values.
Definition: datastruct.h:395
int colCnt
Definition: datastruct.h:383
int randomSeed
Seed for random engine.
Definition: datastruct.h:347
std::vector< randEngine_t > randomEngineVec
Engines used to generate random numbers.
Definition: datastruct.h:635
uint32_t gasId
Id from the gas vector.
Definition: datastruct.h:481
double molDensity
Mol density mol/m^3.
Definition: datastruct.h:370
Holds data about the electromagnetic field.
Definition: datastruct.h:513
SimData * m_pSimData
Pointer to simulation data.
Definition: datastruct.h:780
int calculateColFreq(const Specie &specie, const Gas &gas)
Calculates the collision frequency.
Definition: datastruct.cpp:368
PyFuncTable xSecFtab
Cross section in angstroms, with x-axis is in eV.
Definition: datastruct.h:489
#define LOG_LEVEL
Logging level defined from cmake is or-ed with bitmask to log strings.
Definition: datastruct.h:24
std::vector< double > idx
Vector of 1/dx per range.
Definition: datastruct.h:391
std::vector< std::string > gasNameVec
Gas data.
Definition: datastruct.h:561
double idt
1/dt
Definition: datastruct.h:321
@ Info
Log info messages (mask: 1000)
Command * getNext()
Get the next command in the chain.
Definition: datastruct.h:682
int eCharge
Charge in elemetary charge units.
Definition: datastruct.h:337
double maxEv
Maximal energy in eV.
Definition: datastruct.h:325
int rowCnt
Row count.
Definition: datastruct.h:385
std::vector< uint32_t > gasCollisionVecId
Vector of ids from the gasCollisionVec.
Definition: datastruct.h:349
int type
Type of collision (elastic, inelastic)
Definition: datastruct.h:456
std::map< std::string, std::unique_ptr< CommandChain > > * m_pCmdChainMap
Pointer to command map.
Definition: datastruct.h:782
std::vector< nodeFlag_t > nodeFlagVec
Vector of pointers to the cellVec.
Definition: datastruct.h:607
Simulation data.
Definition: datastruct.h:598
STATE_TYPE state_t
Type of state space variables of each particle (float or double)
Definition: datastruct.h:50
std::vector< State > stateVec
Vector of states.
Definition: datastruct.h:619
std::vector< std::string > gasCollisionNameVec
GasCollision names.
Definition: datastruct.h:563
std::vector< Cell > cellVec
Vector of cells.
Definition: datastruct.h:600
uint32_t specieId
Id from the specie vector.
Definition: datastruct.h:450
Definition: datastruct.h:190
void logToStr(LogMask mask, const std::string &msg)
Logs strings into Logger::m_str.
Definition: datastruct.cpp:499
Structure used instead of std::vector<T> for python bindings.
Definition: datastruct.h:200
@ Error
Log error messages (mask: 0001)
Configuration data in format suitable for Python ctypes.
Definition: datastruct.h:528
int type
Type of collision (elastic, inelastic)
Definition: datastruct.h:485
int colCnt
Column count (index increase by 1, is column increase)
Definition: datastruct.h:411
uint8_t nodeFlag_t
Type for node bitwise marking.
Definition: datastruct.h:58
T z
Variable z.
Definition: datastruct.h:149
PyVec< double > idx
Vector of 1/dx per range.
Definition: datastruct.h:419
FuncTable xSecFtab
Cross section in angstroms, with x-axis is in eV.
Definition: datastruct.h:460
int loadData(const std::string &fileName)
Loads data from the defined file name and based on the object type.
Definition: datastruct.cpp:326
PyVec< double > yVec
Y values.
Definition: datastruct.h:423
friend bool operator==(const Vec3D< T > &lhs, const Vec3D< T > &rhs)
Compares if vectors are equal.
Definition: datastruct.h:154
Wrapper for the GasCollilsion structure to be used by ctypes in python.
Definition: datastruct.h:470
static std::string getLogFileName(uint32_t id, uint32_t cnt)
Constructs file name for the log files.
Definition: datastruct.cpp:476
Simulation data in format suitable for Python ctypes.
Definition: datastruct.h:580
Tabulated function, linear and nonlinear tabulation is available.
Definition: datastruct.h:377
T lenSq() const
Returns the squared vector length in Eucledian metric.
Definition: datastruct.h:187
Definition: datastruct.h:64
std::vector< T > m_valueVec
Vector of parameter values.
Definition: datastruct.h:728
Vec3D< double > strengthB
Strength of B field in T in a given direction (when uniform)
Definition: datastruct.h:522
Class derived from ParamBase that holds parameter values.
Definition: datastruct.h:724
std::vector< PyFuncTable > pyGasCollisionProbVec
Vector for the ctypes wrapper.
Definition: datastruct.h:643
uint32_t id
Id from the gas vector in CfgData.
Definition: datastruct.h:360
Holds information about collisions with gas particles.
Definition: datastruct.h:441
std::string m_name
Name for the command.
Definition: datastruct.h:667
PyVec< double > ranges
Vector of ranges.
Definition: datastruct.h:415
Vec3D< int > periodicBoundary
Periodic boundary 0-no, 1-yes.
Definition: datastruct.h:555
friend std::ostream & operator<<(std::ostream &os, const Vec3D< T > &vec)
Oveload of std::out operator.
Definition: datastruct.h:172
std::vector< Specie > specieVec
Vector of species.
Definition: datastruct.h:631
FuncTable freqFtab
Collision frequency, x-axis is in code velocity squared.
Definition: datastruct.h:462
void printLogFile()
Prints the log string to the defined file.
Definition: datastruct.cpp:516
@ Memory
Log messages concerned with memory allocation/deallocation (mask: 0100)
Logger * m_pLogger
Pointer to the Logger object from parfis.
Definition: datastruct.h:776
std::vector< std::string > specieNameVec
Specie names.
Definition: datastruct.h:559
double threshold
Threshold in eV.
Definition: datastruct.h:454
Vec3D< cellPos_t > pos
Cell position is represented with three integers x,y,z.
Definition: datastruct.h:283
Holds information about each gas component.
Definition: datastruct.h:357
Structure used to represent space cells.
Definition: datastruct.h:280
T y
Variable y.
Definition: datastruct.h:147
int rowCnt
Row count.
Definition: datastruct.h:413
uint32_t id
Id from the gas collision vector in CfgData.
Definition: datastruct.h:473
std::vector< cellId_t > cellIdAVec
Vector of pointer to cells of group A.
Definition: datastruct.h:615
double threshold
Threshold in eV.
Definition: datastruct.h:483
Vec3D< double > cellSize
Single cell size in meters.
Definition: datastruct.h:553
int geometry
Geometry type.
Definition: datastruct.h:547
Vec3D< int > typeE
E field type in a given direction (0:none, 1:uniform)
Definition: datastruct.h:516
double charge
Charge in Coulombs.
Definition: datastruct.h:339
Holds information about each specie.
Definition: datastruct.h:306
double amuMass
Mass in amu.
Definition: datastruct.h:333
Vec3D< double > dvUniformE
Increase in dv for uniform field e.
Definition: datastruct.h:345
int type
Type 0:linear, 1:nonlinear.
Definition: datastruct.h:409
std::function< int()> m_func
Function to run in the command object.
Definition: datastruct.h:673
Field field
Field data.
Definition: datastruct.h:645
uint16_t cellPos_t
Type for cell position vector components.
Definition: datastruct.h:56
Vec3D< double > velInitDistMax
Maximal velocity value for initial distribution.
Definition: datastruct.h:329
std::vector< stateId_t > headIdVec
Vector of pointers to head states.
Definition: datastruct.h:629
Vec3D< double > geometrySize
Geometry size in meters (bounding box of the simulation space)
Definition: datastruct.h:551
Vec3D< int > cellCount
Number of cells in every direction.
Definition: datastruct.h:557
std::vector< FuncTable > gasCollisionProbVec
Vector of total gas collision probability data.
Definition: datastruct.h:641
std::vector< double > ranges
Vector of ranges.
Definition: datastruct.h:387
stateId_t next
Pointer to the next state from the same cell, Const::noStateId for the last state.
Definition: datastruct.h:294
Vec3D< int > typeB
B field type in a given direction (0:none, 1:uniform)
Definition: datastruct.h:518
std::vector< double > scatterAngle
Scattering angle (random number sampled with scatterAngle gives deflection in radians)
Definition: datastruct.h:458
double mass
Mass in kg.
Definition: datastruct.h:335
@ None
No logging (mask: 0000)
double volumeFraction
Gas (volume) fraction.
Definition: datastruct.h:366
PyVec< double > scatterAngle
Scattering angle (random number sampled with scatterAngle gives deflection in radians)
Definition: datastruct.h:487
@ Warning
Log warning messages (mask: 0010)
const char * name
Collision name.
Definition: datastruct.h:446
Chain of commands.
Definition: datastruct.h:661
PyVec< double > xVec
X values.
Definition: datastruct.h:421
Vec3D< state_t > vel
Velocity vector.
Definition: datastruct.h:300
int type
Type 0:linear, 1:nonlinear.
Definition: datastruct.h:380
double maxVel
Maximal velocity allowed for the specie in m/s.
Definition: datastruct.h:323
int setPyCfgData()
Set PyCfgData.
Definition: datastruct.cpp:223
#define STATE_TYPE
Data type used for state_t (float or double) defined before compiling.
Definition: datastruct.h:44
double qm
Charge/mass ratio in C/kg.
Definition: datastruct.h:331
std::vector< cellId_t > cellIdBVec
Vector of pointer to cells of group B.
Definition: datastruct.h:617
void setNext(Command &comRef)
Set next command in the chain.
Definition: datastruct.h:679
const char * fileName
Cross section file name.
Definition: datastruct.h:448
Base class used for configurations.
Definition: datastruct.h:704
const char * name
Specie name.
Definition: datastruct.h:311
std::string m_fname
File name where the log text is written.
Definition: datastruct.h:109
double amuMass
Gas particle mass in amu.
Definition: datastruct.h:364
PyFuncTable & operator=(const FuncTable &ftab)
Overload of the equal operator for easier manipulation.
Definition: datastruct.h:425
PyCfgData pyCfgData
PyCfgData points to data of this object.
Definition: datastruct.h:567
PARFIS_EXPORT int loadCfgData(uint32_t id)
Wrapper for calling member function with the same name from the Parfis object.
Definition: parfis.cpp:455
friend bool operator!=(const Vec3D< T > &lhs, const Vec3D< T > &rhs)
Compares if vectors are not equal.
Definition: datastruct.h:161
std::vector< stateFlag_t > stateFlagVec
Vector of state flags - corresponds to stateVec.
Definition: datastruct.h:621
int velInitDist
Initial velocty random generator.
Definition: datastruct.h:313
PyVec< int > nbins
Vector of number of points per range.
Definition: datastruct.h:417
std::vector< int > nbins
Vector of number of points per range.
Definition: datastruct.h:389
uint32_t cellId_t
Type for cell id.
Definition: datastruct.h:52
std::string m_funcName
Function name.
Definition: datastruct.h:670
std::vector< PyGasCollision > pyGasCollisionVec
Vector for the ctypes wrapper.
Definition: datastruct.h:639
Struct that represents a 3d vector with components of type T.
Definition: datastruct.h:142
PyFuncTable freqFtab
Collision frequency, x-axis is in code velocity squared units.
Definition: datastruct.h:491
uint32_t id
Id from the specie vector.
Definition: datastruct.h:309
static void log(Logger &logger, LogMask mask, const std::string &msg)
Function for logging.
Definition: datastruct.h:123
std::vector< double > xVec
X values.
Definition: datastruct.h:393
std::function< double(double)> eval
Function to run the evaluation based on type.
Definition: datastruct.h:397
double timestep
Timestep for the system in seconds.
Definition: datastruct.h:549
int calculateColProb(const CfgData *pCfgData)
Calculates collision probability from the cx.
Definition: datastruct.cpp:400
const char * fileName
Cross section file name.
Definition: datastruct.h:477
Command * m_pNext
Pointer to the next command in the chain.
Definition: datastruct.h:676
double dt
Timestep in seconds.
Definition: datastruct.h:319
std::string m_str
String with the log text.
Definition: datastruct.h:104
CfgData * m_pCfgData
Pointer to configuration data.
Definition: datastruct.h:778
uint64_t evolveCnt
Evolution counter.
Definition: datastruct.h:649
Logger class.
Definition: datastruct.h:102
double xyDistSq(Vec3D< double > &a, Vec3D< double > &b)
Squared distance between two points in the x-y plane.
Definition: datastruct.h:245
Overload of PyVec for type std::string.
Definition: datastruct.h:220
std::map< std::string, std::unique_ptr< Command > > m_cmdMap
Map of commands.
Definition: datastruct.h:691
T x
Variable x.
Definition: datastruct.h:145
std::vector< std::string > gasCollisionFileNameVec
GasCollision file names.
Definition: datastruct.h:565
size_t headIdOffset
Offset for headIdVec.
Definition: datastruct.h:343
int statesPerCell
States per cell for creating initial particles.
Definition: datastruct.h:315
Class is used as a base class.
Definition: datastruct.h:749
PySimData pySimData
PySimData points to data of this object.
Definition: datastruct.h:647
const char * name
Gas name.
Definition: datastruct.h:362
Main namespace of the library.
Definition: datastruct.h:47
Configuration parameters data.
Definition: datastruct.h:545
uint32_t id
Id from the gas collision vector in CfgData.
Definition: datastruct.h:444
Vec3D< double > strengthE
Strength of E field in V/m in a given direction (when uniform)
Definition: datastruct.h:520
std::map< std::string, std::unique_ptr< ParamBase > > m_childMap
Map of children ParamBase objects (functions as a data containter)
Definition: datastruct.h:712
stateId_t prev
Pointer to the previous state from the same cell, Const::noStateId for the head state.
Definition: datastruct.h:296
PyGasCollision & operator=(const GasCollision &gasCol)
Overload of the equal operator for easier manipulation.
Definition: datastruct.h:493
uint32_t gasId
Id from the gas vector.
Definition: datastruct.h:452
Specie state.
Definition: datastruct.h:291
T len() const
Returns the vector length in Eucledian metric.
Definition: datastruct.h:181
Defines the whole command chain.
Definition: datastruct.h:688
std::vector< GasCollision > gasCollisionVec
Vector of gas collision data.
Definition: datastruct.h:637
uint8_t stateFlag_t
Type for state flags.
Definition: datastruct.h:60
int timestepRatio
Number of CfgData.timestep for one specie timestep.
Definition: datastruct.h:317
LogMask
Log bitmask that corresponds to log level.
Definition: datastruct.h:86
uint32_t stateId_t
Type for the state id.
Definition: datastruct.h:54