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

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

#include <ProcessPointDataToFld.h>

Inheritance diagram for Nektar::Utilities::ProcessPointDataToFld:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::ProcessPointDataToFld:
Collaboration graph
[legend]

Public Member Functions

 ProcessPointDataToFld (FieldSharedPtr f)
 
virtual ~ProcessPointDataToFld ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::Utilities::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
 ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
virtual void Process ()=0
 
void RegisterConfig (std::string key, std::string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
virtual void ClearElementLinks ()
 

Static Public Member Functions

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

Static Public Attributes

static ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. More...
 

Detailed Description

This processing module interpolates one field to another.

Definition at line 51 of file ProcessPointDataToFld.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessPointDataToFld::ProcessPointDataToFld ( FieldSharedPtr  f)

Definition at line 59 of file ProcessPointDataToFld.cpp.

References Nektar::Utilities::Module::m_config, and Nektar::Utilities::Module::m_requireEquiSpaced.

60  : ProcessModule(f)
61 {
62  m_requireEquiSpaced = true;
63 
64  m_config["setnantovalue"] = ConfigOption(false,"NotSet",
65  "reset any nan value to prescribed value");
66 
67  if((f->m_inputfiles.count("pts") == 0))
68  {
69  cout << endl << "A pts input file must be specified for the boundary extraction module" << endl;
70 
71  cout << "Usage: Fieldconvert -m pointdatatofld file.pts file.xml out.fld" << endl;
72  exit(3);
73  }
74 
75  if((f->m_inputfiles.count("xml") == 0)&&(f->m_inputfiles.count("xml.gz") == 0))
76  {
77  cout << endl << "An xml or xml.gz input file must be specified for the boundary extraction module" << endl;
78  cout << "Usage: Fieldconvert -m pointdatatofld file.pts file.xml out.fld" << endl;
79  exit(3);
80  }
81 
82 }
map< string, ConfigOption > m_config
List of configuration values.
Nektar::Utilities::ProcessPointDataToFld::~ProcessPointDataToFld ( )
virtual

Definition at line 84 of file ProcessPointDataToFld.cpp.

85 {
86 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::Utilities::ProcessPointDataToFld::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 55 of file ProcessPointDataToFld.h.

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

55  {
57  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::Utilities::ProcessPointDataToFld::GetModuleName ( )
inlinevirtual

Implements Nektar::Utilities::Module.

Definition at line 66 of file ProcessPointDataToFld.h.

67  {
68  return "ProcessPointDataToFld";
69  }
void Nektar::Utilities::ProcessPointDataToFld::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 88 of file ProcessPointDataToFld.cpp.

References ASSERTL0, Nektar::LibUtilities::eIsEquiSpacedData, Nektar::Utilities::Module::m_config, Nektar::Utilities::Module::m_f, Nektar::LibUtilities::NullPtsField, Vmath::Vcopy(), and WARNINGL0.

89 {
90  if (m_f->m_verbose)
91  {
92  if(m_f->m_comm->TreatAsRankZero())
93  {
94  cout << "ProcessPointDataToFld: projecting data to expansion..."
95  << endl;
96  }
97  }
98 
99  int i,j;
100  bool setnantovalue = false;
101  NekDouble defvalue;
102 
103  if(!boost::iequals(m_config["setnantovalue"].as<string>(),"NotSet"))
104  {
105  setnantovalue = true;
106  defvalue = m_config["setnantovalue"].as<NekDouble>();
107  }
108 
109  // Check for command line point specification if no .pts file specified
110  ASSERTL0(m_f->m_fieldPts != LibUtilities::NullPtsField,
111  "No input points found");
112 
113  int nFields = m_f->m_fieldPts->GetNFields();
114  ASSERTL0(nFields > 0,
115  "No field values provided in input");
116 
117  int dim = m_f->m_fieldPts->GetDim();
118 
119  // assume one field is already defined from input file.
120  m_f->m_exp.resize(nFields);
121  for(i = 1; i < nFields; ++i)
122  {
123  m_f->m_exp[i] = m_f->AppendExpList(0);
124  }
125 
126  Array<OneD, Array<OneD, NekDouble> > pts;
127  m_f->m_fieldPts->GetPts(pts);
128 
129  // set any nan values to default value if requested
130  if(setnantovalue)
131  {
132  for(int i = 0; i < pts[0].num_elements(); ++i)
133  {
134  for(int j = 0; j < nFields; ++j)
135  {
136  if ((boost::math::isnan)(pts[j+dim][i]))
137  {
138  pts[j+dim][i] = defvalue;
139  }
140  }
141  }
142  }
143 
144  if(m_f->m_fieldPts->m_ptsInfo.count(LibUtilities::eIsEquiSpacedData) != 0)
145  {
146  int totcoeffs = m_f->m_exp[0]->GetNcoeffs();
147 
148  ASSERTL0(pts[0].num_elements() != totcoeffs,"length of points in .pts file is different "
149  "to the number of coefficients in expansion ");
150 
151  for(int i = 0; i < nFields; ++i)
152  {
153  Array<OneD, NekDouble> coeffs = m_f->m_exp[i]->UpdateCoeffs(), tmp;
154  int cnt = 0;
155  for(int e = 0; e < m_f->m_exp[0]->GetNumElmts(); ++e)
156  {
157  int ncoeffs = m_f->m_exp[i]->GetExp(e)->GetNcoeffs();
158  int offset = m_f->m_exp[i]->GetCoeff_Offset(e);
159  Vmath::Vcopy(ncoeffs,&pts[i+dim][cnt],1,&coeffs[offset],1);
160 
161  m_f->m_exp[i]->GetExp(e)->EquiSpacedToCoeffs(coeffs+offset,tmp = coeffs+offset);
162  cnt += ncoeffs;
163  }
164  }
165  }
166  else
167  {
168  int totpoints = m_f->m_exp[0]->GetTotPoints();
169  Array< OneD, Array<OneD, NekDouble> > coords(3);
170 
171  coords[0] = Array<OneD,NekDouble>(totpoints);
172  coords[1] = Array<OneD,NekDouble>(totpoints);
173  coords[2] = Array<OneD,NekDouble>(totpoints);
174 
175  m_f->m_exp[0]->GetCoords(coords[0],coords[1],coords[2]);
176 
177 
178  if(pts[0].num_elements() != totpoints)
179  {
180  WARNINGL0(false,"length of points in .pts file is different to the number of quadrature points in xml file");
181  totpoints = min(totpoints,(int)pts[0].num_elements());
182  }
183 
184  int mismatch = 0;
185  for(i = 0; i < totpoints; ++i)
186  {
187  for(j = 0; j < dim; ++j)
188  {
189  if(fabs(coords[j][i]-pts[j][i]) > 1e-4)
190  {
191  string outstring = "Coordinates do not match within 1e-4: "
192  + boost::lexical_cast<string>(coords[j][i])
193  + " versus "
194  + boost::lexical_cast<string>(pts[j][i])
195  + " diff " + boost::lexical_cast<string>(fabs(coords[j][i]-pts[j][i]));;
196  WARNINGL0(false,outstring);
197  mismatch +=1;
198  }
199  }
200 
201  for(j = 0;j < nFields; ++j)
202  {
203  m_f->m_exp[j]->SetPhys(i, pts[j+dim][i]);
204  }
205  }
206 
207  if(m_f->m_session->GetComm()->GetRank() == 0)
208  {
209  cout << endl;
210  }
211 
212  // forward transform fields
213  for(i = 0; i < nFields; ++i)
214  {
215  m_f->m_exp[i]->FwdTrans_IterPerExp(m_f->m_exp[i]->GetPhys(),
216  m_f->m_exp[i]->UpdateCoeffs());
217  }
218  }
219 
220  // set up output fld file.
221  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
222  = m_f->m_exp[0]->GetFieldDefinitions();
223  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
224 
225  for (j = 0; j < nFields; ++j)
226  {
227  for (i = 0; i < FieldDef.size(); ++i)
228  {
229  FieldDef[i]->m_fields.push_back(m_f->m_fieldPts->GetFieldName(j));
230 
231  m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
232  }
233  }
234 
235  m_f->m_fielddef = FieldDef;
236  m_f->m_data = FieldData;
237 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
map< string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.
#define WARNINGL0(condition, msg)
Definition: ErrorUtil.hpp:194
double NekDouble
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:263
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessPointDataToFld::className
static
Initial value:
=
ModuleKey(eProcessModule, "pointdatatofld"),
"Given discrete data at quadrature points project them onto an expansion"
"basis and output fld file. Requires .pts .xml and .fld files.")

Definition at line 58 of file ProcessPointDataToFld.h.