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::OutputFld Class Reference

Converter from fld to vtk. More...

#include <OutputFld.h>

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

Public Member Functions

 OutputFld (FieldSharedPtr f)
virtual ~OutputFld ()
virtual void Process (po::variables_map &vm)
 Write fld to output file.
- Public Member Functions inherited from Nektar::Utilities::OutputModule
 OutputModule (FieldSharedPtr p_f)
void OpenStream ()
 Open a file for output.
 OutputModule (MeshSharedPtr p_m)
void OpenStream ()
- 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 m_className []

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::OutputModule
ofstream m_fldFile
 Output stream.
std::ofstream m_mshFile
 Output stream.

Detailed Description

Converter from fld to vtk.

Definition at line 47 of file OutputFld.h.

Constructor & Destructor Documentation

Nektar::Utilities::OutputFld::OutputFld ( FieldSharedPtr  f)

Definition at line 56 of file OutputFld.cpp.

{
}
Nektar::Utilities::OutputFld::~OutputFld ( )
virtual

Definition at line 60 of file OutputFld.cpp.

{
}

Member Function Documentation

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

Creates an instance of this class.

Definition at line 51 of file OutputFld.h.

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

Write fld to output file.

Implements Nektar::Utilities::Module.

Definition at line 64 of file OutputFld.cpp.

References Nektar::SpatialDomains::BoundaryConditions::GetBoundaryRegions(), Nektar::Utilities::Module::m_config, and Nektar::Utilities::Module::m_f.

{
// Extract the output filename and extension
string filename = m_config["outfile"].as<string>();
if (m_f->m_writeBndFld)
{
ModuleKey module;
// Extract data to boundaryconditions
if (m_f->m_fldToBnd)
{
for (int i = 0; i < m_f->m_exp.size(); ++i)
{
m_f->m_exp[i]->FillBndCondFromField();
}
}
if (m_f->m_verbose)
{
cout << "OutputFld: Writing boundary file(s): ";
for(int i = 0; i < m_f->m_bndRegionsToWrite.size(); ++i)
{
if(i < m_f->m_bndRegionsToWrite.size()-1)
{
cout << ",";
}
}
cout << endl;
}
int nfields = m_f->m_exp.size();
Array<OneD, Array<OneD, const MultiRegions::ExpListSharedPtr> >
BndExp(nfields);
for (int i = 0; i < nfields; ++i)
{
BndExp[i] = m_f->m_exp[i]->GetBndCondExpansions();
}
// get hold of partition boundary regions so we can match it to desired
// region extraction
m_f->m_exp[0]->GetGraph());
SpatialDomains::BoundaryRegionCollection::const_iterator breg_it;
map<int,int> BndRegionMap;
int cnt =0;
for(breg_it = bregions.begin(); breg_it != bregions.end();
++breg_it, ++cnt)
{
BndRegionMap[breg_it->first] = cnt;
}
// find ending of output file and insert _b1, _b2
int dot = filename.find_last_of('.') + 1;
string ext = filename.substr(dot, filename.length() - dot);
string name = filename.substr(0, dot-1);
m_f->m_session->GetBndRegionOrdering();
for(int i = 0; i < m_f->m_bndRegionsToWrite.size(); ++i)
{
string outname = name + "_b"
+ boost::lexical_cast<string>(m_f->m_bndRegionsToWrite[i])
+ "." + ext;
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
if(BndRegionMap.count(m_f->m_bndRegionsToWrite[i]) == 1)
{
int Border = BndRegionMap[m_f->m_bndRegionsToWrite[i]];
FieldDef = BndExp[0][Border]->GetFieldDefinitions();
FieldData.resize(FieldDef.size());
for (int j = 0; j < nfields; ++j)
{
for (int k = 0; k < FieldDef.size(); ++k)
{
BndExp[j][Border]->AppendFieldData(FieldDef[k],
FieldData[k]);
FieldDef[k]->m_fields.push_back(m_f->m_fielddef[0]->
m_fields[j]);
}
}
// output error for regression checking.
if (vm.count("error"))
{
int rank = m_f->m_session->GetComm()->GetRank();
for (int j = 0; j < nfields; ++j)
{
BndExp[j][Border]->BwdTrans(BndExp[j][Border]->GetCoeffs(),
BndExp[j][Border]->UpdatePhys());
//Note currently these calls will
//hange since not all partitions will
//call error.
NekDouble l2err = BndExp[j][Border]
->L2(BndExp[j][Border]->GetPhys());
NekDouble linferr = BndExp[j][Border]
->Linf(BndExp[j][Border]->GetPhys());
if (rank == 0)
{
cout << "L 2 error (variable "
<< FieldDef[0]->m_fields[j]
<< ") : " << l2err << endl;
cout << "L inf error (variable "
<< FieldDef[0]->m_fields[j]
<< ") : " << linferr << endl;
}
}
}
}
m_f->m_fld->Write(outname, FieldDef, FieldData);
}
}
else
{
if (m_f->m_verbose)
{
cout << "OutputFld: Writing file..." << endl;
}
// Write the output file
m_f->m_fld->Write(filename, m_f->m_fielddef, m_f->m_data);
// output error for regression checking.
if (vm.count("error"))
{
int rank = m_f->m_session->GetComm()->GetRank();
for (int j = 0; j < m_f->m_exp.size(); ++j)
{
if (m_f->m_exp[j]->GetPhysState() == false)
{
m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(),
m_f->m_exp[j]->UpdatePhys());
}
NekDouble l2err = m_f->m_exp[j]->L2(
m_f->m_exp[j]->GetPhys());
NekDouble linferr = m_f->m_exp[j]->Linf(
m_f->m_exp[j]->GetPhys());
if (rank == 0)
{
cout << "L 2 error (variable "
<< m_f->m_fielddef[0]->m_fields[j]
<< ") : " << l2err << endl;
cout << "L inf error (variable "
<< m_f->m_fielddef[0]->m_fields[j]
<< ") : " << linferr << endl;
}
}
}
}
}

Member Data Documentation

ModuleKey Nektar::Utilities::OutputFld::m_className
static
Initial value:

Definition at line 54 of file OutputFld.h.