41 using namespace Nektar;
43 int main(
int argc,
char *argv[])
62 string fileName = session->GetFilename();
63 string sessionName = session->GetSessionName();
64 string outFile = sessionName +
".fld";
65 unsigned int nSteps = session->GetParameter(
"NumSteps");
66 NekDouble delta_t = session->GetParameter(
"TimeStep");
67 NekDouble epsilon = session->GetParameter(
"epsilon" );
77 unsigned int nq = field->GetNpoints();
78 Array<OneD,NekDouble> x0(nq), x1(nq), x2(nq);
79 field->GetCoords(x0,x1,x2);
82 icond = session->GetFunction(
"InitialConditions",
"u");
83 icond->Evaluate(x0, x1, x2, 0.0, field->UpdatePhys());
89 Vmath::Zero(field->GetNcoeffs(), field->UpdateCoeffs(), 1);
92 for (
unsigned int n = 0; n < nSteps; ++n)
94 Vmath::Smul(nq, -1.0/delta_t/epsilon, field->GetPhys(), 1,
95 field->UpdatePhys(), 1);
97 field->HelmSolve(field->GetPhys(), field->UpdateCoeffs(),
100 field->BwdTrans(field->GetCoeffs(), field->UpdatePhys());
104 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
105 = field->GetFieldDefinitions();
106 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
107 for(
int i = 0; i < FieldDef.size(); ++i)
109 FieldDef[i]->m_fields.push_back(
"u");
110 field->AppendFieldData(FieldDef[i], FieldData[i]);
112 fld->Write(outFile, FieldDef, FieldData);
115 ex_sol = session->GetFunction(
"ExactSolution",0);
119 Array<OneD, NekDouble> exact(nq);
123 ex_sol->Evaluate(x0, x1, x2, (nSteps)*delta_t, exact);
127 cout <<
"L inf error: "
128 << field->Linf(field->GetPhys(), exact) << endl;
129 cout <<
"L 2 error: "
130 << field->L2(field->GetPhys(), exact) << endl;
131 cout <<
"H 1 error: "
132 << field->H1(field->GetPhys(), exact) << endl;
139 catch (
const std::runtime_error& e)
143 catch (
const std::string& eStr)
145 cout <<
"Error: " << eStr << endl;