array_ops: continue templates
Signed-off-by: Thorsten Liebig <thorsten.liebig@gmx.de>
This commit is contained in:
parent
6f095f6acf
commit
11df0f5c37
@ -35,8 +35,8 @@ Engine_Ext_Mur_ABC::Engine_Ext_Mur_ABC(Operator_Ext_Mur_ABC* op_ext) : Engine_Ex
|
|||||||
m_Mur_Coeff_nyP = m_Op_mur->m_Mur_Coeff_nyP;
|
m_Mur_Coeff_nyP = m_Op_mur->m_Mur_Coeff_nyP;
|
||||||
m_Mur_Coeff_nyPP = m_Op_mur->m_Mur_Coeff_nyPP;
|
m_Mur_Coeff_nyPP = m_Op_mur->m_Mur_Coeff_nyPP;
|
||||||
|
|
||||||
m_volt_nyP = Create2DArray(m_numLines);
|
m_volt_nyP = Create2DArray<FDTD_FLOAT>(m_numLines);
|
||||||
m_volt_nyPP = Create2DArray(m_numLines);
|
m_volt_nyPP = Create2DArray<FDTD_FLOAT>(m_numLines);
|
||||||
|
|
||||||
//find if some excitation is on this mur-abc and find the max length of this excite, so that the abc can start after the excitation is done...
|
//find if some excitation is on this mur-abc and find the max length of this excite, so that the abc can start after the excitation is done...
|
||||||
int maxDelay=-1;
|
int maxDelay=-1;
|
||||||
|
@ -68,8 +68,8 @@ void Operator_Ext_Mur_ABC::SetDirection(int ny, bool top_ny)
|
|||||||
m_numLines[0] = m_Op->GetNumberOfLines(m_nyP);
|
m_numLines[0] = m_Op->GetNumberOfLines(m_nyP);
|
||||||
m_numLines[1] = m_Op->GetNumberOfLines(m_nyPP);
|
m_numLines[1] = m_Op->GetNumberOfLines(m_nyPP);
|
||||||
|
|
||||||
m_Mur_Coeff_nyP = Create2DArray(m_numLines);
|
m_Mur_Coeff_nyP = Create2DArray<FDTD_FLOAT>(m_numLines);
|
||||||
m_Mur_Coeff_nyPP = Create2DArray(m_numLines);
|
m_Mur_Coeff_nyPP = Create2DArray<FDTD_FLOAT>(m_numLines);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,53 +29,6 @@
|
|||||||
#define FREE( array ) free( array )
|
#define FREE( array ) free( array )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
FDTD_FLOAT** Create2DArray(const unsigned int* numLines)
|
|
||||||
{
|
|
||||||
FDTD_FLOAT** array=NULL;
|
|
||||||
unsigned int pos[3];
|
|
||||||
array = new FDTD_FLOAT*[numLines[0]];
|
|
||||||
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
|
||||||
{
|
|
||||||
array[pos[0]] = new FDTD_FLOAT[numLines[1]];
|
|
||||||
for (pos[1]=0;pos[1]<numLines[1];++pos[1])
|
|
||||||
{
|
|
||||||
array[pos[0]][pos[1]] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Delete2DArray(FDTD_FLOAT** array, const unsigned int* numLines)
|
|
||||||
{
|
|
||||||
if (array==NULL) return;
|
|
||||||
unsigned int pos[3];
|
|
||||||
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
|
||||||
{
|
|
||||||
delete[] array[pos[0]];
|
|
||||||
}
|
|
||||||
delete[] array;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dump_N_3DArray2File(ostream &file, FDTD_FLOAT**** array, unsigned int* 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])
|
|
||||||
{
|
|
||||||
file << pos[0] << "\t" << pos[1] << "\t" << pos[2];
|
|
||||||
for (int n=0;n<3;++n)
|
|
||||||
file << "\t" << array[n][pos[0]][pos[1]][pos[2]];
|
|
||||||
file << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Delete1DArray_v4sf(f4vector* array)
|
void Delete1DArray_v4sf(f4vector* array)
|
||||||
{
|
{
|
||||||
if (array==NULL) return;
|
if (array==NULL) return;
|
||||||
|
@ -41,15 +41,45 @@ union f4vector
|
|||||||
float f[4];
|
float f[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
FDTD_FLOAT** Create2DArray(const unsigned int* numLines);
|
void Delete1DArray_v4sf(f4vector* array);
|
||||||
void Delete2DArray(FDTD_FLOAT** array, const unsigned int* numLines);
|
void Delete3DArray_v4sf(f4vector*** array, const unsigned int* numLines);
|
||||||
|
void Delete_N_3DArray_v4sf(f4vector**** array, const unsigned int* numLines);
|
||||||
|
f4vector* Create1DArray_v4sf(const unsigned int numLines);
|
||||||
|
f4vector*** Create3DArray_v4sf(const unsigned int* numLines);
|
||||||
|
f4vector**** Create_N_3DArray_v4sf(const unsigned int* numLines);
|
||||||
|
|
||||||
void Dump_N_3DArray2File(ostream &file, FDTD_FLOAT**** array, const unsigned int* numLines);
|
// *************************************************************************************
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// templates
|
// templates
|
||||||
//
|
// *************************************************************************************
|
||||||
|
template <typename T>
|
||||||
|
T** Create2DArray(const unsigned int* numLines)
|
||||||
|
{
|
||||||
|
T** array=NULL;
|
||||||
|
unsigned int pos[3];
|
||||||
|
array = new T*[numLines[0]];
|
||||||
|
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
||||||
|
{
|
||||||
|
array[pos[0]] = new T[numLines[1]];
|
||||||
|
for (pos[1]=0;pos[1]<numLines[1];++pos[1])
|
||||||
|
{
|
||||||
|
array[pos[0]][pos[1]] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void Delete2DArray(T** array, const unsigned int* numLines)
|
||||||
|
{
|
||||||
|
if (array==NULL) return;
|
||||||
|
unsigned int pos[3];
|
||||||
|
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
||||||
|
{
|
||||||
|
delete[] array[pos[0]];
|
||||||
|
}
|
||||||
|
delete[] array;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T& Access_N_3DArray(T**** array, unsigned int n, unsigned int* pos)
|
inline T& Access_N_3DArray(T**** array, unsigned int n, unsigned int* pos)
|
||||||
{
|
{
|
||||||
@ -122,14 +152,23 @@ void Delete_N_3DArray(T**** array, const unsigned int* numLines)
|
|||||||
delete[] array;
|
delete[] array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void Dump_N_3DArray2File(ostream &file, T**** array, const unsigned int* numLines)
|
||||||
void Delete1DArray_v4sf(f4vector* array);
|
{
|
||||||
void Delete3DArray_v4sf(f4vector*** array, const unsigned int* numLines);
|
unsigned int pos[3];
|
||||||
void Delete_N_3DArray_v4sf(f4vector**** array, const unsigned int* numLines);
|
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
||||||
f4vector* Create1DArray_v4sf(const unsigned int numLines);
|
{
|
||||||
f4vector*** Create3DArray_v4sf(const unsigned int* numLines);
|
for (pos[1]=0;pos[1]<numLines[1];++pos[1])
|
||||||
f4vector**** Create_N_3DArray_v4sf(const unsigned int* numLines);
|
{
|
||||||
|
for (pos[2]=0;pos[2]<numLines[2];++pos[2])
|
||||||
|
{
|
||||||
|
file << pos[0] << "\t" << pos[1] << "\t" << pos[2];
|
||||||
|
for (int n=0;n<3;++n)
|
||||||
|
file << "\t" << (float)array[n][pos[0]][pos[1]][pos[2]];
|
||||||
|
file << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ARRAY_OPS_H
|
#endif // ARRAY_OPS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user