Nektar++
Loading...
Searching...
No Matches
FilterFieldConvert.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: FilterFieldConvert.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Base clase for filters performing operations on samples
32// of the field.
33//
34///////////////////////////////////////////////////////////////////////////////
35
37#include <boost/algorithm/string/classification.hpp>
38#include <boost/algorithm/string/predicate.hpp>
39#include <boost/algorithm/string/split.hpp>
40#include <boost/program_options.hpp>
41
42namespace Nektar::SolverUtils
43{
47
50 const std::shared_ptr<EquationSystem> &pEquation, const ParamMap &pParams)
51 : Filter(pSession, pEquation)
52{
53 m_dt = m_session->GetParameter("TimeStep");
54
55 // OutputFile
56 std::string ext = ".fld";
57 m_outputFile = Filter::SetupOutput(ext, pParams);
58
59 // Time after which we need to write checkfiles
60 auto it = pParams.find("OutputStartTime");
61 if (it == pParams.end())
62 {
64 }
65 else
66 {
67 LibUtilities::Equation equ(m_session->GetInterpreter(), it->second);
69 }
70
71 // OutputFrequency
72 it = pParams.find("OutputFrequency");
73 if (it == pParams.end())
74 {
75 m_outputFrequency = m_session->GetParameter("NumSteps");
76 }
77 else
78 {
79 LibUtilities::Equation equ(m_session->GetInterpreter(), it->second);
80 m_outputFrequency = round(equ.Evaluate());
81 }
82
83 // Restart file
84 it = pParams.find("RestartFile");
85 if (it == pParams.end())
86 {
87 m_restartFile = "";
88 }
89 else
90 {
91 ASSERTL0(it->second.length() > 0, "Missing parameter 'RestartFile'.");
92 if (it->second.find_last_of('.') != std::string::npos)
93 {
94 m_restartFile = it->second;
95 }
96 else
97 {
98 std::stringstream outname;
99 outname << it->second << ".fld";
100 m_restartFile = outname.str();
101 }
102 }
103
104 // The base class can use SampleFrequency = OutputFrequency
105 // (Derived classes need to override this if needed)
107
108 // Phase sampling option
109 it = pParams.find("PhaseAverage");
110 if (it == pParams.end())
111 {
112 m_phaseSample = false;
113 }
114 else
115 {
116 std::string sOption = it->second.c_str();
117 m_phaseSample = (boost::iequals(sOption, "true")) ||
118 (boost::iequals(sOption, "yes"));
119 }
120
121 if (m_phaseSample)
122 {
123 auto itPeriod = pParams.find("PhaseAveragePeriod");
124 auto itPhase = pParams.find("PhaseAveragePhase");
125
126 // Error if only one of the required params for PhaseAverage is present
127 ASSERTL0(
128 (itPeriod != pParams.end() && itPhase != pParams.end()),
129 "The phase sampling feature requires both 'PhaseAveragePeriod' and "
130 "'PhaseAveragePhase' to be set.");
131
132 LibUtilities::Equation equPeriod(m_session->GetInterpreter(),
133 itPeriod->second);
134 m_phaseSamplePeriod = equPeriod.Evaluate();
135
136 LibUtilities::Equation equPhase(m_session->GetInterpreter(),
137 itPhase->second);
138 m_phaseSamplePhase = equPhase.Evaluate();
139
140 // Check that phase and period are within required limits
142 "PhaseAveragePeriod must be greater than 0.");
144 "PhaseAveragePhase must be between 0 and 1.");
145
146 // Load sampling frequency, overriding the previous value
147 it = pParams.find("SampleFrequency");
148 if (it == pParams.end())
149 {
151 }
152 else
153 {
154 LibUtilities::Equation equ(m_session->GetInterpreter(), it->second);
155 m_sampleFrequency = round(equ.Evaluate());
156 }
157
158 // Compute tolerance within which sampling occurs.
160
161 // Display worst case scenario sampling tolerance for exact phase, if
162 // verbose option is active
163 if (m_session->GetComm()->GetRank() == 0 &&
164 m_session->DefinesCmdLineArgument("verbose"))
165 {
166 std::cout << "Phase sampling activated with period "
167 << m_phaseSamplePeriod << " and phase "
168 << m_phaseSamplePhase << "." << std::endl
169 << "Sampling within a tolerance of "
170 << std::setprecision(6) << m_phaseTolerance << "."
171 << std::endl;
172 }
173 }
174
175 m_numSamples = 0;
176 m_index = 0;
177 m_outputIndex = 0;
178
179 //
180 // FieldConvert modules
181 //
182 m_f = std::shared_ptr<Field>(new Field());
183 std::vector<std::string> modcmds;
184 // Process modules
185 std::stringstream moduleStream;
186 it = pParams.find("Modules");
187 if (it != pParams.end())
188 {
189 moduleStream.str(it->second);
190 }
191 while (!moduleStream.fail())
192 {
193 std::string sMod;
194 moduleStream >> sMod;
195 if (!moduleStream.fail())
196 {
197 modcmds.push_back(sMod);
198 }
199 }
200 // Output module
201 modcmds.push_back(m_outputFile);
202 // Create modules
203 CreateModules(modcmds);
204 // Strip options from m_outputFile
205 std::vector<std::string> tmp;
206 boost::split(tmp, m_outputFile, boost::is_any_of(":"));
207 std::string outName = tmp[0];
208 ext = fs::path(outName).extension().string();
209 m_outputFile = Filter::SetupOutput(ext, outName);
210
211 // Prevent checking before overwriting
212 it = pParams.find("options");
213 if (it != pParams.end())
214 {
215 int argc = 0;
216 std::string strargv;
217 std::vector<char *> argv;
218
219 strargv = "dummy " + it->second;
220 strargv.push_back((char)0);
221 bool flag = true;
222 for (size_t i = 0; strargv[i]; ++i)
223 {
224 if (strargv[i] != ' ' && flag)
225 {
226 argv.push_back(&strargv[i]);
227 ++argc;
228 flag = false;
229 }
230 if (strargv[i] == ' ')
231 {
232 flag = true;
233 strargv[i] = 0;
234 }
235 }
236
237 po::options_description desc("Available options");
238
239 // clang-format off
240 desc.add_options()
241 ("help,h",
242 "Produce this help message.")
243 ("modules-list,l",
244 "Print the list of available modules.")
245 ("output-points,n", po::value<int>(),
246 "Output at n equipspaced points along the "
247 "collapsed coordinates (for .dat, .vtu).")
248 ("output-points-hom-z", po::value<int>(),
249 "Number of planes in the z-direction for output of "
250 "Homogeneous 1D expansion(for .dat, .vtu).")
251 ("error,e",
252 "Write error of fields for regression checking")
253 ("force-output,f",
254 "Force the output to be written without any checks")
255 ("range,r", po::value<std::string>(),
256 "Define output range i.e. (-r xmin,xmax,ymin,ymax,zmin,zmax) "
257 "in which any vertex is contained.")
258 ("no-equispaced",
259 "Do not use equispaced output.")
260 ("nparts", po::value<int>(),
261 "Define nparts if running serial problem to mimic "
262 "parallel run with many partitions.")
263 ("npz", po::value<int>(),
264 "Used to define number of partitions in z for Homogeneous1D "
265 "expansions for parallel runs.")
266 ("npt", po::value<int>(),
267 "Used to define number of partitions in time for Parareal runs. ")
268 ("onlyshape", po::value<std::string>(),
269 "Only use element with defined shape type i.e. -onlyshape "
270 " Tetrahedron")
271 ("part-only", po::value<int>(),
272 "Partition into specified npart partitions and exit")
273 ("part-only-overlapping", po::value<int>(),
274 "Partition into specified npart overlapping partitions and exit")
275 ("modules-opt,p", po::value<std::string>(),
276 "Print options for a module.")
277 ("module,m", po::value<std::vector<std::string> >(),
278 "Specify modules which are to be used.")
279 ("use-session-variables",
280 "Use variables defined in session for output")
281 ("use-session-expansion",
282 "Use expansion defined in session.")
283 ("verbose,v",
284 "Enable verbose mode.");
285 // clang-format on
286
287 po::options_description hidden("Hidden options");
288
289 // clang-format off
290 hidden.add_options()
291 ("input-file", po::value<std::vector<std::string> >(),
292 "Input filename");
293 // clang-format on
294
295 po::options_description cmdline_options;
296 cmdline_options.add(hidden).add(desc);
297
298 po::options_description visible("Allowed options");
299 visible.add(desc);
300
301 po::positional_options_description p;
302 p.add("input-file", -1);
303
304 try
305 {
306 po::store(po::command_line_parser(argc, &(argv[0]))
307 .options(cmdline_options)
308 .positional(p)
309 .run(),
310 m_vm);
311 po::notify(m_vm);
312 }
313 catch (const std::exception &e)
314 {
315 std::cerr << e.what() << std::endl;
316 std::cerr << desc;
317 }
318 }
319 m_vm.insert(std::make_pair("force-output", po::variable_value()));
320}
321
324 const NekDouble &time)
325{
326 v_FillVariablesName(pFields);
327 // m_variables need to be filled by a derived class
328 m_outFields.resize(m_variables.size());
329 int nfield;
330
331 for (int n = 0; n < m_variables.size(); ++n)
332 {
333 // if n >= pFields.size() assum we have used n=0 field
334 nfield = (n < pFields.size()) ? n : 0;
335
336 m_outFields[n] =
337 Array<OneD, NekDouble>(pFields[nfield]->GetNcoeffs(), 0.0);
338 }
339
340 m_fieldMetaData["InitialTime"] = boost::lexical_cast<std::string>(time);
341
342 // Load restart file if necessary
343 if (m_restartFile != "")
344 {
345 // Load file
346 std::vector<LibUtilities::FieldDefinitionsSharedPtr> fieldDef;
347 std::vector<std::vector<NekDouble>> fieldData;
348 LibUtilities::FieldMetaDataMap fieldMetaData;
351 fld->Import(m_restartFile, fieldDef, fieldData, fieldMetaData);
352
353 // Extract fields to output
354 int nfield = -1, k;
355 for (int j = 0; j < m_variables.size(); ++j)
356 {
357 // see if m_variables is part of pFields definition and if
358 // so use that field for extract
359 for (k = 0; k < pFields.size(); ++k)
360 {
361 if (pFields[k]->GetSession()->GetVariable(k) == m_variables[j])
362 {
363 nfield = k;
364 break;
365 }
366 }
367 if (nfield == -1)
368 {
369 nfield = 0;
370 }
371
372 for (int i = 0; i < fieldData.size(); ++i)
373 {
374 pFields[nfield]->ExtractDataToCoeffs(
375 fieldDef[i], fieldData[i], m_variables[j], m_outFields[j]);
376 }
377 }
378
379 // Load information for numSamples
380 if (fieldMetaData.count("NumberOfFieldDumps"))
381 {
382 m_numSamples = atoi(fieldMetaData["NumberOfFieldDumps"].c_str());
383 }
384 else
385 {
386 m_numSamples = 1;
387 }
388
389 if (fieldMetaData.count("InitialTime"))
390 {
391 m_fieldMetaData["InitialTime"] = fieldMetaData["InitialTime"];
392 }
393
394 // Load information for outputIndex
395 if (fieldMetaData.count("FilterFileNum"))
396 {
397 m_outputIndex = atoi(fieldMetaData["FilterFileNum"].c_str());
398 }
399
400 // Divide by scale
401 NekDouble scale = v_GetScale();
402 for (int n = 0; n < m_outFields.size(); ++n)
403 {
404 Vmath::Smul(m_outFields[n].size(), 1.0 / scale, m_outFields[n], 1,
405 m_outFields[n], 1);
406 }
407 }
408}
409
412{
413 int nfield = pFields.size();
414 m_variables.resize(pFields.size());
415 for (int n = 0; n < nfield; ++n)
416 {
417 m_variables[n] = pFields[n]->GetSession()->GetVariable(n);
418 }
419
420 // Need to create a dummy coeffs vector to get extra variables names...
421 std::vector<Array<OneD, NekDouble>> coeffs(nfield);
422 for (int n = 0; n < nfield; ++n)
423 {
424 coeffs[n] = pFields[n]->GetCoeffs();
425 }
426 // Get extra variables
427 auto equ = m_equ.lock();
428 ASSERTL0(equ, "Weak pointer expired");
429 equ->ExtraFldOutput(coeffs, m_variables);
430}
431
434 const NekDouble &time)
435{
436 m_index++;
437
438 if (m_index % m_sampleFrequency > 0 ||
439 (time - m_outputStartTime) < -1.0e-07)
440 {
441 return;
442 }
443
444 // Append extra fields
445 int nfield = pFields.size();
446 std::vector<Array<OneD, NekDouble>> coeffs(nfield);
447 for (int n = 0; n < nfield; ++n)
448 {
449 coeffs[n] = pFields[n]->GetCoeffs();
450 }
451 std::vector<std::string> variables = m_variables;
452 auto equ = m_equ.lock();
453 ASSERTL0(equ, "Weak pointer expired");
454 equ->ExtraFldOutput(coeffs, variables);
455
456 if (m_phaseSample)
457 {
458 // The sample is added to the filter only if the current time
459 // corresponds to the correct phase. Introducing M as number of
460 // cycles and N nondimensional phase (between 0 and 1):
461 // t = M * m_phaseSamplePeriod + N * m_phaseSamplePeriod
462 int currentCycle = floor(time / m_phaseSamplePeriod);
463 NekDouble currentPhase = time / m_phaseSamplePeriod - currentCycle;
464
465 // Evaluate phase relative to the requested value.
466 NekDouble relativePhase = fabs(m_phaseSamplePhase - currentPhase);
467
468 // Check if relative phase is within required tolerance and sample.
469 // Care must be taken to handle the cases at phase 0 as the sample might
470 // have to be taken at the very end of the previous cycle instead.
471 if (relativePhase < m_phaseTolerance ||
472 fabs(relativePhase - 1) < m_phaseTolerance)
473 {
474 m_numSamples++;
475 v_ProcessSample(pFields, coeffs, time);
476 if (m_session->GetComm()->GetRank() == 0 &&
477 m_session->DefinesCmdLineArgument("verbose"))
478 {
479 std::cout << "Sample: " << std::setw(8) << std::left
480 << m_numSamples << "Phase: " << std::setw(8)
481 << std::left << currentPhase << std::endl;
482 }
483 }
484 }
485 else
486 {
487 m_numSamples++;
488 v_ProcessSample(pFields, coeffs, time);
489 }
490
491 if (m_index % m_outputFrequency == 0)
492 {
493 m_fieldMetaData["FinalTime"] = boost::lexical_cast<std::string>(time);
494 v_PrepareOutput(pFields, time);
495 m_fieldMetaData["FilterFileNum"] = std::to_string(++m_outputIndex);
497 }
498}
499
502 const NekDouble &time)
503{
504 m_fieldMetaData["FinalTime"] = boost::lexical_cast<std::string>(time);
505 v_PrepareOutput(pFields, time);
506 v_OutputField(pFields);
507}
508
511 &pFields,
512 std::vector<Array<OneD, NekDouble>> &fieldcoeffs,
513 [[maybe_unused]] const NekDouble &time)
514{
515 for (int n = 0; n < m_outFields.size(); ++n)
516 {
517 Vmath::Vcopy(m_outFields[n].size(), fieldcoeffs[n], 1, m_outFields[n],
518 1);
519 }
520}
521
524{
525 NekDouble scale = v_GetScale();
526 for (int n = 0; n < m_outFields.size(); ++n)
527 {
528 Vmath::Smul(m_outFields[n].size(), scale, m_outFields[n], 1,
529 m_outFields[n], 1);
530 }
531
532 CreateFields(pFields);
533
534 // Determine new file name
535 std::stringstream tmpOutname;
536 std::string outname;
537 int dot = m_outputFile.find_last_of('.');
538 std::string name = m_outputFile.substr(0, dot);
539 std::string ext = m_outputFile.substr(dot, m_outputFile.length() - dot);
540 std::string suffix = v_GetFileSuffix();
541
542 if (dump == -1) // final dump
543 {
544 tmpOutname << name << suffix << ext;
545 }
546 else
547 {
548 tmpOutname << name << "_" << dump << suffix << ext;
549 }
550 outname = Filter::SetupOutput(ext, tmpOutname.str());
551 m_modules[m_modules.size() - 1]->RegisterConfig("outfile", outname);
552
553 // Run field process.
554 for (int n = 0; n < SIZE_ModulePriority; ++n)
555 {
556 ModulePriority priority = static_cast<ModulePriority>(n);
557 for (int i = 0; i < m_modules.size(); ++i)
558 {
559 if (m_modules[i]->GetModulePriority() == priority)
560 {
561 m_modules[i]->Process(m_vm);
562 }
563 }
564 }
565
566 // Empty m_f to save memory
567 m_f->ClearField();
568
569 if (dump != -1) // not final dump so rescale
570 {
571 for (int n = 0; n < m_outFields.size(); ++n)
572 {
573 Vmath::Smul(m_outFields[n].size(), 1.0 / scale, m_outFields[n], 1,
574 m_outFields[n], 1);
575 }
576 }
577}
578
580{
581 return true;
582}
583
584void FilterFieldConvert::CreateModules(std::vector<std::string> &modcmds)
585{
586 for (int i = 0; i < modcmds.size(); ++i)
587 {
588 // First split each command by the colon separator.
589 std::vector<std::string> tmp1;
590 ModuleKey module;
591 int offset = 1;
592
593 boost::split(tmp1, modcmds[i], boost::is_any_of(":"));
594
595 if (i == modcmds.size() - 1)
596 {
597 module.first = eOutputModule;
598
599 // If no colon detected, automatically detect mesh type from
600 // file extension. Otherwise override and use tmp1[1] as the
601 // module to load. This also allows us to pass options to
602 // input/output modules. So, for example, to override
603 // filename.xml to be read as vtk, you use:
604 //
605 // filename.xml:vtk:opt1=arg1:opt2=arg2
606 if (tmp1.size() == 1)
607 {
608 int dot = tmp1[0].find_last_of('.') + 1;
609 std::string ext = tmp1[0].substr(dot, tmp1[0].length() - dot);
610 module.second = ext;
611 tmp1.push_back(std::string("outfile=") + tmp1[0]);
612 }
613 else
614 {
615 module.second = tmp1[1];
616 tmp1.push_back(std::string("outfile=") + tmp1[0]);
617 offset++;
618 }
619 }
620 else
621 {
622 module.first = eProcessModule;
623 module.second = tmp1[0];
624 }
625
626 // Create modules
627 ModuleSharedPtr mod;
628 mod = GetModuleFactory().CreateInstance(module, m_f);
629 m_modules.push_back(mod);
630
631 // Set options for this module.
632 for (int j = offset; j < tmp1.size(); ++j)
633 {
634 std::vector<std::string> tmp2;
635 boost::split(tmp2, tmp1[j], boost::is_any_of("="));
636
637 if (tmp2.size() == 1)
638 {
639 mod->RegisterConfig(tmp2[0]);
640 }
641 else if (tmp2.size() == 2)
642 {
643 mod->RegisterConfig(tmp2[0], tmp2[1]);
644 }
645 else
646 {
647 std::cerr << "ERROR: Invalid module configuration: format is "
648 << "either :arg or :arg=val" << std::endl;
649 abort();
650 }
651 }
652
653 // Ensure configuration options have been set.
654 mod->SetDefaults();
655 }
656
657 // Include equispaced output if needed
658 Array<OneD, int> modulesCount(SIZE_ModulePriority, 0);
659 for (int i = 0; i < m_modules.size(); ++i)
660 {
661 ++modulesCount[m_modules[i]->GetModulePriority()];
662 }
663 if (modulesCount[eModifyPts] != 0 && modulesCount[eCreatePts] == 0 &&
664 modulesCount[eConvertExpToPts] == 0)
665 {
666 ModuleKey module;
667 ModuleSharedPtr mod;
668 module.first = eProcessModule;
669 module.second = std::string("equispacedoutput");
670 mod = GetModuleFactory().CreateInstance(module, m_f);
671 m_modules.insert(m_modules.end() - 1, mod);
672 mod->SetDefaults();
673 }
674
675 // Check if modules provided are compatible
677}
678
681{
682 // Fill some parameters of m_f
683 m_f->m_session = m_session;
684 m_f->m_graph = pFields[0]->GetGraph();
685 m_f->m_comm = m_f->m_session->GetComm();
686 m_f->m_fieldMetaDataMap = m_fieldMetaData;
687 m_f->m_fieldPts = LibUtilities::NullPtsField;
688 // Create m_f->m_exp
689 m_f->m_numHomogeneousDir = 0;
690 if (pFields[0]->GetExpType() == MultiRegions::e3DH1D)
691 {
692 m_f->m_numHomogeneousDir = 1;
693 }
694 else if (pFields[0]->GetExpType() == MultiRegions::e3DH2D)
695 {
696 m_f->m_numHomogeneousDir = 2;
697 }
698
699 m_f->m_exp.resize(m_variables.size());
700 m_f->m_exp[0] = pFields[0];
701 int nfield;
702 for (int n = 0; n < m_variables.size(); ++n)
703 {
704 // if n >= pFields.size() assume we have used n=0 field
705 nfield = (n < pFields.size()) ? n : 0;
706
707 m_f->m_exp[n] =
708 m_f->AppendExpList(m_f->m_numHomogeneousDir, m_variables[0]);
709 m_f->m_exp[n]->SetWaveSpace(false);
710
711 ASSERTL1(pFields[nfield]->GetNcoeffs() == m_outFields[n].size(),
712 "pFields[nfield] does not have the "
713 "same number of coefficients as m_outFields[n]");
714
715 m_f->m_exp[n]->ExtractCoeffsToCoeffs(pFields[nfield], m_outFields[n],
716 m_f->m_exp[n]->UpdateCoeffs());
717
718 m_f->m_exp[n]->BwdTrans(m_f->m_exp[n]->GetCoeffs(),
719 m_f->m_exp[n]->UpdatePhys());
720 }
721 m_f->m_variables = m_variables;
722}
723
724// This function checks validity conditions for the list of modules provided
725void FilterFieldConvert::CheckModules(std::vector<ModuleSharedPtr> &modules)
726{
727 // Count number of modules by priority
728 Array<OneD, int> modulesCount(SIZE_ModulePriority, 0);
729 for (int i = 0; i < modules.size(); ++i)
730 {
731 ++modulesCount[modules[i]->GetModulePriority()];
732 }
733
734 // FilterFieldConvert already starts with m_exp, so anything before
735 // eModifyExp is not valid, and also eCreatePts
736 if (modulesCount[eCreateGraph] != 0 ||
737 modulesCount[eCreateFieldData] != 0 ||
738 modulesCount[eModifyFieldData] != 0 || modulesCount[eCreateExp] != 0 ||
739 modulesCount[eFillExp] != 0 || modulesCount[eCreatePts] != 0)
740 {
741 std::stringstream ss;
742 ss << "Module(s): ";
743 for (int i = 0; i < modules.size(); ++i)
744 {
745 if (modules[i]->GetModulePriority() == eCreateGraph ||
746 modules[i]->GetModulePriority() == eCreateFieldData ||
747 modules[i]->GetModulePriority() == eModifyFieldData ||
748 modules[i]->GetModulePriority() == eCreateExp ||
749 modules[i]->GetModulePriority() == eFillExp ||
750 modules[i]->GetModulePriority() == eCreatePts)
751 {
752 ss << modules[i]->GetModuleName() << " ";
753 }
754 }
755 ss << "not compatible with FilterFieldConvert.";
756 ASSERTL0(false, ss.str());
757 }
758
759 // Modules of type eConvertExpToPts are not compatible with eBndExtraction
760 if (modulesCount[eConvertExpToPts] != 0 &&
761 modulesCount[eBndExtraction] != 0)
762 {
763 std::stringstream ss;
764 ss << "Module(s): ";
765 for (int i = 0; i < modules.size(); ++i)
766 {
767 if (modules[i]->GetModulePriority() == eBndExtraction)
768 {
769 ss << modules[i]->GetModuleName() << " ";
770 }
771 }
772 ss << "is not compatible with module(s): ";
773 for (int i = 0; i < modules.size(); ++i)
774 {
775 if (modules[i]->GetModulePriority() == eConvertExpToPts)
776 {
777 ss << modules[i]->GetModuleName() << " ";
778 }
779 }
780 ss << ".";
781 ASSERTL0(false, ss.str());
782 }
783}
784} // namespace Nektar::SolverUtils
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
static std::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
Definition FieldIO.cpp:223
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
SOLVER_UTILS_EXPORT bool v_IsTimeDependent() override
virtual SOLVER_UTILS_EXPORT void v_ProcessSample(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, std::vector< Array< OneD, NekDouble > > &fieldcoeffs, const NekDouble &time)
static std::string className
Name of the class.
SOLVER_UTILS_EXPORT void CreateFields(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields)
void CheckModules(std::vector< ModuleSharedPtr > &modules)
SOLVER_UTILS_EXPORT void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
SOLVER_UTILS_EXPORT void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
virtual SOLVER_UTILS_EXPORT void v_FillVariablesName(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields)
virtual SOLVER_UTILS_EXPORT void v_PrepareOutput(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
void CreateModules(std::vector< std::string > &modcmds)
static FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< EquationSystem > &pEquation, const std::map< std::string, std::string > &pParams)
Creates an instance of this class.
SOLVER_UTILS_EXPORT FilterFieldConvert(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< EquationSystem > &pEquation, const ParamMap &pParams)
LibUtilities::FieldMetaDataMap m_fieldMetaData
std::vector< Array< OneD, NekDouble > > m_outFields
virtual SOLVER_UTILS_EXPORT NekDouble v_GetScale()
virtual SOLVER_UTILS_EXPORT void v_OutputField(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, int dump=-1)
virtual SOLVER_UTILS_EXPORT std::string v_GetFileSuffix()
std::vector< ModuleSharedPtr > m_modules
SOLVER_UTILS_EXPORT void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
SOLVER_UTILS_EXPORT std::string SetupOutput(const std::string ext, const ParamMap &pParams)
Definition Filter.h:139
LibUtilities::SessionReaderSharedPtr m_session
Definition Filter.h:93
const std::weak_ptr< EquationSystem > m_equ
Definition Filter.h:94
std::map< std::string, std::string > ParamMap
Definition Filter.h:66
std::pair< ModuleType, std::string > ModuleKey
Definition Module.h:180
std::shared_ptr< Module > ModuleSharedPtr
Definition Module.h:329
ModuleFactory & GetModuleFactory()
Definition Module.cpp:47
std::shared_ptr< FieldIO > FieldIOSharedPtr
Definition FieldIO.h:322
std::map< std::string, std::string > FieldMetaDataMap
Definition FieldIO.h:50
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static PtsFieldSharedPtr NullPtsField
Definition PtsField.h:185
FilterFactory & GetFilterFactory()
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition Vmath.hpp:100
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825