file-IO support native field dumps
This commit is contained in:
parent
1a06418914
commit
906800c057
@ -90,6 +90,7 @@ void ProcessFields::InitProcess()
|
|||||||
double discScaling = Op->GetGridDelta();
|
double discScaling = Op->GetGridDelta();
|
||||||
#endif
|
#endif
|
||||||
m_Dump_File->SetMeshLines(discLines,numLines,discScaling);
|
m_Dump_File->SetMeshLines(discLines,numLines,discScaling);
|
||||||
|
m_Dump_File->SetNativeDump(g_settings.NativeFieldDumps());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ Base_File_IO::Base_File_IO(std::string filename, int meshType)
|
|||||||
{
|
{
|
||||||
SetFilename(filename);
|
SetFilename(filename);
|
||||||
m_MeshType = meshType;
|
m_MeshType = meshType;
|
||||||
|
m_NativeDump = false;
|
||||||
m_Binary = true;
|
m_Binary = true;
|
||||||
m_Compress = true;
|
m_Compress = true;
|
||||||
m_AppendMode = false;
|
m_AppendMode = false;
|
||||||
|
@ -45,6 +45,8 @@ public:
|
|||||||
//! Set the mesh lines for the given mesh type.
|
//! Set the mesh lines for the given mesh type.
|
||||||
virtual void SetMeshLines(double const* const* lines, unsigned int const* count, double scaling=1) = 0 ;
|
virtual void SetMeshLines(double const* const* lines, unsigned int const* count, double scaling=1) = 0 ;
|
||||||
|
|
||||||
|
void SetNativeDump(bool val) {m_NativeDump=val;};
|
||||||
|
|
||||||
//! Add a scalar field. \sa GetNumberOfFields \sa ClearAllFields
|
//! Add a scalar field. \sa GetNumberOfFields \sa ClearAllFields
|
||||||
virtual void AddScalarField(std::string fieldname, double const* const* const* field, unsigned int const* size) = 0;
|
virtual void AddScalarField(std::string fieldname, double const* const* const* field, unsigned int const* size) = 0;
|
||||||
//! Add a scalar field. \sa GetNumberOfFields \sa ClearAllFields
|
//! Add a scalar field. \sa GetNumberOfFields \sa ClearAllFields
|
||||||
@ -77,6 +79,7 @@ protected:
|
|||||||
unsigned int m_timestep;
|
unsigned int m_timestep;
|
||||||
|
|
||||||
int m_MeshType;
|
int m_MeshType;
|
||||||
|
bool m_NativeDump;
|
||||||
|
|
||||||
bool m_AppendMode;
|
bool m_AppendMode;
|
||||||
bool m_Binary;
|
bool m_Binary;
|
||||||
|
@ -69,9 +69,14 @@ void VTK_File_IO::SetMeshLines(double const* const* lines, unsigned int const* c
|
|||||||
vtkDoubleArray *Coords[3];
|
vtkDoubleArray *Coords[3];
|
||||||
for (int n=0;n<3;++n)
|
for (int n=0;n<3;++n)
|
||||||
{
|
{
|
||||||
Coords[n] = vtkDoubleArray::New();
|
m_MeshLines[n].clear();
|
||||||
|
m_MeshLines[n].reserve(count[n]);
|
||||||
|
Coords[n] = vtkDoubleArray::New();
|
||||||
for (unsigned int i=0; i<count[n]; i++)
|
for (unsigned int i=0; i<count[n]; i++)
|
||||||
|
{
|
||||||
Coords[n]->InsertNextValue(lines[n][i]*scaling);
|
Coords[n]->InsertNextValue(lines[n][i]*scaling);
|
||||||
|
m_MeshLines[n].push_back(lines[n][i]*scaling);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RectGrid->SetXCoordinates(Coords[0]);
|
RectGrid->SetXCoordinates(Coords[0]);
|
||||||
RectGrid->SetYCoordinates(Coords[1]);
|
RectGrid->SetYCoordinates(Coords[1]);
|
||||||
@ -87,6 +92,18 @@ void VTK_File_IO::SetMeshLines(double const* const* lines, unsigned int const* c
|
|||||||
cerr << "VTK_File_IO::SetMeshLines: Error, grid invalid, this should not have happend! " << endl;
|
cerr << "VTK_File_IO::SetMeshLines: Error, grid invalid, this should not have happend! " << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int n=0;n<3;++n)
|
||||||
|
{
|
||||||
|
m_MeshLines[n].clear();
|
||||||
|
m_MeshLines[n].reserve(count[n]);
|
||||||
|
double scale=1;
|
||||||
|
if (n!=1)
|
||||||
|
scale*=scaling;
|
||||||
|
for (unsigned int i=0; i<count[n]; i++)
|
||||||
|
m_MeshLines[n].push_back(lines[n][i]*scale);
|
||||||
|
}
|
||||||
|
|
||||||
StructGrid->SetDimensions(count[0],count[1],count[2]);
|
StructGrid->SetDimensions(count[0],count[1],count[2]);
|
||||||
vtkPoints *points = vtkPoints::New();
|
vtkPoints *points = vtkPoints::New();
|
||||||
points->SetNumberOfPoints(count[0]*count[1]*count[2]);
|
points->SetNumberOfPoints(count[0]*count[1]*count[2]);
|
||||||
@ -157,13 +174,24 @@ void VTK_File_IO::AddVectorField(string fieldname, double const* const* const* c
|
|||||||
array->SetNumberOfTuples(size[0]*size[1]*size[2]);
|
array->SetNumberOfTuples(size[0]*size[1]*size[2]);
|
||||||
array->SetName(fieldname.c_str());
|
array->SetName(fieldname.c_str());
|
||||||
int id=0;
|
int id=0;
|
||||||
|
double out[3];
|
||||||
for (unsigned int k=0;k<size[2];++k)
|
for (unsigned int k=0;k<size[2];++k)
|
||||||
{
|
{
|
||||||
for (unsigned int j=0;j<size[1];++j)
|
for (unsigned int j=0;j<size[1];++j)
|
||||||
{
|
{
|
||||||
|
double cos_a = cos(m_MeshLines[1].at(j)); //needed only for m_MeshType==1 (cylindrical mesh)
|
||||||
|
double sin_a = sin(m_MeshLines[1].at(j)); //needed only for m_MeshType==1 (cylindrical mesh)
|
||||||
for (unsigned int i=0;i<size[0];++i)
|
for (unsigned int i=0;i<size[0];++i)
|
||||||
{
|
{
|
||||||
array->SetTuple3(id++,field[0][i][j][k],field[1][i][j][k],field[2][i][j][k]);
|
if ((m_MeshType==0) || (m_NativeDump))
|
||||||
|
array->SetTuple3(id++,field[0][i][j][k],field[1][i][j][k],field[2][i][j][k]);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out[0] = field[0][i][j][k] * cos_a - field[1][i][j][k] * sin_a;
|
||||||
|
out[1] = field[0][i][j][k] * sin_a + field[1][i][j][k] * cos_a;
|
||||||
|
out[2] = field[2][i][j][k];
|
||||||
|
array->SetTuple3(id++,out[0],out[1],out[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,13 +206,24 @@ void VTK_File_IO::AddVectorField(string fieldname, float const* const* const* co
|
|||||||
array->SetNumberOfTuples(size[0]*size[1]*size[2]);
|
array->SetNumberOfTuples(size[0]*size[1]*size[2]);
|
||||||
array->SetName(fieldname.c_str());
|
array->SetName(fieldname.c_str());
|
||||||
int id=0;
|
int id=0;
|
||||||
|
float out[3];
|
||||||
for (unsigned int k=0;k<size[2];++k)
|
for (unsigned int k=0;k<size[2];++k)
|
||||||
{
|
{
|
||||||
for (unsigned int j=0;j<size[1];++j)
|
for (unsigned int j=0;j<size[1];++j)
|
||||||
{
|
{
|
||||||
|
float cos_a = cos(m_MeshLines[1].at(j)); //needed only for m_MeshType==1 (cylindrical mesh)
|
||||||
|
float sin_a = sin(m_MeshLines[1].at(j)); //needed only for m_MeshType==1 (cylindrical mesh)
|
||||||
for (unsigned int i=0;i<size[0];++i)
|
for (unsigned int i=0;i<size[0];++i)
|
||||||
{
|
{
|
||||||
array->SetTuple3(id++,field[0][i][j][k],field[1][i][j][k],field[2][i][j][k]);
|
if ((m_MeshType==0) || (m_NativeDump))
|
||||||
|
array->SetTuple3(id++,field[0][i][j][k],field[1][i][j][k],field[2][i][j][k]);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out[0] = field[0][i][j][k] * cos_a - field[1][i][j][k] * sin_a;
|
||||||
|
out[1] = field[0][i][j][k] * sin_a + field[1][i][j][k] * cos_a;
|
||||||
|
out[2] = field[2][i][j][k];
|
||||||
|
array->SetTuple3(id++,out[0],out[1],out[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
vtkDataSet* m_GridData;
|
vtkDataSet* m_GridData;
|
||||||
|
|
||||||
|
std::vector<double> m_MeshLines[3];
|
||||||
|
|
||||||
virtual std::string GetTimestepFilename(int pad_length=10) const;
|
virtual std::string GetTimestepFilename(int pad_length=10) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user