default dump not-interpolated
parent
9e86a96436
commit
d31799e912
|
@ -4,10 +4,12 @@ ProcessFields::ProcessFields(Operator* op, Engine* eng) : Processing(op, eng)
|
||||||
{
|
{
|
||||||
DumpMode=0;
|
DumpMode=0;
|
||||||
DumpType = 0;
|
DumpType = 0;
|
||||||
|
// SetSubSampling(1);
|
||||||
|
|
||||||
for (int n=0;n<3;++n)
|
for (int n=0;n<3;++n)
|
||||||
{
|
{
|
||||||
discDLines[n]=NULL;
|
discDLines[n]=NULL;
|
||||||
|
discLines[n]=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,36 +19,79 @@ ProcessFields::~ProcessFields()
|
||||||
{
|
{
|
||||||
delete[] discDLines[n];
|
delete[] discDLines[n];
|
||||||
discDLines[n]=NULL;
|
discDLines[n]=NULL;
|
||||||
|
delete[] discLines[n];
|
||||||
|
discLines[n]=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessFields::DefineStartStopCoord(double* dstart, double* dstop)
|
void ProcessFields::DefineStartStopCoord(double* dstart, double* dstop)
|
||||||
{
|
{
|
||||||
if (Op->SnapToMesh(dstart,start,true)==false) cerr << "ProcessFields::DefineStartStopCoord: Warning: Snapping problem, check start value!!" << endl;
|
if (DumpMode==0)
|
||||||
if (Op->SnapToMesh(dstop,stop,true)==false) cerr << "ProcessFields::DefineStartStopCoord: Warning: Snapping problem, check stop value!!" << endl;
|
|
||||||
|
|
||||||
for (int n=0;n<3;++n)
|
|
||||||
{
|
{
|
||||||
// cerr << "start " << start[n] << "stop " << stop[n];
|
if (Op->SnapToMesh(dstart,start)==false) cerr << "ProcessFields::DefineStartStopCoord: Warning: Snapping problem, check start value!!" << endl;
|
||||||
if (start[n]>stop[n])
|
if (Op->SnapToMesh(dstop,stop)==false) cerr << "ProcessFields::DefineStartStopCoord: Warning: Snapping problem, check stop value!!" << endl;
|
||||||
|
//create dual mesh
|
||||||
|
for (int n=0;n<3;++n)
|
||||||
{
|
{
|
||||||
unsigned int help = start[n];
|
// cerr << "start " << start[n] << "stop " << stop[n];
|
||||||
start[n]=stop[n];
|
if (start[n]>stop[n])
|
||||||
stop[n]=help;
|
{
|
||||||
|
unsigned int help = start[n];
|
||||||
|
start[n]=stop[n];
|
||||||
|
stop[n]=help;
|
||||||
|
}
|
||||||
|
numLines[n]=stop[n]-start[n]+1;
|
||||||
|
// cerr << " number of lines " << numDLines[n] << endl;
|
||||||
|
delete[] discLines[n];
|
||||||
|
discLines[n] = new double[numLines[n]];
|
||||||
|
for (unsigned int i=0;i<numLines[n];++i)
|
||||||
|
{
|
||||||
|
discLines[n][i] = Op->discLines[n][start[n]+i];
|
||||||
|
// cerr << n << " : " << discDLines[n][i] << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
++stop[n];
|
}
|
||||||
numDLines[n]=stop[n]-start[n];
|
else if (DumpMode==2)
|
||||||
// cerr << " number of lines " << numDLines[n] << endl;
|
{
|
||||||
delete[] discDLines[n];
|
if (Op->SnapToMesh(dstart,start,true)==false) cerr << "ProcessFields::DefineStartStopCoord: Warning: Snapping problem, check start value!!" << endl;
|
||||||
discDLines[n] = new double[numDLines[n]];
|
if (Op->SnapToMesh(dstop,stop,true)==false) cerr << "ProcessFields::DefineStartStopCoord: Warning: Snapping problem, check stop value!!" << endl;
|
||||||
for (unsigned int i=0;i<numDLines[n];++i)
|
|
||||||
|
//create dual mesh
|
||||||
|
for (int n=0;n<3;++n)
|
||||||
{
|
{
|
||||||
discDLines[n][i] = 0.5*(Op->discLines[n][start[n]+i+1] + Op->discLines[n][start[n]+i]);
|
// cerr << "start " << start[n] << "stop " << stop[n];
|
||||||
// cerr << n << " : " << discDLines[n][i] << endl;
|
if (start[n]>stop[n])
|
||||||
|
{
|
||||||
|
unsigned int help = start[n];
|
||||||
|
start[n]=stop[n];
|
||||||
|
stop[n]=help;
|
||||||
|
}
|
||||||
|
++stop[n];
|
||||||
|
numDLines[n]=stop[n]-start[n];
|
||||||
|
// cerr << " number of lines " << numDLines[n] << endl;
|
||||||
|
delete[] discDLines[n];
|
||||||
|
discDLines[n] = new double[numDLines[n]];
|
||||||
|
for (unsigned int i=0;i<numDLines[n];++i)
|
||||||
|
{
|
||||||
|
discDLines[n][i] = 0.5*(Op->discLines[n][start[n]+i+1] + Op->discLines[n][start[n]+i]);
|
||||||
|
// cerr << n << " : " << discDLines[n][i] << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void ProcessFields::SetSubSampling(unsigned int subSampleRate, int dir)
|
||||||
|
//{
|
||||||
|
// if (dir>2) return;
|
||||||
|
// if (dir<0)
|
||||||
|
// {
|
||||||
|
// subSample[0]=subSampleRate;
|
||||||
|
// subSample[1]=subSampleRate;
|
||||||
|
// subSample[2]=subSampleRate;
|
||||||
|
// }
|
||||||
|
// else subSample[dir]=subSampleRate;
|
||||||
|
//}
|
||||||
|
|
||||||
bool ProcessFields::DumpFieldArray2VTK(ofstream &file, string name, FDTD_FLOAT**** array, double** discLines, unsigned int* numLines)
|
bool ProcessFields::DumpFieldArray2VTK(ofstream &file, string name, FDTD_FLOAT**** array, double** discLines, unsigned int* numLines)
|
||||||
{
|
{
|
||||||
file << "# vtk DataFile Version 2.0" << endl;
|
file << "# vtk DataFile Version 2.0" << endl;
|
||||||
|
|
|
@ -11,11 +11,13 @@ public:
|
||||||
|
|
||||||
virtual void DefineStartStopCoord(double* dstart, double* dstop);
|
virtual void DefineStartStopCoord(double* dstart, double* dstop);
|
||||||
|
|
||||||
|
// virtual void SetSubSampling(unsigned int subSampleRate, int dir=-1);
|
||||||
|
|
||||||
//! Used file pattern e.g. pattern="tmp/efield_" --> "tmp/efield_000045.vtk" for timestep 45 or "tmp/efield_2.40000e9.vtk" for 2.4GHz E-field dump.
|
//! Used file pattern e.g. pattern="tmp/efield_" --> "tmp/efield_000045.vtk" for timestep 45 or "tmp/efield_2.40000e9.vtk" for 2.4GHz E-field dump.
|
||||||
void SetFilePattern(string fp) {filePattern=fp;}
|
void SetFilePattern(string fp) {filePattern=fp;}
|
||||||
|
|
||||||
//! This methode will dump all fields in the center of a main cell (dual-node) using 4 E-field and 2 H-fields per direction. (default)
|
//! This methode will dump all fields in the center of a main cell (dual-node) using 4 E-field and 2 H-fields per direction. (default)
|
||||||
void SetDumpMode2Cell() {DumpMode=0;}
|
void SetDumpMode2Cell() {DumpMode=2;}
|
||||||
|
|
||||||
//! Set dump type: 0 for E-fields, 1 for H-fields, 2 for D-fields, 3 for B-fields, 4 for J-fields, etc...
|
//! Set dump type: 0 for E-fields, 1 for H-fields, 2 for D-fields, 3 for B-fields, 4 for J-fields, etc...
|
||||||
void SetDumpType(int type) {DumpType=type;}
|
void SetDumpType(int type) {DumpType=type;}
|
||||||
|
@ -30,6 +32,12 @@ protected:
|
||||||
int DumpType;
|
int DumpType;
|
||||||
string filePattern;
|
string filePattern;
|
||||||
|
|
||||||
|
// unsigned int subSample[3];
|
||||||
|
|
||||||
|
//! dump mesh
|
||||||
|
unsigned int numLines[3];
|
||||||
|
double* discLines[3];
|
||||||
|
//! dual dump mesh
|
||||||
unsigned int numDLines[3];
|
unsigned int numDLines[3];
|
||||||
double* discDLines[3];
|
double* discDLines[3];
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,18 +12,9 @@ ProcessFieldsTD::~ProcessFieldsTD()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessFieldsTD::Process()
|
void ProcessFieldsTD::DumpCellInterpol(ofstream &file)
|
||||||
{
|
{
|
||||||
if (Enabled==false) return;
|
if (DumpType==0)
|
||||||
if (filePattern.empty()) return;
|
|
||||||
stringstream ss;
|
|
||||||
ss << std::setw( pad_length ) << std::setfill( '0' ) << Eng->numTS;
|
|
||||||
|
|
||||||
string filename = filePattern + ss.str() + ".vtk";
|
|
||||||
ofstream file(filename.c_str());
|
|
||||||
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl; return;};
|
|
||||||
|
|
||||||
if (DumpType==0)
|
|
||||||
{
|
{
|
||||||
//create array
|
//create array
|
||||||
FDTD_FLOAT**** E_T = Create_N_3DArray(numDLines);
|
FDTD_FLOAT**** E_T = Create_N_3DArray(numDLines);
|
||||||
|
@ -84,11 +75,11 @@ void ProcessFieldsTD::Process()
|
||||||
H_T[0][pos[0]][pos[1]][pos[2]] /= (2*delta*Op->gridDelta);
|
H_T[0][pos[0]][pos[1]][pos[2]] /= (2*delta*Op->gridDelta);
|
||||||
//in y
|
//in y
|
||||||
delta = Op->discLines[1][OpPos[1]+1] - Op->discLines[1][OpPos[1]];
|
delta = Op->discLines[1][OpPos[1]+1] - Op->discLines[1][OpPos[1]];
|
||||||
H_T[1][pos[0]][pos[1]][pos[2]] = Eng->curr[0][OpPos[0]][OpPos[1]][OpPos[2]] + Eng->curr[0][OpPos[0]][OpPos[1]+1][OpPos[2]];
|
H_T[1][pos[0]][pos[1]][pos[2]] = Eng->curr[1][OpPos[0]][OpPos[1]][OpPos[2]] + Eng->curr[1][OpPos[0]][OpPos[1]+1][OpPos[2]];
|
||||||
H_T[1][pos[0]][pos[1]][pos[2]] /= (2*delta*Op->gridDelta);
|
H_T[1][pos[0]][pos[1]][pos[2]] /= (2*delta*Op->gridDelta);
|
||||||
//in z
|
//in z
|
||||||
delta = Op->discLines[2][OpPos[2]+1] - Op->discLines[2][OpPos[2]];
|
delta = Op->discLines[2][OpPos[2]+1] - Op->discLines[2][OpPos[2]];
|
||||||
H_T[2][pos[0]][pos[1]][pos[2]] = Eng->curr[0][OpPos[0]][OpPos[1]][OpPos[2]] + Eng->curr[0][OpPos[0]][OpPos[1]][OpPos[2]+1];
|
H_T[2][pos[0]][pos[1]][pos[2]] = Eng->curr[2][OpPos[0]][OpPos[1]][OpPos[2]] + Eng->curr[2][OpPos[0]][OpPos[1]][OpPos[2]+1];
|
||||||
H_T[2][pos[0]][pos[1]][pos[2]] /= (2*delta*Op->gridDelta);
|
H_T[2][pos[0]][pos[1]][pos[2]] /= (2*delta*Op->gridDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,5 +88,70 @@ void ProcessFieldsTD::Process()
|
||||||
Delete_N_3DArray(H_T,numDLines);
|
Delete_N_3DArray(H_T,numDLines);
|
||||||
H_T = NULL;
|
H_T = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessFieldsTD::DumpNoInterpol(ofstream &file)
|
||||||
|
{
|
||||||
|
if (DumpType==0)
|
||||||
|
{
|
||||||
|
//create array
|
||||||
|
FDTD_FLOAT**** E_T = Create_N_3DArray(numLines);
|
||||||
|
unsigned int pos[3];
|
||||||
|
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
||||||
|
{
|
||||||
|
for (pos[1]=0;pos[1]<numLines[1];++pos[1])
|
||||||
|
{
|
||||||
|
for (pos[2]=0;pos[2]<numLines[2];++pos[2])
|
||||||
|
{
|
||||||
|
E_T[0][pos[0]][pos[1]][pos[2]] = Eng->volt[0][pos[0]+start[0]][pos[1]+start[1]][pos[2]+start[2]];
|
||||||
|
E_T[1][pos[0]][pos[1]][pos[2]] = Eng->volt[1][pos[0]+start[0]][pos[1]+start[1]][pos[2]+start[2]];
|
||||||
|
E_T[2][pos[0]][pos[1]][pos[2]] = Eng->volt[2][pos[0]+start[0]][pos[1]+start[1]][pos[2]+start[2]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DumpFieldArray2VTK(file,string("E-Field"),E_T,discLines,numLines);
|
||||||
|
Delete_N_3DArray(E_T,numLines);
|
||||||
|
E_T = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DumpType==1)
|
||||||
|
{
|
||||||
|
//create array
|
||||||
|
FDTD_FLOAT**** H_T = Create_N_3DArray(numLines);
|
||||||
|
unsigned int pos[3] = {start[0],start[1],start[2]};
|
||||||
|
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
||||||
|
{
|
||||||
|
for (pos[1]=0;pos[1]<numLines[1];++pos[1])
|
||||||
|
{
|
||||||
|
for (pos[2]=0;pos[2]<numLines[2];++pos[2])
|
||||||
|
{
|
||||||
|
//in x
|
||||||
|
H_T[0][pos[0]][pos[1]][pos[2]] = Eng->curr[0][pos[0]+start[0]][pos[1]+start[1]][pos[2]+start[2]];
|
||||||
|
H_T[1][pos[0]][pos[1]][pos[2]] = Eng->curr[1][pos[0]+start[0]][pos[1]+start[1]][pos[2]+start[2]];
|
||||||
|
H_T[2][pos[0]][pos[1]][pos[2]] = Eng->curr[2][pos[0]+start[0]][pos[1]+start[1]][pos[2]+start[2]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DumpFieldArray2VTK(file,string("H-Field"),H_T,discLines,numLines);
|
||||||
|
Delete_N_3DArray(H_T,numLines);
|
||||||
|
H_T = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessFieldsTD::Process()
|
||||||
|
{
|
||||||
|
if (Enabled==false) return;
|
||||||
|
if (filePattern.empty()) return;
|
||||||
|
stringstream ss;
|
||||||
|
ss << std::setw( pad_length ) << std::setfill( '0' ) << Eng->numTS;
|
||||||
|
|
||||||
|
string filename = filePattern + ss.str() + ".vtk";
|
||||||
|
ofstream file(filename.c_str());
|
||||||
|
if (file.is_open()==false) { cerr << "ProcessFieldsTD::Process: can't open file '" << filename << "' for writing... abort! " << endl; return;};
|
||||||
|
|
||||||
|
if (DumpMode==0)
|
||||||
|
DumpNoInterpol(file);
|
||||||
|
if (DumpMode==2)
|
||||||
|
DumpCellInterpol(file);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int pad_length;
|
int pad_length;
|
||||||
|
|
||||||
|
void DumpNoInterpol(ofstream &file);
|
||||||
|
void DumpCellInterpol(ofstream &file);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROCESSFIELDS_TD_H
|
#endif // PROCESSFIELDS_TD_H
|
||||||
|
|
Loading…
Reference in New Issue