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 std::string & s1, const std::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  std::map<std::string, Array<OneD, Array<OneD, float> > > m_interpWeights;
457  /// Map of the interpolation indices for a specific filename.
458  std::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 
553  /// Initialises EquationSystem class members.
555 
556  // Here for consistency purposes with old version
557  int nocase_cmp(const std::string & s1, const std::string& s2)
558  {
559  return NoCaseStringCompare(s1,s2);
560  }
561 
562  SOLVER_UTILS_EXPORT virtual void v_InitObject();
563 
564  /// Virtual function for initialisation implementation.
565  SOLVER_UTILS_EXPORT virtual void v_DoInitialise();
566 
567  /// Virtual function for solve implementation.
568  SOLVER_UTILS_EXPORT virtual void v_DoSolve();
569 
570 
571  /// Virtual function for the L_inf error computation between fields and a given exact solution.
573  unsigned int field,
574  const Array<OneD, NekDouble> &exactsoln = NullNekDouble1DArray);
575 
576  /// Virtual function for the L_2 error computation between fields and a given exact solution.
578  unsigned int field,
579  const Array<OneD, NekDouble> &exactsoln = NullNekDouble1DArray,
580  bool Normalised = false);
581 
582  /// Virtual function for transformation to physical space.
584 
585  /// Virtual function for transformation to coefficient space.
587 
588  /// Virtual function for generating summary information.
590 
592  NekDouble initialtime = 0.0,
593  bool dumpInitialConditions = true,
594  const int domain = 0);
595 
597  unsigned int field,
598  Array<OneD, NekDouble> &outfield,
599  const NekDouble time);
600 
601  //Initialise m_base in order to store the base flow from a file
603 
604  // Fill m_base with the values stored in a fld file
606  std::string pInfile,
608 
609  // Ouptut field information
610  SOLVER_UTILS_EXPORT virtual void v_Output(void);
611 
612  // Get pressure field if available
614 
616  std::vector<Array<OneD, NekDouble> > &fieldcoeffs,
617  std::vector<std::string> &variables);
618 
619  private:
620 
623  const int i, Array<OneD,
624  Array<OneD, NekDouble> >&physfield,
625  Array<OneD, Array<OneD, NekDouble> >&flux);
626 
628  const int i, const int j,
629  Array<OneD, Array<OneD, NekDouble> >&physfield,
630  Array<OneD, Array<OneD, NekDouble> >&flux);
631 
633  const int i, Array<OneD,
634  Array<OneD, NekDouble> >&physfield,
635  Array<OneD, Array<OneD, NekDouble> >&fluxX,
636  Array<OneD, Array<OneD, NekDouble> > &fluxY);
637 
639  Array<OneD, Array<OneD, NekDouble> > &physfield,
640  Array<OneD, Array<OneD, NekDouble> > &numflux);
641 
643  Array<OneD, Array<OneD, NekDouble> > &physfield,
644  Array<OneD, Array<OneD, NekDouble> > &numfluxX,
645  Array<OneD, Array<OneD, NekDouble> > &numfluxY);
646 
648  const Array<OneD, Array<OneD, NekDouble> > &ufield,
649  Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &uflux);
650 
652  const Array<OneD, Array<OneD, NekDouble> > &ufield,
653  Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &qfield,
654  Array<OneD, Array<OneD, NekDouble > > &qflux);
655 
656  SOLVER_UTILS_EXPORT void PrintProgressbar(const int position,
657  const int goal) const
658  {
659  LibUtilities::PrintProgressbar(position, goal, "Interpolating");
660  }
661  };
662 
663 
664  /**
665  * This is the second part of the two-phase initialisation process.
666  * Calls to virtual functions will correctly resolve to the derived class
667  * during this phase of the construction.
668  */
670  {
671  v_InitObject();
672  }
673 
674 
675  /**
676  * This allows initialisation of the solver which cannot be completed
677  * during object construction (such as setting of initial conditions).
678  *
679  * Public interface routine to virtual function implementation.
680  */
682  {
683  v_DoInitialise();
684  }
685 
686 
687  /**
688  * Performs the transformation from coefficient to physical space.
689  *
690  * Public interface routine to virtual function implementation.
691  */
693  {
695  }
696 
697  /**
698  * Performs the transformation from physical to coefficient space.
699  *
700  * Public interface routine to virtual function implementation.
701  */
703  {
705  }
706 
707 
708  /**
709  * Performs the actual solve.
710  *
711  * Public interface routine to virtual function implementation.
712  */
713  inline void EquationSystem::DoSolve(void)
714  {
715  v_DoSolve();
716  }
717 
718 
719  /**
720  * Perform output operations after solve.
721  */
722  inline void EquationSystem::Output(void)
723  {
724  v_Output();
725  }
726 
727  /**
728  * L_inf Error computation
729  * Public interface routine to virtual function implementation.
730  */
731  inline NekDouble EquationSystem::LinfError(unsigned int field, const Array<OneD,NekDouble> &exactsoln)
732  {
733  return v_LinfError(field, exactsoln);
734  }
735 
736  /**
737  * L_2 Error computation
738  * Public interface routine to virtual function implementation.
739  */
740  inline NekDouble EquationSystem::L2Error(unsigned int field, const Array<OneD,NekDouble> &exactsoln, bool Normalised)
741  {
742  return v_L2Error(field, exactsoln, Normalised);
743  }
744 
745  /**
746  * Get Pressure field if available
747  */
749  {
750  return v_GetPressure();
751  }
752 
753  /**
754  * Prints a summary of variables and problem parameters.
755  *
756  * Public interface routine to virtual function implementation.
757  *
758  * @param out The ostream object to write to.
759  */
760  inline void EquationSystem::PrintSummary(std::ostream &out)
761  {
762  if (m_session->GetComm()->GetRank() == 0)
763  {
764  std::vector<std::pair<std::string, std::string> > vSummary;
765  v_GenerateSummary(vSummary);
766 
767  out << "=======================================================================" << std::endl;
768  SummaryList::const_iterator x;
769  for (x = vSummary.begin(); x != vSummary.end(); ++x)
770  {
771  out << "\t";
772  out.width(20);
773  out << x->first << ": " << x->second << std::endl;
774  }
775  out << "=======================================================================" << std::endl;
776  }
777  }
778 
780  {
781  m_lambda = lambda;
782  }
783 
785  bool dumpInitialConditions,
786  const int domain)
787  {
788  v_SetInitialConditions(initialtime,dumpInitialConditions,domain);
789  }
790 
791  /// Evaluates an exact solution
793  Array<OneD, NekDouble> &outfield,
794  const NekDouble time)
795  {
796  v_EvaluateExactSolution(field, outfield, time);
797  }
798 
800  {
801  return m_fields;
802  }
803 
804  /// Return final time
806  {
807  return m_time;
808  }
809 
810  inline int EquationSystem::GetNcoeffs(void)
811  {
812  return m_fields[0]->GetNcoeffs();
813  }
814 
815  inline int EquationSystem::GetNcoeffs(const int eid)
816  {
817  return m_fields[0]->GetNcoeffs(eid);
818  }
819 
821  {
822  return m_graph->GetExpansions().begin()->second->m_basisKeyVector[0]
823  .GetNumModes();
824  }
825 
827  {
828  return m_fields[0]->EvalBasisNumModesMaxPerExp();
829  }
830 
832  {
833  return m_session->GetVariables().size();
834  }
835 
836  inline const std::string EquationSystem::GetVariable(unsigned int i)
837  {
838  return m_session->GetVariable(i);
839  }
840 
842  {
843  return GetTraceNpoints();
844  }
845 
847  {
848  return m_fields[0]->GetTrace()->GetNpoints();
849  }
850 
851  inline int EquationSystem::GetExpSize(void)
852  {
853  return m_fields[0]->GetExpSize();
854  }
855 
857  {
858  return m_fields[0]->GetPhys_Offset(n);
859  }
860 
862  {
863  return m_fields[0]->GetCoeff_Offset(n);
864  }
865 
867  {
868  return m_fields[0]->GetNpoints();
869  }
870 
872  {
873  return m_fields[0]->GetTotPoints(n);
874  }
875 
876  inline int EquationSystem::GetNpoints(void)
877  {
878  return m_fields[0]->GetNpoints();
879  }
880 
882  {
883  return (m_fields.num_elements() - 1);
884  }
885 
886  inline int EquationSystem::GetSteps(void)
887  {
888  return m_steps;
889  }
890 
892  {
893  return m_timestep;
894  }
895 
896  inline void EquationSystem::SetSteps(const int steps)
897  {
898  m_steps = steps;
899  }
900 
901  inline void EquationSystem::CopyFromPhysField(const int i,
902  Array<OneD, NekDouble> &output)
903  {
904  Vmath::Vcopy(output.num_elements(), m_fields[i]->GetPhys(), 1, output, 1 );
905  }
906 
907  inline void EquationSystem::CopyToPhysField(const int i,
908  Array<OneD, NekDouble> &output)
909  {
910  Vmath::Vcopy(output.num_elements(), output, 1, m_fields[i]->UpdatePhys(), 1 );
911  }
912 
913  inline void EquationSystem::GetFluxVector(const int i,
914  Array<OneD, Array<OneD, NekDouble> >&physfield,
916  {
917  v_GetFluxVector(i,physfield, flux);
918  }
919 
920  inline void EquationSystem::GetFluxVector(const int i,
921  Array<OneD, Array<OneD, NekDouble> >&physfield,
924  {
925  v_GetFluxVector(i,physfield, fluxX, fluxY);
926  }
927 
928  inline void EquationSystem::GetFluxVector(const int i, const int j,
929  Array<OneD, Array<OneD, NekDouble> > &physfield,
931  {
932  v_GetFluxVector(i,j,physfield,flux);
933  }
934 
936  Array<OneD, Array<OneD, NekDouble> > &numflux)
937  {
938  v_NumericalFlux(physfield, numflux);
939  }
940 
942  Array<OneD, Array<OneD, NekDouble> > &numfluxX,
943  Array<OneD, Array<OneD, NekDouble> > &numfluxY)
944  {
945  v_NumericalFlux(physfield, numfluxX, numfluxY);
946  }
947 
949  const Array<OneD, Array<OneD, NekDouble> > &ufield,
951  {
952  v_NumFluxforScalar(ufield, uflux);
953  }
954 
956  const Array<OneD, Array<OneD, NekDouble> > &ufield,
959  {
960  v_NumFluxforVector(ufield, qfield, qflux);
961  }
962  }
963 }
964 
965 #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.
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 int NoCaseStringCompare(const std::string &s1, const std::string &s2)
Perform a case-insensitive string comparison.
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.
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.
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)
std::map< std::string, Array< OneD, Array< OneD, float > > > m_interpWeights
Map of the interpolation weights for a specific filename.
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.
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 nocase_cmp(const std::string &s1, const std::string &s2)
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.
std::map< std::string, Array< OneD, Array< OneD, unsigned int > > > m_interpInds
Map of the interpolation indices for a specific filename.
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:218
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:69
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.
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.