18 {
"Point",
"Segment",
"Triangle",
"Square",
"Tetrahedron",
"Cube" };
21 { 1.0, 1.0, 0.5, 1.0, 1./6, 1.0 };
114 GeomCenter[
POINT].
x = 0.0;
115 GeomCenter[
POINT].
y = 0.0;
116 GeomCenter[
POINT].
z = 0.0;
134 GeomCenter[
CUBE].
x = 0.5;
135 GeomCenter[
CUBE].
y = 0.5;
136 GeomCenter[
CUBE].
z = 0.5;
138 PerfGeomToGeomJac[
POINT] = NULL;
139 PerfGeomToGeomJac[
SEGMENT] = NULL;
141 PerfGeomToGeomJac[
SQUARE] = NULL;
143 PerfGeomToGeomJac[
CUBE] = NULL;
165 for (
int i = 0; i <
NumGeom; i++)
167 delete PerfGeomToGeomJac[i];
198 ip.
x = double(rand()) / RAND_MAX;
201 ip.
x = double(rand()) / RAND_MAX;
202 ip.
y = double(rand()) / RAND_MAX;
203 if (ip.
x + ip.
y > 1.0)
210 ip.
x = double(rand()) / RAND_MAX;
211 ip.
y = double(rand()) / RAND_MAX;
214 ip.
x = double(rand()) / RAND_MAX;
215 ip.
y = double(rand()) / RAND_MAX;
216 ip.
z = double(rand()) / RAND_MAX;
219 if (ip.
x + ip.
y > 1.0)
226 if (ip.
x + ip.
z > 1.0)
229 ip.
x = ip.
x + ip.
z - 1.0;
234 else if (ip.
x + ip.
y + ip.
z > 1.0)
238 ip.
x = 1.0 - x - ip.
z;
239 ip.
y = 1.0 - x - ip.
y;
245 ip.
x = double(rand()) / RAND_MAX;
246 ip.
y = double(rand()) / RAND_MAX;
247 ip.
z = double(rand()) / RAND_MAX;
250 MFEM_ABORT(
"Unknown type of reference element!");
260 if (ip.
x != 0.0) {
return false; }
263 if (ip.
x < 0.0 || ip.
x > 1.0) {
return false; }
266 if (ip.
x < 0.0 || ip.
y < 0.0 || ip.
x+ip.
y > 1.0) {
return false; }
269 if (ip.
x < 0.0 || ip.
x > 1.0 || ip.
y < 0.0 || ip.
y > 1.0)
273 if (ip.
x < 0.0 || ip.
y < 0.0 || ip.
z < 0.0 ||
274 ip.
x+ip.
y+ip.
z > 1.0) {
return false; }
277 if (ip.
x < 0.0 || ip.
x > 1.0 || ip.
y < 0.0 || ip.
y > 1.0 ||
278 ip.
z < 0.0 || ip.
z > 1.0) {
return false; }
281 MFEM_ABORT(
"Unknown type of reference element!");
289 template <
int N,
int dim>
290 inline bool IntersectSegment(
double lbeg[N],
double lend[N],
295 for (
int i = 0; i < N; i++)
297 lbeg[i] = std::max(lbeg[i], 0.0);
301 t = std::min(t, lbeg[i]/(lbeg[i]-lend[i]));
306 if (
dim >= 1) { end.
x = t*lend[0] + (1.0-t)*lbeg[0]; }
307 if (
dim >= 2) { end.
y = t*lend[1] + (1.0-t)*lbeg[1]; }
308 if (
dim >= 3) { end.
z = t*lend[2] + (1.0-t)*lbeg[2]; }
324 if (end.
x != 0.0) { end.
x = 0.0;
return false; }
329 if (end.
x < 0.0) { end.
x = 0.0;
return false; }
330 if (end.
x > 1.0) { end.
x = 1.0;
return false; }
335 double lend[3] = { end.
x, end.
y, 1-end.
x-end.
y };
336 double lbeg[3] = { beg.
x, beg.
y, 1-beg.
x-beg.
y };
337 return internal::IntersectSegment<3,2>(lbeg, lend, end);
341 double lend[4] = { end.
x, end.
y, 1-end.
x, 1.0-end.
y };
342 double lbeg[4] = { beg.
x, beg.
y, 1-beg.
x, 1.0-beg.
y };
343 return internal::IntersectSegment<4,2>(lbeg, lend, end);
347 double lend[4] = { end.
x, end.
y, end.
z, 1.0-end.
x-end.
y-end.
z };
348 double lbeg[4] = { beg.
x, beg.
y, beg.
z, 1.0-beg.
x-beg.
y-beg.
z };
349 return internal::IntersectSegment<4,3>(lbeg, lend, end);
353 double lend[6] = { end.
x, end.
y, end.
z,
354 1.0-end.
x, 1.0-end.
y, 1.0-end.
z
356 double lbeg[6] = { beg.
x, beg.
y, beg.
z,
357 1.0-beg.
x, 1.0-beg.
y, 1.0-beg.
z
359 return internal::IntersectSegment<6,3>(lbeg, lend, end);
362 MFEM_ABORT(
"Unknown type of reference element!");
382 pm(0,0) = 0.0; pm(1,0) = 0.0;
383 pm(0,1) = 1.0; pm(1,1) = 0.0;
384 pm(0,2) = 0.5; pm(1,2) = 0.86602540378443864676;
391 pm(0,0) = 0.0; pm(1,0) = 0.0;
392 pm(0,1) = 1.0; pm(1,1) = 0.0;
393 pm(0,2) = 1.0; pm(1,2) = 1.0;
394 pm(0,3) = 0.0; pm(1,3) = 1.0;
401 pm(0,0) = 0.0; pm(1,0) = 0.0; pm(2,0) = 0.0;
402 pm(0,1) = 1.0; pm(1,1) = 0.0; pm(2,1) = 0.0;
403 pm(0,2) = 0.5; pm(1,2) = 0.86602540378443864676; pm(2,2) = 0.0;
404 pm(0,3) = 0.5; pm(1,3) = 0.28867513459481288225;
405 pm(2,3) = 0.81649658092772603273;
412 pm(0,0) = 0.0; pm(1,0) = 0.0; pm(2,0) = 0.0;
413 pm(0,1) = 1.0; pm(1,1) = 0.0; pm(2,1) = 0.0;
414 pm(0,2) = 1.0; pm(1,2) = 1.0; pm(2,2) = 0.0;
415 pm(0,3) = 0.0; pm(1,3) = 1.0; pm(2,3) = 0.0;
416 pm(0,4) = 0.0; pm(1,4) = 0.0; pm(2,4) = 1.0;
417 pm(0,5) = 1.0; pm(1,5) = 0.0; pm(2,5) = 1.0;
418 pm(0,6) = 1.0; pm(1,6) = 1.0; pm(2,6) = 1.0;
419 pm(0,7) = 0.0; pm(1,7) = 1.0; pm(2,7) = 1.0;
424 mfem_error (
"Geometry::GetPerfPointMat (...)");
431 if (PerfGeomToGeomJac[GeomType])
433 Mult(J, *PerfGeomToGeomJac[GeomType], PJ);
469 const double *cp = NULL;
480 if (RGeom[g] != NULL && RGeom[g]->Times == Times)
486 RGeom[g]->
Times = Times;
488 for (i = 0; i <= Times; i++)
491 ip.
x = (type == 0) ?
double(i) / Times : cp[i];
494 for (i = 0; i < Times; i++)
505 if (RGeom[2] != NULL && RGeom[2]->Times == Times &&
506 RGeom[2]->ETimes == ETimes)
511 if (RGeom[2] != NULL)
517 RGeom[2]->
Times = Times;
518 RGeom[2]->
ETimes = ETimes;
519 for (k = j = 0; j <= Times; j++)
520 for (i = 0; i <= Times-j; i++, k++)
525 ip.
x = double(i) / Times;
526 ip.
y = double(j) / Times;
530 ip.
x = cp[i]/(cp[i] + cp[j] + cp[Times-i-j]);
531 ip.
y = cp[j]/(cp[i] + cp[j] + cp[Times-i-j]);
535 for (l = k = j = 0; j < Times; j++, k++)
536 for (i = 0; i < Times-j; i++, k++)
540 G[l++] = k+Times-j+1;
544 G[l++] = k+Times-j+2;
545 G[l++] = k+Times-j+1;
550 for (l = k = 0; k < Times; k += Times/ETimes)
552 j = k*(Times+1)-((k-1)*k)/2;
553 for (i = 0; i < Times-k; i++)
560 for (k = Times; k > 0; k -= Times/ETimes)
563 for (i = 0; i < k; i++)
565 E[l++] = j; j += Times-i;
570 for (k = 0; k < Times; k += Times/ETimes)
573 for (i = 0; i < Times-k; i++)
575 E[l++] = j; j += Times-i+1;
585 if (RGeom[3] != NULL && RGeom[3]->Times == Times &&
586 RGeom[3]->ETimes == ETimes)
591 if (RGeom[3] != NULL)
597 RGeom[3]->
Times = Times;
598 RGeom[3]->
ETimes = ETimes;
599 for (k = j = 0; j <= Times; j++)
600 for (i = 0; i <= Times; i++, k++)
605 ip.
x = double(i) / Times;
606 ip.
y = double(j) / Times;
615 for (l = k = j = 0; j < Times; j++, k++)
616 for (i = 0; i < Times; i++, k++)
625 for (l = k = 0; k <= Times; k += Times/ETimes)
627 for (i = 0, j = k*(Times+1); i < Times; i++)
634 for (k = Times; k >= 0; k -= Times/ETimes)
636 for (i = 0, j = k; i < Times; i++)
638 E[l++] = j; j += Times+1;
649 if (RGeom[g] != NULL && RGeom[g]->Times == Times &&
650 RGeom[g]->ETimes == ETimes)
655 if (RGeom[g] != NULL)
660 8*Times*Times*Times, 0);
661 RGeom[g]->
Times = Times;
662 RGeom[g]->
ETimes = ETimes;
663 for (l = k = 0; k <= Times; k++)
664 for (j = 0; j <= Times; j++)
665 for (i = 0; i <= Times; i++, l++)
670 ip.
x = double(i) / Times;
671 ip.
y = double(j) / Times;
672 ip.
z = double(k) / Times;
682 for (l = k = 0; k < Times; k++)
683 for (j = 0; j < Times; j++)
684 for (i = 0; i < Times; i++)
686 G[l++] = i+0 + (j+0 + (k+0) * (Times+1)) * (Times+1);
687 G[l++] = i+1 + (j+0 + (k+0) * (Times+1)) * (Times+1);
688 G[l++] = i+1 + (j+1 + (k+0) * (Times+1)) * (Times+1);
689 G[l++] = i+0 + (j+1 + (k+0) * (Times+1)) * (Times+1);
690 G[l++] = i+0 + (j+0 + (k+1) * (Times+1)) * (Times+1);
691 G[l++] = i+1 + (j+0 + (k+1) * (Times+1)) * (Times+1);
692 G[l++] = i+1 + (j+1 + (k+1) * (Times+1)) * (Times+1);
693 G[l++] = i+0 + (j+1 + (k+1) * (Times+1)) * (Times+1);
702 if (RGeom[g] != NULL && RGeom[g]->Times == Times &&
703 RGeom[g]->ETimes == ETimes)
708 if (RGeom[g] != NULL)
732 for (k = 0; k <= n; k++)
733 for (j = 0; j <= k; j++)
734 for (i = 0; i <= j; i++)
744 ip.
x = double(k - j) / n;
745 ip.
y = double(i) / n;
746 ip.
z = double(j - i) / n;
750 double w = cp[k-j] + cp[i] + cp[j-i] + cp[Times-k];
755 l = i + (j + k * (n+1)) * (n+1);
759 if (m != (n+3)*(n+2)*(n+1)/6)
761 mfem_error(
"GeometryRefiner::Refine() for TETRAHEDRON #1");
766 for (k = 0; k < n; k++)
767 for (j = 0; j <= k; j++)
768 for (i = 0; i <= j; i++)
778 G[m++] = vi[i+0 + (j+0 + (k+0) * (n+1)) * (n+1)];
779 G[m++] = vi[i+0 + (j+0 + (k+1) * (n+1)) * (n+1)];
780 G[m++] = vi[i+1 + (j+1 + (k+1) * (n+1)) * (n+1)];
781 G[m++] = vi[i+0 + (j+1 + (k+1) * (n+1)) * (n+1)];
785 G[m++] = vi[i+0 + (j+0 + (k+0) * (n+1)) * (n+1)];
786 G[m++] = vi[i+1 + (j+1 + (k+1) * (n+1)) * (n+1)];
787 G[m++] = vi[i+0 + (j+1 + (k+0) * (n+1)) * (n+1)];
788 G[m++] = vi[i+0 + (j+1 + (k+1) * (n+1)) * (n+1)];
790 G[m++] = vi[i+0 + (j+0 + (k+0) * (n+1)) * (n+1)];
791 G[m++] = vi[i+0 + (j+1 + (k+0) * (n+1)) * (n+1)];
792 G[m++] = vi[i+1 + (j+1 + (k+1) * (n+1)) * (n+1)];
793 G[m++] = vi[i+1 + (j+1 + (k+0) * (n+1)) * (n+1)];
798 G[m++] = vi[i+0 + (j+0 + (k+0) * (n+1)) * (n+1)];
799 G[m++] = vi[i+1 + (j+0 + (k+0) * (n+1)) * (n+1)];
800 G[m++] = vi[i+1 + (j+1 + (k+1) * (n+1)) * (n+1)];
801 G[m++] = vi[i+1 + (j+0 + (k+1) * (n+1)) * (n+1)];
805 G[m++] = vi[i+0 + (j+0 + (k+0) * (n+1)) * (n+1)];
806 G[m++] = vi[i+1 + (j+1 + (k+1) * (n+1)) * (n+1)];
807 G[m++] = vi[i+1 + (j+0 + (k+0) * (n+1)) * (n+1)];
808 G[m++] = vi[i+1 + (j+1 + (k+0) * (n+1)) * (n+1)];
811 G[m++] = vi[i+0 + (j+0 + (k+0) * (n+1)) * (n+1)];
812 G[m++] = vi[i+1 + (j+1 + (k+1) * (n+1)) * (n+1)];
813 G[m++] = vi[i+0 + (j+0 + (k+1) * (n+1)) * (n+1)];
814 G[m++] = vi[i+1 + (j+0 + (k+1) * (n+1)) * (n+1)];
819 mfem_error(
"GeometryRefiner::Refine() for TETRAHEDRON #2");
821 for (i = 0; i < m; i++)
824 mfem_error(
"GeometryRefiner::Refine() for TETRAHEDRON #3");
848 if (IntPts[g] == NULL || IntPts[g]->GetNPoints() != Times-1)
852 for (
int i = 1; i < Times; i++)
855 ip.
x = double(i) / Times;
868 if (IntPts[g] == NULL ||
869 IntPts[g]->GetNPoints() != ((Times-1)*(Times-2))/2)
873 for (
int k = 0, j = 1; j < Times-1; j++)
874 for (
int i = 1; i < Times-j; i++, k++)
877 ip.
x = double(i) / Times;
878 ip.
y = double(j) / Times;
891 if (IntPts[g] == NULL || IntPts[g]->GetNPoints() != (Times-1)*(Times-1))
895 for (
int k = 0, j = 1; j < Times; j++)
896 for (
int i = 1; i < Times; i++, k++)
899 ip.
x = double(i) / Times;
900 ip.
y = double(j) / Times;
908 mfem_error(
"GeometryRefiner::RefineInterior(...)");
Class for integration rule.
void JacToPerfJac(int GeomType, const DenseMatrix &J, DenseMatrix &PJ) const
static void GetRandomPoint(int GeomType, IntegrationPoint &ip)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
RefinedGeometry * Refine(int Geom, int Times, int ETimes=1)
Data type dense matrix using column-major storage.
static const double Volume[NumGeom]
const double * ClosedPoints(const int p)
static const int NumBdrArray[]
const IntegrationRule * GetVertices(int GeomType)
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
const IntegrationRule * RefineInterior(int Geom, int Times)
GeometryRefiner GlobGeometryRefiner
Class for linear FE on tetrahedron.
Class for linear FE on triangle.
static const char * Name[NumGeom]
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
static bool ProjectPoint(int GeomType, const IntegrationPoint &beg, IntegrationPoint &end)
void GetPerfPointMat(int GeomType, DenseMatrix &pm)
void mfem_error(const char *msg)
Class for integration point with weight.
static bool CheckPoint(int GeomType, const IntegrationPoint &ip)
Check if the given point is inside the given reference element.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.