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

This processing module interpolates one field to another. More...

#include <ProcessInterpPoints.h>

Inheritance diagram for Nektar::FieldUtils::ProcessInterpPoints:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::ProcessInterpPoints:
Collaboration graph
[legend]

Public Member Functions

 ProcessInterpPoints (FieldSharedPtr f)
 
virtual ~ProcessInterpPoints ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
void PrintProgressbar (const int position, const int goal) const
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 

Private Member Functions

void InterpolateFieldToPts (vector< MultiRegions::ExpListSharedPtr > &field0, LibUtilities::PtsFieldSharedPtr &pts, NekDouble clamp_low, NekDouble clamp_up, NekDouble def_value)
 
void calcCp0 ()
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

Detailed Description

This processing module interpolates one field to another.

Definition at line 51 of file ProcessInterpPoints.h.

Constructor & Destructor Documentation

Nektar::FieldUtils::ProcessInterpPoints::ProcessInterpPoints ( FieldSharedPtr  f)

Definition at line 67 of file ProcessInterpPoints.cpp.

References ASSERTL0, and Nektar::FieldUtils::Module::m_config.

67  : ProcessModule(f)
68 {
69 
70  m_config["fromxml"] = ConfigOption(
71  false, "NotSet", "Xml file from which to interpolate field");
72 
73  ASSERTL0(m_config["fromxml"].as<string>().compare("NotSet") != 0,
74  "Need to specify fromxml=file.xml");
75 
76  m_config["fromfld"] = ConfigOption(
77  false, "NotSet", "Fld file from which to interpolate field");
78 
79  ASSERTL0(m_config["fromfld"].as<string>().compare("NotSet") != 0,
80  "Need to specify fromfld=file.fld ");
81 
82  m_config["clamptolowervalue"] =
83  ConfigOption(false, "-10000000", "Lower bound for interpolation value");
84  m_config["clamptouppervalue"] =
85  ConfigOption(false, "10000000", "Upper bound for interpolation value");
86  m_config["defaultvalue"] =
87  ConfigOption(false, "0", "Default value if point is outside domain");
88  m_config["line"] =
89  ConfigOption(false, "NotSet", "Specify a line of N points using "
90  "line=N,x0,y0,z0,z1,y1,z1");
91  m_config["plane"] = ConfigOption(
92  false, "NotSet", "Specify a plane of N1 x N2 points using "
93  "plane=N1,N2,x0,y0,z0,z1,y1,z1,x2,y2,z2,x3,"
94  "y3,z3");
95  m_config["box"] = ConfigOption(
96  false, "NotSet", "Specify a rectangular box of N1 x N2 x N3 points "
97  "using a box of points limited by box="
98  "N1,N2,N3,xmin,xmax,ymin,ymax,zmin,zmax");
99 
100  m_config["cp"] =
101  ConfigOption(false, "NotSet",
102  "Parameters p0 and q to determine pressure coefficients "
103  "(box only currently)");
104 }
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
Nektar::FieldUtils::ProcessInterpPoints::~ProcessInterpPoints ( )
virtual

Definition at line 106 of file ProcessInterpPoints.cpp.

107 {
108 }

Member Function Documentation

void Nektar::FieldUtils::ProcessInterpPoints::calcCp0 ( )
private

Definition at line 612 of file ProcessInterpPoints.cpp.

