Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AdvectionTerm.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File AdvectionTerm.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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Base class for Navier-Stokes advection term
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 #include <string>
38 
39 
40 namespace Nektar
41 {
42 
44  {
45  typedef Loki::SingletonHolder<AdvectionTermFactory,
46  Loki::CreateUsingNew,
47  Loki::NoDestroy > Type;
48  return Type::Instance();
49  }
50 
51  /**
52  * Constructor. Creates ...
53  *
54  * \param
55  * \param
56  */
60  : m_session(pSession),
61  m_graph(pGraph)
62  {
63  }
64 
66  {
67  // Set space dimension for use in class
68  m_spacedim = m_graph->GetSpaceDimension();
69  m_expdim = m_graph->GetMeshDimension();
70 
71  // Save the basename of input file name for output details.
72  m_sessionName = m_session->GetFilename();
73  m_sessionName = m_sessionName.substr(0, m_sessionName.find_last_of("."));
74 
75  if(m_session->DefinesSolverInfo("PROJECTION"))
76  {
77  std::string ProjectStr
78  = m_session->GetSolverInfo("PROJECTION");
79 
80  if((ProjectStr == "Continuous")||(ProjectStr == "Galerkin")||
81  (ProjectStr == "CONTINUOUS")||(ProjectStr == "GALERKIN"))
82  {
84  }
85  else if((ProjectStr == "MixedCGDG")||(ProjectStr == "Mixed_CG_Discontinuous"))
86  {
88  }
89  else if(ProjectStr == "DisContinuous")
90  {
92  }
93  else
94  {
95  ASSERTL0(false,"PROJECTION value not recognised");
96  }
97  }
98  else
99  {
100  cerr << "Projection type not specified in SOLVERINFO,"
101  "defaulting to continuous Galerkin" << endl;
103  }
104 
106  m_homogen_dealiasing = false;
107 
108  if(m_session->DefinesSolverInfo("DEALIASING"))
109  {
110  m_homogen_dealiasing = true;
111  }
112 
113  m_session->MatchSolverInfo("SPECTRALHPDEALIASING","True",m_specHP_dealiasing,false);
114  if(m_specHP_dealiasing == false)
115  {
116  m_session->MatchSolverInfo("SPECTRALHPDEALIASING","On",m_specHP_dealiasing,false);
117  }
118 
119  m_session->MatchSolverInfo("ModeType","SingleMode",m_SingleMode,false);
120  m_session->MatchSolverInfo("ModeType","HalfMode",m_HalfMode,false);
121  }
122 
124  {
125  }
126 
127  void AdvectionTerm::DoAdvection(Array<OneD, MultiRegions::ExpListSharedPtr> &pFields,
128  const int nConvectiveFields,
129  const Array<OneD, int> &vel_loc,
130  const Array<OneD, const Array<OneD, NekDouble> > &pInarray,
131  Array<OneD, Array<OneD, NekDouble> > &pOutarray,
132  NekDouble time,
133  Array<OneD, NekDouble> &pWk)
134  {
135  int i,j;
136  int VelDim = vel_loc.num_elements();
137  int nqtot = pFields[0]->GetTotPoints();
138  Array<OneD, Array<OneD, NekDouble> > velocity(VelDim);
139 
140  ASSERTL1(nConvectiveFields == pInarray.num_elements(),"Number of convective fields and Inarray are not compatible");
141 
142  for(i = 0; i < VelDim; ++i)
143  {
144  if(pFields[i]->GetWaveSpace() && !m_SingleMode && !m_HalfMode)
145  {
146  j = vel_loc[i];
147  velocity[i] = Array<OneD, NekDouble>(nqtot,0.0);
148  pFields[i]->HomogeneousBwdTrans(pInarray[j],velocity[i]);
149  }
150  else
151  {
152  velocity[i] = pInarray[vel_loc[i]];
153  }
154  }
155 
156 
157  DoAdvection(pFields,velocity,pInarray,pOutarray,time,pWk);
158  }
159 
160  void AdvectionTerm::DoAdvection(Array<OneD, MultiRegions::ExpListSharedPtr> &pFields,
161  const Array<OneD, const Array<OneD, NekDouble> > &velocity,
162  const Array<OneD, const Array<OneD, NekDouble> > &pInarray,
163  Array<OneD, Array<OneD, NekDouble> > &pOutarray,
164  NekDouble time,
165  Array<OneD, NekDouble> &pWk)
166  {
167  int i;
168  int nqtot = pFields[0]->GetTotPoints();
169  int VelDim = velocity.num_elements();
170  Array<OneD, NekDouble > Deriv;
171 
172 
173  m_nConvectiveFields = pInarray.num_elements();
174 
175  // Set up Derivative work space;
176  if(pWk.num_elements())
177  {
178  ASSERTL0(pWk.num_elements() >= nqtot*VelDim,"Workspace is not sufficient");
179  Deriv = pWk;
180  }
181  else
182  {
183  Deriv = Array<OneD, NekDouble> (nqtot*VelDim);
184  }
185 
186 
187  for(i=0; i< m_nConvectiveFields; ++i)
188  {
189  v_ComputeAdvectionTerm(pFields,velocity,pInarray[i],pOutarray[i],i,time,Deriv);
190  Vmath::Neg(nqtot,pOutarray[i],1);
191  }
192  }
193 
194 } //end of namespace