MFEM  v4.1.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
gslib.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2020, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_GSLIB
13 #define MFEM_GSLIB
14 
15 #include "../config/config.hpp"
16 #include "gridfunc.hpp"
17 
18 #ifdef MFEM_USE_GSLIB
19 
20 struct comm;
21 struct findpts_data_2;
22 struct findpts_data_3;
23 
24 namespace mfem
25 {
26 
28 {
29 protected:
32  struct findpts_data_2 *fdata2D;
33  struct findpts_data_3 *fdata3D;
34  int dim;
35 
36  struct comm *gsl_comm;
37 
38  void GetNodeValues(const GridFunction &gf_in, Vector &node_vals);
39 
40 public:
42 
43 #ifdef MFEM_USE_MPI
44  FindPointsGSLIB(MPI_Comm _comm);
45 #endif
46 
48 
49  /** Initializes the internal mesh in gslib, by sending the positions of the
50  Gauss-Lobatto nodes of the input Mesh object @a m.
51  Note: not tested with periodic (DG meshes).
52  Note: the input mesh @a m must have Nodes set.
53 
54  @param[in] m Input mesh.
55  @param[in] bb_t Relative size of bounding box around each element.
56  @param[in] newt_tol Newton tolerance for the gslib search methods.
57  @param[in] npt_max Number of points for simultaneous iteration. This
58  alters performance and memory footprint. */
59  void Setup(Mesh &m, double bb_t, double newt_tol, int npt_max);
60 
61  /** Searches positions given in physical space by @a point_pos. All output
62  Arrays and Vectors are expected to have the correct size.
63 
64  @param[in] point_pos Positions to be found. Must by ordered by nodes
65  (XXX...,YYY...,ZZZ).
66  @param[out] codes Return codes for each point: inside element (0),
67  element boundary (1), not found (2).
68  @param[out] proc_ids MPI proc ids where the points were found.
69  @param[out] elem_ids Element ids where the points were found.
70  @param[out] ref_pos Reference coordinates of the found point. Ordered
71  by vdim (XYZ,XYZ,XYZ...).
72  Note: the gslib reference frame is [-1,1].
73  @param[out] dist Distance between the seeked and the found point
74  in physical space. */
75  void FindPoints(Vector &point_pos, Array<unsigned int> &codes,
76  Array<unsigned int> &proc_ids, Array<unsigned int> &elem_ids,
77  Vector &ref_pos, Vector &dist);
78 
79  /** Interpolation of field values at prescribed reference space positions.
80 
81  @param[in] codes Return codes for each point: inside element (0),
82  element boundary (1), not found (2).
83  @param[in] proc_ids MPI proc ids where the points were found.
84  @param[in] elem_ids Element ids where the points were found.
85  @param[in] ref_pos Reference coordinates of the found point. Ordered
86  by vdim (XYZ,XYZ,XYZ...).
87  Note: the gslib reference frame is [-1,1].
88  @param[in] field_in Function values that will be interpolated on the
89  reference positions. Note: it is assumed that
90  @a field_in is in H1 and in the same space as the
91  mesh that was given to Setup().
92  @param[out] field_out Interpolated values. */
94  Array<unsigned int> &elem_ids, Vector &ref_pos,
95  const GridFunction &field_in, Vector &field_out);
96 
97  /** Cleans up memory allocated internally by gslib.
98  Note that in parallel, this must be called before MPI_Finalize(), as
99  it calls MPI_Comm_free() for internal gslib communicators. */
100  void FreeData();
101 };
102 
103 } // namespace mfem
104 
105 #endif //MFEM_USE_GSLIB
106 
107 #endif //MFEM_GSLIB guard
void FindPoints(Vector &point_pos, Array< unsigned int > &codes, Array< unsigned int > &proc_ids, Array< unsigned int > &elem_ids, Vector &ref_pos, Vector &dist)
Definition: gslib.cpp:115
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:27
struct findpts_data_3 * fdata3D
Definition: gslib.hpp:33
void Setup(Mesh &m, double bb_t, double newt_tol, int npt_max)
Definition: gslib.cpp:58
void GetNodeValues(const GridFunction &gf_in, Vector &node_vals)
Definition: gslib.cpp:190
void Interpolate(Array< unsigned int > &codes, Array< unsigned int > &proc_ids, Array< unsigned int > &elem_ids, Vector &ref_pos, const GridFunction &field_in, Vector &field_out)
Definition: gslib.cpp:155
struct comm * gsl_comm
Definition: gslib.hpp:36
Vector data type.
Definition: vector.hpp:48
struct findpts_data_2 * fdata2D
Definition: gslib.hpp:32