Nektar++
ProcessZeroHomogeneousPlane.cpp
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2//
3// File: ProcessZeroHomogeneousPlane.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: Zero the homogeneous plane in wavespace of a 3DH1D field to
32// visualise the fluctuation.
33//
34////////////////////////////////////////////////////////////////////////////////
35
36#include <iostream>
37#include <string>
38using namespace std;
39
41
43
44namespace Nektar::FieldUtils
45{
46
49 ModuleKey(eProcessModule, "zero-homo-plane"),
51 "Extracts a plane from a 3DH1D expansion, requires planeid to be "
52 "defined.");
53
55 : ProcessModule(f)
56{
57 m_config["planeid"] = ConfigOption(
58 false, "0",
59 "plane id in wavespace to be set zero. Default planeid is zero");
60}
61
63{
64}
65
66void ProcessZeroHomogeneousPlane::v_Process(po::variables_map &vm)
67{
68 m_f->SetUpExp(vm);
69
70 if (m_f->m_numHomogeneousDir != 1)
71 {
73 "ProcessZeroHomogeneousPlane only works for Homogeneous1D.");
74 }
75
76 // Skip in case of empty partition
77 if (m_f->m_exp[0]->GetNumElmts() == 0)
78 {
79 return;
80 }
81
82 int planeid = m_config["planeid"].as<int>();
83 int nfields = m_f->m_variables.size();
84
85 int nstrips;
86 m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
87
88 // Look for correct plane (because of parallel case)
89 int plane = -1;
90 for (int i = 0; i < m_f->m_exp[0]->GetZIDs().size(); ++i)
91 {
92 if (m_f->m_exp[0]->GetZIDs()[i] == planeid)
93 {
94 plane = i;
95 }
96 }
97
98 if (plane != -1)
99 {
100 for (int s = 0; s < nstrips; ++s)
101 {
102 for (int i = 0; i < nfields; ++i)
103 {
104 int n = s * nfields + i;
105
106 // Find the memory location, set zeros
107 int Ncoeff = m_f->m_exp[n]->GetPlane(plane)->GetNcoeffs();
108 Vmath::Zero(Ncoeff,
109 m_f->m_exp[n]->GetPlane(plane)->UpdateCoeffs(), 1);
110
111 m_f->m_exp[n]->BwdTrans(m_f->m_exp[n]->GetCoeffs(),
112 m_f->m_exp[n]->UpdatePhys());
113 }
114 }
115 }
116 else
117 {
118 NEKERROR(ErrorUtil::efatal, "Plane not found.");
119 }
120}
121} // namespace Nektar::FieldUtils
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:272
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.
Definition: NekFactory.hpp:197
std::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:990
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.hpp:273
Represents a command-line configuration option.
Definition: Module.h:129