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

This processing module scales the input fld file. More...

#include <ProcessMRF.h>

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

Public Member Functions

 ProcessMRF (FieldSharedPtr f)
 
 ~ProcessMRF () 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 ReadMRFData ()
 
void TransformVector (std::vector< Array< OneD, NekDouble > > &data)
 
- 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 ()
 

Private Attributes

NekInt m_spacedim
 
std::vector< NekDoublem_origin
 
std::vector< NekDoublem_theta
 
std::vector< NekDoublem_pivot
 

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 scales the input fld file.

Definition at line 48 of file ProcessMRF.h.

Constructor & Destructor Documentation

◆ ProcessMRF()

Nektar::FieldUtils::ProcessMRF::ProcessMRF ( FieldSharedPtr  f)

Definition at line 49 of file ProcessMRF.cpp.

49 : ProcessModule(f)
50{
51 m_config["vectors"] = ConfigOption(false, "NotSet", "Select variables");
52}
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:272

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

◆ ~ProcessMRF()

Nektar::FieldUtils::ProcessMRF::~ProcessMRF ( )
override

Definition at line 54 of file ProcessMRF.cpp.

55{
56}

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 52 of file ProcessMRF.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().

◆ ReadMRFData()

void Nektar::FieldUtils::ProcessMRF::ReadMRFData ( )
protected

Definition at line 146 of file ProcessMRF.cpp.

147{
148 vector<string> strOrigin = {"X", "Y", "Z"};
149 vector<string> strTheta = {"Theta_x", "Theta_y", "Theta_z"};
150 vector<string> strPivot = {"X0", "Y0", "Z0"};
151 m_origin.resize(3, 0.);
152 m_pivot.resize(3, 0.);
153 for (size_t i = 0; i < strOrigin.size(); ++i)
154 {
155 if (m_f->m_fieldMetaDataMap.count(strOrigin[i]))
156 {
157 m_origin[i] = stod(m_f->m_fieldMetaDataMap[strOrigin[i]]);
158 }
159 }
160 for (size_t i = 0; i < strTheta.size(); ++i)
161 {
162 if (m_f->m_fieldMetaDataMap.count(strTheta[i]))
163 {
164 if (m_theta.size() < 3)
165 {
166 m_theta.resize(3, 0.);
167 }
168 m_theta[i] = stod(m_f->m_fieldMetaDataMap[strTheta[i]]);
169 }
170 }
171 for (size_t i = 0; i < strPivot.size(); ++i)
172 {
173 if (m_f->m_fieldMetaDataMap.count(strPivot[i]))
174 {
175 m_pivot[i] = stod(m_f->m_fieldMetaDataMap[strPivot[i]]);
176 }
177 }
178}
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
std::vector< NekDouble > m_theta
Definition: ProcessMRF.h:85
std::vector< NekDouble > m_origin
Definition: ProcessMRF.h:84
std::vector< NekDouble > m_pivot
Definition: ProcessMRF.h:86

References Nektar::FieldUtils::Module::m_f, m_origin, m_pivot, and m_theta.

Referenced by v_Process().

◆ TransformVector()

void Nektar::FieldUtils::ProcessMRF::TransformVector ( std::vector< Array< OneD, NekDouble > > &  data)
protected

Definition at line 180 of file ProcessMRF.cpp.

181{
182 if (m_theta.size() < 3)
183 {
184 return;
185 }
186 if (data.size() < m_spacedim)
187 {
189 "data size is small than the space dimension.");
190 }
191
192 int npoint = data[0].size();
193 int dim = 2;
194 NekDouble sz = sin(m_theta[2]), cz = cos(m_theta[2]);
195 Array<OneD, Array<OneD, NekDouble>> tmp(dim);
196 for (int i = 0; i < dim; ++i)
197 {
198 tmp[i] = Array<OneD, NekDouble>(npoint);
199 Vmath::Vcopy(npoint, data[i], 1, tmp[i], 1);
200 }
201 Vmath::Svtsvtp(npoint, cz, tmp[0], 1, -sz, tmp[1], 1, data[0], 1);
202 Vmath::Svtsvtp(npoint, sz, tmp[0], 1, cz, tmp[1], 1, data[1], 1);
203}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202
double NekDouble
void Svtsvtp(int n, const T alpha, const T *x, int incx, const T beta, const T *y, int incy, T *z, int incz)
Svtsvtp (scalar times vector plus scalar times vector):
Definition: Vmath.hpp:473
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

References Nektar::ErrorUtil::efatal, m_spacedim, m_theta, NEKERROR, Vmath::Svtsvtp(), and Vmath::Vcopy().

Referenced by v_Process().

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 70 of file ProcessMRF.h.

71 {
72 return "Applying mapping to field";
73 }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessMRF.h.

66 {
67 return "ProcessMRF";
68 }

◆ v_GetModulePriority()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 75 of file ProcessMRF.h.

76 {
77 return eModifyExp;
78 }

References Nektar::FieldUtils::eModifyExp.

◆ v_Process()

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

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 58 of file ProcessMRF.cpp.

