FlowSieve  3.0.0
Coarse Graining Routines
Functions
/home/docs/checkouts/readthedocs.org/user_builds/flowsieve/checkouts/read_the_docs_testing/differentiation_tools.hpp File Reference

Collection of all differentiation-related functions. More...

#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include "constants.hpp"
Include dependency graph for differentiation_tools.hpp:

Go to the source code of this file.

Functions

void differentiation_vector (std::vector< double > &diff_array, const double delta, const int index, const int order_of_deriv=1, const int diff_ord=constants::DiffOrd)
 Assign appropriate differentiation vector. More...
 
void non_uniform_diff_vector (std::vector< double > &diff_array, const std::vector< double > &grid, const int Iref, const int LB, const int UB, const int diff_ord=constants::DiffOrd)
 Assign appropriate differentiation vector. More...
 
void spher_derivative_at_point (const std::vector< double *> &deriv_vals, const std::vector< const std::vector< double > *> &fields, const std::vector< double > &grid, const std::string &dim, const int Itime, const int Idepth, const int Ilat, const int Ilon, const int Ntime, const int Ndepth, const int Nlat, const int Nlon, const std::vector< bool > &mask, const int order_of_deriv=1, const int diff_ord=constants::DiffOrd)
 Computes latitudinal derivative at a specific point. More...
 
void Cart_derivatives_at_point (const std::vector< double *> &x_deriv_vals, const std::vector< double *> &y_deriv_vals, const std::vector< double *> &z_deriv_vals, const std::vector< const std::vector< double > *> &fields, const std::vector< double > &latitude, const std::vector< double > &longitude, const int Itime, const int Idepth, const int Ilat, const int Ilon, const int Ntime, const int Ndepth, const int Nlat, const int Nlon, const std::vector< bool > &mask, const int order_of_deriv=1, const int diff_ord=constants::DiffOrd)
 Computes all Cartesian derivative at a specific point. More...
 
void get_diff_vector (std::vector< double > &diff_vector, int &LB_ret, const std::vector< double > &grid, const std::string &dim, const int Itime, const int Idepth, const int Ilat, const int Ilon, const int Ntime, const int Ndepth, const int Nlat, const int Nlon, const std::vector< bool > &mask, const int order_of_deriv, const int diff_ord=constants::DiffOrd)
 Function to return coefficients for differentiation at a target point in space. More...
 

Detailed Description

Collection of all differentiation-related functions.

Function Documentation

◆ Cart_derivatives_at_point()

void Cart_derivatives_at_point ( const std::vector< double *> &  x_deriv_vals,
const std::vector< double *> &  y_deriv_vals,
const std::vector< double *> &  z_deriv_vals,
const std::vector< const std::vector< double > *> &  fields,
const std::vector< double > &  latitude,
const std::vector< double > &  longitude,
const int  Itime,
const int  Idepth,
const int  Ilat,
const int  Ilon,
const int  Ntime,
const int  Ndepth,
const int  Nlat,
const int  Nlon,
const std::vector< bool > &  mask,
const int  order_of_deriv = 1,
const int  diff_ord = constants::DiffOrd 
)

Computes all Cartesian derivative at a specific point.

Computation is done via chain rule on spherical coordinate derivatives. Since both lat- and lon- derivatives are taken, the cost increase to compute all three Cartesian derivatives in comparison to computing a single Cartesian derivative is negligible.

Calls latitude_derivative_at_point() and longitude_derivative_at_point()

Parameters
[in,out]x_deriv_valsvector of pointers to return x-deriv values
[in,out]y_deriv_valsvector of pointers to return y-deriv values
[in,out]z_deriv_valsvector of pointers to return z-deriv values
[in]fieldsvector of pointers to fields to differentiate
[in]latitude(1D) latitude array
[in]longitude(1D) longitude array
[in]Itime,Idepth,Ilat,IlonIndices for the target point in space
[in]Ntime,Ndepth,Nlat,NlonSizes of the dimensions
[in]maskarray to distinguish land/water cells
Here is the call graph for this function:
Here is the caller graph for this function:

◆ differentiation_vector()

