Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
Nektar::Utilities::Iso Class Reference

#include <ProcessIsoContour.h>

Collaboration diagram for Nektar::Utilities::Iso:
Collaboration graph
[legend]

Public Member Functions

void condense (void)
 
void globalcondense (vector< boost::shared_ptr< Iso > > &iso, bool verbose)
 
void separate_regions (vector< boost::shared_ptr< Iso > > &iso, int minsize, bool verbose)
 
void smooth (int n_iter, NekDouble lambda, NekDouble mu)
 
int get_nvert (void)
 
void set_nvert (int n)
 
int get_ntris (void)
 
void set_ntris (int n)
 
void set_fields (const int loc, const Array< OneD, Array< OneD, NekDouble > > &intfields, const int j)
 
NekDouble get_fields (const int i, const int j)
 
void set_x (int loc, NekDouble val)
 
void set_y (int loc, NekDouble val)
 
void set_z (int loc, NekDouble val)
 
NekDouble get_x (int loc)
 
NekDouble get_y (int loc)
 
NekDouble get_z (int loc)
 
int get_vid (int i)
 
void resize_vid (int nconn)
 
void set_vid (int i, int j)
 
void resize_fields (int size)
 
 Iso (int nfields)
 
 ~Iso (void)
 

Private Attributes

bool m_condensed
 
int m_nvert
 
int m_ntris
 
vector< NekDoublem_x
 
vector< NekDoublem_y
 
vector< NekDoublem_z
 
vector< vector< NekDouble > > m_fields
 
Array< OneD, int > m_vid
 

Detailed Description

Definition at line 47 of file ProcessIsoContour.h.

Constructor & Destructor Documentation

Nektar::Utilities::Iso::Iso ( int  nfields)
inline

Definition at line 156 of file ProcessIsoContour.h.

References m_condensed, m_fields, m_nvert, m_x, m_y, and m_z.

157  {
158  m_condensed = false;
159  m_nvert = 0;
160  m_fields.resize(nfields);
161  // set up initial vectors to be 10000 long
162  m_x.resize(10000);
163  m_y.resize(10000);
164  m_z.resize(10000);
165  for(int i = 0; i < m_fields.size(); ++i)
166  {
167  m_fields[i].resize(10000);
168  }
169  };
vector< NekDouble > m_x
vector< vector< NekDouble > > m_fields
vector< NekDouble > m_z
vector< NekDouble > m_y
Nektar::Utilities::Iso::~Iso ( void  )
inline

Definition at line 171 of file ProcessIsoContour.h.

172  {
173  }

Member Function Documentation

void Nektar::Utilities::Iso::condense ( void  )

Definition at line 622 of file ProcessIsoContour.cpp.

References Nektar::StdRegions::find(), Nektar::iterator, m_condensed, m_fields, Nektar::Utilities::IsoVertex::m_fields, Nektar::Utilities::IsoVertex::m_id, m_ntris, m_nvert, m_vid, m_x, Nektar::Utilities::IsoVertex::m_x, m_y, Nektar::Utilities::IsoVertex::m_y, m_z, Nektar::Utilities::IsoVertex::m_z, and Nektar::NekMeshUtils::vert.

