Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
XmlToVtk.cpp File Reference
#include <cstdlib>
#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList1D.h>
#include <MultiRegions/ExpList2D.h>
#include <MultiRegions/ExpList3D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
Include dependency graph for XmlToVtk.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 46 of file XmlToVtk.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::SpatialDomains::eDeformed, Nektar::LibUtilities::eFourier, Nektar::LibUtilities::ePolyEvenlySpaced, Vmath::Fill(), Nektar::LibUtilities::BasisKey::GetBasisType(), Nektar::LibUtilities::BasisKey::GetNumModes(), Nektar::LibUtilities::BasisKey::GetPointsKey(), Vmath::Imin(), npts, Nektar::SpatialDomains::MeshGraph::Read(), Nektar::LibUtilities::SessionReader::RegisterCmdLineFlag(), Vmath::Vcopy(), and Vmath::Vmin().

{
if(argc < 2)
{
cerr << "Usage: XmlToVtk meshfile" << endl;
exit(1);
}
LibUtilities::SessionReader::RegisterCmdLineFlag(
"jacobian", "j", "Output Jacobian as scalar field");
= LibUtilities::SessionReader::CreateInstance(argc, argv);
bool jac = vSession->DefinesCmdLineArgument("jacobian");
// Read in mesh from input file
string meshfile(argv[argc-1]);
SpatialDomains::MeshGraph::Read(vSession); //meshfile);
// Set up Expansion information
SpatialDomains::ExpansionMap emap = graphShPt->GetExpansions();
for (it = emap.begin(); it != emap.end(); ++it)
{
for (int i = 0; i < it->second->m_basisKeyVector.size(); ++i)
{
LibUtilities::BasisKey tmp1 = it->second->m_basisKeyVector[i];
it->second->m_basisKeyVector[i] = LibUtilities::BasisKey(
tmp1.GetBasisType(), tmp1.GetNumModes(),
}
}
// Define Expansion
int expdim = graphShPt->GetMeshDimension();
Array<OneD, MultiRegions::ExpListSharedPtr> Exp(1);
switch(expdim)
{
case 1:
{
::AllocateSharedPtr(vSession,graphShPt);
Exp[0] = Exp1D;
break;
}
case 2:
{
if(vSession->DefinesSolverInfo("HOMOGENEOUS"))
{
std::string HomoStr = vSession->GetSolverInfo("HOMOGENEOUS");
HomoStr == "HOMOGENEOUS1D" || HomoStr == "Homogeneous1D" ||
HomoStr == "1D" || HomoStr == "Homo1D",
"Only 3DH1D supported for XML output currently.");
int nplanes;
vSession->LoadParameter("HomModesZ", nplanes);
// choose points to be at evenly spaced points at nplanes + 1
// points
LibUtilities::eFourier, nplanes, Pkey);
NekDouble lz = vSession->GetParameter("LZ");
vSession, Bkey, lz, false, false, graphShPt);
Exp[0] = Exp3DH1;
}
else
{
::AllocateSharedPtr(vSession,graphShPt);
Exp[0] = Exp2D;
}
break;
}
case 3:
{
::AllocateSharedPtr(vSession,graphShPt);
Exp[0] = Exp3D;
break;
}
default:
{
ASSERTL0(false,"Expansion dimension not recognised");
break;
}
}
// Write out VTK file.
string outname(strtok(argv[argc-1],"."));
outname += ".vtu";
ofstream outfile(outname.c_str());
Exp[0]->WriteVtkHeader(outfile);
if (jac)
{
// Find minimum Jacobian.
Array<OneD, NekDouble> tmp;
Array<OneD, NekDouble> x0 (Exp[0]->GetNpoints());
Array<OneD, NekDouble> x1 (Exp[0]->GetNpoints());
Array<OneD, NekDouble> x2 (Exp[0]->GetNpoints());
Exp[0]->GetCoords(x0, x1, x2);
// Write out field containing Jacobian.
for(int i = 0; i < Exp[0]->GetExpSize(); ++i)
{
LocalRegions::ExpansionSharedPtr e = Exp[0]->GetExp(i);
SpatialDomains::GeomFactorsSharedPtr g = e->GetMetricInfo();
LibUtilities::PointsKeyVector ptsKeys = e->GetPointsKeys();
unsigned int npts = e->GetTotPoints();
if (g->GetGtype() == SpatialDomains::eDeformed)
{
Vmath::Vcopy(npts, g->GetJac(ptsKeys), 1,
tmp = Exp[0]->UpdatePhys()
+ Exp[0]->GetPhys_Offset(i), 1);
}
else
{
Vmath::Fill (npts, g->GetJac(ptsKeys)[0],
tmp = Exp[0]->UpdatePhys()
+ Exp[0]->GetPhys_Offset(i), 1);
}
Exp[0]->WriteVtkPieceHeader(outfile, i);
Exp[0]->WriteVtkPieceData (outfile, i, "Jac");
Exp[0]->WriteVtkPieceFooter(outfile, i);
}
unsigned int n
= Vmath::Imin(Exp[0]->GetNpoints(), Exp[0]->GetPhys(), 1);
cout << "- Minimum Jacobian: "
<< Vmath::Vmin(Exp[0]->GetNpoints(), Exp[0]->GetPhys(), 1)
<< " at coords (" << x0[n] << ", " << x1[n] << ", " << x2[n] << ")"
<< endl;
}
else
{
// For each field write header and footer, since there is no field data.
for(int i = 0; i < Exp[0]->GetExpSize(); ++i)
{
Exp[0]->WriteVtkPieceHeader(outfile, i);
Exp[0]->WriteVtkPieceFooter(outfile, i);
}
}
Exp[0]->WriteVtkFooter(outfile);
return 0;
}