Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 
202  /**
203  *
204  */
206  {
207  }
208 
209  /* For each local element, copy the normals stored in the element list
210  * into the array \a normals.
211  * @param normals Multidimensional array in which to copy normals
212  * to. Must have dimension equal to or larger than
213  * the spatial dimension of the elements.
214  */
216  {
217  int i,j,k,e_npoints,offset;
219 
220  // Assume whole array is of same coordinate dimension
221  int coordim = (*m_exp)[0]->GetGeom()->GetCoordim();
222 
223  ASSERTL1(normals.num_elements() >= coordim,
224  "Output vector does not have sufficient dimensions to "
225  "match coordim");
226 
227  // Process each expansion.
228  for(i = 0; i < m_exp->size(); ++i)
229  {
231 
233 
234  // Get the number of points and normals for this expansion.
235  e_npoints = 1;
236  locnormals = loc_elmt->GetVertexNormal(loc_exp->GetLeftAdjacentElementVertex());
237 
238  // Get the physical data offset for this expansion.
239  offset = m_phys_offset[i];
240 
241  // Process each point in the expansion.
242  for(j = 0; j < e_npoints; ++j)
243  {
244  // Process each spatial dimension and copy the values into
245  // the output array.
246  for(k = 0; k < coordim; ++k)
247  {
248  normals[k][offset] = locnormals[k][0];
249  }
250  }
251  }
252  }
253 
254 
255  /**
256  * One-dimensional upwind.
257  *
258  * @param Vn Velocity field.
259  * @param Fwd Left state.
260  * @param Bwd Right state.
261  * @param Upwind Output vector.
262  */
264  const Array<OneD, const NekDouble> &Fwd,
265  const Array<OneD, const NekDouble> &Bwd,
266  Array<OneD, NekDouble> &Upwind)
267  {
268  // Process each point in the expansion.
269  for(int j = 0; j < Fwd.num_elements(); ++j)
270  {
271  // Upwind based on one-dimensional velocity.
272  if(Vn[j] > 0.0)
273  {
274  Upwind[j] = Fwd[j];
275  }
276  else
277  {
278  Upwind[j] = Bwd[j];
279  }
280  }
281  }
282  } //end of namespace
283 } //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:263
virtual void v_GetNormals(Array< OneD, Array< OneD, NekDouble > > &normals)
Definition: ExpList0D.cpp:215
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1052
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:1015
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:998
int GetExpSize(void)
This function returns the number of elements in the expansion.
Definition: ExpList.h:2046
boost::shared_ptr< Expansion0D > Expansion0DSharedPtr
Definition: Expansion0D.h:49
std::vector< ExpansionSharedPtr > ExpansionVector
Definition: Expansion.h:70
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:1036
Array< OneD, int > m_phys_offset
Offset of elemental data into the array m_phys.
Definition: ExpList.h:1050
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:976
void SetCoeffPhysOffsets()
Definition of the total number of degrees of freedom and quadrature points and offsets to access data...
Definition: ExpList.cpp:247
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:205
void SetExpType(ExpansionType Type)
Returns the type of the expansion.
Definition: ExpList.cpp:277
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:228
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