void differentiation_vector ( std::vector< double > &  diff_array,
const double  delta,
const int  index,
const int  order_of_deriv = 1,
const int  diff_ord = constants::DiffOrd 
)

Assign appropriate differentiation vector.

This function produces the differentiation vector necessary for computing the value of a derivative at a single point.

This function implicitly assumes a uniform grid.

For first derivatives, can use 2nd, 4th, and 6th order convergence.

For second derivatives, can use 2nd and 4th order convergence

The grid need not be centred (to account for coastlines).

Parameters
[in,out]diff_arrayvector into which to store the differentiation coefficients
[in]deltathe (constant) grid spacing
[in]indexindex for where in the stencil you want the derivative
[in]order_of_derivorder of the derivative (default is first derivative)
[in]diff_ordconvergence order (default is specified in constants.hpp)
Here is the caller graph for this function:

◆ get_diff_vector()

void get_diff_vector ( std::vector< double > &  diff_vector,
int &  LB_ret,
const std::vector< double > &  grid,
const std::string &  dim,
const int  Itime,
const int  Idepth,
const int  Ilat,
const int  Ilon,
const int  Ntime,
const int  Ndepth,
const int  Nlat,
const int  Nlon,
const std::vector< bool > &  mask,
const int  order_of_deriv,
const int  diff_ord = constants::DiffOrd 
)

Function to return coefficients for differentiation at a target point in space.

This is used for the Toroidal projection, which requires building a Laplacian matrix.

Parameters
[in,out]diff_vectorvector into which to store the coefficients
[in,out]LB_retindex of the lower bound of the stencil (returned)
[in]gridgrid on which to differentiate
[in]dimname of the differentiation dimension ("lon", "lat")
[in]Itime,Idepth,Ilat,IlonIndices for the target point in space
[in]Ntime,Ndepth,Nlat,NlonSizes of the dimensions
[in]maskmask to distinguish land/water cells
[in]order_of_derivorder of the derivative
[in]diff_ordconvergence order of the derivative (default from constants.hpp)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ non_uniform_diff_vector()

void non_uniform_diff_vector ( std::vector< double > &  diff_array,
const std::vector< double > &  grid,
const int  Iref,
const int  LB,
const int  UB,
const int  diff_ord = constants::DiffOrd 
)

Assign appropriate differentiation vector.

This function produces the differentiation vector necessary for computing the value of a derivative at a single point.

The grid need not the uniform.

For first derivatives, 2nd order convergence can be used.

Second derivatives not yet implemented.

The grid need not be centred (to account for coastlines).

Parameters
[in,out]diff_arrayvector into which to store the differentiation coefficients
[in]gridvector giving the grid on which the derivative is taken
[in]Irefinteger giving the index for the point at which you want the derivative
[in]LBinteger giving the lower bound for the differentiation stencil
[in]UBinteger giving the upper bound for the differentiation stencil
[in]diff_ordconvergence order (default is specified in constants.hpp)
Here is the caller graph for this function:

◆ spher_derivative_at_point()

void spher_derivative_at_point ( const std::vector< double *> &  deriv_vals,
const std::vector< const std::vector< double > *> &  fields,
const std::vector< double > &  grid,
const std::string &  dim,
const int  Itime,
const int  Idepth,
const int  Ilat,
const int  Ilon,
const int  Ntime,
const int  Ndepth,
const int  Nlat,
const int  Nlon,
const std::vector< bool > &  mask,
const int  order_of_deriv = 1,
const int  diff_ord = constants::DiffOrd 
)

Computes latitudinal derivative at a specific point.

Parameters
[in,out]deriv_valsvector of pointers to return values
[in]fieldsvector of pointers to fields to differentiate
[in]grid(1D) latitude or longitude array
[in]dim"lat" or "lon": dimensional along which to differentate
[in]Itime,Idepth,Ilat,IlonIndices for the target point in space
[in]Ntime,Ndepth,Nlat,NlonSizes of the dimensions
[in]maskarray to distinguish land/water cells
[in]order_of_derivorder of the derivative (1st deriv, 2nd deriv, etc)
[in]diff_ordconvergence order (default is specified in constants.hpp)
Here is the call graph for this function:
Here is the caller graph for this function: