20 #include "headcpp.hpp"
21 #include "utilities.hpp"
22 #include "adapted.hpp"
24 #include "array_math.hpp"
26 #include "tensor_impl.hpp"
70 bool doder = (so.
der_t==0x0) ?
false :
true ;
99 bool doder = (so.
der_t==0x0) ?
false :
true ;
126 type_ind.
set(0) = COV ;
127 for (
int i=0 ; i<valso ; i++)
132 Tensor res (
sp, valso+1 , type_ind, basis) ;
140 for (
int nc=0 ; nc<so.
get_val_t().get_n_comp() ; nc++) {
144 for (
int i=0 ; i<valso ; i++)
145 indtarget.
set(i+1) = ind(i) ;
148 indtarget.
set(0) = 1 ;
151 indtarget.
set(0) = 2 ;
154 indtarget.
set(0) = 3 ;
164 Tensor resder (
sp, valso+1 , type_ind, basis) ;
166 for (
int nc=0 ; nc<so.
get_val_t().get_n_comp() ; nc++) {
170 for (
int i=0 ; i<valso ; i++)
171 indtarget.
set(i+1) = ind(i) ;
174 indtarget.
set(0) = 1 ;
177 indtarget.
set(0) = 2 ;
180 indtarget.
set(0) = 3 ;
270 for (
int nc=0 ; nc<so.
get_val_t().get_n_comp() ; nc++) {
274 for (
int i=0 ; i<valso ; i++)
275 indgrad.
set(i+1) = ind(i) ;
291 for (
int nc=0 ; nc<so.
get_val_t().get_n_comp() ; nc++) {
295 for (
int i=0 ; i<valso ; i++)
296 indgrad.
set(i+1) = ind(i) ;
317 cerr <<
"Unknown boundary in Domain_shell_inner_adapted::der_normal" << endl ;
323 #ifndef REMOVE_ALL_CHECKS
325 cerr <<
"Domain_shell_inner_adapted::lap_term_eq not defined for m != 0 (for now)" << endl ;
330 cerr <<
"Domain_shell_inner_adapted::lap_term_eq only defined for scalars" << endl ;
352 return so * (*rad_term_eq) ;
376 der.
cmp[cmp]->set_domain(
num_dom).set_zero() ;
389 type_ind.
set(0) = COV ;
390 for (
int i=1 ; i<valence+1 ; i++)
403 Index pos_res (val_res) ;
405 for (
int i=1 ; i<valence+1 ; i++)
406 pos_res.
set(i) = pos_so(i-1) ;
417 while (pos_so.
inc()) ;
424 Index pos_res (val_res) ;
426 for (
int i=1 ; i<valence+1 ; i++)
427 pos_res.
set(i) = pos_so(i-1) ;
438 while (pos_so.
inc()) ;
456 type_ind.
set(0) = COV ;
457 for (
int i=1 ; i<val_res ; i++)
464 for (
int cmp=0 ; cmp<auxi_val.
get_n_comp() ; cmp ++)
467 for (
int ind_sum=0 ; ind_sum<valence ; ind_sum++) {
470 Index pos_auxi(auxi_val) ;
474 for (
int i=0 ; i<valence ; i++)
475 pos_so.
set(i) = pos_auxi(i+1) ;
477 switch (pos_auxi(0)) {
484 switch (pos_auxi(ind_sum+1)) {
487 pos_so.
set(ind_sum) = 1 ;
492 pos_so.
set(ind_sum) = 0 ;
499 cerr <<
"Bad indice in Domain_shell_inner_adapted::connection_spher" << endl ;
506 switch (pos_auxi(ind_sum+1)) {
509 pos_so.
set(ind_sum) = 2 ;
514 pos_so.
set(ind_sum) = 2 ;
519 pos_so.
set(ind_sum) = 0 ;
521 pos_so.
set(ind_sum) = 1 ;
525 cerr <<
"Bad indice in Domain_shell_inner_adapted::connection_spher" << endl ;
530 cerr <<
"Bad indice in Domain_shell_inner_adapted::connection_spher" << endl ;
534 while (pos_auxi.
inc()) ;
540 return Term_eq (dom, auxi_val) ;
547 for (
int cmp=0 ; cmp<auxi_der.
get_n_comp() ; cmp ++)
551 for (
int ind_sum=0 ; ind_sum<valence ; ind_sum++) {
554 Index pos_auxi_der(auxi_der) ;
558 for (
int i=0 ; i<valence ; i++)
559 pos_so.
set(i) = pos_auxi_der(i+1) ;
561 switch (pos_auxi_der(0)) {
568 switch (pos_auxi_der(ind_sum+1)) {
571 pos_so.
set(ind_sum) = 1 ;
577 pos_so.
set(ind_sum) = 0 ;
585 cerr <<
"Bad indice in Domain_shell_inner_adapted::connection_spher" << endl ;
592 switch (pos_auxi_der(ind_sum+1)) {
595 pos_so.
set(ind_sum) = 2 ;
601 pos_so.
set(ind_sum) = 2 ;
607 pos_so.
set(ind_sum) = 0 ;
610 pos_so.
set(ind_sum) = 1 ;
615 cerr <<
"Bad indice in Domain_shell_inner_adapted::connection_spher" << endl ;
620 cerr <<
"Bad indice in Domain_shell_inner_adapted::connection_spher" << endl ;
624 while (pos_auxi_der.
inc()) ;
627 return Term_eq (dom, auxi_val, auxi_der) ;
638 type_ind.
set(0) = COV ;
639 for (
int i=1 ; i<valence+1 ; i++)
652 Index pos_res (val_res) ;
654 for (
int i=1 ; i<valence+1 ; i++)
655 pos_res.
set(i) = pos_so(i-1) ;
669 while (pos_so.
inc()) ;
676 Index pos_res (val_res) ;
678 for (
int i=1 ; i<valence+1 ; i++)
679 pos_res.
set(i) = pos_so(i-1) ;
693 while (pos_so.
inc()) ;
702 assert (bound==INNER_BC) ;
704 case CARTESIAN_BASIS :
709 case SPHERICAL_BASIS :
715 cerr <<
"Unknown type of tensorial basis in Domain_shell_inner_adapted::give_normal" << endl ;
725 #ifndef REMOVE_ALL_CHECKS
727 cerr <<
"Ope_int_volume only defined with respect for a tensor" << endl ;
732 cerr <<
"Ope_int_volume only defined with respect to a scalar" << endl ;
746 assert(baset==SIN_ODD) ;
751 assert (baser==CHEB) ;
758 resval += 2./(2.*j+1) * integral_1d(CHEB, cf) ;
764 if (integrant.
der_t!=0x0) {
771 assert(baset==SIN_ODD) ;
776 assert (baser==CHEB) ;
783 resder += 2./(2.*j+1) * integral_1d(CHEB, cf) ;
787 return Term_eq (dom, resval, resder) ;
795 cerr <<
"Domain_shell_inner_adapted::integ_term_eq not implemented yet" << endl ;
reference set(const Index &pos)
Read/write of an element.
Bases_container bases_1d
Arrays containing the various basis of decomposition.
Describes the tensorial basis used by the various tensors.
int & set_basis(int nd)
Read/write the basis in a given domain.
Term_eq * der_rad_term_eq
Pointer on the Term_eq containing the .
Term_eq flat_grad_spher(const Term_eq &) const
Computes the flat gradient of a field, in orthonormal spherical coordinates.
Term_eq derive_t(const Term_eq &so) const
Computes .
Term_eq derive_p(const Term_eq &so) const
Computes .
virtual Term_eq connection_spher(const Term_eq &) const
Computes the part of the gradient involving the connections, in spherical orthonormal coordinates.
virtual Term_eq integ_volume_term_eq(const Term_eq &) const
Volume integral of a Term_eq.
virtual void update_term_eq(Term_eq *) const
Update the value of a field, after the shape of the Domain has been changed by the system.
virtual Term_eq partial_spher(const Term_eq &) const
Computes the part of the gradient containing the partial derivative of the field, in spherical orthon...
Term_eq * rad_term_eq
Pointer on the Term_eq containing the radius.
virtual Term_eq dr_term_eq(const Term_eq &) const
Radial derivative of a Term_eq.
virtual Term_eq der_normal_term_eq(const Term_eq &, int) const
Returns the normal derivative of a Term_eq.
virtual Term_eq lap_term_eq(const Term_eq &, int) const
Returns the flat Laplacian of Term_eq, for a given harmonic.
Term_eq * normal_spher
Pointer on the Term_eq containing the normal vector to the inner boundary, in orthonormal spherical c...
void do_normal_cart() const
Computes the normal wrt the inner boundary, in Cartesian coordinates.
virtual Val_domain div_r(const Val_domain &) const
Division by .
const Space & sp
The corresponding Space ; required for updating fields whene the mapping changes.
Term_eq * dt_rad_term_eq
Pointer on the Term_eq containing the .
virtual Term_eq integ_term_eq(const Term_eq &, int) const
Surface integral of a Term_eq.
virtual Val_domain mult_sin_theta(const Val_domain &) const
Multiplication by .
Term_eq * normal_cart
Pointer on the Term_eq containing the normal vector to the inner boundary, in Cartesian coordinates.
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
void do_normal_spher() const
Computes the normal wrt the inner boundary, in orthonormal spherical coordinates.
Term_eq * inner_radius_term_eq
Pointer on the inner boundary , as a Term_eq.
virtual const Term_eq * give_normal(int, int) const
Returns the vector normal to a surface.
virtual Val_domain mult_sin_phi(const Val_domain &) const
Multiplication by .
virtual Term_eq partial_cart(const Term_eq &) const
Computes the part of the gradient containing the partial derivative of the field, in Cartesian coordi...
virtual Term_eq mult_r_term_eq(const Term_eq &) const
Multiplication by of a Term_eq.
virtual Val_domain mult_cos_theta(const Val_domain &) const
Multiplication by .
Term_eq derive_r(const Term_eq &so) const
Computes .
Term_eq * dp_rad_term_eq
Pointer on the Term_eq containing the .
virtual Val_domain mult_sin_theta(const Val_domain &) const
Multiplication by .
Term_eq do_comp_by_comp(const Term_eq &so, Val_domain(Domain::*pfunc)(const Val_domain &) const) const
Function used to apply the same operation to all the components of a tensor, in the current domain.
int num_dom
Number of the current domain (used by the Space)
Dim_array nbr_coefs
Number of coefficients.
virtual Val_domain div_sin_theta(const Val_domain &) const
Division by .
Dim_array nbr_points
Number of colocation points.
Memory_mapped_array< Array< double > * > coloc
Colocation points in each dimension (stored in ndim 1d- arrays)
virtual Val_domain mult_cos_theta(const Val_domain &) const
Multiplication by .
Class that gives the position inside a multi-dimensional Array.
int & set(int i)
Read/write of the position in a given dimension.
bool inc(int increm, int var=0)
Increments the position of the Index.
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
Memory_mapped_array< Scalar * > cmp
Array of size n_comp of pointers onto the components.
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
int get_index_type(int i) const
Gives the type (covariant or contravariant) of a given index.
int get_n_comp() const
Returns the number of stored components.
virtual Array< int > indices(int pos) const
Gives the values of the indices corresponding to a location in the array used for storage of the comp...
int get_valence() const
Returns the valence.
const Space & get_space() const
Returns the Space.
This class is intended to describe the manage objects appearing in the equations.
Tensor * der_t
Pointer on the variation, if the Term_eq is a Tensor.
const int type_data
Flag describing the type of data :
void set_der_t(Tensor)
Sets the tensorial variation (only the values in the pertinent Domain are copied).
Tensor const & get_val_t() const
Tensor const & get_der_t() const
Tensor * val_t
Pointer on the value, if the Term_eq is a Tensor.
Class for storing the basis of decompositions of a field and its values on both the configuration and...
bool check_if_zero() const
Check whether the logical state is zero or not.
double & set(const Index &pos)
Read/write the value of the field in the configuration space.
Val_domain div_sin_theta() const
Division by .
Val_domain mult_cos_theta() const
Multiplication by .
Base_spectral & set_base()
Sets the basis of decomposition.
Array< double > get_coef() const
void allocate_conf()
Allocates the values in the configuration space and destroys the values in the coefficients space.
const Base_spectral & get_base() const
Returns the basis of decomposition.
A class derived from Tensor to deal specificaly with objects of valence 1 (and so also 1-forms).
Scalar & set(int)
Read/write access to a component.