30 #ifndef CORE_DATATYPES_TETVOLMESH_H
31 #define CORE_DATATYPES_TETVOLMESH_H 1
62 #include <boost/thread.hpp>
90 #if (SCIRUN_TETVOL_SUPPORT > 0)
93 #if (SCIRUN_QUADRATIC_SUPPORT > 0)
96 #if (SCIRUN_CUBIC_SUPPORT > 0)
104 TetVolEdgePerNodeTable[4][6] = {{0,1, 2,0, 3,0},
110 TetVolFacePerNodeTable[4][9] = {{0,1,2, 0,1,3, 0,3,2},
111 {0,1,2, 1,2,3, 0,1,3},
112 {0,1,2, 1,2,3, 0,3,2},
113 {1,2,3, 0,1,3, 0,3,2}};
116 TetVolFacePerEdgeTable[6][6] = {{0,1,2, 0,1,3}, {0,1,2, 1,2,3},
117 {0,1,2, 0,3,2}, {0,1,3, 0,3,2},
118 {1,2,3, 0,1,3}, {1,2,3, 0,3,2}};
121 TetVolEdgePerFaceTable[4][6] = {{0,1, 1,2, 2,0 },
127 TetVolEdgeTable[6][2] = {{0,1},{1,2},{2,0},{3,0},{3,1},{3,2}};
130 TetVolFaceTable[4][3] = { {0,2,1},{1,2,3},{0,1,3},{0,3,2}};
135 template <
class Basis>
136 class TetVolMesh :
public Mesh
204 if (basis_type::polynomial_order() > 1)
206 mesh_.get_edges_from_cell(edges_, index_);
214 return mesh_.cells_[index_ * 4];
219 return mesh_.cells_[index_ * 4 + 1];
224 return mesh_.cells_[index_ * 4 + 2];
229 return mesh_.cells_[index_ * 4 + 3];
300 mesh_(mesh), sync_(sync) {}
309 mesh_->synchronize_lock_.lock();
311 sync_ &= ~(mesh_->synchronized_);
313 sync_ &= ~(mesh_->synchronizing_);
316 mesh_->synchronizing_ |= sync_;
318 mesh_->synchronize_lock_.unlock();
330 while(!(mesh_->synchronized_ & Mesh::BOUNDING_BOX_E))
331 mesh_->synchronize_cond_.wait(lock);
337 mesh_->synchronize_lock_.lock();
339 mesh_->synchronized_ |= sync_;
341 mesh_->synchronizing_ &= ~(sync_);
343 mesh_->synchronize_cond_.conditionBroadcast();
344 mesh_->synchronize_lock_.unlock();
372 return boost::make_shared<Core::Datatypes::VirtualMeshFacade<VMesh>>(
vmesh_);
452 { array.
resize(1); array[0]= idx; }
468 { array.resize(1); array[0]= idx; }
485 { array.resize(1); array[0]= idx; }
501 { array.resize(1); array[0]= idx; }
514 { array.resize(1); array[0]= idx; }
524 { array.resize(1); array[0]= idx; }
531 template<
class VECTOR,
class INDEX>
535 unsigned div_per_unit)
const
537 basis_.approx_edge(which_edge, div_per_unit, coords);
542 template<
class VECTOR,
class INDEX>
546 unsigned div_per_unit)
const
548 basis_.approx_face(which_face, div_per_unit, coords);
572 return ((p1 - p0).length());
583 return (
Cross(p0-p1,p2-p0)).length()*0.5;
589 return (
basis_.get_volume(ed));
634 std::vector<double>& coords,
642 {
ASSERTFAIL(
"TetVolMesh::get_weights for edges isn't supported"); }
644 {
ASSERTFAIL(
"TetVolMesh::get_weights for faces isn't supported"); }
656 {
ASSERTFAIL(
"TetVolMesh: This mesh type does not have node normals."); }
659 template<
class VECTOR,
class INDEX1,
class INDEX2>
661 INDEX1 eidx, INDEX2 fidx)
671 const double un0 =
basis_.unit_face_normals[fidx][0];
672 const double un1 =
basis_.unit_face_normals[fidx][1];
673 const double un2 =
basis_.unit_face_normals[fidx][2];
676 result.
x(Ji[0]*un0+Ji[1]*un1+Ji[2]*un2);
677 result.
y(Ji[3]*un0+Ji[4]*un1+Ji[5]*un2);
678 result.
z(Ji[6]*un0+Ji[7]*un1+Ji[8]*un2);
690 template<
class ARRAY>
693 ASSERTMSG(a.size() == 4,
"Tried to add non-tet element.");
695 return add_tet( static_cast<typename Node::index_type>(a[0]),
696 static_cast<typename Node::index_type>(a[1]),
697 static_cast<typename Node::index_type>(a[2]),
698 static_cast<typename Node::index_type>(a[3]) );
711 template<
class VECTOR,
class INDEX>
715 return basis_.get_coords(coords, p, ed);
720 template<
class VECTOR,
class INDEX>
724 pt =
basis_.interpolate(coords, ed);
730 template<
class VECTOR1,
class INDEX,
class VECTOR2>
731 void derivate(
const VECTOR1 &coords, INDEX idx, VECTOR2 &J)
const
734 basis_.derivate(coords, ed, J);
739 template<
class VECTOR,
class INDEX>
744 basis_.derivate(coords,ed,Jv);
751 template<
class VECTOR,
class INDEX>
752 void jacobian(
const VECTOR& coords,INDEX idx,
double* J)
const
756 basis_.derivate(coords,ed,Jv);
771 template<
class VECTOR,
class INDEX>
776 basis_.derivate(coords,ed,Jv);
780 template<
class INDEX>
796 double l0 = (p1-p0).length();
797 double l1 = (p2-p1).length();
798 double l2 = (p0-p2).length();
799 double l3 = (p3-p0).length();
800 double l4 = (p3-p1).length();
801 double l5 = (p3-p2).length();
803 double min_scale = l0*l2*l3;
805 if (temp > min_scale) min_scale = temp;
807 if (temp > min_scale) min_scale = temp;
809 if (temp > min_scale) min_scale = temp;
810 if (min_jacobian > min_scale) min_scale = min_jacobian;
812 return (sqrt(2.0)*min_jacobian/(min_scale));
815 template<
class INDEX>
826 size_t num_vertices =
basis_.number_of_vertices();
827 for (
size_t j=0;j < num_vertices;j++)
831 if(temp < min_jacobian) min_jacobian = temp;
834 return (min_jacobian);
838 template<
class INDEX>
850 double l0 = (p1-p0).length();
851 double l1 = (p2-p1).length();
852 double l2 = (p0-p2).length();
853 double l3 = (p3-p0).length();
854 double l4 = (p3-p1).length();
855 double l5 = (p3-p2).length();
859 double tri_AREA = (l0*l5 + l1*l3 + l2*l4) / 2.0;
862 double tet_VOL =
basis_.get_volume(ed);
865 double s_A = 0.5*(l0+l1+l2);
866 double s_B = 0.5*(l1+l4+l5);
867 double s_C = 0.5*(l2+l3+l5);
868 double s_D = 0.5*(l0+l3+l4);
870 double tri_A = sqrt(s_A*(s_A - l0)*(s_A - l1)*(s_A - l2));
871 double tri_B = sqrt(s_B*(s_B - l1)*(s_B - l4)*(s_B - l5));
872 double tri_C = sqrt(s_C*(s_C - l2)*(s_C - l3)*(s_C - l5));
873 double tri_D = sqrt(s_D*(s_D - l0)*(s_D - l3)*(s_D - l4));
875 double tet_SA = tri_A + tri_B + tri_C + tri_D;
878 double r_in = 3.0 * tet_VOL / tet_SA;
879 double r_cir = sqrt(tri_AREA*(tri_AREA - l0*l5)*(tri_AREA - l1*l3)*(tri_AREA - l2*l4)) / (6.0*tet_VOL);
882 double ideal_ratio = 0.333333;
883 double normalized_actual_ratio = (r_in / r_cir) / ideal_ratio;
884 return (normalized_actual_ratio);
887 template <
class INDEX>
894 template <
class INDEX>
897 double maxdist)
const
899 if (maxdist < 0.0) maxdist = DBL_MAX;
else maxdist = maxdist*maxdist;
903 if (sz == 0)
return (
false);
905 if (node >= 0 && node < sz)
908 double dist = (point-p).length2();
919 "TetVolMesh::find_closest_node requires synchronize(NODE_LOCATE_E).");
931 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
932 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
933 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
935 ei = bi; ej = bj; ek = bk;
937 double dmin = maxdist;
939 bool found_one =
false;
948 if (i < 0 || i > ni)
continue;
951 if (j < 0 || j > nj)
continue;
954 if (k < 0 || k > nk)
continue;
955 if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
957 if (
node_grid_->min_distance_squared(p, i, j, k) < dmin)
966 const double dist = (p-
point).length2();
994 if (!found_one)
return (
false);
999 template <
class ARRAY>
1005 "TetVolMesh::find_closest_node requires synchronize(NODE_LOCATE_E).")
1022 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
1023 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
1024 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
1026 if (ei > ni) ei = ni;
if (ei < 0) ei = 0;
1027 if (ej > nj) ej = nj;
if (ej < 0) ej = 0;
1028 if (ek > nk) ek = nk;
if (ek < 0) ek = 0;
1030 double maxdist2 = maxdist*maxdist;
1038 if (
node_grid_->min_distance_squared(p, i, j, k) < maxdist2)
1046 const double dist = (p-
point).length2();
1048 if (dist < maxdist2)
1050 nodes.push_back(*it);
1059 return(nodes.size() > 0);
1064 template <
class ARRAY1,
class ARRAY2>
1071 "TetVolMesh::find_closest_node requires synchronize(NODE_LOCATE_E).")
1088 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
1089 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
1090 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
1092 if (ei > ni) ei = ni;
if (ei < 0) ei = 0;
1093 if (ej > nj) ej = nj;
if (ej < 0) ej = 0;
1094 if (ek > nk) ek = nk;
if (ek < 0) ek = 0;
1096 double maxdist2 = maxdist*maxdist;
1104 if (
node_grid_->min_distance_squared(p, i, j, k) < maxdist2)
1112 const double dist = (p-
point).length2();
1114 if (dist < maxdist2)
1116 nodes.push_back(*it);
1117 distances.push_back(dist);
1126 return(nodes.size() > 0);
1131 template <
class INDEX,
class ARRAY>
1143 template <
class INDEX,
class ARRAY>
1149 double maxdist)
const
1151 if (maxdist < 0.0) maxdist = DBL_MAX;
else maxdist = maxdist*maxdist;
1156 if (sz == 0)
return (
false);
1159 if ((elem > 0)&&(elem < sz))
1164 basis_.get_coords(coords, p, ed);
1172 "TetVolMesh: need to synchronize FACES_E first");
1174 "TetVolMesh: need to synchronize ELEM_LOCATE_E first");
1186 elem =
static_cast<INDEX
>(*it);
1188 basis_.get_coords(coords, p, ed);
1206 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
1207 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
1208 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
1210 ei = bi; ej = bj; ek = bk;
1212 double dmin = maxdist;
1214 bool found_one =
false;
1223 if (i < 0 || i > ni)
continue;
1226 if (j < 0 || j > nj)
continue;
1229 if (k < 0 || k > nk)
continue;
1230 if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
1232 if (
elem_grid_->min_distance_squared(p, i, j, k) < dmin)
1252 const double dtmp = (p - r).length2();
1264 basis_.get_coords(coords,result,ed);
1275 const double dtmp = (p - r).length2();
1287 basis_.get_coords(coords,result,ed);
1298 const double dtmp = (p - r).length2();
1310 basis_.get_coords(coords,result,ed);
1321 const double dtmp = (p - r).length2();
1333 basis_.get_coords(coords,result,ed);
1352 if (!found_one)
return (
false);
1355 basis_.get_coords(coords,result,ed);
1361 template <
class INDEX>
1370 template<
class ARRAY>
1374 ASSERTFAIL(
"TetVolMesh: Find closest element has not yet been implemented.");
1388 static const std::string
type_name(
int n = -1);
1448 template <
class Iter,
class Functor>
1450 template <
class Iter,
class Functor>
1452 template <
class Iter,
class Functor>
1454 template <
class Iter,
class Functor>
1460 double err = 1.0e-6);
1496 template<
class ARRAY,
class INDEX>
1500 "TetVolMesh: Must call synchronize EDGES_E first");
1503 { array.clear();
return; }
1508 index_type cell_index = (cell_edge_index>>3) << 2;
1509 index_type edge_index = (cell_edge_index)&0x7;
1511 const int *offset = TetVolEdgeTable[edge_index];
1512 array[0] =
static_cast<typename ARRAY::value_type
>(
cells_[cell_index+offset[0]]);
1513 array[1] =
static_cast<typename ARRAY::value_type
>(
cells_[cell_index+offset[1]]);
1517 template<
class ARRAY,
class INDEX>
1521 "TetVolMesh: Must call synchronize FACES_E first");
1524 { array.clear();
return; }
1527 index_type cell_index = cell_face_index&(~0x3);
1532 const int *offset = TetVolFaceTable[face_index];
1533 array[0] =
static_cast<typename ARRAY::value_type
>(
cells_[cell_index+offset[0]]);
1534 array[1] =
static_cast<typename ARRAY::value_type
>(
cells_[cell_index+offset[1]]);
1535 array[2] =
static_cast<typename ARRAY::value_type
>(
cells_[cell_index+offset[2]]);
1538 template<
class ARRAY,
class INDEX>
1543 array[0] =
static_cast<typename ARRAY::value_type
>(
cells_[off]);
1544 array[1] =
static_cast<typename ARRAY::value_type
>(
cells_[off + 1]);
1545 array[2] =
static_cast<typename ARRAY::value_type
>(
cells_[off + 2]);
1546 array[3] =
static_cast<typename ARRAY::value_type
>(
cells_[off + 3]);
1549 template<
class ARRAY,
class INDEX>
1555 template<
class ARRAY,
class INDEX>
1559 "TetVolMesh: Must call synchronize EDGES_E first");
1561 "TetVolMesh: Must call synchronize FACES_E first");
1568 const int* offset = TetVolFaceTable[face_index];
1577 array.push_back(static_cast<typename ARRAY::value_type>(
1583 array.push_back(static_cast<typename ARRAY::value_type>(
1589 array.push_back(static_cast<typename ARRAY::value_type>(
1594 template<
class ARRAY,
class INDEX>
1598 "TetVolMesh: Must call synchronize EDGES_E first");
1611 typedef typename ARRAY::value_type T;
1615 array[i++] = (
static_cast<T
>((*(
edge_table_.find(e))).second));
1621 array[i++] = (
static_cast<T
>((*(
edge_table_.find(e))).second));
1627 array[i++] = (
static_cast<T
>((*(
edge_table_.find(e))).second));
1633 array[i++] = (
static_cast<T
>((*(
edge_table_.find(e))).second));
1639 array[i++] = (
static_cast<T
>((*(
edge_table_.find(e))).second));
1645 array[i++] = (
static_cast<T
>((*(
edge_table_.find(e))).second));
1649 template<
class ARRAY,
class INDEX>
1655 template<
class ARRAY,
class INDEX>
1659 "TetVolMesh: Must call synchronize FACES_E first");
1675 array[0] =
static_cast<typename ARRAY::value_type
>(
1677 array[1] =
static_cast<typename ARRAY::value_type
>(
1679 array[2] =
static_cast<typename ARRAY::value_type
>(
1681 array[3] =
static_cast<typename ARRAY::value_type
>(
1685 template<
class ARRAY,
class INDEX>
1689 "TetVolMesh: Must call synchronize NODE_NEIGHBORS_E first.");
1693 array[i] = static_cast<typename ARRAY::value_type>(
1697 template<
class ARRAY,
class INDEX>
1701 "HexVolMesh: Must call synchronize NODE_NEIGHBORS_E first");
1703 "HexVolMesh: Must call synchronize EDGES_E first");
1706 const std::vector<typename Cell::index_type>& neighbors =
node_neighbors_[idx];
1709 array.reserve(neighbors.size());
1711 for (
size_t n = 0;
n < neighbors.size();
n++)
1716 const int *offset = TetVolEdgePerNodeTable[node_index];
1719 typename edge_nt::const_iterator iter =
edge_table_.find(e);
1720 if (((
edges_[iter->second].cells_[0])&(~0x7))==(cell_index<<1) )
1721 array.push_back(
typename ARRAY::value_type(iter->second));
1725 if (((
edges_[iter->second].cells_[0])&(~0x7))==(cell_index<<1) )
1726 array.push_back(
typename ARRAY::value_type(iter->second));
1730 if (((
edges_[iter->second].cells_[0])&(~0x7))==(cell_index<<1) )
1731 array.push_back(
typename ARRAY::value_type(iter->second));
1735 template<
class ARRAY,
class INDEX>
1739 "TetVolMesh: Must call synchronize EDGES_E first");
1741 "TetVolMesh: Must call synchronize FACES_E first");
1745 for (
size_t c=0; c<
edges_[idx].cells_.size();c++)
1750 const int* off = TetVolFacePerEdgeTable[face_index];
1753 typename face_nt::const_iterator fiter;
1755 n1 =
cells_[cell_index+off[0]]; n2 =
cells_[cell_index+off[1]];
1756 n3 =
cells_[cell_index+off[2]];
1759 if (((
faces_[fiter->second].cells_[0])&(~0x3)) == cell_index)
1760 array.push_back(
typename ARRAY::value_type(fiter->second));
1762 n1 =
cells_[cell_index+off[3]]; n2 =
cells_[cell_index+off[4]];
1763 n3 =
cells_[cell_index+off[5]];
1766 if (((
faces_[fiter->second].cells_[0])&(~0x3)) == cell_index)
1767 array.push_back(
typename ARRAY::value_type(fiter->second));
1771 template<
class ARRAY,
class INDEX>
1775 "TetVolMesh: Must call synchronize NODE_NEIGHBORS_E first");
1777 "TetVolMesh: Must call synchronize EDGES_E first");
1779 "TetVolMesh: Must call synchronize FACES_E first");
1782 const std::vector<typename Cell::index_type>& neighbors =
node_neighbors_[idx];
1785 array.reserve(neighbors.size());
1787 for (
size_t n = 0;
n < neighbors.size();
n++)
1792 const int *offset = TetVolFacePerNodeTable[node_index];
1795 cells_[cell_index+offset[1]],
cells_[cell_index+offset[2]]);
1797 typename face_nt::const_iterator iter =
face_table_.find(e);
1798 if (((
faces_[iter->second].cells_[0])&(~0x3))==cell_index)
1799 array.push_back(
typename ARRAY::value_type(iter->second));
1802 cells_[cell_index+offset[5]]);
1804 if (((
faces_[iter->second].cells_[0])&(~0x3))==cell_index )
1805 array.push_back(
typename ARRAY::value_type(iter->second));
1808 cells_[cell_index+offset[8]]);
1810 if (((
faces_[iter->second].cells_[0])&(~0x3))==cell_index )
1811 array.push_back(
typename ARRAY::value_type(iter->second));
1815 template<
class ARRAY,
class INDEX>
1819 "TetVolMesh: Must call synchronize EDGES_E first");
1820 for (
size_t i=0; i<
edges_[idx].cells_.size(); i++)
1821 array[i] = static_cast<typename ARRAY::value_type>(
edges_[idx].
cells_[i]);
1824 template<
class ARRAY,
class INDEX>
1828 "TetVolMesh: Must call synchronize FACES_E first");
1832 array[0] =
static_cast<typename ARRAY::value_type
>((
faces_[idx].cells_[0])>>2);
1837 array[0] =
static_cast<typename ARRAY::value_type
>((
faces_[idx].cells_[0])>>2);
1838 array[1] =
static_cast<typename ARRAY::value_type
>((
faces_[idx].cells_[1])>>2);
1842 template <
class ARRAY,
class INDEX>
1846 cells_[idx * 4 +
n] = static_cast<index_type>(array[
n]);
1849 template <
class INDEX1,
class INDEX2>
1853 "TetVolMesh: Must call synchronize FACES_E on TetVolMesh first");
1856 if (elem == static_cast<INDEX1>((f.
cells_[0])>>2))
1859 neighbor =
static_cast<INDEX1
>((f.
cells_[1])>>2);
1864 neighbor =
static_cast<INDEX1
>((f.
cells_[0])>>2);
1869 template <
class ARRAY,
class INDEX1,
class INDEX2>
1873 "Must call synchronize FACES_E on TetVolMesh first");
1877 if (elem == static_cast<INDEX1>((f.
cells_[0])>>2))
1881 array[0] =
static_cast<typename ARRAY::value_type
>((f.
cells_[1])>>2);
1887 array[0] =
static_cast<typename ARRAY::value_type
>((f.
cells_[0])>>2);
1892 template <
class ARRAY,
class INDEX>
1899 array.reserve(faces.size());
1900 typename Face::array_type::iterator iter = faces.begin();
1901 while(iter != faces.end())
1903 typename ARRAY::value_type nbor;
1906 array.push_back(nbor);
1913 template <
class ARRAY,
class INDEX>
1917 "Must call synchronize NODE_NEIGHBORS_E on TetVolMesh first.");
1920 std::set<index_type> inserted;
1921 for (
size_t i = 0; i < sz; i++)
1931 array.reserve(inserted.size());
1932 array.insert(array.begin(), inserted.begin(), inserted.end());
1935 template <
class INDEX>
1941 if (sz == 0)
return (
false);
1944 if (node >= 0 && node < sz)
1950 "TetVolMesh::locate_node requires synchronize(NODE_LOCATE_E).")
1962 if (bi > ni) bi =ni;
if (bi < 0) bi = 0;
1963 if (bj > nj) bj =nj;
if (bj < 0) bj = 0;
1964 if (bk > nk) bk =nk;
if (bk < 0) bk = 0;
1970 double dmin = DBL_MAX;
1980 if (i < 0 || i > ni)
continue;
1983 if (j < 0 || j > nj)
continue;
1986 if (k < 0 || k > nk)
continue;
1987 if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
1989 if (
node_grid_->min_distance_squared(p, i, j, k) < dmin)
1998 const double dist = (p-
point).length2();
2018 while ((!found)||(dmin == DBL_MAX)) ;
2024 template <
class INDEX>
2028 "Must call synchronize EDGES_E on TetVolMesh first");
2036 double mindist = 0.0;
2042 if (!found || dist < mindist)
2044 edge =
static_cast<INDEX
>(*bi);
2054 template <
class INDEX>
2058 "Must call synchronize FACES_E on TetVolMesh first");
2061 double mindist = DBL_MAX;
2068 const double dist = (p - c).length2();
2069 if (!found || dist < mindist)
2072 face =
static_cast<INDEX
>(*bi);
2080 template <
class INDEX>
2090 if (sz == 0)
return (
false);
2093 if ((elem > 0)&&(elem < sz))
2095 if (
inside(elem,p))
return (
true);
2099 "TetVolMesh: need to synchronize ELEM_LOCATE_E first");
2108 elem =
static_cast<INDEX
>(*it);
2118 template <
class ARRAY>
2123 "TetVolMesh::locate_elems requires synchronize(ELEM_LOCATE_E).")
2139 for (;p<array.size();p++)
if (array[p] ==
typename ARRAY::value_type(*it))
break;
2140 if (p == array.size()) array.push_back(
typename ARRAY::value_type(*it));
2145 return (array.size() > 0);
2148 template <
class INDEX,
class ARRAY>
2158 if (sz == 0)
return (
false);
2161 if ((elem > 0)&&(elem < sz))
2166 basis_.get_coords(coords, p, ed);
2172 "TetVolMesh: need to synchronize ELEM_LOCATE_E first");
2181 elem =
static_cast<INDEX
>(*it);
2183 basis_.get_coords(coords, p, ed);
2193 template <
class INDEX>
2199 template <
class INDEX>
2211 template <
class INDEX>
2214 const double s = 1.0/3.0;
2226 template <
class INDEX>
2229 const double s = 0.25;
2257 template<
class INDEX>
2265 const double x0 = p0.
x();
2266 const double y0 = p0.
y();
2267 const double z0 = p0.
z();
2268 const double x1 = p1.
x();
2269 const double y1 = p1.
y();
2270 const double z1 = p1.
z();
2271 const double x2 = p2.
x();
2272 const double y2 = p2.
y();
2273 const double z2 = p2.
z();
2274 const double x3 = p3.
x();
2275 const double y3 = p3.
y();
2276 const double z3 = p3.
z();
2278 const double a0 = + x1*(y2*z3-y3*z2) + x2*(y3*z1-y1*z3) + x3*(y1*z2-y2*z1);
2279 const double a1 = - x2*(y3*z0-y0*z3) - x3*(y0*z2-y2*z0) - x0*(y2*z3-y3*z2);
2280 const double a2 = + x3*(y0*z1-y1*z0) + x0*(y1*z3-y3*z1) + x1*(y3*z0-y0*z3);
2281 const double a3 = - x0*(y1*z2-y2*z1) - x1*(y2*z0-y0*z2) - x2*(y0*z1-y1*z0);
2282 const double iV6 = 1.0 / (a0+a1+a2+a3);
2284 const double b0 = - (y2*z3-y3*z2) - (y3*z1-y1*z3) - (y1*z2-y2*z1);
2285 const double c0 = + (x2*z3-x3*z2) + (x3*z1-x1*z3) + (x1*z2-x2*z1);
2286 const double d0 = - (x2*y3-x3*y2) - (x3*y1-x1*y3) - (x1*y2-x2*y1);
2287 const double s0 = iV6 * (a0 + b0*p.
x() + c0*p.
y() + d0*p.
z());
2288 if (s0 < -1e-7)
return (
false);
2290 const double b1 = + (y3*z0-y0*z3) + (y0*z2-y2*z0) + (y2*z3-y3*z2);
2291 const double c1 = - (x3*z0-x0*z3) - (x0*z2-x2*z0) - (x2*z3-x3*z2);
2292 const double d1 = + (x3*y0-x0*y3) + (x0*y2-x2*y0) + (x2*y3-x3*y2);
2293 const double s1 = iV6 * (a1 + b1*p.
x() + c1*p.
y() + d1*p.
z());
2294 if (s1 < -1e-7)
return (
false);
2296 const double b2 = - (y0*z1-y1*z0) - (y1*z3-y3*z1) - (y3*z0-y0*z3);
2297 const double c2 = + (x0*z1-x1*z0) + (x1*z3-x3*z1) + (x3*z0-x0*z3);
2298 const double d2 = - (x0*y1-x1*y0) - (x1*y3-x3*y1) - (x3*y0-x0*y3);
2299 const double s2 = iV6 * (a2 + b2*p.
x() + c2*p.
y() + d2*p.
z());
2300 if (s2 < -1e-7)
return (
false);
2302 const double b3 = +(y1*z2-y2*z1) + (y2*z0-y0*z2) + (y0*z1-y1*z0);
2303 const double c3 = -(x1*z2-x2*z1) - (x2*z0-x0*z2) - (x0*z1-x1*z0);
2304 const double d3 = +(x1*y2-x2*y1) + (x2*y0-x0*y2) + (x0*y1-x1*y0);
2305 const double s3 = iV6 * (a3 + b3*p.
x() + c3*p.
y() + d3*p.
z());
2306 if (s3 < -1e-7)
return (
false);
2346 if (n2 < n1 && n2 < n3)
2351 t = n1; n1 = n2; n2 = n3; n3 = t;
2355 t = n1; n1 = n2; n2 = t;
2358 else if (n3 < n1 && n3 < n2)
2363 t = n1; n1 = n3; n3 = n2; n2 = t;
2367 t = n1; n1 = n3; n3 = t;
2373 t = n2; n2 = n3; n3 = t;
2487 template <
class PFACE>
2492 (
low_mask & static_cast<int>(f.nodes_[2])));
2496 template <
class PFACE>
2520 template <
class PEDGE>
2523 return (static_cast<int>(e.nodes_[0]) <<
sz_half_int) |
2524 (
low_mask &
static_cast<int>(e.nodes_[1]));
2528 template <
class PEDGE>
2538 #ifdef HAVE_HASH_MAP
2541 typedef stdext::hash_map<PFace, typename Face::index_type, FaceHash>
face_ht;
2542 typedef stdext::hash_map<PFaceNode, typename Face::index_type, FaceHash>
face_nt;
2543 typedef stdext::hash_map<PEdge, typename Edge::index_type, EdgeHash>
edge_ht;
2544 typedef stdext::hash_map<PEdgeNode, typename Edge::index_type, EdgeHash>
edge_nt;
2547 typedef hash_map<PFace, typename Face::index_type, FaceHash>
face_ht;
2548 typedef hash_map<PFaceNode, typename Face::index_type, FaceHash>
face_nt;
2549 typedef hash_map<PEdge, typename Edge::index_type, EdgeHash>
edge_ht;
2550 typedef hash_map<PEdgeNode, typename Edge::index_type, EdgeHash>
edge_nt;
2553 typedef std::map<PFace, typename Face::index_type, FaceHash>
face_ht;
2554 typedef std::map<PFaceNode, typename Face::index_type, FaceHash>
face_nt;
2555 typedef std::map<PEdge, typename Edge::index_type, EdgeHash>
edge_ht;
2556 typedef std::map<PEdgeNode, typename Edge::index_type, EdgeHash>
edge_nt;
2576 bool table_only =
false);
2591 bool table_only =
false);
2650 template <
class Basis>
2660 template <
class Basis>
2668 synchronize_lock_(
"TetVolMesh lock"),
2669 synchronize_cond_(
"TetVolMesh condition variable"),
2670 synchronized_(
Mesh::NODES_E |
Mesh::CELLS_E),
2681 template <
class Basis>
2690 synchronize_lock_(
"TetVolMesh lock"),
2691 synchronize_cond_(
"TetVolMesh condition variable"),
2692 synchronized_(
Mesh::NODES_E |
Mesh::CELLS_E),
2703 copy.synchronize_lock_.lock();
2715 copy.synchronize_lock_.unlock();
2723 template <
class Basis>
2729 template <
class Basis>
2730 template <
class Iter,
class Functor>
2734 synchronize_lock_.lock();
2736 points_.resize(end - begin);
2737 std::vector<Core::Geometry::Point>::iterator piter = points_.begin();
2740 *piter = fill_ftor(*iter);
2743 synchronize_lock_.unlock();
2746 template <
class Basis>
2747 template <
class Iter,
class Functor>
2751 synchronize_lock_.lock();
2753 cells_.resize((end - begin) * 4);
2754 std::vector<under_type>::iterator citer = cells_.begin();
2767 synchronize_lock_.unlock();
2770 template <
class Basis>
2775 template <
class Basis>
2779 ASSERT((n >= -1) && n <= 1);
2787 static const std::string nm(
"TetVolMesh");
2799 template <
class Basis>
2825 const double tmp =
v;
2829 else if (t + u + v > 1.0)
2831 const double tmp =
v;
2832 v = t + u + v - 1.0;
2837 const double a = 1.0 - t - u -
v;
2841 template <
class Basis>
2851 result.
extend(points_[*ni]);
2857 template <
class Basis>
2867 template <
class Basis>
2871 synchronize_lock_.lock();
2873 std::vector<Core::Geometry::Point>::iterator itr = points_.begin();
2874 std::vector<Core::Geometry::Point>::iterator eitr = points_.end();
2891 bbox_.extend(point(*ni));
2896 epsilon_ = bbox_.diagonal().length()*1e-8;
2897 epsilon2_ = epsilon_*epsilon_;
2898 epsilon3_ = epsilon_*epsilon_*epsilon_;
2900 synchronized_ |= BOUNDING_BOX_E;
2903 if (node_grid_) { node_grid_->transform(t); }
2904 if (elem_grid_) { elem_grid_->transform(t); }
2906 synchronize_lock_.unlock();
2909 template <
class Basis>
2918 typename face_nt::iterator iter = face_table_.find(f);
2920 if (iter == face_table_.end())
2922 ASSERTFAIL(
"this face did not exist in the table");
2927 index_type* cells = faces_[found_idx].cells_;
2935 face_table_.erase(iter);
2939 if (((faces_[found_idx].cells_[0])>>2) == ci)
2941 cells[0] = cells[1];
2944 else if (((faces_[found_idx].cells_[1])>>2) == ci)
2950 ASSERTFAIL(
"remove face: face does exist but is ");
2955 template <
class Basis>
2963 PFace f(n1, n2, n3);
2965 typename face_ht::iterator iter = table.find(f);
2966 if (iter == table.end())
2968 f.
cells_[0] = combined_index;
2973 PFace f = (*iter).first;
2976 std::cerr <<
"TetVolMesh - This Mesh has problems: Cells #"
2977 << (f.
cells_[0]>>2) <<
", #" << (f.
cells_[1]>>2) <<
", and #"
2978 << (combined_index>>2) <<
" are illegally adjacent." << std::endl;
2980 else if ((f.
cells_[0]>>2) == (combined_index>>2))
2982 std::cerr <<
"TetVolMesh - This Mesh has problems: Cells #"
2983 << (f.
cells_[0]>>2) <<
" and #" << (combined_index>>2)
2984 <<
" are the same." << std::endl;
2988 f.
cells_[1] = combined_index;
2995 template <
class Basis>
3000 begin(ci); end(cie);
3007 get_nodes(arr, *ci);
3011 hash_face(arr[0], arr[2], arr[1], cell_index, table);
3012 hash_face(arr[1], arr[2], arr[3], cell_index + 1, table);
3013 hash_face(arr[0], arr[1], arr[3], cell_index + 2, table);
3014 hash_face(arr[0], arr[3], arr[2], cell_index + 3, table);
3018 faces_.resize(table.size());
3020 typename face_ht::iterator ht_iter = table.begin();
3021 typename face_ht::iterator ht_iter_end = table.end();
3023 boundary_faces_.resize(cells_.size() >> 2);
3026 while (ht_iter != ht_iter_end)
3028 const PFace& pface = (*ht_iter).first;
3030 faces_[uidx].cells_[1] = pface.
cells_[1];
3033 if (pface.
cells_[1] == -1)
3037 boundary_faces_[cell] |= 1 << face;
3042 synchronize_lock_.lock();
3044 synchronize_lock_.unlock();
3050 template <
class Basis>
3059 typename face_nt::iterator nt_iter = face_table_.find(e);
3061 if (nt_iter == face_table_.end())
3064 face_table_[e] = uidx;
3066 faces_.push_back(c);
3067 faces_[uidx].
cells_[0] = combined_index;
3073 ASSERTFAIL(
"Face is in face_table_, but not in faces_ table");
3077 ASSERTFAIL(
"Adding a face that is already connected twice");
3080 faces_[nt_iter->second].cells_[1] = combined_index;
3084 template <
class Basis>
3091 if (n1 == n2)
return;
3093 typename edge_ht::iterator iter = table.find(e);
3095 if (iter == table.end())
3097 e.
cells_.push_back(combined_index);
3102 PEdge e = (*iter).first;
3103 e.
cells_.push_back(combined_index);
3109 template <
class Basis>
3114 begin(ci); end(cie);
3120 get_nodes(arr, *ci);
3122 hash_edge(arr[0], arr[1], cell_index ,table);
3123 hash_edge(arr[1], arr[2], cell_index+1,table);
3124 hash_edge(arr[2], arr[0], cell_index+2,table);
3125 hash_edge(arr[3], arr[0], cell_index+3,table);
3126 hash_edge(arr[3], arr[1], cell_index+4,table);
3127 hash_edge(arr[3], arr[2], cell_index+5,table);
3131 edges_.resize(table.size());
3133 typename edge_ht::iterator ht_iter = table.begin();
3134 typename edge_ht::iterator ht_iter_end = table.end();
3137 while (ht_iter != ht_iter_end)
3139 const PEdge& pedge = (*ht_iter).first;
3145 synchronize_lock_.lock();
3147 synchronize_lock_.unlock();
3150 template <
class Basis>
3156 typename edge_nt::iterator ht_iter = edge_table_.find(e);
3157 if (ht_iter == edge_table_.end())
3160 edge_table_[e] = uidx;
3162 edges_.push_back(c);
3163 edges_[uidx].
cells_.push_back(combined_index);
3167 edges_[ht_iter->second].cells_.push_back(combined_index);
3171 template <
class Basis>
3195 sync &= (~synchronized_);
3200 synchronize_lock_.unlock();
3202 synchronize_lock_.lock();
3208 boost::thread syncthread(syncclass);
3214 synchronize_lock_.unlock();
3216 synchronize_lock_.lock();
3222 boost::thread syncthread(syncclass);
3228 synchronize_lock_.unlock();
3230 synchronize_lock_.lock();
3236 boost::thread syncthread(syncclass);
3242 synchronize_lock_.unlock();
3244 synchronize_lock_.lock();
3250 boost::thread syncthread(syncclass);
3256 synchronize_lock_.unlock();
3258 synchronize_lock_.lock();
3264 boost::thread syncthread(syncclass);
3270 synchronize_lock_.unlock();
3272 synchronize_lock_.lock();
3278 boost::thread syncthread(syncclass);
3282 while ((synchronized_ & sync) != sync)
3284 synchronize_cond_.wait(lock);
3290 template <
class Basis>
3297 template <
class Basis>
3302 synchronize_lock_.lock();
3309 face_table_.clear();
3311 edge_table_.clear();
3312 node_neighbors_.clear();
3313 boundary_faces_.clear();
3318 synchronize_lock_.unlock();
3323 template <
class Basis>
3328 "Must call synchronize NODES_E on TetVolMesh first");
3332 template <
class Basis>
3337 "Must call synchronize NODES_E on TetVolMesh first");
3341 template <
class Basis>
3346 "Must call synchronize NODES_E on TetVolMesh first");
3350 template <
class Basis>
3355 "Must call synchronize EDGES_E on TetVolMesh first");
3359 template <
class Basis>
3364 "Must call synchronize EDGES_E on TetVolMesh first");
3365 itr =
static_cast<index_type>(edges_.size());
3368 template <
class Basis>
3373 "Must call synchronize EDGES_E on TetVolMesh first");
3377 template <
class Basis>
3382 "Must call synchronize FACES_E on TetVolMesh first");
3386 template <
class Basis>
3391 "Must call synchronize FACES_E on TetVolMesh first");
3392 itr =
static_cast<index_type>(faces_.size());
3395 template <
class Basis>
3400 "Must call synchronize FACES_E on TetVolMesh first");
3404 template <
class Basis>
3409 "Must call synchronize CELLS_E on TetVolMesh first");
3413 template <
class Basis>
3418 "Must call synchronize CELLS_E on TetVolMesh first");
3419 itr = cells_.size() >> 2;
3422 template <
class Basis>
3427 "Must call synchronize CELLS_E on TetVolMesh first");
3428 s =
static_cast<size_type>(cells_.size() >> 2);
3431 template <
class Basis>
3438 add_edge(arr[0], arr[1], cell_index);
3439 add_edge(arr[1], arr[2], cell_index+1);
3440 add_edge(arr[2], arr[0], cell_index+2);
3441 add_edge(arr[3], arr[0], cell_index+3);
3442 add_edge(arr[3], arr[1], cell_index+4);
3443 add_edge(arr[3], arr[2], cell_index+5);
3446 template <
class Basis>
3454 typename edge_nt::iterator iter = edge_table_.find(e);
3456 if (iter == edge_table_.end())
3458 ASSERTFAIL(
"this edge did not exist in the table");
3464 const std::vector<index_type>& cells = edges_[found_idx].cells_;
3465 if (cells.size() < 2)
3467 if ((cells[0] >>3) != ci)
3469 ASSERTFAIL(
"this edge does exist in the table but is not connected to this cell");
3471 edge_table_.erase(iter);
3472 if (!table_only) edges_[found_idx].cells_.clear();
3476 typename std::vector<index_type>::iterator citer = edges_[found_idx].cells_.begin();
3477 typename std::vector<index_type>::iterator citer_end = edges_[found_idx].cells_.end();
3480 while(citer != citer_end)
3482 if (((*citer)>>3)==cell_idx) {
3485 edges_[found_idx].cells_.erase(citer);
3486 citer = edges_[found_idx].cells_.begin();
3487 citer_end = edges_[found_idx].cells_.end();
3496 template <
class Basis>
3503 remove_edge(arr[0], arr[1], c, table_only);
3504 remove_edge(arr[1], arr[2], c, table_only);
3505 remove_edge(arr[2], arr[0], c, table_only);
3506 remove_edge(arr[3], arr[0], c, table_only);
3507 remove_edge(arr[3], arr[1], c, table_only);
3508 remove_edge(arr[3], arr[2], c, table_only);
3511 template <
class Basis>
3518 add_face(arr[0], arr[2], arr[1], cell_index);
3519 add_face(arr[1], arr[2], arr[3], cell_index+1);
3520 add_face(arr[0], arr[1], arr[3], cell_index+2);
3521 add_face(arr[0], arr[3], arr[2], cell_index+3);
3525 template <
class Basis>
3532 remove_face(arr[0], arr[2], arr[1], c, table_only);
3533 remove_face(arr[1], arr[2], arr[3], c, table_only);
3534 remove_face(arr[0], arr[1], arr[3], c, table_only);
3535 remove_face(arr[0], arr[3], arr[2], c, table_only);
3539 template <
class Basis>
3545 node_neighbors_[cells_[i]].push_back(i);
3550 template <
class Basis>
3557 typename std::vector<typename Cell::index_type>::iterator node_cells_end =
3558 node_neighbors_[
n].end();
3559 typename std::vector<typename Cell::index_type>::iterator cell =
3560 node_neighbors_[
n].begin();
3561 while (cell != node_cells_end && (*cell) != i) ++cell;
3564 ASSERT(cell != node_cells_end);
3566 node_neighbors_[
n].erase(cell);
3570 template <
class Basis>
3574 synchronize_lock_.lock();
3576 create_cell_node_neighbors(ci);
3578 create_cell_edges(ci);
3580 create_cell_faces(ci);
3582 insert_elem_into_grid(ci);
3583 synchronize_lock_.unlock();
3586 template <
class Basis>
3590 synchronize_lock_.lock();
3592 delete_cell_node_neighbors(ci);
3594 delete_cell_edges(ci);
3596 delete_cell_faces(ci);
3598 remove_elem_from_grid(ci);
3599 synchronize_lock_.unlock();
3602 template <
class Basis>
3606 synchronize_lock_.lock();
3608 create_cell_node_neighbors(ci);
3615 add_edge(arr[0], arr[1], cell_index);
3616 add_edge(arr[1], arr[2], cell_index+1);
3617 add_edge(arr[2], arr[0], cell_index+2);
3618 add_edge(arr[3], arr[0], cell_index+3);
3619 add_edge(arr[3], arr[1], cell_index+4);
3620 add_edge(arr[3], arr[2], cell_index+5);
3628 add_face(arr[0], arr[2], arr[1], cell_index);
3629 add_face(arr[1], arr[2], arr[3], cell_index+1);
3630 add_face(arr[0], arr[1], arr[3], cell_index+2);
3631 add_face(arr[0], arr[3], arr[2], cell_index+3);
3634 insert_elem_into_grid(ci);
3635 synchronize_lock_.unlock();
3638 template <
class Basis>
3642 synchronize_lock_.lock();
3644 delete_cell_node_neighbors(ci);
3646 delete_cell_edges(ci,
true);
3648 delete_cell_faces(ci,
true);
3650 remove_elem_from_grid(ci);
3651 synchronize_lock_.unlock();
3655 template <
class Basis>
3660 ASSERT(array.size() == 4);
3662 delete_cell_syncinfo(idx);
3665 cells_[idx * 4 +
n] = array[
n];
3667 create_cell_syncinfo(idx);
3670 template <
class Basis>
3674 node_neighbors_.clear();
3675 node_neighbors_.resize(points_.size());
3677 for (i = 0; i < num_cells; i++)
3679 node_neighbors_[cells_[i]].push_back(i);
3682 synchronize_lock_.lock();
3684 synchronize_lock_.unlock();
3687 template <
class Basis>
3703 template <
class Basis>
3712 std::vector<double> coords(3);
3713 if (get_coords(coords, p, idx))
3715 basis_.get_weights(coords, w);
3716 return basis_.dofs();
3722 template <
class Basis>
3731 box.
extend(points_[cells_[idx]]);
3732 box.
extend(points_[cells_[idx+1]]);
3733 box.
extend(points_[cells_[idx+2]]);
3734 box.
extend(points_[cells_[idx+3]]);
3736 elem_grid_->insert(ci, box);
3740 template <
class Basis>
3746 box.
extend(points_[cells_[idx]]);
3747 box.
extend(points_[cells_[idx+1]]);
3748 box.
extend(points_[cells_[idx+2]]);
3749 box.
extend(points_[cells_[idx+3]]);
3751 elem_grid_->remove(ci, box);
3754 template <
class Basis>
3760 node_grid_->insert(ni,points_[ni]);
3763 template <
class Basis>
3767 node_grid_->remove(ni,points_[ni]);
3770 template <
class Basis>
3781 3*
static_cast<size_type>((ceil(pow(static_cast<double>(esz) , (1.0/3.0))))/2.0 + 1.0);
3784 double trace = (diag.
x()+diag.
y()+diag.
z());
3793 begin(ci); end(cie);
3796 insert_elem_into_grid(*ci);
3801 synchronize_lock_.lock();
3803 synchronize_lock_.unlock();
3806 template <
class Basis>
3810 ASSERTMSG(bbox_.valid(),
"TetVolMesh BBox not valid");
3818 ((ceil(pow(static_cast<double>(esz) , (1.0/3.0))))/2.0 + 1.0);
3821 double trace = (diag.
x()+diag.
y()+diag.
z());
3830 begin(ni); end(nie);
3833 insert_node_into_grid(*ni);
3838 synchronize_lock_.lock();
3840 synchronize_lock_.unlock();
3843 template <
class Basis>
3863 bbox_.extend(point(*ni));
3868 epsilon_ = bbox_.diagonal().length()*1e-8;
3869 epsilon2_ = epsilon_*epsilon_;
3870 epsilon3_ = epsilon_*epsilon_*epsilon_;
3872 synchronize_lock_.lock();
3873 synchronized_ |= BOUNDING_BOX_E;
3874 synchronize_lock_.unlock();
3877 template <
class Basis>
3882 if (locate(i, p) && (points_[i] - p).length2() < epsilon2_)
3888 points_.push_back(p);
3891 synchronize_lock_.lock();
3892 node_neighbors_.push_back(std::vector<typename Cell::index_type>());
3893 synchronize_lock_.unlock();
3899 template <
class Basis>
3907 cells_.push_back(a);
3908 cells_.push_back(b);
3909 cells_.push_back(c);
3910 cells_.push_back(d);
3914 template <
class Basis>
3918 points_.push_back(p);
3923 template <
class Basis>
3928 return add_tet(add_find_point(p0), add_find_point(p1),
3929 add_find_point(p2), add_find_point(p3));
3932 template <
class Basis>
3945 if (
Dot(
Cross(p1-p0,p2-p0),p3-p0) >= 0.0)
3947 cells_.push_back(a);
3948 cells_.push_back(b);
3952 cells_.push_back(b);
3953 cells_.push_back(a);
3955 cells_.push_back(c);
3956 cells_.push_back(d);
3960 template <
class Basis>
3973 if (
Dot(
Cross(p1-p0,p2-p0),p3-p0) >= 0.0)
3987 template <
class Basis>
3991 synchronize_lock_.lock();
3992 std::set<index_type>::reverse_iterator iter = to_delete.rbegin();
3993 while (iter != to_delete.rend())
3998 std::vector<index_type>::iterator cb = cells_.begin() + ind;
3999 std::vector<index_type>::iterator ce = cb;
4001 cells_.erase(cb, ce);
4004 synchronized_ &= ~
Mesh::LOCATE_E;
4005 synchronized_ &= ~
Mesh::NODE_NEIGHBORS_E;
4008 synchronized_ &= ~
Mesh::FACES_E;
4013 synchronized_ &= ~
Mesh::EDGES_E;
4016 synchronize_lock_.unlock();
4019 template <
class Basis>
4023 synchronize_lock_.lock();
4024 std::set<index_type>::reverse_iterator iter = to_delete.rbegin();
4025 while (iter != to_delete.rend())
4028 std::vector<Core::Geometry::Point>::iterator pit = points_.begin() +
n;
4031 synchronized_ &= ~
Mesh::LOCATE_E;
4032 synchronized_ &= ~
Mesh::NODE_NEIGHBORS_E;
4035 synchronized_ &= ~
Mesh::FACES_E;
4040 synchronized_ &= ~
Mesh::EDGES_E;
4043 synchronize_lock_.unlock();
4046 template <
class Basis>
4053 if (!inside(ci, p))
return false;
4057 delete_cell_syncinfo_special(ci);
4061 tets[1] = add_tet_pos(cells_[index+0], cells_[index+3], cells_[index+1], pi);
4062 tets[2] = add_tet_pos(cells_[index+1], cells_[index+3], cells_[index+2], pi);
4063 tets[3] = add_tet_pos(cells_[index+0], cells_[index+2], cells_[index+3], pi);
4065 mod_tet_pos(ci, cells_[index+0], cells_[index+1], cells_[index+2], pi);
4067 create_cell_syncinfo_special(ci);
4068 create_cell_syncinfo_special(tets[1]);
4069 create_cell_syncinfo_special(tets[2]);
4070 create_cell_syncinfo_special(tets[3]);
4075 template <
class Basis>
4087 for (skip = 0; skip < 4; skip++)
4093 delete_cell_syncinfo_special(ci);
4099 tets.push_back(add_tet_pos(cells_[i+0], cells_[i+3], cells_[i+1], pi));
4100 tets.push_back(add_tet_pos(cells_[i+0], cells_[i+2], cells_[i+3], pi));
4101 mod_tet_pos(ci, cells_[i+0], cells_[i+1], cells_[i+2], pi);
4105 tets.push_back(add_tet_pos(cells_[i+0], cells_[i+3], cells_[i+1], pi));
4106 tets.push_back(add_tet_pos(cells_[i+1], cells_[i+3], cells_[i+2], pi));
4107 mod_tet_pos(ci, cells_[i+0], cells_[i+1], cells_[i+2], pi);
4111 tets.push_back(add_tet_pos(cells_[i+1], cells_[i+3], cells_[i+2], pi));
4112 tets.push_back(add_tet_pos(cells_[i+0], cells_[i+2], cells_[i+3], pi));
4113 mod_tet_pos(ci, cells_[i+0], cells_[i+1], cells_[i+2], pi);
4117 tets.push_back(add_tet_pos(cells_[i+0], cells_[i+3], cells_[i+1], pi));
4118 tets.push_back(add_tet_pos(cells_[i+1], cells_[i+3], cells_[i+2], pi));
4119 mod_tet_pos(ci, cells_[i+0], cells_[i+2], cells_[i+3], pi);
4122 create_cell_syncinfo_special(ci);
4123 create_cell_syncinfo_special(tets[tets.size()-2]);
4124 create_cell_syncinfo_special(tets[tets.size()-1]);
4128 template <
class Basis>
4142 if (skip1 == -1) skip1 = j;
4147 delete_cell_syncinfo_special(ci);
4149 bool pushed =
false;
4152 if (skip1 != 0 && skip2 != 0)
4155 tets.push_back(add_tet_pos(cells_[i+1], cells_[i+3], cells_[i+2], pi));
4158 if (skip1 != 1 && skip2 != 1)
4163 mod_tet_pos(ci, cells_[i+0], cells_[i+2], cells_[i+3], pi);
4167 tets.push_back(add_tet_pos(cells_[i+0], cells_[i+2], cells_[i+3], pi));
4171 if (skip1 != 2 && skip2 != 2)
4176 mod_tet_pos(ci, cells_[i+0], cells_[i+3], cells_[i+1], pi);
4180 tets.push_back(add_tet_pos(cells_[i+0], cells_[i+3], cells_[i+1], pi));
4184 if (skip1 != 3 && skip2 != 3)
4188 "insert_node_in_cell_edge::skip1 or skip2 were invalid.");
4189 mod_tet_pos(ci, cells_[i+0], cells_[i+1], cells_[i+2], pi);
4192 create_cell_syncinfo_special(ci);
4193 create_cell_syncinfo_special(tets[tets.size()-1]);
4196 template <
class Basis>
4210 const double aerr =
Abs(
Dot(
Cross(p1 - p0, p2 - p0), p3 - p0)) * 0.01;
4211 const double a0 =
Abs(
Dot(
Cross(p1 - p, p2 - p), p3 - p));
4212 const double a1 =
Abs(
Dot(
Cross(p - p0, p2 - p0), p3 - p0));
4213 const double a2 =
Abs(
Dot(
Cross(p1 - p0, p - p0), p3 - p0));
4214 const double a3 =
Abs(
Dot(
Cross(p1 - p0, p2 - p0), p - p0));
4217 if (a0 >= aerr && a0 >= epsilon3_) { mask |= 1; }
4218 if (a1 >= aerr && a1 >= epsilon3_) { mask |= 2; }
4219 if (a2 >= aerr && a2 >= epsilon3_) { mask |= 4; }
4220 if (a3 >= aerr && a3 >= epsilon3_) { mask |= 8; }
4224 if (mask == 15) {
return insert_node_in_cell(tets, ci, pi, p); }
4231 pi = cells_[ci*4 + 0];
4240 pi = cells_[ci*4 + 0];
4247 pi = cells_[ci*4 + 1];
4254 pi = cells_[ci*4 + 2];
4261 pi = cells_[ci*4 + 3];
4266 else if (mask == 3 || mask == 5 || mask == 6 ||
4267 mask == 9 || mask == 10 || mask == 12)
4273 etmp =
PEdgeNode(cells_[ci*4 + 0], cells_[ci*4 + 1]);
4278 etmp =
PEdgeNode(cells_[ci*4 + 0], cells_[ci*4 + 2]);
4283 etmp =
PEdgeNode(cells_[ci*4 + 1], cells_[ci*4 + 2]);
4288 etmp =
PEdgeNode(cells_[ci*4 + 0], cells_[ci*4 + 3]);
4290 else if (mask == 10)
4293 etmp =
PEdgeNode(cells_[ci*4 + 1], cells_[ci*4 + 3]);
4295 else if (mask == 12)
4298 etmp =
PEdgeNode(cells_[ci*4 + 2], cells_[ci*4 + 3]);
4301 typename edge_nt::iterator iter = edge_table_.find(etmp);
4303 const std::vector<index_type>& cells = edges_[iter->second].cells_;
4307 for (
size_t i = 0; i < cells.size(); i++)
4309 insert_node_in_edge(tets, pi, (cells[i]>>3), e);
4314 else if (mask == 7 || mask == 11 || mask == 13 || mask == 14)
4321 ftmp =
PFaceNode(cells_[ci*4 + 0], cells_[ci*4 + 1], cells_[ci*4 + 2]);
4323 else if (mask == 11)
4326 ftmp =
PFaceNode(cells_[ci*4 + 0], cells_[ci*4 + 1], cells_[ci*4 + 3]);
4328 else if (mask == 13)
4331 ftmp =
PFaceNode(cells_[ci*4 + 0], cells_[ci*4 + 2], cells_[ci*4 + 3]);
4333 else if (mask == 14)
4336 ftmp =
PFaceNode(cells_[ci*4 + 1], cells_[ci*4 + 2], cells_[ci*4 + 3]);
4339 typename face_nt::iterator iter = face_table_.find(ftmp);
4341 const PFaceCell& f = faces_[iter->second];
4347 insert_node_in_face(tets, pi, ci, n);
4350 insert_node_in_face(tets, pi, nbr_tet, n);
4357 template <
class Basis>
4367 const double sgn =
Dot(
Cross(p1-p0,p2-p0),p3-p0);
4371 cells_[ci*4+0] = cells_[ci*4+1];
4372 cells_[ci*4+1] = tmp;
4376 #define TETVOLMESH_VERSION 4
4378 template <
class Basis>
4382 const int version = stream.
begin_class(type_name(-1),
4390 std::vector<unsigned int> neighbors;
4403 synchronized_ = NODES_E | CELLS_E;
4409 template <
class Basis>
4419 std::string(__FILE__),
4426 template <
class Basis>
4427 const TypeDescription*
4433 template <
class Basis>
4443 std::string(__FILE__),
4450 template <
class Basis>
4460 std::string(__FILE__),
4467 template <
class Basis>
4477 std::string(__FILE__),
4484 template <
class Basis>
4494 std::string(__FILE__),
virtual ~TetVolMesh()
Destructor.
Definition: TetVolMesh.h:2724
index_type edge3_index() const
Definition: TetVolMesh.h:249
void get_center(Core::Geometry::Point &result, typename Cell::index_type idx) const
Definition: TetVolMesh.h:558
void get_nodes(typename Node::array_type &array, typename Cell::index_type idx) const
Definition: TetVolMesh.h:459
Interface to statically allocated std::vector class.
Definition: VUnstructuredMesh.h:41
void insert_node_in_face(typename Cell::array_type &tets, typename Node::index_type ni, typename Cell::index_type ci, const PFaceNode &pf)
Definition: TetVolMesh.h:4077
PEdge(typename Node::index_type n1, typename Node::index_type n2)
Definition: TetVolMesh.h:2464
std::vector< std::vector< typename Cell::index_type > > node_neighbors_
Definition: TetVolMesh.h:2601
void get_faces(typename Face::array_type &array, typename Cell::index_type idx) const
Definition: TetVolMesh.h:486
Elem::index_type add_tet(typename Node::index_type a, typename Node::index_type b, typename Node::index_type c, typename Node::index_type d)
Definition: TetVolMesh.h:3901
index_type edge1_index() const
Definition: TetVolMesh.h:239
bool reading() const
Definition: Persistent.h:164
Distinct type for node FieldIterator.
Definition: FieldIterator.h:89
double get_area(typename Face::index_type idx) const
Definition: TetVolMesh.h:595
void compute_bounding_box()
Definition: TetVolMesh.h:3845
void get_neighbors(typename Elem::array_type &array, typename Elem::index_type elem) const
Definition: TetVolMesh.h:619
void compute_node_neighbors()
Definition: TetVolMesh.h:3672
void get_cells(typename Cell::array_type &array, typename Edge::index_type idx) const
Definition: TetVolMesh.h:493
Definition: FieldRNG.h:37
void get_cells(typename Cell::array_type &array, typename Node::index_type idx) const
Definition: TetVolMesh.h:490
PEdgeNode(typename Node::index_type n1, typename Node::index_type n2)
Definition: TetVolMesh.h:2420
void get_faces(typename Face::array_type &array, typename Edge::index_type idx) const
Definition: TetVolMesh.h:479
std::string get_name(const std::string &type_sep_start="<", const std::string &type_sep_end="> ") const
Definition: TypeDescription.cc:135
static const TypeDescription * cell_type_description()
Definition: TetVolMesh.h:4486
size_t operator()(const PEDGE &e) const
This is the hash function.
Definition: TetVolMesh.h:2521
Distinct type for face Iterator.
Definition: FieldIterator.h:121
bool insert_node_in_cell(typename Cell::array_type &tets, typename Cell::index_type ci, typename Node::index_type &ni, const Core::Geometry::Point &p)
Always creates 4 tets, does not handle element boundaries properly.
Definition: TetVolMesh.h:4048
Definition: ConditionVariable.h:45
index_type edge0_index() const
the following designed to coordinate with ::get_edges
Definition: TetVolMesh.h:234
double inverse_jacobian(const VECTOR &coords, INDEX idx, double *Ji) const
Definition: TetVolMesh.h:772
Definition: TetVolMesh.h:194
void get_nodes(typename Node::array_type &array, typename Face::index_type idx) const
Definition: TetVolMesh.h:456
index_type node0_index() const
the following designed to coordinate with ::get_nodes
Definition: TetVolMesh.h:212
Point max() const
Definition: BBox.h:195
void get_point(Core::Geometry::Point &result, typename Node::index_type index) const
Access the nodes of the mesh.
Definition: TetVolMesh.h:648
SCIRun::index_type index_type
Definition: TetVolMesh.h:146
Definition: TetVolMesh.h:296
#define ASSERTMSG(condition, message)
Definition: Exception.h:113
virtual VMesh * vmesh()
Access point to virtual interface.
Definition: TetVolMesh.h:368
double epsilon3_
Definition: TetVolMesh.h:2625
bool get_elem_neighbor(INDEX1 &neighbor, INDEX1 elem, INDEX2 delem) const
Definition: TetVolMesh.h:1850
double Abs(double d)
Definition: MiscMath.h:369
void node_reserve(size_type s)
Definition: TetVolMesh.h:703
virtual int basis_order()
Definition: TetVolMesh.h:377
void get_face_center(Core::Geometry::Point &p, INDEX idx) const
Definition: TetVolMesh.h:2212
NodeIndex< under_type > index_type
Definition: TetVolMesh.h:155
void get_edges_from_node(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1698
FaceIndex< under_type > size_type
Definition: TetVolMesh.h:171
NodeIndex< under_type > size_type
Definition: TetVolMesh.h:157
static const TypeDescription * elem_type_description()
Definition: TetVolMesh.h:1398
const Core::Geometry::Point & point(typename Node::index_type i)
Definition: TetVolMesh.h:2255
Definition: Persistent.h:89
Edge information.
Definition: TetVolMesh.h:2461
bool locate(typename Edge::index_type &edge, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:626
bool locate_face(INDEX &face, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:2055
#define TETVOLMESH_VERSION
Definition: TetVolMesh.h:4376
Definition: TetVolMesh.h:2505
const Core::Geometry::Point & node2() const
Definition: TetVolMesh.h:275
void get_node_center(Core::Geometry::Point &p, INDEX idx) const
Definition: TetVolMesh.h:2194
bool clear_synchronization()
Definition: TetVolMesh.h:3299
Edge information.
Definition: TetVolMesh.h:2410
PFaceNode(typename Node::index_type n1, typename Node::index_type n2, typename Node::index_type n3)
Definition: TetVolMesh.h:2343
void insert_elem_into_grid(typename Elem::index_type ci)
Definition: TetVolMesh.h:3724
static const int low_mask
Definition: TetVolMesh.h:2517
index_type node3_index() const
Definition: TetVolMesh.h:227
int get_weights(const Core::Geometry::Point &, typename Edge::array_type &, double *)
Definition: TetVolMesh.h:641
static const int sz_third_int
These are for our own use (making the hash function).
Definition: TetVolMesh.h:2481
index_type node2_index() const
Definition: TetVolMesh.h:222
int compute_checksum(T *data, std::size_t length)
Definition: CheckSum.h:38
void mod_tet_pos(typename Elem::index_type tet, typename Node::index_type a, typename Node::index_type b, typename Node::index_type c, typename Node::index_type d)
Definition: TetVolMesh.h:3962
Basis & get_basis()
Get the basis class.
Definition: TetVolMesh.h:416
void get_normal(Core::Geometry::Vector &result, VECTOR &coords, INDEX1 eidx, INDEX2 fidx)
Get the normals at the outside of the element.
Definition: TetVolMesh.h:660
static const size_t bucket_size
These are needed by the hash_map particularly.
Definition: TetVolMesh.h:2510
double InverseMatrix3P(const PointVector &p, double *q)
Inline templated inverse matrix.
Definition: Locate.h:72
void remove_edge(typename Node::index_type n1, typename Node::index_type n2, typename Cell::index_type ci, bool table_only=false)
Definition: TetVolMesh.h:3448
void y(const double)
Definition: Point.h:135
void resize_nodes(size_type s)
Definition: TetVolMesh.h:705
void create_cell_edges(typename Cell::index_type)
Definition: TetVolMesh.h:3433
Definition: Persistent.h:187
Cell Elem
Definition: TetVolMesh.h:185
BBox & extend(const Point &p)
Expand the bounding box to include point p.
Definition: BBox.h:98
std::vector< Core::Geometry::Point > & get_points()
must detach, if altering points!
Definition: TetVolMesh.h:1479
void delete_cell_node_neighbors(typename Cell::index_type)
Definition: TetVolMesh.h:3552
PFaceNode()
3 nodes makes a face.
Definition: TetVolMesh.h:2336
Definition: TypeDescription.h:50
SCIRun::mask_type mask_type
Definition: TetVolMesh.h:148
T Dot(const ColumnMatrixGeneric< T > &a, const ColumnMatrixGeneric< T > &b)
Definition: ColumnMatrixFunctions.h:155
std::vector< PFaceCell > face_ct
Definition: TetVolMesh.h:2559
bool operator==(const PEdgeNode &e) const
true if both have the same nodes (order does not matter)
Definition: TetVolMesh.h:2436
Definition: TypeDescription.h:45
void get_edges(typename Edge::array_type &array, typename Cell::index_type idx) const
Definition: TetVolMesh.h:472
bool inside(INDEX idx, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:2258
#define SCISHARE
Definition: share.h:39
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
CellIndex< under_type > index_type
Definition: TetVolMesh.h:176
static const int up_mask
Definition: TetVolMesh.h:2482
void set_point(const Core::Geometry::Point &point, typename Node::index_type index)
Definition: TetVolMesh.h:650
static const TypeDescription * face_type_description()
Definition: TetVolMesh.h:4469
TetVolMesh< Basis >::index_type index_type
Definition: TetVolMesh.h:197
bool find_closest_nodes(ARRAY1 &distances, ARRAY2 &nodes, const Core::Geometry::Point &p, double maxdist) const
Definition: TetVolMesh.h:1065
void create_cell_syncinfo(typename Cell::index_type ci)
Definition: TetVolMesh.h:3572
EdgeIndex< under_type > size_type
Definition: TetVolMesh.h:164
boost::shared_ptr< Mesh > MeshHandle
Definition: DatatypeFwd.h:67
void pwl_approx_edge(std::vector< VECTOR > &coords, INDEX ci, unsigned which_edge, unsigned div_per_unit) const
Definition: TetVolMesh.h:532
PEdgeNode()
Definition: TetVolMesh.h:2414
NodeIterator< under_type > iterator
Definition: TetVolMesh.h:156
#define MESH_NO_NEIGHBOR
Definition: MeshTraits.h:67
void insert_node_into_grid(typename Node::index_type ci)
Definition: TetVolMesh.h:3756
Distinct type for cell Iterator.
Definition: FieldIterator.h:134
void delete_cell_syncinfo(typename Cell::index_type ci)
Definition: TetVolMesh.h:3588
bool shared() const
Definition: TetVolMesh.h:2457
unsigned int mask_type
Definition: Types.h:45
virtual int topology_geometry() const
Definition: TetVolMesh.h:385
double get_volume(typename Cell::index_type idx) const
Definition: TetVolMesh.h:597
bool operator()(const PFACE &f1, const PFACE &f2) const
This should return less than rather than equal to.
Definition: TetVolMesh.h:2497
bool operator<(const PEdgeNode &e) const
Definition: TetVolMesh.h:2443
Elem::index_type add_tet_pos(typename Node::index_type a, typename Node::index_type b, typename Node::index_type c, typename Node::index_type d)
Definition: TetVolMesh.h:3934
bool operator<(const PFaceNode &f) const
Definition: TetVolMesh.h:2389
void get_nodes(typename Node::array_type &array, typename Edge::index_type idx) const
Definition: TetVolMesh.h:453
bool locate_edge(INDEX &edge, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:2025
static const int low_mask
Definition: TetVolMesh.h:2484
void jacobian(const VECTOR &coords, INDEX idx, double *J) const
Definition: TetVolMesh.h:752
void get_nodes_from_edge(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1497
VMesh * CreateVTetVolMesh(MESH *)
Definition: TetVolMesh.h:83
#define ASSERT(condition)
Definition: Assert.h:110
TetVolMesh()
Construct a new mesh.
Definition: TetVolMesh.h:2661
double get_size(typename Node::index_type) const
Get the size of an element (length, area, volume)
Definition: TetVolMesh.h:562
void begin(typename Node::iterator &) const
begin/end iterators
Definition: TetVolMesh.h:3325
void set_nodes(typename Node::array_type &, typename Cell::index_type)
Definition: TetVolMesh.h:3657
void get_faces(typename Face::array_type &array, typename Node::index_type idx) const
Definition: TetVolMesh.h:476
bool locate_elems(ARRAY &array, const Core::Geometry::BBox &b) const
Definition: TetVolMesh.h:2119
void create_cell_syncinfo_special(typename Cell::index_type ci)
Definition: TetVolMesh.h:3604
bool get_coords(VECTOR &coords, const Core::Geometry::Point &p, INDEX idx) const
Definition: TetVolMesh.h:712
int compute_checksum()
Definition: TetVolMesh.h:2652
boost::shared_ptr< TetVolMesh< Basis > > handle_type
Definition: TetVolMesh.h:150
face_ct faces_
Definition: TetVolMesh.h:2566
virtual int begin_class(const std::string &name, int current_version)
Definition: Persistent.cc:143
void orient(typename Cell::index_type ci)
Orient a cell properly.
Definition: TetVolMesh.h:4359
virtual bool is_editable() const
Check whether mesh can be altered by adding nodes or elements.
Definition: TetVolMesh.h:399
double inscribed_circumscribed_radius_metric(INDEX idx) const
Definition: TetVolMesh.h:839
void get_elem_neighbors(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1893
void get_edges(typename Edge::array_type &array, typename Edge::index_type idx) const
Definition: TetVolMesh.h:466
virtual void get_canonical_transform(Core::Geometry::Transform &t) const
Definition: TetVolMesh.h:2859
void get_elems(typename Elem::array_type &array, typename Cell::index_type idx) const
Definition: TetVolMesh.h:512
FaceIterator< under_type > iterator
Definition: TetVolMesh.h:170
std::vector< index_type > array_type
Definition: TetVolMesh.h:179
Definition: TetVolMesh.h:161
void get_node_neighbors(ARRAY &array, INDEX node) const
We should optimize this function more.
Definition: TetVolMesh.h:1914
void add_face(typename Node::index_type n1, typename Node::index_type n2, typename Node::index_type n3, index_type combined_index)
Definition: TetVolMesh.h:3052
void get_edge_center(Core::Geometry::Point &p, INDEX idx) const
Definition: TetVolMesh.h:2200
boost::unique_lock< boost::mutex > UniqueLock
Definition: ConditionVariable.h:43
void to_index(typename Node::index_type &index, index_type i) const
Definition: TetVolMesh.h:440
index_type edge4_index() const
Definition: TetVolMesh.h:254
double DetMatrix3P(const VectorOfPoints &p)
Inline templated determinant of matrix.
Definition: Locate.h:120
const string find_type_name(float *)
Definition: TypeName.cc:63
void z(const double)
Definition: Point.h:145
void elem_reserve(size_type s)
Definition: TetVolMesh.h:704
void get_cell_center(Core::Geometry::Point &p, INDEX idx) const
Definition: TetVolMesh.h:2227
friend class VTetVolMesh
Make sure the virtual interface has access.
Definition: TetVolMesh.h:139
void get_edges_from_cell(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1595
void remove_node_from_grid(typename Node::index_type ci)
Definition: TetVolMesh.h:3765
void create_cell_faces(typename Cell::index_type)
Definition: TetVolMesh.h:3513
std::map< PEdge, typename Edge::index_type, EdgeHash > edge_ht
Definition: TetVolMesh.h:2555
void get_delems(typename DElem::array_type &array, typename Edge::index_type idx) const
Definition: TetVolMesh.h:519
void get_edges_from_face(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1556
bool insert_node_in_elem(typename Elem::array_type &tets, typename Node::index_type &ni, typename Elem::index_type ci, const Core::Geometry::Point &p)
Definition: TetVolMesh.h:4198
void get_cells_from_node(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1686
bool find_closest_node(double &pdist, Core::Geometry::Point &result, INDEX &node, const Core::Geometry::Point &p, double maxdist) const
Definition: TetVolMesh.h:895
Node::index_type add_node(const Core::Geometry::Point &p)
Definition: TetVolMesh.h:686
edge_ct edges_
Definition: TetVolMesh.h:2570
virtual Core::Geometry::BBox get_bounding_box() const
Get the bounding box of the field.
Definition: TetVolMesh.h:2843
std::map< PFaceNode, typename Face::index_type, FaceHash > face_nt
Definition: TetVolMesh.h:2554
virtual bool unsynchronize(mask_type mask)
Definition: TetVolMesh.h:3292
void set_nodes_by_elem(ARRAY &array, INDEX idx)
Definition: TetVolMesh.h:1843
Definition: VMeshShared.h:40
static const int mid_mask
Definition: TetVolMesh.h:2483
std::vector< under_type > cells_
each 4 indicies make up a tet
Definition: TetVolMesh.h:2315
Definition: ParallelLinearAlgebraTests.cc:358
ElemData(const TetVolMesh< Basis > &msh, const index_type ind)
Definition: TetVolMesh.h:199
static const size_t min_buckets
Definition: TetVolMesh.h:2478
static const int sz_int
These are for our own use (making the hash function.
Definition: TetVolMesh.h:2514
Definition: SearchGridT.h:47
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, ARRAY &coords, INDEX &elem, const Core::Geometry::Point &p, double maxdist) const
Find the closest element to a point.
Definition: TetVolMesh.h:1144
void remove_face(typename Node::index_type n1, typename Node::index_type n2, typename Node::index_type n3, typename Cell::index_type ci, bool table_only=false)
Definition: TetVolMesh.h:2911
const char * name[]
Definition: BoostGraphExampleTests.cc:87
void x(const double)
Definition: Point.h:125
void get_faces_from_edge(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1736
Definition: TetVolMesh.h:77
void Pio_index(Piostream &stream, index_type *data, size_type size)
Definition: Persistent.cc:606
long long size_type
Definition: Types.h:40
void delete_nodes(std::set< index_type > &to_delete)
Definition: TetVolMesh.h:4021
void size(typename Node::size_type &) const
Get the iteration sizes.
Definition: TetVolMesh.h:3343
double scaled_jacobian_metric(INDEX idx) const
Definition: TetVolMesh.h:781
void get_faces(typename Face::array_type &array, typename Face::index_type idx) const
Definition: TetVolMesh.h:483
Node::index_type add_point(const Core::Geometry::Point &p)
Add a new node to the mesh.
Definition: TetVolMesh.h:3916
Definition: StackVector.h:50
void resize_elems(size_type s)
Definition: TetVolMesh.h:706
virtual int dimensionality() const
Topological dimension.
Definition: TetVolMesh.h:380
double get_epsilon() const
Definition: TetVolMesh.h:407
Vector Cross(const Vector &v1, const Vector &v2)
Definition: Vector.h:378
SCIRun::size_type size_type
Definition: TetVolMesh.h:147
static const int up_mask
Definition: TetVolMesh.h:2516
boost::shared_ptr< VMesh > vmesh_
Pointer to virtual interface.
Definition: TetVolMesh.h:2628
void interpolate(Core::Geometry::Point &pt, const VECTOR &coords, INDEX idx) const
Definition: TetVolMesh.h:721
std::vector< PEdgeCell > edge_ct
Definition: TetVolMesh.h:2560
CellIterator< under_type > iterator
Definition: TetVolMesh.h:177
Vector diagonal() const
Definition: BBox.h:198
double det_jacobian(const VECTOR &coords, INDEX idx) const
Definition: TetVolMesh.h:740
size_t operator()(const PFACE &f) const
This is the hash function.
Definition: TetVolMesh.h:2488
bool get_neighbor(typename Elem::index_type &neighbor, typename Elem::index_type elem, typename DElem::index_type delem) const
Get neighbors of an element or a node.
Definition: TetVolMesh.h:606
std::map< PEdgeNode, typename Edge::index_type, EdgeHash > edge_nt
Definition: TetVolMesh.h:2556
void insert_node_in_edge(typename Cell::array_type &tets, typename Node::index_type ni, typename Cell::index_type ci, const PEdgeNode &e)
Definition: TetVolMesh.h:4130
Persistent i/o for STL containers.
std::vector< INDEX >::iterator iterator
Definition: SearchGridT.h:53
std::string type
Definition: Persistent.h:72
StackVector< index_type, 4 > array_type
Definition: TetVolMesh.h:158
static const TypeDescription * node_type_description()
Definition: TetVolMesh.h:4435
void to_index(typename Cell::index_type &index, index_type i) const
Definition: TetVolMesh.h:446
void compute_node_grid()
Definition: TetVolMesh.h:3808
static const int sz_half_int
Definition: TetVolMesh.h:2515
Point min() const
Definition: BBox.h:192
Distinct type for face index.
Definition: FieldIndex.h:90
PFace(typename Node::index_type n1, typename Node::index_type n2, typename Node::index_type n3)
Definition: TetVolMesh.h:2404
void fill_neighbors(Iter begin, Iter end, Functor fill_ftor)
Definition: TetVolMesh.h:168
void get_edges(typename Edge::array_type &array, typename Node::index_type idx) const
Definition: TetVolMesh.h:463
static const std::string type_name(int n=-1)
Core functionality for getting the name of a templated mesh class.
Definition: TetVolMesh.h:2777
void get_elems(typename Elem::array_type &array, typename Face::index_type idx) const
Definition: TetVolMesh.h:509
Basis basis_type
Definition: TetVolMesh.h:151
void x(double)
Definition: Vector.h:175
bool operator()(const PEDGE &e1, const PEDGE &e2) const
This should return less than rather than equal to.
Definition: TetVolMesh.h:2529
bool get_elem_neighbors(ARRAY &array, INDEX1 elem, INDEX2 delem) const
Definition: TetVolMesh.h:1870
void closest_point_on_tri(Point &result, const Point &orig, const Point &p0, const Point &p1, const Point &p2, const double epsilon)
Definition: CompGeom.cc:136
double get_length(typename Edge::index_type idx) const
More specific names for get_size.
Definition: TetVolMesh.h:593
double epsilon_
Definition: TetVolMesh.h:2623
Face information.
Definition: TetVolMesh.h:2318
void fill_cells(Iter begin, Iter end, Functor fill_ftor)
Definition: TetVolMesh.h:2749
virtual bool synchronize(mask_type mask)
Definition: TetVolMesh.h:3173
Node::index_type nodes_[2]
Definition: TetVolMesh.h:2412
static PersistentTypeID tetvolmesh_typeid
This ID is created as soon as this class will be instantiated.
Definition: TetVolMesh.h:1385
bool locate(typename Cell::index_type &cell, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:630
void get_center(Core::Geometry::Point &result, typename Edge::index_type idx) const
Definition: TetVolMesh.h:554
Core::Thread::ConditionVariable synchronize_cond_
Definition: TetVolMesh.h:2614
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
index_type edge2_index() const
Definition: TetVolMesh.h:244
v
Definition: readAllFields.py:42
std::vector< index_type > cells_
list of all the cells this edge is in.
Definition: TetVolMesh.h:2455
void end(typename Node::iterator &) const
Definition: TetVolMesh.h:3334
mask_type synchronized_
Definition: TetVolMesh.h:2617
double normalize()
Definition: Vector.h:437
boost::shared_ptr< SearchGridT< index_type > > elem_grid_
Definition: TetVolMesh.h:2610
double jacobian_metric(INDEX idx) const
Definition: TetVolMesh.h:816
std::map< PFace, typename Face::index_type, FaceHash > face_ht
Definition: TetVolMesh.h:2553
void get_cells_from_face(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1825
face_nt face_table_
Definition: TetVolMesh.h:2567
void run()
Definition: TetVolMesh.h:307
void y(double)
Definition: Vector.h:185
void get_faces_from_node(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1772
double distance_to_line2(const Point &p, const Point &a, const Point &b, const double epsilon)
Definition: CompGeom.cc:53
void compute_faces()
Definition: TetVolMesh.h:2997
Definition: TetVolMesh.h:2471
Distinct type for edge Iterator.
Definition: FieldIterator.h:105
bool locate(typename Elem::index_type &elem, std::vector< double > &coords, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:633
#define ASSERTFAIL(string)
Definition: Assert.h:52
virtual TetVolMesh * clone() const
Definition: TetVolMesh.h:362
void Pio(Piostream &stream, Array1< T > &array)
Definition: Array1.h:65
Some convenient simple iterators for fields.
bool get_neighbors(std::vector< typename Elem::index_type > &array, typename Elem::index_type elem, typename DElem::index_type delem) const
Definition: TetVolMesh.h:615
index_type node1_index() const
Definition: TetVolMesh.h:217
bool locate(typename Node::index_type &node, const Core::Geometry::Point &p) const
return false if point is out of range.
Definition: TetVolMesh.h:624
index_type cells_[2]
Definition: TetVolMesh.h:2328
void get_nodes(typename Node::array_type &array, typename Node::index_type idx) const
Get the child topology elements of the given topology.
Definition: TetVolMesh.h:450
void get_center(Core::Geometry::Point &result, typename Node::index_type idx) const
get the center point (in object space) of an element
Definition: TetVolMesh.h:552
void get_center(Core::Geometry::Point &result, typename Face::index_type idx) const
Definition: TetVolMesh.h:556
Definition: TetVolMesh.h:175
bool find_closest_node(double &pdist, Core::Geometry::Point &result, INDEX &node, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:888
void delete_cell_faces(typename Cell::index_type, bool table_only=false)
Definition: TetVolMesh.h:3527
double get_size(typename Edge::index_type idx) const
Definition: TetVolMesh.h:565
virtual void end_class()
Definition: Persistent.cc:178
std::vector< index_type > array_type
Definition: TetVolMesh.h:172
bool find_closest_nodes(ARRAY &nodes, const Core::Geometry::Point &p, double maxdist) const
Definition: TetVolMesh.h:1000
FaceIndex< under_type > index_type
Definition: TetVolMesh.h:169
void get_cells_from_edge(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1816
EdgeIterator< under_type > iterator
Definition: TetVolMesh.h:163
static Persistent * maker()
This function returns a maker for Pio.
Definition: TetVolMesh.h:1402
const Core::Geometry::Point & node3() const
Definition: TetVolMesh.h:280
const Core::Geometry::Point & node0() const
Definition: TetVolMesh.h:265
std::vector< index_type > array_type
Definition: TetVolMesh.h:165
void get_elems(typename Elem::array_type &array, typename Node::index_type idx) const
Definition: TetVolMesh.h:503
static MeshHandle mesh_maker()
This function returns a handle for the virtual interface.
Definition: TetVolMesh.h:1404
Definition: TetVolMesh.h:2452
long long index_type
Definition: Types.h:39
EdgeIndex< under_type > index_type
Definition: TetVolMesh.h:162
void get_edges(typename Edge::array_type &array, typename Face::index_type idx) const
Definition: TetVolMesh.h:469
Face DElem
Definition: TetVolMesh.h:186
void resize(size_t size, const value_type &val=value_type())
Definition: StackVector.h:61
Definition: TetVolMesh.h:2331
void get_nodes_from_face(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1518
void pwl_approx_face(std::vector< std::vector< VECTOR > > &coords, INDEX ci, unsigned which_face, unsigned div_per_unit) const
Definition: TetVolMesh.h:543
void delete_cell_syncinfo_special(typename Cell::index_type ci)
Definition: TetVolMesh.h:3640
std::vector< Core::Geometry::Point > points_
all the nodes.
Definition: TetVolMesh.h:2312
void get_cells(typename Cell::array_type &array, typename Cell::index_type idx) const
Definition: TetVolMesh.h:499
virtual const TypeDescription * get_type_description() const
Definition: TetVolMesh.h:4428
void operator()()
Definition: TetVolMesh.h:302
bool locate_elem(INDEX &elem, ARRAY &coords, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:2149
void create_cell_node_neighbors(typename Cell::index_type)
Definition: TetVolMesh.h:3541
void fill_points(Iter begin, Iter end, Functor fill_ftor)
Definition: TetVolMesh.h:2732
void get_delems(typename DElem::array_type &array, typename Face::index_type idx) const
Definition: TetVolMesh.h:522
void reset()
Definition: BBox.h:95
bool shared() const
Definition: TetVolMesh.h:2326
const Core::Geometry::Point & node1() const
Definition: TetVolMesh.h:270
edge_nt edge_table_
Definition: TetVolMesh.h:2571
Core::Geometry::BBox bbox_
Definition: TetVolMesh.h:2621
Definition: Persistent.h:64
void get_faces_from_cell(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1656
index_type edge5_index() const
Definition: TetVolMesh.h:259
void to_index(typename Edge::index_type &index, index_type i) const
Definition: TetVolMesh.h:442
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, ARRAY &coords, INDEX &elem, const Core::Geometry::Point &p) const
Find the closest element to a point.
Definition: TetVolMesh.h:1132
bool locate_node(INDEX &node, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:1936
double epsilon2_
Definition: TetVolMesh.h:2624
void fill_data(Iter begin, Iter end, Functor fill_ftor)
MeshFacadeHandle getFacade() const
Definition: TetVolMesh.h:370
Distinct type for edge index.
Definition: FieldIndex.h:81
Node::index_type nodes_[3]
Definition: TetVolMesh.h:2334
int n
Definition: eab.py:9
int get_weights(const Core::Geometry::Point &p, typename Node::array_type &l, double *w)
Definition: TetVolMesh.h:3705
Core::Thread::Mutex synchronize_lock_
Definition: TetVolMesh.h:2613
bool locate_elem(INDEX &elem, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:2081
double get_size(typename Face::index_type idx) const
Definition: TetVolMesh.h:575
std::vector< unsigned char > boundary_faces_
Definition: TetVolMesh.h:2602
bool find_closest_elems(double &, Core::Geometry::Point &, ARRAY &, const Core::Geometry::Point &) const
Find the closest elements to a point.
Definition: TetVolMesh.h:1371
Definition: TetVolMesh.h:2401
void compute_edges()
Definition: TetVolMesh.h:3111
int get_weights(const Core::Geometry::Point &, typename Face::array_type &, double *)
Definition: TetVolMesh.h:643
void remove_elem_from_grid(typename Elem::index_type ci)
Definition: TetVolMesh.h:3742
Synchronize(TetVolMesh< Basis > *mesh, mask_type sync)
Definition: TetVolMesh.h:299
void compute_elem_grid()
Definition: TetVolMesh.h:3772
static const size_t min_buckets
Definition: TetVolMesh.h:2511
bool locate(typename Face::index_type &face, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:628
void get_nodes_from_elem(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1550
mask_type synchronizing_
Definition: TetVolMesh.h:2619
#define DEBUG_CONSTRUCTOR(type)
Definition: Debug.h:64
void delete_cell_edges(typename Cell::index_type, bool table_only=false)
Definition: TetVolMesh.h:3498
void get_neighbors(std::vector< typename Node::index_type > &array, typename Node::index_type node) const
These are more general implementations.
Definition: TetVolMesh.h:612
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, INDEX &elem, const Core::Geometry::Point &p) const
Definition: TetVolMesh.h:1362
void io(Piostream &stream)
Persistent I/O.
Definition: Mesh.cc:387
void delete_cells(std::set< index_type > &to_delete)
Deleting cells, make sure mesh is detached.
Definition: TetVolMesh.h:3989
void get_elems(typename Elem::array_type &array, typename Edge::index_type idx) const
Definition: TetVolMesh.h:506
virtual std::string dynamic_type_name() const
Definition: TetVolMesh.h:1389
void hash_edge(typename Node::index_type n1, typename Node::index_type n2, index_type combined_index, edge_ht &table)
Definition: TetVolMesh.h:3086
virtual void io(Piostream &)
Export this class using the old Pio system.
Definition: TetVolMesh.h:4380
virtual bool has_normals() const
Has this mesh normals.
Definition: TetVolMesh.h:402
double get_size(typename Elem::index_type idx) const
Definition: TetVolMesh.h:586
void get_nodes_from_cell(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1539
static const int sz_int
Definition: TetVolMesh.h:2470
void add_edge(typename Node::index_type n1, typename Node::index_type n2, index_type combined_index)
Definition: TetVolMesh.h:3152
static const size_t bucket_size
Definition: TetVolMesh.h:2477
void z(double)
Definition: Vector.h:195
boost::shared_ptr< MeshFacade< VMesh > > MeshFacadeHandle
Definition: MeshTraits.h:61
Elem::index_type add_elem(ARRAY a)
Add a new element to the mesh.
Definition: TetVolMesh.h:691
void get_random_point(Core::Geometry::Point &p, typename Elem::index_type i, FieldRNG &r) const
Definition: TetVolMesh.h:2801
Index and Iterator types required for Mesh Concept.
Definition: TetVolMesh.h:154
virtual bool has_face_normals() const
Has this mesh face normals.
Definition: TetVolMesh.h:405
boost::shared_ptr< SearchGridT< index_type > > node_grid_
Definition: TetVolMesh.h:2609
PFaceCell()
Definition: TetVolMesh.h:2320
static const TypeDescription * edge_type_description()
Definition: TetVolMesh.h:4452
bool operator==(const PFaceNode &f) const
true if both have the same nodes (order does not matter)
Definition: TetVolMesh.h:2381
SCIRun::index_type under_type
Definition: TetVolMesh.h:145
void hash_face(typename Node::index_type n1, typename Node::index_type n2, typename Node::index_type n3, index_type ci, face_ht &table)
Definition: TetVolMesh.h:2957
CellIndex< under_type > size_type
Definition: TetVolMesh.h:178
void get_delems(typename DElem::array_type &array, typename Node::index_type idx) const
Definition: TetVolMesh.h:516
void derivate(const VECTOR1 &coords, INDEX idx, VECTOR2 &J) const
Definition: TetVolMesh.h:731
virtual void transform(const Core::Geometry::Transform &t)
Core::Geometry::Transform a field (transform all nodes using this transformation matrix) ...
Definition: TetVolMesh.h:2869
void get_delems(typename DElem::array_type &array, typename Cell::index_type idx) const
Definition: TetVolMesh.h:525
int size
Definition: eabLatVolData.py:2
Basis basis_
Definition: TetVolMesh.h:2622
void get_edges_from_elem(ARRAY &array, INDEX idx) const
Definition: TetVolMesh.h:1650
void to_index(typename Face::index_type &index, index_type i) const
Definition: TetVolMesh.h:444
Node::index_type add_find_point(const Core::Geometry::Point &p, double err=1.0e-6)
Definition: TetVolMesh.h:3879
void get_normal(Core::Geometry::Vector &, typename Node::index_type) const
Normals for visualizations.
Definition: TetVolMesh.h:655
#define DEBUG_DESTRUCTOR(type)
Definition: Debug.h:65
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209
bool elem_locate(INDEX &elem, MESH &msh, const Core::Geometry::Point &p)
General case locate, search each elem.
Definition: Mesh.h:188
void get_cells(typename Cell::array_type &array, typename Face::index_type idx) const
Definition: TetVolMesh.h:496