Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EquationSystem.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File EquationSystem.h
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Base class for individual solvers.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_SOLVERUTILS_EQUATIONSYSTEM_H
37 #define NEKTAR_SOLVERUTILS_EQUATIONSYSTEM_H
38 
48 #include <MultiRegions/ExpList.h>
50 #include <SolverUtils/Core/Misc.h>
51 
52 namespace Nektar
53 {
54  namespace SolverUtils
55  {
57 
58  /// A shared pointer to an EquationSystem object
59  typedef boost::shared_ptr<EquationSystem> EquationSystemSharedPtr;
60  /// Datatype of the NekFactory used to instantiate classes derived from
61  /// the EquationSystem class.
63  std::string, EquationSystem,
67 
68  /// A base class for describing how to solve specific equations.
69  class EquationSystem : public boost::enable_shared_from_this<EquationSystem>
70  {
71  public:
72  /// Destructor
74 
75  // Set up trace normals if required
77 
78  /// Initialises the members of this object.
79  SOLVER_UTILS_EXPORT inline void InitObject();
80 
81  /// Perform any initialisation necessary before solving the problem.
82  SOLVER_UTILS_EXPORT inline void DoInitialise();
83 
84  /// Solve the problem.
85  SOLVER_UTILS_EXPORT inline void DoSolve();
86 
87  /// Transform from coefficient to physical space.
89 
90  /// Transform from physical to coefficient space.
92 
93  /// Perform output operations after solve.
94  SOLVER_UTILS_EXPORT inline void Output();
95 
96  /// Linf error computation
97  SOLVER_UTILS_EXPORT inline NekDouble LinfError(unsigned int field, const Array<OneD,NekDouble> &exactsoln = NullNekDouble1DArray);
98 
99  /// Get Session name
101  {
102  return m_sessionName;
103  }
104 
105  template<class T>
106  boost::shared_ptr<T> as()
107  {
108 #if defined __INTEL_COMPILER && BOOST_VERSION > 105200
109  typedef typename boost::shared_ptr<T>::element_type E;
110  E * p = dynamic_cast< E* >( shared_from_this().get() );
111  ASSERTL1(p, "Cannot perform cast");
112  return boost::shared_ptr<T>( shared_from_this(), p );
113 #else
114  return boost::dynamic_pointer_cast<T>( shared_from_this() );
115 #endif
116  }
117 
118  /// Reset Session name
119  SOLVER_UTILS_EXPORT void ResetSessionName(std::string newname)
120  {
121  m_sessionName = newname;
122  }
123 
124  /// Get Session name
126  {
127  return m_session;
128  }
129 
130  /// Get pressure field if available
132 
133  /// Print a summary of parameters and solver characteristics.
134  SOLVER_UTILS_EXPORT inline void PrintSummary(std::ostream &out);
135 
136  /// Set parameter m_lambda
137  SOLVER_UTILS_EXPORT inline void SetLambda(NekDouble lambda);
138 
139  /// Evaluates a function as specified in the session file.
141  Array<OneD, Array<OneD, NekDouble> >& pArray,
142  std::string pFunctionName,
143  const NekDouble pTime = 0.0,
144  const int domain = 0);
145 
146  /// Populate given fields with the function from session.
148  std::vector<std::string> pFieldNames,
149  Array<OneD, Array<OneD, NekDouble> > &pFields,
150  const std::string& pName,
151  const NekDouble& pTime = 0.0,
152  const int domain = 0);
153 
154  /// Populate given fields with the function from session.
156  std::vector<std::string> pFieldNames,
158  const std::string& pName,
159  const NekDouble& pTime = 0.0,
160  const int domain = 0);
161 
162  // Populate an array with a function variable from session.
164  std::string pFieldName,
165  Array<OneD, NekDouble>& pArray,
166  const std::string& pFunctionName,
167  const NekDouble& pTime = 0.0,
168  const int domain = 0);
169 
170  // Describe a function.
172  std::string pFieldName,
173  const std::string &pFunctionName,
174  const int domain);
175 
176  /// Perform initialisation of the base flow.
179 
180  /// Initialise the data in the dependent fields.
182  NekDouble initialtime = 0.0,
183  bool dumpInitialConditions = true,
184  const int domain = 0);
185 
186  /// Evaluates an exact solution
188  int field,
189  Array<OneD, NekDouble> &outfield,
190  const NekDouble time);
191 
192  /// Compute the L2 error between fields and a given exact
193  /// solution.
195  unsigned int field,
196  const Array<OneD,NekDouble> &exactsoln,
197  bool Normalised = false);
198 
199  /// Compute the L2 error of the fields
201  unsigned int field,
202  bool Normalised = false)
203  {
204  return L2Error(field,NullNekDouble1DArray,Normalised);
205  }
206 
207  /// Compute error (L2 and L_inf) over an larger set of quadrature
208  /// points return [L2 Linf]
210  unsigned int field);
211 
212  /// Compute the inner product \f$ (\nabla \phi \cdot F) \f$.
214  const Array<OneD, Array<OneD, NekDouble> > &F,
215  Array<OneD, NekDouble> &outarray);
216 
217  /// Compute the inner product \f$ (\phi, \nabla \cdot F) \f$.
219  const Array<OneD, Array<OneD, NekDouble> > &F,
220  Array<OneD, NekDouble> &outarray);
221 
222  /// Compute the inner product \f$ (\phi, V\cdot \nabla u) \f$.
224  const Array<OneD, Array<OneD, NekDouble> > &V,
226  Array<OneD, NekDouble> &outarray,
227  bool UseContCoeffs = false);
228 
229  /// Compute the non-conservative advection \f$ (V \cdot \nabla u)
230  /// \f$.
232  const Array<OneD, Array<OneD, NekDouble> > &V,
234  Array<OneD, NekDouble> &outarray,
236 
237  /// Calculate the weak discontinuous Galerkin advection.
239  const Array<OneD, Array<OneD, NekDouble> >& InField,
240  Array<OneD, Array<OneD, NekDouble> >& OutField,
241  bool NumericalFluxIncludesNormal = true,
242  bool InFieldIsInPhysSpace = false,
243  int nvariables = 0);
244 
245  /// Calculate weak DG Diffusion in the LDG form.
247  const Array<OneD, Array<OneD, NekDouble> >& InField,
248  Array<OneD, Array<OneD, NekDouble> >& OutField,
249  bool NumericalFluxIncludesNormal = true,
250  bool InFieldIsInPhysSpace = false);
251 
252  /// Write checkpoint file of #m_fields.
253  SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n);
254 
255  /// Write checkpoint file of custom data fields.
257  const int n,
259  std::vector<Array<OneD, NekDouble> > &fieldcoeffs,
260  std::vector<std::string> &variables);
261 
262  /// Write base flow file of #m_fields.
263  SOLVER_UTILS_EXPORT void Checkpoint_BaseFlow(const int n);
264 
265  /// Write field data to the given filename.
266  SOLVER_UTILS_EXPORT void WriteFld(const std::string &outname);
267 
268  /// Write input fields to the given filename.
270  const std::string &outname,
272  std::vector<Array<OneD, NekDouble> > &fieldcoeffs,
273  std::vector<std::string> &variables);
274 
275  /// Input field data from the given file.
277  const std::string &infile,
279 
280  /// Input field data from the given file to multiple domains
282  const std::string &infile,
284  const int ndomains);
285 
286  /// Output a field.
287  /// Input field data into array from the given file.
289  const std::string &infile,
290  std::vector<std::string> &fieldStr,
291  Array<OneD, Array<OneD, NekDouble> > &coeffs);
292 
293  /// Output a field.
294  /// Input field data into ExpList from the given file.
296  const std::string &infile,
298  std::string &pFieldName);
299 
300  /// Builds map of which element holds each history point.
302 
303  /// Probe each history point and write to file.
304  SOLVER_UTILS_EXPORT void WriteHistoryData (std::ostream &out);
305 
306  /// Write out a session summary.
308 
309  SOLVER_UTILS_EXPORT inline Array<
311 
312 
313  /// Get hold of FieldInfoMap so it can be updated
316 
317  /// Return final time
319 
320  SOLVER_UTILS_EXPORT inline int GetNcoeffs();
321 
322  SOLVER_UTILS_EXPORT inline int GetNcoeffs(const int eid);
323 
324  SOLVER_UTILS_EXPORT inline int GetNumExpModes();
325 
328 
329  SOLVER_UTILS_EXPORT inline int GetNvariables();
330 
331  SOLVER_UTILS_EXPORT inline const std::string
332  GetVariable(unsigned int i);
333 
335 
337 
338  SOLVER_UTILS_EXPORT inline int GetExpSize();
339 
340  SOLVER_UTILS_EXPORT inline int GetPhys_Offset(int n);
341 
342  SOLVER_UTILS_EXPORT inline int GetCoeff_Offset(int n);
343 
344  SOLVER_UTILS_EXPORT inline int GetTotPoints();
345 
346  SOLVER_UTILS_EXPORT inline int GetTotPoints(int n);
347 
348  SOLVER_UTILS_EXPORT inline int GetNpoints();
349 
351 
352  SOLVER_UTILS_EXPORT inline int GetSteps();
353 
355 
356  SOLVER_UTILS_EXPORT inline void CopyFromPhysField(const int i,
357  Array<OneD, NekDouble> &output);
358 
359  SOLVER_UTILS_EXPORT inline void CopyToPhysField(const int i,
360  Array<OneD, NekDouble> &output);
361 
362  SOLVER_UTILS_EXPORT inline void SetSteps(const int steps);
363 
365 
367 
369  const int i,
370  Array<OneD, Array<OneD, NekDouble> >&physfield,
371  Array<OneD, Array<OneD, NekDouble> >&flux);
372 
374  const int i,
375  Array<OneD, Array<OneD, NekDouble> >&physfield,
376  Array<OneD, Array<OneD, NekDouble> >&fluxX,
377  Array<OneD, Array<OneD, NekDouble> > &fluxY);
378 
380  const int i,
381  const int j,
382  Array<OneD, Array<OneD, NekDouble> > &physfield,
383  Array<OneD, Array<OneD, NekDouble> > &flux);
384 
386  Array<OneD, Array<OneD, NekDouble> > &physfield,
387  Array<OneD, Array<OneD, NekDouble> > &numflux);
388 
390  Array<OneD, Array<OneD, NekDouble> > &physfield,
391  Array<OneD, Array<OneD, NekDouble> > &numfluxX,
392  Array<OneD, Array<OneD, NekDouble> > &numfluxY);
393 
395  const Array<OneD, Array<OneD, NekDouble> > &ufield,
396  Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &uflux);
397 
399  const Array<OneD, Array<OneD, NekDouble> > &ufield,
400  Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &qfield,
401  Array<OneD, Array<OneD, NekDouble> > &qflux);
402 
404  const bool modbasis);
405 
406  /// Perform a case-insensitive string comparison.
408  const string & s1, const string& s2) ;
409 
411  {
412  return m_nchk;
413  }
414 
416  {
417  m_nchk = num;
418  }
419 
421  {
422  return m_checksteps;
423  }
424 
426  {
427  m_checksteps = num;
428  }
429 
431  const NekDouble time)
432  {
433  m_time = time;
434  }
435 
437  const int step)
438  {
439  m_initialStep = step;
440  }
441 
442  /// Evaluates the boundary conditions at the given time.
444 
445  /// Virtual function to identify if operator is negated in DoSolve
446  SOLVER_UTILS_EXPORT virtual bool v_NegatedOp();
447 
448  protected:
449  /// Communicator
451  /// The session reader
453  /// Field input/output
455  /// Map of the interpolation weights for a specific filename.
456  map<std::string, Array<OneD, Array<OneD, float> > > m_interpWeights;
457  /// Map of the interpolation indices for a specific filename.
458  map<std::string, Array<OneD, Array<OneD, unsigned int> > > m_interpInds;
459  /// Array holding all dependent variables.
461  /// Base fields.
463  /// Array holding all dependent variables.
465  /// Pointer to boundary conditions object.
467  /// Pointer to graph defining mesh.
469  /// Name of the session.
470  std::string m_sessionName;
471  /// Current time of simulation.
473  /// Number of the step where the simulation should begin
475  /// Finish time of the simulation.
477  /// Time step size
479  /// Lambda constant in real system if one required.
481 
482  std::set<std::string> m_loadedFields;
483  /// Time between checkpoints.
485  /// Number of checkpoints written so far
486  int m_nchk;
487  /// Number of steps to take.
488  int m_steps;
489  /// Number of steps between checkpoints.
491  /// Spatial dimension (>= expansion dim).
493  /// Expansion dimension.
494  int m_expdim;
495  /// Flag to determine if single homogeneous mode is used.
497  /// Flag to determine if half homogeneous mode is used.
499  /// Flag to determine if use multiple homogenenous modes are used.
501  /// Flag to determine if FFT is used for homogeneous transform.
502  bool m_useFFT;
503  /**
504  * \brief Flag to determine if dealiasing is used for
505  * homogeneous simulations.
506  */
508  /**
509  * \brief Flag to determine if dealisising is usde for the
510  * Spectral/hp element discretisation.
511  */
513  /// Type of projection; e.g continuous or discontinuous.
515  /// Array holding trace normals for DG simulations in the forwards direction.
517  /// 1 x nvariable x nq
519  /// 2 x m_spacedim x nq
521  /// Flag to indicate if the fields should be checked for singularity.
523  /// Map to identify relevant solver info to dump in output fields
525 
526  /// Number of Quadrature points used to work out the error
528 
529  /// Parameter for homogeneous expansions
531  {
536  };
537 
538 
539 
541 
542  NekDouble m_LhomX; ///< physical length in X direction (if homogeneous)
543  NekDouble m_LhomY; ///< physical length in Y direction (if homogeneous)
544  NekDouble m_LhomZ; ///< physical length in Z direction (if homogeneous)
545 
546  int m_npointsX; ///< number of points in X direction (if homogeneous)
547  int m_npointsY; ///< number of points in Y direction (if homogeneous)
548  int m_npointsZ; ///< number of points in Z direction (if homogeneous)
549 
550  int m_HomoDirec; ///< number of homogenous directions
551 
552  int m_NumMode; ///< Mode to use in case of single mode analysis
553 
554 
555  /// Initialises EquationSystem class members.
557 
558  // Here for consistency purposes with old version
559  int nocase_cmp(const string & s1, const string& s2)
560  {
561  return NoCaseStringCompare(s1,s2);
562  }
563 
564  SOLVER_UTILS_EXPORT virtual void v_InitObject();
565 
566  /// Virtual function for initialisation implementation.
567  SOLVER_UTILS_EXPORT virtual void v_DoInitialise();
568 
569  /// Virtual function for solve implementation.
570  SOLVER_UTILS_EXPORT virtual void v_DoSolve();
571 
572 
573  /// Virtual function for the L_inf error computation between fields and a given exact solution.
575  unsigned int field,
576  const Array<OneD, NekDouble> &exactsoln = NullNekDouble1DArray);
577 
578  /// Virtual function for the L_2 error computation between fields and a given exact solution.
580  unsigned int field,
581  const Array<OneD, NekDouble> &exactsoln = NullNekDouble1DArray,
582  bool Normalised = false);
583 
584  /// Virtual function for transformation to physical space.
586 
587  /// Virtual function for transformation to coefficient space.
589 
590  /// Virtual function for generating summary information.
592 
594  NekDouble initialtime = 0.0,
595  bool dumpInitialConditions = true,
596  const int domain = 0);
597 
599  unsigned int field,
600  Array<OneD, NekDouble> &outfield,
601  const NekDouble time);
602 
603  //Initialise m_base in order to store the base flow from a file
605 
606  // Fill m_base with the values stored in a fld file
608  std::string pInfile,
610 
611  // Ouptut field information
612  SOLVER_UTILS_EXPORT virtual void v_Output(void);
613 
614  // Get pressure field if available
616 
618  std::vector<Array<OneD, NekDouble> > &fieldcoeffs,
619  std::vector<std::string> &variables);
620 
621  private:
622 
625  const int i, Array<OneD,
626  Array<OneD, NekDouble> >&physfield,
627  Array<OneD, Array<OneD, NekDouble> >&flux);
628 
630  const int i, const int j,
631  Array<OneD, Array<OneD, NekDouble> >&physfield,
632  Array<OneD, Array<OneD, NekDouble> >&flux);
633 
635  const int i, Array<OneD,
636  Array<OneD, NekDouble> >&physfield,
637  Array<OneD, Array<OneD, NekDouble> >&fluxX,
638  Array<OneD, Array<OneD, NekDouble> > &fluxY);
639 
641  Array<OneD, Array<OneD, NekDouble> > &physfield,
642  Array<OneD, Array<OneD, NekDouble> > &numflux);
643 
645  Array<OneD, Array<OneD, NekDouble> > &physfield,
646  Array<OneD, Array<OneD, NekDouble> > &numfluxX,
647  Array<OneD, Array<OneD, NekDouble> > &numfluxY);
648 
650  const Array<OneD, Array<OneD, NekDouble> > &ufield,
651  Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &uflux);
652 
654  const Array<OneD, Array<OneD, NekDouble> > &ufield,
655  Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &qfield,
656  Array<OneD, Array<OneD, NekDouble > > &qflux);
657 
658  SOLVER_UTILS_EXPORT void PrintProgressbar(const int position,
659  const int goal) const
660  {
661  LibUtilities::PrintProgressbar(position, goal, "Interpolating");
662  }
663  };
664 
665 
666  /**
667  * This is the second part of the two-phase initialisation process.
668  * Calls to virtual functions will correctly resolve to the derived class
669  * during this phase of the construction.
670  */
672  {
673  v_InitObject();
674  }
675 
676 
677  /**
678  * This allows initialisation of the solver which cannot be completed
679  * during object construction (such as setting of initial conditions).
680  *
681  * Public interface routine to virtual function implementation.
682  */
684  {
685  v_DoInitialise();
686  }
687 
688 
689  /**
690  * Performs the transformation from coefficient to physical space.
691  *
692  * Public interface routine to virtual function implementation.
693  */
695  {
697  }
698 
699  /**
700  * Performs the transformation from physical to coefficient space.
701  *
702  * Public interface routine to virtual function implementation.
703  */
705  {
707  }
708 
709 
710  /**
711  * Performs the actual solve.
712  *
713  * Public interface routine to virtual function implementation.
714  */
715  inline void EquationSystem::DoSolve(void)
716  {
717  v_DoSolve();
718  }
719 
720 
721  /**
722  * Perform output operations after solve.
723  */
724  inline void EquationSystem::Output(void)
725  {
726  v_Output();
727  }
728 
729  /**
730  * L_inf Error computation
731  * Public interface routine to virtual function implementation.
732  */
733  inline NekDouble EquationSystem::LinfError(unsigned int field, const Array<OneD,NekDouble> &exactsoln)
734  {
735  return v_LinfError(field, exactsoln);
736  }
737 
738  /**
739  * L_2 Error computation
740  * Public interface routine to virtual function implementation.
741  */
742  inline NekDouble EquationSystem::L2Error(unsigned int field, const Array<OneD,NekDouble> &exactsoln, bool Normalised)
743  {
744  return v_L2Error(field, exactsoln, Normalised);
745  }
746 
747  /**
748  * Get Pressure field if available
749  */
751  {
752  return v_GetPressure();
753  }
754 
755  /**
756  * Prints a summary of variables and problem parameters.
757  *
758  * Public interface routine to virtual function implementation.
759  *
760  * @param out The ostream object to write to.
761  */
762  inline void EquationSystem::PrintSummary(std::ostream &out)
763  {
764  if (m_session->GetComm()->GetRank() == 0)
765  {
766  std::vector<std::pair<std::string, std::string> > vSummary;
767  v_GenerateSummary(vSummary);
768 
769  out << "=======================================================================" << endl;
770  SummaryList::const_iterator x;
771  for (x = vSummary.begin(); x != vSummary.end(); ++x)
772  {
773  out << "\t";
774  out.width(20);
775  out << x->first << ": " << x->second << endl;
776  }
777  out << "=======================================================================" << endl;
778  }
779  }
780 
782  {
783  m_lambda = lambda;
784  }
785 
787  bool dumpInitialConditions,
788  const int domain)
789  {
790  v_SetInitialConditions(initialtime,dumpInitialConditions,domain);
791  }
792 
793  /// Evaluates an exact solution
795  Array<OneD, NekDouble> &outfield,
796  const NekDouble time)
797  {
798  v_EvaluateExactSolution(field, outfield, time);
799  }
800 
802  {
803  return m_fields;
804  }
805 
806  /// Return final time
808  {
809  return m_time;
810  }
811 
812  inline int EquationSystem::GetNcoeffs(void)
813  {
814  return m_fields[0]->GetNcoeffs();
815  }
816 
817  inline int EquationSystem::GetNcoeffs(const int eid)
818  {
819  return m_fields[0]->GetNcoeffs(eid);
820  }
821 
823  {
824  return m_graph->GetExpansions().begin()->second->m_basisKeyVector[0]
825  .GetNumModes();
826  }
827 
829  {
830  return m_fields[0]->EvalBasisNumModesMaxPerExp();
831  }
832 
834  {
835  return m_session->GetVariables().size();
836  }
837 
838  inline const std::string EquationSystem::GetVariable(unsigned int i)
839  {
840  return m_session->GetVariable(i);
841  }
842 
844  {
845  return GetTraceNpoints();
846  }
847 
849  {
850  return m_fields[0]->GetTrace()->GetNpoints();
851  }
852 
853  inline int EquationSystem::GetExpSize(void)
854  {
855  return m_fields[0]->GetExpSize();
856  }
857 
859  {
860  return m_fields[0]->GetPhys_Offset(n);
861  }
862 
864  {
865  return m_fields[0]->GetCoeff_Offset(n);
866  }
867 
869  {
870  return m_fields[0]->GetNpoints();
871  }
872 
874  {
875  return m_fields[0]->GetTotPoints(n);
876  }
877 
878  inline int EquationSystem::GetNpoints(void)
879  {
880  return m_fields[0]->GetNpoints();
881  }
882 
884  {
885  return (m_fields.num_elements() - 1);
886  }
887 
888  inline int EquationSystem::GetSteps(void)
889  {
890  return m_steps;
891  }
892 
894  {
895  return m_timestep;
896  }
897 
898  inline void EquationSystem::SetSteps(const int steps)
899  {
900  m_steps = steps;
901  }
902 
903  inline void EquationSystem::CopyFromPhysField(const int i,
904  Array<OneD, NekDouble> &output)
905  {
906  Vmath::Vcopy(output.num_elements(), m_fields[i]->GetPhys(), 1, output, 1 );
907  }
908 
909  inline void EquationSystem::CopyToPhysField(const int i,
910  Array<OneD, NekDouble> &output)
911  {
912  Vmath::Vcopy(output.num_elements(), output, 1, m_fields[i]->UpdatePhys(), 1 );
913  }
914 
915  inline void EquationSystem::GetFluxVector(const int i,
916  Array<OneD, Array<OneD, NekDouble> >&physfield,
918  {
919  v_GetFluxVector(i,physfield, flux);
920  }
921 
922  inline void EquationSystem::GetFluxVector(const int i,
923  Array<OneD, Array<OneD, NekDouble> >&physfield,
926  {
927  v_GetFluxVector(i,physfield, fluxX, fluxY);
928  }
929 
930  inline void EquationSystem::GetFluxVector(const int i, const int j,
931  Array<OneD, Array<OneD, NekDouble> > &physfield,
933  {
934  v_GetFluxVector(i,j,physfield,flux);
935  }
936 
938  Array<OneD, Array<OneD, NekDouble> > &numflux)
939  {
940  v_NumericalFlux(physfield, numflux);
941  }
942 
944  Array<OneD, Array<OneD, NekDouble> > &numfluxX,
945  Array<OneD, Array<OneD, NekDouble> > &numfluxY)
946  {
947  v_NumericalFlux(physfield, numfluxX, numfluxY);
948  }
949 
951  const Array<OneD, Array<OneD, NekDouble> > &ufield,
953  {
954  v_NumFluxforScalar(ufield, uflux);
955  }
956 
958  const Array<OneD, Array<OneD, NekDouble> > &ufield,
961  {
962  v_NumFluxforVector(ufield, qfield, qflux);
963  }
964  }
965 }
966 
967 #endif
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &l)
Virtual function for generating summary information.
bool m_singleMode
Flag to determine if single homogeneous mode is used.
SOLVER_UTILS_EXPORT void NumFluxforScalar(const Array< OneD, Array< OneD, NekDouble > > &ufield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &uflux)
f SOLVER_UTILS_EXPORT void AdvectionNonConservativeForm(const Array< OneD, Array< OneD, NekDouble > > &V, const Array< OneD, const NekDouble > &u, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wk=NullNekDouble1DArray)
Compute the non-conservative advection.
SOLVER_UTILS_EXPORT void InitialiseBaseFlow(Array< OneD, Array< OneD, NekDouble > > &base)
Perform initialisation of the base flow.
LibUtilities::NekFactory< std::string, EquationSystem, const LibUtilities::SessionReaderSharedPtr & > EquationSystemFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class...
SOLVER_UTILS_EXPORT std::string DescribeFunction(std::string pFieldName, const std::string &pFunctionName, const int domain)
Provide a description of a function for a given field name.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_gradtan
1 x nvariable x nq
A base class for describing how to solve specific equations.
int nocase_cmp(const string &s1, const string &s2)
static Array< OneD, NekDouble > NullNekDouble1DArray
SOLVER_UTILS_EXPORT NekDouble L2Error(unsigned int field, const Array< OneD, NekDouble > &exactsoln, bool Normalised=false)
Compute the L2 error between fields and a given exact solution.
NekDouble m_time
Current time of simulation.
SOLVER_UTILS_EXPORT void WeakAdvectionNonConservativeForm(const Array< OneD, Array< OneD, NekDouble > > &V, const Array< OneD, const NekDouble > &u, Array< OneD, NekDouble > &outarray, bool UseContCoeffs=false)
Compute the inner product .
NekDouble m_timestep
Time step size.
SOLVER_UTILS_EXPORT void SetUpTraceNormals(void)
SOLVER_UTILS_EXPORT void SetSteps(const int steps)
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:47
NekDouble m_lambda
Lambda constant in real system if one required.
SOLVER_UTILS_EXPORT int GetNvariables()
bool m_halfMode
Flag to determine if half homogeneous mode is used.
NekDouble m_LhomZ
physical length in Z direction (if homogeneous)
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.
SOLVER_UTILS_EXPORT const Array< OneD, int > GetNumExpModesPerExp()
Array< OneD, bool > m_checkIfSystemSingular
Flag to indicate if the fields should be checked for singularity.
int m_expdim
Expansion dimension.
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
NekDouble m_LhomX
physical length in X direction (if homogeneous)
SOLVER_UTILS_EXPORT Array< OneD, MultiRegions::ExpListSharedPtr > & UpdateFields()
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
map< std::string, Array< OneD, Array< OneD, unsigned int > > > m_interpInds
Map of the interpolation indices for a specific filename.
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].
ProjectionType
Type of Galerkin projection.
SOLVER_UTILS_EXPORT void WeakAdvectionGreensDivergenceForm(const Array< OneD, Array< OneD, NekDouble > > &F, Array< OneD, NekDouble > &outarray)
Compute the inner product .
NekDouble m_checktime
Time between checkpoints.
bool m_useFFT
Flag to determine if FFT is used for homogeneous transform.
NekDouble m_LhomY
physical length in Y direction (if homogeneous)
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
SOLVER_UTILS_EXPORT int GetNumExpModes()
SOLVER_UTILS_EXPORT void TransCoeffToPhys()
Transform from coefficient to physical space.
SOLVER_UTILS_EXPORT void InitObject()
Initialises the members of this object.
virtual SOLVER_UTILS_EXPORT void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
SOLVER_UTILS_EXPORT void PrintProgressbar(const int position, const int goal) const
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...
int m_npointsZ
number of points in Z direction (if homogeneous)
virtual SOLVER_UTILS_EXPORT ~EquationSystem()
Destructor.
std::string m_sessionName
Name of the session.
int m_nchk
Number of checkpoints written so far.
int m_NumMode
Mode to use in case of single mode analysis.
SOLVER_UTILS_EXPORT void WeakAdvectionDivergenceForm(const Array< OneD, Array< OneD, NekDouble > > &F, Array< OneD, NekDouble > &outarray)
Compute the inner product .
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
std::map< std::string, std::string > FieldMetaDataMap
Definition: FieldIO.h:53
int m_checksteps
Number of steps between checkpoints.
SOLVER_UTILS_EXPORT int GetCoeff_Offset(int n)
LibUtilities::CommSharedPtr m_comm
Communicator.
SOLVER_UTILS_EXPORT void SetModifiedBasis(const bool modbasis)
SOLVER_UTILS_EXPORT LibUtilities::FieldMetaDataMap & UpdateFieldMetaDataMap()
Get hold of FieldInfoMap so it can be updated.
SOLVER_UTILS_EXPORT void ResetSessionName(std::string newname)
Reset Session name.
SOLVER_UTILS_EXPORT int GetTotPoints()
SOLVER_UTILS_EXPORT const std::string GetVariable(unsigned int i)
SOLVER_UTILS_EXPORT void Output()
Perform output operations after solve.
NekDouble m_fintime
Finish time of the simulation.
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Initialisation object for EquationSystem.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_tanbasis
2 x m_spacedim x nq
SOLVER_UTILS_EXPORT void CopyToPhysField(const int i, Array< OneD, NekDouble > &output)
boost::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
int m_steps
Number of steps to take.
SOLVER_UTILS_EXPORT int NoCaseStringCompare(const string &s1, const string &s2)
Perform a case-insensitive string comparison.
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
int m_HomoDirec
number of homogenous directions
SOLVER_UTILS_EXPORT void FwdTransFields()
Array< OneD, MultiRegions::ExpListSharedPtr > m_derivedfields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT void WeakDGDiffusion(const Array< OneD, Array< OneD, NekDouble > > &InField, Array< OneD, Array< OneD, NekDouble > > &OutField, bool NumericalFluxIncludesNormal=true, bool InFieldIsInPhysSpace=false)
Calculate weak DG Diffusion in the LDG form.
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
SOLVER_UTILS_EXPORT int GetCheckpointSteps()
SOLVER_UTILS_EXPORT int GetSteps()
bool m_multipleModes
Flag to determine if use multiple homogenenous modes are used.
virtual SOLVER_UTILS_EXPORT Array< OneD, bool > v_GetSystemSingularChecks()
SOLVER_UTILS_EXPORT void TransPhysToCoeff()
Transform from physical to coefficient space.
SOLVER_UTILS_EXPORT void NumericalFlux(Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &numflux)
SOLVER_UTILS_EXPORT void SetUpBaseFields(SpatialDomains::MeshGraphSharedPtr &mesh)
SOLVER_UTILS_EXPORT void CopyFromPhysField(const int i, Array< OneD, NekDouble > &output)
SOLVER_UTILS_EXPORT void SetCheckpointSteps(int num)
int m_npointsY
number of points in Y direction (if homogeneous)
virtual SOLVER_UTILS_EXPORT void v_TransPhysToCoeff()
Virtual function for transformation to coefficient space.
virtual SOLVER_UTILS_EXPORT void v_GetFluxVector(const int i, Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &flux)
virtual SOLVER_UTILS_EXPORT void v_Output(void)
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
Pointer to boundary conditions object.
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
int m_spacedim
Spatial dimension (>= expansion dim).
SOLVER_UTILS_EXPORT NekDouble L2Error(unsigned int field, bool Normalised=false)
Compute the L2 error of the fields.
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
boost::shared_ptr< FieldIO > FieldIOSharedPtr
Definition: FieldIO.h:225
double NekDouble
virtual SOLVER_UTILS_EXPORT void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
SOLVER_UTILS_EXPORT void DoInitialise()
Perform any initialisation necessary before solving the problem.
SOLVER_UTILS_EXPORT LibUtilities::SessionReaderSharedPtr GetSession()
Get Session name.
std::set< std::string > m_loadedFields
SOLVER_UTILS_EXPORT NekDouble GetTimeStep()
SOLVER_UTILS_EXPORT void GetFluxVector(const int i, Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &flux)
SOLVER_UTILS_EXPORT void EvaluateFunction(Array< OneD, Array< OneD, NekDouble > > &pArray, std::string pFunctionName, const NekDouble pTime=0.0, const int domain=0)
Evaluates a function as specified in the session file.
SOLVER_UTILS_EXPORT void ScanForHistoryPoints()
Builds map of which element holds each history point.
virtual SOLVER_UTILS_EXPORT void v_DoInitialise()
Virtual function for initialisation implementation.
bool m_homogen_dealiasing
Flag to determine if dealiasing is used for homogeneous simulations.
SOLVER_UTILS_EXPORT std::string GetSessionName()
Get Session name.
EquationSystemFactory & GetEquationSystemFactory()
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.
int m_npointsX
number of points in X direction (if homogeneous)
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
SOLVER_UTILS_EXPORT int GetPhys_Offset(int n)
SOLVER_UTILS_EXPORT NekDouble GetFinalTime()
Return final time.
SOLVER_UTILS_EXPORT void PrintSummary(std::ostream &out)
Print a summary of parameters and solver characteristics.
SOLVER_UTILS_EXPORT void WriteFld(const std::string &outname)
Write field data to the given filename.
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT int GetExpSize()
#define SOLVER_UTILS_EXPORT
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
Array< OneD, MultiRegions::ExpListSharedPtr > m_base
Base fields.
SOLVER_UTILS_EXPORT NekDouble LinfError(unsigned int field, const Array< OneD, NekDouble > &exactsoln=NullNekDouble1DArray)
Linf error computation.
boost::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
Definition: Conditions.h:271
SOLVER_UTILS_EXPORT int GetTraceNpoints()
SOLVER_UTILS_EXPORT int GetNcoeffs()
LibUtilities::FieldIOSharedPtr m_fld
Field input/output.
HomogeneousType
Parameter for homogeneous expansions.
virtual SOLVER_UTILS_EXPORT void v_NumFluxforVector(const Array< OneD, Array< OneD, NekDouble > > &ufield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &qfield, Array< OneD, Array< OneD, NekDouble > > &qflux)
int m_initialStep
Number of the step where the simulation should begin.
SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr GetPressure()
Get pressure field if available.
virtual SOLVER_UTILS_EXPORT bool v_NegatedOp()
Virtual function to identify if operator is negated in DoSolve.
virtual SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr v_GetPressure(void)
SOLVER_UTILS_EXPORT void NumFluxforVector(const Array< OneD, Array< OneD, NekDouble > > &ufield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &qfield, Array< OneD, Array< OneD, NekDouble > > &qflux)
SOLVER_UTILS_EXPORT void ZeroPhysFields()
SOLVER_UTILS_EXPORT void EvaluateExactSolution(int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
Evaluates an exact solution.
SOLVER_UTILS_EXPORT void SessionSummary(SummaryList &vSummary)
Write out a session summary.
SOLVER_UTILS_EXPORT void SetTime(const NekDouble time)
SpatialDomains::MeshGraphSharedPtr m_graph
Pointer to graph defining mesh.
virtual SOLVER_UTILS_EXPORT void v_NumFluxforScalar(const Array< OneD, Array< OneD, NekDouble > > &ufield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &uflux)
SOLVER_UTILS_EXPORT void WriteHistoryData(std::ostream &out)
Probe each history point and write to file.
SOLVER_UTILS_EXPORT void SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Initialise the data in the dependent fields.
SOLVER_UTILS_EXPORT void WeakDGAdvection(const Array< OneD, Array< OneD, NekDouble > > &InField, Array< OneD, Array< OneD, NekDouble > > &OutField, bool NumericalFluxIncludesNormal=true, bool InFieldIsInPhysSpace=false, int nvariables=0)
Calculate the weak discontinuous Galerkin advection.
SOLVER_UTILS_EXPORT int GetNumElmVelocity()
SOLVER_UTILS_EXPORT void Checkpoint_BaseFlow(const int n)
Write base flow file of m_fields.
SOLVER_UTILS_EXPORT void ImportFldBase(std::string pInfile, SpatialDomains::MeshGraphSharedPtr pGraph)
virtual SOLVER_UTILS_EXPORT void v_DoSolve()
Virtual function for solve implementation.
int m_NumQuadPointsError
Number of Quadrature points used to work out the error.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
SOLVER_UTILS_EXPORT void DoSolve()
Solve the problem.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
void PrintProgressbar(const int position, const int goal, const string message)
Prints a progressbar.
Definition: Progressbar.hpp:70
SOLVER_UTILS_EXPORT void SetInitialStep(const int step)
virtual SOLVER_UTILS_EXPORT void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
virtual SOLVER_UTILS_EXPORT void v_TransCoeffToPhys()
Virtual function for transformation to physical space.
map< std::string, Array< OneD, Array< OneD, float > > > m_interpWeights
Map of the interpolation weights for a specific filename.
SOLVER_UTILS_EXPORT void SetLambda(NekDouble lambda)
Set parameter m_lambda.
SOLVER_UTILS_EXPORT EquationSystem(const LibUtilities::SessionReaderSharedPtr &pSession)
Initialises EquationSystem class members.
virtual SOLVER_UTILS_EXPORT void v_NumericalFlux(Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &numflux)
enum HomogeneousType m_HomogeneousType
SOLVER_UTILS_EXPORT void SetCheckpointNumber(int num)
SOLVER_UTILS_EXPORT int GetCheckpointNumber()
Provides a generic Factory class.
Definition: NekFactory.hpp:116
SOLVER_UTILS_EXPORT void ImportFld(const std::string &infile, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Input field data from the given file.