Documentation of CSL
field.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
23 #ifndef FIELD_H_INCLUDED
24 #define FIELD_H_INCLUDED
25 
26 #include "parent.h"
27 #include "indicial.h"
28 
29 namespace csl {
30 
32 
33  protected:
34 
35  const Space* spaceField;
36 
37  public:
38 
39  FieldParent();
40 
41  explicit FieldParent(const std::string& t_name);
42 
43  FieldParent(const FieldParent& field) = default;
44 
45  FieldParent(const std::string& t_name, const Space* t_spaceField);
46 
47  ~FieldParent(){};
48 
49  cslParent::PrimaryType getPrimaryType() const override;
50 
51  const Space* getFieldSpace() const override;
52 
53  protected:
54 
55  void checkFieldRequest(TensorParent* point);
56 };
57 
59 
60  public:
61 
63 
64  explicit ScalarFieldParent(const std::string& t_name);
65 
66  ScalarFieldParent(const ScalarFieldParent& field) = default;
67 
68  ScalarFieldParent(const std::string& t_name, const Space* t_spaceField);
69 
70  ~ScalarFieldParent(){};
71 
72  template<class ...Args>
73  friend
74  std::shared_ptr<ScalarFieldParent> sfparent_(Args&& ...args)
75  {
76  return csl::make_shared<ScalarFieldParent>(args...);
77  }
78 
79  cslParent::Type getType() const override;
80 
81  Expr operator()(const Tensor& point) override;
82 };
83 
85 
86  protected:
87 
88  mutable Tensor point;
89 
90  public:
91 
92  AbstractField(const Tensor& t_vector,
93  const Parent& t_parent);
94 
95  ~AbstractField(){};
96 
97  csl::PrimaryType getPrimaryType() const override;
98 
99  Tensor getPoint() const override;
100 
101  bool dependsOn(Expr_info expr) const override;
102 
103  bool dependsOn(Parent_info t_parent) const override;
104 
105  bool dependsExplicitlyOn(Expr_info expr) const override;
106 
107  void setPoint(const Tensor& t_vector) override;
108 
109  protected:
110 
111  const Space* getSpace() const;
112 };
113 
115 
116  public:
117 
118  ScalarField(const Tensor& t_vector,
119  const Parent& t_parent);
120 
121  explicit
122  ScalarField(const Expr& otherField);
123 
124  explicit
125  ScalarField(const Abstract* otherField);
126 
127  ~ScalarField(){};
128 
129  csl::Type getType() const override;
130 
131  void print(int mode=0,
132  std::ostream& out=std::cout,
133  bool lib = false) const override;
134 
135  std::string printLaTeX(int mode=0) const override;
136 
137  std::optional<Expr> evaluate(
138  csl::eval::mode user_mode = csl::eval::base
139  ) const override;
140 
141  unique_Expr copy_unique() const override;
142 
143  bool commutesWith(Expr_info expr, int sign=-1) const override;
144 
145  bool operator==(Expr_info expr) const override;
146 
147  bool operator<(const Abstract* expr) const override;
148 };
149 
150 } // End of namespace csl
151 
152 #endif
Namespace for csl library.
Definition: abreviation.h:34
Definition: parent.h:439
Parent of an indicial object, allows to generate them (TensorElement).
Definition: indicial.h:245
Base classes for parents and elements.
Type
Enum of the different types of Abstract (i.e. list of all possible specializations).
Definition: enum.h:47
Definition: field.h:58
PrimaryType
Definition: parent.h:39
cslParent::PrimaryType getPrimaryType() const override
Definition: field.cpp:48
virtual bool dependsExplicitlyOn(Expr_info expr) const
Tells if the parent depends explicitely on another expression or not.
Definition: parent.cpp:305
Definition: diagonalization.h:34
PrimaryType
Stores enumerations of types for Abstract objects.
Definition: enum.h:31
virtual Expr operator()(Index index)
Generate the Element for an TensorParent of dimension 1 (a single index).
Definition: parent.cpp:543
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
virtual cslParent::Type getType() const =0
virtual bool dependsOn(Expr_info expr) const
Tells if the parent depends on another expression or not.
Definition: parent.cpp:297
Vector space that has a name, a dimension, a delta tensor and possibly a non-trivial metric...
Definition: space.h:64
Definition: field.h:114
Base class for all parents (indicial, fields etc). All parents derive from this class.
Definition: parent.h:81
bool operator==(const Expr &a, const Expr &b)
see Abstract::operator==()
Definition: abstract.cpp:1398
Definition: field.h:84
Type
Definition: parent.h:47
Definition: field.h:31
Objects handling indexed expressions in order to perform indicial tensor calculations.
bool operator<(const Expr &a, const Expr &b)
see Abstract::operator<()
Definition: abstract.cpp:1423
Definition: indicial.h:675
Base class for all elements. Objects that are constructed by a parent (see AbstractParent) when the u...
Definition: element.h:37
Expression type/.
Definition: abstract.h:1573