17 #ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
18 #pragma GCC diagnostic push
19 #pragma GCC diagnostic ignored "-Wunused-function"
24 #ifdef MFEM_HAVE_GCC_PRAGMA_DIAGNOSTIC
25 #pragma GCC diagnostic pop
32 : mesh(NULL), meshsplit(NULL), ir_simplex(NULL),
33 fdata2D(NULL), fdata3D(NULL), cr(NULL), gsl_comm(NULL),
34 dim(-1), points_cnt(0), setupflag(false), default_interp_value(0),
41 MPI_Initialized(&initialized);
42 if (!initialized) { MPI_Init(NULL, NULL); }
43 MPI_Comm comm = MPI_COMM_WORLD;;
60 : mesh(NULL), meshsplit(NULL), ir_simplex(NULL),
61 fdata2D(NULL), fdata3D(NULL), cr(NULL), gsl_comm(NULL),
62 dim(-1), points_cnt(0), setupflag(false), default_interp_value(0),
74 MFEM_VERIFY(m.
GetNodes() != NULL,
"Mesh nodes are required.");
76 "Mixed meshes are not currently supported in FindPointsGSLIB.");
99 MFEM_ABORT(
"Element type not currently supported in FindPointsGSLIB.");
103 NEtot = pts_cnt/(int)pow(dof1D,
dim);
107 unsigned nr[2] = { dof1D, dof1D };
108 unsigned mr[2] = { 2*dof1D, 2*dof1D };
111 pts_cnt, pts_cnt, npt_max, newt_tol);
115 unsigned nr[3] = { dof1D, dof1D, dof1D };
116 unsigned mr[3] = { 2*dof1D, 2*dof1D, 2*dof1D };
117 double *
const elx[3] =
120 pts_cnt, pts_cnt, npt_max, newt_tol);
127 MFEM_VERIFY(
setupflag,
"Use FindPointsGSLIB::Setup before finding points.");
137 const double *xv_base[2];
138 xv_base[0] = point_pos.
GetData();
140 unsigned xv_stride[2];
141 xv_stride[0] =
sizeof(double);
142 xv_stride[1] =
sizeof(double);
152 const double *xv_base[3];
153 xv_base[0] = point_pos.
GetData();
156 unsigned xv_stride[3];
157 xv_stride[0] =
sizeof(double);
158 xv_stride[1] =
sizeof(double);
159 xv_stride[2] =
sizeof(double);
174 for (
int d = 0; d <
dim; d++) {
gsl_ref(i*dim + d) = -1.; }
184 const double bb_t,
const double newt_tol,
189 Setup(m, bb_t, newt_tol, npt_max);
232 MFEM_ASSERT(gf_in.
FESpace()->
GetVDim() == 1,
"Scalar function expected.");
245 node_vals.
SetSize(NE * dof_cnt);
249 MFEM_VERIFY(tbe != NULL,
"TensorBasis FiniteElement expected.");
254 for (
int i = 0; i < NE; i++)
257 for (
int j = 0; j < dof_cnt; j++)
259 node_vals(pt_id++) = vals_el(dof_map[j]);
267 node_vals.
SetSize(NE * dof_cnt);
271 for (
int j = 0; j < NE; j++)
274 for (
int i = 0; i < dof_cnt; i++)
276 node_vals(pt_id++) = vals_el(i);
282 MFEM_ABORT(
"Element type not currently supported.");
293 pts_cnt = NE * dof_cnt;
298 MFEM_VERIFY(tbe != NULL,
"TensorBasis FiniteElement expected.");
306 for (
int i = 0; i < NE; i++)
310 for (
int j = 0; j < dof_cnt; j++)
312 for (
int d = 0; d <
dim; d++)
314 gsl_mesh(pts_cnt * d + pt_id) = pos(dof_map[j], d);
336 const double quad_v[7][2] =
338 {0, 0}, {0.5, 0}, {1, 0}, {0, 0.5},
339 {1./3., 1./3.}, {0.5, 0.5}, {0, 1}
341 const int quad_e[3][4] =
343 {3, 4, 1, 0}, {4, 5, 2, 1}, {6, 5, 4, 3}
346 for (
int j = 0; j < Nvert; j++)
350 for (
int j = 0; j < NEsplit; j++)
352 int attribute = j + 1;
363 const double hex_v[15][3] =
365 {0, 0, 0.}, {1, 0., 0.}, {0., 1., 0.}, {0, 0., 1.},
366 {0.5, 0., 0.}, {0.5, 0.5, 0.}, {0., 0.5, 0.},
367 {0., 0., 0.5}, {0.5, 0., 0.5}, {0., 0.5, 0.5},
368 {1./3., 0., 1./3.}, {1./3., 1./3., 1./3.}, {0, 1./3., 1./3.},
369 {1./3., 1./3., 0}, {0.25, 0.25, 0.25}
371 const int hex_e[4][8] =
373 {0, 4, 10, 7, 6, 13, 14, 12},
374 {4, 1, 8, 10, 13, 5, 11, 14},
375 {13, 5, 11, 14, 6, 2, 9, 12},
376 {10, 8, 3, 7, 14, 11, 9, 12}
379 for (
int j = 0; j < Nvert; j++)
383 for (
int j = 0; j < NEsplit; j++)
385 int attribute = j + 1;
396 const double hex_v[14][3] =
398 {0, 0, 0}, {0.5, 0, 0}, {1, 0, 0}, {0, 0.5, 0},
399 {1./3., 1./3., 0}, {0.5, 0.5, 0}, {0, 1, 0},
400 {0, 0, 1}, {0.5, 0, 1}, {1, 0, 1}, {0, 0.5, 1},
401 {1./3., 1./3., 1}, {0.5, 0.5, 1}, {0, 1, 1}
403 const int hex_e[3][8] =
405 {3, 4, 1, 0, 10, 11, 8, 7},
406 {4, 5, 2, 1, 11, 12, 9, 8},
407 {6, 5, 4, 3, 13, 12, 11, 10}
410 for (
int j = 0; j < Nvert; j++)
414 for (
int j = 0; j < NEsplit; j++)
416 int attribute = j + 1;
421 else { MFEM_ABORT(
"Unsupported geometry type."); }
428 const int dof_cnt = nodal_fes.GetFE(0)->GetDof(),
429 pts_cnt = NEsplit * dof_cnt;
434 MFEM_VERIFY(tbe != NULL,
"TensorBasis FiniteElement expected.");
445 for (
int i = 0; i < NEsplit; i++)
447 nodal_fes.GetElementVDofs(i, xdofs);
449 for (
int j = 0; j < dof_cnt; j++)
451 for (
int d = 0; d <
dim; d++)
453 irlist(pts_cnt * d + pt_id) = pos(dof_map[j], d);
468 const int tot_pts_cnt = pts_cnt*NE;
470 for (
int j = 0; j < NE; j++)
472 for (
int i = 0; i < dof_cnt*NEsplit; i++)
476 for (
int d = 0; d <
dim; d++)
478 gsl_mesh(tot_pts_cnt*d + pt_id) = locval(d);
503 const double quad_v[7][2] =
505 {0, 0}, {0.5, 0}, {1, 0}, {0, 0.5},
506 {1./3., 1./3.}, {0.5, 0.5}, {0, 1}
508 for (
int k = 0; k <
dim; k++)
510 for (
int j = 0; j < gf_lin.
Size()/
dim; j++)
512 gf_lin(j+k*gf_lin.
Size()/
dim) = quad_v[j][k];
519 const double hex_v[15][3] =
521 {0, 0, 0.}, {1, 0., 0.}, {0., 1., 0.}, {0, 0., 1.},
522 {0.5, 0., 0.}, {0.5, 0.5, 0.}, {0., 0.5, 0.},
523 {0., 0., 0.5}, {0.5, 0., 0.5}, {0., 0.5, 0.5},
524 {1./3., 0., 1./3.}, {1./3., 1./3., 1./3.}, {0, 1./3., 1./3.},
525 {1./3., 1./3., 0}, {0.25, 0.25, 0.25}
527 for (
int k = 0; k <
dim; k++)
529 for (
int j = 0; j < gf_lin.
Size()/
dim; j++)
531 gf_lin(j+k*gf_lin.
Size()/
dim) = hex_v[j][k];
538 const double hex_v[14][3] =
540 {0, 0, 0}, {0.5, 0, 0}, {1, 0, 0}, {0, 0.5, 0},
541 {1./3., 1./3., 0}, {0.5, 0.5, 0}, {0, 1, 0},
542 {0, 0, 1}, {0.5, 0, 1}, {1, 0, 1}, {0, 0.5, 1},
543 {1./3., 1./3., 1}, {0.5, 0.5, 1}, {0, 1, 1}
545 for (
int k = 0; k <
dim; k++)
547 for (
int j = 0; j < gf_lin.
Size()/
dim; j++)
549 gf_lin(j+k*gf_lin.
Size()/
dim) = hex_v[j][k];
556 MFEM_ABORT(
"Element type not currently supported.");
564 int local_elem =
gsl_elem[i]%NEsplit;
569 ip.
Set2(mfem_ref.GetData());
570 if (dim == 3) { ip.
z = mfem_ref(2); }
585 if (fec_h1 && gf_order == mesh_order &&
606 if (indl2.
Size() == 0) {
return; }
610 int gf_order_h1 = std::max(gf_order, 1);
616 if (
avgtype == AvgType::ARITHMETIC)
620 else if (
avgtype == AvgType::HARMONIC)
626 MFEM_ABORT(
"Invalid averaging type.");
629 if (gf_order_h1 == mesh_order)
639 for (
int j = 0; j < ncomp; j++)
641 for (
int i = 0; i < indl2.
Size(); i++)
644 field_out(idx) = field_out_l2(idx);
658 points_fld = field_in.
Size() / ncomp,
661 field_out.
SetSize(points_cnt*ncomp);
664 for (
int i = 0; i < ncomp; i++)
666 const int dataptrin = i*points_fld,
668 field_in_scalar.NewDataAndSize(field_in.
GetData()+dataptrin, points_fld);
673 findpts_eval_2(field_out.
GetData()+dataptrout,
sizeof(double),
682 findpts_eval_3(field_out.
GetData()+dataptrout,
sizeof(double),
712 for (
int i = 0; i < ncomp; i++)
714 field_out(index + i*npt) = localval(i);
728 struct array *outpt =
new array;
729 struct out_pt {
double r[3], ival;
uint index, el, proc; };
731 array_init(
struct out_pt, outpt, nptsend);
733 pt = (
struct out_pt *)outpt->ptr;
745 sarray_transfer(
struct out_pt, outpt, proc, 1,
cr);
751 pt = (
struct out_pt *)outpt->ptr;
756 pt->ival = field_in.
GetValue(pt->el, ip, 1);
761 sarray_transfer(
struct out_pt, outpt, proc, 1,
cr);
763 pt = (
struct out_pt *)outpt->ptr;
766 field_out(pt->index) = pt->ival;
776 pt = (
struct out_pt *)outpt->ptr;
777 Vector vec_int_vals(npt*ncomp);
782 Vector localval(vec_int_vals.GetData()+
index*ncomp, ncomp);
788 struct array *savpt =
new array;
791 array_init(
struct sav_pt, savpt, npt);
793 spt = (
struct sav_pt *)savpt->ptr;
794 pt = (
struct out_pt *)outpt->ptr;
797 spt->index = pt->index;
798 spt->proc = pt->proc;
806 struct array *sendpt =
new array;
807 struct send_pt {
double ival;
uint index, proc; };
808 struct send_pt *sdpt;
809 for (
int j = 0; j < ncomp; j++)
811 array_init(
struct send_pt, sendpt, npt);
813 spt = (
struct sav_pt *)savpt->ptr;
814 sdpt = (
struct send_pt *)sendpt->ptr;
817 sdpt->index = spt->index;
818 sdpt->proc = spt->proc;
819 sdpt->ival = vec_int_vals(j +
index*ncomp);
823 sarray_transfer(
struct send_pt, sendpt, proc, 1,
cr);
824 sdpt = (
struct send_pt *)sendpt->ptr;
827 int idx = sdpt->index + j*nptorig;
828 field_out(idx) = sdpt->ival;
842 #endif // MFEM_USE_GSLIB
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for all finite elements.
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)
struct findpts_data_3 * fdata3D
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.
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.
void MapRefPosAndElemIndices()
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
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)
Array< unsigned int > gsl_code
double * Data() const
Returns the matrix data array.
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)
void InterpolateGeneral(const GridFunction &field_in, Vector &field_out)
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
void GetQuadHexNodalCoordinates()
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.
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)
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.
struct findpts_data_2 * fdata2D
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.