Commit 16e8752b authored by Blue Bird's avatar Blue Bird
Browse files

Aenderungen wegen FFT Variable

parent 5f29e468
......@@ -120,4 +120,197 @@ void Variable2D<double>::QPrint_VTK(QString DateiName, QString title) {
}
};
template <>
void Variable2D<std::complex<double> >::QPrint_VTK(QString DateiName,
double ( *convert ) ( std::complex<double> x ),
QString title) {
QFile fileIn(DateiName);
if(!fileIn.open(QIODevice::WriteOnly)) {
std::cerr << "error open fileIn for writing Variable2D<double>::QPrint_VTK:"
<< qPrintable(fileIn.errorString()) << endl;
}
QTextStream Datei(&fileIn);
D2vector v;
int num_total = 0;
int cell_total = 0;
// Teil 0: Write information
Datei << "# vtk DataFile Version 2.0\n"
<< title << endl
<< "ASCII\n"
<< "DATASET UNSTRUCTURED_GRID\n";
for(int id_rec=0;id_rec<ug->Give_number_rectangle();++id_rec) {
Update<rectangleEl>(id_rec);
num_total += blockgrid->Give_N_total_rectangle(id_rec);
cell_total += (blockgrid->Give_Nx_rectangle(id_rec))
*(blockgrid->Give_Ny_rectangle(id_rec));
}
// Teil 1: Kopfzeile schreiben
Datei << "POINTS " << num_total << " float\n";
// Teil 2: Koordinaten der Punkte ausgeben
for(int id_rec=0;id_rec<ug->Give_number_rectangle();++id_rec) {
int Ny = blockgrid->Give_Ny_rectangle(id_rec);
int Nx = blockgrid->Give_Nx_rectangle(id_rec);
for(int j=0;j<=Ny;++j)
for(int i=0;i<=Nx;++i) {
v = blockgrid->Give_coord_rectangle(id_rec,i,j);
Datei << v.x
<< " " << v.y
<< " " << 0.0
<< "\n";
}
}
// Teil 3: Zellen ausgeben
Datei << "\nCELLS " << cell_total << " " << cell_total*5 << "\n";
int id_start;
id_start = 0;
for(int id_rec=0;id_rec<ug->Give_number_rectangle();++id_rec) {
int Nx = blockgrid->Give_Nx_rectangle(id_rec);
int Ny = blockgrid->Give_Ny_rectangle(id_rec);
for(int j=0;j<Ny;++j) for(int i=0;i<Nx;++i) {
Datei << "4 "
<< id_start + i + (Nx+1)*j << " " // WS
<< id_start + i+1 + (Nx+1)*j << " " // ES
<< id_start + i+1 + (Nx+1)*(j+1) << " " // EN
<< id_start + i + (Nx+1)*(j+1) << " " // WN
<< "\n";
}
id_start = id_start + blockgrid->Give_N_total_rectangle(id_rec);
}
Datei << "\nCELL_TYPES " << cell_total << "\n";
for(int id_rec=0;id_rec<ug->Give_number_rectangle();++id_rec) {
int Nx = blockgrid->Give_Nx_rectangle(id_rec);
int Ny = blockgrid->Give_Ny_rectangle(id_rec);
for(int j=0;j<Ny;++j) for(int i=0;i<Nx;++i)
Datei << "9"
<< "\n";
}
// Teil 4:
Datei << "POINT_DATA " << num_total << "\n";
Datei << "SCALARS " << title << " float 1\n";
Datei << "LOOKUP_TABLE default\r\n";
// Teil 6: Ausgabe der Werte der Variable2D
for(int id_rec=0;id_rec<ug->Give_number_rectangle();++id_rec) {
int Ny = blockgrid->Give_Ny_rectangle(id_rec);
int Nx = blockgrid->Give_Nx_rectangle(id_rec);
for(int j=0;j<=Ny;++j) for(int i=0;i<=Nx;++i) {
Datei << convert(data_rectangles[id_rec][i+(Nx+1)*j])
<< "\n";
}
}
};
template<>
void Variable2D<std::complex<double> >::Print_VTK ( std::ostream& Datei,
double ( *convert ) ( std::complex<double> x ),
std::string title) {
D2vector v;
Datei.precision(20);
Datei.setf(std::ios::fixed,std::ios::floatfield);
int num_total = 0;
int cell_total = 0;
// Teil 0: Write information
Datei << "# vtk DataFile Version 2.0\n"
<< title << std::endl
<< "ASCII\n"
<< "DATASET UNSTRUCTURED_GRID\n";
for(int id_rec=0;id_rec < ug->Give_number_rectangle();++id_rec) {
Update<rectangleEl>(id_rec);
num_total += blockgrid->Give_N_total_rectangle(id_rec);
cell_total += (blockgrid->Give_Nx_rectangle(id_rec))
*(blockgrid->Give_Ny_rectangle(id_rec));
}
// Teil 1: Kopfzeile schreiben
Datei << "POINTS " << num_total << " float\n";
// Teil 2: Koordinaten der Punkte ausgeben
for(int id_rec=0;id_rec<ug->Give_number_rectangle();++id_rec) {
int Ny = blockgrid->Give_Ny_rectangle(id_rec);
int Nx = blockgrid->Give_Nx_rectangle(id_rec);
for(int j=0;j<=Ny;++j)
for(int i=0;i<=Nx;++i) {
v = blockgrid->Give_coord_rectangle(id_rec,i,j);
Datei << v.x
<< " " << v.y
<< " " << 0.0
<< "\n";
}
}
// Teil 3: Zellen ausgeben
Datei << "\nCELLS " << cell_total << " " << cell_total*5 << "\n";
int id_start;
id_start = 0;
for(int id_rec=0;id_rec<ug->Give_number_rectangle();++id_rec) {
int Nx = blockgrid->Give_Nx_rectangle(id_rec);
int Ny = blockgrid->Give_Ny_rectangle(id_rec);
for(int j=0;j<Ny;++j) for(int i=0;i<Nx;++i) {
Datei << "4 "
<< id_start + i + (Nx+1)*j << " " // WS
<< id_start + i+1 + (Nx+1)*j << " " // ES
<< id_start + i+1 + (Nx+1)*(j+1) << " " // EN
<< id_start + i + (Nx+1)*(j+1) << " " // WN
<< "\n";
}
id_start = id_start + blockgrid->Give_N_total_rectangle(id_rec);
}
Datei << "\nCELL_TYPES " << cell_total << "\n";
for(int id_rec=0;id_rec<ug->Give_number_rectangle();++id_rec) {
int Nx = blockgrid->Give_Nx_rectangle(id_rec);
int Ny = blockgrid->Give_Ny_rectangle(id_rec);
for(int j=0;j<Ny;++j) for(int i=0;i<Nx;++i)
Datei << "9"
<< "\n";
}
// Teil 4:
Datei << "POINT_DATA " << num_total << "\n";
Datei << "SCALARS " << title << " float 1\n";
Datei << "LOOKUP_TABLE default\r\n";
// Teil 6: Ausgabe der Werte der Variable2Dref
for(int id_rec=0;id_rec<ug->Give_number_rectangle();++id_rec) {
int Ny = blockgrid->Give_Ny_rectangle(id_rec);
int Nx = blockgrid->Give_Nx_rectangle(id_rec);
for(int j=0;j<=Ny;++j) for(int i=0;i<=Nx;++i) {
Datei << convert(data_rectangles[id_rec][i+(Nx+1)*j]) << "\n";
}
}
}
#endif //#ifndef PRINTVAR2DQTVTKCCH
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment