KADATH
ope_def.cpp
1 /*
2  Copyright 2017 Philippe Grandclement
3 
4  This file is part of Kadath.
5 
6  Kadath is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Kadath is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Kadath. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "ope_eq.hpp"
21 namespace Kadath {
22 Ope_def::Ope_def(const System_of_eqs* zesys, Ope_eq* so, int valence, char* ind, Array<int>* ttype) : Ope_eq(zesys, so->get_dom(), 1) {
23  parts[0] = so ;
24 
25  Term_eq auxi (parts[0]->action()) ;
26 
27  res = new Term_eq (auxi) ;
28  if (res->val_t->get_valence()!=valence) {
29  cerr << "bad valence in definition" << endl ;
30  abort() ;
31  }
32 
33  // need that to enforce affectation of the indices and types
34  if (res->der_t==0x0)
35  res->set_der_zero() ;
36 
37  // Now put the indices and their right type
38  if (valence !=0) {
40  for (int i=0 ; i<valence ; i++)
41  res->val_t->set_name_ind(i, ind[i]) ;
42  res->val_t->set_index_type() = *ttype ;
43 
44 
46  for (int i=0 ; i<valence ; i++)
47  res->der_t->set_name_ind(i, ind[i]) ;
48  res->der_t->set_index_type() = *ttype ;
49  }
50 
51  // Put back things to get the right order
52  *res = auxi ;
53 }
54 
55 
56 Ope_def::~Ope_def() {
57  delete res ;
58 }
59 
61 
62  /*if (!called) {
63  res = new Term_eq(parts[0]->action()) ;
64  called = true ;
65  }
66  return *res ;*/
67  cerr << "Should not call Ope_def::action" << endl ;
68  abort() ;
69 }
70 
72  return res ;
73 }
74 
76  *res = parts[0]->action() ;
77 }}
void compute_res()
Forces the computation of the result (when things have changed).
Definition: ope_def.cpp:75
Term_eq * res
Result of the current definition.
Definition: ope_eq.hpp:482
Ope_def(const System_of_eqs *syst, Ope_eq *so, int val, char *name, Array< int > *ttype)
Constructor.
Definition: ope_def.cpp:22
Term_eq action() const override
Computes the action of the current Ope_eq using its various parts.
Definition: ope_def.cpp:60
Term_eq * get_res()
Returns the result.
Definition: ope_def.cpp:71
Abstract class that describes the various operators that can appear in the equations.
Definition: ope_eq.hpp:32
MMPtr_array< Ope_eq > parts
Pointers of the various parts of the current operator.
Definition: ope_eq.hpp:38
Class used to describe and solve a system of equations.
void set_name_ind(int dd, char name)
Sets the name of one index ; the names must have been affected first.
void set_name_affected()
Affects the name of the indices.
Definition: tensor.hpp:435
int & set_index_type(int i)
Sets the type of the index number.
Definition: tensor.hpp:538
int get_valence() const
Returns the valence.
Definition: tensor.hpp:509
This class is intended to describe the manage objects appearing in the equations.
Definition: term_eq.hpp:62
Tensor * der_t
Pointer on the variation, if the Term_eq is a Tensor.
Definition: term_eq.hpp:69
void set_der_zero()
Sets the variation of the approriate type to zero.
Definition: term_eq.cpp:187
Tensor * val_t
Pointer on the value, if the Term_eq is a Tensor.
Definition: term_eq.hpp:68