SpECTRE Documentation Coverage Report
 Current view: top level - Domain - JacobianDiagnostic.hpp Hit Total Coverage Commit: 9f349d3c09e1c03107f00c2135ca40e209d3b84c Lines: 5 11 45.5 % Date: 2023-06-09 21:05:06 Legend: Lines: hit not hit
  Line data Source code  1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include 7 : #include 8 : 9 : #include "DataStructures/Tensor/TypeAliases.hpp" 10 : #include "Domain/Tags.hpp" 11 : #include "NumericalAlgorithms/Spectral/Mesh.hpp" 12 : #include "Utilities/Gsl.hpp" 13 : #include "Utilities/TMPL.hpp" 14 : 15 : /// \cond 16 : class DataVector; 17 : /// \endcond 18 : 19 : namespace domain { 20 : /*! 21 : * \ingroup ComputationalDomainGroup 22 : * \brief A diagnostic comparing the analytic and numerical Jacobians for a 23 : * map. 24 : * 25 : * Specifically, returns 26 : * \f[ 27 : * C_{\hat{i}} = 1 - 28 : * \frac{\sum_i |\partial_{\hat{i}} x^i|}{\sum_i |D_{\hat{i}} x^i|} 29 : * \f], where \f$x^{\hat{i}}\f$ are the logical 30 : * coordinates, \f$x^i\f$ are the coordinates in the target frame, 31 : * \f$\partial_{\hat{i}}x^i\f$ is the analytic Jacobian, and \f$D_{\hat{i}} 32 : * x^i\f$ is the numerical Jacobian. 33 : * 34 : * \note This function accepts the transpose of the numeric Jacobian as a 35 : * parameter, since the numeric Jacobian will typically be computed via 36 : * logical_partial_derivative(), which prepends the logical (source frame) 37 : * derivative index. Tensors of type Jacobian, in contrast, have the derivative 38 : * index second. 39 : */ 40 : template 41 1 : void jacobian_diagnostic( 42 : const gsl::not_null< 43 : tnsr::i*> 44 : jacobian_diag, 45 : const Jacobian& 46 : analytic_jacobian, 47 : const TensorMetafunctions::prepend_spatial_index< 48 : tnsr::I, Dim, UpLo::Lo, 49 : typename Frame::ElementLogical>& numeric_jacobian_transpose); 50 : 51 : /// @{ 52 : /*! 53 : * \ingroup ComputationalDomainGroup 54 : * \brief A diagnostic comparing the analytic and numerical Jacobians for a 55 : * map. 56 : * 57 : * Specifically, returns 58 : * \f[ 59 : * C_{\hat{i}} = 1 - 60 : * \frac{\sum_i |\partial_{\hat{i}} x^i|}{\sum_i |D_{\hat{i}} x^i|} 61 : * \f], 62 : * where \f$x^{\hat{i}}\f$ are the logical coordinates, \f$x^i\f$ are the 63 : * coordinates in the target frame, \f$\partial_{\hat{i}}x^i\f$ is the analytic 64 : * Jacobian, and \f$D_{\hat{i}} x^i\f$ is the numerical Jacobian. 65 : * 66 : * \note This function accepts the analytic jacobian, mapped coordinates, and 67 : * mesh as a parameter. The numeric jacobian is computed 68 : * internally by differentiating the mapped coordinates with respect to the 69 : * logical coordinates. 70 : */ 71 : template 72 1 : void jacobian_diagnostic( 73 : const gsl::not_null*> 74 : jacobian_diag, 75 : const ::Jacobian& 76 : analytic_jacobian, 77 : const tnsr::I& mapped_coords, const ::Mesh& mesh); 78 : 79 : template 80 1 : tnsr::i jacobian_diagnostic( 81 : const ::Jacobian& 82 : analytic_jacobian, 83 : const tnsr::I& mapped_coords, const ::Mesh& mesh); 84 : /// @} 85 : 86 : namespace Tags { 87 : /// \ingroup DataBoxTagsGroup 88 : /// \ingroup ComputationalDomainGroup 89 : /// \brief A diagnostic comparing the analytic and numerical Jacobians for a 90 : /// map. See domain::jacobian_diagnostic for details. 91 : template 92 1 : struct JacobianDiagnostic : db::SimpleTag { 93 0 : using type = tnsr::i; 94 : }; 95 : 96 : /// \ingroup DataBoxTagsGroup 97 : /// \ingroup ComputationalDomainGroup 98 : /// \brief Computes the Jacobian diagnostic, which compares the analytic 99 : /// Jacobian (provided by some coordinate map) to a numerical Jacobian computed 100 : /// using numerical partial derivatives. The coordinates must be in the target 101 : /// frame of the map. See domain::jacobian_diagnostic for details of the 102 : /// calculation. 103 : template 104 1 : struct JacobianDiagnosticCompute : JacobianDiagnostic, db::ComputeTag { 105 0 : using base = JacobianDiagnostic; 106 0 : using return_type = typename base::type; 107 0 : using argument_tags = tmpl::list< 108 : ::domain::Tags::Jacobian, 109 : ::domain::Tags::Coordinates, Mesh>; 110 0 : static constexpr auto function = static_cast*>, 113 : const ::Jacobian&, 114 : const tnsr::I&, const ::Mesh&)>( 115 : &::domain::jacobian_diagnostic); 116 : }; 117 : } // namespace Tags 118 : } // namespace domain 

 Generated by: LCOV version 1.14