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

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

#include <ProcessInterpPointDataToFld.h>

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

Public Member Functions

 ProcessInterpPointDataToFld (FieldSharedPtr f)
 
 ~ProcessInterpPointDataToFld () 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
 
void PrintProgressbar (const int position, const int goal) const
 
- 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 49 of file ProcessInterpPointDataToFld.h.

Constructor & Destructor Documentation

◆ ProcessInterpPointDataToFld()

Nektar::FieldUtils::ProcessInterpPointDataToFld::ProcessInterpPointDataToFld ( FieldSharedPtr  f)

Definition at line 63 of file ProcessInterpPointDataToFld.cpp.

64 : ProcessModule(f)
65{
66 m_config["frompts"] = ConfigOption(
67 false, "NotSet", "Pts file from which to interpolate field");
68
69 m_config["interpcoord"] =
70 ConfigOption(false, "-1", "coordinate id to use for interpolation");
71}
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:272

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

◆ ~ProcessInterpPointDataToFld()

Nektar::FieldUtils::ProcessInterpPointDataToFld::~ProcessInterpPointDataToFld ( )
override

Definition at line 73 of file ProcessInterpPointDataToFld.cpp.

74{
75}

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 53 of file ProcessInterpPointDataToFld.h.

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

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

◆ PrintProgressbar()

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

Definition at line 81 of file ProcessInterpPointDataToFld.h.

82 {
83 LibUtilities::PrintProgressbar(position, goal, "Interpolating");
84 }
int PrintProgressbar(const int position, const int goal, const std::string message, int lastprogress=-1)
Prints a progressbar.
Definition: Progressbar.hpp:65

References Nektar::LibUtilities::PrintProgressbar().

Referenced by v_Process().

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 71 of file ProcessInterpPointDataToFld.h.

72 {
73 return "Interpolating data to field";
74 }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 66 of file ProcessInterpPointDataToFld.h.

67 {
68 return "ProcessInterpPointDataToFld";
69 }

◆ v_GetModulePriority()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 76 of file ProcessInterpPointDataToFld.h.

77 {
78 return eFillExp;
79 }

References Nektar::FieldUtils::eFillExp.

◆ v_Process()

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

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 77 of file ProcessInterpPointDataToFld.cpp.

