Peano 4
Loading...
Searching...
No Matches
applications::exahype2::swe::parser::AdjointParser Class Reference

#include <AdjointParser.h>

Public Member Functions

 AdjointParser (const char *adjoint_file_path, double start_time=INFINITY)
 
 ~AdjointParser ()
 
double max_inner_product (double i_t, double i_x, double i_y, const double *Q)
 Calculates the maximum inner product of adjoint and current simulation.
 

Private Member Functions

void interpolate_values (size_t i_index, double i_x, double i_y, double *interpolated_values)
 Interpolates spatial indices to fit adjoint solution and returns adjoint solution values at these indices.
 
double calculate_inner_product (size_t i_index, double i_x, double i_y, const double *Q)
 Calculates the inner product of adjoint and current simulation at given timestamp index.
 
void parse_adjoint_file (const char *adjoint_file_path, double start_time=INFINITY)
 Parses given netCDF file of adjoint simulation and reads out all necessary values.
 
void set_start_index (double i_t)
 Call this once every time step to set start index for inner product calculation.
 

Private Attributes

double * adjoint_h_ = nullptr
 
double * adjoint_hu_ = nullptr
 
double * adjoint_hv_ = nullptr
 
double * adjoint_b_ = nullptr
 
double * adjoint_timestamps_ = nullptr
 
size_t number_timestamps_ = 0
 
size_t size_x_adjoint_ = 0
 
size_t size_y_adjoint_ = 0
 
double max_x_adjoint_ = -1
 
double max_y_adjoint_ = -1
 
double min_x_adjoint_ = 1
 
double min_y_adjoint_ = 1
 
double t_f_ = -1
 
double t_s_ = -1
 
size_t inner_product_start_index_ = 1
 
double t_last_call_ = -1.0
 

Detailed Description

Definition at line 10 of file AdjointParser.h.

Constructor & Destructor Documentation

◆ AdjointParser()

applications::exahype2::swe::parser::AdjointParser::AdjointParser ( const char * adjoint_file_path,
double start_time = INFINITY )

Definition at line 8 of file AdjointParser.cpp.

References parse_adjoint_file().

Here is the call graph for this function:

◆ ~AdjointParser()

applications::exahype2::swe::parser::AdjointParser::~AdjointParser ( )

Definition at line 13 of file AdjointParser.cpp.

Member Function Documentation

◆ calculate_inner_product()

double applications::exahype2::swe::parser::AdjointParser::calculate_inner_product ( size_t i_index,
double i_x,
double i_y,
const double * Q )
private

Calculates the inner product of adjoint and current simulation at given timestamp index.

Parameters
i_indexindex of timestamp that poses as upper limit for current simulation time for interpolation
i_xcoordinate of x-dimension of simulation for which the inner product is to be calculated
i_ycoordinate of y-dimension of simulation for which the inner product is to be calculated
Qstate vector of current cell
Returns
double inner product of current cell and adjoint solution for specific interpolated timestamp

Definition at line 35 of file AdjointParser.cpp.

References tarch::la::equals().

Here is the call graph for this function:

◆ interpolate_values()

void applications::exahype2::swe::parser::AdjointParser::interpolate_values ( size_t i_index,
double i_x,
double i_y,
double * interpolated_values )
private

Interpolates spatial indices to fit adjoint solution and returns adjoint solution values at these indices.

Parameters
i_indexindex of timestamp of adjoint solution for which the inner product is to be calculated
i_xcoordinate of x-dimension of simulation which is being interpolated
i_ycoordinate of y-dimension of simulation which is being interpolated
interpolated_valuesarray to be filled with adjoint solution values in the order (h, hu, hv, b)

Definition at line 21 of file AdjointParser.cpp.

References tarch::la::greater(), tarch::la::smaller(), applications::exahype2::swe::parser::NetCDFHelper::transformIndexCDFRangeToArray(), and applications::exahype2::swe::parser::NetCDFHelper::transformIndexSimulationToCDFRange().

Here is the call graph for this function:

◆ max_inner_product()

double applications::exahype2::swe::parser::AdjointParser::max_inner_product ( double i_t,
double i_x,
double i_y,
const double * Q )

Calculates the maximum inner product of adjoint and current simulation.

Use this function for guided adaptive mesh refinement as detailed in https://doi.org/10.1007/s00024-016-1412-y

Parameters
i_tcurrent simulation time
i_xcoordinate of x-dimension of simulation for which the maximum inner product is to be calculated
i_ycoordinate of y-dimension of simulation for which the maximum inner product is to be calculated
Qstate vector of current cell
Returns
double maximum inner product of current cell and interpolated adjoint solution

