tslice_check_einstein.C
/*
* Methods of class Time_slice to check Einstein equation solutions.
*
* (see file time_slice.h for documentation).
*
*/
/*
* Copyright (c) 2004 Eric Gourgoulhon, Jose Luis Jaramillo & 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 tslice_check_einstein_C[] = "$Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_check_einstein.C,v 1.10 2014/10/13 08:53:47 j_novak Exp $" ;
/*
* $Id: tslice_check_einstein.C,v 1.10 2014/10/13 08:53:47 j_novak Exp $
* $Log: tslice_check_einstein.C,v $
* Revision 1.10 2014/10/13 08:53:47 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.9 2014/10/06 15:13:22 j_novak
* Modified #include directives to use c++ syntax.
*
* Revision 1.8 2010/10/20 07:58:09 j_novak
* Better implementation of the explicit time-integration. Not fully-tested yet.
*
* Revision 1.7 2007/11/06 12:10:56 j_novak
* Corrected some mistakes.
*
* Revision 1.6 2007/11/06 11:53:34 j_novak
* Use of contravariant version of the 3+1 equations.
*
* Revision 1.5 2007/06/28 14:40:36 j_novak
* Dynamical check: the fields in the last domain are set to zero to avoid dzpuis problems
*
* Revision 1.4 2004/05/12 15:24:20 e_gourgoulhon
* Reorganized the #include 's, taking into account that
* time_slice.h contains now an #include "metric.h".
*
* Revision 1.3 2004/04/07 07:58:21 e_gourgoulhon
* Constructor as Minkowski slice: added call to std_spectral_base()
* after setting the lapse to 1.
*
* Revision 1.2 2004/04/05 12:38:45 j_novak
* Minor modifs to prevent some warnings.
*
* Revision 1.1 2004/04/05 11:54:20 j_novak
* First operational (but not tested!) version of checks of Eintein equations.
*
*
* $Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_check_einstein.C,v 1.10 2014/10/13 08:53:47 j_novak Exp $
*
*/
// C headers
#include <cstdlib>
#include <cassert>
// Lorene headers
#include "time_slice.h"
#include "unites.h"
namespace Lorene {
Tbl Time_slice::check_hamiltonian_constraint(const Scalar* energy_density,
ostream& ost, bool verb) const {
using namespace Unites ;
bool vacuum = ( energy_density == 0x0 ) ;
Scalar field = trk() * trk() - contract( k_uu(), 0, 1, k_dd(), 0, 1 ) ;
field.dec_dzpuis() ; // dzpuis: 4 -> 3
field += gam().ricci_scal() ;
const Scalar* matter ;
if (vacuum)
matter = new Scalar (0*field) ;
else
matter = energy_density ;
if (verb) ost << endl ;
const char* comment = 0x0 ;
if (verb) comment = "Check of the Hamiltonian constraint" ;
Tbl resu = maxabs(field - (4*qpig) * (*matter), comment, ost,verb ) ;
if (verb) ost << endl ;
if (vacuum) delete matter ;
return resu ;
}
Tbl Time_slice::check_momentum_constraint(const Vector* momentum_density,
ostream& ost, bool verb) const {
using namespace Unites ;
bool vacuum = ( momentum_density == 0x0 ) ;
Vector field = k_uu().divergence(gam()) - trk().derive_con(gam()) ;
const Vector* matter ;
if (vacuum)
matter = new Vector (0*field) ;
else {
assert (momentum_density->get_index_type(0) == CON) ;
matter = momentum_density ;
}
if (verb) ost << endl ;
const char* comment = 0x0 ;
if (verb) comment = "Check of the momentum constraint" ;
Tbl resu = maxabs(field - (2*qpig) * (*matter), comment, ost, verb ) ;
if (verb) ost << endl ;
if (vacuum) delete matter ;
return resu ;
}
Tbl Time_slice::check_dynamical_equations(const Sym_tensor* strain_tensor,
const Scalar* energy_density,
ostream& ost, bool verb) const {
using namespace Unites ;
bool vacuum = ( ( strain_tensor == 0x0 ) && ( energy_density == 0x0 ) ) ;
Sym_tensor dyn_lhs = (k_dd_evol.time_derive(jtime, scheme_order)).up_down(gam()) ;
int nz = dyn_lhs.get_mp().get_mg()->get_nzone() ;
dyn_lhs.annule_domain(nz-1) ;
dyn_lhs = dyn_lhs - k_dd().derive_lie(beta()).up_down(gam()) ;
dyn_lhs.annule_domain(nz-1) ;
const Sym_tensor* matter ;
if (vacuum)
matter = new Sym_tensor(0 * dyn_lhs) ;
else {
const Scalar* ener = 0x0 ;
const Sym_tensor* sij = 0x0 ;
bool new_e = false ;
bool new_s = false ;
if (energy_density == 0x0) {
ener = new Scalar ( 0 * nn() ) ;
new_e = true ;
}
else {
ener = energy_density ;
if (strain_tensor == 0x0) {
sij = new Sym_tensor(0 * dyn_lhs) ;
new_s = true ;
}
else
sij = strain_tensor ;
}
matter = new Sym_tensor( (sij->trace(gam()) - *ener)*gam().con()
- 2*(*sij) ) ;
if (new_e) delete ener ;
if (new_s) delete sij ;
}
Sym_tensor dyn_rhs = nn()*( (gam().ricci().up_down(gam()) + trk()*k_uu()
+ qpig * (*matter))) ;
dyn_rhs.annule_domain(nz-1) ;
dyn_rhs = dyn_rhs - 2*nn()*contract(k_uu(), 1, k_dd().up(0, gam()), 1) ;
dyn_rhs.annule_domain(nz-1) ;
dyn_rhs = dyn_rhs - nn().derive_con(gam()).derive_con(gam()) ;
dyn_rhs.annule_domain(nz-1) ;
if (verb) ost << endl ;
const char* comment = 0x0 ;
if (verb) comment = "Check of the dynamical equations" ;
Tbl resu_tmp = maxabs(dyn_lhs - dyn_rhs, comment, ost, verb) ;
if (verb) ost << endl ;
if (vacuum) delete matter ;
Tbl resu(4, 4, resu_tmp.get_dim(0)) ;
resu.annule_hard() ; //## To initialize resu(0,0,...) which
// does not correspond to a valid component
for (int i=1; i<=3; i++) {
for (int j=1; j<=i; j++) {
Itbl idx(2) ;
idx.set(0) = i ;
idx.set(1) = j ;
int pos = dyn_lhs.position(idx) ;
assert (dyn_rhs.position(idx) == pos) ;
for (int lz=0; lz<resu_tmp.get_dim(0); lz++)
resu.set(i,j,lz) = resu_tmp(pos, lz) ;
}
}
return resu ;
}
}
Lorene::Itbl
Basic integer array class.
Definition itbl.h:122
Lorene::Itbl::set
int & set(int i)
Read/write of a particular element (index i ) (1D case).
Definition itbl.h:247
Lorene::Metric::ricci
const Sym_tensor & ricci() const
Returns the Ricci tensor (given by the Connection p_connect ).
Definition metric.C:338
Lorene::Metric::ricci_scal
virtual const Scalar & ricci_scal() const
Returns the Ricci scalar.
Definition metric.C:350
Lorene::Scalar
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:387
Lorene::Scalar::derive_con
const Vector & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of *this with respect to some metric , by raising the index of...
Definition scalar_deriv.C:402
Lorene::Scalar::dec_dzpuis
virtual void dec_dzpuis(int dec=1)
Decreases by dec units the value of dzpuis and changes accordingly the values of the Scalar in the co...
Definition scalar_r_manip.C:418
Lorene::Sym_tensor
Class intended to describe valence-2 symmetric tensors.
Definition sym_tensor.h:223
Lorene::Sym_tensor::derive_lie
Sym_tensor derive_lie(const Vector &v) const
Computes the Lie derivative of this with respect to some vector field v.
Definition sym_tensor.C:360
Lorene::Sym_tensor::divergence
const Vector & divergence(const Metric &) const
Returns the divergence of this with respect to a Metric .
Definition sym_tensor.C:349
Lorene::Tbl
Basic array class.
Definition tbl.h:161
Lorene::Tbl::annule_hard
void annule_hard()
Sets the Tbl to zero in a hard way.
Definition tbl.C:372
Lorene::Tbl::set
double & set(int i)
Read/write of a particular element (index i) (1D case).
Definition tbl.h:281
Lorene::Tbl::get_dim
int get_dim(int i) const
Gives the i-th dimension (ie dim.dim[i]).
Definition tbl.h:403
Lorene::Time_slice::k_dd
virtual const Sym_tensor & k_dd() const
Extrinsic curvature tensor (covariant components ) at the current time step (jtime ).
Definition time_slice_access.C:135
Lorene::Time_slice::jtime
int jtime
Time step index of the latest slice.
Definition time_slice.h:190
Lorene::Time_slice::k_dd_evol
Evolution_std< Sym_tensor > k_dd_evol
Values at successive time steps of the covariant components of the extrinsic curvature tensor .
Definition time_slice.h:208
Lorene::Time_slice::trk
virtual const Scalar & trk() const
Trace K of the extrinsic curvature at the current time step (jtime ).
Definition time_slice_access.C:177
Lorene::Time_slice::nn
virtual const Scalar & nn() const
Lapse function N at the current time step (jtime ).
Definition time_slice_access.C:79
Lorene::Time_slice::check_hamiltonian_constraint
Tbl check_hamiltonian_constraint(const Scalar *energy_density=0x0, ostream &ost=cout, bool verb=true) const
Checks the level at which the hamiltonian constraint is verified.
Definition tslice_check_einstein.C:79
Lorene::Time_slice::scheme_order
int scheme_order
Order of the finite-differences scheme for the computation of time derivatives.
Definition time_slice.h:187
Lorene::Time_slice::beta
virtual const Vector & beta() const
shift vector at the current time step (jtime )
Definition time_slice_access.C:87
Lorene::Time_slice::gam
const Metric & gam() const
Induced metric at the current time step (jtime ).
Definition time_slice_access.C:95
Lorene::Time_slice::k_uu
virtual const Sym_tensor & k_uu() const
Extrinsic curvature tensor (contravariant components ) at the current time step (jtime ).
Definition time_slice_access.C:157
Lorene::Time_slice::check_dynamical_equations
Tbl check_dynamical_equations(const Sym_tensor *strain_tensor=0x0, const Scalar *energy_density=0x0, ostream &ost=cout, bool verb=true) const
Checks the level at which the dynamical equations are verified.
Definition tslice_check_einstein.C:139
Lorene::Time_slice::check_momentum_constraint
Tbl check_momentum_constraint(const Vector *momentum_density=0x0, ostream &ost=cout, bool verb=true) const
Checks the level at which the momentum constraints are verified.
Definition tslice_check_einstein.C:109
Lorene::Vector
Tensor field of valence 1.
Definition vector.h:188
Lorene::Tensor::get_mp
const Map & get_mp() const
Returns the mapping.
Definition tensor.h:861
Lorene::Tensor::get_index_type
int get_index_type(int i) const
Gives the type (covariant or contravariant) of the index number i .
Definition tensor.h:886
Lorene::Tensor::up_down
Tensor up_down(const Metric &gam) const
Computes a new tensor by raising or lowering all the indices of *this .
Definition tensor_calculus.C:305
Lorene::Tensor::derive_con
const Tensor & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of this with respect to some metric , by raising the last inde...
Definition tensor.C:1014
Lorene::Tensor::annule_domain
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
Definition tensor.C:666
Lorene::Tensor_sym::position
virtual int position(const Itbl &ind) const
Returns the position in the array cmp of a component given by its indices.
Definition tensor_sym.C:245
Lorene::Tensor::trace
Tensor trace(int ind1, int ind2) const
Trace on two different type indices.
Definition tensor_calculus.C:94
Lorene::contract
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
Definition tenseur_operateur.C:279
Lorene::maxabs
Tbl maxabs(const Tensor &aa, const char *comment=0x0, ostream &ost=cout, bool verb=true)
Maxima in each domain of the absolute values of the tensor components.
Definition tensor_calculus_ext.C:606
Lorene
Lorene prototypes.
Definition app_hor.h:64
Unites
Standard units of space, time and mass.