Nektar++
Loading...
Searching...
No Matches
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 = true,
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
128
133 &bndCond,
134 const Array<OneD, const ExpListSharedPtr> &BndCondExp);
135
136 MULTI_REGIONS_EXPORT unsigned GetTraceElmtId(const unsigned elmtid,
137 const unsigned traceid)
138 {
139 return m_traceMap->GetElmtToTrace()[elmtid][traceid]->GetElmtId();
140 }
141
153
154 bool IsLeftAdjacentTrace(const int n, const int e);
155
156protected:
157 /// An array which contains the information about the boundary
158 /// condition structure definition on the different boundary regions.
160
161 /**
162 * @brief An object which contains the discretised boundary
163 * conditions.
164 *
165 * It is an array of size equal to the number of boundary
166 * regions and consists of entries of the type
167 * MultiRegions#ExpList. Every entry corresponds to the
168 * spectral/hp expansion on a single boundary region. The
169 * values of the boundary conditions are stored as the
170 * coefficients of the one-dimensional expansion.
171 */
173
175
176 /// Interfaces mapping for trace space.
178
179 /// Global boundary matrix.
181
182 /// Trace space storage for points between elements.
184
185 /// Local Elemental trace expansions
187
188 /// Local to global DG mapping for trace space.
190
191 /**
192 * @brief A set storing the global IDs of any boundary Verts.
193 */
194 std::set<int> m_boundaryTraces;
195
196 /**
197 * @brief A map which identifies groups of periodic vertices.
198 */
200
201 /**
202 * @brief A map which identifies pairs of periodic edges.
203 */
205
206 /**
207 * @brief A map which identifies pairs of periodic faces.
208 */
210
211 /**
212 * @brief A vector indicating degress of freedom which need to be
213 * copied from forwards to backwards space in case of a periodic
214 * boundary condition.
215 */
216 std::vector<int> m_periodicFwdCopy;
217 std::vector<int> m_periodicBwdCopy;
218
219 /*
220 * @brief A map identifying which traces are left- and
221 * right-adjacent for DG.
222 */
223 std::vector<bool> m_leftAdjacentTraces;
224
225 /**
226 * Map of local trace (the points at the edge,face of
227 * the element) to the trace space discretisation
228 */
230
231 /// Discretises the boundary conditions.
235 const std::string variable, const bool DeclareCoeffPhysArrays = true,
236 const Collections::ImplementationType ImpType =
238
239 /// Make copy of boundary conditions.
243 const std::string variable, const bool DeclareCoeffPhysArrays = true,
244 const Collections::ImplementationType ImpType =
246
247 /// Generate a associative map of periodic vertices in a mesh.
249 const std::string variable);
250
251 void SetUpDG(const std::string = "DefaultVar",
252 const Collections::ImplementationType ImpType =
254
255 ExpListSharedPtr &v_GetTrace() override;
256
259
261 void) const override;
262
263 std::vector<bool> &v_GetLeftAdjacentTraces(void) override;
264
266 Array<OneD, NekDouble> &outarray) override;
267
270 Array<OneD, NekDouble> &outarray) override;
271
274 Array<OneD, NekDouble> &field) override;
275
277 Array<OneD, NekDouble> &outarray,
278 bool gridVelocity = false) override;
279
280 void v_ExtractTracePhys(Array<OneD, NekDouble> &outarray) override;
281
285 Array<OneD, NekDouble> &locTraceFwd,
286 Array<OneD, NekDouble> &locTraceBwd) override;
287
289 const std::string variable);
290
291 std::map<int, RobinBCInfoSharedPtr> v_GetRobinBCInfo() override;
292
294 v_GetBndCondExpansions() override;
295
297 v_GetBndConditions() override;
298
300
302 override;
303
305 Array<OneD, int> &TraceID) override;
306 void v_GetBndElmtExpansion(int i, std::shared_ptr<ExpList> &result,
307 const bool DeclareCoeffPhysArrays) override;
308
309 void v_Reset() override;
310
311 /// Evaluate all boundary conditions at a given time..
313 const NekDouble time = 0.0, const std::string varName = "",
315 const NekDouble x3_in = NekConstants::kNekUnsetDouble) override;
316
317 /// Set boundary conditions to be homogeneous
318 void v_SetBCsToHomogeneous(void) override;
319
320 /// Solve the Helmholtz equation.
322 Array<OneD, NekDouble> &outarray,
323 const StdRegions::ConstFactorMap &factors,
324 const StdRegions::VarCoeffMap &varcoeff,
325 const StdRegions::VarFactorsMap &varfactors,
326 const Array<OneD, const NekDouble> &dirForcing,
327 const bool PhysSpaceForcing) override;
328
330 Array<OneD, NekDouble> &Bwd) override;
332
334
337
339 Array<OneD, NekDouble> &weightjmp) override;
340
342 Array<OneD, NekDouble> &Bwd) override;
343
346 Array<OneD, NekDouble> &Bwd, bool FillBnd = true,
347 bool PutFwdInBwdOnBCs = false,
348 bool DoExchange = true) override;
349
352 bool PutFwdInBwdOnBCs) override;
353
357 &bndConditions,
358 const Array<OneD, const ExpListSharedPtr> &BndCondExpansions,
359 bool PutFwdInBwdOnBCs);
360
362
363 void v_SetBndCondBwdWeight(const int index, const NekDouble value) override;
364
365 void v_GetPeriodicEntities(PeriodicMap &periodicVerts,
366 PeriodicMap &periodicEdges,
367 PeriodicMap &periodicFaces) override;
368
370 const Array<OneD, const NekDouble> &FwdFlux,
371 const Array<OneD, const NekDouble> &BwdFlux,
372 Array<OneD, NekDouble> &outarray) override;
373
374 void Rotate(Array<OneD, Array<OneD, NekDouble>> &Bwd, const int dir,
375 const NekDouble angle, const int offset, const int npts);
376
377 void DeriveRotate(TensorOfArray3D<NekDouble> &Bwd, const int dir,
378 const NekDouble angle, const int offset, const int npts);
379
380private:
381 std::vector<bool> m_negatedFluxNormal;
382
384 const SpatialDomains::CompositeMap &domain,
386 const std::string &variable);
387};
388
389typedef std::shared_ptr<DisContField> DisContFieldSharedPtr;
390
391} // namespace Nektar::MultiRegions
392
393#endif // NEKTAR_LIBS_MULTIREGIONS_DISCONTFIELD1D_H
#define MULTI_REGIONS_EXPORT
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
This class is the abstractio n of a global discontinuous two- dimensional spectral/hp element expansi...
~DisContField() override
Destructor.
Array< OneD, SpatialDomains::BoundaryConditionShPtr > & v_UpdateBndConditions() override
void v_SetBCsToHomogeneous(void) override
Set boundary conditions to be homogeneous.
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.
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.
std::set< int > m_boundaryTraces
A set storing the global IDs of any boundary Verts.
LocTraceToTraceMapSharedPtr m_locTraceToTraceMap
std::vector< bool > m_negatedFluxNormal
MultiRegions::ExpListSharedPtr m_locElmtTrace
Local Elemental trace expansions.
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.
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_PeriodicBwdRot(Array< OneD, Array< OneD, NekDouble > > &Bwd) override
unsigned GetTraceElmtId(const unsigned elmtid, const unsigned traceid)
void v_ExtractTracePhys(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool gridVelocity=false) override
This method extracts the trace (verts in 1D) from the field inarray and puts the values in outarray.
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
GlobalLinSysKey v_HelmSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const StdRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing) override
Solve the Helmholtz equation.
void GenerateBoundaryConditionExpansion(const SpatialDomains::MeshGraphSharedPtr &graph1D, const SpatialDomains::BoundaryConditions &bcs, const std::string variable, const bool DeclareCoeffPhysArrays=true, const Collections::ImplementationType ImpType=Collections::eNoImpType)
Discretises the boundary conditions.
void v_RotLocalBwdDeriveTrace(TensorOfArray3D< NekDouble > &Bwd) override
InterfaceMapDGSharedPtr & v_GetInterfaceMap(void) override
void v_RotLocalBwdTrace(Array< OneD, Array< OneD, NekDouble > > &Bwd) override
InterfaceMapDGSharedPtr m_interfaceMap
Interfaces mapping for trace space.
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
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...
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 Rotate(Array< OneD, Array< OneD, NekDouble > > &Bwd, const int dir, const NekDouble angle, const int offset, const int npts)
Rotate the slice [offset, offset + npts) of the 3D vector field in Bwd around the axis 'dir' by 'angl...
void v_FillBwdWithBoundCond(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd, bool PutFwdInBwdOnBCs) override
GlobalLinSysMapShPtr m_globalBndMat
Global boundary matrix.
void DeriveRotate(TensorOfArray3D< NekDouble > &Bwd, const int dir, const NekDouble angle, const int offset, const int npts)
Rotate the slice [offset, offset + npts) of the 3D vector field in Bwd around the axis 'dir' by 'angl...
PeriodicMap m_periodicVerts
A map which identifies groups of periodic vertices.
ExpListSharedPtr m_trace
Trace space storage for points between elements.
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.
std::vector< int > m_periodicFwdCopy
A vector indicating degress of freedom which need to be copied from forwards to backwards space in ca...
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
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 .
ExpListSharedPtr & GetLocElmtTrace()
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)
AssemblyMapDGSharedPtr & v_GetTraceMap(void) override
void v_PeriodicDeriveBwdRot(TensorOfArray3D< NekDouble > &Bwd) override
std::map< int, RobinBCInfoSharedPtr > v_GetRobinBCInfo() override
void v_GetFwdBwdTracePhys(Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd) override
Base class for all multi-elemental spectral/hp expansions.
Definition ExpList.h:98
SpatialDomains::MeshGraphSharedPtr GetGraph()
Definition ExpList.h:999
std::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
Definition ExpList.h:1184
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition ExpList.h:1124
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
std::shared_ptr< DisContField > DisContFieldSharedPtr
std::shared_ptr< InterfaceMapDG > InterfaceMapDGSharedPtr
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< LocTraceToTraceMap > LocTraceToTraceMapSharedPtr
std::map< int, std::vector< PeriodicEntity > > PeriodicMap
std::shared_ptr< GlobalLinSysMap > GlobalLinSysMapShPtr
Pointer to a GlobalLinSys/key map.
static const NekDouble kNekUnsetDouble
std::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
Definition Conditions.h:327
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition MeshGraph.h:224
std::map< int, CompositeSharedPtr > CompositeMap
Definition MeshGraph.h:186
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
std::map< ConstFactorType, NekDouble > ConstFactorMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap