Nektar++
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 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 separate_regions(vector<boost::shared_ptr<Iso> > &iso, int minsize);
53 
54  void smooth(int n_iter, NekDouble lambda, NekDouble mu);
55 
56  int get_nvert(void)
57  {
58  return m_nvert;
59  }
60 
61  void set_nvert(int n)
62  {
63  m_nvert = n;
64  }
65 
66  int get_ntris(void)
67  {
68  return m_ntris;
69  }
70 
71  void set_ntris(int n)
72  {
73  m_ntris = n;
74  }
75 
76  void set_fields(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 get_fields(const int i, const int j)
91  {
92  return m_fields[i][j];
93  }
94  void set_x(int loc, NekDouble val)
95  {
96  m_x[loc] = val;
97  }
98 
99  void set_y(int loc, NekDouble val)
100  {
101  m_y[loc] = val;
102  }
103 
104  void set_z(int loc, NekDouble val)
105  {
106  m_z[loc] = val;
107  }
108 
109  NekDouble get_x(int loc)
110  {
111  return m_x[loc];
112  }
113 
114  NekDouble get_y(int loc)
115  {
116  return m_y[loc];
117  }
118 
119  NekDouble get_z(int loc)
120  {
121  return m_z[loc];
122  }
123 
124  int get_vid(int i)
125  {
126  return m_vid[i];
127  }
128 
129  void resize_vid(int nconn)
130  {
131  m_vid = Array<OneD, int>(nconn);
132  }
133 
134  void set_vid(int i, int j)
135  {
136  m_vid[i] = j;
137  }
138 
139  void resize_fields(int size)
140  {
141  if(size > m_x.size()) // add 100 element to vectors
142  {
143  m_x.resize(size+1000);
144  m_y.resize(size+1000);
145  m_z.resize(size+1000);;
146  for(int i = 0; i < m_fields.size(); ++i)
147  {
148  m_fields[i].resize(size+100);
149  }
150 
151  }
152  m_nvert = size;
153  }
154 
155  Iso(int nfields)
156  {
157  m_condensed = false;
158  m_nvert = 0;
159  m_fields.resize(nfields);
160  // set up initial vectors to be 10000 long
161  m_x.resize(10000);
162  m_y.resize(10000);
163  m_z.resize(10000);
164  for(int i = 0; i < m_fields.size(); ++i)
165  {
166  m_fields[i].resize(10000);
167  }
168  };
169 
170  ~Iso(void)
171  {
172  }
173 
174  private:
176  int m_nvert; // number of vertices
177  int m_ntris; // number of triangles introduced.
178  vector<NekDouble> m_x;
179  vector<NekDouble> m_y;
180  vector<NekDouble> m_z;
181  vector<vector<NekDouble> > m_fields;
182  Array<OneD, int> m_vid; // used when condensing field
183 
184 };
185 
186 typedef boost::shared_ptr<Iso> IsoSharedPtr;
187 
189 {
190  public:
191  friend class Iso;
192 
193  IsoVertex (void)
194  {
195  m_id = -1;
196  m_x = m_y = m_z = -99999;
197  }
198 
200 
202  {
203  return m_iso_id;
204  }
205 
207  {
208  return m_iso_vert_id;
209  }
210 
211  friend bool operator == (const IsoVertex& x, const IsoVertex& y);
212  friend bool operator != (const IsoVertex& x, const IsoVertex& y);
213 
214  private:
215  int m_id;
216  int m_iso_id;
219  vector<NekDouble > m_fields;
220 
221 };
222 
223 /**
224  * @brief This processing module extracts an isocontour
225  */
227 {
228  public:
229  /// Creates an instance of this class
230  static boost::shared_ptr<Module> create(FieldSharedPtr f)
231  {
233  }
235 
237  virtual ~ProcessIsoContour();
238 
239  /// Write mesh to output file.
240  virtual void Process(po::variables_map &vm);
241 
242  protected:
244  void ResetFieldPts(vector<IsoSharedPtr> &iso);
245 
246  private:
247 
248  vector<IsoSharedPtr> ExtractContour(
249  const int fieldid,
250  const NekDouble val);
251 };
252 
253 }
254 }
255 
256 #endif
void set_vid(int i, int j)
NekDouble get_y(int loc)
pair< ModuleType, string > ModuleKey
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void set_x(int loc, NekDouble val)
virtual void Process()=0
vector< NekDouble > m_x
NekDouble get_x(int loc)
NekDouble get_fields(const int i, const int j)
void globalcondense(vector< boost::shared_ptr< Iso > > &iso)
void resize_vid(int nconn)
void set_y(int loc, NekDouble val)
static boost::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
void smooth(int n_iter, NekDouble lambda, NekDouble mu)
boost::shared_ptr< Iso > IsoSharedPtr
void set_fields(const int loc, const Array< OneD, Array< OneD, NekDouble > > &intfields, const int j)
void separate_regions(vector< boost::shared_ptr< Iso > > &iso, int minsize)
friend bool operator!=(const IsoVertex &x, const IsoVertex &y)
double NekDouble
boost::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:677
vector< vector< NekDouble > > m_fields
vector< NekDouble > m_z
vector< IsoSharedPtr > ExtractContour(const int fieldid, const NekDouble val)
void set_z(int loc, NekDouble val)
Array< OneD, int > m_vid
friend bool operator==(const IsoVertex &x, const IsoVertex &y)
vector< NekDouble > m_y
void ResetFieldPts(vector< IsoSharedPtr > &iso)
This processing module interpolates one field to another.
void resize_fields(int size)
NekDouble get_z(int loc)
This processing module extracts an isocontour.