Nektar++
ProcessNumModes.cpp
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2//
3// File: ProcessNumModes.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: Writes the number of modes in each direction.
32//
33////////////////////////////////////////////////////////////////////////////////
34
35#include <iostream>
36#include <string>
37using namespace std;
38
41
42#include "ProcessNumModes.h"
43
44namespace Nektar::FieldUtils
45{
46
50 "Computes number of modes in each direction for each element.");
51
53{
54}
55
57{
58}
59
60void ProcessNumModes::v_Process(po::variables_map &vm)
61{
62 m_f->SetUpExp(vm);
63
64 int i, s;
65 int expdim = m_f->m_graph->GetMeshDimension();
66 int nfields = m_f->m_variables.size();
67 int addfields = expdim;
68
69 m_f->m_variables.push_back("P1");
70 if (addfields >= 2)
71 {
72 m_f->m_variables.push_back("P2");
73 }
74 if (addfields == 3)
75 {
76 m_f->m_variables.push_back("P3");
77 }
78
79 // Skip in case of empty partition
80 if (m_f->m_exp[0]->GetNumElmts() == 0)
81 {
82 return;
83 }
84
85 int npoints = m_f->m_exp[0]->GetNpoints();
86 Array<OneD, Array<OneD, NekDouble>> outfield(addfields);
87 int nstrips;
88
89 m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
90
91 for (i = 0; i < addfields; ++i)
92 {
93 outfield[i] = Array<OneD, NekDouble>(npoints);
94 }
95
96 int nExp, nq, offset;
97 nExp = m_f->m_exp[0]->GetExpSize();
98
99 for (int n = 0; n < nExp; n++)
100 {
101 offset = m_f->m_exp[0]->GetPhys_Offset(n);
102 nq = m_f->m_exp[0]->GetExp(n)->GetTotPoints();
103
104 for (i = 0; i < expdim; i++)
105 {
106 int P = m_f->m_exp[0]->GetExp(n)->GetBasis(i)->GetNumModes();
107 Array<OneD, NekDouble> result = outfield[i] + offset;
108 Vmath::Fill(nq, 1.0 * P, result, 1);
109 }
110 }
111
112 for (s = 0; s < nstrips; ++s) // homogeneous strip varient
113 {
114 for (i = 0; i < addfields; ++i)
115 {
117 m_f->AppendExpList(m_f->m_numHomogeneousDir);
118 auto it =
119 m_f->m_exp.begin() + s * (nfields + addfields) + nfields + i;
120 m_f->m_exp.insert(it, Exp);
121 }
122 }
123
124 for (s = 0; s < nstrips; ++s)
125 {
126 for (i = 0; i < addfields; ++i)
127 {
128 int fid = s * (nfields + addfields) + nfields + i;
129 Vmath::Vcopy(npoints, outfield[i], 1, m_f->m_exp[fid]->UpdatePhys(),
130 1);
131 m_f->m_exp[fid]->FwdTransLocalElmt(outfield[i],
132 m_f->m_exp[fid]->UpdateCoeffs());
133 }
134 }
135}
136} // namespace Nektar::FieldUtils
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
Abstract base class for processing modules.
Definition: Module.h:301
void v_Process(po::variables_map &vm) override
Write mesh to output file.
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:1026
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47
@ P
Monomial polynomials .
Definition: BasisType.h:62
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.hpp:54
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825
STL namespace.