FEDEM Solver  R8.0
Source code of the dynamics solver
FFaTensor1.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
13 #ifndef FFA_TENSOR1_H
14 #define FFA_TENSOR1_H
15 
16 #include <iostream>
17 
18 class FFaTensor2;
19 class FFaTensor3;
20 
21 
31 {
32  double myT;
33 
34 public:
36  FFaTensor1(double d = 0.0) { myT = d; }
38  FFaTensor1(const FFaTensor2& t);
40  FFaTensor1(const FFaTensor3& t);
41 
43  void fill(double d) { myT = d; }
44 
46  FFaTensor1& operator= (const FFaTensor2& t);
48  FFaTensor1& operator= (const FFaTensor3& t);
49 
52  {
53  myT += t.myT;
54  return *this;
55  }
56 
59  {
60  myT -= t.myT;
61  return *this;
62  }
63 
66  {
67  myT *= d;
68  return *this;
69  }
70 
73  {
74  myT /= d;
75  return *this;
76  }
77 
79  operator double() const { return myT; }
80 
81  // Global operators
82 
86  friend FFaTensor1 operator+ (const FFaTensor1&, const FFaTensor1&);
88  friend FFaTensor1 operator- (const FFaTensor1&, const FFaTensor1&);
89 
91  friend FFaTensor1 operator* (const FFaTensor1&, double);
93  friend FFaTensor1 operator* (double, const FFaTensor1&);
95  friend FFaTensor1 operator/ (const FFaTensor1&, double);
96 
98  friend bool operator== (const FFaTensor1&, const FFaTensor1&);
100  friend bool operator!= (const FFaTensor1&, const FFaTensor1&);
101 
103  friend std::ostream& operator<< (std::ostream&, const FFaTensor1&);
105  friend std::istream& operator>> (std::istream&, FFaTensor1&);
106 };
107 
108 #endif
Class to represent a 1D simple tensor.
Definition: FFaTensor1.H:31
double myT
Tensor component value.
Definition: FFaTensor1.H:32
friend std::istream & operator>>(std::istream &, FFaTensor1 &)
Reading operator.
friend bool operator!=(const FFaTensor1 &, const FFaTensor1 &)
Inequality operator,.
friend FFaTensor1 operator+(const FFaTensor1 &, const FFaTensor1 &)
Global addition operator.
FFaTensor1 & operator*=(double d)
Scaling operator (multiplication by a scalar).
Definition: FFaTensor1.H:65
FFaTensor1 & operator/=(double d)
Scaling operator (division by a scalar).
Definition: FFaTensor1.H:72
void fill(double d)
Initializes all tensor components to the given value.
Definition: FFaTensor1.H:43
FFaTensor1 & operator+=(const FFaTensor1 &t)
Addition operator.
Definition: FFaTensor1.H:51
FFaTensor1 & operator-=(const FFaTensor1 &t)
Subtraction operator.
Definition: FFaTensor1.H:58
friend std::ostream & operator<<(std::ostream &, const FFaTensor1 &)
Printing operator.
friend FFaTensor1 operator-(const FFaTensor1 &)
Unary negation operator.
friend FFaTensor1 operator*(const FFaTensor1 &, double)
Scaling operator, multiplication of a tensor and a scalar.
FFaTensor1(double d=0.0)
Default constructor initializing the tensor to 0 (or given value).
Definition: FFaTensor1.H:36
friend FFaTensor1 operator/(const FFaTensor1 &, double)
Scaling operator, division by a scalar.
FFaTensor1 & operator=(const FFaTensor2 &t)
Overloaded assignment operator.
Definition: FFaTensor1.C:31
friend bool operator==(const FFaTensor1 &, const FFaTensor1 &)
Equality operator,.
Class to represent a 2D symmetrical tensor.
Definition: FFaTensor2.H:35
Class to represent a 3D symmetric tensor.
Definition: FFaTensor3.H:35