LORENE
funcspec.h
1  /*
2  * Definition of Lorene class FuncSpec
3  *
4  */
5 
6 /*
7  * Copyright (c) 2019 Jerome Novak
8  *
9  * This file is part of LORENE.
10  *
11  * LORENE is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2
13  * as published by the Free Software Foundation.
14  *
15  * LORENE is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with LORENE; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */
25 
26 #ifndef __FUNCSPEC__
27 #define __FUNCSPEC__
28 #include "tabspec.h"
29 
30 namespace Lorene {
31 
40  class FuncSpec {
41 
42  //Data
43  //----
44  protected:
45  int nx, ny, nz ;
46  double xmin, xmax, ymin, ymax, zmin, zmax ;
47  TabSpec xx, yy, zz ;
48  mutable TabSpec values, coefs ;
49  mutable bool coefs_up_to_date ;
50  mutable bool values_up_to_date ;
51 
52  mutable FuncSpec* p_dfdx ;
53  mutable FuncSpec* p_dfdy ;
54  mutable FuncSpec* p_dfdz ;
55 
56  //Constructors - Destructor
57  //-------------------------
58  public:
59  explicit FuncSpec(int=2, int=2, int=2) ;
60  explicit FuncSpec(const TabSpec&) ;
64  explicit FuncSpec(const string& coord_name, const string& field) ;
65  FuncSpec(const FuncSpec&) ;
66 
67  void set_grids(double, double, double, double, double, double) ;
68 
69  virtual ~FuncSpec() ;
70 
71  protected:
72  void del_deriv() const ;
73 
74  // Assignments
75  //------------
76  public:
77  void operator=(const FuncSpec&) ;
78  void operator=(const TabSpec&) ;
79  void operator=(double) ;
80 
81  void set_coefs(const TabSpec&) ;
82 
83  // Computing
84  //----------
85  void compute_coefs() const ;
86  double compute_in_xyz(double, double, double) const ;
87  void compute_values() const ;
88 
90  FuncSpec get_partial_x() const ;
92  FuncSpec get_partial_y() const ;
94  FuncSpec get_partial_z() const ;
95 
98  FuncSpec primitive_x() const ;
101  FuncSpec primitive_y() const ;
104  FuncSpec primitive_z() const ;
105 
106  // Saving into files
107  //-------------------
108  void write_grids(const string&) ;
109  void write_values(const string&) ;
110 
111  // Access to data
112  //---------------
113  TabSpec grid_x() const ;
114  TabSpec grid_y() const ;
115  TabSpec grid_z() const ;
116 
117  // Interpolate from a 3D TabSpec
118  //------------------------------
119  void interpolate_from_Tab(const TabSpec& values, const TabSpec& x_coord,
120  const TabSpec& y_coord, const TabSpec& z_coord) ;
121 
122  friend ostream& operator<<(ostream&, const FuncSpec&) ;
123  friend FuncSpec operator+(const FuncSpec&, const FuncSpec&) ;
124  friend FuncSpec operator-(const FuncSpec&) ;
125  friend FuncSpec operator+(const FuncSpec&, double) ;
126  friend FuncSpec operator+(double, const FuncSpec&) ;
127  friend FuncSpec operator-(const FuncSpec&, const FuncSpec&) ;
128  friend FuncSpec operator-(const FuncSpec&, double) ;
129  friend FuncSpec operator-(double, const FuncSpec&) ;
130  friend FuncSpec operator*(const FuncSpec&, const FuncSpec&) ;
131  friend FuncSpec operator*(const FuncSpec&, double) ;
132  friend FuncSpec operator*(double, const FuncSpec&) ;
133  friend FuncSpec operator/(const FuncSpec&, const FuncSpec&) ;
134  friend FuncSpec operator/(const FuncSpec&, double) ;
135  friend FuncSpec operator/(double, const FuncSpec&) ;
136 
137  friend FuncSpec sin(const FuncSpec&) ;
138  friend FuncSpec cos(const FuncSpec&) ;
139  friend FuncSpec tan(const FuncSpec&) ;
140  friend FuncSpec exp(const FuncSpec&) ;
141  friend FuncSpec log(const FuncSpec&) ;
142  friend FuncSpec sqrt(const FuncSpec&) ;
143  friend FuncSpec pow(const FuncSpec&, double) ;
144  friend FuncSpec abs(const FuncSpec&) ;
145 
146  friend double max(const FuncSpec&) ;
147 
148  };
149 
150  ostream& operator<<(ostream&, const FuncSpec&) ;
151 
152  FuncSpec operator-(const FuncSpec&) ;
153  FuncSpec operator+(const FuncSpec&, const FuncSpec&) ;
154  FuncSpec operator+(const FuncSpec&, double) ;
155  FuncSpec operator+(double, const FuncSpec&) ;
156  FuncSpec operator-(const FuncSpec&, const FuncSpec&) ;
157  FuncSpec operator-(const FuncSpec&, double) ;
158  FuncSpec operator-(double, const FuncSpec&) ;
159  FuncSpec operator*(const FuncSpec&, const FuncSpec&) ;
160  FuncSpec operator*(const FuncSpec&, double) ;
161  FuncSpec operator*(double, const FuncSpec&) ;
162  FuncSpec operator/(const FuncSpec&, const FuncSpec&) ;
163  FuncSpec operator/(const FuncSpec&, double) ;
164  FuncSpec operator/(double, const FuncSpec&) ;
165 
166  FuncSpec sin(const FuncSpec&) ;
167  FuncSpec cos(const FuncSpec&) ;
168  FuncSpec tan(const FuncSpec&) ;
169  FuncSpec exp(const FuncSpec&) ;
170  FuncSpec log(const FuncSpec&) ;
171  FuncSpec sqrt(const FuncSpec&) ;
172  FuncSpec pow(const FuncSpec&, double) ;
173  FuncSpec abs(const FuncSpec&) ;
174  double max(const FuncSpec&) ;
175 }
176 #endif
FuncSpec primitive_x() const
Computes the primitive with respect to which is 0 at the left boundary of the interval (xmin )...
Cmp log(const Cmp &)
Neperian logarithm.
Definition: cmp_math.C:299
Cmp exp(const Cmp &)
Exponential.
Definition: cmp_math.C:273
Cmp sqrt(const Cmp &)
Square root.
Definition: cmp_math.C:223
3-indices array to be used with the representation of functions with Cartesian coordinates.
Definition: tabspec.h:41
Lorene prototypes.
Definition: app_hor.h:67
Base_val operator*(const Base_val &, const Base_val &)
This operator is used when calling multiplication or division of Valeur .
Cmp operator/(const Cmp &, const Cmp &)
Cmp / Cmp.
Definition: cmp_arithm.C:460
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:97
Cmp tan(const Cmp &)
Tangent.
Definition: cmp_math.C:123
Class for representing functions of 3 variables, supposed to be Cartesian coordinates ...
Definition: funcspec.h:40
Cmp operator+(const Cmp &)
Definition: cmp_arithm.C:107
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition: cmp_math.C:438
FuncSpec primitive_y() const
Computes the primitive with respect to which is 0 at the left boundary of the interval (ymin )...
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:351
FuncSpec primitive_z() const
Computes the primitive with respect to which is 0 at the left boundary of the interval (zmin )...
FuncSpec get_partial_x() const
Computes partial derivative .
Cmp abs(const Cmp &)
Absolute value.
Definition: cmp_math.C:413
FuncSpec get_partial_z() const
Computes partial derivative .
Cmp operator-(const Cmp &)
- Cmp
Definition: cmp_arithm.C:111
Cmp sin(const Cmp &)
Sine.
Definition: cmp_math.C:72
virtual ~FuncSpec()
Destructor.
FuncSpec get_partial_y() const
Computes partial derivative .