References ASSERTL0, Nektar::ParseUtils::GenerateUnOrderedVector(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, and WARNINGL0.

Referenced by Process().

613 {
614  LibUtilities::PtsFieldSharedPtr pts = m_f->m_fieldPts;
615  int dim = pts->GetDim();
616  int nq1 = pts->GetNpoints();
617  int r, f;
618  int pfield = -1;
619  NekDouble p0,qinv;
620  vector<int> velid;
621 
622  vector<NekDouble> values;
624  m_config["cp"].as<string>().c_str(),values),
625  "Failed to interpret cp string");
626 
627  ASSERTL0(values.size() == 2,
628  "cp string should contain 2 values "
629  "p0 and q (=1/2 rho u^2)");
630 
631  p0 = values[0];
632  qinv = 1.0/values[1];
633 
634  for(int i = 0; i < pts->GetNFields(); ++i)
635  {
636  if(boost::iequals(pts->GetFieldName(i),"p"))
637  {
638  pfield = i;
639  }
640 
641  if(boost::iequals(pts->GetFieldName(i),"u")||
642  boost::iequals(pts->GetFieldName(i),"v")||
643  boost::iequals(pts->GetFieldName(i),"w"))
644  {
645  velid.push_back(i);
646  }
647  }
648 
649  if(pfield != -1)
650  {
651  if(!velid.size())
652  {
653  WARNINGL0(false,"Did not find velocity components for Cp0");
654  }
655  }
656  else
657  {
658  WARNINGL0(false,"Failed to find 'p' field to determine cp0");
659  }
660 
661  // Allocate data storage
662  Array<OneD, Array< OneD, NekDouble> > data(2);
663 
664  for (f = 0; f < 2; ++f)
665  {
666  data[f] = Array< OneD, NekDouble>(nq1, 0.0);
667  }
668 
669  for (r = 0; r < nq1; r++)
670  {
671  if(pfield != -1) // calculate cp
672  {
673  data[0][r] = qinv*(pts->GetPointVal(dim + pfield, r) - p0);
674 
675  if(velid.size()) // calculate cp0
676  {
677  NekDouble q = 0;
678  for(int i = 0; i < velid.size(); ++i)
679  {
680  q += 0.5*pts->GetPointVal(dim + velid[i], r)*
681  pts->GetPointVal(dim + velid[i], r);
682  }
683  data[1][r] = qinv*(pts->GetPointVal(dim + pfield, r)+q - p0);
684  }
685  }
686  }
687 
688  if(pfield != -1)
689  {
690  pts->AddField(data[0], "Cp");
691  if(velid.size())
692  {
693  pts->AddField(data[1], "Cp0");
694  }
695  }
696 }
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
boost::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:178
#define WARNINGL0(condition, msg)
Definition: ErrorUtil.hpp:204
double NekDouble
static bool GenerateUnOrderedVector(const char *const str, std::vector< NekDouble > &vec)
Definition: ParseUtils.hpp:128
FieldSharedPtr m_f
Field object.
static boost::shared_ptr<Module> Nektar::FieldUtils::ProcessInterpPoints::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 55 of file ProcessInterpPoints.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

