17 #ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
18 #pragma GCC diagnostic push
19 #pragma GCC diagnostic ignored "-Wunused-function"
28 #ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
29 #pragma GCC diagnostic pop
36 : mesh(NULL), meshsplit(NULL), ir_simplex(NULL),
37 fdata2D(NULL), fdata3D(NULL), cr(NULL), gsl_comm(NULL),
38 dim(-1), points_cnt(0), setupflag(false), default_interp_value(0),
42 cr =
new gslib::crystal;
45 MPI_Initialized(&initialized);
46 if (!initialized) { MPI_Init(NULL, NULL); }
47 MPI_Comm comm = MPI_COMM_WORLD;
64 : mesh(NULL), meshsplit(NULL), ir_simplex(NULL),
65 fdata2D(NULL), fdata3D(NULL), cr(NULL), gsl_comm(NULL),
66 dim(-1), points_cnt(0), setupflag(false), default_interp_value(0),
70 cr =
new gslib::crystal;
78 MFEM_VERIFY(m.
GetNodes() != NULL,
"Mesh nodes are required.");
80 "Mixed meshes are not currently supported in FindPointsGSLIB.");
103 MFEM_ABORT(
"Element type not currently supported in FindPointsGSLIB.");
107 NEtot = pts_cnt/(int)pow(dof1D,
dim);
111 unsigned nr[2] = { dof1D, dof1D };
112 unsigned mr[2] = { 2*dof1D, 2*dof1D };
115 pts_cnt, pts_cnt, npt_max, newt_tol);
119 unsigned nr[3] = { dof1D, dof1D, dof1D };
120 unsigned mr[3] = { 2*dof1D, 2*dof1D, 2*dof1D };
121 double *
const elx[3] =
124 pts_cnt, pts_cnt, npt_max, newt_tol);
131 MFEM_VERIFY(
setupflag,
"Use FindPointsGSLIB::Setup before finding points.");
141 const double *xv_base[2];
142 xv_base[0] = point_pos.
GetData();
144 unsigned xv_stride[2];
145 xv_stride[0] =
sizeof(double);
146 xv_stride[1] =
sizeof(double);
156 const double *xv_base[3];
157 xv_base[0] = point_pos.
GetData();
160 unsigned xv_stride[3];
161 xv_stride[0] =
sizeof(double);
162 xv_stride[1] =
sizeof(double);
163 xv_stride[2] =
sizeof(double);
178 for (
int d = 0; d <
dim; d++) {
gsl_ref(i*dim + d) = -1.; }
188 const double bb_t,
const double newt_tol,
193 Setup(m, bb_t, newt_tol, npt_max);
236 MFEM_ASSERT(gf_in.
FESpace()->
GetVDim() == 1,
"Scalar function expected.");
249 node_vals.
SetSize(NE * dof_cnt);
253 MFEM_VERIFY(tbe != NULL,
"TensorBasis FiniteElement expected.");
258 for (
int i = 0; i < NE; i++)
261 for (
int j = 0; j < dof_cnt; j++)
263 node_vals(pt_id++) = vals_el(dof_map[j]);
271 node_vals.
SetSize(NE * dof_cnt);
275 for (
int j = 0; j < NE; j++)
278 for (
int i = 0; i < dof_cnt; i++)
280 node_vals(pt_id++) = vals_el(i);
286 MFEM_ABORT(
"Element type not currently supported.");
297 pts_cnt = NE * dof_cnt;
302 MFEM_VERIFY(tbe != NULL,
"TensorBasis FiniteElement expected.");
305 if (dm.
Size() > 0) { dof_map = dm; }
306 else {
for (
int i = 0; i < dof_cnt; i++) { dof_map[i] = i; } }
313 for (
int i = 0; i < NE; i++)
317 for (
int j = 0; j < dof_cnt; j++)
319 for (
int d = 0; d <
dim; d++)
321 gsl_mesh(pts_cnt * d + pt_id) = pos(dof_map[j], d);
343 const double quad_v[7][2] =
345 {0, 0}, {0.5, 0}, {1, 0}, {0, 0.5},
346 {1./3., 1./3.}, {0.5, 0.5}, {0, 1}
348 const int quad_e[3][4] =
350 {3, 4, 1, 0}, {4, 5, 2, 1}, {6, 5, 4, 3}
353 for (
int j = 0; j < Nvert; j++)
357 for (
int j = 0; j < NEsplit; j++)
359 int attribute = j + 1;
370 const double hex_v[15][3] =
372 {0, 0, 0.}, {1, 0., 0.}, {0., 1., 0.}, {0, 0., 1.},
373 {0.5, 0., 0.}, {0.5, 0.5, 0.}, {0., 0.5, 0.},
374 {0., 0., 0.5}, {0.5, 0., 0.5}, {0., 0.5, 0.5},
375 {1./3., 0., 1./3.}, {1./3., 1./3., 1./3.}, {0, 1./3., 1./3.},
376 {1./3., 1./3., 0}, {0.25, 0.25, 0.25}
378 const int hex_e[4][8] =
380 {0, 4, 10, 7, 6, 13, 14, 12},
381 {4, 1, 8, 10, 13, 5, 11, 14},
382 {13, 5, 11, 14, 6, 2, 9, 12},
383 {10, 8, 3, 7, 14, 11, 9, 12}
386 for (
int j = 0; j < Nvert; j++)
390 for (
int j = 0; j < NEsplit; j++)
392 int attribute = j + 1;
403 const double hex_v[14][3] =
405 {0, 0, 0}, {0.5, 0, 0}, {1, 0, 0}, {0, 0.5, 0},
406 {1./3., 1./3., 0}, {0.5, 0.5, 0}, {0, 1, 0},
407 {0, 0, 1}, {0.5, 0, 1}, {1, 0, 1}, {0, 0.5, 1},
408 {1./3., 1./3., 1}, {0.5, 0.5, 1}, {0, 1, 1}
410 const int hex_e[3][8] =
412 {3, 4, 1, 0, 10, 11, 8, 7},
413 {4, 5, 2, 1, 11, 12, 9, 8},
414 {6, 5, 4, 3, 13, 12, 11, 10}
417 for (
int j = 0; j < Nvert; j++)
421 for (
int j = 0; j < NEsplit; j++)
423 int attribute = j + 1;
428 else { MFEM_ABORT(
"Unsupported geometry type."); }
435 const int dof_cnt = nodal_fes.GetFE(0)->GetDof(),
436 pts_cnt = NEsplit * dof_cnt;
441 MFEM_VERIFY(tbe != NULL,
"TensorBasis FiniteElement expected.");
452 for (
int i = 0; i < NEsplit; i++)
454 nodal_fes.GetElementVDofs(i, xdofs);
456 for (
int j = 0; j < dof_cnt; j++)
458 for (
int d = 0; d <
dim; d++)
460 irlist(pts_cnt * d + pt_id) = pos(dof_map[j], d);
475 const int tot_pts_cnt = pts_cnt*NE;
477 for (
int j = 0; j < NE; j++)
479 for (
int i = 0; i < dof_cnt*NEsplit; i++)
483 for (
int d = 0; d <
dim; d++)
485 gsl_mesh(tot_pts_cnt*d + pt_id) = locval(d);
510 const double quad_v[7][2] =
512 {0, 0}, {0.5, 0}, {1, 0}, {0, 0.5},
513 {1./3., 1./3.}, {0.5, 0.5}, {0, 1}
515 for (
int k = 0; k <
dim; k++)
517 for (
int j = 0; j < gf_lin.
Size()/
dim; j++)
519 gf_lin(j+k*gf_lin.
Size()/
dim) = quad_v[j][k];
526 const double hex_v[15][3] =
528 {0, 0, 0.}, {1, 0., 0.}, {0., 1., 0.}, {0, 0., 1.},
529 {0.5, 0., 0.}, {0.5, 0.5, 0.}, {0., 0.5, 0.},
530 {0., 0., 0.5}, {0.5, 0., 0.5}, {0., 0.5, 0.5},
531 {1./3., 0., 1./3.}, {1./3., 1./3., 1./3.}, {0, 1./3., 1./3.},
532 {1./3., 1./3., 0}, {0.25, 0.25, 0.25}
534 for (
int k = 0; k <
dim; k++)
536 for (
int j = 0; j < gf_lin.
Size()/
dim; j++)
538 gf_lin(j+k*gf_lin.
Size()/
dim) = hex_v[j][k];
545 const double hex_v[14][3] =
547 {0, 0, 0}, {0.5, 0, 0}, {1, 0, 0}, {0, 0.5, 0},
548 {1./3., 1./3., 0}, {0.5, 0.5, 0}, {0, 1, 0},
549 {0, 0, 1}, {0.5, 0, 1}, {1, 0, 1}, {0, 0.5, 1},
550 {1./3., 1./3., 1}, {0.5, 0.5, 1}, {0, 1, 1}
552 for (
int k = 0; k <
dim; k++)
554 for (
int j = 0; j < gf_lin.
Size()/
dim; j++)
556 gf_lin(j+k*gf_lin.
Size()/
dim) = hex_v[j][k];
563 MFEM_ABORT(
"Element type not currently supported.");
571 int local_elem =
gsl_elem[i]%NEsplit;
576 ip.
Set2(mfem_ref.GetData());
577 if (dim == 3) { ip.
z = mfem_ref(2); }
592 if (fec_h1 && gf_order == mesh_order &&
613 if (indl2.
Size() == 0) {
return; }
617 int gf_order_h1 = std::max(gf_order, 1);
623 if (
avgtype == AvgType::ARITHMETIC)
627 else if (
avgtype == AvgType::HARMONIC)
633 MFEM_ABORT(
"Invalid averaging type.");
636 if (gf_order_h1 == mesh_order)
646 for (
int j = 0; j < ncomp; j++)
648 for (
int i = 0; i < indl2.
Size(); i++)
651 field_out(idx) = field_out_l2(idx);
665 points_fld = field_in.
Size() / ncomp,
668 field_out.
SetSize(points_cnt*ncomp);
671 for (
int i = 0; i < ncomp; i++)
673 const int dataptrin = i*points_fld,
675 field_in_scalar.NewDataAndSize(field_in.
GetData()+dataptrin, points_fld);
680 findpts_eval_2(field_out.
GetData()+dataptrout,
sizeof(double),
689 findpts_eval_3(field_out.
GetData()+dataptrout,
sizeof(double),
719 for (
int i = 0; i < ncomp; i++)
721 field_out(index + i*npt) = localval(i);
735 struct gslib::array *outpt =
new gslib::array;
736 struct out_pt {
double r[3], ival;
uint index, el, proc; };
738 array_init(
struct out_pt, outpt, nptsend);
740 pt = (
struct out_pt *)outpt->ptr;
752 sarray_transfer(
struct out_pt, outpt, proc, 1,
cr);
758 pt = (
struct out_pt *)outpt->ptr;
763 pt->ival = field_in.
GetValue(pt->el, ip, 1);
768 sarray_transfer(
struct out_pt, outpt, proc, 1,
cr);
770 pt = (
struct out_pt *)outpt->ptr;
773 field_out(pt->index) = pt->ival;
783 pt = (
struct out_pt *)outpt->ptr;
784 Vector vec_int_vals(npt*ncomp);
789 Vector localval(vec_int_vals.GetData()+
index*ncomp, ncomp);
795 struct gslib::array *savpt =
new gslib::array;
798 array_init(
struct sav_pt, savpt, npt);
800 spt = (
struct sav_pt *)savpt->ptr;
801 pt = (
struct out_pt *)outpt->ptr;
804 spt->index = pt->index;
805 spt->proc = pt->proc;
813 struct gslib::array *sendpt =
new gslib::array;
814 struct send_pt {
double ival;
uint index, proc; };
815 struct send_pt *sdpt;
816 for (
int j = 0; j < ncomp; j++)
818 array_init(
struct send_pt, sendpt, npt);
820 spt = (
struct sav_pt *)savpt->ptr;
821 sdpt = (
struct send_pt *)sendpt->ptr;
824 sdpt->index = spt->index;
825 sdpt->proc = spt->proc;
826 sdpt->ival = vec_int_vals(j +
index*ncomp);
830 sarray_transfer(
struct send_pt, sendpt, proc, 1,
cr);
831 sdpt = (
struct send_pt *)sendpt->ptr;
834 int idx = sdpt->index + j*nptorig;
835 field_out(idx) = sdpt->ival;
849 const double bb_t,
const double newt_tol,
852 MFEM_VERIFY(m.
GetNodes() != NULL,
"Mesh nodes are required.");
854 "Mixed meshes are not currently supported in FindPointsGSLIB.");
863 unsigned dof1D = fe->
GetOrder() + 1;
877 MFEM_ABORT(
"Element type not currently supported in FindPointsGSLIB.");
880 MFEM_ASSERT(meshid>=0,
" The ID should be greater than or equal to 0.");
883 NEtot = pts_cnt/(int)pow(dof1D,
dim);
898 unsigned nr[2] = { dof1D, dof1D };
899 unsigned mr[2] = { 2*dof1D, 2*dof1D };
902 pts_cnt, pts_cnt, npt_max, newt_tol,
907 unsigned nr[3] = { dof1D, dof1D, dof1D };
908 unsigned mr[3] = { 2*dof1D, 2*dof1D, 2*dof1D };
909 double *
const elx[3] =
912 pts_cnt, pts_cnt, npt_max, newt_tol,
922 MFEM_VERIFY(
setupflag,
"Use OversetFindPointsGSLIB::Setup before "
924 MFEM_VERIFY(
overset,
" Please setup FindPoints for overlapping grids.");
926 unsigned int match = 0;
936 const double *xv_base[2];
937 xv_base[0] = point_pos.
GetData();
939 unsigned xv_stride[2];
940 xv_stride[0] =
sizeof(double);
941 xv_stride[1] =
sizeof(double);
948 point_id.
GetData(),
sizeof(
unsigned int), &match,
953 const double *xv_base[3];
954 xv_base[0] = point_pos.
GetData();
957 unsigned xv_stride[3];
958 xv_stride[0] =
sizeof(double);
959 xv_stride[1] =
sizeof(double);
960 xv_stride[2] =
sizeof(double);
967 point_id.
GetData(),
sizeof(
unsigned int), &match,
977 for (
int d = 0; d <
dim; d++) {
gsl_ref(i*dim + d) = -1.; }
998 #endif // MFEM_USE_GSLIB
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for all finite elements.
virtual void Interpolate(const GridFunction &field_in, Vector &field_out)
int Size() const
Return the logical size of the array.
Array< unsigned int > gsl_elem
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
int AddQuad(int v1, int v2, int v3, int v4, int attr=1)
virtual ~FindPointsGSLIB()
virtual void GetVectorValue(int i, const IntegrationPoint &ip, Vector &val) const
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
void SetSize(int s)
Resize the vector to size s.
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
void ProjectDiscCoefficient(VectorCoefficient &coeff, Array< int > &dof_attr)
Array< unsigned int > gsl_mfem_elem
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
T * GetData()
Returns the data.
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
int GetNE() const
Returns number of elements.
double * GetData() const
Return a pointer to the beginning of the Vector data.
Array< unsigned int > gsl_proc
void FinalizeHexMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a hexahedral Mesh.
virtual void GetNodeValues(const GridFunction &gf_in, Vector &node_vals)
Get GridFunction from MFEM format to GSLIB format.
void DeleteAll()
Delete the whole array.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
virtual void MapRefPosAndElemIndices()
struct gslib::findpts_data_3 * fdata3D
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
int AddVertex(double x, double y=0.0, double z=0.0)
int Append(const T &el)
Append element 'el' to array, resize if necessary.
void Setup(Mesh &m, const double bb_t=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
double default_interp_value
struct gslib::crystal * cr
void Set2(const double x1, const double x2)
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
void SetNodalFESpace(FiniteElementSpace *nfes)
int GetVDim() const
Returns vector dimension.
FiniteElementSpace * FESpace()
void Set3(const double x1, const double x2, const double x3)
void FindPoints(const Vector &point_pos, Array< unsigned int > &point_id)
Array< unsigned int > gsl_code
double * Data() const
Returns the matrix data array.
virtual void GetSimplexNodalCoordinates()
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
void FindPoints(const Vector &point_pos)
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8, int attr=1)
virtual void InterpolateGeneral(const GridFunction &field_in, Vector &field_out)
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
virtual void GetQuadHexNodalCoordinates()
struct gslib::findpts_data_2 * fdata2D
const Array< int > & GetDofMap() const
Get an Array<int> that maps lexicographically ordered indices to the indices of the respective nodes/...
Class for integration point with weight.
const FiniteElementSpace * GetNodalFESpace() const
void FinalizeQuadMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a quadrilateral Mesh.
void Destroy()
Destroy a vector.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
int index(int i, int j, int nx, int ny)
struct gslib::comm * gsl_comm
void Interpolate(const Vector &point_pos, Array< unsigned int > &point_id, const GridFunction &field_in, Vector &field_out)
IntegrationRule * ir_simplex
const FiniteElementCollection * FEColl() const
void GetNodes(Vector &node_coord) const
Vector coefficient defined by a vector GridFunction.
Arbitrary order H1-conforming (continuous) finite elements.
void Setup(Mesh &m, const int meshid, GridFunction *gfmax=NULL, const double bb_t=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
virtual void InterpolateH1(const GridFunction &field_in, Vector &field_out)
Use GSLIB for communication and interpolation.
virtual double GetValue(int i, const IntegrationPoint &ip, int vdim=1) const
Arbitrary order "L2-conforming" discontinuous finite elements.