Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::FieldUtils::ProcessHomogeneousStretch Class Reference

This processing module stretches the homogeneous direction of a 3DH1D expansion by an integer factor. More...

#include <ProcessHomogeneousStretch.h>

Inheritance diagram for Nektar::FieldUtils::ProcessHomogeneousStretch:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::ProcessHomogeneousStretch:
Collaboration graph
[legend]

Public Member Functions

 ProcessHomogeneousStretch (FieldSharedPtr f)
 
virtual ~ProcessHomogeneousStretch ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

Detailed Description

This processing module stretches the homogeneous direction of a 3DH1D expansion by an integer factor.

Definition at line 50 of file ProcessHomogeneousStretch.h.

Constructor & Destructor Documentation

Nektar::FieldUtils::ProcessHomogeneousStretch::ProcessHomogeneousStretch ( FieldSharedPtr  f)

Definition at line 60 of file ProcessHomogeneousStretch.cpp.

References Nektar::FieldUtils::Module::m_config.

61  : ProcessModule(f)
62 {
63  m_config["factor"] = ConfigOption(false, "NotSet", "stretch factor");
64 }
map< string, ConfigOption > m_config
List of configuration values.
Nektar::FieldUtils::ProcessHomogeneousStretch::~ProcessHomogeneousStretch ( )
virtual

Definition at line 66 of file ProcessHomogeneousStretch.cpp.

67 {
68 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::FieldUtils::ProcessHomogeneousStretch::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 54 of file ProcessHomogeneousStretch.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

55  {
57  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::FieldUtils::ProcessHomogeneousStretch::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 66 of file ProcessHomogeneousStretch.h.

67  {
68  return "ProcessHomogeneousStretch";
69  }
void Nektar::FieldUtils::ProcessHomogeneousStretch::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 70 of file ProcessHomogeneousStretch.cpp.

References ASSERTL0, Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, CellMLToNektar.cellml_metadata::p, Vmath::Vcopy(), and Vmath::Zero().

71 {
72  if (m_f->m_verbose)
73  {
74  if (m_f->m_comm->GetRank() == 0)
75  {
76  cout << "ProcessHomogeneousStretch: Stretching expansion..."
77  << endl;
78  }
79  }
80 
81  if ((m_f->m_fielddef[0]->m_numHomogeneousDir) != 1)
82  {
83  ASSERTL0(false,
84  "ProcessHomogeneousStretch only works for Homogeneous1D.");
85  }
86 
87  ASSERTL0(m_config["factor"].m_beenSet,
88  "Missing parameter factor for ProcessHomogeneousStretch");
89 
90  int factor = m_config["factor"].as<int>();
91  int nfields = m_f->m_fielddef[0]->m_fields.size();
92  int nplanes = m_f->m_exp[0]->GetHomogeneousBasis()->GetZ().num_elements();
93 
94  ASSERTL0(factor > 1, "Parameter factor must be greater than 1.");
95 
96  int nstrips;
97  m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
98 
99  for (int s = 0; s < nstrips; ++s)
100  {
101  for (int i = 0; i < nfields; ++i)
102  {
103  int n = s * nfields + i;
104  int ncoeffs = m_f->m_exp[n]->GetPlane(0)->GetNcoeffs();
105  // Loop planes backwards so we can copy in place
106  for (int p = nplanes - 1; p > 1; --p)
107  {
108  int newP = 2 * factor * (p / 2) + p % 2;
109  if (newP < nplanes)
110  {
111  Vmath::Vcopy(
112  ncoeffs, m_f->m_exp[n]->GetPlane(p)->GetCoeffs(), 1,
113  m_f->m_exp[n]->GetPlane(newP)->UpdateCoeffs(), 1);
114  }
115  Vmath::Zero(ncoeffs, m_f->m_exp[n]->GetPlane(p)->UpdateCoeffs(),
116  1);
117  }
118 
119  m_f->m_exp[n]->BwdTrans(m_f->m_exp[n]->GetCoeffs(),
120  m_f->m_exp[n]->UpdatePhys());
121  }
122  }
123  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
124  m_f->m_exp[0]->GetFieldDefinitions();
125  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
126 
127  for (int s = 0; s < nstrips; ++s)
128  {
129  for (int j = 0; j < nfields; ++j)
130  {
131  for (int i = 0; i < FieldDef.size() / nstrips; ++i)
132  {
133  int n = s * FieldDef.size() / nstrips + i;
134 
135  FieldDef[n]->m_fields.push_back(
136  m_f->m_fielddef[0]->m_fields[j]);
137  m_f->m_exp[s * nfields + j]->AppendFieldData(FieldDef[n],
138  FieldData[n]);
139  }
140  }
141  }
142  for (int i = 0; i < FieldDef.size(); ++i)
143  {
144  FieldDef[i]->m_homogeneousLengths[0] =
145  factor * m_f->m_fielddef[i]->m_homogeneousLengths[0];
146  }
147  m_f->m_fielddef = FieldDef;
148  m_f->m_data = FieldData;
149 }
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:373
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
FieldSharedPtr m_f
Field object.

Member Data Documentation

ModuleKey Nektar::FieldUtils::ProcessHomogeneousStretch::className
static
Initial value:
=
ModuleKey(eProcessModule, "homstretch"),
"Stretches homogeneous direction of a 3DH1D expansion, requires factor "
"to be "
"defined. The number of modes in the final expansion can be defined "
"using"
" --output-points-hom-z.")

Definition at line 58 of file ProcessHomogeneousStretch.h.