/* * Resolution of the divergence-free vector Poisson equation * * (see file vector.h for documentation). * */ /* * Copyright (c) 2003 Eric Gourgoulhon & 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_df_poisson_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/vector_df_poisson.C,v 1.15 2014/10/13 08:53:44 j_novak Exp $" ; /* * $Id: vector_df_poisson.C,v 1.15 2014/10/13 08:53:44 j_novak Exp $ * $Log: vector_df_poisson.C,v $ * Revision 1.15 2014/10/13 08:53:44 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.14 2014/10/06 15:13:20 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.13 2005/02/15 09:45:22 j_novak * Correction of an error in the matching. * * Revision 1.12 2005/02/09 16:53:11 j_novak * Now V^r and eta are matched across domains, but not any of their derivatives. * * Revision 1.11 2005/02/09 14:52:01 j_novak * Better solution in the shells. * * Revision 1.10 2005/02/09 13:20:27 j_novak * Completely new way of solving the vector Poisson equation in the Div_free * case: the system is inverted "as a whole" for V^r and eta. This works only * with Map_af... * * * $Header: /cvsroot/Lorene/C++/Source/Tensor/vector_df_poisson.C,v 1.15 2014/10/13 08:53:44 j_novak Exp $ * */ // C headers #include #include // Lorene headers #include "tensor.h" #include "diff.h" #include "proto.h" #include "param.h" namespace Lorene { Vector_divfree Vector_divfree::poisson(Param& par ) const { // All this has a meaning only for spherical components: #ifndef NDEBUG const Base_vect_spher* bvs = dynamic_cast(triad) ; assert(bvs != 0x0) ; #endif int nitermax = par.get_int() ; int& niter = par.get_int_mod() ; double relax = par.get_double() ; double precis = par.get_double(1) ; Cmp& ss_khi = par.get_cmp_mod(0) ; Cmp& ss_mu = par.get_cmp_mod(1) ; // Solution for the r-component // ---------------------------- Scalar source_r = *(cmp[0]) ; source_r.mult_r() ; Param par_khi ; par_khi.add_int(nitermax, 0) ; par_khi.add_int_mod(niter, 0) ; par_khi.add_double(relax, 0) ; par_khi.add_double(precis, 1) ; par_khi.add_cmp_mod(ss_khi, 0) ; Scalar khi (*mp) ; khi.set_etat_zero() ; source_r.poisson(par_khi, khi) ; khi.div_r() ; // khi now contains V^r // Solution for mu // --------------- Param par_mu ; par_mu.add_int(nitermax, 0) ; par_mu.add_int_mod(niter, 0) ; par_mu.add_double(relax, 0) ; par_mu.add_double(precis, 1) ; par_mu.add_cmp_mod(ss_mu, 0) ; Scalar mu_resu (*mp) ; mu_resu.set_etat_zero() ; mu().poisson(par_mu, mu_resu) ; // Final result // ------------ Vector_divfree resu(*mp, *triad, *met_div) ; resu.set_vr_mu(khi, mu_resu) ; return resu ; } /* * In the case without parameters, first is solved the equation for mu and then * the system of equations for (eta, V^r) is inverted as a whole: * d2 eta / dr2 + 2/r d eta / dr - 1/r d V^r / dr = S(eta) * d V^r / dr + 2/r V^r - l(l+1)/r eta = 0 (div free condition) * * There is no l=0 contribution (divergence free in all space!). * In the nucleus and the CED the system is inverted for h(r) and v(r) , * such that eta = r^2 h and V^r = r^2 v in the nucleus, * in the compactified domain one has eta = u^2 h and V^r = u^2 v (where u=1/r); * In the shells, both equations are multiplied by r. * These methods are used only to get particular solutions. * * Homogeneous solutions are known analitically: r^(l-1) and/or 1/r^(l+2) * It is then only possible to match eta and V^r, but not their derivatives, * due to the div-free condition. */ Vector_divfree Vector_divfree::poisson() 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 // Final result // ------------ Vector_divfree resu(*mpaff, *triad, *met_div) ; // Solution for mu // --------------- Scalar mu_resu = mu().poisson() ; Scalar f_r(*mpaff) ; if (cmp[0]->get_etat() == ETATZERO) { // no work needed ... f_r.set_etat_zero() ; resu.set_vr_mu(f_r, mu_resu) ; return resu ; } // Some working objects //--------------------- const Mg3d& mg = *mpaff->get_mg() ; int nz = mg.get_nzone() ; int nzm1 = nz - 1; assert(mg.get_type_r(0) == RARE) ; assert(mg.get_type_r(nzm1) == UNSURR) ; Scalar S_r = *cmp[0] ; Scalar S_eta = eta() ; 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 solution_hom_un(mg, base) ; solution_hom_un.annule_hard() ; Mtbl_cf solution_hom_deux(mg, base) ; solution_hom_deux.annule_hard() ; // Build-up & inversion of the system for (eta, V^r) in each domain //----------------------------------------------------------------- // Nucleus //-------- int nr = mg.get_nr(0) ; int nt = mg.get_nt(0) ; int np = mg.get_np(0) ; double alpha = mpaff->get_alpha()[0] ; double beta = mpaff->get_beta()[0] ; int l_q = 0 ; int m_q = 0; int base_r = 0 ; int nr0 = nr - 1 ; //one degree of freedom less because of division by r^2 // Loop on l and m //---------------- for (int k=0 ; k 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] ; assert (nr > 4) ; nr0 = nr - 2 ; //two degrees of freedom less because of division by r^2 // Loop on l and m //---------------- for (int k=0 ; kget_alpha()[0] ; // value of x^(l-1) at 1 ... systeme.set(ligne, colonne) = 1. ; for (int i=0 ; iget_alpha()[zone] ; double echelle = mpaff->get_beta()[zone]/alpha ; ligne -- ; //value of (x+echelle)^(l-1) at -1 systeme.set(ligne, colonne) = -pow(echelle-1., double(l_q-1)) ; // value of 1/(x+echelle) ^(l+2) at -1 systeme.set(ligne, colonne+1) = -1/pow(echelle-1., double(l_q+2)) ; for (int i=0 ; iget_alpha()[nzm1] ; ligne -- ; //value of (x-1)^(l+2) at -1 : systeme.set(ligne, colonne) = -pow(-2, double(l_q+2)) ; for (int i=0 ; i 2) systeme.set_band(2,2) ; else systeme.set_band(1,1) ; systeme.set_lu() ; Tbl facteurs(systeme.inverse(sec_membre)) ; int conte = 0 ; // everything is put to the right place, the same combination of hom. // solutions (with some l or -(l+1) factors) must be used for V^r //------------------------------------------------------------------- nr = mg.get_nr(0) ; //nucleus for (int i=0 ; i