623 {
624  register int i,j,cnt;
625  IsoVertex v;
626  vector<IsoVertex> vert;
628 
629  if(!m_ntris) return;
630 
631  if(m_condensed) return;
632  m_condensed = true;
633 
634  vert.reserve(m_ntris/6);
635 
636  m_vid = Array<OneD, int>(3*m_ntris);
637 
638  // fill first 3 points and initialise fields
639  v.m_fields.resize(m_fields.size());
640  for(cnt =0, i = 0; i < 3; ++i)
641  {
642  v.m_x = m_x[i];
643  v.m_y = m_y[i];
644  v.m_z = m_z[i];
645  for(int f = 0; f < m_fields.size(); ++f)
646  {
647  v.m_fields[f] = m_fields[f][i];
648  }
649  v.m_id = cnt;
650  vert.push_back(v);
651  m_vid[i] = v.m_id;
652  ++cnt;
653  }
654 
655  for(i = 1; i < m_ntris; ++i)
656  {
657  for(j = 0; j < 3; ++j)
658  {
659  v.m_x = m_x[3*i+j];
660  v.m_y = m_y[3*i+j];
661  v.m_z = m_z[3*i+j];
662 
663  pt = find(vert.begin(),vert.end(),v);
664  if(pt != vert.end())
665  {
666  m_vid[3*i+j] = pt[0].m_id;
667  }
668  else
669  {
670  v.m_id = cnt;
671 
672  for(int f = 0; f < m_fields.size(); ++f)
673  {
674  v.m_fields[f] = m_fields[f][3*i+j];
675  }
676 
677  vert.push_back(v);
678 
679  m_vid[3*i+j] = v.m_id;
680  ++cnt;
681  }
682  }
683  }
684 
685  // remove elements with multiple vertices
686  for(i = 0,cnt=0; i < m_ntris;)
687  {
688  if((m_vid[3*i] ==m_vid[3*i+1])||
689  (m_vid[3*i] ==m_vid[3*i+2])||
690  (m_vid[3*i+1]==m_vid[3*i+2]))
691  {
692  cnt++;
693  for(j = 3*i; j < 3*(m_ntris-1); ++j)
694  {
695  m_vid[j] = m_vid[j+3];
696  }
697  m_ntris--;
698  }
699  else
700  {
701  ++i;
702  }
703  }
704 
705  m_nvert = vert.size();
706 
707  m_x.resize(m_nvert);
708  m_y.resize(m_nvert);
709  m_z.resize(m_nvert);
710 
711  for(int f = 0; f < m_fields.size(); ++f)
712  {
713  m_fields[f].resize(m_nvert);
714  }
715 
716  for(i = 0; i < m_nvert; ++i)
717  {
718  m_x[i] = vert[i].m_x;
719  m_y[i] = vert[i].m_y;
720  m_z[i] = vert[i].m_z;
721  for(int f = 0; f < m_fields.size(); ++f)
722  {
723  m_fields[f][i] = vert[i].m_fields[f];
724  }
725  }
726 }
vector< NekDouble > m_x
vector< vector< NekDouble > > m_fields
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
vector< NekDouble > m_z
Array< OneD, int > m_vid
vector< NekDouble > m_y
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:315
NekDouble Nektar::Utilities::Iso::get_fields ( const int  i,
const int  j 
)
inline

Definition at line 90 of file ProcessIsoContour.h.

References m_fields.

91  {
92  return m_fields[i][j];
93  }
vector< vector< NekDouble > > m_fields
int Nektar::Utilities::Iso::get_ntris ( void  )
inline

Definition at line 66 of file ProcessIsoContour.h.

References m_ntris.

67  {
68  return m_ntris;
69  }
int Nektar::Utilities::Iso::get_nvert ( void  )
inline

Definition at line 56 of file ProcessIsoContour.h.

References m_nvert.

57  {
58  return m_nvert;
59  }
int Nektar::Utilities::Iso::get_vid ( int  i)
inline

Definition at line 125 of file ProcessIsoContour.h.

References m_vid.

126  {
127  return m_vid[i];
128  }
Array< OneD, int > m_vid
NekDouble Nektar::Utilities::Iso::get_x ( int  loc)
inline

Definition at line 110 of file ProcessIsoContour.h.

References m_x.

111  {
112  return m_x[loc];
113  }
vector< NekDouble > m_x
NekDouble Nektar::Utilities::Iso::get_y ( int  loc)
inline

Definition at line 115 of file ProcessIsoContour.h.

References m_y.

116  {
117  return m_y[loc];
118  }
vector< NekDouble > m_y
NekDouble Nektar::Utilities::Iso::get_z ( int  loc)
inline

Definition at line 120 of file ProcessIsoContour.h.

References m_z.

121  {
122  return m_z[loc];
123  }
vector< NekDouble > m_z
void Nektar::Utilities::Iso::globalcondense ( vector< boost::shared_ptr< Iso > > &  iso,
bool  verbose 
)

Definition at line 757 of file ProcessIsoContour.cpp.

References m_condensed, m_fields, m_ntris, m_nvert, m_vid, m_x, m_y, m_z, Nektar::LibUtilities::PrintProgressbar(), and Nektar::Utilities::same().

