Nektar++
IProductWRTBase.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: IProductWRTBase.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: IProductWRTBase operator implementations
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#include <boost/core/ignore_unused.hpp>
36
37#include <MatrixFreeOps/Operator.hpp>
38
43
44using namespace std;
45
46namespace Nektar
47{
48namespace Collections
49{
50
58
59/**
60 * @brief Inner product operator using standard matrix approach
61 */
62class IProductWRTBase_StdMat final : public Operator
63{
64public:
66
68 {
69 }
70
75 Array<OneD, NekDouble> &wsp) override final
76 {
77 boost::ignore_unused(output1, output2);
78
79 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
80
81 if (m_isDeformed)
82 {
83 Vmath::Vmul(m_jac.size(), m_jac, 1, input, 1, wsp, 1);
84 }
85 else
86 {
88 for (int e = 0; e < m_numElmt; ++e)
89 {
90 Vmath::Smul(m_nqe, m_jac[e], input + e * m_nqe, 1,
91 tmp = wsp + e * m_nqe, 1);
92 }
93 }
94
95 Blas::Dgemm('N', 'N', m_mat->GetRows(), m_numElmt, m_mat->GetColumns(),
96 1.0, m_mat->GetRawPtr(), m_mat->GetRows(), wsp.get(),
97 m_stdExp->GetTotPoints(), 0.0, output.get(),
98 m_stdExp->GetNcoeffs());
99 }
100
101 void operator()(int dir, const Array<OneD, const NekDouble> &input,
103 Array<OneD, NekDouble> &wsp) override final
104 {
105 boost::ignore_unused(dir, input, output, wsp);
106 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
107 }
108
110 int coll_phys_offset) override
111 {
112 boost::ignore_unused(factors, coll_phys_offset);
113 ASSERTL0(false, "Not valid for this operator.");
114 }
115
116protected:
119
120private:
121 IProductWRTBase_StdMat(vector<StdRegions::StdExpansionSharedPtr> pCollExp,
124 : Operator(pCollExp, pGeomData, factors)
125 {
126 m_jac = pGeomData->GetJac(pCollExp);
128 m_stdExp->DetShapeType(), *m_stdExp);
129 m_mat = m_stdExp->GetStdMatrix(key);
130 m_nqe = m_stdExp->GetTotPoints();
132 }
133};
134
135/// Factory initialisation for the IProductWRTBase_StdMat operators
136OperatorKey IProductWRTBase_StdMat::m_typeArr[] = {
139 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_Seg"),
142 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_Tri"),
145 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_NodalTri"),
148 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_Quad"),
151 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_Tet"),
154 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_NodalTet"),
157 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_Pyr"),
160 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_Prism"),
163 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_NodalPrism"),
166 IProductWRTBase_StdMat::create, "IProductWRTBase_StdMat_Hex"),
169 IProductWRTBase_StdMat::create, "IProductWRTBase_SumFac_Pyr")};
170
171/**
172 * @brief Inner product operator using operator using matrix free operators.
173 */
175{
176public:
178
180 {
181 }
182
183 virtual void operator()(const Array<OneD, const NekDouble> &input,
185 Array<OneD, NekDouble> &output1,
186 Array<OneD, NekDouble> &output2,
187 Array<OneD, NekDouble> &wsp) override final
188 {
189 boost::ignore_unused(output1, output2, wsp);
190
191 if (m_isPadded)
192 {
193 // copy into padded vector
194 Vmath::Vcopy(m_nIn, input, 1, m_input, 1);
195 // call op
196 (*m_oper)(m_input, m_output);
197 // copy out of padded vector
198 Vmath::Vcopy(m_nOut, m_output, 1, output, 1);
199 }
200 else
201 {
202 (*m_oper)(input, output);
203 }
204 }
205
206 void operator()(int dir, const Array<OneD, const NekDouble> &input,
208 Array<OneD, NekDouble> &wsp) override final
209 {
210 boost::ignore_unused(dir, input, output, wsp);
211 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
212 }
213
215 int coll_phys_offset) override
216 {
217 boost::ignore_unused(factors, coll_phys_offset);
218 ASSERTL0(false, "Not valid for this operator.");
219 }
220
221private:
222 std::shared_ptr<MatrixFree::IProduct> m_oper;
223
225 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
227 : Operator(pCollExp, pGeomData, factors),
228 MatrixFreeOneInOneOut(pCollExp[0]->GetStdExp()->GetTotPoints(),
229 pCollExp[0]->GetStdExp()->GetNcoeffs(),
230 pCollExp.size())
231 {
232
233 // Basis vector
234 const auto dim = pCollExp[0]->GetStdExp()->GetShapeDimension();
235 std::vector<LibUtilities::BasisSharedPtr> basis(dim);
236 for (unsigned int i = 0; i < dim; ++i)
237 {
238 basis[i] = pCollExp[0]->GetBasis(i);
239 }
240
241 // Get shape type
242 auto shapeType = pCollExp[0]->GetStdExp()->DetShapeType();
243
244 // Generate operator string and create operator.
245 std::string op_string = "IProduct";
246 op_string += MatrixFree::GetOpstring(shapeType, m_isDeformed);
248 op_string, basis, m_nElmtPad);
249
250 // Set Jacobian
251 oper->SetJac(pGeomData->GetJacInterLeave(pCollExp, m_nElmtPad));
252
253 m_oper = std::dynamic_pointer_cast<MatrixFree::IProduct>(oper);
254 ASSERTL0(m_oper, "Failed to cast pointer.");
255 }
256};
257
258/// Factory initialisation for the IProductWRTBase_MatrixFree operators
259OperatorKey IProductWRTBase_MatrixFree::m_typeArr[] = {
262 IProductWRTBase_MatrixFree::create, "IProductWRTBase_MatrixFree_Seg"),
265 IProductWRTBase_MatrixFree::create, "IProductWRTBase_MatrixFree_Quad"),
268 IProductWRTBase_MatrixFree::create, "IProductWRTBase_MatrixFree_Tri"),
271 IProductWRTBase_MatrixFree::create, "IProductWRTBase_MatrixFree_Hex"),
274 IProductWRTBase_MatrixFree::create, "IProductWRTBase_MatrixFree_Prism"),
277 IProductWRTBase_MatrixFree::create, "IProductWRTBase_MatrixFree_Pyr"),
280 IProductWRTBase_MatrixFree::create, "IProductWRTBase_MatrixFree_Tet")
281
282};
283
284/**
285 * @brief Inner product operator using element-wise operation
286 */
288{
289public:
291
293 {
294 }
295
298 Array<OneD, NekDouble> &output1,
299 Array<OneD, NekDouble> &output2,
300 Array<OneD, NekDouble> &wsp) override final
301 {
302 boost::ignore_unused(output1, output2);
303
304 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
305
306 const int nCoeffs = m_stdExp->GetNcoeffs();
307 const int nPhys = m_stdExp->GetTotPoints();
309
310 Vmath::Vmul(m_jacWStdW.size(), m_jacWStdW, 1, input, 1, wsp, 1);
311
312 for (int i = 0; i < m_numElmt; ++i)
313 {
314 m_stdExp->IProductWRTBase_SumFac(wsp + i * nPhys,
315 tmp = output + i * nCoeffs, false);
316 }
317 }
318
319 void operator()(int dir, const Array<OneD, const NekDouble> &input,
321 Array<OneD, NekDouble> &wsp) override final
322 {
323 boost::ignore_unused(dir, input, output, wsp);
324 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
325 }
326
328 int coll_phys_offset) override
329 {
330 boost::ignore_unused(factors, coll_phys_offset);
331 ASSERTL0(false, "Not valid for this operator.");
332 }
333
334protected:
336
337private:
339 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
341 : Operator(pCollExp, pGeomData, factors)
342 {
343 int nqtot = 1;
344 LibUtilities::PointsKeyVector PtsKey = m_stdExp->GetPointsKeys();
345 for (int i = 0; i < PtsKey.size(); ++i)
346 {
347 nqtot *= PtsKey[i].GetNumPoints();
348 }
349
350 m_jacWStdW = pGeomData->GetJacWithStdWeights(pCollExp);
351
352 m_wspSize = nqtot * m_numElmt;
353 }
354};
355
356/// Factory initialisation for the IProductWRTBase_IterPerExp operators
357OperatorKey IProductWRTBase_IterPerExp::m_typeArr[] = {
360 IProductWRTBase_IterPerExp::create, "IProductWRTBase_IterPerExp_Seg"),
363 IProductWRTBase_IterPerExp::create, "IProductWRTBase_IterPerExp_Tri"),
366 IProductWRTBase_IterPerExp::create,
367 "IProductWRTBase_IterPerExp_NodalTri"),
370 IProductWRTBase_IterPerExp::create, "IProductWRTBase_IterPerExp_Quad"),
373 IProductWRTBase_IterPerExp::create, "IProductWRTBase_IterPerExp_Tet"),
376 IProductWRTBase_IterPerExp::create,
377 "IProductWRTBase_IterPerExp_NodalTet"),
380 IProductWRTBase_IterPerExp::create, "IProductWRTBase_IterPerExp_Pyr"),
383 IProductWRTBase_IterPerExp::create, "IProductWRTBase_IterPerExp_Prism"),
386 IProductWRTBase_IterPerExp::create,
387 "IProductWRTBase_IterPerExp_NodalPrism"),
390 IProductWRTBase_IterPerExp::create, "IProductWRTBase_IterPerExp_Hex"),
391};
392
393/**
394 * @brief Inner product operator using original MultiRegions implementation.
395 */
397{
398public:
400
402 {
403 }
404
407 Array<OneD, NekDouble> &output1,
408 Array<OneD, NekDouble> &output2,
409 Array<OneD, NekDouble> &wsp) override final
410 {
411 boost::ignore_unused(output1, output2, wsp);
412
413 const int nCoeffs = m_expList[0]->GetNcoeffs();
414 const int nPhys = m_expList[0]->GetTotPoints();
416
417 for (int i = 0; i < m_numElmt; ++i)
418 {
419 m_expList[i]->IProductWRTBase(input + i * nPhys,
420 tmp = output + i * nCoeffs);
421 }
422 }
423
424 void operator()(int dir, const Array<OneD, const NekDouble> &input,
426 Array<OneD, NekDouble> &wsp) override final
427 {
428 boost::ignore_unused(dir, input, output, wsp);
429 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
430 }
431
433 int coll_phys_offset) override
434 {
435 boost::ignore_unused(factors, coll_phys_offset);
436 ASSERTL0(false, "Not valid for this operator.");
437 }
438
439protected:
440 vector<StdRegions::StdExpansionSharedPtr> m_expList;
441
442private:
444 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
446 : Operator(pCollExp, pGeomData, factors)
447 {
448 m_expList = pCollExp;
449 }
450};
451
452/// Factory initialisation for the IProductWRTBase_NoCollection operators
453OperatorKey IProductWRTBase_NoCollection::m_typeArr[] = {
456 IProductWRTBase_NoCollection::create,
457 "IProductWRTBase_NoCollection_Seg"),
460 IProductWRTBase_NoCollection::create,
461 "IProductWRTBase_NoCollection_Tri"),
464 IProductWRTBase_NoCollection::create,
465 "IProductWRTBase_NoCollection_NodalTri"),
468 IProductWRTBase_NoCollection::create,
469 "IProductWRTBase_NoCollection_Quad"),
472 IProductWRTBase_NoCollection::create,
473 "IProductWRTBase_NoCollection_Tet"),
476 IProductWRTBase_NoCollection::create,
477 "IProductWRTBase_NoCollection_NodalTet"),
480 IProductWRTBase_NoCollection::create,
481 "IProductWRTBase_NoCollection_Pyr"),
484 IProductWRTBase_NoCollection::create,
485 "IProductWRTBase_NoCollection_Prism"),
488 IProductWRTBase_NoCollection::create,
489 "IProductWRTBase_NoCollection_NodalPrism"),
492 IProductWRTBase_NoCollection::create,
493 "IProductWRTBase_NoCollection_Hex"),
494};
495
496/**
497 * @brief Inner product operator using sum-factorisation (Segment)
498 */
500{
501public:
503
505 {
506 }
507
510 Array<OneD, NekDouble> &output1,
511 Array<OneD, NekDouble> &output2,
512 Array<OneD, NekDouble> &wsp) override final
513 {
514 boost::ignore_unused(output1, output2);
515
516 if (m_colldir0)
517 {
518 Vmath::Vmul(m_numElmt * m_nquad0, m_jacWStdW, 1, input, 1, output,
519 1);
520 }
521 else
522 {
523 Vmath::Vmul(m_numElmt * m_nquad0, m_jacWStdW, 1, input, 1, wsp, 1);
524
525 // out = B0*in;
526 Blas::Dgemm('T', 'N', m_nmodes0, m_numElmt, m_nquad0, 1.0,
527 m_base0.get(), m_nquad0, &wsp[0], m_nquad0, 0.0,
528 &output[0], m_nmodes0);
529 }
530 }
531
532 void operator()(int dir, const Array<OneD, const NekDouble> &input,
534 Array<OneD, NekDouble> &wsp) override final
535 {
536 boost::ignore_unused(dir, input, output, wsp);
537 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
538 }
539
541 int coll_phys_offset) override
542 {
543 boost::ignore_unused(factors, coll_phys_offset);
544 ASSERTL0(false, "Not valid for this operator.");
545 }
546
547protected:
548 const int m_nquad0;
549 const int m_nmodes0;
550 const bool m_colldir0;
553
554private:
556 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
558 : Operator(pCollExp, pGeomData, factors),
559 m_nquad0(m_stdExp->GetNumPoints(0)),
560 m_nmodes0(m_stdExp->GetBasisNumModes(0)),
561 m_colldir0(m_stdExp->GetBasis(0)->Collocation()),
562 m_base0(m_stdExp->GetBasis(0)->GetBdata())
563 {
565 m_jacWStdW = pGeomData->GetJacWithStdWeights(pCollExp);
566 }
567};
568
569/// Factory initialisation for the IProductWRTBase_SumFac_Seg operator
570OperatorKey IProductWRTBase_SumFac_Seg::m_type =
573 IProductWRTBase_SumFac_Seg::create, "IProductWRTBase_SumFac_Seg");
574
575/**
576 * @brief Inner product operator using sum-factorisation (Quad)
577 */
579{
580public:
582
584 {
585 }
586
589 Array<OneD, NekDouble> &output1,
590 Array<OneD, NekDouble> &output2,
591 Array<OneD, NekDouble> &wsp) override final
592 {
593 boost::ignore_unused(output1, output2);
594
595 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
596
599 output, wsp);
600 }
601
602 void operator()(int dir, const Array<OneD, const NekDouble> &input,
604 Array<OneD, NekDouble> &wsp) override final
605 {
606 boost::ignore_unused(dir, input, output, wsp);
607 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
608 }
609
611 int coll_phys_offset) override
612 {
613 boost::ignore_unused(factors, coll_phys_offset);
614 ASSERTL0(false, "Not valid for this operator.");
615 }
616
617protected:
618 const int m_nquad0;
619 const int m_nquad1;
620 const int m_nmodes0;
621 const int m_nmodes1;
622 const bool m_colldir0;
623 const bool m_colldir1;
627
628private:
630 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
632 : Operator(pCollExp, pGeomData, factors),
633 m_nquad0(m_stdExp->GetNumPoints(0)),
634 m_nquad1(m_stdExp->GetNumPoints(1)),
635 m_nmodes0(m_stdExp->GetBasisNumModes(0)),
636 m_nmodes1(m_stdExp->GetBasisNumModes(1)),
637 m_colldir0(m_stdExp->GetBasis(0)->Collocation()),
638 m_colldir1(m_stdExp->GetBasis(1)->Collocation()),
639 m_base0(m_stdExp->GetBasis(0)->GetBdata()),
640 m_base1(m_stdExp->GetBasis(1)->GetBdata())
641 {
642 m_jacWStdW = pGeomData->GetJacWithStdWeights(pCollExp);
643 m_wspSize =
645 }
646};
647
648/// Factory initialisation for the IProductWRTBase_SumFac_Quad operator
649OperatorKey IProductWRTBase_SumFac_Quad::m_type =
652 IProductWRTBase_SumFac_Quad::create, "IProductWRTBase_SumFac_Quad");
653
654/**
655 * @brief Inner product operator using sum-factorisation (Tri)
656 */
658{
659public:
661
663 {
664 }
665
668 Array<OneD, NekDouble> &output1,
669 Array<OneD, NekDouble> &output2,
670 Array<OneD, NekDouble> &wsp) override final
671 {
672 boost::ignore_unused(output1, output2);
673
674 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
675
677 m_nmodes1, m_base0, m_base1, m_jacWStdW, input, output,
678 wsp);
679 }
680
681 void operator()(int dir, const Array<OneD, const NekDouble> &input,
683 Array<OneD, NekDouble> &wsp) override final
684 {
685 boost::ignore_unused(dir, input, output, wsp);
686 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
687 }
688
690 int coll_phys_offset) override
691 {
692 boost::ignore_unused(factors, coll_phys_offset);
693 ASSERTL0(false, "Not valid for this operator.");
694 }
695
696protected:
697 const int m_nquad0;
698 const int m_nquad1;
699 const int m_nmodes0;
700 const int m_nmodes1;
705
706private:
708 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
710 : Operator(pCollExp, pGeomData, factors),
711 m_nquad0(m_stdExp->GetNumPoints(0)),
712 m_nquad1(m_stdExp->GetNumPoints(1)),
713 m_nmodes0(m_stdExp->GetBasisNumModes(0)),
714 m_nmodes1(m_stdExp->GetBasisNumModes(1)),
715 m_base0(m_stdExp->GetBasis(0)->GetBdata()),
716 m_base1(m_stdExp->GetBasis(1)->GetBdata())
717 {
718 m_jacWStdW = pGeomData->GetJacWithStdWeights(pCollExp);
719 m_wspSize =
721 if (m_stdExp->GetBasis(0)->GetBasisType() == LibUtilities::eModified_A)
722 {
723 m_sortTopVertex = true;
724 }
725 else
726 {
727 m_sortTopVertex = false;
728 }
729 }
730};
731
732/// Factory initialisation for the IProductWRTBase_SumFac_Tri operator
733OperatorKey IProductWRTBase_SumFac_Tri::m_type =
736 IProductWRTBase_SumFac_Tri::create, "IProductWRTBase_SumFac_Tri");
737
738/**
739 * @brief Inner Product operator using sum-factorisation (Hex)
740 */
742{
743public:
745
747 {
748 }
749
752 Array<OneD, NekDouble> &output1,
753 Array<OneD, NekDouble> &output2,
754 Array<OneD, NekDouble> &wsp) override final
755 {
756 boost::ignore_unused(output1, output2);
757
758 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
759
762 m_base0, m_base1, m_base2, m_jacWStdW, input, output, wsp);
763 }
764
765 void operator()(int dir, const Array<OneD, const NekDouble> &input,
767 Array<OneD, NekDouble> &wsp) override final
768 {
769 boost::ignore_unused(dir, input, output, wsp);
770 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
771 }
772
774 int coll_phys_offset) override
775 {
776 boost::ignore_unused(factors, coll_phys_offset);
777 ASSERTL0(false, "Not valid for this operator.");
778 }
779
780protected:
781 const int m_nquad0;
782 const int m_nquad1;
783 const int m_nquad2;
784 const int m_nmodes0;
785 const int m_nmodes1;
786 const int m_nmodes2;
787 const bool m_colldir0;
788 const bool m_colldir1;
789 const bool m_colldir2;
794
795private:
797 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
799 : Operator(pCollExp, pGeomData, factors),
800 m_nquad0(m_stdExp->GetNumPoints(0)),
801 m_nquad1(m_stdExp->GetNumPoints(1)),
802 m_nquad2(m_stdExp->GetNumPoints(2)),
803 m_nmodes0(m_stdExp->GetBasisNumModes(0)),
804 m_nmodes1(m_stdExp->GetBasisNumModes(1)),
805 m_nmodes2(m_stdExp->GetBasisNumModes(2)),
806 m_colldir0(m_stdExp->GetBasis(0)->Collocation()),
807 m_colldir1(m_stdExp->GetBasis(1)->Collocation()),
808 m_colldir2(m_stdExp->GetBasis(2)->Collocation()),
809 m_base0(m_stdExp->GetBasis(0)->GetBdata()),
810 m_base1(m_stdExp->GetBasis(1)->GetBdata()),
811 m_base2(m_stdExp->GetBasis(2)->GetBdata())
812
813 {
814 m_jacWStdW = pGeomData->GetJacWithStdWeights(pCollExp);
815 m_wspSize = 3 * m_numElmt *
816 (max(m_nquad0 * m_nquad1 * m_nquad2,
818 }
819};
820
821/// Factory initialisation for the IProductWRTBase_SumFac_Hex operator
822OperatorKey IProductWRTBase_SumFac_Hex::m_type =
825 IProductWRTBase_SumFac_Hex::create, "IProductWRTBase_SumFac_Hex");
826
827/**
828 * @brief Inner product operator using sum-factorisation (Tet)
829 */
831{
832public:
834
836 {
837 }
838
841 Array<OneD, NekDouble> &output1,
842 Array<OneD, NekDouble> &output2,
843 Array<OneD, NekDouble> &wsp) override final
844 {
845 boost::ignore_unused(output1, output2);
846
847 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
848
851 m_jacWStdW, input, output, wsp);
852 }
853
854 void operator()(int dir, const Array<OneD, const NekDouble> &input,
856 Array<OneD, NekDouble> &wsp) override final
857 {
858 boost::ignore_unused(dir, input, output, wsp);
859 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
860 }
861
863 int coll_phys_offset) override
864 {
865 boost::ignore_unused(factors, coll_phys_offset);
866 ASSERTL0(false, "Not valid for this operator.");
867 }
868
869protected:
870 const int m_nquad0;
871 const int m_nquad1;
872 const int m_nquad2;
873 const int m_nmodes0;
874 const int m_nmodes1;
875 const int m_nmodes2;
881
882private:
884 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
886 : Operator(pCollExp, pGeomData, factors),
887 m_nquad0(m_stdExp->GetNumPoints(0)),
888 m_nquad1(m_stdExp->GetNumPoints(1)),
889 m_nquad2(m_stdExp->GetNumPoints(2)),
890 m_nmodes0(m_stdExp->GetBasisNumModes(0)),
891 m_nmodes1(m_stdExp->GetBasisNumModes(1)),
892 m_nmodes2(m_stdExp->GetBasisNumModes(2)),
893 m_base0(m_stdExp->GetBasis(0)->GetBdata()),
894 m_base1(m_stdExp->GetBasis(1)->GetBdata()),
895 m_base2(m_stdExp->GetBasis(2)->GetBdata())
896 {
897 m_jacWStdW = pGeomData->GetJacWithStdWeights(pCollExp);
898 m_wspSize =
899 m_numElmt *
900 (max(m_nquad0 * m_nquad1 * m_nquad2,
901 m_nquad2 * m_nmodes0 * (2 * m_nmodes1 - m_nmodes0 + 1) / 2) +
903
904 if (m_stdExp->GetBasis(0)->GetBasisType() == LibUtilities::eModified_A)
905 {
906 m_sortTopEdge = true;
907 }
908 else
909 {
910 m_sortTopEdge = false;
911 }
912 }
913};
914
915/// Factory initialisation for the IProductWRTBase_SumFac_Tet operator
916OperatorKey IProductWRTBase_SumFac_Tet::m_type =
919 IProductWRTBase_SumFac_Tet::create, "IProductWRTBase_SumFac_Tet");
920
921/**
922 * @brief Inner Product operator using sum-factorisation (Prism)
923 */
925{
926public:
928
930 {
931 }
932
935 Array<OneD, NekDouble> &output1,
936 Array<OneD, NekDouble> &output2,
937 Array<OneD, NekDouble> &wsp) override final
938 {
939 boost::ignore_unused(output1, output2);
940
941 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
942
945 m_base2, m_jacWStdW, input, output, wsp);
946 }
947
948 void operator()(int dir, const Array<OneD, const NekDouble> &input,
950 Array<OneD, NekDouble> &wsp) override final
951 {
952 boost::ignore_unused(dir, input, output, wsp);
953 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
954 }
955
957 int coll_phys_offset) override
958 {
959 boost::ignore_unused(factors, coll_phys_offset);
960 ASSERTL0(false, "Not valid for this operator.");
961 }
962
963protected:
964 const int m_nquad0;
965 const int m_nquad1;
966 const int m_nquad2;
967 const int m_nmodes0;
968 const int m_nmodes1;
969 const int m_nmodes2;
975
976private:
978 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
980 : Operator(pCollExp, pGeomData, factors),
981 m_nquad0(m_stdExp->GetNumPoints(0)),
982 m_nquad1(m_stdExp->GetNumPoints(1)),
983 m_nquad2(m_stdExp->GetNumPoints(2)),
984 m_nmodes0(m_stdExp->GetBasisNumModes(0)),
985 m_nmodes1(m_stdExp->GetBasisNumModes(1)),
986 m_nmodes2(m_stdExp->GetBasisNumModes(2)),
987 m_base0(m_stdExp->GetBasis(0)->GetBdata()),
988 m_base1(m_stdExp->GetBasis(1)->GetBdata()),
989 m_base2(m_stdExp->GetBasis(2)->GetBdata())
990
991 {
992 m_jacWStdW = pGeomData->GetJacWithStdWeights(pCollExp);
993
997
998 if (m_stdExp->GetBasis(0)->GetBasisType() == LibUtilities::eModified_A)
999 {
1000 m_sortTopVertex = true;
1001 }
1002 else
1003 {
1004 m_sortTopVertex = false;
1005 }
1006 }
1007};
1008
1009/// Factory initialisation for the IProductWRTBase_SumFac_Prism operator
1010OperatorKey IProductWRTBase_SumFac_Prism::m_type =
1013 IProductWRTBase_SumFac_Prism::create, "IProductWRTBase_SumFac_Prism");
1014
1015/**
1016 * @brief Inner Product operator using sum-factorisation (Pyr)
1017 */
1019{
1020public:
1022
1024 {
1025 }
1026
1028 Array<OneD, NekDouble> &output,
1029 Array<OneD, NekDouble> &output1,
1030 Array<OneD, NekDouble> &output2,
1031 Array<OneD, NekDouble> &wsp) override final
1032 {
1033 boost::ignore_unused(output1, output2);
1034
1035 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
1036
1039 m_jacWStdW, input, output, wsp);
1040 }
1041
1042 void operator()(int dir, const Array<OneD, const NekDouble> &input,
1043 Array<OneD, NekDouble> &output,
1044 Array<OneD, NekDouble> &wsp) override final
1045 {
1046 boost::ignore_unused(dir, input, output, wsp);
1047 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
1048 }
1049
1051 int coll_phys_offset) override
1052 {
1053 boost::ignore_unused(factors, coll_phys_offset);
1054 ASSERTL0(false, "Not valid for this operator.");
1055 }
1056
1057protected:
1058 const int m_nquad0;
1059 const int m_nquad1;
1060 const int m_nquad2;
1061 const int m_nmodes0;
1062 const int m_nmodes1;
1063 const int m_nmodes2;
1069
1070private:
1072 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
1074 : Operator(pCollExp, pGeomData, factors),
1075 m_nquad0(m_stdExp->GetNumPoints(0)),
1076 m_nquad1(m_stdExp->GetNumPoints(1)),
1077 m_nquad2(m_stdExp->GetNumPoints(2)),
1078 m_nmodes0(m_stdExp->GetBasisNumModes(0)),
1079 m_nmodes1(m_stdExp->GetBasisNumModes(1)),
1080 m_nmodes2(m_stdExp->GetBasisNumModes(2)),
1081 m_base0(m_stdExp->GetBasis(0)->GetBdata()),
1082 m_base1(m_stdExp->GetBasis(1)->GetBdata()),
1083 m_base2(m_stdExp->GetBasis(2)->GetBdata())
1084
1085 {
1086 m_jacWStdW = pGeomData->GetJacWithStdWeights(pCollExp);
1087
1089 (max(m_nquad0 * m_nquad1, m_nmodes0 * m_nmodes1)) +
1091
1092 if (m_stdExp->GetBasis(0)->GetBasisType() == LibUtilities::eModified_A)
1093 {
1094 m_sortTopVertex = true;
1095 }
1096 else
1097 {
1098 m_sortTopVertex = false;
1099 }
1100 }
1101};
1102
1103/// Factory initialisation for the IProductWRTBase_SumFac_Pyr operator
1104OperatorKey IProductWRTBase_SumFac_Pyr::m_type =
1107 IProductWRTBase_SumFac_Pyr::create, "IProductWRTBase_SumFac_Pyr");
1108
1109} // namespace Collections
1110} // namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
#define OPERATOR_CREATE(cname)
Definition: Operator.h:45
Inner product operator using element-wise operation.
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
IProductWRTBase_IterPerExp(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
Inner product operator using operator using matrix free operators.
IProductWRTBase_MatrixFree(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
virtual void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
std::shared_ptr< MatrixFree::IProduct > m_oper
Inner product operator using original MultiRegions implementation.
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
vector< StdRegions::StdExpansionSharedPtr > m_expList
IProductWRTBase_NoCollection(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
Inner product operator using standard matrix approach.
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
IProductWRTBase_StdMat(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
Inner Product operator using sum-factorisation (Hex)
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
IProductWRTBase_SumFac_Hex(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
Inner Product operator using sum-factorisation (Prism)
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
IProductWRTBase_SumFac_Prism(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
Inner Product operator using sum-factorisation (Pyr)
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
IProductWRTBase_SumFac_Pyr(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
Inner product operator using sum-factorisation (Quad)
IProductWRTBase_SumFac_Quad(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
Inner product operator using sum-factorisation (Segment)
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
IProductWRTBase_SumFac_Seg(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
Inner product operator using sum-factorisation (Tet)
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
IProductWRTBase_SumFac_Tet(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
Inner product operator using sum-factorisation (Tri)
IProductWRTBase_SumFac_Tri(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
void operator()(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
Perform operation.
unsigned int m_nElmtPad
size after padding
Array< OneD, NekDouble > m_input
padded input/output vectors
Base class for operators on a collection of elements.
Definition: Operator.h:119
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Operator.h:165
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:144
static void Dgemm(const char &transa, const char &transb, const int &m, const int &n, const int &k, const double &alpha, const double *a, const int &lda, const double *b, const int &ldb, const double &beta, double *c, const int &ldc)
BLAS level 3: Matrix-matrix multiply C = A x B where op(A)[m x k], op(B)[k x n], C[m x n] DGEMM perfo...
Definition: Blas.hpp:385
void TetIProduct(bool sortTopEdge, int numElmt, int nquad0, int nquad1, int nquad2, int nmodes0, int nmodes1, int nmodes2, const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &base2, const Array< OneD, const NekDouble > &jac, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp)
Definition: IProduct.cpp:500
void PyrIProduct(bool sortTopVert, int numElmt, int nquad0, int nquad1, int nquad2, int nmodes0, int nmodes1, int nmodes2, const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &base2, const Array< OneD, const NekDouble > &jac, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp)
Definition: IProduct.cpp:409
void TriIProduct(bool sortTopVertex, int numElmt, int nquad0, int nquad1, int nmodes0, int nmodes1, const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &jac, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp)
Definition: IProduct.cpp:131
std::tuple< LibUtilities::ShapeType, OperatorType, ImplementationType, ExpansionIsNodal > OperatorKey
Key for describing an Operator.
Definition: Operator.h:177
void QuadIProduct(bool colldir0, bool colldir1, int numElmt, int nquad0, int nquad1, int nmodes0, int nmodes1, const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &jac, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp)
Definition: IProduct.cpp:48
std::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
OperatorFactory & GetOperatorFactory()
Returns the singleton Operator factory object.
Definition: Operator.cpp:117
void PrismIProduct(bool sortTopVert, int numElmt, int nquad0, int nquad1, int nquad2, int nmodes0, int nmodes1, int nmodes2, const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &base2, const Array< OneD, const NekDouble > &jac, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp)
Definition: IProduct.cpp:342
void HexIProduct(bool colldir0, bool colldir1, bool colldir2, int numElmt, int nquad0, int nquad1, int nquad2, int nmodes0, int nmodes1, int nmodes2, const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &base2, const Array< OneD, const NekDouble > &jac, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp)
Definition: IProduct.cpp:173
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:236
@ eModified_A
Principle Modified Functions .
Definition: BasisType.h:50
ConstFactorMap FactorMap
Definition: StdRegions.hpp:412
StdRegions::ConstFactorMap factors
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:207
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.cpp:245
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1191