Nektar++
Loading...
Searching...
No Matches
ProcessJacobianEnergy.cpp
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2//
3// File: ProcessJacobianEnergy.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: Compute energy of Jacobian.
32//
33////////////////////////////////////////////////////////////////////////////////
34
35#include <iostream>
36#include <string>
37using namespace std;
38
40
42
43namespace Nektar::FieldUtils
44{
45
48 ModuleKey(eProcessModule, "jacobianenergy"),
50 "Show high frequency energy of Jacobian.");
51
53 : ProcessModule(f)
54{
55 m_config["topmodes"] =
56 ConfigOption(false, "1", "how many top modes to keep ");
57}
58
62
63void ProcessJacobianEnergy::v_Process(po::variables_map &vm)
64{
65 m_f->SetUpExp(vm);
66
67 int nfields = m_f->m_variables.size();
68 m_f->m_variables.push_back("jacenergy");
69 // Skip in case of empty partition
70 if (m_f->m_exp[0]->GetNumElmts() == 0)
71 {
72 return;
73 }
74
75 int NumHomogeneousDir = m_f->m_numHomogeneousDir;
77
78 if (nfields)
79 {
80 m_f->m_exp.resize(nfields + 1);
81 exp = m_f->AppendExpList(NumHomogeneousDir);
82 m_f->m_exp[nfields] = exp;
83 }
84 else
85 {
86 exp = m_f->m_exp[0];
87 }
88
89 Array<OneD, NekDouble> phys = exp->UpdatePhys();
90 Array<OneD, NekDouble> coeffs = exp->UpdateCoeffs();
92
93 for (int i = 0; i < exp->GetExpSize(); ++i)
94 {
95 // copy Jacobian into field
96 StdRegions::StdExpansionSharedPtr Elmt = exp->GetExp(i);
97
98 const StdRegions::StdExpansion *sep = &(*Elmt);
99 const LocalRegions::Expansion *lep =
100 dynamic_cast<const LocalRegions::Expansion *>(sep);
101
102 int nquad = Elmt->GetTotPoints();
103 int coeffoffset = exp->GetCoeff_Offset(i);
106 {
107 Vmath::Fill(nquad, Jac[0], phys, 1);
108 }
109 else
110 {
111 Vmath::Vcopy(nquad, Jac, 1, phys, 1);
112 }
113
115 {
116 NekDouble jacmax = Vmath::Vmax(nquad, Jac, 1);
117 NekDouble jacmin = Vmath::Vmin(nquad, Jac, 1);
118
119 NekDouble jacmeasure = jacmax / jacmin - 1.0;
120 Vmath::Fill(nquad, jacmeasure, phys, 1);
121 }
122 else
123 {
124 Vmath::Fill(nquad, 0.0, phys, 1);
125 }
126
127 Elmt->FwdTrans(phys, tmp = coeffs + coeffoffset);
128 }
129 exp->BwdTrans(coeffs, phys);
130}
131} // namespace Nektar::FieldUtils
FieldSharedPtr m_f
Field object.
Definition Module.h:239
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition Module.h:272
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
void v_Process(po::variables_map &vm) override
Write mesh to output file.
Abstract base class for processing modules.
Definition Module.h:301
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
SpatialDomains::GeomFactors * GetGeomFactors() const
Get the geometric factors for this object, generating them if required.
Definition Expansion.h:471
const Array< OneD, const NekDouble > GetJac()
Return the Jacobian of the mapping.
GeomType GetGtype()
Returns whether the geometry is regular or deformed.
The base class for all shapes.
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
std::shared_ptr< Field > FieldSharedPtr
Definition Field.hpp:1030
std::pair< ModuleType, std::string > ModuleKey
Definition Module.h:180
ModuleFactory & GetModuleFactory()
Definition Module.cpp:47
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
@ eRegular
Geometry is straight-sided with constant geometric factors.
@ eDeformed
Geometry is curved or has non-constant factors.
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition Vmath.hpp:725
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition Vmath.hpp:54
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition Vmath.hpp:644
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