41 using namespace Nektar;
43 int main(
int argc,
char *argv[])
62 string sessionName = session->GetSessionName();
63 string outFile = sessionName +
".fld";
64 unsigned int nSteps = session->GetParameter(
"NumSteps");
65 NekDouble delta_t = session->GetParameter(
"TimeStep");
66 NekDouble epsilon = session->GetParameter(
"epsilon" );
76 unsigned int nq = field->GetNpoints();
77 Array<OneD,NekDouble> x0(nq), x1(nq), x2(nq);
78 field->GetCoords(x0,x1,x2);
81 icond = session->GetFunction(
"InitialConditions",
"u");
82 icond->Evaluate(x0, x1, x2, 0.0, field->UpdatePhys());
88 Vmath::Zero(field->GetNcoeffs(), field->UpdateCoeffs(), 1);
91 for (
unsigned int n = 0; n < nSteps; ++n)
93 Vmath::Smul(nq, -1.0/delta_t/epsilon, field->GetPhys(), 1,
94 field->UpdatePhys(), 1);
96 field->HelmSolve(field->GetPhys(), field->UpdateCoeffs(),
99 field->BwdTrans(field->GetCoeffs(), field->UpdatePhys());
103 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
104 = field->GetFieldDefinitions();
105 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
106 for(
int i = 0; i < FieldDef.size(); ++i)
108 FieldDef[i]->m_fields.push_back(
"u");
109 field->AppendFieldData(FieldDef[i], FieldData[i]);
111 fld->Write(outFile, FieldDef, FieldData);
114 ex_sol = session->GetFunction(
"ExactSolution",0);
118 Array<OneD, NekDouble> exact(nq);
122 ex_sol->Evaluate(x0, x1, x2, (nSteps)*delta_t, exact);
126 cout <<
"L inf error: "
127 << field->Linf(field->GetPhys(), exact) << endl;
128 cout <<
"L 2 error: "
129 << field->L2(field->GetPhys(), exact) << endl;
130 cout <<
"H 1 error: "
131 << field->H1(field->GetPhys(), exact) << endl;
138 catch (
const std::runtime_error& e)
142 catch (
const std::string& eStr)
144 cout <<
"Error: " << eStr << endl;