59{
60 m_f->SetUpExp(vm);
62
63 // Skip in case of empty partition
64 if (m_f->m_exp[0]->GetNumElmts() == 0)
65 {
66 return;
67 }
68
69 // Determine dimensions
70 m_spacedim = m_f->m_graph->GetMeshDimension() + m_f->m_numHomogeneousDir;
71
72 // transform coordinates
73 int nfields = m_f->m_variables.size();
74 int addfields = m_spacedim;
75 int npoints = m_f->m_exp[0]->GetNpoints();
76 string fieldNames[3] = {"xCoord", "yCoord", "zCoord"};
77 for (int i = 0; i < addfields; ++i)
78 {
79 m_f->m_variables.push_back(fieldNames[i]);
80 }
81 m_f->m_exp.resize(nfields + addfields);
82 vector<Array<OneD, NekDouble>> coords(m_spacedim);
83 for (int i = 0; i < m_spacedim; ++i)
84 {
85 coords[i] = Array<OneD, NekDouble>(npoints);
86 }
87 if (m_spacedim == 1)
88 {
89 m_f->m_exp[0]->GetCoords(coords[0]);
90 }
91 else if (m_spacedim == 2)
92 {
93 m_f->m_exp[0]->GetCoords(coords[0], coords[1]);
94 }
95 else
96 {
97 m_f->m_exp[0]->GetCoords(coords[0], coords[1], coords[2]);
98 }
99 for (int i = 0; i < m_spacedim; ++i)
100 {
101 Vmath::Sadd(npoints, -m_pivot[i], coords[i], 1, coords[i], 1);
102 }
103 TransformVector(coords);
104 for (int i = 0; i < m_spacedim; ++i)
105 {
106 Vmath::Sadd(npoints, m_pivot[i] + m_origin[i], coords[i], 1, coords[i],
107 1);
108 }
109 // Add new information to m_f
110 for (int i = 0; i < addfields; ++i)
111 {
112 m_f->m_exp[nfields + i] = m_f->AppendExpList(m_f->m_numHomogeneousDir);
113 Vmath::Vcopy(npoints, coords[i], 1,
114 m_f->m_exp[nfields + i]->UpdatePhys(), 1);
115 m_f->m_exp[nfields + i]->FwdTransLocalElmt(
116 coords[i], m_f->m_exp[nfields + i]->UpdateCoeffs());
117 }
118
119 // tranform vectors
120 vector<Array<OneD, NekDouble>> data(m_spacedim);
121 vector<int> vars;
122 if (m_config["vectors"].as<string>().compare("NotSet"))
123 {
124 ParseUtils::GenerateVariableVector(m_config["vectors"].as<string>(),
125 m_f->m_variables, vars);
126 }
127 ASSERTL0(vars.size() % m_spacedim == 0,
128 "The number of vector variables is not divisible by the space "
129 "dimension.");
130 for (int i = 0; i < vars.size() / m_spacedim; ++i)
131 {
132 for (int d = 0; d < m_spacedim; ++d)
133 {
134 data[d] = m_f->m_exp[vars[m_spacedim * i + d]]->UpdatePhys();
135 }
136 TransformVector(data);
137 for (int d = 0; d < m_spacedim; ++d)
138 {
139 int nv = vars[m_spacedim * i + d];
140 m_f->m_exp[nv]->FwdTransLocalElmt(data[d],
141 m_f->m_exp[nv]->UpdateCoeffs());
142 }
143 }
144}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
void TransformVector(std::vector< Array< OneD, NekDouble > > &data)
Definition: ProcessMRF.cpp:180
static bool GenerateVariableVector(const std::string &str, const std::vector< std::string > &variables, std::vector< int > &out)
Definition: ParseUtils.cpp:185
std::vector< double > d(NPUPPER *NPUPPER)
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
Definition: Vmath.hpp:194

References ASSERTL0, Nektar::UnitTests::d(), Nektar::ParseUtils::GenerateVariableVector(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, m_origin, m_pivot, m_spacedim, ReadMRFData(), Vmath::Sadd(), TransformVector(), and Vmath::Vcopy().

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessMRF::className
static
Initial value:
"Add transformed coordinates to output file.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
Definition: ProcessMRF.h:52
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47

Definition at line 56 of file ProcessMRF.h.

◆ m_origin

std::vector<NekDouble> Nektar::FieldUtils::ProcessMRF::m_origin
private

Definition at line 84 of file ProcessMRF.h.

Referenced by ReadMRFData(), and v_Process().

◆ m_pivot

std::vector<NekDouble> Nektar::FieldUtils::ProcessMRF::m_pivot
private

Definition at line 86 of file ProcessMRF.h.

Referenced by ReadMRFData(), and v_Process().

◆ m_spacedim

NekInt Nektar::FieldUtils::ProcessMRF::m_spacedim
private

Definition at line 83 of file ProcessMRF.h.

Referenced by TransformVector(), and v_Process().

◆ m_theta

std::vector<NekDouble> Nektar::FieldUtils::ProcessMRF::m_theta
private

Definition at line 85 of file ProcessMRF.h.

Referenced by ReadMRFData(), and TransformVector().