SpECTRE  v2021.11.01
Events::ObserveNorms< ObservationValueTag, tmpl::list< ObservableTensorTags... >, tmpl::list< NonTensorComputeTags... >, ArraySectionIdTag > Class Template Reference

Compute norms of tensors in the DataBox and write them to disk. More...

#include <ObserveNorms.hpp>

Classes

struct  SubfileName
 The name of the subfile inside the HDF5 file. More...
 
struct  TensorsToObserve
 The tensor to observe and how to do the reduction. More...
 

Public Types

using options = tmpl::list< SubfileName, TensorsToObserve >
 
using observed_reduction_data_tags = observers::make_reduction_data_tags< tmpl::list< ReductionData > >
 
using compute_tags_for_observation_box = tmpl::list< ObservableTensorTags..., NonTensorComputeTags... >
 
using argument_tags = tmpl::list< ObservationValueTag, ::Tags::ObservationBox >
 
using observation_registration_tags = tmpl::list<::Tags::DataBox >
 
using is_ready_argument_tags = tmpl::list<>
 

Public Member Functions

 ObserveNorms (const std::string &subfile_name, const std::vector< ObserveTensor > &observe_tensors)
 
template<typename ComputeTagsList , typename DataBoxType , typename Metavariables , typename ArrayIndex , typename ParallelComponent >
void operator() (const typename ObservationValueTag::type &observation_value, const ObservationBox< ComputeTagsList, DataBoxType > &box, Parallel::GlobalCache< Metavariables > &cache, const ArrayIndex &array_index, const ParallelComponent *const) const
 
template<typename DbTagsList >
std::optional< std::pair< observers::TypeOfObservation, observers::ObservationKey > > get_observation_type_and_key_for_registration (const db::DataBox< DbTagsList > &box) const
 
template<typename Metavariables , typename ArrayIndex , typename Component >
bool is_ready (Parallel::GlobalCache< Metavariables > &, const ArrayIndex &, const Component *const) const
 
bool needs_evolved_variables () const override
 Whether the event uses anything depending on the evolved_variables. If this returns false, anything depending on the evolved variables may have an incorrect value when the event is run. More...
 
void pup (PUP::er &p) override
 
- Public Member Functions inherited from Event
 Event (CkMigrateMessage *msg)
 
 WRAPPED_PUPable_abstract (Event)
 
template<typename ComputeTagsList , typename DataBoxType , typename Metavariables , typename ArrayIndex , typename ComponentPointer >
void run (const ObservationBox< ComputeTagsList, DataBoxType > &box, Parallel::GlobalCache< Metavariables > &cache, const ArrayIndex &array_index, const ComponentPointer) const
 
template<typename DbTags , typename Metavariables , typename ArrayIndex , typename ComponentPointer >
bool is_ready (const db::DataBox< DbTags > &box, Parallel::GlobalCache< Metavariables > &cache, const ArrayIndex &array_index, const ComponentPointer) const
 
virtual bool needs_evolved_variables () const =0
 Whether the event uses anything depending on the evolved_variables. If this returns false, anything depending on the evolved variables may have an incorrect value when the event is run. More...
 

Static Public Attributes

static constexpr Options::String help
 

Detailed Description

template<typename ObservationValueTag, typename... ObservableTensorTags, typename... NonTensorComputeTags, typename ArraySectionIdTag>
class Events::ObserveNorms< ObservationValueTag, tmpl::list< ObservableTensorTags... >, tmpl::list< NonTensorComputeTags... >, ArraySectionIdTag >

Compute norms of tensors in the DataBox and write them to disk.

The L2 norm is computed as the RMS, so

\begin{align*} L_2(u)=\sqrt{\frac{1}{N}\sum_{i=0}^{N} u_i^2} \end{align*}

where \(N\) is the number of grid points.

The norm can be taken for each individual component, or summed over components. For the max/min it is then the max/min over all components, while for the L2 norm we have (for a 3d vector, 2d and 1d are similar)

\begin{align*} L_2(v^k)=\sqrt{\frac{1}{N}\sum_{i=0}^{N} \left[(v^x_i)^2 + (v^y_i)^2 + (v^z_i)^2\right]} \end{align*}

Here is an example of an input file:

R"(
ObserveNorms:
SubfileName: reduction0
TensorsToObserve:
- Name: Var0
NormType: Max
Components: Individual
- Name: Var1
NormType: Min
Components: Individual
- Name: Var0
NormType: Max
Components: Sum
- Name: Var0TimesTwo
NormType: Max
Components: Individual
- Name: Var0TimesThree
NormType: Max
Components: Individual
- Name: Var1
NormType: L2Norm
Components: Sum
- Name: Var1
NormType: L2Norm
Components: Individual
- Name: Var1
NormType: Min
Components: Sum
)");
Note
The NonTensorComputeTags are intended to be used for Variables compute tags like Tags::DerivCompute
Array sections
This event supports sections (see Parallel::Section). Set the ArraySectionIdTag template parameter to split up observations into subsets of elements. The observers::Tags::ObservationKey<ArraySectionIdTag> must be available in the DataBox. It identifies the section and is used as a suffix for the path in the output file.

Member Function Documentation

◆ needs_evolved_variables()

template<typename ObservationValueTag , typename... ObservableTensorTags, typename... NonTensorComputeTags, typename ArraySectionIdTag >
bool Events::ObserveNorms< ObservationValueTag, tmpl::list< ObservableTensorTags... >, tmpl::list< NonTensorComputeTags... >, ArraySectionIdTag >::needs_evolved_variables ( ) const
inlineoverridevirtual

Whether the event uses anything depending on the evolved_variables. If this returns false, anything depending on the evolved variables may have an incorrect value when the event is run.

Implements Event.

Member Data Documentation

◆ help

template<typename ObservationValueTag , typename... ObservableTensorTags, typename... NonTensorComputeTags, typename ArraySectionIdTag >
constexpr Options::String Events::ObserveNorms< ObservationValueTag, tmpl::list< ObservableTensorTags... >, tmpl::list< NonTensorComputeTags... >, ArraySectionIdTag >::help
staticconstexpr
Initial value:
=
"Observe norms of tensors in the DataBox.\n"
"\n"
"Writes reduction quantities:\n"
" * ObservationValueTag (e.g. Time or IterationId)\n"
" * NumberOfPoints = total number of points in the domain\n"
" * Max values\n"
" * Min values\n"
" * L2-norm values\n"

The documentation for this class was generated from the following file: