/* * Method for vector Poisson equation inverting eqs. for V^r and eta as a block. * * (see file vector.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 vector_poisson_block_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/vector_poisson_block.C,v 1.9 2014/10/13 08:53:45 j_novak Exp $" ; /* * $Id: vector_poisson_block.C,v 1.9 2014/10/13 08:53:45 j_novak Exp $ * $Log: vector_poisson_block.C,v $ * Revision 1.9 2014/10/13 08:53:45 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.8 2014/10/06 15:13:21 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.7 2012/10/12 11:43:38 j_novak * Removed some headers * * Revision 1.6 2007/12/21 10:45:06 j_novak * Better treatment of spherical symmetry * * Revision 1.5 2007/09/05 12:35:18 j_novak * Homogeneous solutions are no longer obtained through the analytic formula, but * by solving (again) the operator system with almost zero as r.h.s. This is to * lower the condition number of the matching system. * * Revision 1.4 2007/01/23 17:08:46 j_novak * New function pois_vect_r0.C to solve the l=0 part of the vector Poisson * equation, which involves only the r-component. * * Revision 1.3 2005/12/30 13:39:38 j_novak * Changed the Galerkin base in the nucleus to (hopefully) stabilise the solver * when used in an iteration. Similar changes in the CED too. * * Revision 1.2 2005/02/15 15:43:18 j_novak * First version of the block inversion for the vector Poisson equation (method 6). * * * $Header: /cvsroot/Lorene/C++/Source/Tensor/vector_poisson_block.C,v 1.9 2014/10/13 08:53:45 j_novak Exp $ * */ // C headers #include // Lorene headers #include "metric.h" #include "diff.h" #include "proto.h" namespace Lorene { void Vector::poisson_block(double lam, Vector& resu) const { const Map_af* mpaff = dynamic_cast(mp) ; #ifndef NDEBUG for (int i=0; i<3; i++) assert(cmp[i]->check_dzpuis(4)) ; // All this has a meaning only for spherical components: const Base_vect_spher* bvs = dynamic_cast(triad) ; assert(bvs != 0x0) ; //## ... and affine mapping, for the moment! assert( mpaff != 0x0) ; #endif if (fabs(lam + 1.) < 1.e-8) { const Metric_flat& mets = mp->flat_met_spher() ; Vector_divfree sou(*mp, *triad, mets) ; for (int i=1; i<=3; i++) sou.set(i) = *cmp[i-1] ; resu = sou.poisson() ; return ; } // Some working objects //--------------------- const Mg3d& mg = *mpaff->get_mg() ; int nz = mg.get_nzone() ; int nzm1 = nz - 1; int nt = mg.get_nt(0) ; int np = mg.get_np(0) ; assert(mg.get_type_r(0) == RARE) ; assert(mg.get_type_r(nzm1) == UNSURR) ; Scalar S_r = *cmp[0] ; Scalar S_eta = eta() ; Scalar het(*mpaff) ; Scalar vr(*mpaff) ; bool all_zero = false ; if (S_r.get_etat() == ETATZERO) { if (S_eta.get_etat() == ETATZERO) { vr.set_etat_zero() ; het.set_etat_zero() ; all_zero = true ; } else { S_r.annule_hard() ; S_r.set_spectral_base(S_eta.get_spectral_base()) ; } } if ((S_eta.get_etat() == ETATZERO)&&(!all_zero)) { S_eta.annule_hard() ; S_eta.set_spectral_base(S_r.get_spectral_base()) ; } if (!all_zero) { S_r.set_spectral_va().ylm() ; S_eta.set_spectral_va().ylm() ; const Base_val& base = S_eta.get_spectral_va().base ; Mtbl_cf sol_part_eta(mg, base) ; sol_part_eta.annule_hard() ; Mtbl_cf sol_part_vr(mg, base) ; sol_part_vr.annule_hard() ; Mtbl_cf sol_hom_un_eta(mg, base) ; sol_hom_un_eta.annule_hard() ; Mtbl_cf sol_hom_deux_eta(mg, base) ; sol_hom_deux_eta.annule_hard() ; Mtbl_cf sol_hom_trois_eta(mg, base) ; sol_hom_trois_eta.annule_hard() ; Mtbl_cf sol_hom_quatre_eta(mg, base) ; sol_hom_quatre_eta.annule_hard() ; Mtbl_cf sol_hom_un_vr(mg, base) ; sol_hom_un_vr.annule_hard() ; Mtbl_cf sol_hom_deux_vr(mg, base) ; sol_hom_deux_vr.annule_hard() ; Mtbl_cf sol_hom_trois_vr(mg, base) ; sol_hom_trois_vr.annule_hard() ; Mtbl_cf sol_hom_quatre_vr(mg, base) ; sol_hom_quatre_vr.annule_hard() ; // Solution of the l=0 part for Vr //--------------------------------- Scalar sou_l0 = (*cmp[0]) / (1. + lam) ; sou_l0.set_spectral_va().ylm() ; Scalar vrl0 = pois_vect_r0(sou_l0) ; // Build-up & inversion of the system for (eta, V^r) in each domain //----------------------------------------------------------------- // Nucleus //-------- int nr = mg.get_nr(0) ; double alpha = mpaff->get_alpha()[0] ; double alp2 = alpha*alpha ; double beta = mpaff->get_beta()[0] ; int l_q = 0 ; int m_q = 0; int base_r = 0 ; // Loop on l and m //---------------- for (int k=0 ; k 0) ) { int aa = 0 ; int bb = 0 ; int nr0 = 0 ; if (base_r == R_CHEBP) { nr0 = nr - 1 ; aa = 0 ; bb = 1 ; } else { assert (base_r == R_CHEBI) ; nr0 = nr - 2 ; aa = 2 ; bb = 1 ; } int d0 = nr - nr0 ; int nrtot = 2*nr0 ; Matrice oper(2*nr, 2*nr) ; oper.set_etat_qcq() ; Tbl sec_membre(nrtot) ; sec_membre.set_etat_qcq() ; Diff_dsdx2 d2(base_r, nr) ; const Matrice& md2 = d2.get_matrice() ; Diff_sxdsdx xd(base_r, nr) ; const Matrice& mxd = xd.get_matrice() ; Diff_sx2 s2(base_r, nr) ; const Matrice& ms2 = s2.get_matrice() ; // Building the operator //---------------------- for (int lin=0; lin 2)||pb_eta) { for (int col=0; col 2)||pb_eta) sec_membre.set(nrtot-1) = 0 ; // Inversion of the "big" operator //-------------------------------- Tbl big_res = op2.inverse(sec_membre) ; // Putting coefficients of eta and Vr to individual arrays //-------------------------------------------------------- sol_part_eta.set(0, k, j, 0) = (aa+bb)*big_res(0) ; for (int i=1; i 5) ; assert(nt == mg.get_nt(zone)) ; assert(np == mg.get_np(zone)) ; alpha = mpaff->get_alpha()[zone] ; beta = mpaff->get_beta()[zone] ; double ech = beta / alpha ; // Loop on l and m //---------------- for (int k=0 ; kget_alpha()[nzm1] ; alp2 = alpha*alpha ; assert (nr > 4) ; // Loop on l and m //---------------- for (int k=0 ; k 1) { for (int col=0; colget_alpha()[0] ; // value of at x=1 of eta ... systeme.set(ligne, colonne) = sol_hom_un_eta.val_out_bound_jk(0, j, k) ; systeme.set(ligne, colonne+1) = sol_hom_trois_eta.val_out_bound_jk(0, j, k) ; sec_membre.set(ligne) = -sol_part_eta.val_out_bound_jk(0, j, k) ; ligne++ ; // ... and of its couterpart for V^r systeme.set(ligne, colonne) = sol_hom_un_vr.val_out_bound_jk(0, j, k) ; systeme.set(ligne, colonne+1) = sol_hom_trois_vr.val_out_bound_jk(0, j, k) ; sec_membre.set(ligne) = -sol_part_vr.val_out_bound_jk(0,j,k) ; ligne++ ; //derivatives int pari = (base_r == R_CHEBP ? 0 : 1) ; for (int i=0; iget_alpha()[zone] ; ligne -= 3 ; systeme.set(ligne, colonne) = -sol_hom_un_eta.val_in_bound_jk(zone, j, k) ; systeme.set(ligne, colonne+1) = -sol_hom_deux_eta.val_in_bound_jk(zone, j, k) ; systeme.set(ligne, colonne+2) = -sol_hom_trois_eta.val_in_bound_jk(zone, j, k) ; systeme.set(ligne, colonne+3) = -sol_hom_quatre_eta.val_in_bound_jk(zone, j, k) ; sec_membre.set(ligne) += sol_part_eta.val_in_bound_jk(zone, j, k) ; ligne++ ; // ... and their couterparts for V^r systeme.set(ligne, colonne) = -sol_hom_un_vr.val_in_bound_jk(zone, j, k) ; systeme.set(ligne, colonne+1) = -sol_hom_deux_vr.val_in_bound_jk(zone, j, k) ; systeme.set(ligne, colonne+2) = -sol_hom_trois_vr.val_in_bound_jk(zone, j, k) ; systeme.set(ligne, colonne+3) = -sol_hom_quatre_vr.val_in_bound_jk(zone, j, k) ; sec_membre.set(ligne) += sol_part_vr.val_in_bound_jk(zone, j, k) ; ligne++ ; //derivative of (x+echelle)^(l-1) at -1 pari = -1 ; for (int i=0; iget_alpha()[nzm1] ; ligne -= 3 ; //value of (x-1)^(l+2) at -1 : systeme.set(ligne, colonne) -= sol_hom_deux_eta.val_in_bound_jk(nzm1, j, k) ; systeme.set(ligne, colonne+1) -= sol_hom_quatre_eta.val_in_bound_jk(nzm1, j, k) ; sec_membre.set(ligne) += sol_part_eta.val_in_bound_jk(nzm1, j, k) ; //... and of its couterpart for V^r systeme.set(ligne+1, colonne) -= sol_hom_deux_vr.val_in_bound_jk(nzm1, j, k) ; systeme.set(ligne+1, colonne+1) -= sol_hom_quatre_vr.val_in_bound_jk(nzm1, j, k) ; sec_membre.set(ligne+1) += sol_part_vr.val_in_bound_jk(nzm1, j, k) ; ligne += 2 ; //derivative of (x-1)^(l+2) at -1 : pari = 1 ; for (int i=0; i