Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EquationSystem.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File EquationSystem.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: Main wrapper class for Advection Diffusion Reaction Solver
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
39 
40 #include <LocalRegions/MatrixKey.h>
42 #include <MultiRegions/ContField.h>
45 
46 #include <MultiRegions/ExpList.h>
49 
52 
53 #include <GlobalMapping/Mapping.h>
54 
55 #include <boost/format.hpp>
56 
57 #include <iostream>
58 #include <string>
59 
60 using namespace std;
61 
62 namespace Nektar
63 {
64  namespace SolverUtils
65  {
66 
67  std::string EquationSystem::equationSystemTypeLookupIds[2] = {
68  LibUtilities::SessionReader::RegisterEnumValue("DEALIASING",
69  "True", 0),
70  LibUtilities::SessionReader::RegisterEnumValue("DEALIASING",
71  "False", 1)};
72 
73  /**
74  * @class EquationSystem
75  *
76  * This class is a base class for all solver implementations. It
77  * provides the underlying generic functionality and interface for
78  * solving equations.
79  *
80  * To solve a steady-state equation, create a derived class from this
81  * class and reimplement the virtual functions to provide custom
82  * implementation for the problem.
83  *
84  * To solve unsteady problems, derive from the UnsteadySystem class
85  * instead which provides general time integration.
86  */
88  {
89  static EquationSystemFactory instance;
90  return instance;
91  }
92 
93  /**
94  * This constructor is protected as the objects of this class are never
95  * instantiated directly.
96  * @param pSession The session reader holding problem parameters.
97  */
98  EquationSystem::EquationSystem(
101  : m_comm (pSession->GetComm()),
102  m_session (pSession),
103  m_graph (pGraph),
104  m_lambda (0),
105  m_fieldMetaDataMap(LibUtilities::NullFieldMetaDataMap)
106  {
107  // set up session names in fieldMetaDataMap
108  const vector<std::string> filenames = m_session->GetFilenames();
109 
110  for(int i = 0; i < filenames.size(); ++i)
111  {
112  string sessionname = "SessionName";
113  sessionname += boost::lexical_cast<std::string>(i);
114  m_fieldMetaDataMap[sessionname] = filenames[i];
115  m_fieldMetaDataMap["ChkFileNum"] =
116  boost::lexical_cast<std::string>(0);
117  }
118 
119  }
120 
121  /**
122  * @brief Initialisation object for EquationSystem.
123  */
125  {
126  // Save the basename of input file name for output details
127  m_sessionName = m_session->GetSessionName();
128 
129  // Instantiate a field reader/writer
131 
132  // Also read and store the boundary conditions
136 
137  // Set space dimension for use in class
138  m_spacedim = m_graph->GetSpaceDimension();
139 
140  // Setting parameteres for homogenous problems
141  m_HomoDirec = 0;
142  m_useFFT = false;
143  m_homogen_dealiasing = false;
144  m_singleMode = false;
145  m_halfMode = false;
146  m_multipleModes = false;
148 
149  m_verbose = m_session->DefinesCmdLineArgument("verbose");
150  m_root = false;
151  if (0 == m_comm->GetRank())
152  {
153  m_root =true;
154  }
155 
156  if (m_session->DefinesSolverInfo("HOMOGENEOUS"))
157  {
158  std::string HomoStr = m_session->GetSolverInfo("HOMOGENEOUS");
159  m_spacedim = 3;
160 
161  if ((HomoStr == "HOMOGENEOUS1D") || (HomoStr == "Homogeneous1D")
162  || (HomoStr == "1D") || (HomoStr == "Homo1D"))
163  {
165  m_session->LoadParameter("LZ", m_LhomZ);
166  m_HomoDirec = 1;
167 
168  if(m_session->DefinesSolverInfo("ModeType"))
169  {
170  m_session->MatchSolverInfo("ModeType", "SingleMode",
171  m_singleMode, false);
172  m_session->MatchSolverInfo("ModeType", "HalfMode",
173  m_halfMode, false);
174  m_session->MatchSolverInfo("ModeType", "MultipleModes",
175  m_multipleModes, false);
176  }
177 
178  // Stability Analysis flags
179  if (m_session->DefinesSolverInfo("ModeType"))
180  {
181  if(m_singleMode)
182  {
183  m_npointsZ = 2;
184  }
185  else if(m_halfMode)
186  {
187  m_npointsZ = 1;
188  }
189  else if(m_multipleModes)
190  {
191  m_npointsZ = m_session->GetParameter("HomModesZ");
192  }
193  else
194  {
195  ASSERTL0(false, "SolverInfo ModeType not valid");
196  }
197  }
198  else
199  {
200  m_npointsZ = m_session->GetParameter("HomModesZ");
201  }
202  }
203 
204  if ((HomoStr == "HOMOGENEOUS2D") || (HomoStr == "Homogeneous2D")
205  || (HomoStr == "2D") || (HomoStr == "Homo2D"))
206  {
208  m_session->LoadParameter("HomModesY", m_npointsY);
209  m_session->LoadParameter("LY", m_LhomY);
210  m_session->LoadParameter("HomModesZ", m_npointsZ);
211  m_session->LoadParameter("LZ", m_LhomZ);
212  m_HomoDirec = 2;
213  }
214 
215  if ((HomoStr == "HOMOGENEOUS3D") || (HomoStr == "Homogeneous3D")
216  || (HomoStr == "3D") || (HomoStr == "Homo3D"))
217  {
219  m_session->LoadParameter("HomModesY", m_npointsY);
220  m_session->LoadParameter("LY", m_LhomY);
221  m_session->LoadParameter("HomModesZ", m_npointsZ);
222  m_session->LoadParameter("LZ", m_LhomZ);
223  m_HomoDirec = 2;
224  }
225 
226  m_session->MatchSolverInfo("USEFFT", "FFTW", m_useFFT, false);
227 
228  m_session->MatchSolverInfo("DEALIASING", "True",
229  m_homogen_dealiasing, false);
230  }
231  else
232  {
233  // set to default value so can use to identify 2d or 3D
234  // (homogeneous) expansions
235  m_npointsZ = 1;
236  }
237 
238  m_session->MatchSolverInfo("SPECTRALHPDEALIASING", "True",
239  m_specHP_dealiasing, false);
240  if (m_specHP_dealiasing == false)
241  {
242  m_session->MatchSolverInfo("SPECTRALHPDEALIASING", "On",
243  m_specHP_dealiasing, false);
244  }
245 
246  // Options to determine type of projection from file or directly
247  // from constructor
248  if (m_session->DefinesSolverInfo("PROJECTION"))
249  {
250  std::string ProjectStr = m_session->GetSolverInfo("PROJECTION");
251 
252  if ((ProjectStr == "Continuous") || (ProjectStr == "Galerkin") ||
253  (ProjectStr == "CONTINUOUS") || (ProjectStr == "GALERKIN"))
254  {
256  }
257  else if ((ProjectStr == "MixedCGDG") ||
258  (ProjectStr == "Mixed_CG_Discontinuous"))
259  {
261  }
262  else if(ProjectStr == "DisContinuous")
263  {
265  }
266  else
267  {
268  ASSERTL0(false,"PROJECTION value not recognised");
269  }
270  }
271  else
272  {
273  cerr << "Projection type not specified in SOLVERINFO,"
274  "defaulting to continuous Galerkin" << endl;
276  }
277 
278  // Enforce singularity check for some problems
280 
281  int i;
282  int nvariables = m_session->GetVariables().size();
283  bool DeclareCoeffPhysArrays = true;
284 
285 
287  m_spacedim = m_graph->GetSpaceDimension()+m_HomoDirec;
288  m_expdim = m_graph->GetMeshDimension();
289 
290  /// Continuous field
293  {
294  switch(m_expdim)
295  {
296  case 1:
297  {
300  {
301  const LibUtilities::PointsKey PkeyY
303  const LibUtilities::BasisKey BkeyY
305  const LibUtilities::PointsKey PkeyZ
308  BkeyZ(LibUtilities::eFourier, m_npointsZ, PkeyZ);
309 
310  for (i = 0; i < m_fields.size(); i++)
311  {
312  m_fields[i] = MemoryManager<MultiRegions
313  ::ContField3DHomogeneous2D>
314  ::AllocateSharedPtr(
315  m_session, BkeyY, BkeyZ, m_LhomY,
316  m_LhomZ, m_useFFT,
318  m_session->GetVariable(i));
319  }
320  }
321  else
322  {
323  for (i = 0; i < m_fields.size(); i++)
324  {
327  AllocateSharedPtr(
329  m_session->GetVariable(i));
330  }
331  }
332  break;
333  }
334  case 2:
335  {
337  {
338  // Fourier single mode stability analysis
339  if (m_singleMode)
340  {
341  const LibUtilities::PointsKey PkeyZ(
342  m_npointsZ,
344 
345  const LibUtilities::BasisKey BkeyZ(
347  m_npointsZ,
348  PkeyZ);
349 
350  for(i = 0; i < m_fields.size(); i++)
351  {
352  m_fields[i] = MemoryManager<MultiRegions
353  ::ContField3DHomogeneous1D>
354  ::AllocateSharedPtr(
355  m_session, BkeyZ, m_LhomZ,
357  m_graph,
358  m_session->GetVariable(i),
360  }
361  }
362  // Half mode stability analysis
363  else if(m_halfMode)
364  {
365  const LibUtilities::PointsKey PkeyZ(
366  m_npointsZ,
368 
369  const LibUtilities::BasisKey BkeyZR(
371  m_npointsZ, PkeyZ);
372 
373  const LibUtilities::BasisKey BkeyZI(
375  m_npointsZ, PkeyZ);
376 
377 
378  for (i = 0; i < m_fields.size(); i++)
379  {
380  if(m_session->GetVariable(i).compare("w")
381  == 0)
382  {
383  m_fields[i] = MemoryManager<MultiRegions
384  ::ContField3DHomogeneous1D>
385  ::AllocateSharedPtr(
386  m_session, BkeyZI, m_LhomZ,
387  m_useFFT,
389  m_graph,
390  m_session->GetVariable(i),
392  }
393  else
394  {
395  m_fields[i] = MemoryManager<MultiRegions
396  ::ContField3DHomogeneous1D>
397  ::AllocateSharedPtr(
398  m_session, BkeyZR, m_LhomZ,
400  m_graph,
401  m_session->GetVariable(i),
403  }
404 
405 
406  }
407  }
408  // Normal homogeneous 1D
409  else
410  {
411  const LibUtilities::PointsKey PkeyZ(
412  m_npointsZ,
414  const LibUtilities::BasisKey BkeyZ(
416 
417  for (i = 0; i < m_fields.size(); i++)
418  {
419  m_fields[i] = MemoryManager<MultiRegions
420  ::ContField3DHomogeneous1D>
421  ::AllocateSharedPtr(
422  m_session, BkeyZ, m_LhomZ,
424  m_graph,
425  m_session->GetVariable(i),
427  }
428  }
429  }
430  else
431  {
432  i = 0;
434  firstfield = MemoryManager<MultiRegions::
435  ContField>::AllocateSharedPtr(
437  m_session->GetVariable(i),
438  DeclareCoeffPhysArrays,
440  m_fields[0] = firstfield;
441  for (i = 1; i < m_fields.size(); i++)
442  {
443  if (m_graph->SameExpansionInfo(
444  m_session->GetVariable(0),
445  m_session->GetVariable(i)))
446  {
447  m_fields[i] = MemoryManager<MultiRegions::
448  ContField>::AllocateSharedPtr(
449  *firstfield, m_graph,
450  m_session->GetVariable(i),
451  DeclareCoeffPhysArrays,
453  }
454  else
455  {
456  m_fields[i] = MemoryManager<MultiRegions
457  ::ContField>::AllocateSharedPtr(
458  m_session, m_graph,
459  m_session->GetVariable(i),
460  DeclareCoeffPhysArrays,
462  }
463  }
464 
465  if (m_projectionType ==
467  {
468  /// Setting up the normals
471  (m_spacedim);
472 
473  for (i = 0; i < m_spacedim; ++i)
474  {
476  (GetTraceNpoints());
477  }
478 
479  m_fields[0]->GetTrace()->
480  GetNormals(m_traceNormals);
481  }
482 
483  }
484 
485  break;
486  }
487  case 3:
488  {
489  i = 0;
493  m_session->GetVariable(i),
494  DeclareCoeffPhysArrays,
496 
497  m_fields[0] = firstfield;
498  for (i = 1; i < m_fields.size(); i++)
499  {
500  if(m_graph->SameExpansionInfo(m_session->GetVariable(0),
501  m_session->GetVariable(i)))
502  {
503  m_fields[i] = MemoryManager<MultiRegions
504  ::ContField>::AllocateSharedPtr(
505  *firstfield, m_graph,
506  m_session->GetVariable(i),
507  DeclareCoeffPhysArrays,
509  }
510  else
511  {
512  m_fields[i] = MemoryManager<MultiRegions
513  ::ContField>::AllocateSharedPtr(
514  m_session, m_graph,
515  m_session->GetVariable(i),
516  DeclareCoeffPhysArrays,
518  }
519  }
520 
521  if (m_projectionType ==
523  {
524  /// Setting up the normals
527  (m_spacedim);
528  for(i = 0; i < m_spacedim; ++i)
529  {
530  m_traceNormals[i] =
532  }
533 
534  m_fields[0]->GetTrace()->GetNormals(m_traceNormals);
535  // Call the trace on all fields to ensure DG setup.
536  for(i = 1; i < m_fields.size(); ++i)
537  {
538  m_fields[i]->GetTrace();
539  }
540  }
541  break;
542  }
543  default:
544  ASSERTL0(false,"Expansion dimension not recognised");
545  break;
546  }
547  }
548  // Discontinuous field
549  else
550  {
551  switch(m_expdim)
552  {
553  case 1:
554  {
557  {
558  const LibUtilities::PointsKey PkeyY(
560  const LibUtilities::BasisKey BkeyY(
562  const LibUtilities::PointsKey PkeyZ(
564  const LibUtilities::BasisKey BkeyZ(
566 
567  for (i = 0; i < m_fields.size(); i++)
568  {
569  m_fields[i] = MemoryManager<MultiRegions
570  ::DisContField3DHomogeneous2D>
571  ::AllocateSharedPtr(
572  m_session, BkeyY, BkeyZ, m_LhomY,
573  m_LhomZ, m_useFFT,
575  m_session->GetVariable(i));
576  }
577  }
578  else
579  {
580  for (i = 0; i < m_fields.size(); i++)
581  {
582  m_fields[i] = MemoryManager<MultiRegions::
583  DisContField>::AllocateSharedPtr(
585  m_session->GetVariable(i));
586  }
587  }
588 
589  break;
590  }
591  case 2:
592  {
594  {
595  const LibUtilities::PointsKey PkeyZ(
597  const LibUtilities::BasisKey BkeyZ(
599 
600  for (i = 0; i < m_fields.size(); i++)
601  {
602  m_fields[i] = MemoryManager<MultiRegions
603  ::DisContField3DHomogeneous1D>
604  ::AllocateSharedPtr(
605  m_session, BkeyZ, m_LhomZ, m_useFFT,
607  m_session->GetVariable(i));
608  }
609  }
610  else
611  {
612  for (i = 0; i < m_fields.size(); i++)
613  {
614  m_fields[i] = MemoryManager<MultiRegions::
615  DisContField>::AllocateSharedPtr(
617  m_session->GetVariable(i));
618  }
619  }
620 
621  break;
622  }
623  case 3:
624  {
626  {
627  ASSERTL0(false,
628  "3D fully periodic problems not implemented yet");
629  }
630  else
631  {
632  for (i = 0; i < m_fields.size(); i++)
633  {
634  m_fields[i] = MemoryManager<MultiRegions::
635  DisContField>::AllocateSharedPtr(
637  m_session->GetVariable(i));
638  }
639  }
640  break;
641  }
642  default:
643  ASSERTL0(false, "Expansion dimension not recognised");
644  break;
645  }
646 
647  // Setting up the normals
650 
651  for (i = 0; i < m_spacedim; ++i)
652  {
653  m_traceNormals[i] =
655  }
656 
657  m_fields[0]->GetTrace()->GetNormals(m_traceNormals);
658  }
659 
660  // Set Default Parameter
661  m_session->LoadParameter("Time", m_time, 0.0);
662  m_session->LoadParameter("TimeStep", m_timestep, 0.0);
663  m_session->LoadParameter("NumSteps", m_steps, 0);
664  m_session->LoadParameter("IO_CheckSteps", m_checksteps, 0);
665  m_session->LoadParameter("IO_CheckTime", m_checktime, 0.0);
666  m_session->LoadParameter("FinTime", m_fintime, 0);
667  m_session->LoadParameter("NumQuadPointsError",
669 
670  // Check uniqueness of checkpoint output
671  ASSERTL0((m_checktime == 0.0 && m_checksteps == 0) ||
672  (m_checktime > 0.0 && m_checksteps == 0) ||
673  (m_checktime == 0.0 && m_checksteps > 0),
674  "Only one of IO_CheckTime and IO_CheckSteps "
675  "should be set!");
676  m_session->LoadParameter("TimeIncrementFactor",
677  m_TimeIncrementFactor , 1.0);
678 
679  m_nchk = 0;
680 
681  // Zero all physical fields initially
682  ZeroPhysFields();
683  }
684 
685  /**
686  * @brief Destructor for class EquationSystem.
687  */
689  {
694  }
695 
697  std::string name,
698  const MultiRegions::ExpListSharedPtr &field,
699  bool cache)
700  {
701  MultiRegions::ExpListSharedPtr vField = field;
702  if (!field)
703  {
704  vField = m_fields[0];
705  }
706 
707  if (cache)
708  {
709  if ((m_sessionFunctions.find(name) == m_sessionFunctions.end())
710  || (m_sessionFunctions[name]->GetSession() != m_session)
711  || (m_sessionFunctions[name]->GetExpansion() != vField)
712  )
713  {
716  m_session, vField, name, cache);
717  }
718 
719  return m_sessionFunctions[name];
720  }
721  else
722  {
724  new SessionFunction(m_session,vField, name, cache));
725  }
726  }
727 
728  /**
729  * If boundary conditions are time-dependent, they will be evaluated at
730  * the time specified.
731  * @param time The time at which to evaluate the BCs
732  */
734  {
735  std::string varName;
736  int nvariables = m_fields.size();
737  for (int i = 0; i < nvariables; ++i)
738  {
739  varName = m_session->GetVariable(i);
740  m_fields[i]->EvaluateBoundaryConditions(time, varName);
741  }
742  }
743 
744  /**
745  * Compute the error in the L2-norm.
746  * @param field The field to compare.
747  * @param exactsoln The exact solution to compare with.
748  * @param Normalised Normalise L2-error.
749  * @returns Error in the L2-norm.
750  */
752  unsigned int field,
753  const Array<OneD, NekDouble> &exactsoln,
754  bool Normalised)
755  {
756  NekDouble L2error = -1.0;
757 
758  if (m_NumQuadPointsError == 0)
759  {
760  if (m_fields[field]->GetPhysState() == false)
761  {
762  m_fields[field]->BwdTrans(m_fields[field]->GetCoeffs(),
763  m_fields[field]->UpdatePhys());
764  }
765 
766  if (exactsoln.size())
767  {
768  L2error = m_fields[field]->L2(
769  m_fields[field]->GetPhys(), exactsoln);
770  }
771  else if (m_session->DefinesFunction("ExactSolution"))
772  {
774  exactsoln(m_fields[field]->GetNpoints());
775 
776  GetFunction("ExactSolution")->Evaluate(
777  m_session->GetVariable(field), exactsoln, m_time);
778 
779  L2error = m_fields[field]->L2(
780  m_fields[field]->GetPhys(), exactsoln);
781  }
782  else
783  {
784  L2error = m_fields[field]->L2(m_fields[field]->GetPhys());
785  }
786 
787  if (Normalised == true)
788  {
790  1.0);
791 
792  NekDouble Vol = m_fields[field]->Integral(one);
793  L2error = sqrt(L2error*L2error/Vol);
794  }
795  }
796  else
797  {
798  Array<OneD,NekDouble> L2INF(2);
799  L2INF = ErrorExtraPoints(field);
800  L2error = L2INF[0];
801  }
802  return L2error;
803  }
804 
805  /**
806  * Compute the error in the L_inf-norm
807  * @param field The field to compare.
808  * @param exactsoln The exact solution to compare with.
809  * @returns Error in the L_inft-norm.
810  */
812  unsigned int field,
813  const Array<OneD, NekDouble> &exactsoln)
814  {
815  NekDouble Linferror = -1.0;
816 
817  if (m_NumQuadPointsError == 0)
818  {
819  if (m_fields[field]->GetPhysState() == false)
820  {
821  m_fields[field]->BwdTrans(m_fields[field]->GetCoeffs(),
822  m_fields[field]->UpdatePhys());
823  }
824 
825  if (exactsoln.size())
826  {
827  Linferror = m_fields[field]->Linf(
828  m_fields[field]->GetPhys(), exactsoln);
829  }
830  else if (m_session->DefinesFunction("ExactSolution"))
831  {
833  exactsoln(m_fields[field]->GetNpoints());
834 
835  GetFunction("ExactSolution")->Evaluate(
836  m_session->GetVariable(field), exactsoln, m_time);
837 
838  Linferror = m_fields[field]->Linf(
839  m_fields[field]->GetPhys(), exactsoln);
840  }
841  else
842  {
843  Linferror = m_fields[field]->Linf(
844  m_fields[field]->GetPhys());
845  }
846  }
847  else
848  {
849  Array<OneD,NekDouble> L2INF(2);
850  L2INF = ErrorExtraPoints(field);
851  Linferror = L2INF[1];
852  }
853 
854  return Linferror;
855  }
856 
857  /**
858  * Compute the error in the L2-norm, L-inf for a larger number of
859  * quadrature points.
860  * @param field The field to compare.
861  * @returns Error in the L2-norm and L-inf norm.
862  */
864  unsigned int field)
865  {
866  int NumModes = GetNumExpModes();
867  Array<OneD,NekDouble> L2INF(2);
868 
869  const LibUtilities::PointsKey PkeyT1(
871  const LibUtilities::PointsKey PkeyT2(
873  const LibUtilities::PointsKey PkeyQ1(
875  const LibUtilities::PointsKey PkeyQ2(
877  const LibUtilities::BasisKey BkeyT1(
878  LibUtilities::eModified_A,NumModes, PkeyT1);
879  const LibUtilities::BasisKey BkeyT2(
880  LibUtilities::eModified_B, NumModes, PkeyT2);
881  const LibUtilities::BasisKey BkeyQ1(
882  LibUtilities::eModified_A, NumModes, PkeyQ1);
883  const LibUtilities::BasisKey BkeyQ2(
884  LibUtilities::eModified_A, NumModes, PkeyQ2);
885 
886  LibUtilities::BasisKeyVector Tkeys, Qkeys;
887 
888  // make a copy of the ExpansionInfoMap
889  SpatialDomains::ExpansionInfoMap NewExpInfo = m_graph->GetExpansionInfo();
892 
893  // reset new graph with new keys
894  Tkeys.push_back(BkeyT1);
895  Tkeys.push_back(BkeyT2);
896  m_graph->ResetExpansionInfoToBasisKey(ExpInfo, LibUtilities::eTriangle, Tkeys);
897  Qkeys.push_back(BkeyQ1);
898  Qkeys.push_back(BkeyQ2);
899  m_graph->ResetExpansionInfoToBasisKey(ExpInfo, LibUtilities::eQuadrilateral, Qkeys);
900 
901 
904 
905  int ErrorCoordim = ErrorExp->GetCoordim(0);
906  int ErrorNq = ErrorExp->GetTotPoints();
907 
908  Array<OneD,NekDouble> ErrorXc0(ErrorNq, 0.0);
909  Array<OneD,NekDouble> ErrorXc1(ErrorNq, 0.0);
910  Array<OneD,NekDouble> ErrorXc2(ErrorNq, 0.0);
911 
912  switch(ErrorCoordim)
913  {
914  case 1:
915  ErrorExp->GetCoords(ErrorXc0);
916  break;
917  case 2:
918  ErrorExp->GetCoords(ErrorXc0, ErrorXc1);
919  break;
920  case 3:
921  ErrorExp->GetCoords(ErrorXc0, ErrorXc1, ErrorXc2);
922  break;
923  }
925  m_session->GetFunction("ExactSolution", field);
926 
927  // Evaluate the exact solution
928  Array<OneD,NekDouble> ErrorSol(ErrorNq);
929 
930  exSol->Evaluate(ErrorXc0,ErrorXc1,ErrorXc2,m_time,ErrorSol);
931 
932  // Calcualte spectral/hp approximation on the quadrature points
933  // of this new expansion basis
934  ErrorExp->BwdTrans_IterPerExp(m_fields[field]->GetCoeffs(),
935  ErrorExp->UpdatePhys());
936 
937  L2INF[0] = ErrorExp->L2 (ErrorExp->GetPhys(), ErrorSol);
938  L2INF[1] = ErrorExp->Linf(ErrorExp->GetPhys(), ErrorSol);
939 
940  return L2INF;
941  }
942 
943 
944  /**
945  * Set the physical fields based on a restart file, or a function
946  * describing the initial condition given in the session.
947  * @param initialtime Time at which to evaluate the function.
948  * @param dumpInitialConditions Write the initial condition to file?
949  */
951  bool dumpInitialConditions,
952  const int domain)
953  {
954  boost::ignore_unused(initialtime);
955 
956  if (m_session->GetComm()->GetRank() == 0)
957  {
958  cout << "Initial Conditions:" << endl;
959  }
960 
961  if (m_session->DefinesFunction("InitialConditions"))
962  {
963  GetFunction("InitialConditions")->Evaluate(
964  m_session->GetVariables(), m_fields, m_time, domain);
965  // Enforce C0 Continutiy of initial condiiton
968  {
969  for (int i = 0; i < m_fields.size(); ++i)
970  {
971  m_fields[i]->LocalToGlobal();
972  m_fields[i]->GlobalToLocal();
973  m_fields[i]->BwdTrans(m_fields[i]->GetCoeffs(),
974  m_fields[i]->UpdatePhys());
975  }
976  }
977 
978  if (m_session->GetComm()->GetRank() == 0)
979  {
980 
981  for (int i = 0; i < m_fields.size(); ++i)
982  {
983  std::string varName = m_session->GetVariable(i);
984  cout << " - Field " << varName << ": "
985  << GetFunction("InitialConditions")->Describe(varName, domain)
986  << endl;
987  }
988  }
989  }
990  else
991  {
992  int nq = m_fields[0]->GetNpoints();
993  for (int i = 0; i < m_fields.size(); i++)
994  {
995  Vmath::Zero(nq, m_fields[i]->UpdatePhys(), 1);
996  m_fields[i]->SetPhysState(true);
998  m_fields[i]->UpdateCoeffs(), 1);
999  if (m_session->GetComm()->GetRank() == 0)
1000  {
1001  cout << " - Field " << m_session->GetVariable(i)
1002  << ": 0 (default)" << endl;
1003  }
1004  }
1005 
1006  }
1007 
1008  if (dumpInitialConditions && m_checksteps && m_nchk == 0)
1009  {
1011  }
1012  ++m_nchk;
1013  }
1014 
1016  unsigned int field,
1017  Array<OneD, NekDouble> &outfield,
1018  const NekDouble time)
1019  {
1020  ASSERTL0 (outfield.size() == m_fields[field]->GetNpoints(),
1021  "ExactSolution array size mismatch.");
1022  Vmath::Zero(outfield.size(), outfield, 1);
1023  if (m_session->DefinesFunction("ExactSolution"))
1024  {
1025  GetFunction("ExactSolution")->Evaluate(
1026  m_session->GetVariable(field), outfield, time);
1027  }
1028  }
1029 
1030 
1031  /**
1032  * By default, nothing needs initialising at the EquationSystem level.
1033  */
1035  {
1036 
1037  }
1038 
1039  /**
1040  *
1041  */
1043  {
1044 
1045  }
1046 
1047  /**
1048  * Virtual function to define if operator in DoSolve is
1049  * negated with regard to the strong form. This is currently
1050  * only used in Arnoldi solves. Default is false.
1051  */
1053  {
1054  return false;
1055  }
1056 
1057  /**
1058  *
1059  */
1061  {
1062 
1063  }
1064 
1065  /**
1066  *
1067  */
1069  {
1070 
1071  }
1072 
1073 
1074  /// Virtual function for generating summary information.
1076  {
1077  SessionSummary(l);
1078  }
1079 
1080 
1081  /**
1082  * Write the field data to file. The file is named according to the
1083  * session name with the extension .fld appended.
1084  */
1086  {
1087  WriteFld(m_sessionName + ".fld");
1088  }
1089 
1090  /**
1091  * Zero the physical fields.
1092  */
1094  {
1095  for (int i = 0; i < m_fields.size(); i++)
1096  {
1098  m_fields[i]->UpdatePhys(),1);
1099  }
1100  }
1101 
1102  /**
1103  * FwdTrans the m_fields members
1104  */
1106  {
1107  for (int i = 0; i < m_fields.size(); i++)
1108  {
1109  m_fields[i]->FwdTrans(m_fields[i]->GetPhys(),
1110  m_fields[i]->UpdateCoeffs());
1111  m_fields[i]->SetPhysState(false);
1112  }
1113  }
1114 
1115  /**
1116  * Write the n-th checkpoint file.
1117  * @param n The index of the checkpoint file.
1118  */
1120  {
1121  std::string outname = m_sessionName + "_" +
1122  boost::lexical_cast<std::string>(n);
1123  WriteFld(outname + ".chk");
1124  }
1125 
1126  /**
1127  * Write the n-th checkpoint file.
1128  * @param n The index of the checkpoint file.
1129  */
1131  const int n,
1133  std::vector<Array<OneD, NekDouble> > &fieldcoeffs,
1134  std::vector<std::string> &variables)
1135  {
1136  std::string outname = m_sessionName + "_" +
1137  boost::lexical_cast<std::string>(n);
1138  WriteFld(outname, field, fieldcoeffs, variables);
1139  }
1140 
1141  /**
1142  * Write the n-th base flow into a .chk file
1143  * @param n The index of the base flow file.
1144  */
1146  {
1147  std::string outname = m_sessionName + "_BaseFlow_" +
1148  boost::lexical_cast<std::string>(n);
1149 
1150  WriteFld(outname + ".chk");
1151  }
1152 
1153  /**
1154  * Writes the field data to a file with the given filename.
1155  * @param outname Filename to write to.
1156  */
1157  void EquationSystem::WriteFld(const std::string &outname)
1158  {
1159  std::vector<Array<OneD, NekDouble> > fieldcoeffs(
1160  m_fields.size());
1161  std::vector<std::string> variables(m_fields.size());
1162 
1163  for (int i = 0; i < m_fields.size(); ++i)
1164  {
1165  if (m_fields[i]->GetNcoeffs() == m_fields[0]->GetNcoeffs())
1166  {
1167  fieldcoeffs[i] = m_fields[i]->UpdateCoeffs();
1168  }
1169  else
1170  {
1171  fieldcoeffs[i] = Array<OneD,NekDouble>(m_fields[0]->
1172  GetNcoeffs());
1173  m_fields[0]->ExtractCoeffsToCoeffs(m_fields[i],
1174  m_fields[i]->GetCoeffs(),
1175  fieldcoeffs[i]);
1176  }
1177  variables[i] = m_boundaryConditions->GetVariable(i);
1178  }
1179 
1180  ExtraFldOutput(fieldcoeffs, variables);
1181 
1182  WriteFld(outname, m_fields[0], fieldcoeffs, variables);
1183  }
1184 
1185 
1186 
1187  /**
1188  * Writes the field data to a file with the given filename.
1189  * @param outname Filename to write to.
1190  * @param field ExpList on which data is based.
1191  * @param fieldcoeffs An array of array of expansion coefficients.
1192  * @param variables An array of variable names.
1193  */
1195  const std::string &outname,
1197  std::vector<Array<OneD, NekDouble> > &fieldcoeffs,
1198  std::vector<std::string> &variables)
1199  {
1200  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
1201  = field->GetFieldDefinitions();
1202  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
1203 
1204  // Copy Data into FieldData and set variable
1205  for(int j = 0; j < fieldcoeffs.size(); ++j)
1206  {
1207  for(int i = 0; i < FieldDef.size(); ++i)
1208  {
1209  // Could do a search here to find correct variable
1210  FieldDef[i]->m_fields.push_back(variables[j]);
1211  field->AppendFieldData(FieldDef[i], FieldData[i],
1212  fieldcoeffs[j]);
1213  }
1214  }
1215 
1216  // Update time in field info if required
1217  if(m_fieldMetaDataMap.find("Time") != m_fieldMetaDataMap.end())
1218  {
1219  m_fieldMetaDataMap["Time"] =
1220  boost::lexical_cast<std::string>(m_time);
1221  }
1222 
1223  // Update step in field info if required
1224  if(m_fieldMetaDataMap.find("ChkFileNum") != m_fieldMetaDataMap.end())
1225  {
1226  m_fieldMetaDataMap["ChkFileNum"] =
1227  boost::lexical_cast<std::string>(m_nchk);
1228  }
1229 
1230  // If necessary, add mapping information to metadata
1231  // and output mapping coordinates
1233  fields[0] = field;
1237  mapping->Output( fieldMetaDataMap, outname);
1238 
1239 #ifdef NEKTAR_DISABLE_BACKUPS
1240  bool backup = false;
1241 #else
1242  bool backup = true;
1243 #endif
1244 
1245  m_fld->Write(outname, FieldDef, FieldData, fieldMetaDataMap, backup);
1246  }
1247 
1248 
1249  /**
1250  * Import field from infile and load into \a m_fields. This routine will
1251  * also perform a \a BwdTrans to ensure data is in both the physical and
1252  * coefficient storage.
1253  * @param infile Filename to read.
1254  */
1256  const std::string &infile,
1258  {
1259  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
1260  std::vector<std::vector<NekDouble> > FieldData;
1261  LibUtilities::FieldIOSharedPtr field_fld =
1263  field_fld->Import(infile,FieldDef,FieldData);
1264 
1265  // Copy FieldData into m_fields
1266  for(int j = 0; j < pFields.size(); ++j)
1267  {
1268  Vmath::Zero(pFields[j]->GetNcoeffs(),
1269  pFields[j]->UpdateCoeffs(),1);
1270 
1271  for(int i = 0; i < FieldDef.size(); ++i)
1272  {
1273  ASSERTL1(FieldDef[i]->m_fields[j] ==
1274  m_session->GetVariable(j),
1275  std::string("Order of ") + infile
1276  + std::string(" data and that defined in "
1277  "m_boundaryconditions differs"));
1278 
1279  pFields[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
1280  FieldDef[i]->m_fields[j],
1281  pFields[j]->UpdateCoeffs());
1282  }
1283  pFields[j]->BwdTrans(pFields[j]->GetCoeffs(),
1284  pFields[j]->UpdatePhys());
1285  }
1286  }
1287 
1288 
1289 
1290  /**
1291  * Import field from infile and load into \a m_fields. This routine will
1292  * also perform a \a BwdTrans to ensure data is in both the physical and
1293  * coefficient storage.
1294  * @param infile Filename to read.
1295  * If optionan \a ndomains is specified it assumes we loop over nodmains
1296  * for each nvariables.
1297  */
1299  const std::string &infile,
1301  const int ndomains)
1302  {
1303  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
1304  std::vector<std::vector<NekDouble> > FieldData;
1305 
1306  LibUtilities::Import(infile,FieldDef,FieldData);
1307 
1308  int nvariables = GetNvariables();
1309 
1310  ASSERTL0(ndomains*nvariables == pFields.size(),
1311  "Number of fields does not match the number of variables and domains");
1312 
1313  // Copy FieldData into m_fields
1314  for(int j = 0; j < ndomains; ++j)
1315  {
1316  for(int i = 0; i < nvariables; ++i)
1317  {
1318  Vmath::Zero(pFields[j*nvariables+i]->GetNcoeffs(),
1319  pFields[j*nvariables+i]->UpdateCoeffs(),1);
1320 
1321  for(int n = 0; n < FieldDef.size(); ++n)
1322  {
1323  ASSERTL1(FieldDef[n]->m_fields[i] == m_session->GetVariable(i),
1324  std::string("Order of ") + infile
1325  + std::string(" data and that defined in "
1326  "m_boundaryconditions differs"));
1327 
1328  pFields[j*nvariables+i]->ExtractDataToCoeffs(
1329  FieldDef[n], FieldData[n],
1330  FieldDef[n]->m_fields[i],
1331  pFields[j*nvariables+i]->UpdateCoeffs());
1332  }
1333  pFields[j*nvariables+i]->BwdTrans(
1334  pFields[j*nvariables+i]->GetCoeffs(),
1335  pFields[j*nvariables+i]->UpdatePhys());
1336  }
1337  }
1338  }
1339 
1340  /**
1341  * Import field from infile and load into \a pField. This routine will
1342  * also perform a \a BwdTrans to ensure data is in both the physical and
1343  * coefficient storage.
1344  */
1346  const std::string &infile,
1348  std::string &pFieldName)
1349  {
1350  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
1351  std::vector<std::vector<NekDouble> > FieldData;
1352 
1353  LibUtilities::FieldIOSharedPtr field_fld =
1355  field_fld->Import(infile,FieldDef,FieldData);
1356  int idx = -1;
1357 
1358  Vmath::Zero(pField->GetNcoeffs(),pField->UpdateCoeffs(),1);
1359 
1360  for(int i = 0; i < FieldDef.size(); ++i)
1361  {
1362  // find the index of the required field in the file.
1363  for(int j = 0; j < FieldData.size(); ++j)
1364  {
1365  if (FieldDef[i]->m_fields[j] == pFieldName)
1366  {
1367  idx = j;
1368  }
1369  }
1370  ASSERTL1(idx >= 0, "Field " + pFieldName + " not found.");
1371 
1372  pField->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
1373  FieldDef[i]->m_fields[idx],
1374  pField->UpdateCoeffs());
1375  }
1376  pField->BwdTrans(pField->GetCoeffs(), pField->UpdatePhys());
1377  }
1378 
1379  /**
1380  * Import field from infile and load into the array \a coeffs.
1381  *
1382  * @param infile Filename to read.
1383  * @param fieldStr an array of string identifying fields to be imported
1384  * @param coeffs array of array of coefficients to store imported data
1385  */
1387  const std::string &infile,
1388  std::vector< std::string> &fieldStr,
1389  Array<OneD, Array<OneD, NekDouble> > &coeffs)
1390  {
1391 
1392  ASSERTL0(fieldStr.size() <= coeffs.size(),
1393  "length of fieldstr should be the same as pFields");
1394 
1395  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
1396  std::vector<std::vector<NekDouble> > FieldData;
1397 
1398  LibUtilities::FieldIOSharedPtr field_fld =
1400  field_fld->Import(infile,FieldDef,FieldData);
1401 
1402  // Copy FieldData into m_fields
1403  for(int j = 0; j < fieldStr.size(); ++j)
1404  {
1405  Vmath::Zero(coeffs[j].size(),coeffs[j],1);
1406  for(int i = 0; i < FieldDef.size(); ++i)
1407  {
1408  m_fields[0]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
1409  fieldStr[j], coeffs[j]);
1410  }
1411  }
1412  }
1413 
1414  /**
1415  * Write out a summary of the session data.
1416  * @param out Output stream to write data to.
1417  */
1419  {
1420  AddSummaryItem(s, "EquationType",
1421  m_session->GetSolverInfo("EQTYPE"));
1422  AddSummaryItem(s, "Session Name", m_sessionName);
1423  AddSummaryItem(s, "Spatial Dim.", m_spacedim);
1424  AddSummaryItem(s, "Max SEM Exp. Order",
1425  m_fields[0]->EvalBasisNumModesMax());
1426 
1427  if (m_session->GetComm()->GetSize() > 1)
1428  {
1429  AddSummaryItem(s, "Num. Processes",
1430  m_session->GetComm()->GetSize());
1431  }
1432 
1434  {
1435  AddSummaryItem(s, "Quasi-3D", "Homogeneous in z-direction");
1436  AddSummaryItem(s, "Expansion Dim.", m_expdim + 1);
1437  AddSummaryItem(s, "Num. Hom. Modes (z)", m_npointsZ);
1438  AddSummaryItem(s, "Hom. length (LZ)", m_LhomZ);
1439  AddSummaryItem(s, "FFT Type", m_useFFT ? "FFTW" : "MVM");
1440  if (m_halfMode)
1441  {
1442  AddSummaryItem(s, "ModeType", "Half Mode");
1443  }
1444  else if (m_singleMode)
1445  {
1446  AddSummaryItem(s, "ModeType", "Single Mode");
1447  }
1448  else if (m_multipleModes)
1449  {
1450  AddSummaryItem(s, "ModeType", "Multiple Modes");
1451  }
1452  }
1453  else if(m_HomogeneousType == eHomogeneous2D)
1454  {
1455  AddSummaryItem(s, "Quasi-3D", "Homogeneous in yz-plane");
1456  AddSummaryItem(s, "Expansion Dim.", m_expdim + 2);
1457  AddSummaryItem(s, "Num. Hom. Modes (y)", m_npointsY);
1458  AddSummaryItem(s, "Num. Hom. Modes (z)", m_npointsZ);
1459  AddSummaryItem(s, "Hom. length (LY)", m_LhomY);
1460  AddSummaryItem(s, "Hom. length (LZ)", m_LhomZ);
1461  AddSummaryItem(s, "FFT Type", m_useFFT ? "FFTW" : "MVM");
1462  }
1463  else
1464  {
1465  AddSummaryItem(s, "Expansion Dim.", m_expdim);
1466  }
1467 
1468  if (m_session->DefinesSolverInfo("UpwindType"))
1469  {
1470  AddSummaryItem(s, "Riemann Solver",
1471  m_session->GetSolverInfo("UpwindType"));
1472  }
1473 
1474  if (m_session->DefinesSolverInfo("AdvectionType"))
1475  {
1476  std::string AdvectionType;
1477  AdvectionType = m_session->GetSolverInfo("AdvectionType");
1478  AddSummaryItem(s, "Advection Type", GetAdvectionFactory().
1479  GetClassDescription(AdvectionType));
1480  }
1481 
1483  {
1484  AddSummaryItem(s, "Projection Type", "Continuous Galerkin");
1485  }
1487  {
1488  AddSummaryItem(s, "Projection Type", "Discontinuous Galerkin");
1489  }
1491  {
1492  AddSummaryItem(s, "Projection Type",
1493  "Mixed Continuous Galerkin and Discontinuous");
1494  }
1495 
1496  if (m_session->DefinesSolverInfo("DiffusionType"))
1497  {
1498  std::string DiffusionType;
1499  DiffusionType = m_session->GetSolverInfo("DiffusionType");
1500  AddSummaryItem(s, "Diffusion Type", GetDiffusionFactory().
1501  GetClassDescription(DiffusionType));
1502  }
1503  }
1504 
1506  {
1507  return Array<OneD, bool>(m_session->GetVariables().size(), false);
1508  }
1509 
1511  {
1512  ASSERTL0(false, "This function is not valid for the Base class");
1514  return null;
1515  }
1516 
1518  std::vector<Array<OneD, NekDouble> > &fieldcoeffs,
1519  std::vector<std::string> &variables)
1520  {
1521  boost::ignore_unused(fieldcoeffs, variables);
1522  }
1523 
1524  }
1525 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250
static GLOBAL_MAPPING_EXPORT MappingSharedPtr Load(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Return a pointer to the mapping, creating it on first call.
Definition: Mapping.cpp:268
Describes the specification for a Basis.
Definition: Basis.h:50
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:226
static std::shared_ptr< FieldIO > CreateDefault(const LibUtilities::SessionReaderSharedPtr session)
Returns an object for the default FieldIO method.
Definition: FieldIO.cpp:195
Provides a generic Factory class.
Definition: NekFactory.hpp:105
Defines a specification for a set of points.
Definition: Points.h:60
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
This class is the abstraction of a global continuous two- dimensional spectral/hp element expansion w...
Definition: ContField.h:56
virtual SOLVER_UTILS_EXPORT void v_DoInitialise()
Virtual function for initialisation implementation.
int m_spacedim
Spatial dimension (>= expansion dim).
SOLVER_UTILS_EXPORT int GetTraceNpoints()
SOLVER_UTILS_EXPORT void ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
bool m_useFFT
Flag to determine if FFT is used for homogeneous transform.
SOLVER_UTILS_EXPORT int GetNvariables()
int m_expdim
Expansion dimension.
LibUtilities::FieldIOSharedPtr m_fld
Field input/output.
SOLVER_UTILS_EXPORT void SessionSummary(SummaryList &vSummary)
Write out a session summary.
virtual SOLVER_UTILS_EXPORT void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
virtual SOLVER_UTILS_EXPORT ~EquationSystem()
Destructor.
SpatialDomains::MeshGraphSharedPtr m_graph
Pointer to graph defining mesh.
LibUtilities::CommSharedPtr m_comm
Communicator.
NekDouble m_timestep
Time step size.
SOLVER_UTILS_EXPORT void ImportFld(const std::string &infile, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Input field data from the given file.
NekDouble m_time
Current time of simulation.
bool m_multipleModes
Flag to determine if use multiple homogenenous modes are used.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
virtual SOLVER_UTILS_EXPORT void v_TransPhysToCoeff()
Virtual function for transformation to coefficient space.
NekDouble m_fintime
Finish time of the simulation.
virtual SOLVER_UTILS_EXPORT NekDouble v_L2Error(unsigned int field, const Array< OneD, NekDouble > &exactsoln=NullNekDouble1DArray, bool Normalised=false)
Virtual function for the L_2 error computation between fields and a given exact solution.
virtual SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr v_GetPressure(void)
int m_npointsZ
number of points in Z direction (if homogeneous)
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
virtual SOLVER_UTILS_EXPORT void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
std::map< std::string, SolverUtils::SessionFunctionSharedPtr > m_sessionFunctions
Map of known SessionFunctions.
NekDouble m_checktime
Time between checkpoints.
virtual SOLVER_UTILS_EXPORT NekDouble v_LinfError(unsigned int field, const Array< OneD, NekDouble > &exactsoln=NullNekDouble1DArray)
Virtual function for the L_inf error computation between fields and a given exact solution.
virtual SOLVER_UTILS_EXPORT void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
SOLVER_UTILS_EXPORT void WriteFld(const std::string &outname)
Write field data to the given filename.
SOLVER_UTILS_EXPORT void ImportFldToMultiDomains(const std::string &infile, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const int ndomains)
Input field data from the given file to multiple domains.
NekDouble m_LhomY
physical length in Y direction (if homogeneous)
int m_npointsY
number of points in Y direction (if homogeneous)
std::string m_sessionName
Name of the session.
SOLVER_UTILS_EXPORT void Checkpoint_BaseFlow(const int n)
Write base flow file of m_fields.
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
bool m_singleMode
Flag to determine if single homogeneous mode is used.
virtual SOLVER_UTILS_EXPORT bool v_NegatedOp()
Virtual function to identify if operator is negated in DoSolve.
SOLVER_UTILS_EXPORT void ZeroPhysFields()
int m_HomoDirec
number of homogenous directions
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
enum HomogeneousType m_HomogeneousType
SOLVER_UTILS_EXPORT Array< OneD, NekDouble > ErrorExtraPoints(unsigned int field)
Compute error (L2 and L_inf) over an larger set of quadrature points return [L2 Linf].
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, bool > m_checkIfSystemSingular
Flag to indicate if the fields should be checked for singularity.
bool m_homogen_dealiasing
Flag to determine if dealiasing is used for homogeneous simulations.
SOLVER_UTILS_EXPORT int GetNcoeffs()
int m_nchk
Number of checkpoints written so far.
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
virtual SOLVER_UTILS_EXPORT void v_DoSolve()
Virtual function for solve implementation.
virtual SOLVER_UTILS_EXPORT Array< OneD, bool > v_GetSystemSingularChecks()
int m_steps
Number of steps to take.
int m_NumQuadPointsError
Number of Quadrature points used to work out the error.
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
SOLVER_UTILS_EXPORT int GetNumExpModes()
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
Pointer to boundary conditions object.
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
NekDouble m_LhomZ
physical length in Z direction (if homogeneous)
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &l)
Virtual function for generating summary information.
bool m_halfMode
Flag to determine if half homogeneous mode is used.
SOLVER_UTILS_EXPORT void FwdTransFields()
int m_checksteps
Number of steps between checkpoints.
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Initialisation object for EquationSystem.
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
virtual SOLVER_UTILS_EXPORT void v_Output(void)
virtual SOLVER_UTILS_EXPORT void v_TransCoeffToPhys()
Virtual function for transformation to physical space.
GLOBAL_MAPPING_EXPORT typedef std::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
Definition: Mapping.h:50
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > &ElementIDs)
This function allows for data to be imported from an FLD file when a session and/or communicator is n...
Definition: FieldIO.cpp:293
std::shared_ptr< FieldIO > FieldIOSharedPtr
Definition: FieldIO.h:306
std::map< std::string, std::string > FieldMetaDataMap
Definition: FieldIO.h:52
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:131
static FieldMetaDataMap NullFieldMetaDataMap
Definition: FieldIO.h:53
std::vector< BasisKey > BasisKeyVector
Name for a vector of BasisKeys.
@ eFourierEvenlySpaced
1D Evenly-spaced points using Fourier Fit
Definition: PointsType.h:65
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:51
@ eFourierSingleModeSpaced
1D Non Evenly-spaced points for Single Mode analysis
Definition: PointsType.h:66
@ eGaussRadauMAlpha1Beta0
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:58
@ eModified_B
Principle Modified Functions .
Definition: BasisType.h:49
@ eFourierSingleMode
Fourier ModifiedExpansion with just the first mode .
Definition: BasisType.h:59
@ eModified_A
Principle Modified Functions .
Definition: BasisType.h:48
@ eFourierHalfModeIm
Fourier Modified expansions with just the imaginary part of the first mode
Definition: BasisType.h:61
@ eFourierHalfModeRe
Fourier Modified expansions with just the real part of the first mode
Definition: BasisType.h:60
@ eFourier
Fourier Expansion .
Definition: BasisType.h:53
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< ContField > ContFieldSharedPtr
Definition: ContField.h:292
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:47
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:46
DiffusionFactory & GetDiffusionFactory()
Definition: Diffusion.cpp:41
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:47
std::shared_ptr< SessionFunction > SessionFunctionSharedPtr
std::shared_ptr< ExpansionInfoMap > ExpansionInfoMapShPtr
Definition: MeshGraph.h:145
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
std::map< int, ExpansionInfoShPtr > ExpansionInfoMap
Definition: MeshGraph.h:143
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
NekMatrix< NekMatrix< NekDouble, StandardMatrixTag >, ScaledMatrixTag > DNekScalMat
NekMatrix< NekMatrix< NekMatrix< NekDouble, StandardMatrixTag >, ScaledMatrixTag >, BlockMatrixTag > DNekScalBlkMat
Definition: NekTypeDefs.hpp:65
double NekDouble
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:436
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:267
Used to lookup the create function in NekManager.
Definition: MatrixKey.h:68