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, const bool SetUpJustDG = true,
70  const bool DeclareCoeffPhysArrays = true,
72  const std::string bcvariable = "NotSet");
73 
74  /// Constructor for a DisContField from a List of subdomains
75  /// New Constructor for arterial network
79  const SpatialDomains::CompositeMap &domain,
81  const std::string &variable, const LibUtilities::CommSharedPtr &comm,
82  bool SetToOneSpaceDimensions = false,
83  const Collections::ImplementationType ImpType =
85 
86  /// Constructs a 1D discontinuous field based on an existing field.
88  const bool DeclareCoeffPhysArrays = true);
89 
91  const DisContField &In, const SpatialDomains::MeshGraphSharedPtr &graph,
92  const std::string &variable, const bool SetUpJustDG = false,
93  const bool DeclareCoeffPhysArrays = true);
94 
95  /// Constructs a 1D discontinuous field based on an
96  /// existing field. (needed in order to use ContField(
97  /// const ExpList &In) constructor
99 
100  /// Destructor.
102 
103  /// For a given key, returns the associated global linear system.
105  GetGlobalBndLinSys(const GlobalLinSysKey &mkey);
106 
107  /// Check to see if expansion has the same BCs as In
109 
110  // Return the internal vector which directs whether the normal flux
111  // at the trace defined by Left and Right Adjacent elements
112  // is negated with respect to the segment normal
113  MULTI_REGIONS_EXPORT std::vector<bool> &GetNegatedFluxNormal(void);
114 
116  L2_DGDeriv(const int dir, const Array<OneD, const NekDouble> &soln);
117 
119  Array<OneD, NekDouble> &outarray);
120 
123  {
125  }
126 
127 protected:
128  /// The number of boundary segments on which Dirichlet boundary
129  /// conditions are imposed.
131 
132  /**
133  * @brief An object which contains the discretised boundary
134  * conditions.
135  *
136  * It is an array of size equal to the number of boundary
137  * regions and consists of entries of the type
138  * MultiRegions#ExpList. Every entry corresponds to the
139  * spectral/hp expansion on a single boundary region. The
140  * values of the boundary conditions are stored as the
141  * coefficients of the one-dimensional expansion.
142  */
144 
146 
147  /// An array which contains the information about the boundary
148  /// condition on the different boundary regions.
150 
151  /// Global boundary matrix.
153 
154  /// Trace space storage for points between elements.
156 
157  /// Local to global DG mapping for trace space.
159 
160  /**
161  * @brief A set storing the global IDs of any boundary Verts.
162  */
163  std::set<int> m_boundaryTraces;
164 
165  /**
166  * @brief A map which identifies groups of periodic vertices.
167  */
169 
170  /**
171  * @brief A map which identifies pairs of periodic edges.
172  */
174 
175  /**
176  * @brief A map which identifies pairs of periodic faces.
177  */
179 
180  /**
181  * @brief A vector indicating degress of freedom which need to be
182  * copied from forwards to backwards space in case of a periodic
183  * boundary condition.
184  */
185  std::vector<int> m_periodicFwdCopy;
186  std::vector<int> m_periodicBwdCopy;
187 
188  /*
189  * @brief A map identifying which traces are left- and
190  * right-adjacent for DG.
191  */
192  std::vector<bool> m_leftAdjacentTraces;
193 
194  /**
195  * Map of local trace (the points at the edge,face of
196  * the element) to the trace space discretisation
197  */
199 
200  /// Discretises the boundary conditions.
202  const SpatialDomains::MeshGraphSharedPtr &graph1D,
204  const std::string variable, const bool DeclareCoeffPhysArrays = true);
205 
206  /// Generate a associative map of periodic vertices in a mesh.
208  const std::string variable);
209 
211  {
213  {
214  SetUpDG();
215  }
216 
217  return m_trace;
218  }
219 
221  {
222  return m_traceMap;
223  }
224 
226  void) const
227  {
228  return m_locTraceToTraceMap;
229  }
230 
231  // Return the internal vector which identifieds if trace
232  // is left adjacent definiing which trace the normal
233  // points otwards from
234  virtual std::vector<bool> &v_GetLeftAdjacentTraces(void);
235 
236  virtual void v_AddTraceIntegral(const Array<OneD, const NekDouble> &Fn,
237  Array<OneD, NekDouble> &outarray);
238 
239  virtual void v_AddFwdBwdTraceIntegral(
240  const Array<OneD, const NekDouble> &Fwd,
241  const Array<OneD, const NekDouble> &Bwd,
242  Array<OneD, NekDouble> &outarray);
243 
244  virtual void v_AddTraceQuadPhysToField(
245  const Array<OneD, const NekDouble> &Fwd,
247  virtual void v_ExtractTracePhys(Array<OneD, NekDouble> &outarray);
248  virtual void v_ExtractTracePhys(const Array<OneD, const NekDouble> &inarray,
249  Array<OneD, NekDouble> &outarray);
250 
251  virtual void v_GetLocTraceFromTracePts(
252  const Array<OneD, const NekDouble> &Fwd,
253  const Array<OneD, const NekDouble> &Bwd,
254  Array<OneD, NekDouble> &locTraceFwd,
255  Array<OneD, NekDouble> &locTraceBwd);
256 
257 #if 0
258  /// Populates the list of boundary condition expansions in multidomain case.
259  void SetMultiDomainBoundaryConditionExpansion(
260  const SpatialDomains::MeshGraphSharedPtr &graph1D,
262  const std::string variable,
264  &bndCondExpansions,
265  Array<OneD, SpatialDomains
266  ::BoundaryConditionShPtr> &bndConditions,
267  int subdomain);
268 #endif
269 
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 
288  {
289  return m_bndCondExpansions[i];
290  }
291 
294  {
295  return m_bndConditions;
296  }
297 
298  virtual void v_GetBoundaryToElmtMap(Array<OneD, int> &ElmtID,
299  Array<OneD, int> &TraceID);
300  virtual void v_GetBndElmtExpansion(int i, std::shared_ptr<ExpList> &result,
301  const bool DeclareCoeffPhysArrays);
302  virtual void v_Reset();
303 
304  /// Evaluate all boundary conditions at a given time..
305  virtual void v_EvaluateBoundaryConditions(
306  const NekDouble time = 0.0, const std::string varName = "",
309 
310  /// Solve the Helmholtz equation.
311  virtual void v_HelmSolve(const Array<OneD, const NekDouble> &inarray,
312  Array<OneD, NekDouble> &outarray,
313  const StdRegions::ConstFactorMap &factors,
314  const StdRegions::VarCoeffMap &varcoeff,
315  const MultiRegions::VarFactorsMap &varfactors,
316  const Array<OneD, const NekDouble> &dirForcing,
317  const bool PhysSpaceForcing);
318 
319  inline virtual void v_PeriodicBwdCopy(
321 
322  virtual void v_FillBwdWithBwdWeight(Array<OneD, NekDouble> &weightave,
323  Array<OneD, NekDouble> &weightjmp);
324 
325  inline virtual void v_GetFwdBwdTracePhys(Array<OneD, NekDouble> &Fwd,
327 
328  virtual void v_GetFwdBwdTracePhys(const Array<OneD, const NekDouble> &field,
331  bool FillBnd = true,
332  bool PutFwdInBwdOnBCs = false,
333  bool DoExchange = true);
334  virtual void v_FillBwdWithBoundCond(const Array<OneD, NekDouble> &Fwd,
336  bool PutFwdInBwdOnBCs);
337 
338  inline virtual const Array<OneD, const NekDouble> &v_GetBndCondBwdWeight();
339 
340  inline virtual void v_SetBndCondBwdWeight(const int index,
341  const NekDouble value);
342 
343  void SetUpDG(const std::string = "DefaultVar");
344  bool IsLeftAdjacentTrace(const int n, const int e);
345 
346  /**
347  * @brief Obtain a copy of the periodic edges and vertices for this
348  * field.
349  */
350  virtual void v_GetPeriodicEntities(PeriodicMap &periodicVerts,
351  PeriodicMap &periodicEdges,
352  PeriodicMap &periodicFaces)
353  {
354  periodicVerts = m_periodicVerts;
355  periodicEdges = m_periodicEdges;
356  periodicFaces = m_periodicFaces;
357  }
358 
359 private:
360  std::vector<bool> m_negatedFluxNormal;
361 
363  const SpatialDomains::CompositeMap &domain,
365  const std::string &variable);
366  virtual void v_AddTraceIntegralToOffDiag(
367  const Array<OneD, const NekDouble> &FwdFlux,
368  const Array<OneD, const NekDouble> &BwdFlux,
369  Array<OneD, NekDouble> &outarray);
370 };
371 
372 inline std::vector<bool> &DisContField::v_GetLeftAdjacentTraces(void)
373 {
374  return m_leftAdjacentTraces;
375 }
376 
377 typedef std::shared_ptr<DisContField> DisContFieldSharedPtr;
378 
379 /**
380  * Generate the forward or backward state for each trace point.
381  * @param Fwd Forward state.
382  * @param Bwd Backward state.
383  */
386 {
387  v_GetFwdBwdTracePhys(m_phys, Fwd, Bwd);
388 }
389 
391 {
392  return m_bndCondBndWeight;
393 }
394 
395 void DisContField::v_SetBndCondBwdWeight(const int index, const NekDouble value)
396 {
397  m_bndCondBndWeight[index] = value;
398 }
399 
402 {
403  for (int n = 0; n < m_periodicFwdCopy.size(); ++n)
404  {
405  Bwd[m_periodicBwdCopy[n]] = Fwd[m_periodicFwdCopy[n]];
406  }
407 }
408 
409 } // namespace MultiRegions
410 } // namespace Nektar
411 
412 #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:390
std::vector< int > m_periodicBwdCopy
Definition: DisContField.h:186
void GenerateFieldBnd1D(SpatialDomains::BoundaryConditions &bcs, const std::string variable)
PeriodicMap m_periodicEdges
A map which identifies pairs of periodic edges.
Definition: DisContField.h:173
PeriodicMap m_periodicFaces
A map which identifies pairs of periodic faces.
Definition: DisContField.h:178
virtual const LocTraceToTraceMapSharedPtr & v_GetLocTraceToTraceMap(void) const
Definition: DisContField.h:225
std::set< int > m_boundaryTraces
A set storing the global IDs of any boundary Verts.
Definition: DisContField.h:163
LocTraceToTraceMapSharedPtr m_locTraceToTraceMap
Definition: DisContField.h:198
virtual MultiRegions::ExpListSharedPtr & v_UpdateBndCondExpansion(int i)
Definition: DisContField.h:287
virtual ~DisContField()
Destructor.
std::vector< bool > m_negatedFluxNormal
Definition: DisContField.h:360
virtual const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & v_GetBndConditions()
Definition: DisContField.h:282
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:158
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:210
GlobalLinSysSharedPtr GetGlobalBndLinSys(const GlobalLinSysKey &mkey)
For a given key, returns the associated global linear system.
virtual AssemblyMapDGSharedPtr & v_GetTraceMap(void)
Definition: DisContField.h:220
virtual void v_SetBndCondBwdWeight(const int index, const NekDouble value)
Definition: DisContField.h:395
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:130
virtual Array< OneD, SpatialDomains::BoundaryConditionShPtr > & v_UpdateBndConditions()
Definition: DisContField.h:293
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:400
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:384
void FindPeriodicTraces(const SpatialDomains::BoundaryConditions &bcs, const std::string variable)
Generate a associative map of periodic vertices in a mesh.
Array< OneD, NekDouble > m_bndCondBndWeight
Definition: DisContField.h:145
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)
virtual std::vector< bool > & v_GetLeftAdjacentTraces(void)
Definition: DisContField.h:372
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition on the different boundary region...
Definition: DisContField.h:149
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.
GlobalLinSysMapShPtr m_globalBndMat
Global boundary matrix.
Definition: DisContField.h:152
virtual void v_ExtractTracePhys(Array< OneD, NekDouble > &outarray)
PeriodicMap m_periodicVerts
A map which identifies groups of periodic vertices.
Definition: DisContField.h:168
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:155
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.
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
An object which contains the discretised boundary conditions.
Definition: DisContField.h:143
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:350
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:185
bool IsLeftAdjacentTrace(const int n, const int e)
This routine determines if an element is to the "left" of the adjacent trace, which arises from the i...
virtual void v_FillBwdWithBoundCond(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd, bool PutFwdInBwdOnBCs)
std::vector< bool > m_leftAdjacentTraces
Definition: DisContField.h:192
void GetLocTraceToTraceMap(LocTraceToTraceMapSharedPtr &LocTraceToTraceMap)
Definition: DisContField.h:121
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:101
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
Definition: ExpList.h:1175
A helper class to deal with trace operations in the discontinuous Galerkin code.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:54
std::shared_ptr< AssemblyMapDG > AssemblyMapDGSharedPtr
Definition: AssemblyMapDG.h:47
static ExpListSharedPtr NullExpListSharedPtr
Definition: ExpList.h:1633
std::shared_ptr< DisContField > DisContFieldSharedPtr
Definition: DisContField.h:377
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:212
std::map< int, CompositeSharedPtr > CompositeMap
Definition: MeshGraph.h:138
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:172
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:240
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:282
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble