49int main(
int argc,
char *argv[])
53 fprintf(stderr,
"Usage: ./NonLinearEnergy file.xml \n");
54 fprintf(stderr,
"\t Method will read intiial conditions section of "
55 ".xml file for input \n");
66 session = LibUtilities::SessionReader::CreateInstance(argc, argv);
69 graph = SpatialDomains::MeshGraphIO::Read(session);
72 session->LoadSolverInfo(
"Driver", vDriverModule,
"Standard");
80 IncNav->UpdateFields();
83 int nConvectiveFields = IncNav->GetNConvectiveFields();
84 int nphys = fields[0]->GetTotPoints();
88 for (i = 0; i < nConvectiveFields; ++i)
90 VelFields[i] = fields[i]->UpdatePhys();
94 std::shared_ptr<NavierStokesAdvection>
A =
95 std::dynamic_pointer_cast<NavierStokesAdvection>(
96 IncNav->GetAdvObject());
100 cout <<
"Must use non-linear Navier-Stokes advection" << endl;
105 A->Advect(nConvectiveFields, fields, VelFields, VelFields, NonLinear,
109 for (i = 0; i < nConvectiveFields; ++i)
111 fields[i]->FwdTransLocalElmt(NonLinear[i],
112 fields[i]->UpdateCoeffs());
115 for (
int n = 0; n < fields[i]->GetExpSize(); ++n)
117 int offset = fields[i]->GetCoeff_Offset(n);
118 int ncoeffs = fields[i]->GetExp(n)->GetNcoeffs();
121 fields[i]->GetExp(n)->ReduceOrderCoeffs(
122 fields[i]->GetExp(n)->GetBasisNumModes(0) - 1,
123 fields[i]->GetCoeffs() + offset, coeffsred);
125 Vmath::Vsub(ncoeffs, fields[i]->GetCoeffs() + offset, 1,
127 tmp = fields[i]->UpdateCoeffs() + offset, 1);
131 string name =
"NL_TopMode_" + session->GetVariable(i);
132 session->SetVariable(i,
name.c_str());
136 std::string outname = IncNav->GetSessionName();
138 outname +=
"_NonLinear_Energy";
139 IncNav->ResetSessionName(outname);
142 catch (
const std::runtime_error &)
146 catch (
const std::string &eStr)
148 cout <<
"Error: " << eStr << endl;
int main(int argc, char *argv[])
This class is the base class for Navier Stokes problems.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
SOLVER_UTILS_EXPORT void SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Initialise the data in the dependent fields.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
DriverFactory & GetDriverFactory()
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< IncNavierStokes > IncNavierStokesSharedPtr
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.