758 {
759  int i,j,n;
760  int nvert,nelmt;
761  int niso=iso.size();
762  int id1,id2;
763  Array<OneD, Array<OneD, int> > vidmap;
764 
765  if(m_condensed) return;
766  m_condensed = true;
767 
768  vidmap = Array<OneD, Array<OneD, int> > (niso);
769 
770  m_ntris = 0;
771  for(i = 0; i < niso; ++i)
772  {
773  if(iso[i]->m_ntris)
774  {
775  m_ntris += iso[i]->m_ntris;
776  }
777  }
778 
779  m_vid = Array<OneD, int>(3*m_ntris);
780 
781  m_nvert = 0;
782  for(i = 0; i < niso; ++i)
783  {
784  if(iso[i]->m_ntris)
785  {
786  m_nvert += iso[i]->m_nvert;
787  }
788  }
789 
790  vector< vector<int> > isocon;
791  isocon.resize(niso);
792 
793  // identify which iso are connected by at least one point;
794  // find min x,y,z and max x,y,z and see if overlap to select
795  // which zones should be connected
796  {
797  vector<Array<OneD, NekDouble> > sph(niso);
798  Array<OneD, NekDouble> rng(6);
799  for(i = 0; i < niso; ++i)
800  {
801  sph[i] = Array<OneD, NekDouble>(4);
802 
803  // find max and min of isocontour
804  rng[0] = rng[3] = iso[i]->m_x[0];
805  rng[1] = rng[4] = iso[i]->m_x[1];
806  rng[2] = rng[5] = iso[i]->m_x[2];
807 
808  for(id1 = 1; id1 < iso[i]->m_nvert;++id1)
809  {
810  rng[0] = min(rng[0],iso[i]->m_x[i]);
811  rng[1] = min(rng[1],iso[i]->m_y[i]);
812  rng[2] = min(rng[2],iso[i]->m_z[i]);
813 
814  rng[3] = max(rng[3],iso[i]->m_x[i]);
815  rng[4] = max(rng[4],iso[i]->m_y[i]);
816  rng[5] = max(rng[5],iso[i]->m_z[i]);
817  }
818 
819  // centroid
820  sph[i][0] = (rng[3]+rng[0])/2.0;
821  sph[i][1] = (rng[4]+rng[1])/2.0;
822  sph[i][2] = (rng[5]+rng[2])/2.0;
823 
824  // radius;
825  sph[i][3] = sqrt((rng[3]-rng[0])*(rng[3]-rng[0]) +
826  (rng[4]-rng[1])*(rng[4]-rng[1]) +
827  (rng[5]-rng[2])*(rng[5]-rng[2]));
828  }
829 
830  for(i = 0; i < niso; ++i)
831  {
832  for(j = i; j < niso; ++j)
833  {
834  NekDouble diff=sqrt((sph[i][0]-sph[j][0])*(sph[i][0]-sph[j][0])+
835  (sph[i][1]-sph[j][1])*(sph[i][1]-sph[j][1])+
836  (sph[i][2]-sph[j][2])*(sph[i][2]-sph[j][2]));
837 
838  // if centroid is closer than added radii
839  if(diff < sph[i][3] + sph[j][3])
840  {
841  isocon[i].push_back(j);
842  }
843  }
844  }
845 
846  }
847 
848 
849  for(i = 0; i < niso; ++i)
850  {
851  vidmap[i] = Array<OneD, int>(iso[i]->m_nvert,-1);
852  }
853  nvert = 0;
854  int cnt = 0;
855  // count up amount of checking to be done
856  NekDouble totiso = 0;
857  for(i = 0; i < niso; ++i)
858  {
859  totiso += isocon[i].size();
860  }
861 
862 
863  if(verbose)
864  {
865  cout << "Progress Bar totiso: " << totiso << endl;
866  }
867  for(i = 0; i < niso; ++i)
868  {
869  for(n = 0; n < isocon[i].size(); ++n, ++cnt)
870  {
871 
872  if(verbose && totiso >= 40)
873  {
874  LibUtilities::PrintProgressbar(cnt,totiso,"Condensing verts");
875  }
876 
877  int con = isocon[i][n];
878  for(id1 = 0; id1 < iso[i]->m_nvert; ++id1)
879  {
880 
881  if(verbose && totiso < 40)
882  {
883  LibUtilities::PrintProgressbar(id1,iso[i]->m_nvert,"isocon");
884  }
885 
886  int start = 0;
887  if(con == i)
888  {
889  start = id1+1;
890  }
891  for(id2 = start; id2 < iso[con]->m_nvert; ++id2)
892  {
893 
894  if((vidmap[con][id2] == -1)||(vidmap[i][id1] == -1))
895  {
896  if(same(iso[i]->m_x[id1], iso[i]->m_y[id1],
897  iso[i]->m_z[id1], iso[con]->m_x[id2],
898  iso[con]->m_y[id2],iso[con]->m_z[id2]))
899  {
900  if((vidmap[i][id1] == -1) &&
901  (vidmap[con][id2] != -1))
902  {
903  vidmap[i][id1] = vidmap[con][id2];
904  }
905  else if((vidmap[con][id2] == -1) &&
906  (vidmap[i][id1] != -1))
907  {
908  vidmap[con][id2] = vidmap[i][id1];
909  }
910  else if((vidmap[con][id2] == -1) &&
911  (vidmap[i][id1] == -1))
912  {
913  vidmap[i][id1] = vidmap[con][id2] = nvert++;
914  }
915  }
916  }
917  }
918  }
919  }
920 
921  for(id1 = 0; id1 < iso[i]->m_nvert;++id1)
922  {
923  if(vidmap[i][id1] == -1)
924  {
925  vidmap[i][id1] = nvert++;
926  }
927  }
928  }
929  m_nvert = nvert;
930 
931  nelmt = 0;
932  // reset m_vid;
933  for(n = 0; n < niso; ++n)
934  {
935  for(i = 0; i < iso[n]->m_ntris; ++i,nelmt++)
936  {
937  for(j=0; j < 3;++j)
938  {
939  m_vid[3*nelmt+j] = vidmap[n][iso[n]->m_vid[3*i+j]];
940  }
941  }
942  }
943 
944  m_ntris = nelmt;
945 
946  m_x.resize(m_nvert);
947  m_y.resize(m_nvert);
948  m_z.resize(m_nvert);
949 
950  m_fields.resize(iso[0]->m_fields.size());
951  for(i = 0; i < iso[0]->m_fields.size(); ++i)
952  {
953  m_fields[i].resize(m_nvert);
954  }
955 
956  // reset coordinate and fields.
957  for(n = 0; n < niso; ++n)
958  {
959  for(i = 0; i < iso[n]->m_nvert; ++i)
960  {
961  m_x[vidmap[n][i]] = iso[n]->m_x[i];
962  m_y[vidmap[n][i]] = iso[n]->m_y[i];
963  m_z[vidmap[n][i]] = iso[n]->m_z[i];
964 
965  for(j = 0; j < m_fields.size(); ++j)
966  {
967  m_fields[j][vidmap[n][i]] = iso[n]->m_fields[j][i];
968  }
969  }
970  }
971  cout << endl;
972 }
vector< NekDouble > m_x
double NekDouble
vector< vector< NekDouble > > m_fields
vector< NekDouble > m_z
Array< OneD, int > m_vid
vector< NekDouble > m_y
bool same(NekDouble x1, NekDouble y1, NekDouble z1, NekDouble x2, NekDouble y2, NekDouble z2)
void PrintProgressbar(const int position, const int goal, const string message)
Prints a progressbar.
Definition: Progressbar.hpp:69
void Nektar::Utilities::Iso::resize_fields ( int  size)
inline

