23 ncdata =
new double [3 *
n];
35 if((n > 0) && (data != NULL)){
63 ncdata =
new double [3 *
n];
80 this->
x(n) = point.
x();
81 this->
y(n) = point.
y();
82 this->
z(n) = point.
z();
87 double dist = 1000000;
91 double testd = (p-testp).
norm();
102 double dist = 1000000;
106 double testd = (p-testp).
norm();
124 std::memcpy(
ncdata,data,n*
sizeof(
double)*3);
131 std::vector<Mesh::IndexType> &candidates,
132 std::vector<Mesh::IndexType> &cells)
134 std::vector<IndexType>::iterator ci = candidates.begin();
135 while(ci != candidates.end()){
136 unsigned int cell_id = *ci++;
137 unsigned int esize = conn.
Esize(cell_id);
138 std::vector<GeoPrim::CPoint> element_points(esize);
142 element_points[
node-1] = ep;
149 cells.push_back(cell_id);
157 std::vector<Mesh::IndexType> &cells)
159 unsigned int nelem = conn.size();
162 unsigned int esize = conn.
Esize(n);
163 std::vector<GeoPrim::CPoint> element_points(esize);
167 element_points[
node-1] = ep;
182 std::vector<double> ¢roids)
184 unsigned int nelem = conn.size();
185 centroids.resize(3*nelem,0.0);
186 for(
int i = 0;
i < nelem;
i++){
201 if(nc.x(nn) < bnds[0])
203 if(nc.x(nn) > bnds[1])
205 if(nc.y(nn) < bnds[2])
207 if(nc.y(nn) > bnds[3])
209 if(nc.z(nn) < bnds[4])
211 if(nc.z(nn) > bnds[5])
219 return(IRAD::Util::LessThan(*
this,f));
226 std::vector<std::vector<Mesh::IndexType> >(*this).swap(*
this);
231 std::vector<std::vector<Mesh::IndexType> >(*this).swap(*
this);
238 this->push_back(elem);
243 std::vector<IndexType> a;
249 _nelem = this->size();
250 Connectivity::iterator ti = this->begin();
251 while(ti != this->end()){
252 std::vector<Mesh::IndexType>(*ti).swap(*ti);
255 std::vector<std::vector<Mesh::IndexType> >(*this).swap(*
this);
259 Connectivity::iterator ti = this->begin();
260 while(ti != this->end()){
262 ti = this->erase(ti);
271 Connectivity::iterator ti = this->begin();
272 while(ti != this->end()){
274 std::vector<IndexType> tmp(*ti);
279 std::vector<std::vector<IndexType> >(*this).swap(*
this);
282 _sizes.resize(_nelem);
284 _sizes[
i] = (*this)[
i].size();
296 nnodes = MaxNodeId<Connectivity,std::vector<IndexType> >(*this);
300 if((*
this)[
i].size() > 1){
301 std::vector<IndexType>::const_iterator ii = (*this)[
i].begin();
302 while(ii != (*
this)[
i].end()){
303 rc[*ii-1].push_back(
i+1);
315 nnodes = MaxNodeId<Connectivity,std::vector<IndexType> >(*this);
329 std::vector<IndexType>::const_iterator ii = (*this)[
i].begin();
330 while(ii != (*
this)[
i].end()){
331 rc[*ii-1].push_back(
i+1);
346 fcon.reserve(nface_estimate);
347 sf.reserve(nface_estimate);
349 std::vector<Mesh::Connectivity> all_face_conn;
350 all_face_conn.resize(this->
Nelem());
356 element_being_processed <= number_of_elements;
357 element_being_processed++)
363 ef[index].resize(ge.
nfaces(),0);
372 element_being_processed <= number_of_elements;
373 element_being_processed++)
386 face_being_processed <= nfaces;
387 face_being_processed++){
389 if(!ef[index][findex]){
390 fcon.push_back(all_face_conn[index][findex]);
391 ef[index][findex] = number_of_faces + 1;
394 sf.push_back(std::make_pair(seid1,seid2));
395 sf[number_of_faces].first.first = element_being_processed;
396 sf[number_of_faces].first.second = face_being_processed;
402 std::vector<Mesh::IndexType>::iterator fni = fcon[number_of_faces].begin();
403 while(fni != fcon[number_of_faces].end() && !found){
405 std::vector<Mesh::IndexType>::iterator enbri = dc[face_node_index].begin();
406 while(enbri != dc[face_node_index].end() && !found){
408 if(enbr_index+1 > element_being_processed){
410 for(
Mesh::IndexType nbrface = 1;nbrface <= nbr_nfaces && !found;nbrface++){
412 if(!ef[enbr_index][nbr_face_index]){
413 if(IRAD::Util::HaveOppositeOrientation(all_face_conn[index][findex],
414 all_face_conn[enbr_index][nbr_face_index])){
416 ef[enbr_index][nbr_face_index] = number_of_faces + 1;
417 sf[number_of_faces].second.first = enbr_index+1;
418 sf[number_of_faces].second.second = nbr_face_index+1;
436 Connectivity::iterator ci = this->begin();
438 while(ci != this->end()){
439 ci->erase(std::lower_bound(ci->begin(),ci->end(),offset+n++));
446 Connectivity::iterator ci = this->begin();
448 while(ci != this->end()){
449 ci->insert(std::lower_bound(ci->begin(),ci->end(),offset+
n),1,offset+n);
463 std::vector<IndexType>::const_iterator
ni = (*this)[
i].begin();
464 while(ni != (*
this)[
i].end()){
466 std::vector<IndexType>::const_iterator dci = dc[index].begin();
467 while(dci != dc[index].end())
468 rl[
i].insert(*dci++);
483 std::vector<bool> added(
_nelem,
false);
486 std::vector<IndexType>::iterator
ni = (*this)[
i].begin();
487 std::list<IndexType> nbrlist;
488 while(ni != (*
this)[
i].end()){
490 std::vector<IndexType>::iterator dci = dc[index].begin();
491 while(dci != dc[index].end()){
494 nbrlist.push_back(*dci);
505 nbrlist.remove(current_element);
508 rl[
i].resize(nbrlist.size());
510 std::list<IndexType>::iterator si = nbrlist.begin();
511 while(si != nbrlist.end()){
513 added[*si-1] =
false;
529 std::cout <<
"GETADJACENT: Determining MaxNodeId" << std::endl;
530 nadj = MaxNodeId<Connectivity,std::vector<IndexType> >(dc);
532 std::vector<bool> added(nadj,
false);
535 std::vector<IndexType>::iterator
ni = (*this)[
i].begin();
536 std::list<IndexType> nbrlist;
537 while(ni != (*
this)[
i].end()){
539 std::vector<IndexType>::iterator dci = dc[index].begin();
540 while(dci != dc[index].end()){
543 nbrlist.push_back(*dci);
553 rl[
i].resize(nbrlist.size());
555 std::list<IndexType>::iterator si = nbrlist.begin();
556 while(si != nbrlist.end()){
558 added[*si-1] =
false;
571 std::vector<Mesh::IndexType> &subset)
573 std::list<Mesh::IndexType> alist;
574 std::vector<Mesh::IndexType>::iterator
ni = nodes.begin();
575 while(ni != nodes.end()){
577 std::vector<Mesh::IndexType>::iterator dci = dc[node_index].begin();
578 while(dci != dc[node_index].end())
579 alist.push_back(*dci++);
583 subset.resize(alist.size());
584 std::vector<Mesh::IndexType>::iterator ssi = subset.begin();
585 std::list<Mesh::IndexType>::iterator li = alist.begin();
586 while(li != alist.end())
600 remap[
i] = renumber++;
601 std::list<IndexType> processing_queue;
602 std::vector<IndexType>::iterator
ni = (*this)[
i].begin();
603 while(ni != (*
this)[
i].end()){
605 if(remap[index] == 0){
606 processing_queue.push_back(index);
607 remap[index] = renumber++;
610 std::list<IndexType>::iterator pqi = processing_queue.begin();
611 while(pqi != processing_queue.end()){
613 std::vector<IndexType>::iterator ini = (*this)[index].begin();
614 while(ini != (*
this)[index].end()){
616 if(remap[iindex] == 0){
617 processing_queue.push_back(iindex);
618 remap[iindex] = renumber++;
625 assert((renumber == (
_nelem+1)));
637 double scal = 1.0/(
static_cast<double>(esize));
638 return(centroid *= scal);
647 SF[0] = 1. - natc[0] - natc[1];
653 const double xi = natc[0];
654 const double xi_minus = 1. - xi;
655 const double eta = natc[1];
656 const double eta_minus = 1. - eta;
658 SF[0] = xi_minus * eta_minus;
659 SF[1] = xi * eta_minus;
661 SF[3] = xi_minus * eta;
665 std::cerr <<
"GenericCell_2::shape_func:Error: unkown element type."
678 Np[0][0] = -1; Np[0][1] = -1;
679 Np[1][0] = 1; Np[1][1] = 0;
680 Np[2][0] = 0; Np[2][1] = 1;
684 const double xi = natc[0];
685 const double xi_minus = 1. - xi;
686 const double eta = natc[1];
687 const double eta_minus = 1. - eta;
689 Np[0][0] = -eta_minus; Np[0][1] = -xi_minus;
690 Np[1][0] = eta_minus; Np[1][1] = -xi;
691 Np[2][0] = eta; Np[2][1] = xi;
692 Np[3][0] = -eta; Np[3][1] = xi_minus;
697 std::cerr <<
"GenericCell_2::dshape_func:error: Unknown element type."
709 J[0] = p[1]-p[0]; J[1] = p[2]-p[0];
712 const double xi = nc[0];
713 const double xi_minus = 1. - xi;
714 const double eta = nc[1];
715 const double eta_minus = 1. - eta;
716 J[0] = ((p[1]-p[0]) *= eta_minus) += (( p[2]-p[3]) *= eta );
717 J[1] = ((p[3]-p[0]) *= xi_minus) += (( p[2]-p[1]) *= xi);
721 const double xi = nc[0];
722 const double eta = nc[1];
723 const double zeta = 1.-xi-eta;
725 J[0] = ((p[1]-p[0]) *= 4.*xi -1.)
726 += ((p[3]-p[0]) *= 4.*zeta-4*xi)
727 += ((p[4]-p[5]) *= 4.*eta);
728 J[1] = ((p[2]-p[0]) *= 4.*eta -1.)
729 += ((p[5]-p[0]) *= 4*zeta-4*eta)
730 += ((p[4]-p[3]) *= 4.*xi);
734 const double xi = nc[0];
735 const double xi_minus = 1. - xi;
736 const double eta = nc[1];
737 const double eta_minus = 1. - eta;
739 J[0] = ((p[1]-p[0]) *= eta_minus) += ((p[2]-p[3]) *= eta)
740 -= ((((p[0]-p[4])+=(p[1]-p[4])) *= 2.*eta_minus*(xi_minus-xi))
741 += (((p[2]-p[6])+=(p[3]-p[6])) *= 2.*eta*(xi_minus-xi))
742 += (((p[1]-p[5])+=(p[2]-p[5])-=((p[0]-p[7])+=(p[3]-p[7])))
743 *= 2.*eta*eta_minus));
745 ((J[1] = p[3]-p[0]) *= xi_minus) += ((p[2]-p[1]) *= xi)
746 -= ((((p[1]-p[5])+=(p[2]-p[5])) *= 2.*xi*(eta_minus-eta))
747 += (((p[0]-p[7])+=(p[3]-p[7])) *= 2.*xi_minus*(eta_minus-eta))
748 += (((p[2]-p[6])+=(p[1]-p[4])-=((p[3]-p[6])+=(p[0]-p[4])))
765 P[i_minus] = nc[ec.
Node(elnum,i_minus+1)];
766 P[
i] = nc[ec.
Node(elnum,
i+1)];
768 P[i_plus] = nc[ec.
Node(elnum,i_plus+1)];
794 this->shape_func(natc,SF);
797 P[
i].init(nc[ec.Node(elnum,
i+1)]);
802 this->jacobian(P,natc,jac);
814 const double xi = nc.
x();
815 const double eta = nc.
y();
819 v += ((f[1]-f[0])*=xi) += ((f[2]-f[0])*=eta);
823 v += ((f[1]-f[0]) *= (xi * (1.-eta)))
824 += ((f[3]-f[0]) *= eta)
825 += ((f[2]-f[3]) *= xi*eta);
829 const double zeta=1.-xi-eta;
831 v += ((f[1]-f[0]) *= xi * (2.*xi-1.))
832 += ((f[3]-f[0]) *= 4.* xi * zeta)
833 += ((f[2]-f[0]) *= eta * (2.*eta-1.))
834 += ((f[5]-f[0]) *= 4. * eta * zeta)
835 += ((f[4]-f[0]) *= 4.*xi*eta);
839 const double xi_minus = 1. - xi;
840 const double eta_minus = 1. - eta;
841 v += ((f[1]-f[0]) *= eta * (2.*eta-1.))
842 += ((f[3]-f[0]) *= eta)
843 += ((f[2]-f[3]) *= xi * eta)
844 -= ((((f[0]-f[4])+=(f[1]-f[4])) *= 2.*xi*xi_minus*eta_minus)
845 += (((f[2]-f[6])+=(f[3]-f[6])) *= 2.*xi*xi_minus*eta)
846 += (((f[1]-f[5])+=(f[2]-f[5])) *= 2.*xi*eta*eta_minus)
847 += (((f[0]-f[7])+=(f[3]-f[7])) *= 2.*xi_minus*eta*eta_minus));
911 SF[0] = 1. - nc.
x() - nc.
y() - nc.
z();
918 const double xi = nc.
x();
919 const double eta = nc.
y();
920 const double zeta = nc.
z();
921 const double alpha = (1. - xi - eta - zeta);
922 SF[0] = alpha*(1. - 2.*(xi + eta + zeta));
923 SF[1] = xi *(2.* xi - 1.);
924 SF[2] = eta *(2. * eta - 1.);
925 SF[3] = zeta *(2. * zeta - 1.);
926 SF[4] = 4.* xi * alpha;
927 SF[5] = 4.* eta * alpha;
928 SF[6] = 4.* zeta * alpha;
929 SF[7] = 4. * xi * eta;
930 SF[8] = 4. * eta * zeta;
931 SF[9] = 4. * xi * zeta;
936 const double xi = nc.
x();
937 const double xi_minus = 1. - xi;
938 const double eta = nc.
y();
939 const double eta_minus = 1. - eta;
940 const double zeta = nc.
z();
941 const double zeta_minus = 1. - zeta;
942 SF[0] = xi_minus * eta_minus * zeta_minus;
943 SF[1] = xi * eta_minus * zeta_minus;
944 SF[2] = xi * eta * zeta_minus;
945 SF[3] = xi_minus * eta * zeta_minus;
946 SF[4] = xi_minus * eta_minus * zeta;
947 SF[5] = xi * eta_minus * zeta;
948 SF[6] = xi * eta * zeta;
949 SF[7] = xi_minus * eta * zeta;
953 std::cerr <<
"GenericElement::shape_func:Error: unkown element type."
966 dSF[0][0] = -1; dSF[0][1] = -1; dSF[0][2] = -1;
967 dSF[1][0] = 1; dSF[1][1] = 0; dSF[1][2] = 0;
968 dSF[2][0] = 0; dSF[2][1] = 1; dSF[2][2] = 0;
969 dSF[3][0] = 0; dSF[3][1] = 0; dSF[3][2] = 1;
973 const double xi = nc.
x();
974 const double eta = nc.
y();
975 const double zeta = nc.
z();
976 const double alpha = (1. - xi - eta - zeta);
977 dSF[0][0] = (4.*(xi+eta+zeta)-3.); dSF[0][1] = dSF[0][0]; dSF[0][2] = dSF[0][0];
978 dSF[1][0] = 4.*xi - 1.; dSF[1][1] = 0; dSF[1][2] = 0;
979 dSF[2][0] = 0; dSF[2][1] = 4.*eta - 1.; dSF[2][2] = 0;
980 dSF[3][0] = 0; dSF[3][1] = 0; dSF[3][2] = 4.*zeta - 1.;
981 dSF[4][0] = 4.*(alpha - xi); dSF[4][1] = -4.*xi; dSF[4][2] = -4.*xi;
982 dSF[5][0] = -4.*eta; dSF[5][1] = 4.*(alpha - eta); dSF[5][2] = -4.*eta;
983 dSF[6][0] = -4.*zeta; dSF[6][1] = -4.*zeta; dSF[6][2] = 4.*(alpha - zeta);
984 dSF[7][0] = 4.*eta; dSF[7][1] = 4.*xi; dSF[7][2] = 0;
985 dSF[8][0] = 0; dSF[8][1] = 4.*zeta; dSF[8][2] = 4.*eta;
986 dSF[9][0] = 4.*zeta; dSF[9][1] = 0; dSF[9][2] = 4.*xi;
990 const double xi = nc.
x();
991 const double xi_minus = 1. - xi;
992 const double eta = nc.
y();
993 const double eta_minus = 1. - eta;
994 const double zeta = nc.
z();
995 const double zeta_minus = 1. - zeta;
996 dSF[0][0] = -1.*eta_minus*zeta_minus; dSF[0][1] = -1.*xi_minus*zeta_minus; dSF[0][2] = -1.*xi_minus*eta_minus;
997 dSF[1][0] = eta_minus*zeta_minus; dSF[1][1] = -1.*xi*zeta_minus; dSF[1][2] = -1.*xi*eta_minus;
998 dSF[2][0] = eta*zeta_minus; dSF[2][1] = xi*zeta_minus; dSF[2][2] = -1.*xi*eta;
999 dSF[3][0] = -1.*eta*zeta_minus; dSF[3][1] = xi_minus*zeta_minus; dSF[3][2] = -1.*xi_minus*eta;
1000 dSF[4][0] = -1.*eta_minus*zeta; dSF[4][1] = -1.*xi_minus*zeta; dSF[4][2] = xi_minus*eta_minus;
1001 dSF[5][0] = eta_minus*zeta; dSF[5][1] = -1.*xi*zeta; dSF[5][2] = xi*eta_minus;
1002 dSF[6][0] = eta*zeta; dSF[6][1] = xi*zeta; dSF[6][2] = xi*eta;
1003 dSF[7][0] = -1.*eta*zeta; dSF[7][1] = xi_minus * zeta; dSF[7][2] = xi_minus*eta;
1007 std::cerr <<
"GenericElement::dshape_func:error: Unknown element type."
1028 const double xi = nc.
x();
1029 const double eta = nc.
y();
1030 const double zeta = nc.
z();
1031 const double alpha = (1. - xi - eta - zeta);
1033 J[0] = ((p[9]-p[6])*=4.*zeta)+=((p[7]-p[5])*=4.*eta)+=
1034 (p[4]*(4.*(alpha-xi))+p[1]*(4.*xi-1.)+P);
1035 J[1] = ((p[8]-p[6])*=4.*zeta)+=((p[7]-p[4])*=4.*xi)+=
1036 (p[5]*(4.*(alpha-eta))+p[2]*(4.*eta-1.)+P);
1037 J[2] = ((p[9]-p[4])*=4.*xi)+=((p[8]-p[5])*=4.*eta)+=
1038 (p[6]*(4.*(alpha-zeta))+p[3]*(4.*zeta-1.)+P);
1042 const double xi = nc.
x();
1043 const double xi_minus = 1. - xi;
1044 const double eta = nc.
y();
1045 const double eta_minus = 1. - eta;
1046 const double zeta = nc.
z();
1047 const double zeta_minus = 1. - zeta;
1048 J[0] = ((p[6]-p[7])*=eta*zeta)+=((p[5]-p[4])*=eta_minus*zeta)+=
1049 ((p[2]-p[3])*=eta*zeta_minus)+=((p[1]-p[0])*=eta_minus*zeta_minus);
1050 J[1] = ((p[7]-p[4])*=xi_minus*zeta)+=((p[6]-p[5])*=xi*zeta)+=
1051 ((p[3]-p[0])*=xi_minus*zeta_minus)+=((p[2]-p[1])*=xi*zeta_minus);
1052 J[2] = ((p[7]-p[3])*=xi_minus*eta)+=((p[6]-p[2])*=xi*eta)+=
1053 ((p[5]-p[1])*=xi*eta_minus)+=((p[4]-p[0])*=xi_minus*eta_minus);
1057 std::cerr <<
"GenericElement::jacobian:Error: Cannot handle this"
1058 <<
" element size (yet)." << std::endl;
1070 const double xi = nc.
x();
1071 const double eta = nc.
y();
1072 const double zeta = nc.
z();
1076 v += (((f[1]-f[0])*=xi) += ((f[2]-f[0])*=eta) += ((f[3] - f[0])*=zeta));
1081 const double alpha = (1.-xi-eta-zeta);
1082 v = (alpha*(1.-2.*(xi+eta+zeta))*f[0] +
1083 xi*(2.*xi-1.)*f[1] +
1084 eta*(2.*eta-1.)*f[2] +
1085 zeta*(2.*zeta-1.)*f[3] +
1088 4.*zeta*alpha*f[6] +
1095 const double xi = nc.
x();
1096 const double xi_minus = 1. - xi;
1097 const double eta = nc.
y();
1098 const double eta_minus = 1. - eta;
1099 const double zeta = nc.
z();
1100 const double zeta_minus = 1. - zeta;
1101 v = (xi_minus*eta_minus*zeta_minus*f[0] +
1102 xi*eta_minus*zeta_minus*f[1] +
1103 xi*eta*zeta_minus*f[2] +
1104 xi_minus*eta*zeta_minus*f[3] +
1105 xi_minus*eta_minus*zeta*f[4] +
1106 xi*eta_minus*zeta*f[5] +
1108 xi_minus*eta*zeta*f[7]);
1112 std::cerr <<
"interpolate::error Cannot handle this element "
1113 <<
"type (yet)." << std::endl;
1132 small_box = mesh_box;
1136 unsigned int esize = ec.
Esize(n);
1137 std::vector<GeoPrim::CPoint> element_points(esize);
1141 element_points[
node-1] = ep;
1146 if(box < small_box) small_box =
box;
1147 if(box > large_box) large_box =
box;
1168 const NodalCoordinates &nc,
1170 std::list<IndexType> &elements)
1172 int nnodes = nc.Size();
1173 for(
int i = 1;
i <= nnodes;
i++){
1176 std::vector<IndexType>::const_iterator dci = dc[
i-1].begin();
1177 while(dci != dc[
i-1].end()){
1178 elements.push_back(*dci++);
1182 if(!elements.empty()){
1214 const NodalCoordinates &nc,
1216 const std::vector<Mesh::IndexType> &elements,
1223 std::vector<IndexType>::const_iterator ei = elements.begin();
1224 while(ei != elements.end()){
1226 unsigned int esize = ec.Esize(*ei);
1227 if(esize == 4 || esize == 10)
1228 guess.
init(.25,.25,.25);
1229 else if (esize == 8 || esize == 20)
1230 guess.
init(.5,.5,.5);
1254 if(natc[0] >=
LTOL && natc[0] <=
HTOL &&
1255 natc[1] >=
LTOL && natc[1] <=
HTOL &&
1256 natc[2] >=
LTOL && natc[2] <=
HTOL){
1257 if(esize == 4 || esize == 10){
1258 if((natc[0]+natc[1]+natc[2]) <=
HTOL)
1261 else if(esize == 8 || esize == 20)
1264 std::cerr <<
"Mesh::FindPointInMesh: Error: Cannot handle"
1265 <<
" this element type. (yet)" << std::endl;
1299 const NodalCoordinates &nc,
1307 std::list<IndexType> elements;
1309 std::list<IndexType>::iterator ei = elements.begin();
1310 while(ei != elements.end()){
1312 unsigned int esize = ec.Esize(*ei);
1313 if(esize == 4 || esize == 10)
1314 guess.
init(.25,.25,.25);
1315 else if (esize == 8 || esize == 20)
1316 guess.
init(.5,.5,.5);
1323 std::cout <<
"Mesh::FindPointInMesh: Error: Closest approach: " << dist
1324 <<
" at node " << closest_node <<
"." << std::endl
1325 <<
"Mesh::FindPointInMesh: Element(" << *ei <<
") = (";
1326 IRAD::Util::DumpContents(std::cout,ec[*ei-1],
",");
1327 std::cout <<
")" << std::endl;
1328 std::vector<Mesh::IndexType>::const_iterator ei2 = dc[closest_node-1].begin();
1330 while(ei2 != dc[closest_node-1].end()){
1332 std::vector<Mesh::IndexType>::const_iterator
ni = ec[*ei2-1].begin();
1333 while(ni != ec[*ei2-1].end())
1337 std::cout <<
"Mesh::FindPointInMesh: Bounding box of failed search: "
1338 << new_bounds << std::endl;
1341 if(natc[0] >=
LTOL && natc[0] <=
HTOL &&
1342 natc[1] >=
LTOL && natc[1] <=
HTOL &&
1343 natc[2] >=
LTOL && natc[2] <=
HTOL){
1344 if(esize == 4 || esize == 10){
1345 if((natc[0]+natc[1]+natc[2]) <=
HTOL)
1348 else if(esize == 8 || esize == 20)
1351 std::cerr <<
"Mesh::FindPointInMesh: Error: Cannot handle"
1352 <<
" this element type. (yet)" << std::endl;
1387 const NodalCoordinates &nc,
1395 std::list<IndexType> elements;
1397 std::list<IndexType>::iterator ei = elements.begin();
1398 while(ei != elements.end()){
1400 unsigned int esize = ec.Esize(*ei);
1401 if(esize == 3 || esize == 6)
1402 guess.
init(.25,.25,0);
1403 else if (esize == 4 || esize == 8)
1404 guess.
init(.5,.5,0);
1411 std::cout <<
"Mesh::FindPointInMesh: Error: Closest approach: " << dist
1412 <<
" at node " << closest_node <<
"." << std::endl
1413 <<
"Mesh::FindPointInMesh: Element(" << *ei <<
") = (";
1414 IRAD::Util::DumpContents(std::cout,ec[*ei-1],
",");
1415 std::cout <<
")" << std::endl;
1416 std::vector<Mesh::IndexType>::const_iterator ei2 = dc[closest_node-1].begin();
1418 while(ei2 != dc[closest_node-1].end()){
1420 std::vector<Mesh::IndexType>::const_iterator ni = ec[*ei2-1].begin();
1421 while(ni != ec[*ei2-1].end())
1425 std::cout <<
"Mesh::FindPointInMesh: Bounding box of failed search: "
1426 << new_bounds << std::endl;
1429 if(natc[0] >=
LTOL && natc[0] <=
HTOL &&
1430 natc[1] >=
LTOL && natc[1] <=
HTOL)
1432 if(esize == 3 || esize == 6){
1433 if(((natc[0]+natc[1]) <=
HTOL))
1436 else if(esize == 4 || esize == 8)
1439 std::cerr <<
"Mesh::FindPointInMesh: Error: Cannot handle"
1440 <<
" this element type. (yet)" << std::endl;
1458 double scal = 1.0/(
static_cast<double>(esize));
1459 return(centroid *= scal);
1470 double scal = 1.0/(
static_cast<double>(esize));
1486 return((avec*aface.
Normal()) < 0);
1495 return((bvec*bface.
Normal()) < 0);
1504 return((cvec*cface.
Normal()) < 0);
1513 return((dvec*dface.
Normal()) < 0);
1538 else if(
_size == 5){
1546 return((bvec*bface.
Normal()) < 0);
1553 else if(
_size == 6){
1560 return((cvec*cface.
Normal()) < 0);
1565 else if(
_size == 8){
1651 int ein_size = ec.
Nelem();
1652 while(ein <= ein_size){
1653 unsigned int esize = ec.
Esize(ein);
1654 if(esize == 4 || esize == 10)
1655 guess.
init(.25,.25,.25);
1656 else if (esize == 8 || esize == 20)
1657 guess.
init(.5,.5,.5);
1662 std::cerr <<
"GlobalFindPointInMesh: error NewtonRaphson failed."
1666 if(natc[0] >=
LTOL && natc[0] <=
HTOL &&
1667 natc[1] >=
LTOL && natc[1] <=
HTOL &&
1668 natc[2] >=
LTOL && natc[2] <=
HTOL){
1669 if(esize == 4 || esize == 10){
1670 if((natc[0]+natc[1]+natc[2]) <=
HTOL){
1674 else if(esize == 8 || esize == 20)
1677 std::cerr <<
"GlobalFindPointInMesh: Error: Cannot handle"
1678 <<
" this element type. (yet)" << std::endl;
1697 Inf.open(path.c_str());
1700 Inf >> mesh.
nc >> mesh.
con;
1715 const std::vector<IndexType> &e)
const
1885 const GenericElement &el,
1894 double errtol = 1e-12;
1898 for (k=0;k<ntrial;k++) {
1900 el.shapef_jacobian_at(point,natc,elnum,ec,nc,fvec,fjac);
1905 errf += fabs(fvec[i]);
1948 const GenericCell_2 &el,
1950 const NodalCoordinates &nc,
1960 for (k=0;k<ntrial;k++) {
1961 el.shapef_jacobian_at(point,natc,elnum,ec,nc,fvec,fjac);
1964 errf += fabs(fvec[i]);
1986 #define LUDTINY 1.0e-24
1992 double big,dum,sum,temp;
2000 if ((temp=fabs(a[i][j])) > big) big=temp;
2011 sum -= a[i][k]*a[k][j];
2018 sum -= a[i][k]*a[k][j];
2020 if ( (dum=vv[i]*fabs(sum)) >= big) {
2059 for (j=ii;j<=i-1;j++)
2060 sum -= a[i][j]*b[j];
2066 for (i=2;i>=0;i--) {
2069 sum -= a[i][j]*b[j];
2077 std::getline(iSt,line);
2078 std::istringstream Istr(line);
2088 std::getline(iSt,line);
2089 std::istringstream Istr(line);
2096 std::getline(iSt,line);
2097 std::istringstream Istr2(line);
2100 while(Istr2 >> node)
2101 ec[
i].push_back(node);
2102 std::vector<Mesh::IndexType>(ec[
i]).
swap(ec[i]);
2113 std::getline(iSt,line);
2114 std::istringstream Istr(line);
2119 double *inPtr = nc[
n];
2120 std::getline(iSt,line);
2121 std::istringstream Istr2(line);
2122 Istr2 >> inPtr[0] >> inPtr[1] >> inPtr[2];
2131 oSt.setf(std::ios::scientific);
2132 oSt.setf(std::ios::showpoint);
2133 oSt << std::setprecision(10) << std::setiosflags(std::ios::left);
2135 if(nc.
size() > 0) oSt <<
"\n";
2137 oSt << std::setw(16) << nc[
n][0] <<
"\t"
2138 << std::setw(16) << nc[
n][1] <<
"\t"
2139 << std::setw(16) << nc[
n][2];
2148 oSt << std::setiosflags(std::ios::left) << ec.size();
2149 if(ec.size() == 0)
return(oSt);
2151 Mesh::Connectivity::const_iterator ci = ec.begin();
2152 while(ci != ec.end()){
2153 std::vector<IndexType>::const_iterator ni = ci->begin();
2154 while(ni != ci->end()){
2168 if(ge.first.empty())
return(oSt);
2169 oSt << std::setiosflags(std::ios::left) << ge.first <<
"\n";
/brief Cartesian 3 Vector
void swap(int &a, int &b)
int GetMeshCentroids(Mesh::NodalCoordinates &nc, Mesh::Connectivity &conn, std::vector< double > ¢roids)
C3Vector & Init(const double *a)
Mesh::IndexType closest_node(const GeoPrim::CPoint &p, double *dist_ptr=NULL) const
void AddPoint(const CPoint &p)
void GetAdjacent(Connectivity &rl, Connectivity &dc, IndexType n=0, bool sortit=false)
void init_copy(IndexType n, double *data)
General connectivity object.
void init(const double *points, unsigned int n)
void shape_func(const GeoPrim::CVector &, double[]) const
bool operator<(const TestFace &f)
Mesh::Connectivity _collections
void int int REAL REAL * y
void dshape_func(const GeoPrim::CVector &, double[][2]) const
void jacobian(const GeoPrim::CPoint p[], const GeoPrim::CVector &, GeoPrim::CVector J[]) const
Mesh::IndexType GlobalFindPointInMesh(const GeoPrim::CPoint &p, const NodalCoordinates &nc, const Connectivity &ec, const Connectivity &dc, const GeoPrim::CBox &box, GeoPrim::CVector &natc)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
int ReadMesh(const std::string &path, Mesh::UnstructuredMesh &mesh)
GeoPrim::C3Point Centroid()
Class Mesh is the main class that holds all information to describe the current state of the mesh...
void dshape_func(const GeoPrim::CVector &, double[][3]) const
void GetNeighborhood(NeighborHood &, const Connectivity &dc, IndexType size=0)
bool LUDcmp(GeoPrim::CVector a[], int indx[])
real *8 function offset(vNorm, x2, y2, z2)
void GetPointSet(GeoPrim::CPoint ps[], IndexType elnum, const Connectivity &ec, const NodalCoordinates &nc)
bool contains(const CPoint &p) const
void ReOrient(std::vector< IndexType > &ec)
void ElementsOn(std::vector< Mesh::IndexType > &nodes, Connectivity &dc, std::vector< Mesh::IndexType > &subset)
void Resize(unsigned int N=0)
T norm(const NVec< DIM, T > &v)
void GetMeshBoxes(const NodalCoordinates &nc, const Connectivity &ec, GeoPrim::CBox &mesh_box, GeoPrim::CBox &small_box, GeoPrim::CBox &large_box)
Bounding boxes for a mesh.
Mesh::IndexType FindPointInMesh_2(const GeoPrim::CPoint &p, const NodalCoordinates &nc, const Connectivity &ec, const Connectivity &dc, const GeoPrim::CBox &box, GeoPrim::CVector &natc)
Locate element containing given physical point.
bool ShapeOK(std::vector< IndexType > &ec, NodalCoordinates &nc) const
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
void get_face_connectivities(Connectivity &, const std::vector< IndexType > &) const
Face conn for given element.
std::pair< IndexType, CellEntityIDType > SubEntityId
void int int int REAL REAL REAL * z
void ReOrient(std::vector< IndexType > &ec)
void matrix_mode(IndexType offset=0)
void Inverse(Connectivity &, IndexType nnodes=0) const
IndexType & Node(IndexType e, IndexType n)
bool Inverted(std::vector< IndexType > &ec, NodalCoordinates &nc) const
void GetNormalSet(GeoPrim::CVector ns[], IndexType elnum, const Connectivity &ec, const NodalCoordinates &nc)
CVector & init(const CPoint &p)
IndexType Esize(IndexType n) const
void interpolate(const GeoPrim::CVector f[], const GeoPrim::CVector &nc, GeoPrim::CVector &) const
int CollideCellsWithBox(Mesh::NodalCoordinates &nc, Mesh::Connectivity &conn, GeoPrim::CBox &box, std::vector< Mesh::IndexType > &candidates, std::vector< Mesh::IndexType > &cells)
Connects continuous to discrete.
Mesh::IndexType FindPointInMesh(const GeoPrim::CPoint &p, const NodalCoordinates &nc, const Connectivity &ec, const Connectivity &dc, const GeoPrim::CBox &box, GeoPrim::CVector &natc)
Locate element containing given physical point.
void BreadthFirstRenumber(std::vector< Mesh::IndexType > &remap)
Mesh::IndexType FindPointInCells(const GeoPrim::CPoint &p, const NodalCoordinates &nc, const Connectivity &ec, const std::vector< Mesh::IndexType > &elements, GeoPrim::CVector &natc)
Locate element containing given physical point.
void BuildFaceConnectivity(Connectivity &fcon, Connectivity &ef, std::vector< Mesh::SymbolicFace > &sf, Connectivity &dc) const
const GeoPrim::CPoint closest_point(const GeoPrim::CPoint &p) const
void Transpose(CVector matrix[])
void graph_mode(IndexType offset=0)
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
void InverseDegenerate(Connectivity &, IndexType nnodes=0) const
CBox around(const CPoint &p) const
friend istream & operator>>(istream &stream, Mesh &mesh)
The mesh instream operator is used to drive the reading of the one input file to the code...
void LUBksb(GeoPrim::CVector a[], int indx[], GeoPrim::CVector &b)
bool contains_point(const C3Point &P) const
void shapef_jacobian_at(const GeoPrim::CPoint &p, GeoPrim::CVector &natc, IndexType elnum, const Connectivity &ec, const NodalCoordinates &nc, GeoPrim::CVector &fvec, GeoPrim::CVector fjac[]) const
CBox intersect(const CBox &b) const
int CollideMeshWithBox(Mesh::NodalCoordinates &nc, Mesh::Connectivity &conn, GeoPrim::CBox &box, std::vector< Mesh::IndexType > &cells)
void int int REAL REAL REAL *z blockDim dim * ni
long double dist(long double *coord1, long double *coord2, int size)
bool NewtonRaphson(GeoPrim::CVector &natc, IndexType elnum, const GenericElement &el, const Connectivity &ec, const NodalCoordinates &nc, const GeoPrim::CPoint &point)
Newton-Raphson method, customized for using the GeoPrimitives and computational mesh constructs...
void shapef_jacobian_at(const GeoPrim::CPoint &p, GeoPrim::CVector &natc, IndexType elnum, const Connectivity &ec, const NodalCoordinates &nc, GeoPrim::CVector &fvec, GeoPrim::CVector jac[]) const
void GetCoordinateBounds(NodalCoordinates &nc, std::vector< double > &)
IRAD::Primitive::IndexType IndexType
void jacobian(const GeoPrim::CPoint p[], const GeoPrim::CVector &nc, GeoPrim::CVector J[]) const
friend ostream & operator<<(ostream &stream, Mesh &mesh)
The mesh ostream operator is used to drive the writing of both output fils from the code...
void interpolate(const GeoPrim::CVector f[], const GeoPrim::CVector &nc, GeoPrim::CVector &) const
GeoPrim::C3Point Centroid()
bool NewtonRaphson_2(GeoPrim::CVector &natc, IndexType elnum, const GenericCell_2 &el, const Connectivity &ec, const NodalCoordinates &nc, const GeoPrim::CPoint &point)
Newton-Raphson method, customized for using the GeoPrimitives and computational mesh constructs...
void init_node(IndexType n, const GeoPrim::CPoint &)
void shape_func(const GeoPrim::CVector &, double[]) const
Encapsulates an element-connectivity of a mesh.
void FindElementsInBox(const GeoPrim::CBox &box, const NodalCoordinates &nc, const Connectivity &dc, std::list< IndexType > &elements)
Get elements in box.