21 #include "../coordinates/coordinates.hpp"
22 #include "../math/core.h"
29 "mass,moment of inertia relative to a thin spherical shell,mean angular "
32 data.NewAthenaArray(3, 1, 1, 1);
33 if (strcmp(COORDINATE_SYSTEM,
"spherical_polar") != 0) {
34 std::stringstream msg;
35 msg <<
"### FATAL ERROR in AngularMomentum::AngularMomentum" << std::endl
36 <<
"Diagnostics 'am' can only be used in spherical_polar geometry."
45 int is = pmb->is, js = pmb->js, ks = pmb->ks;
46 int ie = pmb->ie, je = pmb->je, ke = pmb->ke;
53 Real xmin = pmb->pmy_mesh->mesh_size.x1min;
54 Real xmax = pmb->pmy_mesh->mesh_size.x1max;
55 Real mean_radius = (xmin + xmax) / 2.;
57 for (
int k = ks; k <= ke; ++k)
58 for (
int j = js;
j <= je; ++
j) {
59 pcoord->CellVolume(k,
j, is, ie,
vol_);
60 for (
int i = is; i <= ie; ++i) {
62 mass_moi_am[0] +=
vol_(i) * w(IDN, k,
j, i);
64 mass_moi_am[1] +=
vol_(i) * w(IDN, k,
j, i) *
65 sqr(pcoord->x1v(i) * sin(pcoord->x2v(
j)));
67 mass_moi_am[2] +=
vol_(i) * w(IDN, k,
j, i) * pcoord->x1v(i) *
68 sin(pcoord->x2v(
j)) * w(IV3, k,
j, i);
74 MPI_Allreduce(MPI_IN_PLACE, mass_moi_am, 3, MPI_ATHENA_REAL, MPI_SUM,
77 data(0) = mass_moi_am[0];
79 mass_moi_am[1] / (2. / 3. * mass_moi_am[0] * mean_radius * mean_radius);
80 if (mass_moi_am[1] != 0)
data(2) = mass_moi_am[2] / mass_moi_am[1];
void Finalize(AthenaArray< Real > const &w)
AngularMomentum(MeshBlock *pmb)