Nektar++
ExpList0D.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File ExpList0D.cpp
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: Expansion list 0D definition
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
37 #include <MultiRegions/ExpList0D.h>
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43  namespace MultiRegions
44  {
45 
46 
47  /**
48  * Default constructor ExpList0D object.
49  */
50  ExpList0D::ExpList0D():
51  ExpList()
52  {
53  SetExpType(e0D);
54  }
55 
56  /**
57  * Creates an identical copy of another ExpList0D object.
58  */
59  ExpList0D::ExpList0D(const ExpList0D &In, bool DeclareCoeffPhysArrays):
60  ExpList(In,DeclareCoeffPhysArrays)
61  {
62  SetExpType(e0D);
63  }
64 
66  ExpList()
67  {
68  SetExpType(e0D);
69  m_ncoeffs = 1;
70  m_npoints = 1;
71 
72  // Set up m_coeffs, m_phys.
75 
77  (*m_exp).push_back(Point);
78 
80  }
81 
82  /**
83  * Store expansions for the trace space expansions used in
84  * DisContField1D.
85  *
86  * @param bndConstraint Array of ExpList1D objects each containing a
87  * 1D spectral/hp element expansion on a single
88  * boundary region.
89  * @param bndCond Array of BoundaryCondition objects which contain
90  * information about the boundary conditions on the
91  * different boundary regions.
92  * @param locexp Complete domain expansion list.
93  * @param graph1D 1D mesh corresponding to the expansion list.
94  * @param periodicVertices List of periodic Vertices.
95  * @param UseGenSegExp If true, create general segment expansions
96  * instead of just normal segment expansions.
97  */
99  const Array<OneD, const ExpListSharedPtr> &bndConstraint,
101  &bndCond,
102  const LocalRegions::ExpansionVector &locexp,
103  const SpatialDomains::MeshGraphSharedPtr &graph1D,
104  const PeriodicMap &periodicVerts,
105  const bool DeclareCoeffPhysArrays)
106  : ExpList()
107  {
108  boost::ignore_unused(graph1D, periodicVerts);
109 
110  SetExpType(e0D);
111 
112  int i, j, id, elmtid=0;
113  map<int,int> EdgeDone;
114  map<int,int> NormalSet;
115 
119 
120  // First loop over boundary conditions to renumber Dirichlet boundaries
121  for(i = 0; i < bndCond.num_elements(); ++i)
122  {
123  if(bndCond[i]->GetBoundaryConditionType() == SpatialDomains::eDirichlet)
124  {
125  for(j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
126  {
127  PointGeom = bndConstraint[i]->GetExp(0)->GetGeom()->GetVertex(0);
129 
130  EdgeDone[PointGeom->GetVid()] = elmtid;
131 
132  Point->SetElmtId(elmtid++);
133  (*m_exp).push_back(Point);
134  }
135  }
136  }
137 
138  // loop over all other edges and fill out other connectivities
139  for(i = 0; i < locexp.size(); ++i)
140  {
141  for(j = 0; j < 2; ++j)
142  {
143  exp = locexp[i]->as<LocalRegions::Expansion1D>();
144  PointGeom = (exp->GetGeom1D())->GetVertex(j);
145  id = PointGeom->GetVid();
146 
147  if(EdgeDone.count(id)==0)
148  {
150  EdgeDone[id] = elmtid;
151 
152  //if (periodicVertices.count(id) > 0)
153  //{
154  // EdgeDone[periodicVertices.find(id)->second] = elmtid;
155  //}
156 
157  Point->SetElmtId(elmtid++);
158  (*m_exp).push_back(Point);
159  }
160  /*else // variable modes/points
161  {
162  LibUtilities::BasisKey EdgeBkey
163  = locexp[i]->DetEdgeBasisKey(j);
164 
165  if((*m_exp)[EdgeDone[id]]->GetNumPoints(0) >= EdgeBkey.GetNumPoints()
166  && (*m_exp)[EdgeDone[id]]->GetBasisNumModes(0) >= EdgeBkey.GetNumModes())
167  {
168  }
169  else if((*m_exp)[EdgeDone[id]]->GetNumPoints(0) <= EdgeBkey.GetNumPoints()
170  && (*m_exp)[EdgeDone[id]]->GetBasisNumModes(0) <= EdgeBkey.GetNumModes())
171  {
172  Seg = MemoryManager<LocalRegions::SegExp>::AllocateSharedPtr(EdgeBkey, SegGeom);
173  Seg->SetElmtId(EdgeDone[id]);
174  (*m_exp)[EdgeDone[id]] = Seg;
175  NormalSet.erase(id);
176  }
177  else
178  {
179  ASSERTL0(false,
180  "inappropriate number of points/modes (max "
181  "num of points is not set with max order)");
182  }
183  }*/
184  }
185  }
186 
187 
188 
189  // Setup Default optimisation information.
190  int nel = GetExpSize();
192 
193  // Set up offset information and array sizes
195 
196  // Set up m_coeffs, m_phys.
197  if(DeclareCoeffPhysArrays)
198  {
201  }
202  }
203 
204 
205  /**
206  *
207  */
209  {
210  }
211 
212  /* For each local element, copy the normals stored in the element list
213  * into the array \a normals.
214  * @param normals Multidimensional array in which to copy normals
215  * to. Must have dimension equal to or larger than
216  * the spatial dimension of the elements.
217  */
219  {
220  int i,j,k,e_npoints,offset;
222 
223  // Assume whole array is of same coordinate dimension
224  int coordim = (*m_exp)[0]->GetGeom()->GetCoordim();
225 
226  ASSERTL1(normals.num_elements() >= coordim,
227  "Output vector does not have sufficient dimensions to "
228  "match coordim");
229 
230  // Process each expansion.
231  for(i = 0; i < m_exp->size(); ++i)
232  {
234 
236 
237  // Get the number of points and normals for this expansion.
238  e_npoints = 1;
239  locnormals = loc_elmt->GetVertexNormal(loc_exp->GetLeftAdjacentElementVertex());
240 
241  // Get the physical data offset for this expansion.
242  offset = m_phys_offset[i];
243 
244  // Process each point in the expansion.
245  for(j = 0; j < e_npoints; ++j)
246  {
247  // Process each spatial dimension and copy the values into
248  // the output array.
249  for(k = 0; k < coordim; ++k)
250  {
251  normals[k][offset] = locnormals[k][0];
252  }
253  }
254  }
255  }
256 
257 
258  /**
259  * One-dimensional upwind.
260  *
261  * @param Vn Velocity field.
262  * @param Fwd Left state.
263  * @param Bwd Right state.
264  * @param Upwind Output vector.
265  */
267  const Array<OneD, const NekDouble> &Fwd,
268  const Array<OneD, const NekDouble> &Bwd,
270  {
271  // Process each point in the expansion.
272  for(int j = 0; j < Fwd.num_elements(); ++j)
273  {
274  // Upwind based on one-dimensional velocity.
275  if(Vn[j] > 0.0)
276  {
277  Upwind[j] = Fwd[j];
278  }
279  else
280  {
281  Upwind[j] = Bwd[j];
282  }
283  }
284  }
285  } //end of namespace
286 } //end of namespace
virtual void v_Upwind(const Array< OneD, const NekDouble > &Vn, const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &Upwind)
Definition: ExpList0D.cpp:266
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
virtual void v_GetNormals(Array< OneD, Array< OneD, NekDouble > > &normals)
Definition: ExpList0D.cpp:218
ExpList()
The default constructor.
Definition: ExpList.cpp:96
std::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
Definition: ExpList.h:1090
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1106
STL namespace.
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
Definition: ExpList.h:1069
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:1052
int GetExpSize(void)
This function returns the number of elements in the expansion.
Definition: ExpList.h:2170
std::vector< ExpansionSharedPtr > ExpansionVector
Definition: Expansion.h:67
void Upwind(const Array< OneD, const Array< OneD, NekDouble > > &Vec, const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &Upwind)
Definition: ExpList.h:2249
Base class for all multi-elemental spectral/hp expansions.
Definition: ExpList.h:103
Expansion1DSharedPtr GetLeftAdjacentElementExp() const
Definition: Expansion0D.h:85
std::shared_ptr< Expansion0D > Expansion0DSharedPtr
Definition: Expansion0D.h:48
Array< OneD, int > m_phys_offset
Offset of elemental data into the array m_phys.
Definition: ExpList.h:1104
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:1030
void SetCoeffPhysOffsets()
Definition of the total number of degrees of freedom and quadrature points and offsets to access data...
Definition: ExpList.cpp:249
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:59
std::map< int, std::vector< PeriodicEntity > > PeriodicMap
ExpList0D()
The defualt constructor.
Definition: ExpList0D.cpp:50
std::shared_ptr< PointExp > PointExpSharedPtr
Definition: PointExp.h:129
This class is the abstraction of a collection of zero-dimensional expansions which is merely a collec...
Definition: ExpList0D.h:62
virtual ~ExpList0D()
Destructor.
Definition: ExpList0D.cpp:208
void SetExpType(ExpansionType Type)
Returns the type of the expansion.
Definition: ExpList.cpp:279
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
std::shared_ptr< Expansion1D > Expansion1DSharedPtr
Definition: Expansion1D.h:51