56  {
58  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::FieldUtils::ProcessInterpPoints::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 69 of file ProcessInterpPoints.h.

70  {
71  return "ProcessInterpPoints";
72  }
void Nektar::FieldUtils::ProcessInterpPoints::InterpolateFieldToPts ( vector< MultiRegions::ExpListSharedPtr > &  field0,
LibUtilities::PtsFieldSharedPtr pts,
NekDouble  clamp_low,
NekDouble  clamp_up,
NekDouble  def_value 
)
private

Definition at line 573 of file ProcessInterpPoints.cpp.

References ASSERTL0, Nektar::FieldUtils::Interpolator::Interpolate(), Nektar::FieldUtils::Module::m_f, PrintProgressbar(), and Nektar::FieldUtils::Interpolator::SetProgressCallback().

Referenced by Process().

579 {
580  ASSERTL0(pts->GetNFields() >= field0.size(), "ptField has too few fields");
581 
582  int nfields = field0.size();
583 
584  Interpolator interp;
585  if (m_f->m_comm->GetRank() == 0)
586  {
587  interp.SetProgressCallback(&ProcessInterpPoints::PrintProgressbar,
588  this);
589  }
590  interp.Interpolate(field0, pts);
591  if (m_f->m_comm->GetRank() == 0)
592  {
593  cout << endl;
594  }
595 
596  for (int f = 0; f < nfields; ++f)
597  {
598  for (int i = 0; i < pts->GetNpoints(); ++i)
599  {
600  if (pts->GetPointVal(f, i) > clamp_up)
601  {
602  pts->SetPointVal(f, i, clamp_up);
603  }
604  else if (pts->GetPointVal(f, i) < clamp_low)
605  {
606  pts->SetPointVal(f, i, clamp_low);
607  }
608  }
609  }
610 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
void PrintProgressbar(const int position, const int goal) const
FieldSharedPtr m_f
Field object.
void Nektar::FieldUtils::ProcessInterpPoints::PrintProgressbar ( const int  position,
const int  goal 
) const

Definition at line 698 of file ProcessInterpPoints.cpp.

References Nektar::LibUtilities::PrintProgressbar().

Referenced by InterpolateFieldToPts().

700 {
701  LibUtilities::PrintProgressbar(position, goal, "Interpolating");
702 }
int PrintProgressbar(const int position, const int goal, const string message, int lastprogress=-1)
Prints a progressbar.
Definition: Progressbar.hpp:69
void Nektar::FieldUtils::ProcessInterpPoints::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 110 of file ProcessInterpPoints.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, calcCp0(), Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::LibUtilities::ePtsBox, Nektar::LibUtilities::ePtsLine, Nektar::LibUtilities::ePtsPlane, Nektar::ParseUtils::GenerateOrderedStringVector(), Nektar::ParseUtils::GenerateUnOrderedVector(), InterpolateFieldToPts(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, npts, Nektar::LibUtilities::NullFieldMetaDataMap, Nektar::LibUtilities::NullPtsField, Nektar::SpatialDomains::MeshGraph::Read(), Vmath::Vmax(), and Vmath::Vmin().

111 {
112  if (m_f->m_verbose)
113  {
114  if (m_f->m_comm->TreatAsRankZero())
115  {
116  cout << "ProcessInterpPoints: interpolating to points..." << endl;
117  }
118  }
119 
120  int rank = m_f->m_comm->GetRank();
121  int nprocs = m_f->m_comm->GetSize();
122 
123  // Check for command line point specification if no .pts file
124  // specified
125  if (m_f->m_fieldPts == LibUtilities::NullPtsField)
126  {
127  if (m_config["line"].as<string>().compare("NotSet") != 0)
128  {
129  string help = m_config["line"].as<string>();
130  vector<NekDouble> values;
132  m_config["line"].as<string>().c_str(), values),
133  "Failed to interpret line string");
134 
135  ASSERTL0(values.size() > 2,
136  "line string should contain 2 Dim+1 values "
137  "N,x0,y0,z0,x1,y1,z1");
138 
139  double tmp;
140  ASSERTL0(std::modf(values[0], &tmp) == 0.0, "N is not an integer");
141  ASSERTL0(values[0] > 1, "N is not a valid number");
142 
143  int dim = (values.size() - 1) / 2;
144  int npts = values[0];
145  Array<OneD, Array<OneD, NekDouble> > pts(dim);
146 
147  for (int i = 0; i < dim; ++i)
148  {
149  pts[i] = Array<OneD, NekDouble>(npts);
150  }
151 
152  for (int i = 0; i < npts; ++i)
153  {
154  pts[0][i] =
155  values[1] +
156  i / ((NekDouble)(npts - 1)) * (values[dim + 1] - values[1]);
157  if (dim > 1)
158  {
159  pts[1][i] = values[2] +
160  i / ((NekDouble)(npts - 1)) *
161  (values[dim + 2] - values[2]);
162 
163  if (dim > 2)
164  {
165  pts[2][i] = values[3] +
166  i / ((NekDouble)(npts - 1)) *
167  (values[dim + 3] - values[3]);
168  }
169  }
170  }
171 
172  vector<int> ppe;
173  ppe.push_back(npts);
174  m_f->m_fieldPts =
176  pts);
177  m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsLine);
178  m_f->m_fieldPts->SetPointsPerEdge(ppe);
179  }
180  else if (m_config["plane"].as<string>().compare("NotSet") != 0)
181  {
182  string help = m_config["plane"].as<string>();
183  vector<NekDouble> values;
185  m_config["plane"].as<string>().c_str(), values),
186  "Failed to interpret plane string");
187 
188  ASSERTL0(values.size() > 9,
189  "plane string should contain 4 Dim+2 values "
190  "N1,N2,x0,y0,z0,x1,y1,z1,x2,y2,z2,x3,y3,z3");
191 
192  double tmp;
193  ASSERTL0(std::modf(values[0], &tmp) == 0.0, "N1 is not an integer");
194  ASSERTL0(std::modf(values[1], &tmp) == 0.0, "N2 is not an integer");
195 
196  ASSERTL0(values[0] > 1, "N1 is not a valid number");
197  ASSERTL0(values[1] > 1, "N2 is not a valid number");
198 
199  int dim = (values.size() - 2) / 4;
200 
201  int npts1 = values[0];
202  int npts2 = values[1];
203 
204  Array<OneD, Array<OneD, NekDouble> > pts(dim);
205 
206  int totpts = npts1 * npts2;
207  int nlocpts = totpts / nprocs;
208 
209  if (rank < nprocs - 1)
210  {
211  for (int i = 0; i < dim; ++i)
212  {
213  pts[i] = Array<OneD, NekDouble>(nlocpts);
214  }
215 
216  int cnt = 0;
217  int cntloc = 0;
218 
219  for (int j = 0; j < npts2; ++j)
220  {
221  for (int i = 0; i < npts1; ++i)
222  {
223 
224  if ((cnt >= rank * nlocpts) &&
225  (cnt < (rank + 1) * nlocpts))
226  {
227  pts[0][cntloc] =
228  (values[2] +
229  i / ((NekDouble)(npts1 - 1)) *
230  (values[dim + 2] - values[2])) *
231  (1.0 - j / ((NekDouble)(npts2 - 1))) +
232  (values[3 * dim + 2] +
233  i / ((NekDouble)(npts1 - 1)) *
234  (values[2 * dim + 2] -
235  values[3 * dim + 2])) *
236  (j / ((NekDouble)(npts2 - 1)));
237 
238  pts[1][cntloc] =
239  (values[3] +
240  i / ((NekDouble)(npts1 - 1)) *
241  (values[dim + 3] - values[3])) *
242  (1.0 - j / ((NekDouble)(npts2 - 1))) +
243  (values[3 * dim + 3] +
244  i / ((NekDouble)(npts1 - 1)) *
245  (values[2 * dim + 3] -
246  values[3 * dim + 3])) *
247  (j / ((NekDouble)(npts2 - 1)));
248 
249  if (dim > 2)
250  {
251  pts[2][cntloc] =
252  (values[4] +
253  i / ((NekDouble)(npts1 - 1)) *
254  (values[dim + 4] - values[4])) *
255  (1.0 - j / ((NekDouble)(npts2 - 1))) +
256  (values[3 * dim + 4] +
257  i / ((NekDouble)(npts1 - 1)) *
258  (values[2 * dim + 4] -
259  values[3 * dim + 4])) *
260  (j / ((NekDouble)(npts2 - 1)));
261  }
262  cntloc++;
263  }
264  cnt++;
265  }
266  }
267  }
268  else
269  {
270  totpts = totpts - rank * nlocpts;
271 
272  for (int i = 0; i < dim; ++i)
273  {
274  pts[i] = Array<OneD, NekDouble>(totpts);
275  }
276 
277  int cnt = 0;
278  int cntloc = 0;
279 
280  for (int j = 0; j < npts2; ++j)
281  {
282  for (int i = 0; i < npts1; ++i)
283  {
284 
285  if (cnt >= rank * nlocpts)
286  {
287  pts[0][cntloc] =
288  (values[2] +
289  i / ((NekDouble)(npts1 - 1)) *
290  (values[dim + 2] - values[2])) *
291  (1.0 - j / ((NekDouble)(npts2 - 1))) +
292  (values[3 * dim + 2] +
293  i / ((NekDouble)(npts1 - 1)) *
294  (values[2 * dim + 2] -
295  values[3 * dim + 2])) *
296  (j / ((NekDouble)(npts2 - 1)));
297 
298  pts[1][cntloc] =
299  (values[3] +
300  i / ((NekDouble)(npts1 - 1)) *
301  (values[dim + 3] - values[3])) *
302  (1.0 - j / ((NekDouble)(npts2 - 1))) +
303  (values[3 * dim + 3] +
304  i / ((NekDouble)(npts1 - 1)) *
305  (values[2 * dim + 3] -
306  values[3 * dim + 3])) *
307  (j / ((NekDouble)(npts2 - 1)));
308 
309  if (dim > 2)
310  {
311  pts[2][cntloc] =
312  (values[4] +
313  i / ((NekDouble)(npts1 - 1)) *
314  (values[dim + 4] - values[4])) *
315  (1.0 - j / ((NekDouble)(npts2 - 1))) +
316  (values[3 * dim + 4] +
317  i / ((NekDouble)(npts1 - 1)) *
318  (values[2 * dim + 4] -
319  values[3 * dim + 4])) *
320  (j / ((NekDouble)(npts2 - 1)));
321  }
322  cntloc++;
323  }
324  cnt++;
325  }
326  }
327  }
328 
329  vector<int> ppe;
330  ppe.push_back(npts1);
331  ppe.push_back(npts2);
332  m_f->m_fieldPts =
334  pts);
335  m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsPlane);
336  m_f->m_fieldPts->SetPointsPerEdge(ppe);
337  }
338  else if (m_config["box"].as<string>().compare("NotSet") != 0)
339  {
340  string help = m_config["box"].as<string>();
341  vector<NekDouble> values;
343  m_config["box"].as<string>().c_str(), values),
344  "Failed to interpret box string");
345 
346  ASSERTL0(values.size() == 9,
347  "box string should contain 9 values "
348  "N1,N2,N3,xmin,xmax,ymin,ymax,zmin,zmax");
349 
350  int dim = 3;
351 
352  int npts1 = values[0];
353  int npts2 = values[1];
354  int npts3 = values[2];
355 
356  Array<OneD, Array<OneD, NekDouble> > pts(dim);
357 
358  int totpts = npts1 * npts2 * npts3;
359  int nlocpts = totpts / nprocs;
360 
361  if (rank < nprocs - 1) // for rank 0 to nproc-1
362  {
363  totpts = nlocpts;
364 
365  for (int i = 0; i < dim; ++i)
366  {
367  pts[i] = Array<OneD, NekDouble>(totpts);
368  }
369 
370  int cnt = 0;
371  int cntloc = 0;
372 
373  for (int k = 0; k < npts3; ++k)
374  {
375  for (int j = 0; j < npts2; ++j)
376  {
377  for (int i = 0; i < npts1; ++i)
378  {
379  if ((cnt >= rank * nlocpts) &&
380  (cnt < (rank + 1) * nlocpts))
381  {
382  pts[0][cntloc] = values[3] +
383  i / ((NekDouble)(npts1 - 1)) *
384  (values[4] - values[3]);
385  pts[1][cntloc] = values[5] +
386  j / ((NekDouble)(npts2 - 1)) *
387  (values[6] - values[5]);
388  pts[2][cntloc] = values[7] +
389  k / ((NekDouble)(npts3 - 1)) *
390  (values[8] - values[7]);
391  cntloc++;
392  }
393  cnt++;
394  }
395  }
396  }
397  }
398  else // give last rank all remaining points
399  {
400  totpts = totpts - rank * nlocpts;
401 
402  for (int i = 0; i < dim; ++i)
403  {
404  pts[i] = Array<OneD, NekDouble>(totpts);
405  }
406 
407  int cnt = 0;
408  int cntloc = 0;
409 
410  for (int k = 0; k < npts3; ++k)
411  {
412  for (int j = 0; j < npts2; ++j)
413  {
414  for (int i = 0; i < npts1; ++i)
415  {
416  if (cnt >= rank * nlocpts)
417  {
418  pts[0][cntloc] = values[3] +
419  i / ((NekDouble)(npts1 - 1)) *
420  (values[4] - values[3]);
421  pts[1][cntloc] = values[5] +
422  j / ((NekDouble)(npts2 - 1)) *
423  (values[6] - values[5]);
424  pts[2][cntloc] = values[7] +
425  k / ((NekDouble)(npts3 - 1)) *
426  (values[8] - values[7]);
427  cntloc++;
428  }
429  cnt++;
430  }
431  }
432  }
433  }
434 
435  vector<int> ppe;
436  ppe.push_back(npts1);
437  ppe.push_back(npts2);
438  ppe.push_back(npts3);
439  m_f->m_fieldPts =
441  pts);
442  m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsBox);
443  m_f->m_fieldPts->SetPointsPerEdge(ppe);
444  vector<NekDouble> boxdim;
445  boxdim.assign(&values[3], &values[3] + 6);
446  m_f->m_fieldPts->SetBoxSize(boxdim);
447  }
448  }
449 
450  FieldSharedPtr fromField = boost::shared_ptr<Field>(new Field());
451 
452  std::vector<std::string> files;
453  ParseUtils::GenerateOrderedStringVector(m_config["fromxml"].as<string>().c_str(), files);
454  // set up session file for from field
455  fromField->m_session =
457 
458  // Set up range based on min and max of local parallel partition
461 
462  int coordim = m_f->m_fieldPts->GetDim();
463  int npts = m_f->m_fieldPts->GetNpoints();
464  Array<OneD, Array<OneD, NekDouble> > pts;
465  m_f->m_fieldPts->GetPts(pts);
466 
467  rng->m_checkShape = false;
468  rng->m_zmin = -1;
469  rng->m_zmax = 1;
470  rng->m_ymin = -1;
471  rng->m_ymax = 1;
472  switch (coordim)
473  {
474  case 3:
475  rng->m_doZrange = true;
476  rng->m_zmin = Vmath::Vmin(npts, pts[2], 1);
477  rng->m_zmax = Vmath::Vmax(npts, pts[2], 1);
478  if (rng->m_zmax == rng->m_zmin)
479  {
480  rng->m_zmin -= 1;
481  rng->m_zmax += 1;
482  }
483  case 2:
484  rng->m_doYrange = true;
485  rng->m_ymin = Vmath::Vmin(npts, pts[1], 1);
486  rng->m_ymax = Vmath::Vmax(npts, pts[1], 1);
487  case 1:
488  rng->m_doXrange = true;
489  rng->m_xmin = Vmath::Vmin(npts, pts[0], 1);
490  rng->m_xmax = Vmath::Vmax(npts, pts[0], 1);
491  break;
492  default:
493  ASSERTL0(false, "too many values specfied in range");
494  }
495 
496  // setup rng parameters.
497  fromField->m_graph =
498  SpatialDomains::MeshGraph::Read(fromField->m_session, rng);
499 
500  // Read in local from field partitions
501  const SpatialDomains::ExpansionMap &expansions =
502  fromField->m_graph->GetExpansions();
503 
504  Array<OneD, int> ElementGIDs(expansions.size());
505  SpatialDomains::ExpansionMap::const_iterator expIt;
506 
507  int i = 0;
508  for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
509  {
510  ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
511  }
512 
513  // check to see that we do have some elmement in teh domain since
514  // possibly all points could be outside of the domain
515  ASSERTL0(i > 0, "No elements are set. Are the interpolated points "
516  "wihtin the domain given by the xml files?");
517 
518  string fromfld = m_config["fromfld"].as<string>();
519  m_f->FieldIOForFile(fromfld)->Import(
520  fromfld, fromField->m_fielddef, fromField->m_data,
522 
523  int NumHomogeneousDir = fromField->m_fielddef[0]->m_numHomogeneousDir;
524 
525  //----------------------------------------------
526  // Set up Expansion information to use mode order from field
527  fromField->m_graph->SetExpansions(fromField->m_fielddef);
528 
529  int nfields = fromField->m_fielddef[0]->m_fields.size();
530 
531  fromField->m_exp.resize(nfields);
532  fromField->m_exp[0] = fromField->SetUpFirstExpList(NumHomogeneousDir, true);
533 
534  m_f->m_exp.resize(nfields);
535 
536  // declare auxiliary fields.
537  for (i = 1; i < nfields; ++i)
538  {
539  fromField->m_exp[i] = fromField->AppendExpList(NumHomogeneousDir);
540  }
541 
542  // load field into expansion in fromfield.
543  for (int j = 0; j < nfields; ++j)
544  {
545  for (i = 0; i < fromField->m_fielddef.size(); i++)
546  {
547  fromField->m_exp[j]->ExtractDataToCoeffs(
548  fromField->m_fielddef[i], fromField->m_data[i],
549  fromField->m_fielddef[0]->m_fields[j],
550  fromField->m_exp[j]->UpdateCoeffs());
551  }
552  fromField->m_exp[j]->BwdTrans(fromField->m_exp[j]->GetCoeffs(),
553  fromField->m_exp[j]->UpdatePhys());
554 
555  Array<OneD, NekDouble> newPts(m_f->m_fieldPts->GetNpoints());
556  m_f->m_fieldPts->AddField(newPts,
557  fromField->m_fielddef[0]->m_fields[j]);
558  }
559 
560  NekDouble clamp_low = m_config["clamptolowervalue"].as<NekDouble>();
561  NekDouble clamp_up = m_config["clamptouppervalue"].as<NekDouble>();
562  NekDouble def_value = m_config["defaultvalue"].as<NekDouble>();
563 
564  InterpolateFieldToPts(fromField->m_exp, m_f->m_fieldPts, clamp_low,
565  clamp_up, def_value);
566 
567  if (!boost::iequals(m_config["cp"].as<string>(), "NotSet"))
568  {
569  calcCp0();
570  }
571 }
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
static bool GenerateOrderedStringVector(const char *const str, std::vector< std::string > &vec)
Definition: ParseUtils.hpp:143
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
Definition: MeshGraph.cpp:124
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition: Vmath.cpp:779
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition: Vmath.cpp:871
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
boost::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:767
static std::string npts
Definition: InputFld.cpp:43
boost::shared_ptr< DomainRange > DomainRangeShPtr
Definition: MeshGraph.h:157
double NekDouble
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:179
static bool GenerateUnOrderedVector(const char *const str, std::vector< NekDouble > &vec)
Definition: ParseUtils.hpp:128
static FieldMetaDataMap NullFieldMetaDataMap
Definition: FieldIO.h:55
void InterpolateFieldToPts(vector< MultiRegions::ExpListSharedPtr > &field0, LibUtilities::PtsFieldSharedPtr &pts, NekDouble clamp_low, NekDouble clamp_up, NekDouble def_value)
std::map< int, ExpansionShPtr > ExpansionMap
Definition: MeshGraph.h:174
FieldSharedPtr m_f
Field object.

Member Data Documentation

ModuleKey Nektar::FieldUtils::ProcessInterpPoints::className
static
Initial value:
=
ModuleKey(eProcessModule, "interppoints"),
"Interpolates a set of points to another, requires fromfld and "
"fromxml to be defined, a line, plane or block of points can be "
"defined")

Definition at line 59 of file ProcessInterpPoints.h.