Nektar++
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:
[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 ()
 
virtual std::string GetModuleDescription ()
 
virtual ModulePriority GetModulePriority ()
 
- 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 (std::string key, std::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 void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

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

Static Public Attributes

static ModuleKey className
 

Private Member Functions

void CreateFieldPts (po::variables_map &vm)
 
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...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 

Detailed Description

This processing module interpolates one field to another.

Definition at line 50 of file ProcessInterpPoints.h.

Constructor & Destructor Documentation

◆ ProcessInterpPoints()

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

Definition at line 68 of file ProcessInterpPoints.cpp.

References Nektar::FieldUtils::Module::m_config.

68  : ProcessModule(f)
69 {
70  m_config["fromxml"] = ConfigOption(
71  false, "NotSet", "Xml file from which to interpolate field");
72 
73  m_config["fromfld"] = ConfigOption(
74  false, "NotSet", "Fld file from which to interpolate field");
75 
76  m_config["topts"] = ConfigOption(
77  false, "NotSet", "Pts file to which interpolate field");
78  m_config["line"] = ConfigOption(
79  false, "NotSet", "Specify a line of N points using "
80  "line=N,x0,y0,z0,z1,y1,z1");
81  m_config["plane"] = ConfigOption(
82  false, "NotSet", "Specify a plane of N1 x N2 points using "
83  "plane=N1,N2,x0,y0,z0,z1,y1,z1,x2,y2,z2,x3,y3,z3");
84  m_config["box"] = ConfigOption(
85  false, "NotSet", "Specify a rectangular box of N1 x N2 x N3 points "
86  "using a box of points limited by box="
87  "N1,N2,N3,xmin,xmax,ymin,ymax,zmin,zmax");
88 
89  m_config["clamptolowervalue"] =
90  ConfigOption(false, "-10000000", "Lower bound for interpolation value");
91  m_config["clamptouppervalue"] =
92  ConfigOption(false, "10000000", "Upper bound for interpolation value");
93  m_config["defaultvalue"] =
94  ConfigOption(false, "0", "Default value if point is outside domain");
95 
96  m_config["cp"] =
97  ConfigOption(false, "NotSet",
98  "Parameters p0 and q to determine pressure coefficients");
99 }
std::map< std::string, ConfigOption > m_config
List of configuration values.

◆ ~ProcessInterpPoints()

Nektar::FieldUtils::ProcessInterpPoints::~ProcessInterpPoints ( )
virtual

Definition at line 101 of file ProcessInterpPoints.cpp.

102 {
103 }

Member Function Documentation

◆ calcCp0()

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

Definition at line 501 of file ProcessInterpPoints.cpp.

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

Referenced by GetModulePriority(), and Process().

502 {
503  LibUtilities::PtsFieldSharedPtr pts = m_f->m_fieldPts;
504  int dim = pts->GetDim();
505  int nq1 = pts->GetNpoints();
506  int r, f;
507  int pfield = -1;
508  NekDouble p0,qinv;
509  vector<int> velid;
510 
511  vector<NekDouble> values;
512  ASSERTL0(ParseUtils::GenerateVector(m_config["cp"].as<string>(), values),
513  "Failed to interpret cp string");
514 
515  ASSERTL0(values.size() == 2,
516  "cp string should contain 2 values "
517  "p0 and q (=1/2 rho u^2)");
518 
519  p0 = values[0];
520  qinv = 1.0/values[1];
521 
522  for(int i = 0; i < pts->GetNFields(); ++i)
523  {
524  if(boost::iequals(pts->GetFieldName(i),"p"))
525  {
526  pfield = i;
527  }
528 
529  if(boost::iequals(pts->GetFieldName(i),"u")||
530  boost::iequals(pts->GetFieldName(i),"v")||
531  boost::iequals(pts->GetFieldName(i),"w"))
532  {
533  velid.push_back(i);
534  }
535  }
536 
537  if(pfield != -1)
538  {
539  if(!velid.size())
540  {
541  WARNINGL0(false,"Did not find velocity components for Cp0");
542  }
543  }
544  else
545  {
546  WARNINGL0(false,"Failed to find 'p' field to determine cp0");
547  }
548 
549  // Allocate data storage
550  Array<OneD, Array< OneD, NekDouble> > data(2);
551 
552  for (f = 0; f < 2; ++f)
553  {
554  data[f] = Array< OneD, NekDouble>(nq1, 0.0);
555  }
556 
557  for (r = 0; r < nq1; r++)
558  {
559  if(pfield != -1) // calculate cp
560  {
561  data[0][r] = qinv*(pts->GetPointVal(dim + pfield, r) - p0);
562 
563  if(velid.size()) // calculate cp0
564  {
565  NekDouble q = 0;
566  for(int i = 0; i < velid.size(); ++i)
567  {
568  q += 0.5*pts->GetPointVal(dim + velid[i], r)*
569  pts->GetPointVal(dim + velid[i], r);
570  }
571  data[1][r] = qinv*(pts->GetPointVal(dim + pfield, r)+q - p0);
572  }
573  }
574  }
575 
576  if(pfield != -1)
577  {
578  pts->AddField(data[0], "Cp");
579  m_f->m_variables.push_back("Cp");
580  if(velid.size())
581  {
582  pts->AddField(data[1], "Cp0");
583  m_f->m_variables.push_back("Cp0");
584  }
585  }
586 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::map< std::string, ConfigOption > m_config
List of configuration values.
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:179
#define WARNINGL0(condition, msg)
Definition: ErrorUtil.hpp:223
double NekDouble
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
Definition: ParseUtils.cpp:135
FieldSharedPtr m_f
Field object.

◆ create()

static std::shared_ptr<Module> Nektar::FieldUtils::ProcessInterpPoints::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 54 of file ProcessInterpPoints.h.

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

55  {
57  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ CreateFieldPts()

void Nektar::FieldUtils::ProcessInterpPoints::CreateFieldPts ( po::variables_map &  vm)
private

Definition at line 228 of file ProcessInterpPoints.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::ePtsBox, Nektar::LibUtilities::ePtsLine, Nektar::LibUtilities::ePtsPlane, Nektar::ParseUtils::GenerateVector(), Nektar::FieldUtils::Module::m_config, and Nektar::FieldUtils::Module::m_f.

Referenced by GetModulePriority(), and Process().

229 {
230  boost::ignore_unused(vm);
231 
232  int rank = m_f->m_comm->GetRank();
233  int nprocs = m_f->m_comm->GetSize();
234  // Check for command line point specification
235 
236  if (m_config["topts"].as<string>().compare("NotSet") != 0)
237  {
238  string inFile = m_config["topts"].as<string>();
239 
240  if (boost::filesystem::path(inFile).extension() == ".pts")
241  {
244 
245  ptsIO->Import(inFile, m_f->m_fieldPts);
246  }
247  else if (boost::filesystem::path(inFile).extension() == ".csv")
248  {
251 
252  csvIO->Import(inFile, m_f->m_fieldPts);
253  }
254  else
255  {
256  ASSERTL0(false, "unknown topts file type");
257  }
258 
259  }
260  else if (m_config["line"].as<string>().compare("NotSet") != 0)
261  {
262  vector<NekDouble> values;
264  m_config["line"].as<string>(), values),
265  "Failed to interpret line string");
266 
267  ASSERTL0(values.size() > 2,
268  "line string should contain 2*Dim+1 values "
269  "N,x0,y0,z0,x1,y1,z1");
270 
271  double tmp;
272  ASSERTL0(std::modf(values[0], &tmp) == 0.0, "N is not an integer");
273  ASSERTL0(values[0] > 1, "N is not a valid number");
274 
275  int dim = (values.size() - 1) / 2;
276  int npts = values[0];
277 
278  // Information for partitioning
279  int ptsPerProc = npts / nprocs;
280  int extraPts = (rank < nprocs - 1) ? 0: npts % nprocs;
281  int locPts = ptsPerProc + extraPts;
282  int start = rank * ptsPerProc;
283  int end = start + locPts;
284 
285  Array<OneD, Array<OneD, NekDouble> > pts(dim);
286  Array<OneD, NekDouble> delta(dim);
287  for (int i = 0; i < dim; ++i)
288  {
289  pts[i] = Array<OneD, NekDouble>(locPts);
290  delta[i] = (values[dim + i + 1] - values[ i + 1]) / (npts - 1);
291  }
292 
293 
294 
295  for (int i = 0, cntLoc = 0; i < npts; ++i)
296  {
297  if (i >= start && i < end)
298  {
299  for (int n = 0; n < dim; ++n)
300  {
301  pts[n][cntLoc] = values[n+1] + i * delta[n];
302  }
303  ++cntLoc;
304  }
305  }
306 
307  vector<size_t> ppe;
308  ppe.push_back(npts);
309  m_f->m_fieldPts =
311  pts);
312  m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsLine);
313  m_f->m_fieldPts->SetPointsPerEdge(ppe);
314  }
315  else if (m_config["plane"].as<string>().compare("NotSet") != 0)
316  {
317  vector<NekDouble> values;
319  m_config["plane"].as<string>(), values),
320  "Failed to interpret plane string");
321 
322  ASSERTL0(values.size() > 9,
323  "plane string should contain 4 Dim+2 values "
324  "N1,N2,x0,y0,z0,x1,y1,z1,x2,y2,z2,x3,y3,z3");
325 
326  double tmp;
327  ASSERTL0(std::modf(values[0], &tmp) == 0.0, "N1 is not an integer");
328  ASSERTL0(std::modf(values[1], &tmp) == 0.0, "N2 is not an integer");
329 
330  ASSERTL0(values[0] > 1, "N1 is not a valid number");
331  ASSERTL0(values[1] > 1, "N2 is not a valid number");
332 
333  int dim = (values.size() - 2) / 4;
334 
335  Array<OneD, int> npts(2);
336  npts[0] = values[0];
337  npts[1] = values[1];
338 
339  int totpts = npts[0] * npts[1];
340 
341  // Information for partitioning
342  int ptsPerProc = totpts / nprocs;
343  int extraPts = (rank < nprocs - 1) ? 0: totpts % nprocs;
344  int locPts = ptsPerProc + extraPts;
345  int start = rank * ptsPerProc;
346  int end = start + locPts;
347 
348  Array<OneD, Array<OneD, NekDouble> > pts(dim);
349  Array<OneD, NekDouble> delta1(dim);
350  Array<OneD, NekDouble> delta2(dim);
351  for (int i = 0; i < dim; ++i)
352  {
353  pts[i] = Array<OneD, NekDouble>(locPts);
354  delta1[i] = (values[2+1*dim + i] - values[2+0*dim + i])/(npts[0]-1);
355  delta2[i] = (values[2+2*dim + i] - values[2+3*dim + i])/(npts[0]-1);
356  }
357 
358  for (int j = 0, cnt = 0, cntLoc = 0; j < npts[1]; ++j)
359  {
360  for (int i = 0; i < npts[0]; ++i, ++cnt)
361  {
362  if (cnt >= start && cnt < end)
363  {
364  for (int n = 0; n < dim; ++n)
365  {
366  pts[n][cntLoc] =
367  (values[2+n] + i * delta1[n]) *
368  (1.0 - j / ((NekDouble)(npts[1]-1))) +
369  (values[2 + 3*dim + n] + i * delta2[n]) *
370  ( j / ((NekDouble)(npts[1]-1)));
371  }
372  ++cntLoc;
373  }
374  }
375  }
376 
377  vector<size_t> ppe;
378  ppe.push_back(npts[0]);
379  ppe.push_back(npts[1]);
380  m_f->m_fieldPts =
382  pts);
383  m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsPlane);
384  m_f->m_fieldPts->SetPointsPerEdge(ppe);
385  }
386  else if (m_config["box"].as<string>().compare("NotSet") != 0)
387  {
388  vector<NekDouble> values;
390  m_config["box"].as<string>(), values),
391  "Failed to interpret box string");
392 
393  ASSERTL0(values.size() == 9,
394  "box string should contain 9 values "
395  "N1,N2,N3,xmin,xmax,ymin,ymax,zmin,zmax");
396 
397  int dim = 3;
398  Array<OneD, int> npts(3);
399  npts[0] = values[0];
400  npts[1] = values[1];
401  npts[2] = values[2];
402 
403  int totpts = npts[0]*npts[1]*npts[2];
404 
405  Array<OneD, Array<OneD, NekDouble> > pts(dim);
406  Array<OneD, NekDouble> delta(dim);
407 
408  // Information for partitioning
409  int ptsPerProc = totpts / nprocs;
410  int extraPts = (rank < nprocs - 1) ? 0: totpts % nprocs;
411  int locPts = ptsPerProc + extraPts;
412  int start = rank * ptsPerProc;
413  int end = start + locPts;
414 
415  for (int i = 0; i < dim; ++i)
416  {
417  pts[i] = Array<OneD, NekDouble>(locPts);
418  delta[i] = (values[4 + 2*i] - values[3 + 2*i]) / (npts[i] - 1);
419  }
420 
421 
422 
423  for (int k = 0, cnt = 0, cntLoc = 0; k < npts[2]; ++k)
424  {
425  for (int j = 0; j < npts[1]; ++j)
426  {
427  for (int i = 0; i < npts[0]; ++i, ++cnt)
428  {
429  if (cnt >= start && cnt < end)
430  {
431  pts[0][cntLoc] = values[3] + i * delta[0];
432  pts[1][cntLoc] = values[5] + j * delta[1];
433  pts[2][cntLoc] = values[7] + k * delta[2];
434  ++cntLoc;
435  }
436  }
437  }
438  }
439 
440  vector<size_t> ppe;
441  ppe.push_back(npts[0]);
442  ppe.push_back(npts[1]);
443  ppe.push_back(npts[2]);
444  m_f->m_fieldPts =
446  pts);
447  m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsBox);
448  m_f->m_fieldPts->SetPointsPerEdge(ppe);
449  vector<NekDouble> boxdim;
450  boxdim.assign(&values[3], &values[3] + 6);
451  m_f->m_fieldPts->SetBoxSize(boxdim);
452  }
453  else
454  {
455  ASSERTL0(false,
456  "Missing target points for ProcessInterpPoints.");
457  }
458 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::map< std::string, ConfigOption > m_config
List of configuration values.
std::shared_ptr< PtsIO > PtsIOSharedPtr
Definition: PtsIO.h:96
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
double NekDouble
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
Definition: ParseUtils.cpp:135
std::shared_ptr< CsvIO > CsvIOSharedPtr
Definition: CsvIO.h:81
FieldSharedPtr m_f
Field object.

