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
39#include <boost/core/ignore_unused.hpp>
40
43
44#include "ProcessNumModes.h"
45
46namespace Nektar
47{
48namespace FieldUtils
49{
50
54 "Computes number of modes in each direction for each element.");
55
57{
58}
59
61{
62}
63
64void ProcessNumModes::v_Process(po::variables_map &vm)
65{
66 m_f->SetUpExp(vm);
67
68 int i, s;
69 int expdim = m_f->m_graph->GetMeshDimension();
70 int nfields = m_f->m_variables.size();
71 int addfields = expdim;
72
73 m_f->m_variables.push_back("P1");
74 if (addfields >= 2)
75 {
76 m_f->m_variables.push_back("P2");
77 }
78 if (addfields == 3)
79 {
80 m_f->m_variables.push_back("P3");
81 }
82
83 // Skip in case of empty partition
84 if (m_f->m_exp[0]->GetNumElmts() == 0)
85 {
86 return;
87 }
88
89 int npoints = m_f->m_exp[0]->GetNpoints();
90 Array<OneD, Array<OneD, NekDouble>> outfield(addfields);
91 int nstrips;
92
93 m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
94
95 for (i = 0; i < addfields; ++i)
96 {
97 outfield[i] = Array<OneD, NekDouble>(npoints);
98 }
99
100 int nExp, nq, offset;
101 nExp = m_f->m_exp[0]->GetExpSize();
102
103 for (int n = 0; n < nExp; n++)
104 {
105 offset = m_f->m_exp[0]->GetPhys_Offset(n);
106 nq = m_f->m_exp[0]->GetExp(n)->GetTotPoints();
107
108 for (i = 0; i < expdim; i++)
109 {
110 int P = m_f->m_exp[0]->GetExp(n)->GetBasis(i)->GetNumModes();
111 Array<OneD, NekDouble> result = outfield[i] + offset;
112 Vmath::Fill(nq, 1.0 * P, result, 1);
113 }
114 }
115
116 for (s = 0; s < nstrips; ++s) // homogeneous strip varient
117 {
118 for (i = 0; i < addfields; ++i)
119 {
121 m_f->AppendExpList(m_f->m_numHomogeneousDir);
122 auto it =
123 m_f->m_exp.begin() + s * (nfields + addfields) + nfields + i;
124 m_f->m_exp.insert(it, Exp);
125 }
126 }
127
128 for (s = 0; s < nstrips; ++s)
129 {
130 for (i = 0; i < addfields; ++i)
131 {
132 int fid = s * (nfields + addfields) + nfields + i;
133 Vmath::Vcopy(npoints, outfield[i], 1, m_f->m_exp[fid]->UpdatePhys(),
134 1);
135 m_f->m_exp[fid]->FwdTransLocalElmt(outfield[i],
136 m_f->m_exp[fid]->UpdateCoeffs());
137 }
138 }
139}
140} // namespace FieldUtils
141} // namespace Nektar
FieldSharedPtr m_f
Field object.
Definition: Module.h:234
Abstract base class for processing modules.
Definition: Module.h:292
virtual 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.
Definition: NekFactory.hpp:198
std::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:991
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:317
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49
@ P
Monomial polynomials .
Definition: BasisType.h:64
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:2
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:43
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1191