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)
 
virtual ~ProcessCreateExp ()
 
- 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 ()
 
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

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

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 49 of file ProcessCreateExp.h.

Constructor & Destructor Documentation

◆ ProcessCreateExp()

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

Definition at line 54 of file ProcessCreateExp.cpp.

54  : ProcessModule(f)
55 {
56 }

◆ ~ProcessCreateExp()

Nektar::FieldUtils::ProcessCreateExp::~ProcessCreateExp ( )
virtual

Definition at line 58 of file ProcessCreateExp.cpp.

59 {
60 }

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 53 of file ProcessCreateExp.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().

◆ LoadFieldData()

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

Definition at line 187 of file ProcessCreateExp.cpp.

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

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

Referenced by v_Process().

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 73 of file ProcessCreateExp.h.

74  {
75  return "Creating m_exp if needed";
76  }

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 68 of file ProcessCreateExp.h.

69  {
70  return "ProcessCreateExp";
71  }

◆ v_GetModulePriority()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 78 of file ProcessCreateExp.h.

79  {
80  return eCreateExp;
81  }

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 62 of file ProcessCreateExp.cpp.

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

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), 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:198
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:317
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 57 of file ProcessCreateExp.h.