Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ContField1D.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File ContField1D.h
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: Field definition in one-dimension
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIBS_MULTIREGIONS_CONTFIELD1D_H
37 #define NEKTAR_LIBS_MULTIREGIONS_CONTFIELD1D_H
38 
39 
48 
49 namespace Nektar
50 {
51  namespace MultiRegions
52  {
53  /// Abstraction of a global continuous one-dimensional spectral/hp
54  /// element expansion which approximates the solution of a set of
55  /// partial differential equations.
57  {
58  public:
59  /// Default constructor.
61 
62  /// Set up global continuous field based on an input mesh and
63  /// boundary conditions.
67  const std::string &variable);
68 
69  /// Copy constructor.
70  MULTI_REGIONS_EXPORT ContField1D(const ContField1D &In);
71 
72  /// Copy constructor.
74  const ExpList1D & In);
75  /// Destructor
77 
78  /// Perform global forward transformation of a function \f$f(x)\f$,
79  // subject to the boundary conditions specified.
81  Array<OneD, NekDouble> &outarray,
82  CoeffState coeffstate = eLocal);
83 
84  /// This function performs the backward transformation of the
85  /// spectral/hp element expansion.
87  Array<OneD, NekDouble> &outarray,
88  CoeffState coeffstate = eLocal);
89 
90  ///
92  const Array<OneD, const NekDouble> &inarray,
93  Array<OneD, NekDouble> &outarray,
94  CoeffState coeffstate = eLocal);
95 
96  /// Return the boundary conditions expansion.
97  // inline
100 
101  // inline
104  /// Scatters from the global coefficients
105  /// \f$\boldsymbol{\hat{u}}_g\f$ to the local coefficients
106  /// \f$\boldsymbol{\hat{u}}_l\f$.
107  // inline
109  Array<OneD,NekDouble> &outarray);
110 
111  /// Gathers the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
112  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
113  // inline
115 
116  /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
117  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
118  // inline
120 
121  /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
122  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
123  // inline
125  Array<OneD,NekDouble> &outarray);
126 
127  /// Returns the map from local to global level.
128  // inline
130 
131  /// Calculates the inner product of a function \f$f(x)\f$ with
132  /// respect to all <em>global</em> expansion modes
133  /// \f$\phi_n^e(x)\f$.
135  Array<OneD, NekDouble> &outarray,
136  CoeffState coeffstate = eLocal);
137 
138  /// Calculates the result of the multiplication of a global matrix
139  /// of type specified by \a mkey with a vector given by \a inarray.
141  const Array<OneD,const NekDouble> &inarray,
142  Array<OneD, NekDouble> &outarray,
143  CoeffState coeffstate = eLocal);
144 
145  protected:
146  /// (A shared pointer to) the object which contains all the required
147  /// information for the transformation from local to global degrees
148  /// of freedom.
150 
151 
152  /// A enum list declaring how to interpret coeffs,
153  /// i.e. eLocal, eHybrid or eGlobal
155 
156  /// (A shared pointer to) a list which collects all the global
157  /// matrices being assembled, such that they should be constructed
158  /// only once.
160 
161  /// A manager which collects all the global
162  /// linear systems being assembled, such that they should be
163  /// constructed only once.
165 
166  private:
167  /// Returns the linear system specified by \a mkey.
169 
171 
172  /// Solve the linear system specified by the key \a key.
173  void GlobalSolve( const GlobalLinSysKey &key,
174  const Array<OneD, const NekDouble> &rhs,
175  Array<OneD, NekDouble> &inout,
176  const Array<OneD, const NekDouble> &dirForcing
178 
179  /// Perform a forward transform
180  virtual void v_FwdTrans(
181  const Array<OneD, const NekDouble> &inarray,
182  Array<OneD, NekDouble> &outarray,
183  CoeffState coeffstate);
184 
185  virtual void v_MultiplyByInvMassMatrix(
186  const Array<OneD, const NekDouble> &inarray,
187  Array<OneD, NekDouble> &outarray,
188  CoeffState coeffstate);
189 
190  /// Impose the Dirichlet Boundary Conditions on outarray
192 
193  /// Scatters from the global coefficients
194  /// \f$\boldsymbol{\hat{u}}_g\f$ to the local coefficients
195  /// \f$\boldsymbol{\hat{u}}_l\f$.
196  // inline
197  MULTI_REGIONS_EXPORT virtual void v_GlobalToLocal(void);
198 
199 
200  /// Gathers the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
201  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
202  // inline
203  MULTI_REGIONS_EXPORT virtual void v_LocalToGlobal(void);
204 
205  virtual void v_HelmSolve(
206  const Array<OneD, const NekDouble> &inarray,
207  Array<OneD, NekDouble> &outarray,
208  const FlagList &flags,
209  const StdRegions::ConstFactorMap &factors,
210  const StdRegions::VarCoeffMap &varcoeff,
211  const Array<OneD, const NekDouble> &dirForcing);
212 
213  virtual const Array<OneD,const SpatialDomains
215 
216  virtual void v_BwdTrans(
217  const Array<OneD, const NekDouble> &inarray,
218  Array<OneD, NekDouble> &outarray,
219  CoeffState coeffstate);
220 
221  virtual void v_IProductWRTBase(
222  const Array<OneD, const NekDouble> &inarray,
223  Array<OneD, NekDouble> &outarray,
224  CoeffState coeffstate);
225 
226  /// Calculates the result of the multiplication of a global matrix
227  /// of type specified by \a mkey with a vector given by \a inarray.
228  virtual void v_GeneralMatrixOp(
229  const GlobalMatrixKey &gkey,
230  const Array<OneD,const NekDouble> &inarray,
231  Array<OneD, NekDouble> &outarray,
232  CoeffState coeffstate);
233 
234  virtual void v_ClearGlobalLinSysManager(void);
235 
236  };
237  typedef boost::shared_ptr<ContField1D> ContField1DSharedPtr;
238 
239  // Inline implementations follow
240 
243  {
244  return m_bndCondExpansions;
245  }
246 
249  {
250  return m_bndConditions;
251  }
252 
253 
254  /**
255  * This operation is evaluated as:
256  * \f{tabbing}
257  * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
258  * > > Do \= $i=$ $0,N_m^e-1$ \\
259  * > > > $\boldsymbol{\hat{u}}^{e}[i] = \mbox{sign}[e][i] \cdot
260  * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]$ \\
261  * > > continue \\
262  * > continue
263  * \f}
264  * where \a map\f$[e][i]\f$ is the mapping array and \a
265  * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
266  * correct modal connectivity between the different elements (both
267  * these arrays are contained in the data member #m_locToGloMap). This
268  * operation is equivalent to the scatter operation
269  * \f$\boldsymbol{\hat{u}}_l=\mathcal{A}\boldsymbol{\hat{u}}_g\f$, where
270  * \f$\mathcal{A}\f$ is the
271  * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
272  *
273  * @param inarray An array of size \f$N_\mathrm{dof}\f$
274  * containing the global degrees of freedom
275  * \f$\boldsymbol{x}_g\f$.
276  * @param outarray The resulting local degrees of freedom
277  * \f$\boldsymbol{x}_l\f$ will be stored in this
278  * array of size \f$N_\mathrm{eof}\f$.
279  */
281  const Array<OneD, const NekDouble> &inarray,
282  Array<OneD,NekDouble> &outarray)
283  {
284  m_locToGloMap->GlobalToLocal(inarray,outarray);
285  }
286 
287 
288  /**
289  * This operation is evaluated as:
290  * \f{tabbing}
291  * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
292  * > > Do \= $i=$ $0,N_m^e-1$ \\
293  * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
294  * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
295  * \boldsymbol{\hat{u}}^{e}[i]$\\
296  * > > continue\\
297  * > continue
298  * \f}
299  * where \a map\f$[e][i]\f$ is the mapping array and \a
300  * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
301  * correct modal connectivity between the different elements (both
302  * these arrays are contained in the data member #m_locToGloMap). This
303  * operation is equivalent to the gather operation
304  * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
305  * where \f$\mathcal{A}\f$ is the
306  * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
307  *
308  */
309  inline void ContField1D::Assemble()
310  {
311  m_locToGloMap->Assemble(m_coeffs,m_coeffs);
312  }
313 
314  /**
315  * This operation is evaluated as:
316  * \f{tabbing}
317  * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
318  * > > Do \= $i=$ $0,N_m^e-1$ \\
319  * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
320  * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
321  * \boldsymbol{\hat{u}}^{e}[i]$\\
322  * > > continue\\
323  * > continue
324  * \f}
325  * where \a map\f$[e][i]\f$ is the mapping array and \a
326  * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
327  * correct modal connectivity between the different elements (both
328  * these arrays are contained in the data member #m_locToGloMap). This
329  * operation is equivalent to the gather operation
330  * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
331  * where \f$\mathcal{A}\f$ is the
332  * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
333  *
334  * @param inarray An array of size \f$N_\mathrm{eof}\f$
335  * containing the local degrees of freedom
336  * \f$\boldsymbol{x}_l\f$.
337  * @param outarray The resulting global degrees of freedom
338  * \f$\boldsymbol{x}_g\f$ will be stored in this
339  * array of size \f$N_\mathrm{dof}\f$.
340  */
342  const Array<OneD, const NekDouble> &inarray,
343  Array<OneD,NekDouble> &outarray)
344  {
345  m_locToGloMap->Assemble(inarray,outarray);
346  }
347 
348  inline const AssemblyMapCGSharedPtr&
350  {
351  return m_locToGloMap;
352  }
353 
354  } //end of namespace
355 } //end of namespace
356 
357 #endif // MULTIERGIONS_CONTSOLNFIELD1D_H
virtual void v_HelmSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const FlagList &flags, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const Array< OneD, const NekDouble > &dirForcing)
void LocalToGlobal()
Gathers the global coefficients from the local coefficients .
boost::shared_ptr< ContField1D > ContField1DSharedPtr
Definition: ContField1D.h:237
Local coefficients.
virtual void v_MultiplyByInvMassMatrix(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
static Array< OneD, NekDouble > NullNekDouble1DArray
virtual void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
CoeffState m_coeffState
A enum list declaring how to interpret coeffs, i.e. eLocal, eHybrid or eGlobal.
Definition: ContField1D.h:154
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition on the different boundary region...
void GeneralMatrixOp(const GlobalMatrixKey &gkey, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Calculates the result of the multiplication of a global matrix of type specified by mkey with a vecto...
#define MULTI_REGIONS_EXPORT
GlobalMatrixMapShPtr m_globalMat
(A shared pointer to) a list which collects all the global matrices being assembled, such that they should be constructed only once.
Definition: ContField1D.h:159
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:251
const AssemblyMapCGSharedPtr & GetLocalToGlobalMap() const
Returns the map from local to global level.
Definition: ContField1D.h:349
virtual void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
Perform a forward transform.
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:939
void MultiplyByInvMassMatrix(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
virtual void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
GlobalLinSysSharedPtr GetGlobalLinSys(const GlobalLinSysKey &mkey)
Returns the linear system specified by mkey.
const Array< OneD, const MultiRegions::ExpListSharedPtr > & GetBndCondExpansions()
Return the boundary conditions expansion.
Definition: ContField1D.h:242
Abstraction of a global continuous one-dimensional spectral/hp element expansion which approximates t...
Definition: ContField1D.h:56
boost::shared_ptr< GlobalMatrixMap > GlobalMatrixMapShPtr
Shared pointer to a global matrix map.
Definition: GlobalMatrix.h:93
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:226
LibUtilities::NekManager< GlobalLinSysKey, GlobalLinSys > m_globalLinSysManager
A manager which collects all the global linear systems being assembled, such that they should be cons...
Definition: ContField1D.h:164
void IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Calculates the inner product of a function with respect to all global expansion modes ...
This class is the abstraction of a global discontinuous two- dimensional spectral/hp element expansio...
Defines a list of flags.
Describe a linear system.
virtual void v_ImposeDirichletConditions(Array< OneD, NekDouble > &outarray)
Impose the Dirichlet Boundary Conditions on outarray.
Describes a matrix with ordering defined by a local to global map.
const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & GetBndConditions()
Definition: ContField1D.h:248
void GlobalSolve(const GlobalLinSysKey &key, const Array< OneD, const NekDouble > &rhs, Array< OneD, NekDouble > &inout, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)
Solve the linear system specified by the key key.
virtual void v_ClearGlobalLinSysManager(void)
virtual void v_GlobalToLocal(void)
Scatters from the global coefficients to the local coefficients .
ContField1D()
Default constructor.
Definition: ContField1D.cpp:86
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
Discretised boundary conditions.
void Assemble()
Assembles the global coefficients from the local coefficients .
Definition: ContField1D.h:309
void BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
This function performs the backward transformation of the spectral/hp element expansion.
This class is the abstraction of a one-dimensional multi-elemental expansions which is merely a colle...
Definition: ExpList1D.h:61
boost::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:52
virtual ~ContField1D()
Destructor.
GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey)
void FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Perform global forward transformation of a function ,.
boost::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
Definition: Conditions.h:208
boost::shared_ptr< AssemblyMapCG > AssemblyMapCGSharedPtr
Definition: AssemblyMapCG.h:52
virtual void v_LocalToGlobal(void)
Gathers the global coefficients from the local coefficients .
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
void GlobalToLocal(void)
Put the coefficients into local ordering and place in m_coeffs.
Definition: ExpList.h:1858
virtual void v_GeneralMatrixOp(const GlobalMatrixKey &gkey, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
Calculates the result of the multiplication of a global matrix of type specified by mkey with a vecto...
AssemblyMapCGSharedPtr m_locToGloMap
(A shared pointer to) the object which contains all the required information for the transformation f...
Definition: ContField1D.h:149
virtual const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & v_GetBndConditions()