Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Nektar::FieldUtils::ProcessPointDataToFld Class Reference

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

#include <ProcessPointDataToFld.h>

Inheritance diagram for Nektar::FieldUtils::ProcessPointDataToFld:
[legend]

Public Member Functions

 ProcessPointDataToFld (FieldSharedPtr f)
 
 ~ProcessPointDataToFld () override
 
- 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)
 
virtual ~Module ()=default
 
void Process (po::variables_map &vm)
 
std::string GetModuleName ()
 
std::string GetModuleDescription ()
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
ModulePriority GetModulePriority ()
 
std::vector< ModuleKeyGetModulePrerequisites ()
 
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 AddFile (std::string fileType, std::string fileName)
 
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
 

Protected Member Functions

void v_Process (po::variables_map &vm) override
 Write mesh to output file. More...
 
std::string v_GetModuleName () override
 
std::string v_GetModuleDescription () override
 
ModulePriority v_GetModulePriority () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
virtual void v_Process (po::variables_map &vm)
 
virtual std::string v_GetModuleName ()
 
virtual std::string v_GetModuleDescription ()
 
virtual ModulePriority v_GetModulePriority ()
 
virtual std::vector< ModuleKeyv_GetModulePrerequisites ()
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 
std::set< std::string > m_allowedFiles
 List of allowed file formats. More...
 

Detailed Description

This processing module interpolates one field to another.

Definition at line 48 of file ProcessPointDataToFld.h.

Constructor & Destructor Documentation

◆ ProcessPointDataToFld()

Nektar::FieldUtils::ProcessPointDataToFld::ProcessPointDataToFld ( FieldSharedPtr  f)

Definition at line 54 of file ProcessPointDataToFld.cpp.

55 : ProcessModule(f)
56{
57 m_config["setnantovalue"] = ConfigOption(
58 false, "NotSet", "reset any nan value to prescribed value");
59
60 m_config["frompts"] = ConfigOption(
61 false, "NotSet", "Pts file from which to interpolate field");
62}
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:272

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

◆ ~ProcessPointDataToFld()

Nektar::FieldUtils::ProcessPointDataToFld::~ProcessPointDataToFld ( )
override

Definition at line 64 of file ProcessPointDataToFld.cpp.

65{
66}

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 52 of file ProcessPointDataToFld.h.

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

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

◆ v_GetModuleDescription()

std::string Nektar::FieldUtils::ProcessPointDataToFld::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 70 of file ProcessPointDataToFld.h.

71 {
72 return "Projecting data to expansion";
73 }

◆ v_GetModuleName()

std::string Nektar::FieldUtils::ProcessPointDataToFld::v_GetModuleName ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessPointDataToFld.h.

66 {
67 return "ProcessPointDataToFld";
68 }

◆ v_GetModulePriority()

ModulePriority Nektar::FieldUtils::ProcessPointDataToFld::v_GetModulePriority ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 75 of file ProcessPointDataToFld.h.

76 {
77 return eFillExp;
78 }

References Nektar::FieldUtils::eFillExp.

◆ v_Process()

void Nektar::FieldUtils::ProcessPointDataToFld::v_Process ( po::variables_map &  vm)
overrideprotectedvirtual

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 68 of file ProcessPointDataToFld.cpp.

