Nektar++
Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Attributes | Friends | List of all members
Nektar::SolverUtils::DriverAdaptive Class Reference

Base class for the adaptive polynomial order driver. More...

#include <DriverAdaptive.h>

Inheritance diagram for Nektar::SolverUtils::DriverAdaptive:
[legend]

Static Public Member Functions

static DriverSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
 Creates an instance of this class. More...
 

Static Public Attributes

static std::string className
 Name of the class. More...
 

Protected Member Functions

SOLVER_UTILS_EXPORT DriverAdaptive (const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
 Constructor. More...
 
virtual SOLVER_UTILS_EXPORT ~DriverAdaptive ()
 Destructor. More...
 
virtual SOLVER_UTILS_EXPORT void v_InitObject (std::ostream &out=std::cout)
 Second-stage initialisation. More...
 
virtual SOLVER_UTILS_EXPORT void v_Execute (std::ostream &out=std::cout)
 Virtual function for solve implementation. More...
 
SOLVER_UTILS_EXPORT void ReplaceExpansion (Array< OneD, MultiRegions::ExpListSharedPtr > &fields, std::map< int, int > deltaP)
 Update EXPANSIONS tag inside XML schema to reflect new polynomial order distribution. More...
 
- Protected Member Functions inherited from Nektar::SolverUtils::Driver
 Driver (const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
 Initialises EquationSystem class members. More...
 
virtual SOLVER_UTILS_EXPORT Array< OneD, NekDoublev_GetRealEvl (void)
 
virtual SOLVER_UTILS_EXPORT Array< OneD, NekDoublev_GetImagEvl (void)
 

Static Protected Attributes

static std::string driverLookupId
 
- Static Protected Attributes inherited from Nektar::SolverUtils::Driver
static std::string evolutionOperatorLookupIds []
 
static std::string evolutionOperatorDef
 
static std::string driverDefault
 

Friends

class MemoryManager< DriverAdaptive >
 

Additional Inherited Members

- Public Member Functions inherited from Nektar::SolverUtils::Driver
virtual ~Driver ()
 Destructor. More...
 
SOLVER_UTILS_EXPORT void InitObject (std::ostream &out=std::cout)
 Initialise Object. More...
 
SOLVER_UTILS_EXPORT void Execute (std::ostream &out=std::cout)
 Execute driver. More...
 
SOLVER_UTILS_EXPORT Array< OneD, EquationSystemSharedPtrGetEqu ()
 
SOLVER_UTILS_EXPORT Array< OneD, NekDoubleGetRealEvl (void)
 
SOLVER_UTILS_EXPORT Array< OneD, NekDoubleGetImagEvl (void)
 
- Protected Attributes inherited from Nektar::SolverUtils::Driver
LibUtilities::CommSharedPtr m_comm
 Communication object. More...
 
LibUtilities::SessionReaderSharedPtr m_session
 Session reader object. More...
 
LibUtilities::SessionReaderSharedPtr session_LinNS
 I the Coupling between SFD and arnoldi. More...
 
SpatialDomains::MeshGraphSharedPtr m_graph
 MeshGraph object. More...
 
Array< OneD, EquationSystemSharedPtrm_equ
 Equation system to solve. More...
 
int m_nequ
 number of equations More...
 
enum EvolutionOperatorType m_EvolutionOperator
 Evolution Operator. More...
 

Detailed Description

Base class for the adaptive polynomial order driver.

Definition at line 47 of file DriverAdaptive.h.

Constructor & Destructor Documentation

◆ DriverAdaptive()

Nektar::SolverUtils::DriverAdaptive::DriverAdaptive ( const LibUtilities::SessionReaderSharedPtr  pSession,
const SpatialDomains::MeshGraphSharedPtr  pGraph 
)
protected

Constructor.

Definition at line 62 of file DriverAdaptive.cpp.

65  : Driver(pSession, pGraph)
66 {
67 }
Driver(const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
Initialises EquationSystem class members.
Definition: Driver.cpp:73

◆ ~DriverAdaptive()

Nektar::SolverUtils::DriverAdaptive::~DriverAdaptive ( )
protectedvirtual

Destructor.

Definition at line 72 of file DriverAdaptive.cpp.

73 {
74 }

Member Function Documentation

◆ create()

static DriverSharedPtr Nektar::SolverUtils::DriverAdaptive::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const SpatialDomains::MeshGraphSharedPtr pGraph 
)
inlinestatic

Creates an instance of this class.

Definition at line 53 of file DriverAdaptive.h.

56  {
59  p->InitObject();
60  return p;
61  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
Definition: Driver.h:51

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and CellMLToNektar.cellml_metadata::p.

◆ ReplaceExpansion()

void Nektar::SolverUtils::DriverAdaptive::ReplaceExpansion ( Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
std::map< int, int >  deltaP 
)
protected

Update EXPANSIONS tag inside XML schema to reflect new polynomial order distribution.

Parameters
fieldsInput fields.
deltaPMap of polynomial order expansions

Definition at line 445 of file DriverAdaptive.cpp.

447 {
448  int nExp, nDim;
449  int expdim = m_equ[0]->UpdateFields()[0]->GetGraph()->GetMeshDimension();
450 
451  // Get field definitions
452  std::vector<LibUtilities::FieldDefinitionsSharedPtr> fielddefs =
453  fields[0]->GetFieldDefinitions();
454 
455  if (fielddefs[0]->m_numHomogeneousDir == 1)
456  {
457  nDim = expdim + 1;
458  }
459  else
460  {
461  nDim = expdim;
462  }
463 
464  // Add variables to field definition
465  for (int i = 0; i < fielddefs.size(); ++i)
466  {
467  for (int j = 0; j < fields.size(); ++j)
468  {
469  fielddefs[i]->m_fields.push_back(m_session->GetVariable(j));
470  }
471  }
472 
473  // Get tinyxml objects
474  TiXmlElement *exp_tag = m_session->GetElement("NEKTAR/EXPANSIONS");
475 
476  // Clear current expansions
477  exp_tag->Clear();
478 
479  // Write new expansion information
480  for (int f = 0; f < fielddefs.size(); ++f)
481  {
482  nExp = fielddefs[f]->m_elementIDs.size();
483 
484  //---------------------------------------------
485  // Write ELEMENTS
486  TiXmlElement *elemTag = new TiXmlElement("ELEMENTS");
487  exp_tag->LinkEndChild(elemTag);
488 
489  // Write FIELDS
490  std::string fieldsString;
491  {
492  std::stringstream fieldsStringStream;
493  bool first = true;
494  for (std::vector<int>::size_type i = 0;
495  i < fielddefs[f]->m_fields.size(); i++)
496  {
497  if (!first)
498  {
499  fieldsStringStream << ",";
500  }
501  fieldsStringStream << fielddefs[f]->m_fields[i];
502  first = false;
503  }
504  fieldsString = fieldsStringStream.str();
505  }
506  elemTag->SetAttribute("FIELDS", fieldsString);
507 
508  // Write SHAPE
509  std::string shapeString;
510  {
511  std::stringstream shapeStringStream;
512  shapeStringStream
513  << LibUtilities::ShapeTypeMap[fielddefs[f]->m_shapeType];
514  if (fielddefs[f]->m_numHomogeneousDir == 1)
515  {
516  shapeStringStream << "-HomogenousExp1D";
517  }
518  else if (fielddefs[f]->m_numHomogeneousDir == 2)
519  {
520  shapeStringStream << "-HomogenousExp2D";
521  }
522 
523  shapeString = shapeStringStream.str();
524  }
525  elemTag->SetAttribute("SHAPE", shapeString);
526 
527  // Write BASIS
528  std::string basisString;
529  {
530  std::stringstream basisStringStream;
531  bool first = true;
532  for (std::vector<LibUtilities::BasisType>::size_type i = 0;
533  i < fielddefs[f]->m_basis.size(); i++)
534  {
535  if (!first)
536  {
537  basisStringStream << ",";
538  }
539  basisStringStream
540  << LibUtilities::BasisTypeMap[fielddefs[f]->m_basis[i]];
541  first = false;
542  }
543  basisString = basisStringStream.str();
544  }
545  elemTag->SetAttribute("BASIS", basisString);
546 
547  // Write homogeneuous length details
548  if (fielddefs[f]->m_numHomogeneousDir)
549  {
550  std::string homoLenString;
551  {
552  std::stringstream homoLenStringStream;
553  bool first = true;
554  for (int i = 0; i < fielddefs[f]->m_numHomogeneousDir; ++i)
555  {
556  if (!first)
557  {
558  homoLenStringStream << ",";
559  }
560  homoLenStringStream
561  << fielddefs[f]->m_homogeneousLengths[i];
562  first = false;
563  }
564  homoLenString = homoLenStringStream.str();
565  }
566  elemTag->SetAttribute("HOMOGENEOUSLENGTHS", homoLenString);
567  }
568 
569  // Write homogeneuous planes/lines details
570  if (fielddefs[f]->m_numHomogeneousDir)
571  {
572  if (fielddefs[f]->m_homogeneousYIDs.size() > 0)
573  {
574  std::string homoYIDsString;
575  {
576  std::stringstream homoYIDsStringStream;
577  bool first = true;
578  for (int i = 0; i < fielddefs[f]->m_homogeneousYIDs.size();
579  i++)
580  {
581  if (!first)
582  {
583  homoYIDsStringStream << ",";
584  }
585  homoYIDsStringStream
586  << fielddefs[f]->m_homogeneousYIDs[i];
587  first = false;
588  }
589  homoYIDsString = homoYIDsStringStream.str();
590  }
591  elemTag->SetAttribute("HOMOGENEOUSYIDS", homoYIDsString);
592  }
593 
594  if (fielddefs[f]->m_homogeneousZIDs.size() > 0)
595  {
596  std::string homoZIDsString;
597  {
598  std::stringstream homoZIDsStringStream;
599  bool first = true;
600  for (int i = 0; i < fielddefs[f]->m_homogeneousZIDs.size();
601  i++)
602  {
603  if (!first)
604  {
605  homoZIDsStringStream << ",";
606  }
607  homoZIDsStringStream
608  << fielddefs[f]->m_homogeneousZIDs[i];
609  first = false;
610  }
611  homoZIDsString = homoZIDsStringStream.str();
612  }
613  elemTag->SetAttribute("HOMOGENEOUSZIDS", homoZIDsString);
614  }
615  }
616 
617  // Write NUMMODESPERDIR
618  std::string numModesString;
619  {
620  std::stringstream numModesStringStream;
621 
622  numModesStringStream << "MIXORDER:";
623  bool first = true;
624  int eId;
625  Array<OneD, int> order(nDim, 0);
626  for (int n = 0; n < nExp; n++)
627  {
628  eId = fielddefs[f]->m_elementIDs[n];
629 
630  for (int i = 0; i < expdim; i++)
631  {
632  order[i] = deltaP[eId];
633  }
634 
635  for (int i = 0; i < nDim; i++)
636  {
637  if (fielddefs[f]->m_uniOrder)
638  {
639  order[i] += fielddefs[f]->m_numModes[i];
640  }
641  else
642  {
643  order[i] += fielddefs[f]->m_numModes[n * nDim + i];
644  }
645 
646  if (!first)
647  {
648  numModesStringStream << ",";
649  }
650 
651  numModesStringStream << order[i];
652  first = false;
653  }
654  }
655  numModesString = numModesStringStream.str();
656  }
657  elemTag->SetAttribute("NUMMODESPERDIR", numModesString);
658 
659  // Write IDs. Should ideally look at ways of compressing this stream if
660  // just sequential.
661  elemTag->SetAttribute(
662  "ID", ParseUtils::GenerateSeqString(fielddefs[f]->m_elementIDs));
663  }
664 }
static std::string GenerateSeqString(const std::vector< T > &v)
Generate a compressed comma-separated string representation of a vector of unsigned integers.
Definition: ParseUtils.h:71
LibUtilities::SessionReaderSharedPtr m_session
Session reader object.
Definition: Driver.h:88
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:97
const char *const ShapeTypeMap[SIZE_ShapeType]
Definition: ShapeType.hpp:77
const char *const BasisTypeMap[]
Definition: Foundations.hpp:46

References Nektar::LibUtilities::BasisTypeMap, Nektar::ParseUtils::GenerateSeqString(), Nektar::SolverUtils::Driver::m_equ, Nektar::SolverUtils::Driver::m_session, and Nektar::LibUtilities::ShapeTypeMap.

Referenced by v_Execute().

◆ v_Execute()

void Nektar::SolverUtils::DriverAdaptive::v_Execute ( std::ostream &  out = std::cout)
protectedvirtual

Virtual function for solve implementation.

Implements Nektar::SolverUtils::Driver.

Definition at line 84 of file DriverAdaptive.cpp.

85 {
86  time_t starttime, endtime;
87  NekDouble CPUtime;
88 
89  m_equ[0]->PrintSummary(out);
90 
91  // First run using original order
92  time(&starttime);
93  m_equ[0]->DoInitialise();
94 
95  // Obtain initial time in case a restart was used
96  NekDouble startTime = m_equ[0]->GetFinalTime();
97  m_equ[0]->DoSolve();
98 
99  // Load session parameters and solver info
100  bool isHomogeneous1D;
101  int nRuns, minP, maxP, sensorVar;
102  NekDouble lowerTol, upperTol;
103  m_session->LoadParameter("NumRuns", nRuns, 1);
104  m_session->LoadParameter("AdaptiveMinModes", minP, 4);
105  m_session->LoadParameter("AdaptiveMaxModes", maxP, 12);
106  m_session->LoadParameter("AdaptiveLowerTolerance", lowerTol, 1e-8);
107  m_session->LoadParameter("AdaptiveUpperTolerance", upperTol, 1e-6);
108  m_session->LoadParameter("AdaptiveSensorVariable", sensorVar, 0);
109  m_session->MatchSolverInfo("Homogeneous", "1D", isHomogeneous1D, false);
110 
111  // Get number of elements and planes
112  int nExp, nPlanes;
113  if (isHomogeneous1D)
114  {
115  nExp = m_equ[0]->UpdateFields()[0]->GetPlane(0)->GetExpSize();
116  nPlanes = m_equ[0]->UpdateFields()[0]->GetZIDs().size();
117  }
118  else
119  {
120  nExp = m_equ[0]->UpdateFields()[0]->GetExpSize();
121  nPlanes = 1;
122  }
123  int expdim = m_equ[0]->UpdateFields()[0]->GetGraph()->GetMeshDimension();
124 
125  int nFields = m_equ[0]->UpdateFields().size();
126  int numSteps = m_session->GetParameter("NumSteps");
127  NekDouble period = m_session->GetParameter("TimeStep") * numSteps;
128 
129  Array<OneD, NekDouble> coeffs, phys, physReduced, tmpArray;
130 
131  // Get mapping
133  mapping = GlobalMapping::Mapping::Load(m_session, m_equ[0]->UpdateFields());
134 
135  // Adaptive loop
136  Array<OneD, int> P(expdim);
137  Array<OneD, int> numPoints(expdim);
138  Array<OneD, LibUtilities::PointsKey> ptsKey(expdim);
140  for (int i = 1; i < nRuns; i++)
141  {
142  // Get field expansions
143  Array<OneD, MultiRegions::ExpListSharedPtr> fields =
144  m_equ[0]->UpdateFields();
145 
146  // Determine the change to be applied in the order
147  map<int, int> deltaP;
148  int offset = 0;
149  for (int n = 0; n < nExp; n++)
150  {
151  offset = fields[sensorVar]->GetPhys_Offset(n);
152  Exp = fields[sensorVar]->GetExp(n);
153 
154  for (int k = 0; k < expdim; ++k)
155  {
156  P[k] = Exp->GetBasis(k)->GetNumModes();
157  numPoints[k] = Exp->GetBasis(k)->GetNumPoints();
158  ptsKey[k] = LibUtilities::PointsKey(
159  numPoints[k], Exp->GetBasis(k)->GetPointsType());
160  }
161 
162  // Declare orthogonal basis.
164  switch (Exp->GetGeom()->GetShapeType())
165  {
167  {
168  LibUtilities::BasisKey Ba(LibUtilities::eOrtho_A, P[0] - 1,
169  ptsKey[0]);
170  LibUtilities::BasisKey Bb(LibUtilities::eOrtho_A, P[1] - 1,
171  ptsKey[1]);
172  OrthoExp = MemoryManager<
173  StdRegions::StdQuadExp>::AllocateSharedPtr(Ba, Bb);
174  break;
175  }
177  {
178  LibUtilities::BasisKey Ba(LibUtilities::eOrtho_A, P[0] - 1,
179  ptsKey[0]);
180  LibUtilities::BasisKey Bb(LibUtilities::eOrtho_B, P[1] - 1,
181  ptsKey[1]);
182  OrthoExp =
184  Ba, Bb);
185  break;
186  }
188  {
189  LibUtilities::BasisKey Ba(LibUtilities::eOrtho_A, P[0] - 1,
190  ptsKey[0]);
191  LibUtilities::BasisKey Bb(LibUtilities::eOrtho_B, P[1] - 1,
192  ptsKey[1]);
193  LibUtilities::BasisKey Bc(LibUtilities::eOrtho_C, P[2] - 1,
194  ptsKey[2]);
195  OrthoExp =
197  Ba, Bb, Bc);
198  break;
199  }
201  {
202  LibUtilities::BasisKey Ba(LibUtilities::eOrtho_A, P[0] - 1,
203  ptsKey[0]);
204  LibUtilities::BasisKey Bb(LibUtilities::eOrtho_A, P[1] - 1,
205  ptsKey[1]);
206  LibUtilities::BasisKey Bc(LibUtilities::eOrtho_C, P[2] - 1,
207  ptsKey[2]);
208  OrthoExp =
210  Ba, Bb, Bc);
211  break;
212  }
214  {
215  LibUtilities::BasisKey Ba(LibUtilities::eOrtho_A, P[0] - 1,
216  ptsKey[0]);
217  LibUtilities::BasisKey Bb(LibUtilities::eOrtho_A, P[1] - 1,
218  ptsKey[1]);
219  LibUtilities::BasisKey Bc(LibUtilities::eOrtho_B, P[2] - 1,
220  ptsKey[2]);
221  OrthoExp = MemoryManager<
222  StdRegions::StdPrismExp>::AllocateSharedPtr(Ba, Bb, Bc);
223  break;
224  }
226  {
227  LibUtilities::BasisKey Ba(LibUtilities::eOrtho_A, P[0] - 1,
228  ptsKey[0]);
229  LibUtilities::BasisKey Bb(LibUtilities::eOrtho_A, P[1] - 1,
230  ptsKey[1]);
231  LibUtilities::BasisKey Bc(LibUtilities::eOrtho_A, P[2] - 1,
232  ptsKey[2]);
233  OrthoExp =
235  Ba, Bb, Bc);
236  break;
237  }
238  default:
239  ASSERTL0(false, "Shape not supported.");
240  break;
241  }
242 
243  int nq = OrthoExp->GetTotPoints();
244 
245  NekDouble error = 0;
246  NekDouble fac = 0;
247  NekDouble tmp = 0;
248 
249  coeffs = Array<OneD, NekDouble>(OrthoExp->GetNcoeffs());
250  physReduced = Array<OneD, NekDouble>(OrthoExp->GetTotPoints());
251  tmpArray = Array<OneD, NekDouble>(OrthoExp->GetTotPoints(), 0.0);
252 
253  // Refinement based only on one variable
254  for (int plane = 0; plane < nPlanes; plane++)
255  {
256  if (isHomogeneous1D)
257  {
258  phys =
259  fields[sensorVar]->GetPlane(plane)->GetPhys() + offset;
260  }
261  else
262  {
263  phys = fields[sensorVar]->GetPhys() + offset;
264  }
265 
266  // Project solution to lower order
267  OrthoExp->FwdTrans(phys, coeffs);
268  OrthoExp->BwdTrans(coeffs, physReduced);
269 
270  // Calculate error =||phys-physReduced||^2 / ||phys||^2
271  Vmath::Vsub(nq, phys, 1, physReduced, 1, tmpArray, 1);
272  Vmath::Vmul(nq, tmpArray, 1, tmpArray, 1, tmpArray, 1);
273  tmp = Exp->Integral(tmpArray);
274 
275  Vmath::Vmul(nq, phys, 1, phys, 1, tmpArray, 1);
276  fac = Exp->Integral(tmpArray);
277 
278  tmp = abs(tmp / fac);
279 
280  if (tmp != tmp)
281  {
282  ASSERTL0(false,
283  "Adaptive procedure encountered NaN value.");
284  }
285 
286  // Get maximum value along planes
287  error = (tmp > error) ? tmp : error;
288  }
289 
290  // Combine planes from different processes
291  m_session->GetComm()->GetColumnComm()->AllReduce(
292  error, LibUtilities::ReduceMax);
293 
294  // Override tolerances if function is defined
295  if (m_session->DefinesFunction("AdaptiveLowerTolerance"))
296  {
297  int nq = Exp->GetTotPoints();
298 
299  // Obtain points from the the element
300  Array<OneD, NekDouble> xc0, xc1, xc2;
301  xc0 = Array<OneD, NekDouble>(nq, 0.0);
302  xc1 = Array<OneD, NekDouble>(nq, 0.0);
303  xc2 = Array<OneD, NekDouble>(nq, 0.0);
304  Exp->GetCoords(xc0, xc1, xc2);
305 
306  // Evaluate function from session file
307  Array<OneD, NekDouble> tolerance(nq, 0.0);
309  m_session->GetFunction("AdaptiveLowerTolerance", 0);
310  ffunc->Evaluate(xc0, xc1, xc2, tolerance);
311  lowerTol = Vmath::Vsum(nq, tolerance, 1) / nq;
312  }
313 
314  if (m_session->DefinesFunction("AdaptiveUpperTolerance"))
315  {
316  int nq = Exp->GetTotPoints();
317 
318  // Obtain points from the the element
319  Array<OneD, NekDouble> xc0, xc1, xc2;
320  xc0 = Array<OneD, NekDouble>(nq, 0.0);
321  xc1 = Array<OneD, NekDouble>(nq, 0.0);
322  xc2 = Array<OneD, NekDouble>(nq, 0.0);
323  Exp->GetCoords(xc0, xc1, xc2);
324 
325  // Evaluate function from session file
326  Array<OneD, NekDouble> tolerance(nq, 0.0);
328  m_session->GetFunction("AdaptiveUpperTolerance", 0);
329  ffunc->Evaluate(xc0, xc1, xc2, tolerance);
330  upperTol = Vmath::Vsum(nq, tolerance, 1) / nq;
331  }
332 
333  // Determine what to do with the polynomial order
334  if ((error > upperTol) && (P[0] < maxP))
335  {
336  deltaP[Exp->GetGeom()->GetGlobalID()] = 1;
337  }
338  else if ((error < lowerTol) && P[0] > minP)
339  {
340  deltaP[Exp->GetGeom()->GetGlobalID()] = -1;
341  }
342  else
343  {
344  deltaP[Exp->GetGeom()->GetGlobalID()] = 0;
345  }
346  }
347 
348  // Write new expansion section to the session reader and re-read graph.
349  ReplaceExpansion(fields, deltaP);
350  m_graph->ReadExpansionInfo();
351 
352  // Reset GlobalLinSys Manager to avoid using too much memory
353  //
354  // @todo This could be made better by replacing individual matrices
355  // within the linear system.
356  if (LibUtilities::NekManager<MultiRegions::GlobalLinSysKey,
357  MultiRegions::GlobalLinSys>::
358  PoolCreated(std::string("GlobalLinSys")))
359  {
360  LibUtilities::NekManager<MultiRegions::GlobalLinSysKey,
361  MultiRegions::GlobalLinSys>::
362  ClearManager(std::string("GlobalLinSys"));
363  }
364 
365  int chkNumber = m_equ[0]->GetCheckpointNumber();
366  int chkSteps = m_equ[0]->GetCheckpointSteps();
367 
368  // Initialise driver again
370 
371  // Update mapping (must be before m_equ[0]->DoInitialise();)
372  mapping->ReplaceField(m_equ[0]->UpdateFields());
373 
374  // Set chkSteps to zero to avoid writing initial condition
375  m_equ[0]->SetCheckpointSteps(0);
376 
377  // Initialise equation
378  m_equ[0]->DoInitialise();
379  m_equ[0]->SetInitialStep(i * numSteps);
380  m_equ[0]->SetSteps(i * numSteps + numSteps);
381  m_equ[0]->SetTime(startTime + i * period);
382  m_equ[0]->SetBoundaryConditions(startTime + i * period);
383  m_equ[0]->SetCheckpointNumber(chkNumber);
384  m_equ[0]->SetCheckpointSteps(chkSteps);
385 
386  // Project solution to new expansion
387  for (int n = 0; n < nFields; n++)
388  {
389  m_equ[0]->UpdateFields()[n]->ExtractCoeffsToCoeffs(
390  fields[n], fields[n]->GetCoeffs(),
391  m_equ[0]->UpdateFields()[n]->UpdateCoeffs());
392  m_equ[0]->UpdateFields()[n]->BwdTrans(
393  m_equ[0]->UpdateFields()[n]->GetCoeffs(),
394  m_equ[0]->UpdateFields()[n]->UpdatePhys());
395  }
396 
397  // Solve equation
398  m_equ[0]->DoSolve();
399  }
400 
401  time(&endtime);
402 
403  m_equ[0]->Output();
404 
405  if (m_comm->GetRank() == 0)
406  {
407  CPUtime = difftime(endtime, starttime);
408  cout << "-------------------------------------------" << endl;
409  cout << "Total Computation Time = " << CPUtime << "s" << endl;
410  cout << "-------------------------------------------" << endl;
411  }
412 
413  // Evaluate and output computation time and solution accuracy.
414  // The specific format of the error output is essential for the
415  // regression tests to work.
416 
417  // Evaluate L2 Error
418  for (int i = 0; i < m_equ[0]->GetNvariables(); ++i)
419  {
420  Array<OneD, NekDouble> exactsoln(m_equ[0]->GetTotPoints(), 0.0);
421 
422  // Evaluate "ExactSolution" function, or zero array
423  m_equ[0]->EvaluateExactSolution(i, exactsoln, m_equ[0]->GetFinalTime());
424 
425  NekDouble vL2Error = m_equ[0]->L2Error(i, exactsoln);
426  NekDouble vLinfError = m_equ[0]->LinfError(i, exactsoln);
427 
428  if (m_comm->GetRank() == 0)
429  {
430  out << "L 2 error (variable " << m_equ[0]->GetVariable(i)
431  << ") : " << vL2Error << endl;
432  out << "L inf error (variable " << m_equ[0]->GetVariable(i)
433  << ") : " << vLinfError << endl;
434  }
435  }
436 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
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:269
SOLVER_UTILS_EXPORT void ReplaceExpansion(Array< OneD, MultiRegions::ExpListSharedPtr > &fields, std::map< int, int > deltaP)
Update EXPANSIONS tag inside XML schema to reflect new polynomial order distribution.
virtual SOLVER_UTILS_EXPORT void v_InitObject(std::ostream &out=std::cout)
Definition: Driver.cpp:87
LibUtilities::CommSharedPtr m_comm
Communication object.
Definition: Driver.h:85
SpatialDomains::MeshGraphSharedPtr m_graph
MeshGraph object.
Definition: Driver.h:94
GLOBAL_MAPPING_EXPORT typedef std::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
Definition: Mapping.h:50
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:130
@ eOrtho_A
Principle Orthogonal Functions .
Definition: BasisType.h:44
@ eOrtho_C
Principle Orthogonal Functions .
Definition: BasisType.h:48
@ eOrtho_B
Principle Orthogonal Functions .
Definition: BasisType.h:46
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition: Expansion.h:68
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
double NekDouble
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:209
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.cpp:895
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:419
scalarT< T > abs(scalarT< T > in)
Definition: scalar.hpp:295

