Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | 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 ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
void LoadFieldData (bool useSessionVariables=false)
 
virtual std::string GetModuleName ()
 
virtual std::string GetModuleDescription ()
 
virtual ModulePriority GetModulePriority ()
 
- 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
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
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
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- 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 55 of file ProcessCreateExp.cpp.

55  : ProcessModule(f)
56 {
57 }

◆ ~ProcessCreateExp()

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

Definition at line 59 of file ProcessCreateExp.cpp.

60 {
61 }

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().

◆ GetModuleDescription()

virtual std::string Nektar::FieldUtils::ProcessCreateExp::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 72 of file ProcessCreateExp.h.

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

◆ GetModuleName()

virtual std::string Nektar::FieldUtils::ProcessCreateExp::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 67 of file ProcessCreateExp.h.

68  {
69  return "ProcessCreateExp";
70  }

◆ GetModulePriority()

virtual ModulePriority Nektar::FieldUtils::ProcessCreateExp::GetModulePriority ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 77 of file ProcessCreateExp.h.

78  {
79  return eCreateExp;
80  }

References Nektar::FieldUtils::eCreateExp.

◆ LoadFieldData()

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

Definition at line 191 of file ProcessCreateExp.cpp.

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

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

Referenced by Process().

◆ Process()

void Nektar::FieldUtils::ProcessCreateExp::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 63 of file ProcessCreateExp.cpp.

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

Definition at line 57 of file ProcessCreateExp.h.