◆ GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessInterpPoints::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 73 of file ProcessInterpPoints.h.

74  {
75  return "Interpolating to points";
76  }

◆ GetModuleName()

virtual std::string Nektar::FieldUtils::ProcessInterpPoints::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 68 of file ProcessInterpPoints.h.

69  {
70  return "ProcessInterpPoints";
71  }

◆ GetModulePriority()

virtual ModulePriority Nektar::FieldUtils::ProcessInterpPoints::GetModulePriority ( )
inlinevirtual

◆ InterpolateFieldToPts()

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 460 of file ProcessInterpPoints.cpp.

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

Referenced by GetModulePriority(), and Process().

466 {
467  boost::ignore_unused(def_value);
468 
469  ASSERTL0(pts->GetNFields() == field0.size(), "ptField has too few fields");
470 
471  int nfields = field0.size();
472 
473  Interpolator interp;
474  if (m_f->m_comm->GetRank() == 0)
475  {
476  interp.SetProgressCallback(&ProcessInterpPoints::PrintProgressbar,
477  this);
478  }
479  interp.Interpolate(field0, pts);
480  if (m_f->m_comm->GetRank() == 0)
481  {
482  cout << endl;
483  }
484 
485  for (int f = 0; f < nfields; ++f)
486  {
487  for (int i = 0; i < pts->GetNpoints(); ++i)
488  {
489  if (pts->GetPointVal(f, i) > clamp_up)
490  {
491  pts->SetPointVal(f, i, clamp_up);
492  }
493  else if (pts->GetPointVal(f, i) < clamp_low)
494  {
495  pts->SetPointVal(f, i, clamp_low);
496  }
497  }
498  }
499 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
void PrintProgressbar(const int position, const int goal) const
FieldSharedPtr m_f
Field object.

◆ PrintProgressbar()

void Nektar::FieldUtils::ProcessInterpPoints::PrintProgressbar ( const int  position,
const int  goal 
) const

Definition at line 588 of file ProcessInterpPoints.cpp.

References Nektar::LibUtilities::PrintProgressbar().

Referenced by InterpolateFieldToPts().

590 {
591  LibUtilities::PrintProgressbar(position, goal, "Interpolating");
592 }
int PrintProgressbar(const int position, const int goal, const std::string message, int lastprogress=-1)
Prints a progressbar.
Definition: Progressbar.hpp:67

◆ Process()

void Nektar::FieldUtils::ProcessInterpPoints::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 105 of file ProcessInterpPoints.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, calcCp0(), CreateFieldPts(), Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::ErrorUtil::efatal, Nektar::ParseUtils::GenerateVector(), Nektar::LibUtilities::GetCommFactory(), InterpolateFieldToPts(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, NEKERROR, Nektar::LibUtilities::NullFieldMetaDataMap, Nektar::SpatialDomains::MeshGraph::Read(), Vmath::Vmax(), and Vmath::Vmin().

106 {
107  CreateFieldPts(vm);
108 
109  FieldSharedPtr fromField = std::shared_ptr<Field>(new Field());
110  std::vector<std::string> files;
111  ParseUtils::GenerateVector(m_config["fromxml"].as<string>(), files);
112 
113  // set up session file for from field
114  char *argv[] = { const_cast<char *>("FieldConvert"), nullptr };
115  fromField->m_session =
117  1, argv, files,
118  LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0));
119  // Set up range based on min and max of local parallel partition
122  int coordim = m_f->m_fieldPts->GetDim();
123  int npts = m_f->m_fieldPts->GetNpoints();
124  std::vector<std::string> fieldNames = m_f->m_fieldPts->GetFieldNames();
125  for (auto &it : fieldNames)
126  {
127  m_f->m_fieldPts->RemoveField(it);
128  }
129 
130  Array<OneD, Array<OneD, NekDouble> > pts;
131  m_f->m_fieldPts->GetPts(pts);
132 
133  rng->m_checkShape = false;
134  rng->m_zmin = -1;
135  rng->m_zmax = 1;
136  rng->m_ymin = -1;
137  rng->m_ymax = 1;
138  switch (coordim)
139  {
140  case 3:
141  rng->m_doZrange = true;
142  rng->m_zmin = Vmath::Vmin(npts, pts[2], 1);
143  rng->m_zmax = Vmath::Vmax(npts, pts[2], 1);
144  if (rng->m_zmax == rng->m_zmin)
145  {
146  rng->m_zmin -= 1;
147  rng->m_zmax += 1;
148  }
149  /* Falls through. */
150  case 2:
151  rng->m_doYrange = true;
152  rng->m_ymin = Vmath::Vmin(npts, pts[1], 1);
153  rng->m_ymax = Vmath::Vmax(npts, pts[1], 1);
154  /* Falls through. */
155  case 1:
156  rng->m_doXrange = true;
157  rng->m_xmin = Vmath::Vmin(npts, pts[0], 1);
158  rng->m_xmax = Vmath::Vmax(npts, pts[0], 1);
159  break;
160  default:
161  NEKERROR(ErrorUtil::efatal, "too many values specfied in range");
162  }
163  // setup rng parameters.
164  fromField->m_graph =
165  SpatialDomains::MeshGraph::Read(fromField->m_session, rng);
166  // Read in local from field partitions
167  const SpatialDomains::ExpansionMap &expansions =
168  fromField->m_graph->GetExpansions();
169  Array<OneD, int> ElementGIDs(expansions.size());
170 
171  int i = 0;
172  for (auto &expIt : expansions)
173  {
174  ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
175  }
176  // check to see that we do have some elmement in teh domain since
177  // possibly all points could be outside of the domain
178  ASSERTL0(i > 0, "No elements are set. Are the interpolated points "
179  "wihtin the domain given by the xml files?");
180  string fromfld = m_config["fromfld"].as<string>();
181  m_f->FieldIOForFile(fromfld)->Import(
182  fromfld, fromField->m_fielddef, fromField->m_data,
184  int NumHomogeneousDir = fromField->m_fielddef[0]->m_numHomogeneousDir;
185  //----------------------------------------------
186  // Set up Expansion information to use mode order from field
187  fromField->m_graph->SetExpansions(fromField->m_fielddef);
188  int nfields = fromField->m_fielddef[0]->m_fields.size();
189  fromField->m_exp.resize(nfields);
190  fromField->m_exp[0] = fromField->SetUpFirstExpList(NumHomogeneousDir, true);
191  m_f->m_exp.resize(nfields);
192  // declare auxiliary fields.
193  for (i = 1; i < nfields; ++i)
194  {
195  fromField->m_exp[i] = fromField->AppendExpList(NumHomogeneousDir);
196  }
197  // load field into expansion in fromfield.
198  for (int j = 0; j < nfields; ++j)
199  {
200  for (i = 0; i < fromField->m_fielddef.size(); i++)
201  {
202  fromField->m_exp[j]->ExtractDataToCoeffs(
203  fromField->m_fielddef[i], fromField->m_data[i],
204  fromField->m_fielddef[0]->m_fields[j],
205  fromField->m_exp[j]->UpdateCoeffs());
206  }
207  fromField->m_exp[j]->BwdTrans(fromField->m_exp[j]->GetCoeffs(),
208  fromField->m_exp[j]->UpdatePhys());
209  Array<OneD, NekDouble> newPts(m_f->m_fieldPts->GetNpoints());
210  m_f->m_fieldPts->AddField(newPts,
211  fromField->m_fielddef[0]->m_fields[j]);
212  m_f->m_variables.push_back(fromField->m_fielddef[0]->m_fields[j]);
213  }
214 
215  NekDouble clamp_low = m_config["clamptolowervalue"].as<NekDouble>();
216  NekDouble clamp_up = m_config["clamptouppervalue"].as<NekDouble>();
217  NekDouble def_value = m_config["defaultvalue"].as<NekDouble>();
218 
219  InterpolateFieldToPts(fromField->m_exp, m_f->m_fieldPts, clamp_low,
220  clamp_up, def_value);
221 
222  if (!boost::iequals(m_config["cp"].as<string>(), "NotSet"))
223  {
224  calcCp0();
225  }
226 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:209
std::map< std::string, ConfigOption > m_config
List of configuration values.
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:782
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:874
std::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:762
std::shared_ptr< DomainRange > DomainRangeShPtr
Definition: MeshGraph.h:128
CommFactory & GetCommFactory()
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
double NekDouble
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
Definition: ParseUtils.cpp:135
static FieldMetaDataMap NullFieldMetaDataMap
Definition: FieldIO.h:53
void InterpolateFieldToPts(vector< MultiRegions::ExpListSharedPtr > &field0, LibUtilities::PtsFieldSharedPtr &pts, NekDouble clamp_low, NekDouble clamp_up, NekDouble def_value)
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, DomainRangeShPtr rng=NullDomainRangeShPtr, bool fillGraph=true)
Definition: MeshGraph.cpp:113
std::map< int, ExpansionShPtr > ExpansionMap
Definition: MeshGraph.h:152
FieldSharedPtr m_f
Field object.

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessInterpPoints::className
static
Initial value:
=
ModuleKey(eProcessModule, "interppoints"),
"Interpolates a field to a set of points. Requires fromfld, fromxml "
"to be defined, and a topts, line, plane or block of target points ")

Definition at line 58 of file ProcessInterpPoints.h.