69{
70 m_f->SetUpExp(vm);
71
72 int i, j;
73 bool setnantovalue = false;
74 NekDouble defvalue = 0.0;
75
76 if (!boost::iequals(m_config["setnantovalue"].as<string>(), "NotSet"))
77 {
78 setnantovalue = true;
79 defvalue = m_config["setnantovalue"].as<NekDouble>();
80 }
81
82 // Check for command line point specification if no .pts file specified
83 // Load pts file
85 ASSERTL0(m_config["frompts"].as<string>().compare("NotSet") != 0,
86 "ProcessInterpPointDataToFld requires frompts parameter");
87 string inFile = m_config["frompts"].as<string>().c_str();
90
91 // Determine file format from file extension
92 if (fs::path(inFile).extension() == ".pts")
93 {
94 LibUtilities::PtsIO(c).Import(inFile, fieldPts);
95 }
96 else if (fs::path(inFile).extension() == ".csv")
97 {
98 LibUtilities::CsvIO(c).Import(inFile, fieldPts);
99 }
100 else
101 {
103 "Unsupported file format for the \"frompts\" parameter. "
104 "Supported formats: \".pts\" and \".csv\"");
105 }
106
107 int nFields = fieldPts->GetNFields();
108 ASSERTL0(nFields > 0, "No field values provided in input");
109
110 int dim = fieldPts->GetDim();
111
112 // assume one field is already defined from input file.
113 ASSERTL0(
114 m_f->m_numHomogeneousDir == 0,
115 "ProcessInterpPointDataToFld does not support homogeneous expansion");
116
117 m_f->m_exp.resize(nFields);
118 for (i = 1; i < nFields; ++i)
119 {
120 m_f->m_exp[i] = m_f->AppendExpList(m_f->m_numHomogeneousDir);
121 }
122
123 Array<OneD, Array<OneD, NekDouble>> pts;
124 fieldPts->GetPts(pts);
125
126 // set any nan values to default value if requested
127 if (setnantovalue)
128 {
129 for (int i = 0; i < pts[0].size(); ++i)
130 {
131 for (int j = 0; j < nFields; ++j)
132 {
133 if ((boost::math::isnan)(pts[j + dim][i]))
134 {
135 pts[j + dim][i] = defvalue;
136 }
137 }
138 }
139 }
140
141 if (fieldPts->m_ptsInfo.count(LibUtilities::eIsEquiSpacedData) != 0)
142 {
143 int totcoeffs = m_f->m_exp[0]->GetNcoeffs();
144
145 ASSERTL0(pts[0].size() != totcoeffs,
146 "length of points in .pts file is different "
147 "to the number of coefficients in expansion ");
148
149 for (int i = 0; i < nFields; ++i)
150 {
151 Array<OneD, NekDouble> coeffs = m_f->m_exp[i]->UpdateCoeffs(), tmp;
152 int cnt = 0;
153 for (int e = 0; e < m_f->m_exp[0]->GetNumElmts(); ++e)
154 {
155 int ncoeffs = m_f->m_exp[i]->GetExp(e)->GetNcoeffs();
156 int offset = m_f->m_exp[i]->GetCoeff_Offset(e);
157 Vmath::Vcopy(ncoeffs, &pts[i + dim][cnt], 1, &coeffs[offset],
158 1);
159
160 m_f->m_exp[i]->GetExp(e)->EquiSpacedToCoeffs(
161 coeffs + offset, tmp = coeffs + offset);
162 cnt += ncoeffs;
163 }
164 m_f->m_exp[i]->BwdTrans(m_f->m_exp[i]->GetCoeffs(),
165 m_f->m_exp[i]->UpdatePhys());
166 }
167 }
168 else
169 {
170 int totpoints = m_f->m_exp[0]->GetTotPoints();
171 Array<OneD, Array<OneD, NekDouble>> coords(3);
172
173 coords[0] = Array<OneD, NekDouble>(totpoints);
174 coords[1] = Array<OneD, NekDouble>(totpoints);
175 coords[2] = Array<OneD, NekDouble>(totpoints);
176
177 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
178
179 if (pts[0].size() != totpoints)
180 {
181 WARNINGL0(false, "length of points in .pts file is different to "
182 "the number of quadrature points in xml file");
183 totpoints = min(totpoints, (int)pts[0].size());
184 }
185
186 for (j = 0; j < dim; ++j)
187 {
188 for (i = 0; i < totpoints; ++i)
189 {
190 if (fabs(coords[j][i] - pts[j][i]) > 1e-4)
191 {
192 string outstring =
193 "Coordinates do not match within 1e-4: " +
194 boost::lexical_cast<string>(coords[j][i]) + " versus " +
195 boost::lexical_cast<string>(pts[j][i]) + " diff " +
196 boost::lexical_cast<string>(
197 fabs(coords[j][i] - pts[j][i]));
198 ;
199 WARNINGL0(false, outstring);
200 }
201 }
202 }
203
204 for (j = 0; j < nFields; ++j)
205 {
206 Array<OneD, NekDouble> phys = m_f->m_exp[j]->UpdatePhys();
207
208 for (i = 0; i < totpoints; ++i)
209 {
210 phys[i] = pts[j + dim][i];
211 }
212
213 // forward transform fields
214 m_f->m_exp[j]->FwdTransLocalElmt(phys,
215 m_f->m_exp[j]->UpdateCoeffs());
216 }
217 }
218
219 // save field names
220 for (int j = 0; j < fieldPts->GetNFields(); ++j)
221 {
222 m_f->m_variables.push_back(fieldPts->GetFieldName(j));
223 }
224}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202
#define WARNINGL0(condition, msg)
Definition: ErrorUtil.hpp:215
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:143
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:184
CommFactory & GetCommFactory()
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
double NekDouble
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::ErrorUtil::efatal, Nektar::LibUtilities::eIsEquiSpacedData, Nektar::LibUtilities::GetCommFactory(), Nektar::LibUtilities::PtsIO::Import(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, NEKERROR, Vmath::Vcopy(), and WARNINGL0.

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::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 frompts and .xml and .fld files.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47

Definition at line 56 of file ProcessPointDataToFld.h.