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

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

#include <ProcessCreateExp.h>

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

Public Member Functions

 ProcessCreateExp (FieldSharedPtr f)
 
 ~ProcessCreateExp () 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...
 
void LoadFieldData (bool useSessionVariables=false)
 
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 scales the input fld file.

Definition at line 47 of file ProcessCreateExp.h.

Constructor & Destructor Documentation

◆ ProcessCreateExp()

Nektar::FieldUtils::ProcessCreateExp::ProcessCreateExp ( FieldSharedPtr  f)

Definition at line 52 of file ProcessCreateExp.cpp.

◆ ~ProcessCreateExp()

Nektar::FieldUtils::ProcessCreateExp::~ProcessCreateExp ( )
override

Definition at line 56 of file ProcessCreateExp.cpp.

57{
58}

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 51 of file ProcessCreateExp.h.

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

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

◆ LoadFieldData()

void Nektar::FieldUtils::ProcessCreateExp::LoadFieldData ( bool  useSessionVariables = false)
protected

Definition at line 185 of file ProcessCreateExp.cpp.

186{
187 int i, j;
188 int nfields, nstrips;
189 m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
190 vector<string> vars = m_f->m_session->GetVariables();
191
192 if (useSessionVariables)
193 {
194 m_f->m_variables = vars;
195 }
196 nfields = m_f->m_variables.size();
197
198 m_f->m_exp.resize(nfields * nstrips);
199 // declare other fields;
200 for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
201 {
202 for (i = 0; i < nfields; ++i)
203 {
204 if (i < vars.size())
205 {
206 // check to see if field already defined
207 if (!m_f->m_exp[s * nfields + i])
208 {
209 m_f->m_exp[s * nfields + i] =
210 m_f->AppendExpList(m_f->m_numHomogeneousDir, vars[i]);
211 }
212 }
213 else
214 {
215 if (vars.size())
216 {
217 m_f->m_exp[s * nfields + i] =
218 m_f->AppendExpList(m_f->m_numHomogeneousDir, vars[0]);
219 }
220 else
221 {
222 m_f->m_exp[s * nfields + i] =
223 m_f->AppendExpList(m_f->m_numHomogeneousDir);
224 }
225 }
226 }
227 }
228
229 // Extract data to coeffs and bwd transform
230 for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
231 {
232 for (j = 0; j < nfields; ++j)
233 {
234 for (i = 0; i < m_f->m_data.size() / nstrips; ++i)
235 {
236 int n = i * nstrips + s;
237 // In case of multiple flds, we might not have a
238 // variable in this m_data[n] -> skip in this case
239 auto it = find(m_f->m_fielddef[n]->m_fields.begin(),
240 m_f->m_fielddef[n]->m_fields.end(),
241 m_f->m_variables[j]);
242 if (it != m_f->m_fielddef[n]->m_fields.end())
243 {
244 m_f->m_exp[s * nfields + j]->ExtractDataToCoeffs(
245 m_f->m_fielddef[n], m_f->m_data[n], m_f->m_variables[j],
246 m_f->m_exp[s * nfields + j]->UpdateCoeffs());
247 }
248 }
249 m_f->m_exp[s * nfields + j]->BwdTrans(
250 m_f->m_exp[s * nfields + j]->GetCoeffs(),
251 m_f->m_exp[s * nfields + j]->UpdatePhys());
252 }
253 }
254 // Clear fielddef and data (they should not be used after running this
255 // module)
256 m_f->m_fielddef = vector<LibUtilities::FieldDefinitionsSharedPtr>();
257 m_f->m_data = vector<std::vector<NekDouble>>();
258}
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:447

References Nektar::StdRegions::find(), and Nektar::FieldUtils::Module::m_f.

Referenced by v_Process().

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 71 of file ProcessCreateExp.h.

72 {
73 return "Creating m_exp if needed";
74 }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 66 of file ProcessCreateExp.h.

67 {
68 return "ProcessCreateExp";
69 }

◆ v_GetModulePriority()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 76 of file ProcessCreateExp.h.

77 {
78 return eCreateExp;
79 }

References Nektar::FieldUtils::eCreateExp.

◆ v_Process()

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

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 60 of file ProcessCreateExp.cpp.

