LALPulsar  6.1.0.1-89842e6
TwoDMesh.c File Reference

Creates or destroys a hierarchical mesh of templates on an 2-dimensional parameter space. More...

Prototypes

void LALCreateTwoDMesh (LALStatus *stat, TwoDMeshNode **mesh, TwoDMeshParamStruc *params)
 
void LALDestroyTwoDMesh (LALStatus *stat, TwoDMeshNode **mesh, UINT4 *nFree)
 
void LALRefineTwoDMesh (LALStatus *stat, TwoDMeshNode *coarseMesh, TwoDMeshNode *fineMesh)
 

Detailed Description

Creates or destroys a hierarchical mesh of templates on an 2-dimensional parameter space.

Author
Creighton, T. D.

Description

The routine LALCreateTwoDMesh() lays out an unevenly-spaced mesh on a 2-dimensional parameter space, according to the method presented in Header TwoDMesh.h and detailed in TwoDMeshInternal.c. The parameter mesh is a handle to the head of the newly-created linked list of mesh points, while params points to the parameter structure used to create the list. On completion, params->nOut is set to the number of mesh points created.

The routine LALDestroyTwoDMesh() destroys the list pointed to by *mesh, including all sub-meshes, and sets *mesh=NULL. If *mesh is already NULL, nothing is done (this is not an erroneous usage). If nFree \( \neq \) NULL, then *nFree is set to the number of nodes freed.

The routine LALRefineTwoDMesh() creates a heirarchical search mesh by inserting copies of the nodes in the list pointed to by fineMesh into the subMesh fields of appropriate nodes in the list pointed to by coarseMesh. The contents of the fineMesh list are untouched. If a fineMesh tile does not overlap with any cosarseMesh tile, a warning is generated, but this is not treated as an error. If an internal error does occur, the refinement will be left in a state of partial completion; there is just too much overhead involved in maintaining an uncorrupted copy of the coarseMesh list for it to be worthwhile.

Algorithm

LALCreateTwoDMesh() simply creates a dummy node to serve as the head of the linked list, and calls LALTwoDMesh() in TwoDMeshInternal.c to attach a mesh to it. The details of the algorithm are given in TwoDMeshInternal.c.

LALDestroyTwoDMesh() navigates down the linked list of mesh points, destroying them as it goes. It calls itself recursively on any non-empty sub-meshes to destroy them too.

LALRefineTwoDMesh() moves along the fineMesh list; for each node in the list, it searches the coarseMesh list for the any tile that overlaps with the fine mesh tile. It then copies the fine mesh node (and its submesh, if any) into the coarse mesh node's subMesh list, using LALTwoDNodeCopy() in TwoDMeshInternal.c. Although it uses more memory, this recursive copy routine is preferred over simple relinking, so as to avoid any possible memory leaks: destroying the coarse mesh list will leave the fine mesh list intact, and vice-versa.

To create a \( >2 \) ~level hierarchical search mesh, build it from the bottom up: call LALRefineTwoDMesh() to add the finest mesh to the next finest, add that to the next finest, and so on up to the coarsest mesh.

Uses

LALFree()
#define lalDebugLevel
int LALWarning(LALStatus *status, const char *warning)
int LALInfo(LALStatus *status, const char *info)
void LALTwoDMesh(LALStatus *status, TwoDMeshNode **tail, TwoDMeshParamStruc *params)
void LALTwoDNodeCopy(LALStatus *status, TwoDMeshNode **new_, TwoDMeshNode *old)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1

Notes

Definition in file TwoDMesh.c.

Go to the source code of this file.