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