Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Expansion list 0D definition
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include <MultiRegions/ExpList0D.h>
37 
38 namespace Nektar
39 {
40  namespace MultiRegions
41  {
42 
43 
44  /**
45  * Default constructor ExpList0D object.
46  */
48  ExpList()
49  {
50  SetExpType(e0D);
51  }
52 
53  /**
54  * Creates an identical copy of another ExpList0D object.
55  */
56  ExpList0D::ExpList0D(const ExpList0D &In, bool DeclareCoeffPhysArrays):
57  ExpList(In,DeclareCoeffPhysArrays)
58  {
59  SetExpType(e0D);
60  }
61 
63  ExpList()
64  {
65  SetExpType(e0D);
66  m_ncoeffs = 1;
67  m_npoints = 1;
68 
69  // Set up m_coeffs, m_phys.
70  m_coeffs = Array<OneD, NekDouble>(m_ncoeffs);
71  m_phys = Array<OneD, NekDouble>(m_npoints);
72 
74  (*m_exp).push_back(Point);
75 
77  }
78 
79  /**
80  * Store expansions for the trace space expansions used in
81  * DisContField1D.
82  *
83  * @param bndConstraint Array of ExpList1D objects each containing a
84  * 1D spectral/hp element expansion on a single
85  * boundary region.
86  * @param bndCond Array of BoundaryCondition objects which contain
87  * information about the boundary conditions on the
88  * different boundary regions.
89  * @param locexp Complete domain expansion list.
90  * @param graph1D 1D mesh corresponding to the expansion list.
91  * @param periodicVertices List of periodic Vertices.
92  * @param UseGenSegExp If true, create general segment expansions
93  * instead of just normal segment expansions.
94  */
96  const Array<OneD, const ExpListSharedPtr> &bndConstraint,
97  const Array<OneD, const SpatialDomains::BoundaryConditionShPtr>
98  &bndCond,
99  const LocalRegions::ExpansionVector &locexp,
100  const SpatialDomains::MeshGraphSharedPtr &graph1D,
101  const PeriodicMap &periodicVerts,
102  const bool DeclareCoeffPhysArrays)
103  : ExpList()
104  {
105  SetExpType(e0D);
106 
107  int i, j, id, elmtid=0;
108  map<int,int> EdgeDone;
109  map<int,int> NormalSet;
110 
114 
115  // First loop over boundary conditions to renumber Dirichlet boundaries
116  for(i = 0; i < bndCond.num_elements(); ++i)
117  {
118  if(bndCond[i]->GetBoundaryConditionType() == SpatialDomains::eDirichlet)
119  {
120  for(j = 0; j < bndConstraint[i]->GetExpSize(); ++j)
121  {
122  PointGeom = bndConstraint[i]->GetExp(0)->GetGeom()->GetVertex(0);
124 
125  EdgeDone[PointGeom->GetVid()] = elmtid;
126 
127  Point->SetElmtId(elmtid++);
128  (*m_exp).push_back(Point);
129  }
130  }
131  }
132 
133  // loop over all other edges and fill out other connectivities
134  for(i = 0; i < locexp.size(); ++i)
135  {
136  for(j = 0; j < 2; ++j)
137  {
138  exp = locexp[i]->as<LocalRegions::Expansion1D>();
139  PointGeom = (exp->GetGeom1D())->GetVertex(j);
140  id = PointGeom->GetVid();
141 
142  if(EdgeDone.count(id)==0)
143  {
145  EdgeDone[id] = elmtid;
146 
147  //if (periodicVertices.count(id) > 0)
148  //{
149  // EdgeDone[periodicVertices.find(id)->second] = elmtid;
150  //}
151 
152  Point->SetElmtId(elmtid++);
153  (*m_exp).push_back(Point);
154  }
155  /*else // variable modes/points
156  {
157  LibUtilities::BasisKey EdgeBkey
158  = locexp[i]->DetEdgeBasisKey(j);
159 
160  if((*m_exp)[EdgeDone[id]]->GetNumPoints(0) >= EdgeBkey.GetNumPoints()
161  && (*m_exp)[EdgeDone[id]]->GetBasisNumModes(0) >= EdgeBkey.GetNumModes())
162  {
163  }
164  else if((*m_exp)[EdgeDone[id]]->GetNumPoints(0) <= EdgeBkey.GetNumPoints()
165  && (*m_exp)[EdgeDone[id]]->GetBasisNumModes(0) <= EdgeBkey.GetNumModes())
166  {
167  Seg = MemoryManager<LocalRegions::SegExp>::AllocateSharedPtr(EdgeBkey, SegGeom);
168  Seg->SetElmtId(EdgeDone[id]);
169  (*m_exp)[EdgeDone[id]] = Seg;
170  NormalSet.erase(id);
171  }
172  else
173  {
174  ASSERTL0(false,
175  "inappropriate number of points/modes (max "
176  "num of points is not set with max order)");
177  }
178  }*/
179  }
180  }
181 
182 
183 
184  // Setup Default optimisation information.
185  int nel = GetExpSize();
187 
188  // Set up offset information and array sizes
190 
191  // Set up m_coeffs, m_phys.
192  if(DeclareCoeffPhysArrays)
193  {
194  m_coeffs = Array<OneD, NekDouble>(m_ncoeffs);
195  m_phys = Array<OneD, NekDouble>(m_npoints);
196  }
197  }
198 
199 
201  {
202  int i;
203 
204  // Set up offset information and array sizes
205  m_coeff_offset = Array<OneD,int>(m_exp->size());
206  m_phys_offset = Array<OneD,int>(m_exp->size());
207  m_offset_elmt_id = Array<OneD,int>(m_exp->size());
208 
209  m_ncoeffs = m_npoints = 0;
210 
211  for(i = 0; i < m_exp->size(); ++i)
212  {
214  m_phys_offset [i] = m_npoints;
215  m_offset_elmt_id[i] = i;
216  m_ncoeffs += (*m_exp)[i]->GetNcoeffs();
217  m_npoints += (*m_exp)[i]->GetTotPoints();
218  }
219  }
220 
221  /**
222  *
223  */
225  {
226  }
227 
228  /* For each local element, copy the normals stored in the element list
229  * into the array \a normals.
230  * @param normals Multidimensional array in which to copy normals
231  * to. Must have dimension equal to or larger than
232  * the spatial dimension of the elements.
233  */
234  void ExpList0D::v_GetNormals(Array<OneD, Array<OneD, NekDouble> > &normals)
235  {
236  int i,j,k,e_npoints,offset;
237  Array<OneD,Array<OneD,NekDouble> > locnormals;
238 
239  // Assume whole array is of same coordinate dimension
240  int coordim = (*m_exp)[0]->GetGeom()->GetCoordim();
241 
242  ASSERTL1(normals.num_elements() >= coordim,
243  "Output vector does not have sufficient dimensions to "
244  "match coordim");
245 
246  // Process each expansion.
247  for(i = 0; i < m_exp->size(); ++i)
248  {
250 
252 
253  // Get the number of points and normals for this expansion.
254  e_npoints = 1;
255  locnormals = loc_elmt->GetVertexNormal(loc_exp->GetLeftAdjacentElementVertex());
256 
257  // Get the physical data offset for this expansion.
258  offset = m_phys_offset[i];
259 
260  // Process each point in the expansion.
261  for(j = 0; j < e_npoints; ++j)
262  {
263  // Process each spatial dimension and copy the values into
264  // the output array.
265  for(k = 0; k < coordim; ++k)
266  {
267  normals[k][offset] = locnormals[k][0];
268  }
269  }
270  }
271  }
272 
273 
274  /**
275  * One-dimensional upwind.
276  *
277  * @param Vn Velocity field.
278  * @param Fwd Left state.
279  * @param Bwd Right state.
280  * @param Upwind Output vector.
281  */
282  void ExpList0D::v_Upwind(const Array<OneD, const NekDouble> &Vn,
283  const Array<OneD, const NekDouble> &Fwd,
284  const Array<OneD, const NekDouble> &Bwd,
285  Array<OneD, NekDouble> &Upwind)
286  {
287  // Process each point in the expansion.
288  for(int j = 0; j < Fwd.num_elements(); ++j)
289  {
290  // Upwind based on one-dimensional velocity.
291  if(Vn[j] > 0.0)
292  {
293  Upwind[j] = Fwd[j];
294  }
295  else
296  {
297  Upwind[j] = Bwd[j];
298  }
299  }
300  }
301  } //end of namespace
302 } //end of namespace