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
47#include <boost/algorithm/string.hpp>
48
49namespace Nektar
50{
51namespace MultiRegions
52{
53
54/// This class is the abstractio n of a global discontinuous two-
55/// dimensional spectral/hp element expansion which approximates the
56/// solution of a set of partial differential equations.
57class DisContField : public ExpList
58{
59public:
62
63 /// Default constructor.
65
66 /// Constructs a 1D discontinuous field based on a mesh and boundary
67 /// conditions.
71 const std::string &variable, const bool SetUpJustDG = true,
72 const bool DeclareCoeffPhysArrays = true,
74 const std::string bcvariable = "NotSet");
75
76 /// Constructor for a DisContField from a List of subdomains
77 /// New Constructor for arterial network
81 const SpatialDomains::CompositeMap &domain,
83 const std::string &variable, const LibUtilities::CommSharedPtr &comm,
84 bool SetToOneSpaceDimensions = false,
87
88 /// Constructs a 1D discontinuous field based on an existing field.
90 const bool DeclareCoeffPhysArrays = true);
91
94 const std::string &variable, const bool SetUpJustDG = false,
95 const bool DeclareCoeffPhysArrays = true);
96
97 /// Constructs a 1D discontinuous field based on an
98 /// existing field. (needed in order to use ContField(
99 /// const ExpList &In) constructor
101
102 /// Destructor.
104
105 /// For a given key, returns the associated global linear system.
108
109 /// Check to see if expansion has the same BCs as In
111
112 // Return the internal vector which directs whether the normal flux
113 // at the trace defined by Left and Right Adjacent elements
114 // is negated with respect to the segment normal
115 MULTI_REGIONS_EXPORT std::vector<bool> &GetNegatedFluxNormal(void);
116
118 L2_DGDeriv(const int dir, const Array<OneD, const NekDouble> &coeffs,
119 const Array<OneD, const NekDouble> &soln);
121 const Array<OneD, const NekDouble> &coeffs,
122 Array<OneD, NekDouble> &outarray);
123
126 {
128 }
129
130protected:
131 /// The number of boundary segments on which Dirichlet boundary
132 /// conditions are imposed.
134
135 /// An array which contains the information about the boundary
136 /// condition structure definition on the different boundary regions.
138
139 /**
140 * @brief An object which contains the discretised boundary
141 * conditions.
142 *
143 * It is an array of size equal to the number of boundary
144 * regions and consists of entries of the type
145 * MultiRegions#ExpList. Every entry corresponds to the
146 * spectral/hp expansion on a single boundary region. The
147 * values of the boundary conditions are stored as the
148 * coefficients of the one-dimensional expansion.
149 */
151
153
154 /// Interfaces mapping for trace space.
156
157 /// Global boundary matrix.
159
160 /// Trace space storage for points between elements.
162
163 /// Local to global DG mapping for trace space.
165
166 /**
167 * @brief A set storing the global IDs of any boundary Verts.
168 */
169 std::set<int> m_boundaryTraces;
170
171 /**
172 * @brief A map which identifies groups of periodic vertices.
173 */
175
176 /**
177 * @brief A map which identifies pairs of periodic edges.
178 */
180
181 /**
182 * @brief A map which identifies pairs of periodic faces.
183 */
185
186 /**
187 * @brief A vector indicating degress of freedom which need to be
188 * copied from forwards to backwards space in case of a periodic
189 * boundary condition.
190 */
191 std::vector<int> m_periodicFwdCopy;
192 std::vector<int> m_periodicBwdCopy;
193
194 /*
195 * @brief A map identifying which traces are left- and
196 * right-adjacent for DG.
197 */
198 std::vector<bool> m_leftAdjacentTraces;
199
200 /**
201 * Map of local trace (the points at the edge,face of
202 * the element) to the trace space discretisation
203 */
205
206 /// Discretises the boundary conditions.
210 const std::string variable, const bool DeclareCoeffPhysArrays = true);
211
212 /// Generate a associative map of periodic vertices in a mesh.
214 const std::string variable);
215
216 void SetUpDG(const std::string = "DefaultVar",
217 const Collections::ImplementationType ImpType =
219
220 bool IsLeftAdjacentTrace(const int n, const int e);
221
222 virtual ExpListSharedPtr &v_GetTrace() override;
223
224 virtual AssemblyMapDGSharedPtr &v_GetTraceMap(void) override;
225
227 void) const override;
228
229 virtual std::vector<bool> &v_GetLeftAdjacentTraces(void) override;
230
232 Array<OneD, NekDouble> &outarray) override;
233
234 virtual void v_AddFwdBwdTraceIntegral(
237 Array<OneD, NekDouble> &outarray) override;
238
239 virtual void v_AddTraceQuadPhysToField(
242 Array<OneD, NekDouble> &field) override;
243
244 virtual void v_ExtractTracePhys(const Array<OneD, const NekDouble> &inarray,
245 Array<OneD, NekDouble> &outarray) override;
246
247 virtual void v_ExtractTracePhys(Array<OneD, NekDouble> &outarray) override;
248
249 virtual void v_GetLocTraceFromTracePts(
252 Array<OneD, NekDouble> &locTraceFwd,
253 Array<OneD, NekDouble> &locTraceBwd) override;
254
256 const std::string variable);
257
258 virtual std::map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo() override;
259
261 &v_GetBndCondExpansions() override;
262
264 &v_GetBndConditions() override;
265
267 int i) override;
268
270 &v_UpdateBndConditions() override;
271
272 virtual void v_GetBoundaryToElmtMap(Array<OneD, int> &ElmtID,
273 Array<OneD, int> &TraceID) override;
274 virtual void v_GetBndElmtExpansion(
275 int i, std::shared_ptr<ExpList> &result,
276 const bool DeclareCoeffPhysArrays) override;
277
278 virtual void v_Reset() override;
279
280 /// Evaluate all boundary conditions at a given time..
281 virtual void v_EvaluateBoundaryConditions(
282 const NekDouble time = 0.0, const std::string varName = "",
284 const NekDouble x3_in = NekConstants::kNekUnsetDouble) override;
285
286 /// Solve the Helmholtz equation.
288 const Array<OneD, const NekDouble> &inarray,
289 Array<OneD, NekDouble> &outarray,
291 const StdRegions::VarCoeffMap &varcoeff,
292 const MultiRegions::VarFactorsMap &varfactors,
293 const Array<OneD, const NekDouble> &dirForcing,
294 const bool PhysSpaceForcing) override;
295
296 virtual void v_PeriodicBwdCopy(const Array<OneD, const NekDouble> &Fwd,
297 Array<OneD, NekDouble> &Bwd) override;
298
299 virtual void v_FillBwdWithBwdWeight(
300 Array<OneD, NekDouble> &weightave,
301 Array<OneD, NekDouble> &weightjmp) override;
302
304 Array<OneD, NekDouble> &Bwd) override;
305
306 virtual void v_GetFwdBwdTracePhys(const Array<OneD, const NekDouble> &field,
309 bool FillBnd = true,
310 bool PutFwdInBwdOnBCs = false,
311 bool DoExchange = true) override;
312
313 virtual void v_FillBwdWithBoundCond(const Array<OneD, NekDouble> &Fwd,
315 bool PutFwdInBwdOnBCs) override;
316
318 override;
319
320 virtual void v_SetBndCondBwdWeight(const int index,
321 const NekDouble value) override;
322
323 virtual void v_GetPeriodicEntities(PeriodicMap &periodicVerts,
324 PeriodicMap &periodicEdges,
325 PeriodicMap &periodicFaces) override;
326
327 virtual void v_AddTraceIntegralToOffDiag(
328 const Array<OneD, const NekDouble> &FwdFlux,
329 const Array<OneD, const NekDouble> &BwdFlux,
330 Array<OneD, NekDouble> &outarray) override;
331
332private:
333 std::vector<bool> m_negatedFluxNormal;
334
336 const SpatialDomains::CompositeMap &domain,
338 const std::string &variable);
339};
340
341typedef std::shared_ptr<DisContField> DisContFieldSharedPtr;
342
343} // namespace MultiRegions
344} // namespace Nektar
345
346#endif // NEKTAR_LIBS_MULTIREGIONS_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:58
virtual Array< OneD, SpatialDomains::BoundaryConditionShPtr > & v_UpdateBndConditions() override
std::vector< int > m_periodicBwdCopy
Definition: DisContField.h:192
virtual void v_AddTraceIntegral(const Array< OneD, const NekDouble > &Fn, Array< OneD, NekDouble > &outarray) override
Add trace contributions into elemental coefficient spaces.
void GenerateFieldBnd1D(SpatialDomains::BoundaryConditions &bcs, const std::string variable)
PeriodicMap m_periodicEdges
A map which identifies pairs of periodic edges.
Definition: DisContField.h:179
void SetUpDG(const std::string="DefaultVar", const Collections::ImplementationType ImpType=Collections::eNoImpType)
Set up all DG member variables and maps.
PeriodicMap m_periodicFaces
A map which identifies pairs of periodic faces.
Definition: DisContField.h:184
std::set< int > m_boundaryTraces
A set storing the global IDs of any boundary Verts.
Definition: DisContField.h:169
LocTraceToTraceMapSharedPtr m_locTraceToTraceMap
Definition: DisContField.h:204
virtual ~DisContField()
Destructor.
std::vector< bool > m_negatedFluxNormal
Definition: DisContField.h:333
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:164
Array< OneD, int > m_BCtoTraceMap
Definition: DisContField.h:61
void EvaluateHDGPostProcessing(const Array< OneD, const NekDouble > &coeffs, Array< OneD, NekDouble > &outarray)
Evaluate HDG post-processing to increase polynomial order of solution.
virtual void v_GetPeriodicEntities(PeriodicMap &periodicVerts, PeriodicMap &periodicEdges, PeriodicMap &periodicFaces) override
Obtain a copy of the periodic edges and vertices for this field.
GlobalLinSysSharedPtr GetGlobalBndLinSys(const GlobalLinSysKey &mkey)
For a given key, returns the associated global linear system.
virtual const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & v_GetBndConditions() override
virtual MultiRegions::ExpListSharedPtr & v_UpdateBndCondExpansion(int i) override
virtual void v_SetBndCondBwdWeight(const int index, const NekDouble value) override
virtual void v_PeriodicBwdCopy(const Array< OneD, const NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd) override
virtual void v_GetBoundaryToElmtMap(Array< OneD, int > &ElmtID, Array< OneD, int > &TraceID) override
size_t m_numDirBndCondExpansions
The number of boundary segments on which Dirichlet boundary conditions are imposed.
Definition: DisContField.h:133
virtual void v_ExtractTracePhys(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
This method extracts the trace (verts in 1D) from the field inarray and puts the values in outarray.
InterfaceMapDGSharedPtr m_interfaceMap
Interfaces mapping for trace space.
Definition: DisContField.h:155
virtual void v_GetBndElmtExpansion(int i, std::shared_ptr< ExpList > &result, const bool DeclareCoeffPhysArrays) override
virtual void v_FillBwdWithBwdWeight(Array< OneD, NekDouble > &weightave, Array< OneD, NekDouble > &weightjmp) override
Fill the weight with m_bndCondBndWeight.
virtual const Array< OneD, const NekDouble > & v_GetBndCondBwdWeight() override
virtual const Array< OneD, const MultiRegions::ExpListSharedPtr > & v_GetBndCondExpansions() override
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:152
bool SameTypeOfBoundaryConditions(const DisContField &In)
Check to see if expansion has the same BCs as In.
virtual ExpListSharedPtr & v_GetTrace() override
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition structure definition on the diff...
Definition: DisContField.h:137
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) override
Evaluate all boundary conditions at a given time..
virtual void v_AddFwdBwdTraceIntegral(const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &outarray) override
Add trace contributions into elemental coefficient spaces.
virtual const LocTraceToTraceMapSharedPtr & v_GetLocTraceToTraceMap(void) const override
virtual void v_AddTraceIntegralToOffDiag(const Array< OneD, const NekDouble > &FwdFlux, const Array< OneD, const NekDouble > &BwdFlux, Array< OneD, NekDouble > &outarray) override
virtual void v_FillBwdWithBoundCond(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd, bool PutFwdInBwdOnBCs) override
GlobalLinSysMapShPtr m_globalBndMat
Global boundary matrix.
Definition: DisContField.h:158
PeriodicMap m_periodicVerts
A map which identifies groups of periodic vertices.
Definition: DisContField.h:174
ExpListSharedPtr m_trace
Trace space storage for points between elements.
Definition: DisContField.h:161
virtual void v_AddTraceQuadPhysToField(const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &field) override
virtual void v_Reset() override
Reset this field, so that geometry information can be updated.
std::vector< bool > & GetNegatedFluxNormal(void)
DisContField()
Default constructor.
virtual std::vector< bool > & v_GetLeftAdjacentTraces(void) override
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
An object which contains the discretised boundary conditions.
Definition: DisContField.h:150
virtual GlobalLinSysKey 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) override
Solve the Helmholtz equation.
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:191
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...
std::vector< bool > m_leftAdjacentTraces
Definition: DisContField.h:198
NekDouble L2_DGDeriv(const int dir, const Array< OneD, const NekDouble > &coeffs, const Array< OneD, const NekDouble > &soln)
Calculate the error of the derivative using the consistent DG evaluation of .
virtual void v_GetLocTraceFromTracePts(const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &locTraceFwd, Array< OneD, NekDouble > &locTraceBwd) override
void GetLocTraceToTraceMap(LocTraceToTraceMapSharedPtr &LocTraceToTraceMap)
Definition: DisContField.h:124
virtual AssemblyMapDGSharedPtr & v_GetTraceMap(void) override
virtual std::map< int, RobinBCInfoSharedPtr > v_GetRobinBCInfo() override
virtual void v_GetFwdBwdTracePhys(Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd) override
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:102
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:57
std::shared_ptr< AssemblyMapDG > AssemblyMapDGSharedPtr
Definition: AssemblyMapDG.h:48
std::shared_ptr< DisContField > DisContFieldSharedPtr
Definition: DisContField.h:341
std::shared_ptr< InterfaceMapDG > InterfaceMapDGSharedPtr
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:53
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< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:176
std::map< int, CompositeSharedPtr > CompositeMap
Definition: MeshGraph.h:138
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:408
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:352
StdRegions::ConstFactorMap factors
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble