Nektar++
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 // 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: Field definition in one-dimension
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIBS_MULTIREGIONS_CONTFIELD1D_H
36 #define NEKTAR_LIBS_MULTIREGIONS_CONTFIELD1D_H
37 
38 
47 
48 namespace Nektar
49 {
50  namespace MultiRegions
51  {
52  /// Abstraction of a global continuous one-dimensional spectral/hp
53  /// element expansion which approximates the solution of a set of
54  /// partial differential equations.
56  {
57  public:
58  /// Default constructor.
60 
61  /// Set up global continuous field based on an input mesh and
62  /// boundary conditions.
66  const std::string &variable = "DefaultVar",
69 
70  /// Copy constructor.
71  MULTI_REGIONS_EXPORT ContField1D(const ContField1D &In);
72 
73  /// Copy constructor.
75  const ExpList1D & In);
76  /// Destructor
78 
79  /// Perform global forward transformation of a function \f$f(x)\f$,
80  // subject to the boundary conditions specified.
82  Array<OneD, NekDouble> &outarray,
83  CoeffState coeffstate = eLocal);
84 
85  /// This function performs the backward transformation of the
86  /// spectral/hp element expansion.
88  Array<OneD, NekDouble> &outarray,
89  CoeffState coeffstate = eLocal);
90 
91  ///
93  const Array<OneD, const NekDouble> &inarray,
94  Array<OneD, NekDouble> &outarray,
95  CoeffState coeffstate = eLocal);
96 
97  /// Return the boundary conditions expansion.
98  // inline
101 
102  // inline
105 
106 
107  /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
108  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
109  // inline
111 
112  /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
113  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
114  // inline
116  Array<OneD,NekDouble> &outarray);
117 
118  /// Returns the map from local to global level.
119  // inline
121 
122  /// Calculates the inner product of a function \f$f(x)\f$ with
123  /// respect to all <em>global</em> expansion modes
124  /// \f$\phi_n^e(x)\f$.
126  Array<OneD, NekDouble> &outarray,
127  CoeffState coeffstate = eLocal);
128 
129  /// Calculates the result of the multiplication of a global matrix
130  /// of type specified by \a mkey with a vector given by \a inarray.
132  const Array<OneD,const NekDouble> &inarray,
133  Array<OneD, NekDouble> &outarray,
134  CoeffState coeffstate = eLocal);
135 
136  protected:
137  /// (A shared pointer to) the object which contains all the required
138  /// information for the transformation from local to global degrees
139  /// of freedom.
141 
142 
143  /// A enum list declaring how to interpret coeffs,
144  /// i.e. eLocal, eHybrid or eGlobal
146 
147  /// (A shared pointer to) a list which collects all the global
148  /// matrices being assembled, such that they should be constructed
149  /// only once.
151 
152  /// A manager which collects all the global
153  /// linear systems being assembled, such that they should be
154  /// constructed only once.
156 
157  private:
158  /// Returns the linear system specified by \a mkey.
160 
162 
163  /// Solve the linear system specified by the key \a key.
164  void GlobalSolve( const GlobalLinSysKey &key,
166  Array<OneD, NekDouble> &inout,
167  const Array<OneD, const NekDouble> &dirForcing
169 
170  /// Perform a forward transform
171  virtual void v_FwdTrans(
172  const Array<OneD, const NekDouble> &inarray,
173  Array<OneD, NekDouble> &outarray,
174  CoeffState coeffstate);
175 
176  virtual void v_MultiplyByInvMassMatrix(
177  const Array<OneD, const NekDouble> &inarray,
178  Array<OneD, NekDouble> &outarray,
179  CoeffState coeffstate);
180 
181  /// Impose the Dirichlet Boundary Conditions on outarray
183 
184  /// Scatters from the global coefficients
185  /// \f$\boldsymbol{\hat{u}}_g\f$ to the local coefficients
186  /// \f$\boldsymbol{\hat{u}}_l\f$.
187  // inline
189  const Array<OneD, const NekDouble> &inarray,
190  Array<OneD,NekDouble> &outarray);
191 
192  MULTI_REGIONS_EXPORT virtual void v_GlobalToLocal(void);
193 
194  /// Gathers the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
195  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
196  // inline
198  const Array<OneD, const NekDouble> &inarray,
199  Array<OneD,NekDouble> &outarray,
200  bool useComm);
201 
202  MULTI_REGIONS_EXPORT virtual void v_LocalToGlobal(bool useComm);
203 
204  virtual void v_HelmSolve(
205  const Array<OneD, const NekDouble> &inarray,
206  Array<OneD, NekDouble> &outarray,
207  const FlagList &flags,
208  const StdRegions::ConstFactorMap &factors,
209  const StdRegions::VarCoeffMap &varcoeff,
210  const MultiRegions::VarFactorsMap &varfactors,
211  const Array<OneD, const NekDouble> &dirForcing,
212  const bool PhysSpaceForcing);
213 
214  virtual const Array<OneD,const SpatialDomains
216 
217  virtual void v_BwdTrans(
218  const Array<OneD, const NekDouble> &inarray,
219  Array<OneD, NekDouble> &outarray,
220  CoeffState coeffstate);
221 
222  virtual void v_IProductWRTBase(
223  const Array<OneD, const NekDouble> &inarray,
224  Array<OneD, NekDouble> &outarray,
225  CoeffState coeffstate);
226 
227  /// Calculates the result of the multiplication of a global matrix
228  /// of type specified by \a mkey with a vector given by \a inarray.
229  virtual void v_GeneralMatrixOp(
230  const GlobalMatrixKey &gkey,
231  const Array<OneD,const NekDouble> &inarray,
232  Array<OneD, NekDouble> &outarray,
233  CoeffState coeffstate);
234 
235  virtual void v_ClearGlobalLinSysManager(void);
236 
237  };
238  typedef std::shared_ptr<ContField1D> ContField1DSharedPtr;
239 
240  // Inline implementations follow
241 
244  {
245  return m_bndCondExpansions;
246  }
247 
250  {
251  return m_bndConditions;
252  }
253 
254 
255  /**
256  * This operation is evaluated as:
257  * \f{tabbing}
258  * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
259  * > > Do \= $i=$ $0,N_m^e-1$ \\
260  * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
261  * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
262  * \boldsymbol{\hat{u}}^{e}[i]$\\
263  * > > continue\\
264  * > continue
265  * \f}
266  * where \a map\f$[e][i]\f$ is the mapping array and \a
267  * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
268  * correct modal connectivity between the different elements (both
269  * these arrays are contained in the data member #m_locToGloMap). This
270  * operation is equivalent to the gather operation
271  * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
272  * where \f$\mathcal{A}\f$ is the
273  * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
274  *
275  */
276  inline void ContField1D::Assemble()
277  {
278  m_locToGloMap->Assemble(m_coeffs,m_coeffs);
279  }
280 
281  /**
282  * This operation is evaluated as:
283  * \f{tabbing}
284  * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
285  * > > Do \= $i=$ $0,N_m^e-1$ \\
286  * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
287  * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
288  * \boldsymbol{\hat{u}}^{e}[i]$\\
289  * > > continue\\
290  * > continue
291  * \f}
292  * where \a map\f$[e][i]\f$ is the mapping array and \a
293  * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
294  * correct modal connectivity between the different elements (both
295  * these arrays are contained in the data member #m_locToGloMap). This
296  * operation is equivalent to the gather operation
297  * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
298  * where \f$\mathcal{A}\f$ is the
299  * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
300  *
301  * @param inarray An array of size \f$N_\mathrm{eof}\f$
302  * containing the local degrees of freedom
303  * \f$\boldsymbol{x}_l\f$.
304  * @param outarray The resulting global degrees of freedom
305  * \f$\boldsymbol{x}_g\f$ will be stored in this
306  * array of size \f$N_\mathrm{dof}\f$.
307  */
309  const Array<OneD, const NekDouble> &inarray,
310  Array<OneD,NekDouble> &outarray)
311  {
312  m_locToGloMap->Assemble(inarray,outarray);
313  }
314 
315  inline const AssemblyMapCGSharedPtr&
317  {
318  return m_locToGloMap;
319  }
320 
321  } //end of namespace
322 } //end of namespace
323 
324 #endif // MULTIERGIONS_CONTSOLNFIELD1D_H
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
std::shared_ptr< ContField1D > ContField1DSharedPtr
Definition: ContField1D.h:238
Local coefficients.
virtual void v_MultiplyByInvMassMatrix(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
std::shared_ptr< AssemblyMapCG > AssemblyMapCGSharedPtr
Definition: AssemblyMapCG.h:51
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:145
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:150
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:50
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:294
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 MultiRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing)
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:1052
void MultiplyByInvMassMatrix(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
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:243
Abstraction of a global continuous one-dimensional spectral/hp element expansion which approximates t...
Definition: ContField1D.h:55
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:264
const AssemblyMapCGSharedPtr & GetLocalToGlobalMap() const
Returns the map from local to global level.
Definition: ContField1D.h:316
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:155
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.
std::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
Definition: Conditions.h:219
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:249
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)
ContField1D()
Default constructor.
Definition: ContField1D.cpp:85
std::shared_ptr< GlobalMatrixMap > GlobalMatrixMapShPtr
Shared pointer to a global matrix map.
Definition: GlobalMatrix.h:92
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
Discretised boundary conditions.
void Assemble()
Assembles the global coefficients from the local coefficients .
Definition: ContField1D.h:276
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:58
virtual ~ContField1D()
Destructor.
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool useComm)
Gathers the global coefficients from the local coefficients .
GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs
void FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Perform global forward transformation of a function ,.
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...
std::shared_ptr< SessionReader > SessionReaderSharedPtr
AssemblyMapCGSharedPtr m_locToGloMap
(A shared pointer to) the object which contains all the required information for the transformation f...
Definition: ContField1D.h:140
virtual const Array< OneD, const SpatialDomains ::BoundaryConditionShPtr > & v_GetBndConditions()
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap