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...
 
- 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 (string key, 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, set< int > &prismsDone, 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...
 

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