61{
62 if (m_f->m_graph)
63 {
64 LibUtilities::Timer timerpart;
65 if (m_f->m_verbose)
66 {
67 if (m_f->m_comm->TreatAsRankZero())
68 {
69 timerpart.Start();
70 }
71 }
72 // check to see if fld file defined so can use in
73 // expansion defintion if required
74 bool fldfilegiven = (m_f->m_fielddef.size() != 0);
75 bool expFromFld = fldfilegiven && !vm.count("use-session-expansion");
76
77 // load fielddef header if fld file is defined. This gives
78 // precedence to Homogeneous definition in fld file
79 m_f->m_numHomogeneousDir = 0;
80 if (expFromFld)
81 {
82 m_f->m_numHomogeneousDir = m_f->m_fielddef[0]->m_numHomogeneousDir;
83
84 // Set up Expansion information to use mode order from field
85 m_f->m_graph->SetExpansionInfo(m_f->m_fielddef);
86 }
87 else
88 {
89 if (m_f->m_session->DefinesSolverInfo("HOMOGENEOUS"))
90 {
91 std::string HomoStr =
92 m_f->m_session->GetSolverInfo("HOMOGENEOUS");
93
94 if ((HomoStr == "HOMOGENEOUS1D") ||
95 (HomoStr == "Homogeneous1D") || (HomoStr == "1D") ||
96 (HomoStr == "Homo1D"))
97 {
98 m_f->m_numHomogeneousDir = 1;
99 }
100 if ((HomoStr == "HOMOGENEOUS2D") ||
101 (HomoStr == "Homogeneous2D") || (HomoStr == "2D") ||
102 (HomoStr == "Homo2D"))
103 {
104 m_f->m_numHomogeneousDir = 2;
105 }
106 }
107 }
108
109 m_f->m_exp.resize(1);
110 // Check if there are any elements to process
111 vector<int> IDs;
112 auto domain = m_f->m_graph->GetDomain();
113 for (int d = 0; d < domain.size(); ++d)
114 {
115 for (auto &compIter : domain[d])
116 {
117 for (auto &x : compIter.second->m_geomVec)
118 {
119 IDs.push_back(x->GetGlobalID());
120 }
121 }
122 }
123 // if Range has been specified it is possible to have a
124 // partition which is empty so check this and return with empty
125 // expansion if no elements present.
126 if (!IDs.size())
127 {
128 m_f->m_exp[0] =
130 return;
131 }
132
133 // Adjust number of quadrature points
134 if (vm.count("output-points"))
135 {
136 int nPointsNew = vm["output-points"].as<int>();
137 m_f->m_graph->SetExpansionInfoToPointOrder(nPointsNew);
138 }
139
140 if (m_f->m_verbose)
141 {
142 if (m_f->m_comm->TreatAsRankZero())
143 {
144 timerpart.Stop();
145 NekDouble cpuTime = timerpart.TimePerTest(1);
146
147 stringstream ss;
148 ss << cpuTime << "s";
149 cout << "\t ProcessCreateExp setexpansion CPU Time: " << setw(8)
150 << left << ss.str() << endl;
151 timerpart.Start();
152 }
153 }
154 // Override number of planes with value from cmd line
155 if (m_f->m_numHomogeneousDir == 1 && vm.count("output-points-hom-z"))
156 {
157 int expdim = m_f->m_graph->GetMeshDimension();
158 m_f->m_fielddef[0]->m_numModes[expdim] =
159 vm["output-points-hom-z"].as<int>();
160 }
161 m_f->m_exp[0] =
162 m_f->SetUpFirstExpList(m_f->m_numHomogeneousDir, expFromFld);
163 if (m_f->m_verbose)
164 {
165 if (m_f->m_comm->TreatAsRankZero())
166 {
167 timerpart.Stop();
168 NekDouble cpuTime = timerpart.TimePerTest(1);
169
170 stringstream ss1;
171
172 ss1 << cpuTime << "s";
173 cout << "\t ProcessCreateExp set first exp CPU Time: "
174 << setw(8) << left << ss1.str() << endl;
175 }
176 }
177
178 if (fldfilegiven)
179 {
180 LoadFieldData(vm.count("use-session-variables"));
181 }
182 }
183}
void LoadFieldData(bool useSessionVariables=false)
std::vector< double > d(NPUPPER *NPUPPER)
double NekDouble

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::UnitTests::d(), LoadFieldData(), Nektar::FieldUtils::Module::m_f, Nektar::LibUtilities::Timer::Start(), Nektar::LibUtilities::Timer::Stop(), and Nektar::LibUtilities::Timer::TimePerTest().

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessCreateExp::className
static
Initial value:
=
"dummy module used to create m_exp.")
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 55 of file ProcessCreateExp.h.