Commit f5ae8a7f authored by Dave Moxey's avatar Dave Moxey

Fix Tecplot output for normal expansions (homogeneous not yet working)

parent add940c3
......@@ -1324,7 +1324,7 @@ namespace Nektar
* @param var variables names
*/
void ExpList::v_WriteTecplotHeader(std::ofstream &outfile,
std::string var)
std::string var)
{
int coordim = GetExp(0)->GetCoordim();
char vars[3] = { 'x', 'y', 'z' };
......@@ -1335,7 +1335,12 @@ namespace Nektar
outfile << ", " << vars[i];
}
outfile << ", " << var << std::endl << std::endl;
if (var.size() > 0)
{
outfile << ", " << var;
}
outfile << std::endl << std::endl;
}
/**
......@@ -1348,6 +1353,8 @@ namespace Nektar
int i, j;
int coordim = GetCoordim(0);
int nPoints = GetTotPoints();
int nBases = (*m_exp)[0]->GetNumBases();
int numBlocks = 0;
Array<OneD, Array<OneD, NekDouble> > coords(3);
......@@ -1361,12 +1368,9 @@ namespace Nektar
GetCoords(coords[0], coords[1], coords[2]);
int numBlocks = 0;
for (i = 0; i < m_exp->size(); ++i)
{
const int nBases = (*m_exp)[i]->GetNumBases();
int numInt = 1;
int numInt = 1;
for (j = 0; j < nBases; ++j)
{
......@@ -1375,43 +1379,38 @@ namespace Nektar
numBlocks += numInt;
}
outfile << "Zone, N=" << nPoints << ", E="
<< numBlocks << ", F=FEBlock" ;
switch((*m_exp)[0]->GetNumBases())
{
case 2:
outfile << ", ET=QUADRILATERAL" << std::endl;
break;
case 3:
outfile << ", ET=BRICK" << std::endl;
break;
default:
ASSERTL0(false,"Not set up for this type of output");
break;
}
}
else
{
nPoints = (*m_exp)[expansion]->GetTotPoints();
coords[0] = Array<OneD,NekDouble>(nPoints);
coords[1] = Array<OneD,NekDouble>(nPoints);
coords[2] = Array<OneD,NekDouble>(nPoints);
int nBases = (*m_exp)[expansion]->GetNumBases();
char dims[3] = { 'I', 'J', 'K' };
coords[0] = Array<OneD, NekDouble>(nPoints);
coords[1] = Array<OneD, NekDouble>(nPoints);
coords[2] = Array<OneD, NekDouble>(nPoints);
outfile << "Zone";
(*m_exp)[expansion]->GetCoords(coords[0], coords[1], coords[2]);
for (i = 0; i < nBases; ++i)
numBlocks = 1;
for (j = 0; j < nBases; ++j)
{
outfile << ", " << dims[i] << "="
<< (*m_exp)[expansion]->GetNumPoints(i);
numBlocks *= (*m_exp)[expansion]->GetNumPoints(j)-1;
}
}
outfile << "Zone, N=" << nPoints << ", E="
<< numBlocks << ", F=FEBlock" ;
outfile << ", F=Block" << std::endl;
switch((*m_exp)[0]->GetNumBases())
{
case 2:
outfile << ", ET=QUADRILATERAL" << std::endl;
break;
case 3:
outfile << ", ET=BRICK" << std::endl;
break;
default:
ASSERTL0(false,"Not set up for this type of output");
break;
}
// Write out coordinates
......@@ -1429,62 +1428,75 @@ namespace Nektar
}
}
void ExpList::v_WriteTecplotConnectivity(std::ofstream &outfile)
void ExpList::v_WriteTecplotConnectivity(std::ofstream &outfile,
int expansion)
{
int i,j,k,l;
int nbase = (*m_exp)[0]->GetNumBases();
int cnt = 0;
for(i = 0; i < (*m_exp).size(); ++i)
boost::shared_ptr<LocalRegions::ExpansionVector> exp = m_exp;
if (expansion != -1)
{
if(nbase == 2)
exp = boost::shared_ptr<LocalRegions::ExpansionVector>(
new LocalRegions::ExpansionVector(1));
(*exp)[0] = (*m_exp)[expansion];
}
if (nbase == 2)
{
for(i = 0; i < (*exp).size(); ++i)
{
int np0 = (*m_exp)[i]->GetNumPoints(0);
int np1 = (*m_exp)[i]->GetNumPoints(1);
const int np0 = (*exp)[i]->GetNumPoints(0);
const int np1 = (*exp)[i]->GetNumPoints(1);
for(j = 1; j < np1; ++j)
{
for(k = 1; k < np0; ++k)
{
outfile << cnt + (j-1)*np0 + k << " ";
outfile << cnt + (j-1)*np0 + k +1 << " ";
outfile << cnt + j*np0 + k +1 << " ";
outfile << cnt + j*np0 + k << endl;
outfile << cnt + (j-1)*np0 + k << " ";
outfile << cnt + (j-1)*np0 + k+1 << " ";
outfile << cnt + j *np0 + k+1 << " ";
outfile << cnt + j *np0 + k << endl;
}
}
cnt += np0*np1;
}
else if(nbase == 3)
}
else if (nbase == 3)
{
for(i = 0; i < (*exp).size(); ++i)
{
int np0 = (*m_exp)[i]->GetNumPoints(0);
int np1 = (*m_exp)[i]->GetNumPoints(1);
int np2 = (*m_exp)[i]->GetNumPoints(2);
const int np0 = (*exp)[i]->GetNumPoints(0);
const int np1 = (*exp)[i]->GetNumPoints(1);
const int np2 = (*exp)[i]->GetNumPoints(2);
const int np01 = np0*np1;
for(j = 1; j < np2; ++j)
{
for(k = 1; k < np1; ++k)
{
for(l = 1; l < np0; ++l)
{
outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l << " ";
outfile << cnt + (j-1)*np0*np1 + (k-1)*np0 + l +1 << " ";
outfile << cnt + (j-1)*np0*np1 + k*np0 + l +1 << " ";
outfile << cnt + (j-1)*np0*np1 + k*np0 + l << " ";
outfile << cnt + j*np0*np1 + (k-1)*np0 + l << " ";
outfile << cnt + j*np0*np1 + (k-1)*np0 + l +1 << " ";
outfile << cnt + j*np0*np1 + k*np0 + l +1 << " ";
outfile << cnt + j*np0*np1 + k*np0 + l << endl;
outfile << cnt + (j-1)*np01 + (k-1)*np0 + l << " ";
outfile << cnt + (j-1)*np01 + (k-1)*np0 + l+1 << " ";
outfile << cnt + (j-1)*np01 + k *np0 + l+1 << " ";
outfile << cnt + (j-1)*np01 + k *np0 + l << " ";
outfile << cnt + j *np01 + (k-1)*np0 + l << " ";
outfile << cnt + j *np01 + (k-1)*np0 + l+1 << " ";
outfile << cnt + j *np01 + k *np0 + l+1 << " ";
outfile << cnt + j *np01 + k *np0 + l << endl;
}
}
}
cnt += np0*np1*np2;
}
else
{
ASSERTL0(false,"Not set up for this dimension");
}
}
else
{
ASSERTL0(false,"Not set up for this dimension");
}
}
......
......@@ -337,24 +337,28 @@ namespace Nektar
MULTI_REGIONS_EXPORT void ApplyGeomInfo();
void WriteTecplotHeader(std::ofstream &outfile,
std::string var = "v")
std::string var = "")
{
v_WriteTecplotHeader(outfile, var);
}
void WriteTecplotZone(std::ofstream &outfile, int expansion = -1)
void WriteTecplotZone(
std::ofstream &outfile,
int expansion = -1)
{
v_WriteTecplotZone(outfile, expansion);
}
void WriteTecplotField(std::ofstream &outfile, int expansion = -1)
void WriteTecplotField(std::ofstream &outfile,
int expansion = -1)
{
v_WriteTecplotField(outfile, expansion);
}
void WriteTecplotConnectivity(std::ofstream &outfile)
void WriteTecplotConnectivity(std::ofstream &outfile,
int expansion = -1)
{
v_WriteTecplotConnectivity(outfile);
v_WriteTecplotConnectivity(outfile, expansion);
}
MULTI_REGIONS_EXPORT void WriteVtkHeader(std::ofstream &outfile);
......@@ -1154,12 +1158,13 @@ namespace Nektar
virtual void v_ExtractCoeffsToCoeffs(const boost::shared_ptr<ExpList> &fromExpList, const Array<OneD, const NekDouble> &fromCoeffs, Array<OneD, NekDouble> &toCoeffs);
virtual void v_WriteTecplotHeader(std::ofstream &outfile,
std::string var = "v");
std::string var = "");
virtual void v_WriteTecplotZone(std::ofstream &outfile,
int expansion);
virtual void v_WriteTecplotField(std::ofstream &outfile,
int expansion);
virtual void v_WriteTecplotConnectivity(std::ofstream &outfile);
virtual void v_WriteTecplotConnectivity(std::ofstream &outfile,
int expansion);
virtual void v_WriteVtkPieceHeader(std::ofstream &outfile, int expansion);
virtual void v_WriteVtkPieceData(std::ofstream &outfile, int expansion,
std::string var);
......
......@@ -287,6 +287,8 @@ namespace Nektar
*/
void ExpList3DHomogeneous1D::v_WriteTecplotZone(std::ofstream &outfile, int expansion)
{
ExpList::v_WriteTecplotZone(outfile, expansion);
/*
int i,j;
int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
......@@ -312,6 +314,7 @@ namespace Nektar
}
outfile << std::endl;
}
*/
}
......
////////////////////////////////////////////////////////////////////////////////
//
// File: FldToTecplot.cpp
//
// For more information, please see: http://www.nektar.info/
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Output Tecplot file containing field.
//
////////////////////////////////////////////////////////////////////////////////
#include <cstdio>
#include <cstdlib>
......@@ -10,6 +45,7 @@
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList1DHomogeneous2D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>
using namespace Nektar;
#include <sys/stat.h>
......@@ -22,27 +58,27 @@ int fexist( const char *filename ) {
int main(int argc, char *argv[])
{
unsigned int i, j;
Array<OneD,NekDouble> fce;
Array<OneD,NekDouble> xc0,xc1,xc2;
if(argc < 3)
if(argc < 2)
{
fprintf(stderr,"Usage: %s meshfile fieldfile\n",argv[0]);
exit(1);
}
unsigned int i, j;
Array<OneD,NekDouble> fce;
Array<OneD,NekDouble> xc0,xc1,xc2;
bool Extrude2DWithHomogeneous = false;
bool SingleModePlot=false;
bool HalfModePlot=false;
int nExtraPoints, nExtraPlanes;
LibUtilities::SessionReader::RegisterCmdLineFlag(
"multi-zone", "m", "Output multi-zone format (one element per zone).");
LibUtilities::SessionReaderSharedPtr vSession
= LibUtilities::SessionReader::CreateInstance(argc, argv);
vSession->LoadParameter("OutputExtraPoints",nExtraPoints,0);
vSession->LoadParameter("OutputExtraPlanes",nExtraPlanes,0);
......@@ -490,6 +526,7 @@ int main(int argc, char *argv[])
{
Exp1[j]->WriteTecplotField(outfile,i);
}
Exp1[0]->WriteTecplotConnectivity(outfile,i);
}
}
else{
......@@ -502,20 +539,10 @@ int main(int argc, char *argv[])
}
ofstream outfile(fname.c_str());
Exp[0]->WriteTecplotHeader(outfile,var);
if(expdim == 3)
{
Exp[0]->WriteTecplotHeader(outfile,var);
Exp[0]->WriteTecplotZone(outfile);
for(int j = 0; j < Exp.num_elements(); ++j)
{
Exp[j]->WriteTecplotField(outfile);
}
Exp[0]->WriteTecplotConnectivity(outfile);
}
else
if (vSession->DefinesCmdLineArgument("multi-zone"))
{
Exp[0]->WriteTecplotHeader(outfile,var);
for(int i = 0; i < Exp[0]->GetNumElmts(); ++i)
{
Exp[0]->WriteTecplotZone(outfile,i);
......@@ -523,9 +550,18 @@ int main(int argc, char *argv[])
{
Exp[j]->WriteTecplotField(outfile,i);
}
Exp[0]->WriteTecplotConnectivity(outfile,i);
}
}
else
{
Exp[0]->WriteTecplotZone(outfile);
for(int j = 0; j < Exp.num_elements(); ++j)
{
Exp[j]->WriteTecplotField(outfile);
}
Exp[0]->WriteTecplotConnectivity(outfile);
}
}
//----------------------------------------------
}
......
#include <cstdio>
#include <cstdlib>
#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList1D.h>
#include <MultiRegions/ExpList2D.h>
#include <MultiRegions/ExpList3D.h>
using namespace Nektar;
int main(int argc, char *argv[])
{
Array<OneD,NekDouble> fce;
Array<OneD,NekDouble> xc0,xc1,xc2;
if(argc != 2)
{
fprintf(stderr,"Usage: XmlToTecplot meshfile\n");
exit(1);
}
LibUtilities::SessionReaderSharedPtr vSession
= LibUtilities::SessionReader::CreateInstance(argc, argv);
//----------------------------------------------
// Read in mesh from input file
string meshfile(argv[argc-1]);
SpatialDomains::MeshGraphSharedPtr graphShPt = SpatialDomains::MeshGraph::Read(vSession);//meshfile);
//----------------------------------------------
//----------------------------------------------
// Set up Expansion information
SpatialDomains::ExpansionMap emap = graphShPt->GetExpansions();
SpatialDomains::ExpansionMapIter it;
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];
LibUtilities::PointsKey tmp2 = tmp1.GetPointsKey();
it->second->m_basisKeyVector[i] = LibUtilities::BasisKey(
tmp1.GetBasisType(), tmp1.GetNumModes(),
LibUtilities::PointsKey(tmp1.GetNumModes(),
LibUtilities::ePolyEvenlySpaced));
}
}
//----------------------------------------------
//----------------------------------------------
// Define Expansion
int expdim = graphShPt->GetMeshDimension();
Array<OneD, MultiRegions::ExpListSharedPtr> Exp(1);
switch(expdim)
{
case 1:
{
MultiRegions::ExpList1DSharedPtr Exp1D;
Exp1D = MemoryManager<MultiRegions::ExpList1D>::AllocateSharedPtr(vSession,graphShPt);
Exp[0] = Exp1D;
break;
}
case 2:
{
MultiRegions::ExpList2DSharedPtr Exp2D;
Exp2D = MemoryManager<MultiRegions::ExpList2D>::AllocateSharedPtr(vSession,graphShPt);
Exp[0] = Exp2D;
break;
}
case 3:
{
MultiRegions::ExpList3DSharedPtr Exp3D;
Exp3D = MemoryManager<MultiRegions::ExpList3D>::AllocateSharedPtr(vSession,graphShPt);
Exp[0] = Exp3D;
break;
}
default:
ASSERTL0(false,"Expansion dimension not recognised");
break;
}
//-----------------------------------------------
//----------------------------------------------
// Write solution depending on #define
string outfile(strtok(argv[argc-1],"."));
outfile += ".dat";
ofstream outstrm(outfile.c_str());
Exp[0]->WriteTecplotHeader (outstrm);
Exp[0]->WriteTecplotZone (outstrm);
Exp[0]->WriteTecplotField (outstrm);
Exp[0]->WriteTecplotConnectivity(outstrm);
outstrm.close();
//----------------------------------------------
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
// File: XmlToTecplot.cpp
//
// For more information, please see: http://www.nektar.info/
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Output Tecplot description of mesh.
//
////////////////////////////////////////////////////////////////////////////////
#include <cstdio>
#include <cstdlib>
#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList1D.h>
#include <MultiRegions/ExpList2D.h>
#include <MultiRegions/ExpList3D.h>
using namespace Nektar;
int main(int argc, char *argv[])
{
Array<OneD,NekDouble> fce;
Array<OneD,NekDouble> xc0,xc1,xc2;
if(argc < 2)
{
fprintf(stderr,"Usage: XmlToTecplot meshfile\n");
exit(1);
}
LibUtilities::SessionReader::RegisterCmdLineFlag(
"multi-zone", "m", "Output multi-zone format (one element per zone).");
LibUtilities::SessionReaderSharedPtr vSession
= LibUtilities::SessionReader::CreateInstance(argc, argv);
//----------------------------------------------
// Read in mesh from input file
string meshfile(argv[argc-1]);
SpatialDomains::MeshGraphSharedPtr graphShPt
= SpatialDomains::MeshGraph::Read(vSession);
//----------------------------------------------
//----------------------------------------------
// Set up Expansion information
SpatialDomains::ExpansionMap emap = graphShPt->GetExpansions();
SpatialDomains::ExpansionMapIter it;
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];
LibUtilities::PointsKey tmp2 = tmp1.GetPointsKey();
it->second->m_basisKeyVector[i] = LibUtilities::BasisKey(
tmp1.GetBasisType(), tmp1.GetNumModes(),
LibUtilities::PointsKey(tmp1.GetNumModes(),
LibUtilities::ePolyEvenlySpaced));
}
}
//----------------------------------------------
//----------------------------------------------
// Define Expansion
int expdim = graphShPt->GetMeshDimension();
Array<OneD, MultiRegions::ExpListSharedPtr> Exp(1);
switch(expdim)
{
case 1:
{
MultiRegions::ExpList1DSharedPtr Exp1D;
Exp1D = MemoryManager<MultiRegions::ExpList1D>::AllocateSharedPtr(vSession,graphShPt);
Exp[0] = Exp1D;
break;
}
case 2:
{
MultiRegions::ExpList2DSharedPtr Exp2D;
Exp2D = MemoryManager<MultiRegions::ExpList2D>::AllocateSharedPtr(vSession,graphShPt);
Exp[0] = Exp2D;
break;
}