Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProcessIsoContour.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: ProcessIsoContour.h
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Generate isocontours from field data.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef FIELDUTILS_PROCESSISOCONTOUR
37 #define FIELDUTILS_PROCESSISOCONTOUR
38 
39 #include "../Module.h"
41 
42 namespace Nektar
43 {
44 namespace FieldUtils
45 {
46 
47 class Iso
48 {
49  public:
50  void Condense(void);
51  void GlobalCondense(vector<boost::shared_ptr<Iso> > &iso, bool verbose);
52  void SeparateRegions(vector<boost::shared_ptr<Iso> > &iso, int minsize, bool verbose);
53 
54  void Smooth(int n_iter, NekDouble lambda, NekDouble mu);
55 
56  int GetNVert(void)
57  {
58  return m_nvert;
59  }
60 
61  void SetNVert(int n)
62  {
63  m_nvert = n;
64  }
65 
66  int GetNTris(void)
67  {
68  return m_ntris;
69  }
70 
71  void SetNTris(int n)
72  {
73  m_ntris = n;
74  }
75 
76  void SetFields(const int loc,
77  const Array<OneD,Array<OneD, NekDouble> > &intfields,
78  const int j)
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  }
89 
90  NekDouble GetFields(const int i, const int j)
91  {
92  return m_fields[i][j];
93  }
94 
95  void SetX(int loc, NekDouble val)
96  {
97  m_x[loc] = val;
98  }
99 
100  void SetY(int loc, NekDouble val)
101  {
102  m_y[loc] = val;
103  }
104 
105  void SetZ(int loc, NekDouble val)
106  {
107  m_z[loc] = val;
108  }
109 
110  NekDouble GetX(int loc)
111  {
112  return m_x[loc];
113  }
114 
115  NekDouble GetY(int loc)
116  {
117  return m_y[loc];
118  }
119 
120  NekDouble GetZ(int loc)
121  {
122  return m_z[loc];
123  }
124 
125  int GetVId(int i)
126  {
127  return m_vid[i];
128  }
129 
130  void ResizeVId(int nconn)
131  {
132  m_vid = Array<OneD, int>(nconn);
133  }
134 
135  void SetVId(int i, int j)
136  {
137  m_vid[i] = j;
138  }
139 
140  void ResizeFields(int size)
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  }
155 
156  Iso(int nfields)
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(1000);
163  m_y.resize(1000);
164  m_z.resize(1000);
165  for(int i = 0; i < m_fields.size(); ++i)
166  {
167  m_fields[i].resize(1000);
168  }
169  };
170 
171  ~Iso(void)
172  {
173  }
174 
175  private:
177  int m_nvert; // number of vertices
178  int m_ntris; // number of triangles introduced.
179  vector<NekDouble> m_x;
180  vector<NekDouble> m_y;
181  vector<NekDouble> m_z;
182  vector<vector<NekDouble> > m_fields;
183  Array<OneD, int> m_vid; // used when condensing field
184 
185 };
186 
187 typedef boost::shared_ptr<Iso> IsoSharedPtr;
188 
190 {
191  public:
192  friend class Iso;
193 
194  IsoVertex (void)
195  {
196  m_id = -1;
197  m_x = m_y = m_z = -99999;
198  }
199 
201 
203  {
204  return m_iso_id;
205  }
206 
208  {
209  return m_iso_vert_id;
210  }
211 
212  friend bool operator == (const IsoVertex& x, const IsoVertex& y);
213  friend bool operator != (const IsoVertex& x, const IsoVertex& y);
214 
215  private:
216  int m_id;
217  int m_iso_id;
220  vector<NekDouble > m_fields;
221 
222 };
223 
224 /**
225  * @brief This processing module extracts an isocontour
226  */
228 {
229  public:
230  /// Creates an instance of this class
231  static boost::shared_ptr<Module> create(FieldSharedPtr f)
232  {
234  }
236 
238  virtual ~ProcessIsoContour();
239 
240  /// Write mesh to output file.
241  virtual void Process(po::variables_map &vm);
242 
243  protected:
245  void ResetFieldPts(vector<IsoSharedPtr> &iso);
246  void SetupIsoFromFieldPts(vector<IsoSharedPtr> &isovec);
247 
248  private:
249 
250  vector<IsoSharedPtr> ExtractContour(
251  const int fieldid,
252  const NekDouble val);
253 };
254 
255 }
256 }
257 
258 #endif
NekDouble GetX(int loc)
void SetX(int loc, NekDouble val)
NekDouble GetFields(const int i, const int j)
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
NekDouble GetY(int loc)
pair< ModuleType, string > ModuleKey
void ResetFieldPts(vector< IsoSharedPtr > &iso)
void SetupIsoFromFieldPts(vector< IsoSharedPtr > &isovec)
vector< vector< NekDouble > > m_fields
void SetFields(const int loc, const Array< OneD, Array< OneD, NekDouble > > &intfields, const int j)
boost::shared_ptr< Iso > IsoSharedPtr
This processing module interpolates one field to another.
boost::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:767
void GlobalCondense(vector< boost::shared_ptr< Iso > > &iso, bool verbose)
double NekDouble
friend bool operator!=(const IsoVertex &x, const IsoVertex &y)
void Smooth(int n_iter, NekDouble lambda, NekDouble mu)
vector< NekDouble > m_z
void SetVId(int i, int j)
virtual void Process(po::variables_map &vm)
Write mesh to output file.
void SetZ(int loc, NekDouble val)
static boost::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
vector< NekDouble > m_x
Array< OneD, int > m_vid
friend bool operator==(const IsoVertex &x, const IsoVertex &y)
NekDouble GetZ(int loc)
void SeparateRegions(vector< boost::shared_ptr< Iso > > &iso, int minsize, bool verbose)
void SetY(int loc, NekDouble val)
This processing module extracts an isocontour.
vector< IsoSharedPtr > ExtractContour(const int fieldid, const NekDouble val)
vector< NekDouble > m_y