Nektar++
LocTraceToTraceMap.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File LocTraceToTraceMap.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: Local Trace to general trace map information
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef MULTIREGIONS_LOCTRACETOTRACEMAP_H
36 #define MULTIREGIONS_LOCTRACETOTRACEMAP_H
37 
38 #include <tuple>
39 
44 
45 namespace Nektar
46 {
47 namespace LocalRegions
48 {
49 class Expansion;
50 typedef std::shared_ptr<Expansion> ExpansionSharedPtr;
51 }
52 
53 namespace MultiRegions
54 {
55 class ExpList;
56 typedef std::shared_ptr<ExpList> ExpListSharedPtr;
57 
59 {
67 };
68 
69 /**
70  * @brief Map holding points distributions required for interpolation of local
71  * traces onto global trace in two and three dimensions.
72  *
73  * The tuple contains four PointsKey entries. All four are used in 3D, but for
74  * 2D only two are used. The first two denote the local elemental points
75  * distributions, the latter the target trace distributions. In the 2D case,
76  * unused trace directions are set to LibUtilities::eNoPointsType.
77  */
78 typedef std::tuple<LibUtilities::PointsKey,
82 
83 struct cmpop
84 {
86  TraceInterpPoints const &b) const
87  {
88  if (std::get<0>(a) < std::get<0>(b))
89  {
90  return true;
91  }
92 
93  if (std::get<0>(b) < std::get<0>(a))
94  {
95  return false;
96  }
97 
98  if (std::get<1>(a) < std::get<1>(b))
99  {
100  return true;
101  }
102  if (std::get<1>(b) < std::get<1>(a))
103  {
104  return false;
105  }
106 
107  if (std::get<2>(a) < std::get<2>(b))
108  {
109  return true;
110  }
111 
112  if (std::get<2>(b) < std::get<2>(a))
113  {
114  return false;
115  }
116 
117  if (std::get<3>(a) < std::get<3>(b))
118  {
119  return true;
120  }
121 
122  return false;
123  }
124 };
125 
126 /**
127  * @brief A helper class to deal with trace operations in the discontinuous
128  * Galerkin code.
129  *
130  * This class sets up a number of mappings to deal with operations that take the
131  * "local trace" of an expansion list -- i.e. the concatenation of all elemental
132  * facets -- to the "global trace" -- where the duplicate facets between
133  * connected elements have been removed.
134  *
135  * <pre>
136  * Elements: Local trace: Global trace:
137  * +----+----+ + +---+ + + +---+ + + +---+ + +---+ +
138  * | | | | | | | | | |
139  * | | | | | | | | | |
140  * +----+----+ + +---+ + + +---+ + + +---+ + +---+ +
141  * </pre>
142  *
143  * There are a number of mappings that are required that this class provides
144  * maps for:
145  *
146  * - Extracting the local trace from the elements in physical space
147  * - Dealing with cases that need interpolation (i.e. where the polynomial
148  * order varies between two elements)
149  * - Adding global trace contributions back into the elements.
150  *
151  * These are documented in the member variables and class functions.
152  */
154 {
155 public:
156  // Constructor
158  const ExpList &locExp,
159  const ExpListSharedPtr &trace,
161  &elmtToTrace,
162  const std::vector<bool> &LeftAdjacents);
163 
164  // Destructor
166 
168  const ExpList &locExp,
169  const ExpListSharedPtr &trace,
171  &elmtToTrace,
172  const std::vector<bool> &LeftAdjacents);
173 
175  const ExpList &locExp,
176  const ExpListSharedPtr &trace,
178  &elmtToTrace,
179  const std::vector<bool> &LeftAdjacents);
180 
182  const Array<OneD, const NekDouble> &field,
183  Array<OneD, NekDouble> faces);
184 
186  const Array<OneD, const NekDouble> &field,
187  Array<OneD, NekDouble> faces);
188 
190  const int dir,
191  const Array<OneD, const NekDouble> &locfaces,
192  Array<OneD, NekDouble> edges);
193 
195  const int dir,
196  const Array<OneD, const NekDouble> &locfaces,
197  Array<OneD, NekDouble> faces);
198 
200  const Array<OneD, const NekDouble> &trace,
201  Array<OneD, NekDouble> &field);
202 
204  const int dir,
205  const Array<OneD, const NekDouble> &race,
206  Array<OneD, NekDouble> &field);
207 
208  /**
209  * @brief Return the number of `forward' local trace points.
210  */
212  {
213  return m_nFwdLocTracePts;
214  }
215 
216  /**
217  * @brief Return the number of local trace points.
218  */
220  {
221  return m_nLocTracePts;
222  }
223 
224 private:
225  /// The number of forward trace points. A local trace element is `forward'
226  /// if it is the side selected for the global trace.
228  /// The number of local trace points.
230  /// The number of global trace points.
232  /// A mapping from the local trace points, arranged as all forwards traces
233  /// followed by backwards traces, to elemental storage.
235  /// A mapping from local trace points to the global trace. Dimension 0 holds
236  /// forward traces, dimension 1 backward.
238  /// A mapping holding the type of interpolation needed for each local trace.
239  /// Dimension 0 holds forward traces, dimension 1 backward.
241  /// Interpolation matrices for either 2D edges or first coordinate of 3D
242  /// face.
244  /// Interpolation matrices for the second coordinate of 3D face, not used in
245  /// 2D.
247  /// Interpolation points key distributions for each of the local to global
248  /// mappings.
250  /// Mapping to hold first coordinate direction endpoint interpolation, which
251  /// can be more optimal if using Gauss-Radau distribution for triangles
253  /// Mapping to hold second coordinate direction endpoint interpolation,
254  /// which can be more optimal if using Gauss-Radau distribution for
255  /// triangles
257  /// Number of edges/faces on a 2D/3D element that require interpolation.
259  /// Number of forwards/backwards trace coefficients.
261  /// Mapping from forwards/backwards trace coefficients to elemental
262  /// coefficient storage.
264  /// Mapping from forwards/backwards trace coefficients to the position of
265  /// the trace element in global storage.
267  /// Sign array for mapping from forwards/backwards trace coefficients to
268  /// local trace storage.
270 };
271 
272 typedef std::shared_ptr<LocTraceToTraceMap> LocTraceToTraceMapSharedPtr;
273 
274 }
275 }
276 
277 #endif
#define MULTI_REGIONS_EXPORT
Defines a specification for a set of points.
Definition: Points.h:60
Base class for all multi-elemental spectral/hp expansions.
Definition: ExpList.h:104
A helper class to deal with trace operations in the discontinuous Galerkin code.
Array< OneD, Array< OneD, int > > m_traceCoeffsToElmtSign
Sign array for mapping from forwards/backwards trace coefficients to local trace storage.
int GetNLocTracePts()
Return the number of local trace points.
Array< OneD, Array< OneD, int > > m_traceCoeffsToElmtTrace
Mapping from forwards/backwards trace coefficients to the position of the trace element in global sto...
LocTraceToTraceMap(const ExpList &locExp, const ExpListSharedPtr &trace, const Array< OneD, Array< OneD, LocalRegions::ExpansionSharedPtr > > &elmtToTrace, const std::vector< bool > &LeftAdjacents)
Set up trace to trace mapping components.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_interpEndPtI0
Mapping to hold first coordinate direction endpoint interpolation, which can be more optimal if using...
void LocTracesFromField(const Array< OneD, const NekDouble > &field, Array< OneD, NekDouble > faces)
Gather the local traces in physical space from field using m_fieldToLocTraceMap.
void Setup2D(const ExpList &locExp, const ExpListSharedPtr &trace, const Array< OneD, Array< OneD, LocalRegions::ExpansionSharedPtr > > &elmtToTrace, const std::vector< bool > &LeftAdjacents)
Set up member variables for a two-dimensional problem.
void Setup3D(const ExpList &locExp, const ExpListSharedPtr &trace, const Array< OneD, Array< OneD, LocalRegions::ExpansionSharedPtr > > &elmtToTrace, const std::vector< bool > &LeftAdjacents)
Set up member variables for a three-dimensional problem.
int m_nLocTracePts
The number of local trace points.
int m_nTracePts
The number of global trace points.
Array< OneD, Array< OneD, int > > m_interpNfaces
Number of edges/faces on a 2D/3D element that require interpolation.
int m_nTraceCoeffs[2]
Number of forwards/backwards trace coefficients.
int m_nFwdLocTracePts
The number of forward trace points. A local trace element is ‘forward’ if it is the side selected for...
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_interpEndPtI1
Mapping to hold second coordinate direction endpoint interpolation, which can be more optimal if usin...
void InterpLocEdgesToTrace(const int dir, const Array< OneD, const NekDouble > &locfaces, Array< OneD, NekDouble > edges)
Interpolate local trace edges to global trace edge point distributions where required.
Array< OneD, Array< OneD, int > > m_traceCoeffsToElmtMap
Mapping from forwards/backwards trace coefficients to elemental coefficient storage.
Array< OneD, Array< OneD, InterpLocTraceToTrace > > m_interpTrace
A mapping holding the type of interpolation needed for each local trace. Dimension 0 holds forward tr...
void FwdLocTracesFromField(const Array< OneD, const NekDouble > &field, Array< OneD, NekDouble > faces)
Gather the forwards-oriented local traces in physical space from field using m_fieldToLocTraceMap.
Array< OneD, Array< OneD, TraceInterpPoints > > m_interpPoints
Interpolation points key distributions for each of the local to global mappings.
Array< OneD, Array< OneD, int > > m_LocTraceToTraceMap
A mapping from local trace points to the global trace. Dimension 0 holds forward traces,...
void AddTraceCoeffsToFieldCoeffs(const Array< OneD, const NekDouble > &trace, Array< OneD, NekDouble > &field)
Add contributions from trace coefficients to the elemental field storage.
Array< OneD, Array< OneD, DNekMatSharedPtr > > m_interpTraceI1
Interpolation matrices for the second coordinate of 3D face, not used in 2D.
Array< OneD, Array< OneD, DNekMatSharedPtr > > m_interpTraceI0
Interpolation matrices for either 2D edges or first coordinate of 3D face.
Array< OneD, int > m_fieldToLocTraceMap
A mapping from the local trace points, arranged as all forwards traces followed by backwards traces,...
int GetNFwdLocTracePts()
Return the number of ‘forward’ local trace points.
void InterpLocFacesToTrace(const int dir, const Array< OneD, const NekDouble > &locfaces, Array< OneD, NekDouble > faces)
Interpolate local faces to trace face point distributions where required.
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition: Expansion.h:65
std::tuple< LibUtilities::PointsKey, LibUtilities::PointsKey, LibUtilities::PointsKey, LibUtilities::PointsKey > TraceInterpPoints
Map holding points distributions required for interpolation of local traces onto global trace in two ...
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< LocTraceToTraceMap > LocTraceToTraceMapSharedPtr
bool operator()(TraceInterpPoints const &a, TraceInterpPoints const &b) const