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: 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, bool verbose);
52  void separate_regions(vector<boost::shared_ptr<Iso> > &iso, int minsize, bool verbose);
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 
95  void set_x(int loc, NekDouble val)
96  {
97  m_x[loc] = val;
98  }
99 
100  void set_y(int loc, NekDouble val)
101  {
102  m_y[loc] = val;
103  }
104 
105  void set_z(int loc, NekDouble val)
106  {
107  m_z[loc] = val;
108  }
109 
110  NekDouble get_x(int loc)
111  {
112  return m_x[loc];
113  }
114 
115  NekDouble get_y(int loc)
116  {
117  return m_y[loc];
118  }
119 
120  NekDouble get_z(int loc)
121  {
122  return m_z[loc];
123  }
124 
125  int get_vid(int i)
126  {
127  return m_vid[i];
128  }
129 
130  void resize_vid(int nconn)
131  {
132  m_vid = Array<OneD, int>(nconn);
133  }
134 
135  void set_vid(int i, int j)
136  {
137  m_vid[i] = j;
138  }
139 
140  void resize_fields(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(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  };
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
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 resize_vid(int nconn)
void separate_regions(vector< boost::shared_ptr< Iso > > &iso, int minsize, bool verbose)
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 SetupIsoFromFieldPts(vector< IsoSharedPtr > &isovec)
friend bool operator!=(const IsoVertex &x, const IsoVertex &y)
double NekDouble
boost::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:695
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 globalcondense(vector< boost::shared_ptr< Iso > > &iso, bool verbose)
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.