OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
MSLang.h
Go to the documentation of this file.
1#ifndef MSLANG_H
2#define MSLANG_H
3
6
7#include <fstream>
8#include <iostream>
9#include <list>
10#include <memory>
11#include <string>
12
13namespace mslang {
14 typedef std::string::iterator iterator;
15
17 v[2] = 0.0;
18 return euclidean_norm(v);
19 }
20
21 struct Base;
22
23 struct Function {
24 virtual ~Function() {};
25
26 virtual void print(int indent) = 0;
27 virtual void apply(std::vector<std::shared_ptr<Base>>& bfuncs) = 0;
28
29 static bool parse(iterator& it, const iterator& end, Function*& fun);
30
31 static const std::string UDouble;
32 static const std::string Double;
33 static const std::string UInt;
34 static const std::string FCall;
35 };
36
37 struct Base : public Function {
40 std::vector<std::shared_ptr<Base>> divisor_m;
41
42 Base() : trafo_m() {}
43
44 Base(const Base& right) : trafo_m(right.trafo_m), bb_m(right.bb_m) {}
45
46 virtual ~Base() {
47 // for (auto item: divisor_m) {
48 // item.reset();
49 // }
50 divisor_m.clear();
51 }
52
53 virtual std::shared_ptr<Base> clone() const = 0;
54 virtual void writeGnuplot(std::ofstream& out) const = 0;
55 virtual void computeBoundingBox() = 0;
56 virtual bool isInside(const Vector_t<double, 3>& R) const = 0;
57 virtual void divideBy(std::vector<std::shared_ptr<Base>>& divisors) {
58 for (auto item : divisors) {
59 if (bb_m.doesIntersect(item->bb_m)) {
60 divisor_m.emplace_back(item->clone());
61 }
62 }
63 }
64 };
65
66 bool parse(std::string str, Function*& fun);
67} // namespace mslang
68
69#endif
ippl::Vector< T, Dim > Vector_t
KOKKOS_INLINE_FUNCTION double euclidean_norm(const Vector_t< T, D > &v)
Definition VectorMath.h:15
double euclidean_norm2D(Vector_t< double, 3 > v)
Definition MSLang.h:16
std::string::iterator iterator
Definition MSLang.h:14
bool parse(std::string str, Function *&fun)
Definition MSLang.cpp:36
std::vector< std::shared_ptr< Base > > divisor_m
Definition MSLang.h:40
virtual bool isInside(const Vector_t< double, 3 > &R) const =0
virtual ~Base()
Definition MSLang.h:46
virtual void computeBoundingBox()=0
Base(const Base &right)
Definition MSLang.h:44
AffineTransformation trafo_m
Definition MSLang.h:38
BoundingBox2D bb_m
Definition MSLang.h:39
virtual void divideBy(std::vector< std::shared_ptr< Base > > &divisors)
Definition MSLang.h:57
virtual std::shared_ptr< Base > clone() const =0
virtual void writeGnuplot(std::ofstream &out) const =0
bool doesIntersect(const BoundingBox2D &bb) const
static const std::string FCall
Definition MSLang.h:34
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)=0
virtual ~Function()
Definition MSLang.h:24
static const std::string Double
Definition MSLang.h:32
static const std::string UDouble
Definition MSLang.h:31
static bool parse(iterator &it, const iterator &end, Function *&fun)
Definition MSLang.cpp:47
virtual void print(int indent)=0
static const std::string UInt
Definition MSLang.h:33