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>
37 using namespace std;
38 
39 #include <boost/core/ignore_unused.hpp>
40 
42 #include <StdRegions/StdQuadExp.h>
43 
44 #include "ProcessNumModes.h"
45 
46 namespace Nektar
47 {
48 namespace FieldUtils
49 {
50 
51 ModuleKey ProcessNumModes::className =
53  ModuleKey(eProcessModule, "nummodes"),
54  ProcessNumModes::create,
55  "Computes number of modes in each direction for each element.");
56 
57 ProcessNumModes::ProcessNumModes(FieldSharedPtr f) : ProcessModule(f)
58 {
59 }
60 
62 {
63 }
64 
65 void ProcessNumModes::Process(po::variables_map &vm)
66 {
67  m_f->SetUpExp(vm);
68 
69  int i, s;
70  int expdim = m_f->m_graph->GetMeshDimension();
71  int nfields = m_f->m_variables.size();
72  int addfields = expdim;
73 
74  m_f->m_variables.push_back("P1");
75  if (addfields >= 2)
76  {
77  m_f->m_variables.push_back("P2");
78  }
79  if (addfields == 3)
80  {
81  m_f->m_variables.push_back("P3");
82  }
83 
84  // Skip in case of empty partition
85  if (m_f->m_exp[0]->GetNumElmts() == 0)
86  {
87  return;
88  }
89 
90  int npoints = m_f->m_exp[0]->GetNpoints();
91  Array<OneD, Array<OneD, NekDouble> > outfield(addfields);
92  int nstrips;
93 
94  m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
95 
96  for (i = 0; i < addfields; ++i)
97  {
98  outfield[i] = Array<OneD, NekDouble>(npoints);
99  }
100 
102 
103  int nExp, nq, offset;
104  nExp = m_f->m_exp[0]->GetExpSize();
105 
106  for (int n = 0; n < nExp; n++)
107  {
108  offset = m_f->m_exp[0]->GetPhys_Offset(n);
109  nq = m_f->m_exp[0]->GetExp(n)->GetTotPoints();
110 
111  for (i = 0; i < expdim; i++)
112  {
113  int P = m_f->m_exp[0]->GetExp(n)->GetBasis(i)->GetNumModes();
114  Array<OneD, NekDouble> result = outfield[i] + offset;
115  Vmath::Fill(nq, 1.0 * P, result, 1);
116  }
117  }
118 
119  for (s = 0; s < nstrips; ++s)
120  {
121  for (i = 0; i < addfields; ++i)
122  {
123  Exp = m_f->AppendExpList(m_f->m_numHomogeneousDir);
124  Vmath::Vcopy(npoints, outfield[i], 1, Exp->UpdatePhys(), 1);
125  Exp->FwdTrans_IterPerExp(outfield[i], Exp->UpdateCoeffs());
126 
127  auto it =
128  m_f->m_exp.begin() + s * (nfields + addfields) + nfields + i;
129  m_f->m_exp.insert(it, Exp);
130  }
131  }
132 
133 }
134 }
135 }
FieldSharedPtr m_f
Field object.
Definition: Module.h:230
Abstract base class for processing modules.
Definition: Module.h:265
virtual void Process(po::variables_map &vm)
Write mesh to output file.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:200
std::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:989
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:290
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199
P
Definition: main.py:133