![]() |
Bimetric 3+1 toolkit for spherical symmetry
|
Namespaces | |
namespace | fld |
Contains the localized variable names for all known grid functions. | |
Data Structures | |
class | UniformGrid |
Uniform grid of grid functions. More... | |
class | GridUser |
GridUser contains cached variables from the grid-driver. More... | |
class | GridPoint |
A wrapper for a grid point so that the all of the grid functions can be treated as a compound object when reading/writing. More... | |
struct | GF_Descriptor |
Verbose descriptor of a grid function. More... | |
Functions | |
void | GridUser::applyBoundaryConditions (Int m, Int gf, Int parity) |
void | GridUser::smoothenGF2 (Int m, Int outgf, Int tmpgf, Int ingf, Int parity) |
void | GridUser::smoothenGF (Int m, Int outgf, Int tmpgf, Int ingf, Int parity) |
Smooth data using a local polynomial regression. |
void GridUser::applyBoundaryConditions | ( | Int | m, |
Int | gf, | ||
Int | parity | ||
) |
Definition at line 439 of file gridDriver.h.
Smooth data using a local polynomial regression.
The convolution is done with respect to the Savitzky-Golay matrix that corresponds to a smoothing kernel of radius sgRadius
and a polynomial regression of degree polyDeg
.
outf
must not be equal to ingf
outf
is copied to copy2gf
if copy2gf >= 0
Savitzky-Golay smoothing.nb
, which tests the algorithm. Definition at line 466 of file gridDriver.h.
{ // Smoothing parameters: Int sgRadius = 32; // Default kernel radius Int order = 2; // Polynomial order is twice of this Int guard = 3; // guard buffer between NaN and the convolution window // Find the first not-NaN from the left // Int nFrom = nGhost; while( nFrom < nTotal && std::isnan( GF( ingf, m, nFrom ) ) ) { ++nFrom; } // If there were no NaN's, move nFrom as far as possible to the left // if( nFrom == nGhost ) { nFrom = -nLen; } // Find the last not-NaN from the right (do not average with the extrapolated region) // Int nTo = nGhost + nLen; while( nTo >= nGhost && std::isnan( GF( ingf, m, nTo - 1 ) ) ) { --nTo; } OMP_parallel_for( Int n = nFrom < 0 ? 0 : nFrom ; n < nTo; ++n ) { // Find the minimum radius (between 0 and sgRadius) // Int left = n - nFrom; Int right = nTo - guard - 1 - n; Int rad = right < left ? right : left; if ( rad < 0 ) { rad = 0; } else if( rad > sgRadius ) { rad = sgRadius; } // Convolve with the coefficients. // Parity pair on the staggered grid where r(m,nGhost-1) = -r(m,nGhost) reads: // // gf( m, nGhost + k ) == gf( m, nGhost-1 - k ) * parity, where k >= 0 // // Let k = n + i - nGhost; then: // // if( k >= 0 ) // then: use gf( m, nGhost + k ) // else: use gf( m, nGhost-1 - k ) * parity // which is the same as gf( m, nGhost-1 - (n + i - nGhost) ) * parity // or gf( m, 2*nGhost - n - i - 1 ) * parity // Real sum = 0; for( Int i = -rad; i <= rad; ++i ) { sum += SG_coeff[rad][order][ rad + i ] * ( n + i >= nGhost ? GF( ingf, m, n + i ) : parity * GF( ingf, m, 2 * nGhost - n - i - 1 ) ); } GF( outgf, m, n ) = sum; } // Extrapolate to the right // for( Int n = nTo; n < nTotal; ++n ) { extrapolate_lin( outgf, m, n ); } // Optionally copy the output to a new location // if( copy2gf >= 0 ) { OMP_parallel_for( Int n = 0; n < nTotal; ++n ) { GF( copy2gf, m, n ) = GF( outgf, m, n ); } } }
Definition at line 452 of file gridDriver.h.
{ smoothenGF( m, -1, fld::gdbg, ingf, parity ); smoothenGF( m, copy2gf, outgf, fld::gdbg, parity ); }