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.");
81 MFEM_VERIFY(!(m.
GetNodes()->FESpace()->IsVariableOrder()),
82 "Variable order mesh is not currently supported.");
105 MFEM_ABORT(
"Element type not currently supported in FindPointsGSLIB.");
109 NEtot = pts_cnt/(int)
pow(dof1D,
dim);
113 unsigned nr[2] = { dof1D, dof1D };
114 unsigned mr[2] = { 2*dof1D, 2*dof1D };
117 pts_cnt, pts_cnt, npt_max, newt_tol);
121 unsigned nr[3] = { dof1D, dof1D, dof1D };
122 unsigned mr[3] = { 2*dof1D, 2*dof1D, 2*dof1D };
123 double *
const elx[3] =
126 pts_cnt, pts_cnt, npt_max, newt_tol);
133 MFEM_VERIFY(
setupflag,
"Use FindPointsGSLIB::Setup before finding points.");
143 const double *xv_base[2];
144 xv_base[0] = point_pos.
GetData();
146 unsigned xv_stride[2];
147 xv_stride[0] =
sizeof(double);
148 xv_stride[1] =
sizeof(double);
158 const double *xv_base[3];
159 xv_base[0] = point_pos.
GetData();
162 unsigned xv_stride[3];
163 xv_stride[0] =
sizeof(double);
164 xv_stride[1] =
sizeof(double);
165 xv_stride[2] =
sizeof(double);
180 for (
int d = 0; d <
dim; d++) {
gsl_ref(i*dim + d) = -1.; }
190 const double bb_t,
const double newt_tol,
195 Setup(m, bb_t, newt_tol, npt_max);
238 MFEM_ASSERT(gf_in.
FESpace()->
GetVDim() == 1,
"Scalar function expected.");
251 node_vals.
SetSize(NE * dof_cnt);
255 MFEM_VERIFY(tbe != NULL,
"TensorBasis FiniteElement expected.");
260 for (
int i = 0; i < NE; i++)
263 for (
int j = 0; j < dof_cnt; j++)
265 node_vals(pt_id++) = vals_el(dof_map[j]);
273 node_vals.
SetSize(NE * dof_cnt);
277 for (
int j = 0; j < NE; j++)
280 for (
int i = 0; i < dof_cnt; i++)
282 node_vals(pt_id++) = vals_el(i);
288 MFEM_ABORT(
"Element type not currently supported.");
299 pts_cnt = NE * dof_cnt;
304 MFEM_VERIFY(tbe != NULL,
"TensorBasis FiniteElement expected.");
307 if (dm.
Size() > 0) { dof_map = dm; }
308 else {
for (
int i = 0; i < dof_cnt; i++) { dof_map[i] = i; } }
315 for (
int i = 0; i < NE; i++)
319 for (
int j = 0; j < dof_cnt; j++)
321 for (
int d = 0; d <
dim; d++)
323 gsl_mesh(pts_cnt * d + pt_id) = pos(dof_map[j], d);
345 const double quad_v[7][2] =
347 {0, 0}, {0.5, 0}, {1, 0}, {0, 0.5},
348 {1./3., 1./3.}, {0.5, 0.5}, {0, 1}
350 const int quad_e[3][4] =
352 {3, 4, 1, 0}, {4, 5, 2, 1}, {6, 5, 4, 3}
355 for (
int j = 0; j < Nvert; j++)
359 for (
int j = 0; j < NEsplit; j++)
361 int attribute = j + 1;
372 const double hex_v[15][3] =
374 {0, 0, 0.}, {1, 0., 0.}, {0., 1., 0.}, {0, 0., 1.},
375 {0.5, 0., 0.}, {0.5, 0.5, 0.}, {0., 0.5, 0.},
376 {0., 0., 0.5}, {0.5, 0., 0.5}, {0., 0.5, 0.5},
377 {1./3., 0., 1./3.}, {1./3., 1./3., 1./3.}, {0, 1./3., 1./3.},
378 {1./3., 1./3., 0}, {0.25, 0.25, 0.25}
380 const int hex_e[4][8] =
382 {0, 4, 10, 7, 6, 13, 14, 12},
383 {4, 1, 8, 10, 13, 5, 11, 14},
384 {13, 5, 11, 14, 6, 2, 9, 12},
385 {10, 8, 3, 7, 14, 11, 9, 12}
388 for (
int j = 0; j < Nvert; j++)
392 for (
int j = 0; j < NEsplit; j++)
394 int attribute = j + 1;
405 const double hex_v[14][3] =
407 {0, 0, 0}, {0.5, 0, 0}, {1, 0, 0}, {0, 0.5, 0},
408 {1./3., 1./3., 0}, {0.5, 0.5, 0}, {0, 1, 0},
409 {0, 0, 1}, {0.5, 0, 1}, {1, 0, 1}, {0, 0.5, 1},
410 {1./3., 1./3., 1}, {0.5, 0.5, 1}, {0, 1, 1}
412 const int hex_e[3][8] =
414 {3, 4, 1, 0, 10, 11, 8, 7},
415 {4, 5, 2, 1, 11, 12, 9, 8},
416 {6, 5, 4, 3, 13, 12, 11, 10}
419 for (
int j = 0; j < Nvert; j++)
423 for (
int j = 0; j < NEsplit; j++)
425 int attribute = j + 1;
430 else { MFEM_ABORT(
"Unsupported geometry type."); }
437 const int dof_cnt = nodal_fes.GetFE(0)->GetDof(),
438 pts_cnt = NEsplit * dof_cnt;
443 MFEM_VERIFY(tbe != NULL,
"TensorBasis FiniteElement expected.");
454 for (
int i = 0; i < NEsplit; i++)
456 nodal_fes.GetElementVDofs(i, xdofs);
458 for (
int j = 0; j < dof_cnt; j++)
460 for (
int d = 0; d <
dim; d++)
462 irlist(pts_cnt * d + pt_id) = pos(dof_map[j], d);
477 const int tot_pts_cnt = pts_cnt*NE;
479 for (
int j = 0; j < NE; j++)
481 for (
int i = 0; i < dof_cnt*NEsplit; i++)
485 for (
int d = 0; d <
dim; d++)
487 gsl_mesh(tot_pts_cnt*d + pt_id) = locval(d);
512 const double quad_v[7][2] =
514 {0, 0}, {0.5, 0}, {1, 0}, {0, 0.5},
515 {1./3., 1./3.}, {0.5, 0.5}, {0, 1}
517 for (
int k = 0; k <
dim; k++)
519 for (
int j = 0; j < gf_lin.
Size()/
dim; j++)
521 gf_lin(j+k*gf_lin.
Size()/
dim) = quad_v[j][k];
528 const double hex_v[15][3] =
530 {0, 0, 0.}, {1, 0., 0.}, {0., 1., 0.}, {0, 0., 1.},
531 {0.5, 0., 0.}, {0.5, 0.5, 0.}, {0., 0.5, 0.},
532 {0., 0., 0.5}, {0.5, 0., 0.5}, {0., 0.5, 0.5},
533 {1./3., 0., 1./3.}, {1./3., 1./3., 1./3.}, {0, 1./3., 1./3.},
534 {1./3., 1./3., 0}, {0.25, 0.25, 0.25}
536 for (
int k = 0; k <
dim; k++)
538 for (
int j = 0; j < gf_lin.
Size()/
dim; j++)
540 gf_lin(j+k*gf_lin.
Size()/
dim) = hex_v[j][k];
547 const double hex_v[14][3] =
549 {0, 0, 0}, {0.5, 0, 0}, {1, 0, 0}, {0, 0.5, 0},
550 {1./3., 1./3., 0}, {0.5, 0.5, 0}, {0, 1, 0},
551 {0, 0, 1}, {0.5, 0, 1}, {1, 0, 1}, {0, 0.5, 1},
552 {1./3., 1./3., 1}, {0.5, 0.5, 1}, {0, 1, 1}
554 for (
int k = 0; k <
dim; k++)
556 for (
int j = 0; j < gf_lin.
Size()/
dim; j++)
558 gf_lin(j+k*gf_lin.
Size()/
dim) = hex_v[j][k];
565 MFEM_ABORT(
"Element type not currently supported.");
573 int local_elem =
gsl_elem[i]%NEsplit;
578 ip.
Set2(mfem_ref.GetData());
579 if (dim == 3) { ip.
z = mfem_ref(2); }
594 if (fec_h1 && gf_order == mesh_order &&
616 int borderPts = indl2.
Size();
618 MPI_Allreduce(MPI_IN_PLACE, &borderPts, 1, MPI_INT, MPI_SUM,
gsl_comm->c);
620 if (borderPts == 0) {
return; }
625 int gf_order_h1 = std::max(gf_order, 1);
631 if (
avgtype == AvgType::ARITHMETIC)
635 else if (
avgtype == AvgType::HARMONIC)
641 MFEM_ABORT(
"Invalid averaging type.");
644 if (gf_order_h1 == mesh_order)
654 for (
int j = 0; j < ncomp; j++)
656 for (
int i = 0; i < indl2.
Size(); i++)
659 field_out(idx) = field_out_l2(idx);
673 points_fld = field_in.
Size() / ncomp,
676 field_out.
SetSize(points_cnt*ncomp);
679 for (
int i = 0; i < ncomp; i++)
681 const int dataptrin = i*points_fld,
683 field_in_scalar.NewDataAndSize(field_in.
GetData()+dataptrin, points_fld);
688 findpts_eval_2(field_out.
GetData()+dataptrout,
sizeof(double),
697 findpts_eval_3(field_out.
GetData()+dataptrout,
sizeof(double),
727 for (
int i = 0; i < ncomp; i++)
729 field_out(index + i*npt) = localval(i);
743 struct gslib::array *outpt =
new gslib::array;
744 struct out_pt {
double r[3], ival;
uint index, el, proc; };
746 array_init(
struct out_pt, outpt, nptsend);
748 pt = (
struct out_pt *)outpt->ptr;
760 sarray_transfer(
struct out_pt, outpt, proc, 1,
cr);
766 pt = (
struct out_pt *)outpt->ptr;
771 pt->ival = field_in.
GetValue(pt->el, ip, 1);
776 sarray_transfer(
struct out_pt, outpt, proc, 1,
cr);
778 pt = (
struct out_pt *)outpt->ptr;
781 field_out(pt->index) = pt->ival;
791 pt = (
struct out_pt *)outpt->ptr;
792 Vector vec_int_vals(npt*ncomp);
797 Vector localval(vec_int_vals.GetData()+
index*ncomp, ncomp);
803 struct gslib::array *savpt =
new gslib::array;
806 array_init(
struct sav_pt, savpt, npt);
808 spt = (
struct sav_pt *)savpt->ptr;
809 pt = (
struct out_pt *)outpt->ptr;
812 spt->index = pt->index;
813 spt->proc = pt->proc;
821 struct gslib::array *sendpt =
new gslib::array;
822 struct send_pt {
double ival;
uint index, proc; };
823 struct send_pt *sdpt;
824 for (
int j = 0; j < ncomp; j++)
826 array_init(
struct send_pt, sendpt, npt);
828 spt = (
struct sav_pt *)savpt->ptr;
829 sdpt = (
struct send_pt *)sendpt->ptr;
832 sdpt->index = spt->index;
833 sdpt->proc = spt->proc;
834 sdpt->ival = vec_int_vals(j +
index*ncomp);
838 sarray_transfer(
struct send_pt, sendpt, proc, 1,
cr);
839 sdpt = (
struct send_pt *)sendpt->ptr;
842 int idx = sdpt->index + j*nptorig;
843 field_out(idx) = sdpt->ival;
857 const double bb_t,
const double newt_tol,
860 MFEM_VERIFY(m.
GetNodes() != NULL,
"Mesh nodes are required.");
862 "Mixed meshes are not currently supported in FindPointsGSLIB.");
863 MFEM_VERIFY(!(m.
GetNodes()->FESpace()->IsVariableOrder()),
864 "Variable order mesh is not currently supported.");
873 unsigned dof1D = fe->
GetOrder() + 1;
887 MFEM_ABORT(
"Element type not currently supported in FindPointsGSLIB.");
890 MFEM_ASSERT(meshid>=0,
" The ID should be greater than or equal to 0.");
893 NEtot = pts_cnt/(int)
pow(dof1D,
dim);
908 unsigned nr[2] = { dof1D, dof1D };
909 unsigned mr[2] = { 2*dof1D, 2*dof1D };
912 pts_cnt, pts_cnt, npt_max, newt_tol,
917 unsigned nr[3] = { dof1D, dof1D, dof1D };
918 unsigned mr[3] = { 2*dof1D, 2*dof1D, 2*dof1D };
919 double *
const elx[3] =
922 pts_cnt, pts_cnt, npt_max, newt_tol,
932 MFEM_VERIFY(
setupflag,
"Use OversetFindPointsGSLIB::Setup before "
934 MFEM_VERIFY(
overset,
" Please setup FindPoints for overlapping grids.");
936 unsigned int match = 0;
946 const double *xv_base[2];
947 xv_base[0] = point_pos.
GetData();
949 unsigned xv_stride[2];
950 xv_stride[0] =
sizeof(double);
951 xv_stride[1] =
sizeof(double);
958 point_id.
GetData(),
sizeof(
unsigned int), &match,
963 const double *xv_base[3];
964 xv_base[0] = point_pos.
GetData();
967 unsigned xv_stride[3];
968 xv_stride[0] =
sizeof(double);
969 xv_stride[1] =
sizeof(double);
970 xv_stride[2] =
sizeof(double);
977 point_id.
GetData(),
sizeof(
unsigned int), &match,
987 for (
int d = 0; d <
dim; d++) {
gsl_ref(i*dim + d) = -1.; }
1008 #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)
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
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 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)
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
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()
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
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.