#ifndef __FVM_NODAL_LOCATE_H__
#define __FVM_NODAL_LOCATE_H__
/*============================================================================
* Locate points in a nodal representation associated with a mesh
*============================================================================*/
/*
This file is part of the "Finite Volume Mesh" library, intended to provide
finite volume mesh and associated fields I/O and manipulation services.
Copyright (C) 2005-2006 EDF
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*----------------------------------------------------------------------------*/
#include <fvm_config.h>
#if defined(FVM_HAVE_MPI)
#include <mpi.h>
#endif
/*----------------------------------------------------------------------------
* Local headers
*----------------------------------------------------------------------------*/
#include <fvm_defs.h>
#include <fvm_nodal.h>
/*----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#if 0
} /* Fake brace to force back Emacs auto-indentation back to column 0 */
#endif
#endif /* __cplusplus */
/*=============================================================================
* Macro definitions
*============================================================================*/
/*============================================================================
* Type definitions
*============================================================================*/
/*----------------------------------------------------------------------------
* Structure defining a locator
*----------------------------------------------------------------------------*/
typedef struct _fvm_locator_t fvm_locator_t;
/*=============================================================================
* Static global variables
*============================================================================*/
/*=============================================================================
* Public function prototypes
*============================================================================*/
/*----------------------------------------------------------------------------
* Creation of a locator structure.
*
* Note that depending on the choice of ranks of the associated communicator,
* distant ranks may in fact be truly distant or not. If n_ranks = 1 and
* start_rank is equal to the current rank in the communicator, the locator
* will work only locally.
*
* parameters:
* tolerance <-- addition to local extents of each element:
* extent = base_extent * (1 + tolerance)
* comm <-- associated MPI communicator
* n_ranks <-- number of MPI ranks associated with distant location
* start_rank <-- first MPI rank associated with distant location
*
* returns:
* pointer to locator
*----------------------------------------------------------------------------*/
#if defined(FVM_HAVE_MPI)
fvm_locator_t *
fvm_locator_create(const double tolerance,
const MPI_Comm comm,
const int n_ranks,
const int start_rank);
#else
fvm_locator_t *
fvm_locator_create(const double tolerance);
#endif
/*----------------------------------------------------------------------------
* Destruction of a locator structure.
*
* parameters:
* this_locator <-- locator to destroy
*
* returns:
* NULL pointer
*----------------------------------------------------------------------------*/
fvm_locator_t *
fvm_locator_destroy(fvm_locator_t * this_locator);
/*----------------------------------------------------------------------------
* Prepare locator for use with a given nodal mesh representation.
*
* parameters:
* this_locator <-> pointer to locator structure
* this_nodal <-- pointer to (containing) mesh representation structure
* dim <-- space dimension of points to locate
* n_points <-- number of points to locate
* point_index <-- optional indirection array to point_coords
* (1 to n_points numbering)
* point_coords <-- coordinates of points to locate
* (dimension: dim * n_points)
*----------------------------------------------------------------------------*/
void
fvm_locator_set_nodal(fvm_locator_t *const this_locator,
const fvm_nodal_t *const this_nodal,
const int dim,
const fvm_lnum_t n_points,
const fvm_lnum_t point_index[],
const fvm_coord_t point_coords[]);
/*----------------------------------------------------------------------------
* Return number of distant points after locator initialization.
*
* parameters:
* this_locator <-- pointer to locator structure
*
* returns:
* number of distant points.
*----------------------------------------------------------------------------*/
fvm_lnum_t
fvm_locator_get_n_dist_points(const fvm_locator_t *const this_locator);
/*----------------------------------------------------------------------------
* Return an array of local element numbers containing (or nearest to)
* each distant point after locator initialization.
*
* parameters:
* this_locator <-- pointer to locator structure
*
* returns:
* local element numbers associated with distant points (1 to n numbering).
*----------------------------------------------------------------------------*/
const fvm_lnum_t *
fvm_locator_get_dist_locations(const fvm_locator_t *const this_locator);
/*----------------------------------------------------------------------------
* Return an array of coordinates of each distant point after
* locator initialization.
*
* parameters:
* this_locator <-- pointer to locator structure
*
* returns:
* coordinate array associated with distant points (interlaced).
*----------------------------------------------------------------------------*/
const fvm_coord_t *
fvm_locator_get_dist_coords(const fvm_locator_t *const this_locator);
/*----------------------------------------------------------------------------
* Return number of points located after locator initialization.
*
* parameters:
* this_locator <-- pointer to locator structure
*
* returns:
* number of points located.
*----------------------------------------------------------------------------*/
fvm_lnum_t
fvm_locator_get_n_interior(const fvm_locator_t *const this_locator);
/*----------------------------------------------------------------------------
* Return list of points not located after locator initialization.
* This list defines a subset of the point set used at initialization.
*
* parameters:
* this_locator <-- pointer to locator structure
*
* returns:
* list of points not located (1 to n numbering).
*----------------------------------------------------------------------------*/
const fvm_lnum_t *
fvm_locator_get_interior_list(const fvm_locator_t *const this_locator);
/*----------------------------------------------------------------------------
* Return number of points not located after locator initialization.
*
* parameters:
* this_locator <-- pointer to locator structure
*
* returns:
* number of points not located.
*----------------------------------------------------------------------------*/
fvm_lnum_t
fvm_locator_get_n_exterior(const fvm_locator_t *const this_locator);
/*----------------------------------------------------------------------------
* Return list of points not located after locator initialization.
* This list defines a subset of the point set used at initialization.
*
* parameters:
* this_locator <-- pointer to locator structure
*
* returns:
* list of points not located (1 to n numbering).
*----------------------------------------------------------------------------*/
const fvm_lnum_t *
fvm_locator_get_exterior_list(const fvm_locator_t *const this_locator);
/*----------------------------------------------------------------------------
* Discard list of points not located after locator initialization.
* This list defines a subset of the point set used at initialization.
*
* parameters:
* this_locator <-- pointer to locator structure
*
* returns:
* list of points not located (1 to n numbering).
*----------------------------------------------------------------------------*/
void
fvm_locator_discard_exterior(fvm_locator_t *const this_locator);
/*----------------------------------------------------------------------------
* Distribute variable defined on distant points to processes owning
* the original points (i.e. distant processes).
*
* The exchange is symmetric if both variables are defined, receive
* only if distant_var is NULL, or send only if local_var is NULL.
*
* parameters:
* this_locator <-- pointer to locator structure
* distant_var <-- variable defined on distant points (ready to send)
* local_var --> variable defined on local points (received)
* type_size <-- sizeof (float or double) variable type
* stride <-- dimension (1 for scalar, 3 for interlaced vector)
*----------------------------------------------------------------------------*/
void
fvm_locator_exchange_point_var(fvm_locator_t *const this_locator,
void *const distant_var,
void *const local_var,
const size_t type_size,
const size_t stride);
/*----------------------------------------------------------------------------
* Dump printout of a locator structure.
*
* parameters:
* this_locator <-- pointer to structure that should be dumped
*----------------------------------------------------------------------------*/
void
fvm_locator_dump(const fvm_locator_t *this_locator);
/*----------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __FVM_NODAL_LOCATE_H__ */
syntax highlighted by Code2HTML, v. 0.9.1