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