Definition at line 140 of file ProcessIsoContour.h.

References m_fields, m_nvert, m_x, m_y, and m_z.

141  {
142  if(size > m_x.size()) // add 1000 element to vectors
143  {
144  m_x.resize(size+100);
145  m_y.resize(size+100);
146  m_z.resize(size+100);;
147  for(int i = 0; i < m_fields.size(); ++i)
148  {
149  m_fields[i].resize(size+1000);
150  }
151 
152  }
153  m_nvert = size;
154  }
vector< NekDouble > m_x
vector< vector< NekDouble > > m_fields
vector< NekDouble > m_z
vector< NekDouble > m_y
void Nektar::Utilities::Iso::resize_vid ( int  nconn)
inline

Definition at line 130 of file ProcessIsoContour.h.

References m_vid.

131  {
132  m_vid = Array<OneD, int>(nconn);
133  }
Array< OneD, int > m_vid
void Nektar::Utilities::Iso::separate_regions ( vector< boost::shared_ptr< Iso > > &  iso,
int  minsize,
bool  verbose 
)

Definition at line 1069 of file ProcessIsoContour.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::iterator, m_fields, m_ntris, m_nvert, m_vid, m_x, m_y, m_z, Nektar::LibUtilities::PrintProgressbar(), WARNINGL0, and Vmath::Zero().

