Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CoalescedGeomData.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Collection.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: Collection top class definition
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
38 
39 using namespace std;
40 
41 namespace Nektar {
42 namespace Collections {
43 
44 CoalescedGeomData::CoalescedGeomData(void)
45 {
46 }
47 
48 CoalescedGeomData::~CoalescedGeomData(void)
49 {
50 }
51 
52 const Array<OneD, const NekDouble> &CoalescedGeomData::GetJac(
53  vector<StdRegions::StdExpansionSharedPtr> &pCollExp)
54 {
55 
56  if(m_oneDGeomData.count(eJac) == 0)
57  {
58 
59  LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
60  int nElmts = pCollExp.size();
61 
62  // set up Cached Jacobians to be continuous
63  int npts = 1;
64  for (int i = 0; i < ptsKeys.size(); ++i)
65  {
66  npts *= ptsKeys[i].GetNumPoints();
67  }
68 
69 
70  Array<OneD, NekDouble> newjac(npts*nElmts);
71 
72  //copy Jacobians into a continuous list and set new chatched value
73  int cnt = 0;
74  for(int i = 0; i < nElmts; ++i)
75  {
77  pCollExp[i]->GetMetricInfo()->GetJac(ptsKeys);
78 
79  if (pCollExp[i]->GetMetricInfo()->GetGtype() ==
81  {
82  Vmath::Vcopy(npts, &jac[0], 1, &newjac[cnt], 1);
83  }
84  else
85  {
86  Vmath::Fill(npts, jac[0], &newjac[cnt], 1);
87  }
88 
89  cnt += npts;
90  }
91 
92  m_oneDGeomData[eJac] = newjac;
93  }
94 
95  return m_oneDGeomData[eJac];
96 }
97 
98 
99 
100 const Array<OneD, const NekDouble> &CoalescedGeomData::GetJacWithStdWeights(
101  vector<StdRegions::StdExpansionSharedPtr> &pCollExp)
102 {
103  if(m_oneDGeomData.count(eJacWithStdWeights) == 0)
104  {
105  LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
106  int nElmts = pCollExp.size();
107 
108  // set up Cached Jacobians to be continuous
109  int npts = 1;
110  for (int i = 0; i < ptsKeys.size(); ++i)
111  {
112  npts *= ptsKeys[i].GetNumPoints();
113  }
114 
115 
116  Array<OneD, NekDouble> newjac(npts*nElmts), tmp;
117 
118  //copy Jacobians into a continuous list and set new chatched value
119  int cnt = 0;
120  for(int i = 0; i < nElmts; ++i)
121  {
122  const Array<OneD, const NekDouble> jac =
123  pCollExp[i]->GetMetricInfo()->GetJac(ptsKeys);
124 
125  if (pCollExp[i]->GetMetricInfo()->GetGtype() ==
127  {
128  Vmath::Vcopy(npts, &jac[0], 1, &newjac[cnt], 1);
129  }
130  else
131  {
132  Vmath::Fill(npts, jac[0], &newjac[cnt], 1);
133  }
134 
135  pCollExp[0]->MultiplyByStdQuadratureMetric(newjac + cnt,
136  tmp = newjac + cnt);
137  cnt += npts;
138  }
139 
140  m_oneDGeomData[eJacWithStdWeights] = newjac;
141  }
142 
143  return m_oneDGeomData[eJacWithStdWeights];
144 }
145 
146 
147 const Array<TwoD, const NekDouble> &CoalescedGeomData::GetDerivFactors(
148  vector<StdRegions::StdExpansionSharedPtr> &pCollExp)
149 {
150  if(m_twoDGeomData.count(eDerivFactors) == 0)
151  {
152  LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
153 
154  int nElmts = pCollExp.size();
155  const int coordim = pCollExp[0]->GetCoordim();
156  int dim = ptsKeys.size();
157 
158  // set up Cached Jacobians to be continuous
159  int npts = 1;
160  for (int i = 0; i < dim; ++i)
161  {
162  npts *= ptsKeys[i].GetNumPoints();
163  }
164 
165 
166  Array<TwoD, NekDouble> newDFac(dim*coordim,npts*nElmts);
167 
168  //copy Jacobians into a continuous list and set new chatched value
169  int cnt = 0;
170  for(int i = 0; i < nElmts; ++i)
171  {
172  const Array<TwoD, const NekDouble> Dfac =
173  pCollExp[i]->GetMetricInfo()->GetDerivFactors(ptsKeys);
174 
175  if (pCollExp[i]->GetMetricInfo()->GetGtype() ==
177  {
178  for (int j = 0; j < dim*coordim; ++j)
179  {
180  Vmath::Vcopy(npts, &Dfac[j][0], 1, &newDFac[j][cnt], 1);
181  }
182  }
183  else
184  {
185  for (int j = 0; j < dim*coordim; ++j)
186  {
187  Vmath::Fill(npts, Dfac[j][0], &newDFac[j][cnt], 1);
188  }
189  }
190  cnt += npts;
191  }
192 
193  m_twoDGeomData[eDerivFactors] = newDFac;
194  }
195 
196  return m_twoDGeomData[eDerivFactors];
197 }
198 
199 }
200 }
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:242
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:46
STL namespace.
static std::string npts
Definition: InputFld.cpp:43
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
Geometry is curved or has non-constant factors.