/* * Resolution of the divergence ODE: df/df + n*f/r = source (source must have dzpuis =2) * * (see file scalar.h for documentation). * */ /* * Copyright (c) 2005 Jerome Novak * * This file is part of LORENE. * * LORENE is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * LORENE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with LORENE; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ char scalar_sol_div_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_sol_div.C,v 1.5 2014/10/13 08:53:47 j_novak Exp $" ; /* * $Id: scalar_sol_div.C,v 1.5 2014/10/13 08:53:47 j_novak Exp $ * $Log: scalar_sol_div.C,v $ * Revision 1.5 2014/10/13 08:53:47 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.4 2014/10/06 15:16:16 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.3 2005/09/16 14:33:00 j_novak * Added #include . * * Revision 1.2 2005/09/16 12:49:52 j_novak * The case with dzpuis=1 is added. * * Revision 1.1 2005/06/08 12:35:22 j_novak * New method for solving divergence-like ODEs. * * * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_sol_div.C,v 1.5 2014/10/13 08:53:47 j_novak Exp $ * */ // C headers #include #include //Lorene headers #include "tensor.h" #include "diff.h" #include "proto.h" // Local prototypes namespace Lorene { void _sx_r_chebp(Tbl* , int& ) ; void _sx_r_chebi(Tbl* , int& ) ; Scalar Scalar::sol_divergence(int n_factor) const { assert(etat != ETATNONDEF) ; const Map_af* mpaff = dynamic_cast(mp) ; assert( mpaff != 0x0) ; Scalar result(*mp) ; if ( etat == ETATZERO ) result.set_etat_zero() ; else { //source not zero Base_val base_resu = get_spectral_base() ; base_resu.mult_x() ; const Mg3d* mg = mp->get_mg() ; result.set_etat_qcq() ; result.set_spectral_base(base_resu) ; result.set_spectral_va().set_etat_cf_qcq() ; Valeur sigma(va) ; sigma.ylm_i() ; // work on Fourier basis const Mtbl_cf& source = *sigma.c_cf ; // Checks on the type of domains int nz = mg->get_nzone() ; bool ced = (mg->get_type_r(nz-1) == UNSURR ) ; assert ( (!ced) || (check_dzpuis(2)) || (check_dzpuis(1)) ) ; assert (mg->get_type_r(0) == RARE) ; int nt = mg->get_nt(0) ; int np = mg->get_np(0) ; #ifndef NDEBUG for (int lz = 0; lzget_nt(lz) == nt) && (mg->get_np(lz) == np) ) ; #endif int nr, base_r,l_quant, m_quant; Tbl *so ; Tbl *s_hom ; Tbl *s_part ; // Working objects and initialization Mtbl_cf sol_part(mg, base_resu) ; Mtbl_cf sol_hom(mg, base_resu) ; Mtbl_cf& resu = *result.set_spectral_va().c_cf ; sol_part.annule_hard(); sol_hom.annule_hard() ; resu.annule_hard() ; //--------------- //-- NUCLEUS --- //--------------- int lz = 0 ; nr = mg->get_nr(lz) ; int dege = 1 ; // the operator is degenerate int nr0 = nr - dege ; Tbl vect1(3, 1, nr) ; Tbl vect2(3, 1, nr) ; int base_pipo = 0 ; double alpha = mpaff->get_alpha()[lz] ; double beta = 0. ; Matrice ope_even(nr0, nr0) ; //when the *result* is decomposed on R_CHEBP ope_even.set_etat_qcq() ; for (int i=dege; iset_etat_qcq() ; for (int i=0 ; iset(i) = source(lz, k, j, i) ; s_part = new Tbl(operateur.inverse(*so)) ; // Putting to Mtbl_cf double somme = 0 ; for (int i=0 ; iget_nr(lz) ; alpha = mpaff->get_alpha()[lz] ; beta = mpaff->get_beta()[lz]; double ech = beta / alpha ; Diff_id id(R_CHEB, nr) ; const Matrice& mid = id.get_matrice() ; Diff_xdsdx xd(R_CHEB, nr) ; const Matrice& mxd = xd.get_matrice() ; Diff_dsdx dx(R_CHEB, nr) ; const Matrice& mdx = dx.get_matrice() ; Matrice operateur = mxd + ech*mdx + n_factor*mid ; operateur.set_lu() ; // homogeneous solution s_hom = new Tbl(solh(nr, n_factor-1, ech, R_CHEB)) ; for (int k=0 ; kset_etat_qcq() ; // particular solution Tbl tmp(nr) ; tmp.set_etat_qcq() ; for (int i=0 ; iset(i) = beta*tmp(i) ; multx_1d(nr, &tmp.t, R_CHEB) ; for (int i=0; iset(i) += alpha*tmp(i) ; s_part = new Tbl (operateur.inverse(*so)) ; // cleaning things... for (int i=0 ; iget_nr(nz-1) ; alpha = mpaff->get_alpha()[nz-1] ; beta = mpaff->get_beta()[nz-1] ; dege = dzp ; nr0 = nr - dege ; Diff_dsdx dx(R_CHEBU, nr) ; const Matrice& mdx = dx.get_matrice() ; Diff_sx sx(R_CHEBU, nr) ; const Matrice& msx = sx.get_matrice() ; Diff_xdsdx xdx(R_CHEBU, nr) ; const Matrice& mxdx = xdx.get_matrice() ; Diff_id id(R_CHEBU, nr) ; const Matrice& mid = id.get_matrice() ; Matrice operateur(nr0, nr0) ; operateur.set_etat_qcq() ; if (dzp == 2) for (int lin=0; linset_etat_qcq() ; for (int i=0 ; iset(i) = source(nz-1, k, j, i) ; s_part = new Tbl(operateur.inverse(*so)) ; // cleaning double somme = 0 ; for (int i=0 ; i 1) { Tbl echelles(nz-1) ; echelles.set_etat_qcq() ; for (lz=1; lzget_beta()[lz]/mpaff->get_alpha()[lz] -1), n_factor) ; if (ced) echelles.set(nz-2) = 1./pow(-2., n_factor) ; for (int k=0 ; kget_nr(lz-1) ; nr = mg->get_nr(lz) ; for (int i=0; i