37 #include <boost/core/ignore_unused.hpp> 88 session = LibUtilities::SessionReader::CreateInstance(argc, argv);
91 graph = SpatialDomains::MeshGraph::Read(session);
94 fld = LibUtilities::FieldIO::CreateDefault(session);
97 sessionName = session->GetSessionName();
98 scheme = session->GetSolverInfo(
"TimeIntegrationMethod");
99 nSteps = session->GetParameter(
"NumSteps");
100 delta_t = session->GetParameter(
"TimeStep");
101 epsilon = session->GetParameter(
"epsilon");
102 lambda = 1.0/delta_t/epsilon;
109 fields[0] = field->UpdatePhys();
112 unsigned int nq = field->GetNpoints();
114 field->GetCoords(x0,x1,x2);
118 = session->GetFunction(
"InitialConditions",
"u");
119 icond->Evaluate(x0,x1,x2,0.0,field->UpdatePhys());
130 CreateInstance(scheme);
135 u = IntScheme->InitializeScheme(delta_t, fields, 0.0, ode);
138 Vmath::Zero(field->GetNcoeffs(), field->UpdateCoeffs(), 1);
140 for (
int n = 0; n < nSteps; ++n)
142 fields = IntScheme->TimeIntegrate(n, delta_t, u, ode);
144 Vmath::Vcopy(field->GetNpoints(), fields[0], 1, field->UpdatePhys(), 1);
158 boost::ignore_unused(time);
163 for (
int i = 0; i < inarray.num_elements(); ++i)
171 field->HelmSolve(outarray[i],
172 field->UpdateCoeffs(),
176 field->BwdTrans (field->GetCoeffs(), outarray[i]);
183 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
184 = field->GetFieldDefinitions();
185 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
186 for(
int i = 0; i < FieldDef.size(); ++i)
188 FieldDef[i]->m_fields.push_back(
"u");
189 field->AppendFieldData(FieldDef[i], FieldData[i]);
191 fld->Write(session->GetSessionName() +
".fld", FieldDef, FieldData);
198 unsigned int nq = field->GetNpoints();
200 field->GetCoords(x0,x1,x2);
203 session->GetFunction(
"ExactSolution",0);
209 ex_sol->Evaluate(x0, x1, x2, (nSteps)*delta_t, exact);
212 cout <<
"L inf error: " 213 << field->Linf(field->GetPhys(), exact) << endl;
214 cout <<
"L 2 error: " 215 << field->L2(field->GetPhys(), exact) << endl;
216 cout <<
"H 1 error: " 217 << field->H1(field->GetPhys(), exact) << endl;
222 int main(
int argc,
char *argv[])
229 catch (
const std::runtime_error& e)
233 catch (
const std::string& eStr)
235 cout <<
"Error: " << eStr << endl;
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
LibUtilities::TimeIntegrationWrapperSharedPtr IntScheme
MultiRegions::ContField2DSharedPtr field
Diffusion(int argc, char *argv[])
int main(int argc, char *argv[])
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< ContField2D > ContField2DSharedPtr
LibUtilities::TimeIntegrationSolutionSharedPtr u
LibUtilities::FieldIOSharedPtr fld
std::map< ConstFactorType, NekDouble > ConstFactorMap
std::shared_ptr< TimeIntegrationWrapper > TimeIntegrationWrapperSharedPtr
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Array< OneD, Array< OneD, NekDouble > > fields
TimeIntegrationWrapperFactory & GetTimeIntegrationWrapperFactory()
LibUtilities::SessionReaderSharedPtr session
std::shared_ptr< Equation > EquationSharedPtr
void DoImplicitSolve(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time, const NekDouble lambda)
SpatialDomains::MeshGraphSharedPtr graph
LibUtilities::TimeIntegrationSchemeOperators ode
void Zero(int n, T *x, const int incx)
Zero vector.
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::shared_ptr< TimeIntegrationSolution > TimeIntegrationSolutionSharedPtr
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static FlagList NullFlagList
An empty flag list.