Nektar++
DisContField.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File DisContField.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 for a discontinuous
32 // LDG-H expansion
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIBS_MULTIREGIONS_DISCONTFIELD1D_H
37 #define NEKTAR_LIBS_MULTIREGIONS_DISCONTFIELD1D_H
38 
41 #include <MultiRegions/ExpList.h>
46 #include <boost/algorithm/string.hpp>
47 
48 namespace Nektar
49 {
50  namespace MultiRegions
51  {
52  /// This class is the abstractio n of a global discontinuous two-
53  /// dimensional spectral/hp element expansion which approximates the
54  /// solution of a set of partial differential equations.
55  class DisContField: public ExpList
56  {
57  public:
60 
61  /// Default constructor.
63 
64  /// Constructs a 1D discontinuous field based on a mesh and boundary
65  /// conditions.
69  const std::string &variable,
70  const bool SetUpJustDG = true,
71  const bool DeclareCoeffPhysArrays = true,
74 
75  /// Constructor for a DisContField from a List of subdomains
76  /// New Constructor for arterial network
80  const SpatialDomains::CompositeMap& domain,
82  const std::string &variable,
83  bool SetToOneSpaceDimensions = false,
86 
87  /// Constructs a 1D discontinuous field based on an existing field.
89  const DisContField &In,
90  const bool DeclareCoeffPhysArrays = true);
91 
93  const DisContField &In,
95  const std::string &variable,
96  const bool SetUpJustDG = false,
97  const bool DeclareCoeffPhysArrays = true);
98 
99  /// Constructs a 1D discontinuous field based on an
100  /// existing field. (needed in order to use ContField(
101  /// const ExpList &In) constructor
103 
104  /// Destructor.
106 
107  /// For a given key, returns the associated global linear system.
109  const GlobalLinSysKey &mkey);
110 
111  /// Check to see if expansion has the same BCs as In
113 
114  // Return the internal vector which directs whether the normal flux
115  // at the trace defined by Left and Right Adjacent elements
116  // is negated with respect to the segment normal
117  MULTI_REGIONS_EXPORT std::vector<bool> &GetNegatedFluxNormal(void);
118 
120  const int dir,
121  const Array<OneD, const NekDouble> &soln);
122 
124  Array<OneD, NekDouble> &outarray);
125 
126  protected:
127  /// The number of boundary segments on which Dirichlet boundary
128  /// conditions are imposed.
130 
131  /**
132  * @brief An object which contains the discretised boundary
133  * conditions.
134  *
135  * It is an array of size equal to the number of boundary
136  * regions and consists of entries of the type
137  * MultiRegions#ExpList. Every entry corresponds to the
138  * spectral/hp expansion on a single boundary region. The
139  * values of the boundary conditions are stored as the
140  * coefficients of the one-dimensional expansion.
141  */
143 
145 
146  /// An array which contains the information about the boundary
147  /// condition on the different boundary regions.
149 
150  /// Global boundary matrix.
152 
153  /// Trace space storage for points between elements.
155 
156  /// Local to global DG mapping for trace space.
158 
159  /**
160  * @brief A set storing the global IDs of any boundary Verts.
161  */
162  std::set<int> m_boundaryTraces;
163 
164  /**
165  * @brief A map which identifies groups of periodic vertices.
166  */
168 
169  /**
170  * @brief A map which identifies pairs of periodic edges.
171  */
173 
174  /**
175  * @brief A map which identifies pairs of periodic faces.
176  */
178 
179  /**
180  * @brief A vector indicating degress of freedom which need to be
181  * copied from forwards to backwards space in case of a periodic
182  * boundary condition.
183  */
184  std::vector<int> m_periodicFwdCopy;
185  std::vector<int> m_periodicBwdCopy;
186 
187  /*
188  * @brief A map identifying which traces are left- and
189  * right-adjacent for DG.
190  */
191  std::vector<bool> m_leftAdjacentTraces;
192 
193  /**
194  * Map of local trace (the points at the edge,face of
195  * the element) to the trace space discretisation
196  */
198 
199  /// Discretises the boundary conditions.
201  const SpatialDomains::MeshGraphSharedPtr &graph1D,
203  const std::string variable,
204  const bool DeclareCoeffPhysArrays = true);
205 
206 
207  /// Generate a associative map of periodic vertices in a mesh.
208  void FindPeriodicTraces
210  const std::string variable);
211 
213  {
215  {
216  SetUpDG();
217  }
218 
219  return m_trace;
220  }
221 
223  {
224  return m_traceMap;
225  }
226 
227  virtual const LocTraceToTraceMapSharedPtr
229  {
230  return m_locTraceToTraceMap;
231  }
232 
233  virtual void v_AddTraceIntegral(
235  Array<OneD, NekDouble> &outarray);
236  virtual void v_AddFwdBwdTraceIntegral(
237  const Array<OneD, const NekDouble> &Fwd,
238  const Array<OneD, const NekDouble> &Bwd,
239  Array<OneD, NekDouble> &outarray);
240  virtual void v_AddTraceQuadPhysToField(
241  const Array<OneD, const NekDouble> &Fwd,
242  const Array<OneD, const NekDouble> &Bwd,
243  Array<OneD, NekDouble> &field);
244  virtual void v_ExtractTracePhys(
245  Array<OneD, NekDouble> &outarray);
246  virtual void v_ExtractTracePhys(
247  const Array<OneD, const NekDouble> &inarray,
248  Array<OneD, NekDouble> &outarray);
249 
250  virtual void v_GetLocTraceFromTracePts(
251  const Array<OneD, const NekDouble> &Fwd,
252  const Array<OneD, const NekDouble> &Bwd,
253  Array<OneD, NekDouble> &locTraceFwd,
254  Array<OneD, NekDouble> &locTraceBwd);
255 
256 #if 0
257  /// Populates the list of boundary condition expansions in multidomain case.
258  void SetMultiDomainBoundaryConditionExpansion(
259  const SpatialDomains::MeshGraphSharedPtr &graph1D,
261  const std::string variable,
263  &bndCondExpansions,
264  Array<OneD, SpatialDomains
265  ::BoundaryConditionShPtr> &bndConditions,
266  int subdomain);
267 #endif
268 
271  const std::string variable);
272 
273  virtual std::map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo();
274 
277  {
278  return m_bndCondExpansions;
279  }
280 
283  {
284  return m_bndConditions;
285  }
286 
289  {
290  return m_bndCondExpansions[i];
291  }
292 
295  {
296  return m_bndConditions;
297  }
298 
299  virtual void v_GetBoundaryToElmtMap(
300  Array<OneD,int> &ElmtID, Array<OneD,int> &TraceID);
301  virtual void v_GetBndElmtExpansion(int i,
302  std::shared_ptr<ExpList> &result,
303  const bool DeclareCoeffPhysArrays);
304  virtual void v_Reset();
305 
306  /// Evaluate all boundary conditions at a given time..
307  virtual void v_EvaluateBoundaryConditions(
308  const NekDouble time = 0.0,
309  const std::string varName = "",
312 
313  /// Solve the Helmholtz equation.
314  virtual void v_HelmSolve(
315  const Array<OneD, const NekDouble> &inarray,
316  Array<OneD, NekDouble> &outarray,
317  const StdRegions::ConstFactorMap &factors,
318  const StdRegions::VarCoeffMap &varcoeff,
319  const MultiRegions::VarFactorsMap &varfactors,
320  const Array<OneD, const NekDouble> &dirForcing,
321  const bool PhysSpaceForcing);
322 
323  inline virtual void v_PeriodicBwdCopy(
324  const Array<OneD, const NekDouble> &Fwd,
326 
327  virtual void v_FillBwdWithBwdWeight(
328  Array<OneD, NekDouble> &weightave,
329  Array<OneD, NekDouble> &weightjmp);
330 
331  inline virtual void v_GetFwdBwdTracePhys(
334 
335  virtual void v_GetFwdBwdTracePhys(
336  const Array<OneD, const NekDouble> &field,
339  bool FillBnd = true,
340  bool PutFwdInBwdOnBCs = false,
341  bool DoExchange = true);
342  virtual void v_FillBwdWithBoundCond(
343  const Array<OneD, NekDouble> &Fwd,
345  bool PutFwdInBwdOnBCs);
346 
347  inline virtual const Array<OneD,const NekDouble>
349 
350  inline virtual void v_SetBndCondBwdWeight(
351  const int index,
352  const NekDouble value);
353 
354  void SetUpDG(const std::string = "DefaultVar");
355  bool IsLeftAdjacentTrace(const int n, const int e);
356 
357  /**
358  * @brief Obtain a copy of the periodic edges and vertices for this
359  * field.
360  */
361  virtual void v_GetPeriodicEntities(
362  PeriodicMap &periodicVerts,
363  PeriodicMap &periodicEdges,
364  PeriodicMap &periodicFaces)
365  {
366  periodicVerts = m_periodicVerts;
367  periodicEdges = m_periodicEdges;
368  periodicFaces = m_periodicFaces;
369  }
370 
371  private:
372 
373  std::vector<bool> m_negatedFluxNormal;
374 
378  const std::string &variable);
379  virtual void v_AddTraceIntegralToOffDiag(
380  const Array<OneD, const NekDouble> &FwdFlux,
381  const Array<OneD, const NekDouble> &BwdFlux,
382  Array<OneD, NekDouble> &outarray);
383  };
384 
385  typedef std::shared_ptr<DisContField> DisContFieldSharedPtr;
386 
387  /**
388  * Generate the forward or backward state for each trace point.
389  * @param Fwd Forward state.
390  * @param Bwd Backward state.
391  */
394  {
395  v_GetFwdBwdTracePhys(m_phys,Fwd,Bwd);
396  }
397 
400  {
401  return m_bndCondBndWeight;
402  }
403 
405  const int index,
406  const NekDouble value)
407  {
408  m_bndCondBndWeight[index] = value;
409  }
410 
412  const Array<OneD, const NekDouble> &Fwd,
414  {
415  for (int n = 0; n < m_periodicFwdCopy.size(); ++n)
416  {
417  Bwd[m_periodicBwdCopy[n]] = Fwd[m_periodicFwdCopy[n]];
418  }
419  }
420 
421  } //end of namespace
422 } //end of namespace
423 
424 #endif // MULTIERGIONS_DISCONTFIELD1D_H
#define MULTI_REGIONS_EXPORT
This class is the abstractio n of a global discontinuous two- dimensional spectral/hp element expansi...
Definition: DisContField.h:56
virtual const Array< OneD, const NekDouble > & v_GetBndCondBwdWeight()
Definition: DisContField.h:399
std::vector< int > m_periodicBwdCopy
Definition: DisContField.h:185
void GenerateFieldBnd1D(SpatialDomains::BoundaryConditions &bcs, const std::string variable)
PeriodicMap m_periodicEdges
A map which identifies pairs of periodic edges.
Definition: DisContField.h:172
PeriodicMap m_periodicFaces
A map which identifies pairs of periodic faces.
Definition: DisContField.h:177
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition on the different boundary region...
Definition: DisContField.h:148
virtual const LocTraceToTraceMapSharedPtr & v_GetLocTraceToTraceMap(void) const
Definition: DisContField.h:228
std::set< int > m_boundaryTraces
A set storing the global IDs of any boundary Verts.
Definition: DisContField.h:162
LocTraceToTraceMapSharedPtr m_locTraceToTraceMap
Definition: DisContField.h:197
virtual MultiRegions::ExpListSharedPtr & v_UpdateBndCondExpansion(int i)
Definition: DisContField.h:288
virtual ~DisContField()
Destructor.
std::vector< bool > m_negatedFluxNormal
Definition: DisContField.h:373
SpatialDomains::BoundaryConditionsSharedPtr GetDomainBCs(const SpatialDomains::CompositeMap &domain, const SpatialDomains::BoundaryConditions &Allbcs, const std::string &variable)
AssemblyMapDGSharedPtr m_traceMap
Local to global DG mapping for trace space.
Definition: DisContField.h:157
virtual void v_AddTraceIntegralToOffDiag(const Array< OneD, const NekDouble > &FwdFlux, const Array< OneD, const NekDouble > &BwdFlux, Array< OneD, NekDouble > &outarray)
Array< OneD, int > m_BCtoTraceMap
Definition: DisContField.h:59
virtual ExpListSharedPtr & v_GetTrace()
Definition: DisContField.h:212
GlobalLinSysSharedPtr GetGlobalBndLinSys(const GlobalLinSysKey &mkey)
For a given key, returns the associated global linear system.
virtual AssemblyMapDGSharedPtr & v_GetTraceMap(void)
Definition: DisContField.h:222
virtual void v_SetBndCondBwdWeight(const int index, const NekDouble value)
Definition: DisContField.h:404
virtual std::map< int, RobinBCInfoSharedPtr > v_GetRobinBCInfo()
int m_numDirBndCondExpansions
The number of boundary segments on which Dirichlet boundary conditions are imposed.
Definition: DisContField.h:129
virtual Array< OneD, SpatialDomains::BoundaryConditionShPtr > & v_UpdateBndConditions()
Definition: DisContField.h:294
void EvaluateHDGPostProcessing(Array< OneD, NekDouble > &outarray)
Evaluate HDG post-processing to increase polynomial order of solution.
virtual void v_PeriodicBwdCopy(const Array< OneD, const NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
Definition: DisContField.h:411
virtual const Array< OneD, const MultiRegions::ExpListSharedPtr > & v_GetBndCondExpansions()
Definition: DisContField.h:276
NekDouble L2_DGDeriv(const int dir, const Array< OneD, const NekDouble > &soln)
Calculate the error of the derivative using the consistent DG evaluation of .
virtual void v_AddTraceIntegral(const Array< OneD, const NekDouble > &Fn, Array< OneD, NekDouble > &outarray)
Add trace contributions into elemental coefficient spaces.
virtual void v_GetFwdBwdTracePhys(Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
Definition: DisContField.h:392
void FindPeriodicTraces(const SpatialDomains::BoundaryConditions &bcs, const std::string variable)
Generate a associative map of periodic vertices in a mesh.
bool SameTypeOfBoundaryConditions(const DisContField &In)
Check to see if expansion has the same BCs as In.
virtual void v_GetLocTraceFromTracePts(const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &locTraceFwd, Array< OneD, NekDouble > &locTraceBwd)
Array< OneD, NekDouble > m_bndCondBndWeight
Definition: DisContField.h:144
virtual void v_AddFwdBwdTraceIntegral(const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &outarray)
Add trace contributions into elemental coefficient spaces.
virtual void v_Reset()
Reset this field, so that geometry information can be updated.
virtual void v_GetBndElmtExpansion(int i, std::shared_ptr< ExpList > &result, const bool DeclareCoeffPhysArrays)
virtual void v_FillBwdWithBwdWeight(Array< OneD, NekDouble > &weightave, Array< OneD, NekDouble > &weightjmp)
Fill the weight with m_bndCondBndWeight.
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
An object which contains the discretised boundary conditions.
Definition: DisContField.h:142
GlobalLinSysMapShPtr m_globalBndMat
Global boundary matrix.
Definition: DisContField.h:151
virtual void v_ExtractTracePhys(Array< OneD, NekDouble > &outarray)
PeriodicMap m_periodicVerts
A map which identifies groups of periodic vertices.
Definition: DisContField.h:167
virtual void v_AddTraceQuadPhysToField(const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &field)
ExpListSharedPtr m_trace
Trace space storage for points between elements.
Definition: DisContField.h:154
virtual void v_EvaluateBoundaryConditions(const NekDouble time=0.0, const std::string varName="", const NekDouble x2_in=NekConstants::kNekUnsetDouble, const NekDouble x3_in=NekConstants::kNekUnsetDouble)
Evaluate all boundary conditions at a given time..
virtual void v_GetBoundaryToElmtMap(Array< OneD, int > &ElmtID, Array< OneD, int > &TraceID)
std::vector< bool > & GetNegatedFluxNormal(void)
DisContField()
Default constructor.
virtual void v_GetPeriodicEntities(PeriodicMap &periodicVerts, PeriodicMap &periodicEdges, PeriodicMap &periodicFaces)
Obtain a copy of the periodic edges and vertices for this field.
Definition: DisContField.h:361
virtual const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & v_GetBndConditions()
Definition: DisContField.h:282
void SetUpDG(const std::string="DefaultVar")
Set up all DG member variables and maps.
std::vector< int > m_periodicFwdCopy
A vector indicating degress of freedom which need to be copied from forwards to backwards space in ca...
Definition: DisContField.h:184
bool IsLeftAdjacentTrace(const int n, const int e)
virtual void v_FillBwdWithBoundCond(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd, bool PutFwdInBwdOnBCs)
std::vector< bool > m_leftAdjacentTraces
Definition: DisContField.h:191
virtual void v_HelmSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const MultiRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing)
Solve the Helmholtz equation.
void GenerateBoundaryConditionExpansion(const SpatialDomains::MeshGraphSharedPtr &graph1D, const SpatialDomains::BoundaryConditions &bcs, const std::string variable, const bool DeclareCoeffPhysArrays=true)
Discretises the boundary conditions.
Base class for all multi-elemental spectral/hp expansions.
Definition: ExpList.h:107
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
Definition: ExpList.h:1269
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< AssemblyMapDG > AssemblyMapDGSharedPtr
Definition: AssemblyMapDG.h:47
static ExpListSharedPtr NullExpListSharedPtr
Definition: ExpList.h:1792
std::shared_ptr< DisContField > DisContFieldSharedPtr
Definition: DisContField.h:385
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:50
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< LocTraceToTraceMap > LocTraceToTraceMapSharedPtr
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
std::map< int, std::vector< PeriodicEntity > > PeriodicMap
std::shared_ptr< GlobalLinSysMap > GlobalLinSysMapShPtr
Pointer to a GlobalLinSys/key map.
Definition: GlobalLinSys.h:57
static const NekDouble kNekUnsetDouble
std::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
Definition: Conditions.h:289
std::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
Definition: Conditions.h:219
std::map< int, CompositeSharedPtr > CompositeMap
Definition: MeshGraph.h:138
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:272
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:314
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble