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

This processing module scales the input fld file. More...

#include <ProcessAddFld.h>

Inheritance diagram for Nektar::Utilities::ProcessAddFld:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::ProcessAddFld:
Collaboration graph
[legend]

Public Member Functions

 ProcessAddFld (FieldSharedPtr f)
 
virtual ~ProcessAddFld ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::Utilities::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
 ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
virtual void Process ()=0
 
void RegisterConfig (std::string key, std::string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
virtual void ClearElementLinks ()
 

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::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. More...
 

Detailed Description

This processing module scales the input fld file.

Definition at line 50 of file ProcessAddFld.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessAddFld::ProcessAddFld ( FieldSharedPtr  f)

Definition at line 55 of file ProcessAddFld.cpp.

References ASSERTL0, and Nektar::Utilities::Module::m_config.

55  : ProcessModule(f)
56 {
57  m_config["scale"] = ConfigOption(false, "1.0", "scale factor");
58 
59  m_config["fromfld"] = ConfigOption(false, "NotSet",
60  "Fld file form which to add field");
61 
62  ASSERTL0(m_config["fromfld"].as<string>().compare("NotSet") != 0,
63  "Need to specify fromfld=file.fld ");
64 
65 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
map< string, ConfigOption > m_config
List of configuration values.
Nektar::Utilities::ProcessAddFld::~ProcessAddFld ( )
virtual

Definition at line 67 of file ProcessAddFld.cpp.

68 {
69 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::Utilities::ProcessAddFld::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 54 of file ProcessAddFld.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::Utilities::ProcessAddFld::GetModuleName ( )
inlinevirtual

Implements Nektar::Utilities::Module.

Definition at line 66 of file ProcessAddFld.h.

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

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 71 of file ProcessAddFld.cpp.

References ASSERTL0, Nektar::Utilities::Module::m_config, Nektar::Utilities::Module::m_f, Nektar::LibUtilities::NullFieldMetaDataMap, Vmath::Smul(), Vmath::Vadd(), and Vmath::Vcopy().

72 {
73  if (m_f->m_verbose)
74  {
75  if(m_f->m_comm->TreatAsRankZero())
76  {
77  cout << "ProcessAddFld: Adding new fld to input fld..." << endl;
78  }
79  }
80 
81  ASSERTL0(m_f->m_data.size() != 0,"No input data defined");
82 
83  string scalestr = m_config["scale"].as<string>();
84  NekDouble scale = boost::lexical_cast<NekDouble>(scalestr);
85 
86  string fromfld = m_config["fromfld"].as<string>();
87  FieldSharedPtr fromField = boost::shared_ptr<Field>(new Field());
88 
89  if(m_f->m_exp.size())
90  {
91  // Set up ElementGIDs in case of parallel processing
92  Array<OneD,int> ElementGIDs(m_f->m_exp[0]->GetExpSize());
93  for (int i = 0; i < m_f->m_exp[0]->GetExpSize(); ++i)
94  {
95  ElementGIDs[i] = m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
96  }
97  m_f->m_fld->Import(fromfld,
98  fromField->m_fielddef,
99  fromField->m_data,
101  ElementGIDs);
102  }
103  else
104  {
105  m_f->m_fld->Import(fromfld,
106  fromField->m_fielddef,
107  fromField->m_data,
109  }
110 
111  bool samelength = true;
112  if(fromField->m_data.size() != m_f->m_data.size())
113  {
114  samelength = false;
115  }
116 
117  // scale input field
118  for(int i = 0; i < fromField->m_data.size(); ++i)
119  {
120  int datalen = fromField->m_data[i].size();
121 
122  Vmath::Smul(datalen, scale, &(fromField->m_data[i][0]), 1,
123  &(fromField->m_data[i][0]), 1);
124 
125  if(samelength)
126  {
127  if(datalen != m_f->m_data[i].size())
128  {
129  samelength = false;
130  }
131  }
132  }
133 
134  if(samelength == true)
135  {
136  for(int i = 0; i < m_f->m_data.size(); ++i)
137  {
138  int datalen = m_f->m_data[i].size();
139 
140  Vmath::Vadd(datalen, &(m_f->m_data[i][0]), 1,
141  &(fromField->m_data[i][0]), 1,
142  &(m_f->m_data[i][0]), 1);
143  }
144  }
145  else
146  {
147  ASSERTL0(m_f->m_exp.size() != 0 ,
148  "Input fields have partitions of different length and so xml "
149  "file needs to be specified");
150 
151  int nfields = m_f->m_fielddef[0]->m_fields.size();
152  int ncoeffs = m_f->m_exp[0]->GetNcoeffs();
153  Array<OneD, NekDouble> SaveFld(ncoeffs);
154 
155  for (int j = 0; j < nfields; ++j)
156  {
157  Vmath::Vcopy(ncoeffs,m_f->m_exp[j]->GetCoeffs(),1, SaveFld,1);
158 
159 
160  // since expansion is set up according to m_f search for same variable in new field
161  int nfield;
162  for (nfield = 0; nfield < fromField->m_fielddef[0]->m_fields.size(); ++nfield)
163  {
164  if(fromField->m_fielddef[0]->m_fields[nfield] ==
165  m_f->m_fielddef[0]->m_fields[j])
166  {
167  break;
168  }
169  }
170 
171  ASSERTL0(nfield != fromField->m_fielddef[0]->m_fields.size(),
172  "Could not find field " + m_f->m_fielddef[0]->m_fields[j] + " in from field");
173 
174  // load new field
175  for (int i = 0; i < fromField->m_data.size(); ++i)
176  {
177  m_f->m_exp[j]->ExtractDataToCoeffs(
178  fromField->m_fielddef[i],
179  fromField->m_data[i],
180  fromField->m_fielddef[i]->m_fields[nfield],
181  m_f->m_exp[j]->UpdateCoeffs());
182  }
183 
184  Vmath::Vadd(ncoeffs, m_f->m_exp[j]->GetCoeffs(), 1,
185  SaveFld, 1,
186  m_f->m_exp[j]->UpdateCoeffs(), 1);
187  }
188 
189  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
190  = m_f->m_exp[0]->GetFieldDefinitions();
191  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
192 
193  for(int i = 0; i < nfields; ++i)
194  {
195  for (int j = 0; j < FieldDef.size(); ++j)
196  {
197  FieldDef[j]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[i]);
198  m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
199  }
200  }
201 
202  m_f->m_fielddef = FieldDef;
203  m_f->m_data = FieldData;
204  }
205 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
map< string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:199
double NekDouble
boost::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:698
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
static FieldMetaDataMap NullFieldMetaDataMap
Definition: FieldIO.h:54
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:285

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessAddFld::className
static
Initial value:
=
ProcessAddFld::create, "add two fields together with optional scaling. Must specify fromfld and scaling is optionally specified with input option scale.")

Definition at line 58 of file ProcessAddFld.h.