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
50{
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.
55class DisContField : public ExpList
56{
57public:
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,
85
86 /// Constructs a 1D discontinuous field based on an existing field.
88 const bool DeclareCoeffPhysArrays = true);
89
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.
106
107 /// Check to see if expansion has the same BCs as In
109 const DisContField &In);
110
111 // Return the internal vector which directs whether the normal flux
112 // at the trace defined by Left and Right Adjacent elements
113 // is negated with respect to the segment normal
114 MULTI_REGIONS_EXPORT std::vector<bool> &GetNegatedFluxNormal(void);
115
117 L2_DGDeriv(const int dir, const Array<OneD, const NekDouble> &coeffs,
118 const Array<OneD, const NekDouble> &soln);
120 const Array<OneD, const NekDouble> &coeffs,
121 Array<OneD, NekDouble> &outarray);
122
125 {
127 }
128
133 &bndCond,
134 const Array<OneD, const ExpListSharedPtr> &BndCondExp);
135
136protected:
137 /// The number of boundary segments on which Dirichlet boundary
138 /// conditions are imposed.
140
141 /// An array which contains the information about the boundary
142 /// condition structure definition on the different boundary regions.
144
145 /**
146 * @brief An object which contains the discretised boundary
147 * conditions.
148 *
149 * It is an array of size equal to the number of boundary
150 * regions and consists of entries of the type
151 * MultiRegions#ExpList. Every entry corresponds to the
152 * spectral/hp expansion on a single boundary region. The
153 * values of the boundary conditions are stored as the
154 * coefficients of the one-dimensional expansion.
155 */
157
159
160 /// Interfaces mapping for trace space.
162
163 /// Global boundary matrix.
165
166 /// Trace space storage for points between elements.
168
169 /// Local to global DG mapping for trace space.
171
172 /**
173 * @brief A set storing the global IDs of any boundary Verts.
174 */
175 std::set<int> m_boundaryTraces;
176
177 /**
178 * @brief A map which identifies groups of periodic vertices.
179 */
181
182 /**
183 * @brief A map which identifies pairs of periodic edges.
184 */
186
187 /**
188 * @brief A map which identifies pairs of periodic faces.
189 */
191
192 /**
193 * @brief A vector indicating degress of freedom which need to be
194 * copied from forwards to backwards space in case of a periodic
195 * boundary condition.
196 */
197 std::vector<int> m_periodicFwdCopy;
198 std::vector<int> m_periodicBwdCopy;
199
200 /*
201 * @brief A map identifying which traces are left- and
202 * right-adjacent for DG.
203 */
204 std::vector<bool> m_leftAdjacentTraces;
205
206 /**
207 * Map of local trace (the points at the edge,face of
208 * the element) to the trace space discretisation
209 */
211
212 /// Discretises the boundary conditions.
216 const std::string variable, const bool DeclareCoeffPhysArrays = true);
217
218 /// Generate a associative map of periodic vertices in a mesh.
220 const std::string variable);
221
222 void SetUpDG(const std::string = "DefaultVar",
223 const Collections::ImplementationType ImpType =
225
226 bool IsLeftAdjacentTrace(const int n, const int e);
227
228 ExpListSharedPtr &v_GetTrace() override;
229
231
233 void) const override;
234
235 std::vector<bool> &v_GetLeftAdjacentTraces(void) override;
236
238 Array<OneD, NekDouble> &outarray) override;
239
242 Array<OneD, NekDouble> &outarray) override;
243
246 Array<OneD, NekDouble> &field) override;
247
249 Array<OneD, NekDouble> &outarray) override;
250
251 void v_ExtractTracePhys(Array<OneD, NekDouble> &outarray) override;
252
256 Array<OneD, NekDouble> &locTraceFwd,
257 Array<OneD, NekDouble> &locTraceBwd) override;
258
260 const std::string variable);
261
262 std::map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo() override;
263
265 &v_GetBndCondExpansions() override;
266
268 &v_GetBndConditions() override;
269
271
273 override;
274
276 Array<OneD, int> &TraceID) override;
277 void v_GetBndElmtExpansion(int i, std::shared_ptr<ExpList> &result,
278 const bool DeclareCoeffPhysArrays) override;
279
280 void v_Reset() override;
281
282 /// Evaluate all boundary conditions at a given time..
284 const NekDouble time = 0.0, const std::string varName = "",
286 const NekDouble x3_in = NekConstants::kNekUnsetDouble) override;
287
288 /// Solve the Helmholtz equation.
290 Array<OneD, NekDouble> &outarray,
292 const StdRegions::VarCoeffMap &varcoeff,
293 const MultiRegions::VarFactorsMap &varfactors,
294 const Array<OneD, const NekDouble> &dirForcing,
295 const bool PhysSpaceForcing) override;
296
298 Array<OneD, NekDouble> &Bwd) override;
299
301 Array<OneD, NekDouble> &weightjmp) override;
302
304 Array<OneD, NekDouble> &Bwd) override;
305
308 Array<OneD, NekDouble> &Bwd, bool FillBnd = true,
309 bool PutFwdInBwdOnBCs = false,
310 bool DoExchange = true) override;
311
314 bool PutFwdInBwdOnBCs) override;
315
319 &bndConditions,
320 const Array<OneD, const ExpListSharedPtr> &BndCondExpansions,
321 bool PutFwdInBwdOnBCs);
322
324
325 void v_SetBndCondBwdWeight(const int index, const NekDouble value) override;
326
327 void v_GetPeriodicEntities(PeriodicMap &periodicVerts,
328 PeriodicMap &periodicEdges,
329 PeriodicMap &periodicFaces) override;
330
332 const Array<OneD, const NekDouble> &FwdFlux,
333 const Array<OneD, const NekDouble> &BwdFlux,
334 Array<OneD, NekDouble> &outarray) override;
335
336private:
337 std::vector<bool> m_negatedFluxNormal;
338
340 const SpatialDomains::CompositeMap &domain,
342 const std::string &variable);
343};
344
345typedef std::shared_ptr<DisContField> DisContFieldSharedPtr;
346
347} // namespace Nektar::MultiRegions
348
349#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:56
~DisContField() override
Destructor.
Array< OneD, SpatialDomains::BoundaryConditionShPtr > & v_UpdateBndConditions() override
std::vector< int > m_periodicBwdCopy
Definition: DisContField.h:198
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:185
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:190
std::set< int > m_boundaryTraces
A set storing the global IDs of any boundary Verts.
Definition: DisContField.h:175
LocTraceToTraceMapSharedPtr m_locTraceToTraceMap
Definition: DisContField.h:210
std::vector< bool > m_negatedFluxNormal
Definition: DisContField.h:337
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:170
Array< OneD, int > m_BCtoTraceMap
Definition: DisContField.h:59
void EvaluateHDGPostProcessing(const Array< OneD, const NekDouble > &coeffs, Array< OneD, NekDouble > &outarray)
Evaluate HDG post-processing to increase polynomial order of solution.
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.
const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & v_GetBndConditions() override
MultiRegions::ExpListSharedPtr & v_UpdateBndCondExpansion(int i) override
void v_SetBndCondBwdWeight(const int index, const NekDouble value) override
void v_PeriodicBwdCopy(const Array< OneD, const NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd) override
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:139
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:161
void v_GetBndElmtExpansion(int i, std::shared_ptr< ExpList > &result, const bool DeclareCoeffPhysArrays) override
void v_FillBwdWithBwdWeight(Array< OneD, NekDouble > &weightave, Array< OneD, NekDouble > &weightjmp) override
Fill the weight with m_bndCondBndWeight.
const Array< OneD, const NekDouble > & v_GetBndCondBwdWeight() override
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:158
bool SameTypeOfBoundaryConditions(const DisContField &In)
Check to see if expansion has the same BCs as In.
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:143
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..
void FillBwdWithBoundCond(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd, const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > &bndConditions, const Array< OneD, const ExpListSharedPtr > &BndCondExpansions, bool PutFwdInBwdOnBCs)
void GetFwdBwdTracePhys(const Array< OneD, const NekDouble > &field, Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd, const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > &bndCond, const Array< OneD, const ExpListSharedPtr > &BndCondExp)
This method extracts the "forward" and "backward" trace data from the array field and puts the data i...
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.
const LocTraceToTraceMapSharedPtr & v_GetLocTraceToTraceMap(void) const override
void v_AddTraceIntegralToOffDiag(const Array< OneD, const NekDouble > &FwdFlux, const Array< OneD, const NekDouble > &BwdFlux, Array< OneD, NekDouble > &outarray) override
void v_FillBwdWithBoundCond(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd, bool PutFwdInBwdOnBCs) override
GlobalLinSysMapShPtr m_globalBndMat
Global boundary matrix.
Definition: DisContField.h:164
PeriodicMap m_periodicVerts
A map which identifies groups of periodic vertices.
Definition: DisContField.h:180
ExpListSharedPtr m_trace
Trace space storage for points between elements.
Definition: DisContField.h:167
void v_AddTraceQuadPhysToField(const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &field) override
void v_Reset() override
Reset this field, so that geometry information can be updated.
std::vector< bool > & GetNegatedFluxNormal(void)
DisContField()
Default constructor.
std::vector< bool > & v_GetLeftAdjacentTraces(void) override
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
An object which contains the discretised boundary conditions.
Definition: DisContField.h:156
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:197
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:204
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 .
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:123
AssemblyMapDGSharedPtr & v_GetTraceMap(void) override
std::map< int, RobinBCInfoSharedPtr > v_GetRobinBCInfo() override
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:98
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:55
std::shared_ptr< AssemblyMapDG > AssemblyMapDGSharedPtr
Definition: AssemblyMapDG.h:46
std::shared_ptr< DisContField > DisContFieldSharedPtr
Definition: DisContField.h:345
std::shared_ptr< InterfaceMapDG > InterfaceMapDGSharedPtr
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:51
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:55
static const NekDouble kNekUnsetDouble
std::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
Definition: Conditions.h:289
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
std::map< int, CompositeSharedPtr > CompositeMap
Definition: MeshGraph.h:136
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:402
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:346
StdRegions::ConstFactorMap factors
double NekDouble