Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private 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.
- Public Member Functions inherited from Nektar::Utilities::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.
void PrintConfig ()
 Print out all configuration options for a module.
void SetDefaults ()
 Sets default configuration options for those which have not been set.
bool GetRequireEquiSpaced (void)
void SetRequireEquiSpaced (bool pVal)
 Module (MeshSharedPtr p_m)
virtual void Process ()=0
void RegisterConfig (string key, string value)
void PrintConfig ()
void SetDefaults ()
MeshSharedPtr GetMesh ()
virtual void ProcessVertices ()
 Extract element vertices.

Static Public Member Functions

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

Static Public Attributes

static ModuleKey className

Private Attributes

FieldSharedPtr m_fromField

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::Module
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges.
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces.
virtual void ProcessElements ()
 Generate element IDs.
virtual void ProcessComposites ()
 Generate composites.
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly.
void PrismLines (int prism, PerMap &perFaces, set< int > &prismsDone, vector< ElementSharedPtr > &line)
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object.
map< string, ConfigOptionm_config
 List of configuration values.
bool m_requireEquiSpaced
MeshSharedPtr m_mesh
 Mesh object.

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.

{
if((f->m_inputfiles.count("fld") == 0) &&
(f->m_inputfiles.count("rst") == 0) &&
(f->m_inputfiles.count("chk") == 0))
{
cout << "A fld, chk or rst input file must be specified for the "
"scaleinputfld module" << endl;
exit(3);
}
m_config["scale"] = ConfigOption(false, "1.0", "scale factor");
m_config["fromfld"] = ConfigOption(false, "NotSet",
"Fld file form which to interpolate field");
ASSERTL0(m_config["fromfld"].as<string>().compare("NotSet") != 0,
"Need to specify fromfld=file.fld ");
}
Nektar::Utilities::ProcessAddFld::~ProcessAddFld ( )
virtual

Definition at line 76 of file ProcessAddFld.cpp.

{
}

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.

void Nektar::Utilities::ProcessAddFld::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 80 of file ProcessAddFld.cpp.

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

{
if (m_f->m_verbose)
{
cout << "ProcessAddFld: Adding new fld to input fld" << endl;
}
ASSERTL0(m_f->m_data.size() != 0,"No input data defined");
string scalestr = m_config["scale"].as<string>();
NekDouble scale = boost::lexical_cast<NekDouble>(scalestr);
string fromfld = m_config["fromfld"].as<string>();
m_fromField = boost::shared_ptr<Field>(new Field());
if(m_f->m_exp.size())
{
// Set up ElementGIDs in case of parallel processing
Array<OneD,int> ElementGIDs(m_f->m_exp[0]->GetExpSize());
for (int i = 0; i < m_f->m_exp[0]->GetExpSize(); ++i)
{
ElementGIDs[i] = m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
}
m_f->m_fld->Import(fromfld,m_fromField->m_fielddef,
m_fromField->m_data,
ElementGIDs);
}
else
{
m_f->m_fld->Import(fromfld,m_fromField->m_fielddef,
m_fromField->m_data,
}
bool samelength = true;
if(m_fromField->m_data.size() != m_f->m_data.size())
{
samelength = false;
}
// scale input field
for(int i = 0; i < m_fromField->m_data.size(); ++i)
{
int datalen = m_fromField->m_data[i].size();
Vmath::Smul(datalen, scale, &(m_fromField->m_data[i][0]), 1,
&(m_fromField->m_data[i][0]), 1);
if(samelength)
{
if(datalen != m_f->m_data[i].size())
{
samelength = false;
}
}
}
if(samelength == true)
{
for(int i = 0; i < m_f->m_data.size(); ++i)
{
int datalen = m_f->m_data[i].size();
Vmath::Vadd(datalen, &(m_f->m_data[i][0]), 1,
&(m_fromField->m_data[i][0]), 1,
&(m_f->m_data[i][0]), 1);
}
}
else
{
ASSERTL0(m_f->m_exp.size() != 0 ,
"Input fields have partitions of different length and so xml "
"file needs to be specified");
int nfields = m_f->m_fielddef[0]->m_fields.size();
int ncoeffs = m_f->m_exp[0]->GetNcoeffs();
Array<OneD, NekDouble> SaveFld(ncoeffs);
for (int j = 0; j < nfields; ++j)
{
Vmath::Vcopy(ncoeffs,m_f->m_exp[j]->GetCoeffs(),1, SaveFld,1);
// load new field
for (int i = 0; i < m_fromField->m_data.size(); ++i)
{
m_f->m_exp[j]->ExtractDataToCoeffs(
m_fromField->m_fielddef[i],
m_fromField->m_data[i],
m_fromField->m_fielddef[i]->m_fields[j],
m_f->m_exp[j]->UpdateCoeffs());
}
Vmath::Vadd(ncoeffs, m_f->m_exp[j]->GetCoeffs(), 1,
SaveFld, 1,
m_f->m_exp[j]->UpdateCoeffs(), 1);
}
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
= m_f->m_exp[0]->GetFieldDefinitions();
std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
for(int i = 0; i < nfields; ++i)
{
for (int j = 0; j < FieldDef.size(); ++j)
{
FieldDef[j]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[i]);
m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
}
}
m_f->m_fielddef = FieldDef;
m_f->m_data = FieldData;
}
}

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessAddFld::className
static
Initial value:
ProcessAddFld::create, "rescale input field by a constant factor.")

Definition at line 58 of file ProcessAddFld.h.

FieldSharedPtr Nektar::Utilities::ProcessAddFld::m_fromField
private

Definition at line 67 of file ProcessAddFld.h.

Referenced by Process().