Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Compute energy of Jacobian.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #include <string>
37 #include <iostream>
38 using namespace std;
39 
40 #include "ProcessJacobianEnergy.h"
41 
44 
45 namespace Nektar
46 {
47 namespace Utilities
48 {
49 
50 ModuleKey ProcessJacobianEnergy::className =
52  ModuleKey(eProcessModule, "jacobianenergy"),
53  ProcessJacobianEnergy::create,
54  "Show high frequency energy of Jacobian.");
55 
56 ProcessJacobianEnergy::ProcessJacobianEnergy(FieldSharedPtr f) :
57  ProcessModule(f)
58 {
59  m_config["topmodes"] = ConfigOption(false, "1",
60  "how many top modes to keep ");
61 }
62 
64 {
65 }
66 
67 void ProcessJacobianEnergy::Process(po::variables_map &vm)
68 {
69  if (m_f->m_verbose)
70  {
71  cout << "ProcessJacobianEnergy: Process Jacobian fld" << endl;
72  }
73 
74  Array<OneD, NekDouble> phys = m_f->m_exp[0]->UpdatePhys();
75  Array<OneD, NekDouble> coeffs = m_f->m_exp[0]->UpdateCoeffs();
76  Array<OneD, NekDouble> tmp,tmp1;
77 
78  for(int i =0; i < m_f->m_exp[0]->GetExpSize(); ++i)
79  {
80  // copy Jacobian into field
81  StdRegions::StdExpansionSharedPtr Elmt = m_f->m_exp[0]->GetExp(i);
82 
83  int ncoeffs = Elmt->GetNcoeffs();
84  int nquad = Elmt->GetTotPoints();
85  int coeffoffset = m_f->m_exp[0]->GetCoeff_Offset(i);
86  Array<OneD, NekDouble> coeffs1(ncoeffs);
88  Elmt->GetMetricInfo()->GetJac(Elmt->GetPointsKeys());
89  if(Elmt->GetMetricInfo()->GetGtype() == SpatialDomains::eRegular)
90  {
91  Vmath::Fill(nquad,Jac[0],phys,1);
92  }
93  else
94  {
95  Vmath::Vcopy(nquad,Jac,1,phys,1);
96  }
97 
98  if(Elmt->GetMetricInfo()->GetGtype() == SpatialDomains::eDeformed)
99  {
100  NekDouble jacmax = Vmath::Vmax(nquad,Jac,1);
101  NekDouble jacmin = Vmath::Vmin(nquad,Jac,1);
102 
103  NekDouble jacmeasure = jacmax/jacmin -1.0;
104  Vmath::Fill(nquad,jacmeasure,phys,1);
105  }
106  else
107  {
108  Vmath::Fill(nquad,0.0,phys,1);
109  }
110 
111  Elmt->FwdTrans(phys,tmp = coeffs + coeffoffset);
112  }
113 
114  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
115  = m_f->m_exp[0]->GetFieldDefinitions();
116  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
117 
118  for (int i = 0; i < FieldDef.size(); ++i)
119  {
120  FieldDef[i]->m_fields.push_back("JacobianEnergy");
121  m_f->m_exp[0]->AppendFieldData(FieldDef[i], FieldData[i]);
122  }
123 
124  m_f->m_fielddef = FieldDef;
125  m_f->m_data = FieldData;
126 }
127 
128 }
129 }
pair< ModuleType, string > ModuleKey
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.cpp:765
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.cpp:857
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:46
virtual void Process()=0
map< string, ConfigOption > m_config
List of configuration values.
STL namespace.
FieldSharedPtr m_f
Field object.
double NekDouble
boost::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:695
Represents a command-line configuration option.
Geometry is straight-sided with constant geometric factors.
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
Geometry is curved or has non-constant factors.
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215