44{
   51 
   52    try
   53    {
   54        
   55        session = LibUtilities::SessionReader::CreateInstance(argc, argv);
   56 
   57        
   58        graph = SpatialDomains::MeshGraph::Read(session);
   59 
   60        
   61        fld = LibUtilities::FieldIO::CreateDefault(session);
   62 
   63        
   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");
 
   69 
   70        
   72            session, graph, session->GetVariable(0));
   73 
   74        
   75        unsigned int nq = field->GetNpoints();
   77        field->GetCoords(x0, x1, x2);
   78 
   79        
   80        icond = session->GetFunction("InitialConditions", "u");
   81        icond->Evaluate(x0, x1, x2, 0.0, field->UpdatePhys());
   82 
   83        
   85 
   86        
   87        Vmath::Zero(field->GetNcoeffs(), field->UpdateCoeffs(), 1);
 
   88 
   89        
   90        for (unsigned int n = 0; n < nSteps; ++n)
   91        {
   92            Vmath::Smul(nq, -1.0 / delta_t / epsilon, field->GetPhys(), 1,
 
   93                        field->UpdatePhys(), 1);
   94 
   95            field->HelmSolve(field->GetPhys(), field->UpdateCoeffs(), 
factors);
 
   96 
   97            field->BwdTrans(field->GetCoeffs(), field->UpdatePhys());
   98        }
   99 
  100        
  101        std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
  102            field->GetFieldDefinitions();
  103        std::vector<std::vector<NekDouble>> FieldData(FieldDef.size());
  104        for (int i = 0; i < FieldDef.size(); ++i)
  105        {
  106            FieldDef[i]->m_fields.push_back("u");
  107            field->AppendFieldData(FieldDef[i], FieldData[i]);
  108        }
  109        fld->Write(outFile, FieldDef, FieldData);
  110 
  111        
  112        ex_sol = session->GetFunction("ExactSolution", 0);
  113        if (ex_sol)
  114        {
  115            
  117 
  118            
  119            
  120            ex_sol->Evaluate(x0, x1, x2, (nSteps)*delta_t, exact);
  121 
  122            
  123            
  124            cout << "L inf error:      " << field->Linf(field->GetPhys(), exact)
  125                 << endl;
  126            cout << "L 2 error:        " << field->L2(field->GetPhys(), exact)
  127                 << endl;
  128            cout << "H 1 error:        " << field->H1(field->GetPhys(), exact)
  129                 << endl;
  130            
  131        }
  132 
  133        
  134        session->Finalise();
  135    }
  136    catch (const std::runtime_error &e)
  137    {
  138        return 1;
  139    }
  140    catch (const std::string &eStr)
  141    {
  142        cout << "Error: " << eStr << endl;
  143    }
  144 
  145    return 0;
  146}
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
 
std::shared_ptr< FieldIO > FieldIOSharedPtr
 
std::shared_ptr< SessionReader > SessionReaderSharedPtr
 
std::shared_ptr< Equation > EquationSharedPtr
 
std::shared_ptr< ContField > ContFieldSharedPtr
 
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
 
std::map< ConstFactorType, NekDouble > ConstFactorMap
 
StdRegions::ConstFactorMap factors
 
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
 
void Zero(int n, T *x, const int incx)
Zero vector.