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

Converter from fld to vtk. More...

#include <OutputVtk.h>

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

Public Member Functions

 OutputVtk (FieldSharedPtr f)
virtual ~OutputVtk ()
virtual void Process (po::variables_map &vm)
 Write fld to output file.
 OutputVtk (MeshSharedPtr m)
virtual ~OutputVtk ()
virtual void Process ()
 Write mesh 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)
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 Module (MeshSharedPtr p_m)
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 boost::shared_ptr< Modulecreate (MeshSharedPtr m)
 Creates an instance of this class.

Static Public Attributes

static ModuleKey m_className
static ModuleKey className

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::Module
 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.

Converter for Gmsh files.

Definition at line 47 of file PostProcessing/FieldConvert/OutputVtk.h.

Constructor & Destructor Documentation

Nektar::Utilities::OutputVtk::OutputVtk ( FieldSharedPtr  f)
Nektar::Utilities::OutputVtk::~OutputVtk ( )
virtual

Definition at line 56 of file PostProcessing/FieldConvert/OutputVtk.cpp.

{
}
Nektar::Utilities::OutputVtk::OutputVtk ( MeshSharedPtr  m)

Definition at line 57 of file PreProcessing/MeshConvert/OutputVtk.cpp.

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

Member Function Documentation

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

Creates an instance of this class.

Definition at line 51 of file PostProcessing/FieldConvert/OutputVtk.h.

static boost::shared_ptr<Module> Nektar::Utilities::OutputVtk::create ( MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 51 of file PreProcessing/MeshConvert/OutputVtk.h.

{
return MemoryManager<OutputVtk>::AllocateSharedPtr(m);
}
void Nektar::Utilities::OutputVtk::Process ( )
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 67 of file PreProcessing/MeshConvert/OutputVtk.cpp.

References Nektar::iterator, Nektar::Utilities::Module::m_config, and Nektar::Utilities::Module::m_mesh.

{
if (m_mesh->m_verbose)
{
cout << "OutputVtk: Writing file..." << endl;
}
vtkPolyData *vtkMesh = vtkPolyData::New();
vtkPoints *vtkPoints = vtkPoints::New();
vtkCellArray *vtkPolys = vtkCellArray::New();
std::set<NodeSharedPtr> tmp(
m_mesh->m_vertexSet.begin(),
m_mesh->m_vertexSet.end());
for (it = tmp.begin(); it != tmp.end(); ++it)
{
NodeSharedPtr n = *it;
vtkPoints->InsertPoint(n->m_id, n->m_x, n->m_y, n->m_z);
}
vtkIdType p[8];
vector<ElementSharedPtr> &elmt =
m_mesh->m_element[m_mesh->m_expDim];
for(int i = 0; i < elmt.size(); ++i)
{
int vertexCount = elmt[i]->GetVertexCount();
for (int j = 0; j < vertexCount; ++j)
{
p[j] = elmt[i]->GetVertex(j)->m_id;
}
vtkPolys->InsertNextCell(vertexCount, &p[0]);
}
vtkMesh->SetPoints(vtkPoints);
vtkMesh->SetPolys(vtkPolys);
// Write out the new mesh
vtkPolyDataWriter *vtkMeshWriter = vtkPolyDataWriter::New();
vtkMeshWriter->SetFileName(m_config["outfile"].as<string>().c_str());
#if VTK_MAJOR_VERSION <= 5
vtkMeshWriter->SetInput(vtkMesh);
#else
vtkMeshWriter->SetInputData(vtkMesh);
#endif
vtkMeshWriter->Update();
}
void Nektar::Utilities::OutputVtk::Process ( po::variables_map &  vm)
virtual

Write fld to output file.

Implements Nektar::Utilities::Module.

Definition at line 60 of file PostProcessing/FieldConvert/OutputVtk.cpp.

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

{
if(!m_f->m_exp.size()) // do nothing if no expansion defined
{
return;
}
int i, j;
if (m_f->m_verbose)
{
cout << "OutputVtk: Writing file..." << endl;
}
// Extract the output filename and extension
string filename = m_config["outfile"].as<string>();
// amend for parallel output if required
if(m_f->m_session->GetComm()->GetSize() != 1)
{
int dot = filename.find_last_of('.');
string ext = filename.substr(dot,filename.length()-dot);
string procId = "_P" + boost::lexical_cast<std::string>(m_f->m_session->GetComm()->GetRank());
string start = filename.substr(0,dot);
filename = start + procId + ext;
}
// Write solution.
ofstream outfile(filename.c_str());
m_f->m_exp[0]->WriteVtkHeader(outfile);
// For each field write out field data for each expansion.
for (i = 0; i < m_f->m_exp[0]->GetNumElmts(); ++i)
{
m_f->m_exp[0]->WriteVtkPieceHeader(outfile,i);
// For this expansion write out each field.
for (j = 0; j < m_f->m_fielddef[0]->m_fields.size(); ++j)
{
m_f->m_exp[j]->WriteVtkPieceData(outfile, i,
m_f->m_fielddef[0]->m_fields[j]);
}
m_f->m_exp[0]->WriteVtkPieceFooter(outfile, i);
}
m_f->m_exp[0]->WriteVtkFooter(outfile);
cout << "Written file: " << filename << endl;
}

Member Data Documentation

ModuleKey Nektar::Utilities::OutputVtk::className
static
Initial value:

Definition at line 54 of file PreProcessing/MeshConvert/OutputVtk.h.

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

Definition at line 54 of file PostProcessing/FieldConvert/OutputVtk.h.