Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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: Computes vorticity field.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef UTILITIES_PREPROCESSING_FIELDCONVERT_PROCESSISOCONTOUR
37 #define UTILITIES_PREPROCESSING_FIELDCONVERT_PROCESSISOCONTOUR
38 
39 #include "Module.h"
41 
42 namespace Nektar
43 {
44 namespace Utilities
45 {
46 
47 class Iso
48 {
49 public:
50  void condense(void);
51  void globalcondense(vector<boost::shared_ptr<Iso> > &iso);
52  void smooth(int n_iter, NekDouble lambda, NekDouble mu);
53 
54  int get_nvert(void)
55  {
56  return m_nvert;
57  }
58 
59  void set_nvert(int n)
60  {
61  m_nvert = n;
62  }
63 
64  int get_ntris(void)
65  {
66  return m_ntris;
67  }
68 
69  void set_ntris(int n)
70  {
71  m_ntris = n;
72  }
73 
74  void set_fields(const int loc,
75  const Array<OneD,Array<OneD, NekDouble> > &intfields,
76  const int j)
77  {
78  m_x[loc] = intfields[0][j];
79  m_y[loc] = intfields[1][j];
80  m_z[loc] = intfields[2][j];
81 
82  for(int i = 0; i < intfields.num_elements()-3; ++i)
83  {
84  m_fields[i][loc] = intfields[i+3][j];
85  }
86  }
87 
88  NekDouble get_fields(const int i, const int j)
89  {
90  return m_fields[i][j];
91  }
92  void set_x(int loc, NekDouble val)
93  {
94  m_x[loc] = val;
95  }
96 
97  void set_y(int loc, NekDouble val)
98  {
99  m_y[loc] = val;
100  }
101 
102  void set_z(int loc, NekDouble val)
103  {
104  m_z[loc] = val;
105  }
106 
107  NekDouble get_x(int loc)
108  {
109  return m_x[loc];
110  }
111 
112  NekDouble get_y(int loc)
113  {
114  return m_y[loc];
115  }
116 
117  NekDouble get_z(int loc)
118  {
119  return m_z[loc];
120  }
121 
122  int get_vid(int i)
123  {
124  return m_vid[i];
125  }
126 
127  void resize_vid(int nconn)
128  {
129  m_vid = Array<OneD, int>(nconn);
130  }
131 
132  void set_vid(int i, int j)
133  {
134  m_vid[i] = j;
135  }
136 
137  void resize_fields(int size)
138  {
139  if(size > m_x.size()) // add 100 element to vectors
140  {
141  m_x.resize(size+1000);
142  m_y.resize(size+1000);
143  m_z.resize(size+1000);;
144  for(int i = 0; i < m_fields.size(); ++i)
145  {
146  m_fields[i].resize(size+100);
147  }
148 
149  }
150  m_nvert = size;
151  }
152 
153  Iso(int nfields)
154  {
155  m_condensed = false;
156  m_nvert = 0;
157  m_fields.resize(nfields);
158  // set up initial vectors to be 10000 long
159  m_x.resize(10000);
160  m_y.resize(10000);
161  m_z.resize(10000);
162  for(int i = 0; i < m_fields.size(); ++i)
163  {
164  m_fields[i].resize(10000);
165  }
166  };
167 
168  ~Iso(void)
169  {
170  }
171 
172 private:
174  int m_nvert; // number of vertices
175  int m_ntris; // number of triangles introduced.
176  vector<NekDouble> m_x;
177  vector<NekDouble> m_y;
178  vector<NekDouble> m_z;
179  vector<vector<NekDouble> > m_fields;
180  Array<OneD, int> m_vid; // used when condensing field
181 
182 };
183 
184 typedef boost::shared_ptr<Iso> IsoSharedPtr;
185 
187 {
188 public:
189  friend class Iso;
190 
191  IsoVertex (void)
192  {
193  m_id = -1;
194  m_x = m_y = m_z = -99999;
195  }
196 
198 
200  {
201  return m_iso_id;
202  }
203 
205  {
206  return m_iso_vert_id;
207  }
208 
209  friend bool operator == (const IsoVertex& x, const IsoVertex& y);
210  friend bool operator != (const IsoVertex& x, const IsoVertex& y);
211 
212 private:
213  int m_id;
214  int m_iso_id;
217  vector<NekDouble > m_fields;
218 
219 };
220 
221 /**
222  * @brief This processing module extracts an isocontour
223  */
225 {
226 public:
227  /// Creates an instance of this class
228  static boost::shared_ptr<Module> create(FieldSharedPtr f)
229  {
231  }
233 
235  virtual ~ProcessIsoContour();
236 
237  /// Write mesh to output file.
238  virtual void Process(po::variables_map &vm);
239 
240 protected:
242  void ResetFieldPts(vector<IsoSharedPtr> &iso);
243 
244 private:
245 
246  vector<IsoSharedPtr> ExtractContour(
247  const int fieldid,
248  const NekDouble val);
249 };
250 }
251 }
252 
253 #endif