55 session = LibUtilities::SessionReader::CreateInstance(argc, argv);
58 graph = SpatialDomains::MeshGraph::Read(session);
61 fld = LibUtilities::FieldIO::CreateDefault(session);
64 string sessionName = session->GetSessionName();
65 string outFile = sessionName +
".fld";
66 unsigned int nSteps = session->GetParameter(
"NumSteps");
67 NekDouble delta_t = session->GetParameter(
"TimeStep");
68 NekDouble epsilon = session->GetParameter(
"epsilon" );
75 unsigned int nq = field->GetNpoints();
77 field->GetCoords(x0,x1,x2);
80 icond = session->GetFunction(
"InitialConditions",
"u");
81 icond->Evaluate(x0, x1, x2, 0.0, field->UpdatePhys());
87 Vmath::Zero(field->GetNcoeffs(), field->UpdateCoeffs(), 1);
90 for (
unsigned int n = 0; n < nSteps; ++n)
92 Vmath::Smul(nq, -1.0/delta_t/epsilon, field->GetPhys(), 1,
93 field->UpdatePhys(), 1);
95 field->HelmSolve(field->GetPhys(), field->UpdateCoeffs(),
98 field->BwdTrans(field->GetCoeffs(), field->UpdatePhys());
102 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
103 = field->GetFieldDefinitions();
104 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
105 for(
int i = 0; i < FieldDef.size(); ++i)
107 FieldDef[i]->m_fields.push_back(
"u");
108 field->AppendFieldData(FieldDef[i], FieldData[i]);
110 fld->Write(outFile, FieldDef, FieldData);
113 ex_sol = session->GetFunction(
"ExactSolution",0);
121 ex_sol->Evaluate(x0, x1, x2, (nSteps)*delta_t, exact);
125 cout <<
"L inf error: " 126 << field->Linf(field->GetPhys(), exact) << endl;
127 cout <<
"L 2 error: " 128 << field->L2(field->GetPhys(), exact) << endl;
129 cout <<
"H 1 error: " 130 << field->H1(field->GetPhys(), exact) << endl;
137 catch (
const std::runtime_error& e)
141 catch (
const std::string& eStr)
143 cout <<
"Error: " << eStr << endl;
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< ContField2D > ContField2DSharedPtr
std::map< ConstFactorType, NekDouble > ConstFactorMap
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
std::shared_ptr< Equation > EquationSharedPtr
void Zero(int n, T *x, const int incx)
Zero vector.
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static FlagList NullFlagList
An empty flag list.