Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
CFLStep.cpp File Reference
#include <cstdio>
#include <cstdlib>
#include <SolverUtils/Driver.h>
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <IncNavierStokesSolver/EquationSystems/IncNavierStokes.h>
Include dependency graph for CFLStep.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 13 of file CFLStep.cpp.

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Vmath::Fill(), Nektar::SolverUtils::GetDriverFactory(), Vmath::Imax(), and Nektar::SolverUtils::EquationSystem::SetInitialConditions().

14 {
15  if(argc != 2)
16  {
17  fprintf(stderr,"Usage: ./CflStep file.xml \n");
18  fprintf(stderr,"\t Method will read intiial conditions section of .xml file for input \n");
19  exit(1);
20  }
21 
23  string vDriverModule;
24  DriverSharedPtr drv;
25  try
26  {
27  // Create session reader.
28  session = LibUtilities::SessionReader::CreateInstance(argc, argv);
29 
30  // Create driver
31  session->LoadSolverInfo("Driver", vDriverModule, "Standard");
32  drv = GetDriverFactory().CreateInstance(vDriverModule, session);
33 
34 
35  EquationSystemSharedPtr EqSys = drv->GetEqu()[0];
36  IncNavierStokesSharedPtr IncNav = EqSys->as<IncNavierStokes>();
37 
38  IncNav->SetInitialConditions(0.0,false);
39  Array<OneD, NekDouble> cfl = IncNav->GetElmtCFLVals();
40 
41  // Reset Pressure field with CFL values
42  Array<OneD, MultiRegions::ExpListSharedPtr> fields = IncNav->UpdateFields();
43  int i,n,nquad,cnt;
44  int nfields = fields.num_elements();
45  int nexp = fields[0]->GetExpSize();
46 
47  int elmtid = Vmath::Imax(nexp,cfl,1);
48 
49  cout << "Max CFL: "<< cfl[elmtid] << " In element " << elmtid << endl;
50 
51 
52  for(n = 0; n < nfields; ++n)
53  {
54  if(session->GetVariable(n) == "p")
55  {
56  break;
57  }
58  }
59 
60  ASSERTL0(n != nfields, "Could not find field named p in m_fields");
61 
62  Array<OneD, NekDouble> phys = fields[n]->UpdatePhys();
63 
64  cnt = 0;
65  for(i = 0; i < fields[n]->GetExpSize(); ++i)
66  {
67  nquad = fields[n]->GetExp(i)->GetTotPoints();
68  Vmath::Fill(nquad,cfl[i],&phys[cnt],1);
69  cnt += nquad;
70  }
71 
72  fields[n]->FwdTrans_IterPerExp(fields[n]->GetPhys(),fields[n]->UpdateCoeffs());
73 
74  // Need to reset varibale name for output
75  session->SetVariable(n,"CFL");
76 
77  // Reset session name for output file
78  std::string outname = IncNav->GetSessionName();
79 
80  outname += "_CFLStep";
81  IncNav->ResetSessionName(outname);
82  IncNav->Output();
83 
84  }
85  catch (const std::runtime_error&)
86  {
87  return 1;
88  }
89  catch (const std::string& eStr)
90  {
91  cout << "Error: " << eStr << endl;
92  }
93 
94 
95  return 0;
96 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
boost::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
Definition: Driver.h:52
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:162
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:46
boost::shared_ptr< IncNavierStokes > IncNavierStokesSharedPtr
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
int Imax(int n, const T *x, const int incx)
Return the index of the maximum element in x.
Definition: Vmath.cpp:755
boost::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
This class is the base class for Navier Stokes problems.
DriverFactory & GetDriverFactory()
Definition: Driver.cpp:66
SOLVER_UTILS_EXPORT void SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Initialise the data in the dependent fields.