Refine Domain1D grids so that profiles satisfy adaptation tolerances. More...
#include <refine.h>
Refine Domain1D grids so that profiles satisfy adaptation tolerances.
Public Member Functions | |
Refiner (Domain1D &domain) | |
Refiner (const Refiner &)=delete | |
Refiner & | operator= (const Refiner &)=delete |
void | setCriteria (double ratio=10.0, double slope=0.8, double curve=0.8, double prune=-0.1) |
Set grid refinement criteria. | |
vector< double > | getCriteria () |
Get the grid refinement criteria. | |
void | setActive (int comp, bool state=true) |
Set the active state for a component. | |
void | setMaxPoints (int npmax) |
Set the maximum number of points allowed in the domain. | |
size_t | maxPoints () const |
Returns the maximum number of points allowed in the domain. | |
void | setGridMin (double gridmin) |
Set the minimum allowable spacing between adjacent grid points [m]. | |
double | gridMin () const |
Returns the the minimum allowable spacing between adjacent grid points [m]. | |
int | analyze (size_t n, const double *z, const double *x) |
Determine locations in the grid that need additional grid points and update the internal state of the Refiner with this information. | |
int | getNewGrid (int n, const double *z, int nn, double *znew) |
Constructs a new grid based on refinement locations determined by the analyze() method. | |
int | nNewPoints () |
Returns the number of new grid points that were needed. | |
void | show () |
Displays the results of the grid refinement analysis. | |
bool | newPointNeeded (size_t j) |
Returns true if a new grid point is needed to the right of grid index j. | |
bool | keepPoint (size_t j) |
Returns true if the grid point at index j should be kept. | |
double | value (const double *x, size_t n, size_t j) |
Returns the value of the solution component, n, at grid point j. | |
double | maxRatio () |
Returns the maximum allowable ratio of grid spacing between adjacent intervals. | |
double | maxDelta () |
Returns the maximum allowable difference in value between adjacent points. | |
double | maxSlope () |
Returns the maximum allowable difference in the derivative between adjacent points. | |
double | prune () |
Returns the threshold for removing unnecessary grid points. | |
Protected Types | |
enum | GridPointStatus { UNSET = 0 , KEEP = 1 , REMOVE = -1 } |
Protected Attributes | |
set< size_t > | m_insertPts |
Indices of grid points that need new grid points added after them. | |
map< size_t, GridPointStatus > | m_keep |
Status of whether each grid point should be kept or removed. | |
set< string > | m_componentNames |
Names of components that require the addition of new grid points. | |
vector< bool > | m_active |
Flags for whether each component should be considered for grid refinement. | |
double | m_min_range = 0.01 |
Threshold for ignoring small changes around a constant during refinement. | |
Domain1D * | m_domain |
Pointer to the domain to be refined. | |
size_t | m_nv |
Number of components in the domain. | |
size_t | m_npmax = 1000 |
Maximum number of grid points. | |
double | m_thresh = std::sqrt(std::numeric_limits<double>::epsilon()) |
Absolute tolerance threshold for solution components in the domain. | |
double | m_gridmin = 1e-10 |
minimum grid spacing [m] | |
Refinement criteria | |
double | m_ratio = 10.0 |
grid spacing refinement criteria | |
double | m_slope = 0.8 |
function change refinement criteria | |
double | m_curve = 0.8 |
function slope refinement criteria | |
double | m_prune = -0.001 |
pruning refinement criteria | |
Definition at line 14 of file refine.cpp.
void setCriteria | ( | double | ratio = 10.0 , |
double | slope = 0.8 , |
||
double | curve = 0.8 , |
||
double | prune = -0.1 |
||
) |
Set grid refinement criteria.
The ratio parameter is the maximum allowed ratio between grid spacing at adjacent intervals. The ratio parameter considers the situation where the left interval is much larger than the right interval, or if the right interval is much larger than the left interval. See ratio.
The slope parameter is the maximum fractional change in the value of each solution component between adjacent grid points. See slope.
The curve parameter is the maximum fractional change in the derivative of each solution component between adjacent grid points. See curve.
The prune parameter is a threshold for removing unnecessary grid points. See prune.
ratio | Maximum ratio between grid spacing at adjacent intervals. That is, (x[j+1] - x[j]) / (x[j] - x[j-1]) < ratio |
slope | Maximum fractional change in the value of each solution component between adjacent grid points. |
curve | Maximum fractional change in the derivative of each solution component between adjacent grid points. |
prune | Threshold for removing unnecessary grid points. prune should be smaller than both slope and curve . Set prune <= 0 to disable pruning. |
Definition at line 21 of file refine.cpp.
|
inline |
Get the grid refinement criteria.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
int analyze | ( | size_t | n, |
const double * | z, | ||
const double * | x | ||
) |
Determine locations in the grid that need additional grid points and update the internal state of the Refiner with this information.
[in] | n | Number of grid points |
[in] | z | Point to array of grid points |
[in] | x | Pointer to solution vector |
Definition at line 43 of file refine.cpp.
int getNewGrid | ( | int | n, |
const double * | z, | ||
int | nn, | ||
double * | znew | ||
) |
Constructs a new grid based on refinement locations determined by the analyze() method.
This function generates a new grid by inserting additional points into the current grid at locations where the analyze() method has identified a need for refinement. The new grid points are placed midway between existing points deemed necessary for increased resolution. If no refinement is needed, the original grid is copied directly.
[in] | n | The number of points in the original grid array z . |
[in] | z | Pointer to the array of original grid points. |
[in] | nn | The maximum number of points that the new grid array znew can hold. |
[out] | znew | Pointer to the array where the new grid points will be stored. |
Definition at line 238 of file refine.cpp.
|
inline |
void show | ( | ) |
Displays the results of the grid refinement analysis.
This method logs information about where new grid points have been inserted and the components that required these insertions, if any. If no new points were needed, it logs that the current grid is sufficient.
Definition at line 216 of file refine.cpp.
|
inline |
|
inline |
double value | ( | const double * | x, |
size_t | n, | ||
size_t | j | ||
) |
Returns the value of the solution component, n, at grid point j.
x | Solution vector |
n | Solution component index |
j | Grid point index |
Definition at line 211 of file refine.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |