Nektar++
UnsteadyReactionDiffusion.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: UnsteadyReactionDiffusion.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Unsteady reaction-diffusion solve routines
32//
33///////////////////////////////////////////////////////////////////////////////
34
36#include <iomanip>
37#include <iostream>
38
39using namespace std;
40
41namespace Nektar
42{
45 "UnsteadyReactionDiffusion", UnsteadyReactionDiffusion::create);
46
50 : UnsteadyDiffusion(pSession, pGraph)
51{
52}
53
54/**
55 * @brief Initialisation object for the unsteady reaction-diffusion problem.
56 */
58{
60
61 // Forcing terms
63 m_fields, m_fields.size());
64
65 // Reset OdeRhs functor
67}
68
69/**
70 * @brief Compute the right-hand side for the unsteady reaction diffusion
71 * problem.
72 *
73 * @param inarray Given fields.
74 * @param outarray Calculated solution.
75 * @param time Time.
76 */
78 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
79 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time)
80{
82 {
83 UnsteadyDiffusion::DoOdeRhs(inarray, outarray, time);
84 }
85 else
86 {
87 // RHS should be set to zero.
88 for (int i = 0; i < outarray.size(); ++i)
89 {
90 Vmath::Zero(outarray[i].size(), &outarray[i][0], 1);
91 }
92 }
93
94 // Add forcing terms for reaction.
95 for (auto &x : m_forcing)
96 {
97 // set up non-linear terms
98 x->Apply(m_fields, inarray, outarray, time);
99 }
100}
101
102} // namespace Nektar
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
static SOLVER_UTILS_EXPORT std::vector< ForcingSharedPtr > Load(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
Definition: Forcing.cpp:118
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
void v_InitObject(bool DeclareFields=true) override
Initialisation object for the unsteady diffusion problem.
static EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
Forcing terms.
UnsteadyReactionDiffusion(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the right-hand side for the unsteady reaction diffusion problem.
void v_InitObject(bool DeclareFields=true) override
Initialisation object for the unsteady reaction-diffusion problem.
static std::string className
Name of class.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
EquationSystemFactory & GetEquationSystemFactory()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
double NekDouble
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.hpp:273