1070  {
1071  int i,j,k,id;
1072  Array<OneD, vector<int> >vertcon(m_nvert);
1074  list<int> tocheck;
1075  list<int>::iterator cid;
1076 
1077  Array<OneD, bool> viddone(m_nvert,false);
1078 
1079  // make list of connecting tris around each vertex
1080  for(i = 0; i < m_ntris; ++i)
1081  {
1082  for(j = 0; j < 3; ++j)
1083  {
1084  vertcon[m_vid[3*i+j]].push_back(i);
1085  }
1086  }
1087 
1088  Array<OneD, int> vidregion(m_nvert,-1);
1089 
1090  int nregions = -1;
1091 
1092 
1093  // check all points are assigned to a region
1094  for(k = 0; k < m_nvert; ++k)
1095  {
1096  if(verbose)
1097  {
1098  LibUtilities::PrintProgressbar(k,m_nvert,"Separating regions");
1099  }
1100 
1101  if(vidregion[k] == -1)
1102  {
1103  vidregion[k] = ++nregions;
1104 
1105  // find all elmts around this.. vertex that need to be checked
1106  for(ipt = vertcon[k].begin(); ipt != vertcon[k].end(); ++ipt)
1107  {
1108  for(i = 0; i < 3; ++i)
1109  {
1110  if(vidregion[id = m_vid[3*(ipt[0])+i]] == -1)
1111  {
1112  tocheck.push_back(id);
1113  vidregion[id] = nregions;
1114  }
1115  }
1116  }
1117  viddone[k] = 1;
1118 
1119  // check all other neighbouring vertices
1120  while(tocheck.size())
1121  {
1122  cid = tocheck.begin();
1123  while(cid != tocheck.end())
1124  {
1125  if(!viddone[*cid])
1126  {
1127  for(ipt = vertcon[*cid].begin(); ipt != vertcon[*cid].end(); ++ipt)
1128  {
1129  for(i = 0; i < 3; ++i)
1130  {
1131  if(vidregion[id = m_vid[3*(ipt[0])+i]] == -1)
1132  {
1133  tocheck.push_back(id);
1134  vidregion[id] = nregions;
1135  }
1136  }
1137  }
1138  viddone[*cid] = 1;
1139  ++cid;
1140  tocheck.pop_front();
1141  }
1142  }
1143  }
1144  }
1145  }
1146  nregions++;
1147 
1148 
1149  Array<OneD, int> nvert(nregions,0);
1150  Array<OneD, int> nelmt(nregions,0);
1151 
1152  // count nverts
1153  for(i = 0; i < m_nvert; ++i)
1154  {
1155  nvert[vidregion[i]] +=1;
1156  }
1157 
1158  // count nelmts
1159  for(i = 0; i < m_ntris; ++i)
1160  {
1161  nelmt[vidregion[m_vid[3*i]]] +=1;
1162  }
1163 
1164  Array<OneD, int> vidmap(m_nvert);
1165  // generate new list of isocontour
1166  for(int n = 0; n < nregions; ++n)
1167  {
1168  if(nelmt[n] > minsize)
1169  {
1170  int nfields = m_fields.size();
1172 
1173  iso->m_ntris = nelmt[n];
1174  iso->m_vid = Array<OneD, int>(3*nelmt[n]);
1175 
1176  iso->m_nvert = nvert[n];
1177  iso->m_x.resize(nvert[n]);
1178  iso->m_y.resize(nvert[n]);
1179  iso->m_z.resize(nvert[n]);
1180 
1181  iso->m_fields.resize(nfields);
1182  for(i = 0; i < nfields; ++i)
1183  {
1184  iso->m_fields[i].resize(nvert[n]);
1185  }
1186 
1187 
1188  int cnt = 0;
1189  // generate vid map;
1190  Vmath::Zero(m_nvert,vidmap,1);
1191  for(i = 0; i < m_nvert; ++i)
1192  {
1193  if(vidregion[i] == n)
1194  {
1195  vidmap[i] = cnt++;
1196  }
1197  }
1198 
1199  cnt = 0;
1200  for(i = 0; i < m_ntris; ++i)
1201  {
1202  if(vidregion[m_vid[3*i]] == n)
1203  {
1204  for(j = 0; j < 3; ++j)
1205  {
1206  iso->m_vid[3*cnt+j] = vidmap[m_vid[3*i+j]];
1207 
1208  iso->m_x[vidmap[m_vid[3*i+j]]] = m_x[m_vid[3*i+j]];
1209  iso->m_y[vidmap[m_vid[3*i+j]]] = m_y[m_vid[3*i+j]];
1210  iso->m_z[vidmap[m_vid[3*i+j]]] = m_z[m_vid[3*i+j]];
1211 
1212  for(k = 0; k < nfields; ++k)
1213  {
1214  iso->m_fields[k][vidmap[m_vid[3*i+j]]] = m_fields[k][m_vid[3*i+j]];
1215  }
1216  }
1217  cnt++;
1218  }
1219  }
1220 
1221  WARNINGL0(cnt == nelmt[n],"Number of elements do not match");
1222  sep_iso.push_back(iso);
1223  }
1224  }
1225  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
vector< NekDouble > m_x
boost::shared_ptr< Iso > IsoSharedPtr
#define WARNINGL0(condition, msg)
Definition: ErrorUtil.hpp:194
vector< vector< NekDouble > > m_fields
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
vector< NekDouble > m_z
Array< OneD, int > m_vid
vector< NekDouble > m_y
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:359
void PrintProgressbar(const int position, const int goal, const string message)
Prints a progressbar.
Definition: Progressbar.hpp:69
void Nektar::Utilities::Iso::set_fields ( const int  loc,
const Array< OneD, Array< OneD, NekDouble > > &  intfields,
const int  j 
)
inline

Definition at line 76 of file ProcessIsoContour.h.

References m_fields, m_x, m_y, and m_z.

79  {
80  m_x[loc] = intfields[0][j];
81  m_y[loc] = intfields[1][j];
82  m_z[loc] = intfields[2][j];
83 
84  for(int i = 0; i < intfields.num_elements()-3; ++i)
85  {
86  m_fields[i][loc] = intfields[i+3][j];
87  }
88  }
vector< NekDouble > m_x
vector< vector< NekDouble > > m_fields
vector< NekDouble > m_z
vector< NekDouble > m_y
void Nektar::Utilities::Iso::set_ntris ( int  n)
inline

Definition at line 71 of file ProcessIsoContour.h.

References m_ntris.

72  {
73  m_ntris = n;
74  }
void Nektar::Utilities::Iso::set_nvert ( int  n)
inline

Definition at line 61 of file ProcessIsoContour.h.

References m_nvert.

62  {
63  m_nvert = n;
64  }
void Nektar::Utilities::Iso::set_vid ( int  i,
int  j 
)
inline

Definition at line 135 of file ProcessIsoContour.h.

References m_vid.

136  {
137  m_vid[i] = j;
138  }
Array< OneD, int > m_vid
void Nektar::Utilities::Iso::set_x ( int  loc,
NekDouble  val 
)
inline

Definition at line 95 of file ProcessIsoContour.h.

References m_x.

96  {
97  m_x[loc] = val;
98  }
vector< NekDouble > m_x
void Nektar::Utilities::Iso::set_y ( int  loc,
NekDouble  val 
)
inline

Definition at line 100 of file ProcessIsoContour.h.

References m_y.

101  {
102  m_y[loc] = val;
103  }
vector< NekDouble > m_y
void Nektar::Utilities::Iso::set_z ( int  loc,
NekDouble  val 
)
inline

Definition at line 105 of file ProcessIsoContour.h.

References m_z.

106  {
107  m_z[loc] = val;
108  }
vector< NekDouble > m_z
void Nektar::Utilities::Iso::smooth ( int  n_iter,
NekDouble  lambda,
NekDouble  mu 
)

Definition at line 974 of file ProcessIsoContour.cpp.

References Nektar::iterator, m_ntris, m_nvert, m_vid, m_x, m_y, and m_z.

975 {
976  int iter,i,j;
977  NekDouble del_v[3];
978  NekDouble w;
979  Array<OneD, NekDouble> xtemp, ytemp, ztemp;
980  vector< vector<int> > adj,vertcon;
983 
984  // determine elements around each vertex
985  vertcon.resize(m_nvert);
986  for(i = 0; i < m_ntris; ++i)
987  {
988  for(j = 0; j < 3; ++j)
989  {
990  vertcon[m_vid[3*i+j]].push_back(i);
991  }
992  }
993 
994  // determine vertices around each vertex
995  adj.resize(m_nvert);
996 
997  for(i =0; i < m_nvert; ++i)
998  {
999  for(ipt = vertcon[i].begin(); ipt != vertcon[i].end(); ++ipt)
1000  {
1001  for(j = 0; j < 3; ++j)
1002  {
1003  // make sure not adding own vertex
1004  if(m_vid[3*(*ipt)+j] != i)
1005  {
1006  // check to see if vertex has already been added
1007  for(iad = adj[i].begin(); iad != adj[i].end();++iad)
1008  {
1009  if(*iad == (m_vid[3*(*ipt)+j])) break;
1010  }
1011 
1012  if(iad == adj[i].end())
1013  {
1014  adj[i].push_back(m_vid[3*(*ipt)+j]);
1015  }
1016  }
1017  }
1018  }
1019  }
1020 
1021  xtemp = Array<OneD, NekDouble>(m_nvert);
1022  ytemp = Array<OneD, NekDouble>(m_nvert);
1023  ztemp = Array<OneD, NekDouble>(m_nvert);
1024 
1025  // smooth each point
1026  for (iter=0;iter<n_iter;iter++)
1027  {
1028  // compute first weighted average
1029  for(i=0;i< m_nvert;++i)
1030  {
1031  w = 1.0/(NekDouble)(adj[i].size());
1032 
1033  del_v[0] = del_v[1] = del_v[2] = 0.0;
1034 
1035  for(iad = adj[i].begin(); iad != adj[i].end(); ++iad)
1036  {
1037  del_v[0] = del_v[0] + (m_x[*iad]-m_x[i])*w;
1038  del_v[1] = del_v[1] + (m_y[*iad]-m_y[i])*w;
1039  del_v[2] = del_v[2] + (m_z[*iad]-m_z[i])*w;
1040  }
1041 
1042  xtemp[i] = m_x[i] + del_v[0] * lambda;
1043  ytemp[i] = m_y[i] + del_v[1] * lambda;
1044  ztemp[i] = m_z[i] + del_v[2] * lambda;
1045  }
1046 
1047  // compute second weighted average
1048  for(i=0;i< m_nvert;++i)
1049  {
1050 
1051  w = 1.0/(NekDouble)(adj[i].size());
1052  del_v[0] = del_v[1] = del_v[2] = 0;
1053 
1054  for(iad = adj[i].begin(); iad != adj[i].end(); ++iad)
1055  {
1056  del_v[0] = del_v[0] + (m_x[*iad]-m_x[i])*w;
1057  del_v[1] = del_v[1] + (m_y[*iad]-m_y[i])*w;
1058  del_v[2] = del_v[2] + (m_z[*iad]-m_z[i])*w;
1059  }
1060 
1061  m_x[i] = xtemp[i] + del_v[0] * mu;
1062  m_y[i] = ytemp[i] + del_v[1] * mu;
1063  m_z[i] = ztemp[i] + del_v[2] * mu;
1064  }
1065  }
1066 }
vector< NekDouble > m_x
double NekDouble
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
vector< NekDouble > m_z
Array< OneD, int > m_vid
vector< NekDouble > m_y

Member Data Documentation

bool Nektar::Utilities::Iso::m_condensed
private

Definition at line 176 of file ProcessIsoContour.h.

Referenced by condense(), globalcondense(), and Iso().

vector<vector<NekDouble> > Nektar::Utilities::Iso::m_fields
private
int Nektar::Utilities::Iso::m_ntris
private
int Nektar::Utilities::Iso::m_nvert
private
Array<OneD, int> Nektar::Utilities::Iso::m_vid
private
vector<NekDouble> Nektar::Utilities::Iso::m_x
private
vector<NekDouble> Nektar::Utilities::Iso::m_y
private
vector<NekDouble> Nektar::Utilities::Iso::m_z
private