56 session = LibUtilities::SessionReader::CreateInstance(argc, argv);
59 fld = LibUtilities::FieldIO::CreateDefault(session);
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" );
69 graph = SpatialDomains::MeshGraph::Read(session);
76 unsigned int nq = field->GetNpoints();
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);
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;
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
boost::shared_ptr< ContField2D > ContField2DSharedPtr
std::map< ConstFactorType, NekDouble > ConstFactorMap
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
boost::shared_ptr< FieldIO > FieldIOSharedPtr
boost::shared_ptr< Equation > EquationSharedPtr
void Zero(int n, T *x, const int incx)
Zero vector.
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
static FlagList NullFlagList
An empty flag list.