All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Diffusion Class Reference
Collaboration diagram for Diffusion:
Collaboration graph

Public Member Functions

 Diffusion (int argc, char *argv[])
 ~Diffusion ()
void TimeIntegrate ()
void DoImplicitSolve (const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time, const NekDouble lambda)

Private Member Functions

void WriteSolution ()
void ExactSolution ()

Private Attributes

LibUtilities::SessionReaderSharedPtr session
LibUtilities::FieldIOSharedPtr fld
string sessionName
string fileName
SpatialDomains::MeshGraphSharedPtr graph
MultiRegions::ContField2DSharedPtr field
LibUtilities::TimeIntegrationWrapperSharedPtr IntScheme
LibUtilities::TimeIntegrationSolutionSharedPtr u
LibUtilities::TimeIntegrationSchemeOperators ode
Array< OneD, Array< OneD,
NekDouble > > 
string scheme
unsigned int nSteps
NekDouble delta_t
NekDouble epsilon
NekDouble lambda

Detailed Description

Definition at line 46 of file DiffusionSolverTimeInt.cpp.

Constructor & Destructor Documentation

Diffusion::Diffusion ( int  argc,
char *  argv[] 

Definition at line 84 of file DiffusionSolverTimeInt.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::SessionReader::CreateInstance(), and Nektar::SpatialDomains::MeshGraph::Read().

// Create session reader.
session = LibUtilities::SessionReader::CreateInstance(argc, argv);
// Create Field I/O object.
// Get some information from the session
fileName = session->GetFilename();
sessionName = session->GetSessionName();
scheme = session->GetSolverInfo("TimeIntegrationMethod");
nSteps = session->GetParameter("NumSteps");
delta_t = session->GetParameter("TimeStep");
epsilon = session->GetParameter("epsilon");
// Read the geometry and the expansion information
graph = SpatialDomains::MeshGraph::Read(session);
// Set up the field
fields = Array<OneD, Array<OneD, NekDouble> >(1);
fields[0] = field->UpdatePhys();
// Get coordinates of physical points
unsigned int nq = field->GetNpoints();
Array<OneD,NekDouble> x0(nq), x1(nq), x2(nq);
// Evaluate initial condition
= session->GetFunction("InitialConditions", "u");
Diffusion::~Diffusion ( )

Definition at line 123 of file DiffusionSolverTimeInt.cpp.


Member Function Documentation

void Diffusion::DoImplicitSolve ( const Array< OneD, const Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble  time,
const NekDouble  lambda 

Definition at line 153 of file DiffusionSolverTimeInt.cpp.

References Nektar::StdRegions::eFactorLambda, Nektar::NullFlagList, and Vmath::Smul().

Referenced by TimeIntegrate().

for (int i = 0; i < inarray.num_elements(); ++i)
// Multiply RHS by 1.0/timestep/lambda
Vmath::Smul(field->GetNpoints(), -factors[StdRegions::eFactorLambda],
inarray [i], 1,
outarray[i], 1);
// Solve a system of equations with Helmholtz solver
NullFlagList, factors);
// Transform to physical space and store in solution vector
field->BwdTrans (field->GetCoeffs(), outarray[i]);
void Diffusion::ExactSolution ( )

Definition at line 195 of file DiffusionSolverTimeInt.cpp.

unsigned int nq = field->GetNpoints();
Array<OneD,NekDouble> x0(nq), x1(nq), x2(nq);
// evaluate exact solution
Array<OneD, NekDouble> exact(nq);
ex_sol->Evaluate(x0, x1, x2, (nSteps)*delta_t, exact);
// Calculate errors
cout << "L inf error: "
<< field->Linf(field->GetPhys(), exact) << endl;
cout << "L 2 error: "
<< field->L2(field->GetPhys(), exact) << endl;
cout << "H 1 error: "
<< field->H1(field->GetPhys(), exact) << endl;
void Diffusion::TimeIntegrate ( )

Definition at line 128 of file DiffusionSolverTimeInt.cpp.

References DoImplicitSolve(), Nektar::LibUtilities::GetTimeIntegrationWrapperFactory(), Vmath::Vcopy(), and Vmath::Zero().

Referenced by main().

// Initialise the scheme for actual time integration scheme
u = IntScheme->InitializeScheme(delta_t, fields, 0.0, ode);
// Zero field coefficients for initial guess for linear solver.
Vmath::Zero(field->GetNcoeffs(), field->UpdateCoeffs(), 1);
for (int n = 0; n < nSteps; ++n)
fields = IntScheme->TimeIntegrate(n, delta_t, u, ode);
Vmath::Vcopy(field->GetNpoints(), fields[0], 1, field->UpdatePhys(), 1);
void Diffusion::WriteSolution ( )

Definition at line 179 of file DiffusionSolverTimeInt.cpp.

// Write solution to file
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
= field->GetFieldDefinitions();
std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
for(int i = 0; i < FieldDef.size(); ++i)
field->AppendFieldData(FieldDef[i], FieldData[i]);
fld->Write(session->GetSessionName() + ".fld", FieldDef, FieldData);

Member Data Documentation

NekDouble Diffusion::delta_t

Definition at line 75 of file DiffusionSolverTimeInt.cpp.

NekDouble Diffusion::epsilon

Definition at line 76 of file DiffusionSolverTimeInt.cpp.

MultiRegions::ContField2DSharedPtr Diffusion::field

Definition at line 66 of file DiffusionSolverTimeInt.cpp.

Array<OneD, Array<OneD, NekDouble> > Diffusion::fields

Definition at line 71 of file DiffusionSolverTimeInt.cpp.

string Diffusion::fileName

Definition at line 64 of file DiffusionSolverTimeInt.cpp.

LibUtilities::FieldIOSharedPtr Diffusion::fld

Definition at line 62 of file DiffusionSolverTimeInt.cpp.

SpatialDomains::MeshGraphSharedPtr Diffusion::graph

Definition at line 65 of file DiffusionSolverTimeInt.cpp.

LibUtilities::TimeIntegrationWrapperSharedPtr Diffusion::IntScheme

Definition at line 68 of file DiffusionSolverTimeInt.cpp.

NekDouble Diffusion::lambda

Definition at line 77 of file DiffusionSolverTimeInt.cpp.

unsigned int Diffusion::nSteps

Definition at line 74 of file DiffusionSolverTimeInt.cpp.

Definition at line 70 of file DiffusionSolverTimeInt.cpp.

string Diffusion::scheme

Definition at line 73 of file DiffusionSolverTimeInt.cpp.

LibUtilities::SessionReaderSharedPtr Diffusion::session

Definition at line 61 of file DiffusionSolverTimeInt.cpp.

string Diffusion::sessionName

Definition at line 63 of file DiffusionSolverTimeInt.cpp.

Definition at line 69 of file DiffusionSolverTimeInt.cpp.