References tinysimd::abs(), Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::eHexahedron, Nektar::LibUtilities::eOrtho_A, Nektar::LibUtilities::eOrtho_B, Nektar::LibUtilities::eOrtho_C, Nektar::LibUtilities::ePrism, Nektar::LibUtilities::ePyramid, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eTetrahedron, Nektar::LibUtilities::eTriangle, Nektar::GlobalMapping::Mapping::Load(), Nektar::SolverUtils::Driver::m_comm, Nektar::SolverUtils::Driver::m_equ, Nektar::SolverUtils::Driver::m_graph, Nektar::SolverUtils::Driver::m_session, Nektar::GlobalMapping::MappingSharedPtr, Nektar::LibUtilities::P, Nektar::LibUtilities::ReduceMax, ReplaceExpansion(), Nektar::SolverUtils::Driver::v_InitObject(), Vmath::Vmul(), Vmath::Vsub(), and Vmath::Vsum().

◆ v_InitObject()

void Nektar::SolverUtils::DriverAdaptive::v_InitObject ( std::ostream &  out = std::cout)
protectedvirtual

Second-stage initialisation.

Reimplemented from Nektar::SolverUtils::Driver.

Definition at line 79 of file DriverAdaptive.cpp.

80 {
82 }

References Nektar::SolverUtils::Driver::v_InitObject().

Friends And Related Function Documentation

◆ MemoryManager< DriverAdaptive >

friend class MemoryManager< DriverAdaptive >
friend

Definition at line 1 of file DriverAdaptive.h.

Member Data Documentation

◆ className

string Nektar::SolverUtils::DriverAdaptive::className
static
Initial value:
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
static DriverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
DriverFactory & GetDriverFactory()
Definition: Driver.cpp:64

Name of the class.

Definition at line 64 of file DriverAdaptive.h.

◆ driverLookupId

string Nektar::SolverUtils::DriverAdaptive::driverLookupId
staticprotected
Initial value:
=
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.

Definition at line 86 of file DriverAdaptive.h.