forked from sxs-collaboration/spectre
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sxs-collaboration#5681 from nikwit/geodesic-accele…
…ration Add geodesic coordinate acceleration function
- Loading branch information
Showing
10 changed files
with
370 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/PointwiseFunctions/GeneralRelativity/GeodesicAcceleration.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#include "PointwiseFunctions/GeneralRelativity/GeodesicAcceleration.hpp" | ||
|
||
#include <cstddef> | ||
|
||
#include "DataStructures/DataVector.hpp" | ||
#include "DataStructures/Tensor/Tensor.hpp" | ||
#include "Utilities/Gsl.hpp" | ||
|
||
namespace gr { | ||
template <typename DataType, size_t Dim> | ||
void geodesic_acceleration( | ||
gsl::not_null<tnsr::I<DataType, Dim>*> acceleration, | ||
const tnsr::I<DataType, Dim>& velocity, | ||
const tnsr::Abb<DataType, Dim>& christoffel_second_kind) { | ||
for (size_t i = 0; i < Dim; ++i) { | ||
acceleration->get(i) = | ||
velocity.get(i) * christoffel_second_kind.get(0, 0, 0) - | ||
christoffel_second_kind.get(i + 1, 0, 0); | ||
for (size_t j = 0; j < Dim; ++j) { | ||
acceleration->get(i) += | ||
2. * velocity.get(j) * | ||
(velocity.get(i) * christoffel_second_kind.get(0, j + 1, 0) - | ||
christoffel_second_kind.get(i + 1, j + 1, 0)); | ||
for (size_t k = 0; k < Dim; ++k) { | ||
acceleration->get(i) += | ||
velocity.get(j) * velocity.get(k) * | ||
(velocity.get(i) * christoffel_second_kind.get(0, j + 1, k + 1) - | ||
christoffel_second_kind.get(i + 1, j + 1, k + 1)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
template <typename DataType, size_t Dim> | ||
tnsr::I<DataType, Dim> geodesic_acceleration( | ||
const tnsr::I<DataType, Dim>& velocity, | ||
const tnsr::Abb<DataType, Dim>& christoffel_second_kind) { | ||
tnsr::I<DataType, Dim> acceleration{get_size(get<0>(velocity))}; | ||
geodesic_acceleration(make_not_null(&acceleration), velocity, | ||
christoffel_second_kind); | ||
return acceleration; | ||
} | ||
|
||
} // namespace gr | ||
template void gr::geodesic_acceleration( | ||
const gsl::not_null<tnsr::I<double, 3>*> acceleration, | ||
const tnsr::I<double, 3>& velocity, | ||
const tnsr::Abb<double, 3>& christoffel_second_kind); | ||
template tnsr::I<double, 3> gr::geodesic_acceleration( | ||
const tnsr::I<double, 3>& velocity, | ||
const tnsr::Abb<double, 3>& christoffel_second_kind); | ||
template void gr::geodesic_acceleration( | ||
const gsl::not_null<tnsr::I<DataVector, 3>*> acceleration, | ||
const tnsr::I<DataVector, 3>& velocity, | ||
const tnsr::Abb<DataVector, 3>& christoffel_second_kind); | ||
template tnsr::I<DataVector, 3> gr::geodesic_acceleration( | ||
const tnsr::I<DataVector, 3>& velocity, | ||
const tnsr::Abb<DataVector, 3>& christoffel_second_kind); |
38 changes: 38 additions & 0 deletions
38
src/PointwiseFunctions/GeneralRelativity/GeodesicAcceleration.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
|
||
#include "DataStructures/Tensor/Tensor.hpp" | ||
#include "Utilities/Gsl.hpp" | ||
|
||
namespace gr { | ||
/// @{ | ||
|
||
/*! | ||
* \brief Computes the coordinate geodesic acceleration in the inertial frame. | ||
* | ||
* \details The geodesic acceleration in coordinate form is given by | ||
* \f{equation} | ||
* \frac{d^2 x^i}{d t^2} = (v^i \Gamma^0_{00} - \Gamma^i_{00} ) + 2 v^j (v^i | ||
* \Gamma^0_{j0} - \Gamma^i_{j0} ) + v^j v^k (v^i \Gamma^0_{jk} - \Gamma^i_{jk} | ||
* ), \f} | ||
* where \f$v^i\f$ is the coordinate velocity, \f$\Gamma^\mu_{\nu \rho}\f$ are | ||
* the spacetime Christoffel symbols of the second kind, and all latin indices | ||
* are spatial. | ||
*/ | ||
template <typename DataType, size_t Dim> | ||
void geodesic_acceleration( | ||
gsl::not_null<tnsr::I<DataType, Dim>*> acceleration, | ||
const tnsr::I<DataType, Dim>& velocity, | ||
const tnsr::Abb<DataType, Dim>& christoffel_second_kind); | ||
|
||
template <typename DataType, size_t Dim> | ||
tnsr::I<DataType, Dim> geodesic_acceleration( | ||
const tnsr::I<DataType, Dim>& velocity, | ||
const tnsr::Abb<DataType, Dim>& christoffel_second_kind); | ||
/// @} | ||
|
||
} // namespace gr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.