Cantera  3.1.0b1
Loading...
Searching...
No Matches
Refiner Class Reference

Refine Domain1D grids so that profiles satisfy adaptation tolerances. More...

#include <refine.h>

Detailed Description

Refine Domain1D grids so that profiles satisfy adaptation tolerances.

Definition at line 16 of file refine.h.

Public Member Functions

 Refiner (Domain1D &domain)
 
 Refiner (const Refiner &)=delete
 
Refineroperator= (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.
 
Domain1Dm_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
 

Member Enumeration Documentation

◆ GridPointStatus

enum GridPointStatus
protected

Definition at line 200 of file refine.h.

Constructor & Destructor Documentation

◆ Refiner()

Refiner ( Domain1D domain)

Definition at line 14 of file refine.cpp.

◆ ~Refiner()

virtual ~Refiner ( )
inlinevirtual

Definition at line 20 of file refine.h.

Member Function Documentation

◆ setCriteria()

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.

Parameters
ratioMaximum ratio between grid spacing at adjacent intervals. That is, (x[j+1] - x[j]) / (x[j] - x[j-1]) < ratio
slopeMaximum fractional change in the value of each solution component between adjacent grid points.
curveMaximum fractional change in the derivative of each solution component between adjacent grid points.
pruneThreshold 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.

◆ getCriteria()

vector< double > getCriteria ( )
inline

Get the grid refinement criteria.

See also
Refiner::setCriteria

Definition at line 60 of file refine.h.

◆ setActive()

void setActive ( int  comp,
bool  state = true 
)
inline

Set the active state for a component.

Parameters
compComponent index
stateTrue if the component should be considered for grid refinement

Definition at line 71 of file refine.h.

◆ setMaxPoints()

void setMaxPoints ( int  npmax)
inline

Set the maximum number of points allowed in the domain.

Definition at line 76 of file refine.h.

◆ maxPoints()

size_t maxPoints ( ) const
inline

Returns the maximum number of points allowed in the domain.

Definition at line 81 of file refine.h.

◆ setGridMin()

void setGridMin ( double  gridmin)
inline

Set the minimum allowable spacing between adjacent grid points [m].

Definition at line 86 of file refine.h.

◆ gridMin()

double gridMin ( ) const
inline

Returns the the minimum allowable spacing between adjacent grid points [m].

Definition at line 92 of file refine.h.

◆ analyze()

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.

Parameters
[in]nNumber of grid points
[in]zPoint to array of grid points
[in]xPointer to solution vector
Returns
The number of new grid points needed (size of m_insertPts)

Definition at line 43 of file refine.cpp.

◆ getNewGrid()

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.

Parameters
[in]nThe number of points in the original grid array z.
[in]zPointer to the array of original grid points.
[in]nnThe maximum number of points that the new grid array znew can hold.
[out]znewPointer to the array where the new grid points will be stored.
Returns
The function returns 0 upon successful creation of the new grid. Throws an exception if the provided output array size is insufficient to hold the new grid.
Deprecated:
Unused. To be removed after Cantera 3.1.

Definition at line 238 of file refine.cpp.

◆ nNewPoints()

int nNewPoints ( )
inline

Returns the number of new grid points that were needed.

Definition at line 132 of file refine.h.

◆ show()

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.

Note
This method should be called after analyze() to report the outcomes of the refinement analysis.

Definition at line 216 of file refine.cpp.

◆ newPointNeeded()

bool newPointNeeded ( size_t  j)
inline

Returns true if a new grid point is needed to the right of grid index j.

Parameters
jGrid point index

Definition at line 153 of file refine.h.

◆ keepPoint()

bool keepPoint ( size_t  j)
inline

Returns true if the grid point at index j should be kept.

Parameters
jGrid point index

Definition at line 162 of file refine.h.

◆ value()

double value ( const double *  x,
size_t  n,
size_t  j 
)

Returns the value of the solution component, n, at grid point j.

Parameters
xSolution vector
nSolution component index
jGrid point index

Definition at line 211 of file refine.cpp.

◆ maxRatio()

double maxRatio ( )
inline

Returns the maximum allowable ratio of grid spacing between adjacent intervals.

Definition at line 176 of file refine.h.

◆ maxDelta()

double maxDelta ( )
inline

Returns the maximum allowable difference in value between adjacent points.

Definition at line 181 of file refine.h.

◆ maxSlope()

double maxSlope ( )
inline

Returns the maximum allowable difference in the derivative between adjacent points.

Definition at line 186 of file refine.h.

◆ prune()

double prune ( )
inline

Returns the threshold for removing unnecessary grid points.

Definition at line 191 of file refine.h.

Member Data Documentation

◆ m_insertPts

set<size_t> m_insertPts
protected

Indices of grid points that need new grid points added after them.

Definition at line 197 of file refine.h.

◆ m_keep

map<size_t, GridPointStatus> m_keep
protected

Status of whether each grid point should be kept or removed.

Definition at line 207 of file refine.h.

◆ m_componentNames

set<string> m_componentNames
protected

Names of components that require the addition of new grid points.

Definition at line 210 of file refine.h.

◆ m_active

vector<bool> m_active
protected

Flags for whether each component should be considered for grid refinement.

Definition at line 213 of file refine.h.

◆ m_ratio

double m_ratio = 10.0
protected

grid spacing refinement criteria

Definition at line 217 of file refine.h.

◆ m_slope

double m_slope = 0.8
protected

function change refinement criteria

Definition at line 218 of file refine.h.

◆ m_curve

double m_curve = 0.8
protected

function slope refinement criteria

Definition at line 219 of file refine.h.

◆ m_prune

double m_prune = -0.001
protected

pruning refinement criteria

Definition at line 220 of file refine.h.

◆ m_min_range

double m_min_range = 0.01
protected

Threshold for ignoring small changes around a constant during refinement.

Definition at line 224 of file refine.h.

◆ m_domain

Domain1D* m_domain
protected

Pointer to the domain to be refined.

Definition at line 226 of file refine.h.

◆ m_nv

size_t m_nv
protected

Number of components in the domain.

Definition at line 227 of file refine.h.

◆ m_npmax

size_t m_npmax = 1000
protected

Maximum number of grid points.

Definition at line 228 of file refine.h.

◆ m_thresh

double m_thresh = std::sqrt(std::numeric_limits<double>::epsilon())
protected

Absolute tolerance threshold for solution components in the domain.

Definition at line 231 of file refine.h.

◆ m_gridmin

double m_gridmin = 1e-10
protected

minimum grid spacing [m]

Definition at line 232 of file refine.h.


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