Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 = "DefaultVar");
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 
105 
106  /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
107  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
108  // inline
110 
111  /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
112  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
113  // inline
115  Array<OneD,NekDouble> &outarray);
116 
117  /// Returns the map from local to global level.
118  // inline
120 
121  /// Calculates the inner product of a function \f$f(x)\f$ with
122  /// respect to all <em>global</em> expansion modes
123  /// \f$\phi_n^e(x)\f$.
125  Array<OneD, NekDouble> &outarray,
126  CoeffState coeffstate = eLocal);
127 
128  /// Calculates the result of the multiplication of a global matrix
129  /// of type specified by \a mkey with a vector given by \a inarray.
131  const Array<OneD,const NekDouble> &inarray,
132  Array<OneD, NekDouble> &outarray,
133  CoeffState coeffstate = eLocal);
134 
135  protected:
136  /// (A shared pointer to) the object which contains all the required
137  /// information for the transformation from local to global degrees
138  /// of freedom.
140 
141 
142  /// A enum list declaring how to interpret coeffs,
143  /// i.e. eLocal, eHybrid or eGlobal
145 
146  /// (A shared pointer to) a list which collects all the global
147  /// matrices being assembled, such that they should be constructed
148  /// only once.
150 
151  /// A manager which collects all the global
152  /// linear systems being assembled, such that they should be
153  /// constructed only once.
155 
156  private:
157  /// Returns the linear system specified by \a mkey.
159 
161 
162  /// Solve the linear system specified by the key \a key.
163  void GlobalSolve( const GlobalLinSysKey &key,
164  const Array<OneD, const NekDouble> &rhs,
165  Array<OneD, NekDouble> &inout,
166  const Array<OneD, const NekDouble> &dirForcing
168 
169  /// Perform a forward transform
170  virtual void v_FwdTrans(
171  const Array<OneD, const NekDouble> &inarray,
172  Array<OneD, NekDouble> &outarray,
173  CoeffState coeffstate);
174 
175  virtual void v_MultiplyByInvMassMatrix(
176  const Array<OneD, const NekDouble> &inarray,
177  Array<OneD, NekDouble> &outarray,
178  CoeffState coeffstate);
179 
180  /// Impose the Dirichlet Boundary Conditions on outarray
182 
183  /// Scatters from the global coefficients
184  /// \f$\boldsymbol{\hat{u}}_g\f$ to the local coefficients
185  /// \f$\boldsymbol{\hat{u}}_l\f$.
186  // inline
188  const Array<OneD, const NekDouble> &inarray,
189  Array<OneD,NekDouble> &outarray);
190 
191  MULTI_REGIONS_EXPORT virtual void v_GlobalToLocal(void);
192 
193  /// Gathers the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
194  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
195  // inline
197  const Array<OneD, const NekDouble> &inarray,
198  Array<OneD,NekDouble> &outarray,
199  bool useComm);
200 
201  MULTI_REGIONS_EXPORT virtual void v_LocalToGlobal(bool useComm);
202 
203  virtual void v_HelmSolve(
204  const Array<OneD, const NekDouble> &inarray,
205  Array<OneD, NekDouble> &outarray,
206  const FlagList &flags,
207  const StdRegions::ConstFactorMap &factors,
208  const StdRegions::VarCoeffMap &varcoeff,
209  const Array<OneD, const NekDouble> &dirForcing,
210  const bool PhysSpaceForcing);
211 
212  virtual const Array<OneD,const SpatialDomains
214 
215  virtual void v_BwdTrans(
216  const Array<OneD, const NekDouble> &inarray,
217  Array<OneD, NekDouble> &outarray,
218  CoeffState coeffstate);
219 
220  virtual void v_IProductWRTBase(
221  const Array<OneD, const NekDouble> &inarray,
222  Array<OneD, NekDouble> &outarray,
223  CoeffState coeffstate);
224 
225  /// Calculates the result of the multiplication of a global matrix
226  /// of type specified by \a mkey with a vector given by \a inarray.
227  virtual void v_GeneralMatrixOp(
228  const GlobalMatrixKey &gkey,
229  const Array<OneD,const NekDouble> &inarray,
230  Array<OneD, NekDouble> &outarray,
231  CoeffState coeffstate);
232 
233  virtual void v_ClearGlobalLinSysManager(void);
234 
235  };
236  typedef boost::shared_ptr<ContField1D> ContField1DSharedPtr;
237 
238  // Inline implementations follow
239 
242  {
243  return m_bndCondExpansions;
244  }
245 
248  {
249  return m_bndConditions;
250  }
251 
252 
253  /**
254  * This operation is evaluated as:
255  * \f{tabbing}
256  * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
257  * > > Do \= $i=$ $0,N_m^e-1$ \\
258  * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
259  * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
260  * \boldsymbol{\hat{u}}^{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 gather operation
269  * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
270  * where \f$\mathcal{A}\f$ is the
271  * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
272  *
273  */
274  inline void ContField1D::Assemble()
275  {
276  m_locToGloMap->Assemble(m_coeffs,m_coeffs);
277  }
278 
279  /**
280  * This operation is evaluated as:
281  * \f{tabbing}
282  * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
283  * > > Do \= $i=$ $0,N_m^e-1$ \\
284  * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
285  * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
286  * \boldsymbol{\hat{u}}^{e}[i]$\\
287  * > > continue\\
288  * > continue
289  * \f}
290  * where \a map\f$[e][i]\f$ is the mapping array and \a
291  * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
292  * correct modal connectivity between the different elements (both
293  * these arrays are contained in the data member #m_locToGloMap). This
294  * operation is equivalent to the gather operation
295  * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
296  * where \f$\mathcal{A}\f$ is the
297  * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
298  *
299  * @param inarray An array of size \f$N_\mathrm{eof}\f$
300  * containing the local degrees of freedom
301  * \f$\boldsymbol{x}_l\f$.
302  * @param outarray The resulting global degrees of freedom
303  * \f$\boldsymbol{x}_g\f$ will be stored in this
304  * array of size \f$N_\mathrm{dof}\f$.
305  */
307  const Array<OneD, const NekDouble> &inarray,
308  Array<OneD,NekDouble> &outarray)
309  {
310  m_locToGloMap->Assemble(inarray,outarray);
311  }
312 
313  inline const AssemblyMapCGSharedPtr&
315  {
316  return m_locToGloMap;
317  }
318 
319  } //end of namespace
320 } //end of namespace
321 
322 #endif // MULTIERGIONS_CONTSOLNFIELD1D_H
boost::shared_ptr< ContField1D > ContField1DSharedPtr
Definition: ContField1D.h:236
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:144
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:149
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:252
const AssemblyMapCGSharedPtr & GetLocalToGlobalMap() const
Returns the map from local to global level.
Definition: ContField1D.h:314
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:998
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:241
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:227
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:154
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.
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, const bool PhysSpaceForcing)
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:247
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:86
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
Discretised boundary conditions.
void Assemble()
Assembles the global coefficients from the local coefficients .
Definition: ContField1D.h:274
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.
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)
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:219
boost::shared_ptr< AssemblyMapCG > AssemblyMapCGSharedPtr
Definition: AssemblyMapCG.h:52
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
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:139
virtual const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & v_GetBndConditions()