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