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

- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. 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.

◆ ~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.

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

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

◆ GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 70 of file ProcessCreateExp.h.

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

◆ GetModuleName()

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

Implements Nektar::FieldUtils::Module.

Definition at line 65 of file ProcessCreateExp.h.

66  {
67  return "ProcessCreateExp";
68  }

◆ GetModulePriority()

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

Implements Nektar::FieldUtils::Module.

Definition at line 75 of file ProcessCreateExp.h.

References Nektar::FieldUtils::eCreateExp.

◆ 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.

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

64 {
65  if(m_f->m_graph)
66  {
67  int i, j;
68  LibUtilities::Timer timerpart;
69  if (m_f->m_verbose)
70  {
71  if (m_f->m_comm->TreatAsRankZero())
72  {
73  timerpart.Start();
74  }
75  }
76 
77  // check to see if fld file defined so can use in
78  // expansion defintion if required
79  bool fldfilegiven = (m_f->m_fielddef.size() != 0);
80  bool expFromFld = fldfilegiven && !vm.count("useSessionExpansion");
81 
82  // load fielddef header if fld file is defined. This gives
83  // precedence to Homogeneous definition in fld file
84  m_f->m_numHomogeneousDir = 0;
85  if (expFromFld)
86  {
87  m_f->m_numHomogeneousDir = m_f->m_fielddef[0]->m_numHomogeneousDir;
88 
89  // Set up Expansion information to use mode order from field
90  m_f->m_graph->SetExpansions(m_f->m_fielddef);
91  }
92  else
93  {
94  if (m_f->m_session->DefinesSolverInfo("HOMOGENEOUS"))
95  {
96  std::string HomoStr =
97  m_f->m_session->GetSolverInfo("HOMOGENEOUS");
98 
99  if ((HomoStr == "HOMOGENEOUS1D") ||
100  (HomoStr == "Homogeneous1D") ||
101  (HomoStr == "1D") || (HomoStr == "Homo1D"))
102  {
103  m_f->m_numHomogeneousDir = 1;
104  }
105  if ((HomoStr == "HOMOGENEOUS2D") ||
106  (HomoStr == "Homogeneous2D") ||
107  (HomoStr == "2D") || (HomoStr == "Homo2D"))
108  {
109  m_f->m_numHomogeneousDir = 2;
110  }
111  }
112  }
113 
114  m_f->m_exp.resize(1);
115 
116  // Check if there are any elements to process
117  vector<int> IDs;
118  auto domain = m_f->m_graph->GetDomain();
119  for(int d = 0; d < domain.size(); ++d)
120  {
121  for (auto &compIter : domain[d])
122  {
123  for (auto &x : compIter.second->m_geomVec)
124  {
125  IDs.push_back(x->GetGlobalID());
126  }
127  }
128  }
129 
130  // if Range has been specified it is possible to have a
131  // partition which is empty so check this and return with empty
132  // expansion if no elements present.
133  if (!IDs.size())
134  {
137  return;
138  }
139 
140  // Adjust number of quadrature points
141  if (vm.count("output-points"))
142  {
143  int nPointsNew = vm["output-points"].as<int>();
144  m_f->m_graph->SetExpansionsToPointOrder(nPointsNew);
145  }
146 
147  if (m_f->m_verbose)
148  {
149  if (m_f->m_comm->TreatAsRankZero())
150  {
151  timerpart.Stop();
152  NekDouble cpuTime = timerpart.TimePerTest(1);
153 
154  stringstream ss;
155  ss << cpuTime << "s";
156  cout << "\t ProcessCreateExp setexpansion CPU Time: "
157  << setw(8) << left
158  << ss.str() << endl;
159  timerpart.Start();
160  }
161  }
162 
163  // Override number of planes with value from cmd line
164  if (m_f->m_numHomogeneousDir == 1 && vm.count("output-points-hom-z"))
165  {
166  int expdim = m_f->m_graph->GetMeshDimension();
167  m_f->m_fielddef[0]->m_numModes[expdim] =
168  vm["output-points-hom-z"].as<int>();
169  }
170 
171  m_f->m_exp[0] = m_f->SetUpFirstExpList(m_f->m_numHomogeneousDir,
172  expFromFld);
173 
174  if (m_f->m_verbose)
175  {
176  if (m_f->m_comm->TreatAsRankZero())
177  {
178  timerpart.Stop();
179  NekDouble cpuTime = timerpart.TimePerTest(1);
180 
181  stringstream ss1;
182 
183  ss1 << cpuTime << "s";
184  cout << "\t ProcessCreateExp set first exp CPU Time: "
185  << setw(8) << left
186  << ss1.str() << endl;
187  }
188  }
189 
190  if (fldfilegiven)
191  {
192  int nfields, nstrips;
193 
194  m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
195 
196  vector<string> vars = m_f->m_session->GetVariables();
197  if (vm.count("useSessionVariables"))
198  {
199  m_f->m_variables = vars;
200  }
201  nfields = m_f->m_variables.size();
202 
203  m_f->m_exp.resize(nfields * nstrips);
204 
205  // declare other fields;
206  for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
207  {
208  for (i = 0; i < nfields; ++i)
209  {
210  if (i < vars.size())
211  {
212  // check to see if field already defined
213  if (!m_f->m_exp[s * nfields + i])
214  {
215  m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
216  m_f->m_numHomogeneousDir, vars[i]);
217  }
218  }
219  else
220  {
221  if (vars.size())
222  {
223  m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
224  m_f->m_numHomogeneousDir, vars[0]);
225  }
226  else
227  {
228  m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
229  m_f->m_numHomogeneousDir);
230  }
231  }
232  }
233  }
234 
235  // Extract data to coeffs and bwd transform
236  for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
237  {
238  for (j = 0; j < nfields; ++j)
239  {
240  for (i = 0; i < m_f->m_data.size() / nstrips; ++i)
241  {
242  int n = i * nstrips + s;
243  // In case of multiple flds, we might not have a
244  // variable in this m_data[n] -> skip in this case
245  auto it = find (m_f->m_fielddef[n]->m_fields.begin(),
246  m_f->m_fielddef[n]->m_fields.end(),
247  m_f->m_variables[j]);
248  if(it !=m_f->m_fielddef[n]->m_fields.end())
249  {
250  m_f->m_exp[s * nfields + j]->ExtractDataToCoeffs(
251  m_f->m_fielddef[n],
252  m_f->m_data[n],
253  m_f->m_variables[j],
254  m_f->m_exp[s * nfields + j]->UpdateCoeffs());
255  }
256  }
257  m_f->m_exp[s * nfields + j]->BwdTrans(
258  m_f->m_exp[s * nfields + j]->GetCoeffs(),
259  m_f->m_exp[s * nfields + j]->UpdatePhys());
260  }
261  }
262  // Clear fielddef and data
263  // (they should not be used after running this module)
264  m_f->m_fielddef = vector<LibUtilities::FieldDefinitionsSharedPtr>();
265  m_f->m_data = vector<std::vector<NekDouble> >();
266  }
267  }
268 
269 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
double NekDouble
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:358
FieldSharedPtr m_f
Field object.

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessCreateExp::className
static
Initial value:
=
ModuleKey(eProcessModule, "createExp"),
"dummy module used to create m_exp.")

Definition at line 57 of file ProcessCreateExp.h.