78{
79 m_f->SetUpExp(vm);
80
81 int i, j;
83 // Load pts file
84 ASSERTL0(m_config["frompts"].as<string>().compare("NotSet") != 0,
85 "ProcessInterpPointDataToFld requires frompts parameter");
86 string inFile = m_config["frompts"].as<string>().c_str();
87
88 int totpoints = m_f->m_exp[0]->GetTotPoints();
89
90 Array<OneD, Array<OneD, NekDouble>> intFields(3);
91 for (int i = 0; i < 3; ++i)
92 {
93 intFields[i] = Array<OneD, NekDouble>(totpoints, 0.);
94 }
95 m_f->m_exp[0]->GetCoords(intFields[0], intFields[1], intFields[2]);
96
97 if (fs::path(inFile).extension() == ".pts")
98 {
101
102 ptsIO->Import(inFile, fieldPts);
103 }
104 else if (fs::path(inFile).extension() == ".csv")
105 {
108
111
112 NekDouble vmax, vmin, margin = 0.1;
113 vmax = intFields[0][Vmath::Imax(totpoints, intFields[0], 1)];
114 vmin = intFields[0][Vmath::Imin(totpoints, intFields[0], 1)];
115 Range->m_xmax = (vmax - vmin) * margin + vmax;
116 Range->m_xmin = -(vmax - vmin) * margin + vmin;
117
118 vmax = intFields[1][Vmath::Imax(totpoints, intFields[1], 1)];
119 vmin = intFields[1][Vmath::Imin(totpoints, intFields[1], 1)];
120 Range->m_ymax = (vmax - vmin) * margin + vmax;
121 Range->m_ymin = -(vmax - vmin) * margin + vmin;
122
123 vmax = intFields[2][Vmath::Imax(totpoints, intFields[2], 1)];
124 vmin = intFields[2][Vmath::Imin(totpoints, intFields[2], 1)];
125 Range->m_zmax = (vmax - vmin) * margin + vmax;
126 Range->m_zmin = -(vmax - vmin) * margin + vmin;
127
128 csvIO->Import(inFile, fieldPts, LibUtilities::NullFieldMetaDataMap,
129 Range);
130 }
131 else
132 {
133 ASSERTL0(false, "unknown frompts file type");
134 }
135
136 int nFields = fieldPts->GetNFields();
137 ASSERTL0(nFields > 0, "No field values provided in input");
138
139 // Define new expansions.
140 ASSERTL0(
141 m_f->m_numHomogeneousDir == 0,
142 "ProcessInterpPointDataToFld does not support homogeneous expansion");
143
144 m_f->m_exp.resize(nFields);
145 for (i = 1; i < nFields; ++i)
146 {
147 m_f->m_exp[i] = m_f->AppendExpList(m_f->m_numHomogeneousDir);
148 }
149
150 Array<OneD, Array<OneD, NekDouble>> intFields1(3 + nFields);
151
152 for (int i = 0; i < 3; ++i)
153 {
154 intFields1[i] = intFields[i];
155 }
156
157 // Declare space for interpolated fields
158 for (int i = 3; i < 3 + nFields; ++i)
159 {
160 intFields1[i] = Array<OneD, NekDouble>(totpoints);
161 }
162
165
166 int coord_id = m_config["interpcoord"].as<int>();
167 ASSERTL0(coord_id <= static_cast<int>(outPts->GetDim()) - 1,
168 "interpcoord is bigger than the Pts files dimension");
169
170 Interpolator<std::vector<MultiRegions::ExpListSharedPtr>> interp(
171 LibUtilities::eNoMethod, coord_id);
172
173 if (m_f->m_verbose && m_f->m_comm->TreatAsRankZero())
174 {
175 interp.SetProgressCallback(
177 }
178 interp.Interpolate(fieldPts, outPts);
179 if (m_f->m_verbose && m_f->m_comm->TreatAsRankZero())
180 {
181 cout << endl;
182 }
183
184 for (i = 0; i < totpoints; ++i)
185 {
186 for (j = 0; j < nFields; ++j)
187 {
188 m_f->m_exp[j]->SetPhys(i, outPts->GetPointVal(3 + j, i));
189 }
190 }
191 // forward transform fields
192 for (i = 0; i < nFields; ++i)
193 {
194 m_f->m_exp[i]->FwdTransLocalElmt(m_f->m_exp[i]->GetPhys(),
195 m_f->m_exp[i]->UpdateCoeffs());
196 }
197
198 // save field names
199 for (int j = 0; j < fieldPts->GetNFields(); ++j)
200 {
201 m_f->m_variables.push_back(fieldPts->GetFieldName(j));
202 }
203}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
void PrintProgressbar(const int position, const int goal) const
static FieldMetaDataMap NullFieldMetaDataMap
Definition: FieldIO.h:51
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:184
std::shared_ptr< DomainRange > DomainRangeShPtr
Definition: DomainRange.h:64
std::shared_ptr< CsvIO > CsvIOSharedPtr
Definition: CsvIO.h:74
std::shared_ptr< PtsIO > PtsIOSharedPtr
Definition: PtsIO.h:90
double NekDouble
int Imax(int n, const T *x, const int incx)
Return the index of the maximum element in x.
Definition: Vmath.hpp:623
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
Definition: Vmath.hpp:704

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::eNoMethod, Vmath::Imax(), Vmath::Imin(), Nektar::FieldUtils::Interpolator< T >::Interpolate(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, Nektar::LibUtilities::NullFieldMetaDataMap, PrintProgressbar(), and Nektar::LibUtilities::Interpolator::SetProgressCallback().

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessInterpPointDataToFld::className
static
Initial value:
=
ModuleKey(eProcessModule, "interppointdatatofld"),
"Interpolates given discrete data using a finite difference "
"approximation to a fld file given a xml file")
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 57 of file ProcessInterpPointDataToFld.h.