Definition at line 61 of file AdjointParser.cpp.

References tarch::la::equals(), tarch::la::smaller(), and tarch::la::smallerEquals().

Here is the call graph for this function:

◆ parse_adjoint_file()

void applications::exahype2::swe::parser::AdjointParser::parse_adjoint_file ( const char * adjoint_file_path,
double start_time = INFINITY )
private

Parses given netCDF file of adjoint simulation and reads out all necessary values.

Parameters
adjoint_file_pathpath to pre-computed adjoint solution netCDF file
start_timestart time for temporal area of interest. Default (=INFINITY) is to read from file.

Definition at line 104 of file AdjointParser.cpp.

References applications::exahype2::swe::parser::NetCDFReader::closeCdf(), applications::exahype2::swe::parser::NetCDFReader::getDimension(), applications::exahype2::swe::parser::NetCDFReader::getGlobalAttDouble(), applications::exahype2::swe::parser::NetCDFReader::openCdf(), applications::exahype2::swe::parser::NetCDFReader::readVariable1D(), applications::exahype2::swe::parser::NetCDFReader::readVariable2D(), and applications::exahype2::swe::parser::NetCDFReader::readVariable3DHyperslab().

Referenced by AdjointParser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_start_index()

void applications::exahype2::swe::parser::AdjointParser::set_start_index ( double i_t)
private

Call this once every time step to set start index for inner product calculation.

Parameters
i_tcurrent time of forward simulation

Definition at line 91 of file AdjointParser.cpp.

References tarch::la::greater(), and tarch::la::smallerEquals().

Here is the call graph for this function:

Field Documentation

◆ adjoint_b_

double* applications::exahype2::swe::parser::AdjointParser::adjoint_b_ = nullptr
private

Definition at line 15 of file AdjointParser.h.

◆ adjoint_h_

double* applications::exahype2::swe::parser::AdjointParser::adjoint_h_ = nullptr
private

Definition at line 12 of file AdjointParser.h.

◆ adjoint_hu_

double* applications::exahype2::swe::parser::AdjointParser::adjoint_hu_ = nullptr
private

Definition at line 13 of file AdjointParser.h.

◆ adjoint_hv_

double* applications::exahype2::swe::parser::AdjointParser::adjoint_hv_ = nullptr
private

Definition at line 14 of file AdjointParser.h.

◆ adjoint_timestamps_

double* applications::exahype2::swe::parser::AdjointParser::adjoint_timestamps_ = nullptr
private

Definition at line 16 of file AdjointParser.h.

◆ inner_product_start_index_

size_t applications::exahype2::swe::parser::AdjointParser::inner_product_start_index_ = 1
private

Definition at line 31 of file AdjointParser.h.

◆ max_x_adjoint_

double applications::exahype2::swe::parser::AdjointParser::max_x_adjoint_ = -1
private

Definition at line 23 of file AdjointParser.h.

◆ max_y_adjoint_

double applications::exahype2::swe::parser::AdjointParser::max_y_adjoint_ = -1
private

Definition at line 24 of file AdjointParser.h.

◆ min_x_adjoint_

double applications::exahype2::swe::parser::AdjointParser::min_x_adjoint_ = 1
private

Definition at line 25 of file AdjointParser.h.

◆ min_y_adjoint_

double applications::exahype2::swe::parser::AdjointParser::min_y_adjoint_ = 1
private

Definition at line 26 of file AdjointParser.h.

◆ number_timestamps_

size_t applications::exahype2::swe::parser::AdjointParser::number_timestamps_ = 0
private

Definition at line 18 of file AdjointParser.h.

◆ size_x_adjoint_

size_t applications::exahype2::swe::parser::AdjointParser::size_x_adjoint_ = 0
private

Definition at line 20 of file AdjointParser.h.

◆ size_y_adjoint_

size_t applications::exahype2::swe::parser::AdjointParser::size_y_adjoint_ = 0
private

Definition at line 21 of file AdjointParser.h.

◆ t_f_

double applications::exahype2::swe::parser::AdjointParser::t_f_ = -1
private

Definition at line 28 of file AdjointParser.h.

◆ t_last_call_

double applications::exahype2::swe::parser::AdjointParser::t_last_call_ = -1.0
private

Definition at line 32 of file AdjointParser.h.

◆ t_s_

double applications::exahype2::swe::parser::AdjointParser::t_s_ = -1
private

Definition at line 29 of file AdjointParser.h.


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