Nektar++
Loading...
Searching...
No Matches
ProcessForceDecomposeVol.cpp
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2//
3// File: ProcessForceDecomposeVol.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: Computes volume force elements using weighted pressure source
32// theory.
33//
34////////////////////////////////////////////////////////////////////////////////
35
36#include <iostream>
37#include <string>
38using namespace std;
39
42
44
45namespace Nektar::FieldUtils
46{
47
50 ModuleKey(eProcessModule, "FDecomposeVol"),
51 ProcessForceDecomposeVol::create, "Computes volume force elements.");
52
55{
57 false, "0", "Method to obtain Q: 0 user provided; 1 from pressure;");
58 m_config["box"] = ConfigOption(false, "NotSet",
59 "Bounding box of the integration domain "
60 "box=xmin,xmax,ymin,ymax,zmin,zmax");
61 m_config["scandir"] = ConfigOption(false, "NotSet", "Scan direction");
62}
63
67
68void ProcessForceDecomposeVol::v_Process(po::variables_map &vm)
69{
70 m_f->SetUpExp(vm);
71
72 int nfields = m_f->m_variables.size();
73 m_expdim = m_f->m_graph->GetSpaceDimension();
74 m_spacedim = m_expdim + m_f->m_numHomogeneousDir;
75 ASSERTL0(m_spacedim == 3 || m_spacedim == 2,
76 "ProcessForceDecomposeVol must be computed for a 2D, quasi-3D, or "
77 "3D case.");
78
79 // Skip in case of empty partition
80 if (m_f->m_exp[0]->GetNumElmts() == 0)
81 {
82 return;
83 }
84
86 if (m_config["box"].as<string>().compare("NotSet") != 0)
87 {
88 vector<NekDouble> values;
89 ParseUtils::GenerateVector(m_config["box"].as<string>(), values);
90
92 values.size() == 6,
93 "box string should contain 6 values xmin,xmax,ymin,ymax,zmin,zmax");
94 BoundBox = Array<OneD, NekDouble>(values.size());
95 for (size_t i = 0; i < values.size(); ++i)
96 {
97 BoundBox[i] = values[i];
98 }
99 }
100 else
101 {
102 BoundBox = Array<OneD, NekDouble>(6);
103 BoundBox[0] = -3.;
104 BoundBox[1] = 6.;
105 BoundBox[2] = -3.;
106 BoundBox[3] = 3.;
107 BoundBox[4] = -1.;
108 BoundBox[5] = 1.;
109 }
110 int scanDir = 0;
111 if (m_config["scandir"].as<string>().compare("NotSet") != 0)
112 {
113 scanDir = m_config["scandir"].as<int>();
114 }
115
116 std::map<int, std::string> Iphi;
117 for (size_t i = 0; i < m_f->m_variables.size(); ++i)
118 {
119 if (std::string::npos != m_f->m_variables[i].find("phi"))
120 {
121 Iphi[i] = m_f->m_variables[i];
122 }
123 }
124 int addfields = Iphi.size();
125
126 int npoints = m_f->m_exp[0]->GetNpoints();
127
128 int nstrips;
129 m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
130
131 vector<MultiRegions::ExpListSharedPtr> Exp(nstrips * addfields);
132
133 for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
134 {
136 for (int i = 0; i < nfields; ++i)
137 {
138 exp[i] = m_f->m_exp[s * nfields + i];
139 }
140 Array<OneD, NekDouble> Q(npoints);
141 GetQ(exp, Q);
142 Array<OneD, Array<OneD, NekDouble>> Qphi(Iphi.size());
143 int i = 0;
144 for (const auto &phi : Iphi)
145 {
146 Qphi[i] = Array<OneD, NekDouble>(npoints, 0.);
147 Vmath::Vmul(npoints, Q, 1,
148 m_f->m_exp[s * nfields + phi.first]->GetPhys(), 1,
149 Qphi[i], 1);
150 Vmath::Smul(npoints, 2., Qphi[i], 1, Qphi[i], 1);
151
152 Exp[s * addfields + i] =
153 m_f->AppendExpList(m_f->m_numHomogeneousDir);
154 Vmath::Vcopy(npoints, Qphi[i], 1,
155 Exp[s * addfields + i]->UpdatePhys(), 1);
156 Exp[s * addfields + i]->FwdTransLocalElmt(
157 Qphi[i], Exp[s * addfields + i]->UpdateCoeffs());
158
159 auto it =
160 m_f->m_exp.begin() + s * (nfields + addfields) + nfields + i;
161 m_f->m_exp.insert(it, Exp[s * addfields + i]);
162 ++i;
163 }
164 // process force
165 VolumeIntegrateForce(m_f->m_exp[0], Qphi, m_f->m_comm, Iphi, BoundBox,
166 scanDir);
167 }
168
169 for (const auto &phi : Iphi)
170 {
171 m_f->m_variables.push_back("Q" + phi.second);
172 }
173}
174
175} // namespace Nektar::FieldUtils
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
Definition Module.h:239
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition Module.h:272
This processing module calculates the Q Criterion and adds it as an extra-field to the output file.
void GetQ(const Array< OneD, MultiRegions::ExpListSharedPtr > exp, Array< OneD, NekDouble > &Q)
void VolumeIntegrateForce(const MultiRegions::ExpListSharedPtr &field, const Array< OneD, Array< OneD, NekDouble > > &data, const LibUtilities::CommSharedPtr &comm, std::map< int, std::string > &Iphi, Array< OneD, NekDouble > &BoundBox, int dir)
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.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
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
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.hpp:72
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.hpp:100
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825
STL namespace.
Represents a command-line configuration option.
Definition Module.h:129