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",
70 
71  /// Copy constructor.
72  MULTI_REGIONS_EXPORT ContField1D(const ContField1D &In);
73 
74  /// Copy constructor.
76  const ExpList1D & In);
77  /// Destructor
79 
80  /// Perform global forward transformation of a function \f$f(x)\f$,
81  // subject to the boundary conditions specified.
83  Array<OneD, NekDouble> &outarray,
84  CoeffState coeffstate = eLocal);
85 
86  /// This function performs the backward transformation of the
87  /// spectral/hp element expansion.
89  Array<OneD, NekDouble> &outarray,
90  CoeffState coeffstate = eLocal);
91 
92  ///
94  const Array<OneD, const NekDouble> &inarray,
95  Array<OneD, NekDouble> &outarray,
96  CoeffState coeffstate = eLocal);
97 
98  /// Return the boundary conditions expansion.
99  // inline
102 
103  // inline
106 
107 
108  /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
109  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
110  // inline
112 
113  /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
114  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
115  // inline
117  Array<OneD,NekDouble> &outarray);
118 
119  /// Returns the map from local to global level.
120  // inline
122 
123  /// Calculates the inner product of a function \f$f(x)\f$ with
124  /// respect to all <em>global</em> expansion modes
125  /// \f$\phi_n^e(x)\f$.
127  Array<OneD, NekDouble> &outarray,
128  CoeffState coeffstate = eLocal);
129 
130  /// Calculates the result of the multiplication of a global matrix
131  /// of type specified by \a mkey with a vector given by \a inarray.
133  const Array<OneD,const NekDouble> &inarray,
134  Array<OneD, NekDouble> &outarray,
135  CoeffState coeffstate = eLocal);
136 
137  protected:
138  /// (A shared pointer to) the object which contains all the required
139  /// information for the transformation from local to global degrees
140  /// of freedom.
142 
143 
144  /// A enum list declaring how to interpret coeffs,
145  /// i.e. eLocal, eHybrid or eGlobal
147 
148  /// (A shared pointer to) a list which collects all the global
149  /// matrices being assembled, such that they should be constructed
150  /// only once.
152 
153  /// A manager which collects all the global
154  /// linear systems being assembled, such that they should be
155  /// constructed only once.
157 
158  private:
159  /// Returns the linear system specified by \a mkey.
161 
163 
164  /// Solve the linear system specified by the key \a key.
165  void GlobalSolve( const GlobalLinSysKey &key,
166  const Array<OneD, const NekDouble> &rhs,
167  Array<OneD, NekDouble> &inout,
168  const Array<OneD, const NekDouble> &dirForcing
170 
171  /// Perform a forward transform
172  virtual void v_FwdTrans(
173  const Array<OneD, const NekDouble> &inarray,
174  Array<OneD, NekDouble> &outarray,
175  CoeffState coeffstate);
176 
177  virtual void v_MultiplyByInvMassMatrix(
178  const Array<OneD, const NekDouble> &inarray,
179  Array<OneD, NekDouble> &outarray,
180  CoeffState coeffstate);
181 
182  /// Impose the Dirichlet Boundary Conditions on outarray
184 
185  /// Scatters from the global coefficients
186  /// \f$\boldsymbol{\hat{u}}_g\f$ to the local coefficients
187  /// \f$\boldsymbol{\hat{u}}_l\f$.
188  // inline
190  const Array<OneD, const NekDouble> &inarray,
191  Array<OneD,NekDouble> &outarray);
192 
193  MULTI_REGIONS_EXPORT virtual void v_GlobalToLocal(void);
194 
195  /// Gathers the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
196  /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
197  // inline
199  const Array<OneD, const NekDouble> &inarray,
200  Array<OneD,NekDouble> &outarray,
201  bool useComm);
202 
203  MULTI_REGIONS_EXPORT virtual void v_LocalToGlobal(bool useComm);
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  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 boost::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
boost::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)
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:146
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:151
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:252
const AssemblyMapCGSharedPtr & GetLocalToGlobalMap() const
Returns the map from local to global level.
Definition: ContField1D.h:316
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:243
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:156
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: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:86
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: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:141
virtual const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & v_GetBndConditions()