Commit 7e315a51 authored by Christoph Pflaum's avatar Christoph Pflaum
Browse files

isystem hinzu

parent 69edd80f
......@@ -40,19 +40,3 @@
// some member functions
/*
template <>
template <>
void Expr_interpolant_point_to_cell<double>::Update<hexahedronEl>(int id_hex) const {
v->Update<hexahedronEl>(id_hex);
}
template <>
template <>
void Expr_interpolant_point_to_cell<std::complex<double> >::Update<hexahedronEl>(int id_hex) const {
v->Update<hexahedronEl>(id_hex);
}
*/
......@@ -98,10 +98,15 @@ inline Expr_interpolant_point_to_cell<A> Cell_interpolation(const Expr<A>& a) {
// 2.1. definition
//////////////////////////////////////////////////////////////
template <class DTyp, class Vari>
class VariableVector;
template <class DTyp>
class Cell_variable : public Expr<Cell_variable< DTyp > > {
public:
friend VariableVector<DTyp, Cell_variable<DTyp> >;
public:
typedef DTyp Result;
......@@ -111,8 +116,8 @@ class Cell_variable : public Expr<Cell_variable< DTyp > > {
~Cell_variable();
template <elementTyp TYP_EL>
void Update(int id) const {}
// template <elementTyp TYP_EL>
// void Update(int id) const {}
Blockgrid* Give_blockgrid() const { return blockgrid; };
Unstructured_grid* Give_Ug() const { return ug; };
......@@ -163,6 +168,7 @@ class Cell_variable : public Expr<Cell_variable< DTyp > > {
bool containsNaN();
private:
inline DTyp* give_startTotal() const { return dataTotal; }
Blockgrid* blockgrid;
Unstructured_grid* ug;
......@@ -385,7 +391,7 @@ void Cell_variable<DTyp>::operator=(const Cell_variable<DTyp>& varRight) {
for(int id=startHex;id<endHex;++id) {
int idRight = id - startHex;
varRight.template Update<hexahedronEl>(id);
// varRight.template Update<hexahedronEl>(id);
if(ug->Give_hexahedron(id)->my_object(my_rank)) {
Nx = blockgrid->Give_Nx_hexahedron(id);
......@@ -410,7 +416,7 @@ void Cell_variable<DTyp>::operator=(const Cell_variable<DTyp>& varRight) {
// hexahedra
for(int id=0;id<numberHex;++id) {
varRight.template Update<hexahedronEl>(id);
// varRight.template Update<hexahedronEl>(id);
if(ug->Give_hexahedron(id)->my_object(my_rank)) {
......@@ -449,7 +455,7 @@ void Cell_variable<DTyp>::operator=(const Expr<A>& a) {
// hexahedra
int Nx, Ny, Nz;
for(int id=0;id<numberHex;++id) {
ao.template Update<hexahedronEl>(id);
//ao.template Update<hexahedronEl>(id);
if(ug->Give_hexahedron(id)->my_object(my_rank)) {
Nx = blockgrid->Give_Nx_hexahedron(id);
......@@ -478,7 +484,7 @@ void Cell_variable<DTyp>::operator=(const Expr_Restriction<A>& a) {
// hexahedra
for(int id=0;id<numberHex;++id) {
a.template Update<hexahedronEl>(id);
//a.template Update<hexahedronEl>(id);
if(ug->Give_hexahedron(id)->my_object(my_rank) &&
a.template Give_marker<hexahedronEl>(id)==yes_mark) {
......
......@@ -45,139 +45,6 @@
* class FunctorVector
*
************************************************************/
#ifdef CPP11
#include <tuple>
#define Functor1 Functor
template<int ...> struct Functor_seq {};
template<int N, int ...S> struct Functor_gens : Functor_gens<N-1, N-1, S...> {};
template<int ...S> struct Functor_gens<0, S...>{ typedef Functor_seq<S...> type; };
template<typename... Args> inline void pass(Args&&...) {}
template <class DTyp_Result, class DTyp, class Func, typename ... A>
class Exp_Functor : public Expr< Exp_Functor<DTyp_Result, DTyp, Func, A...> > {
std::tuple<const A&...> a_;
Func& functor_;
control_typ funCtrTyp_;
template<elementTyp TYP_EL, int ...S>
inline DTyp_Result
Give_data_private(params_in, Functor_seq<S...>) const;
template<int ...S>
inline DTyp_Result
Give_cell_hexahedra_private(params_in_cell, Functor_seq<S...>) const;
template <elementTyp TYP_EL, int ...S>
void
Update_private ( int id, Functor_seq<S...> ) const;
template <elementTyp TYP_EL>
void
Update_private ( const A&... a ) const
{}
template <elementTyp TYP_EL, typename Any>
inline Any& Update_private ( int id, Any& any) const {
any.template Update<TYP_EL>(id);
return any;
}
public:
inline Exp_Functor ( Func& functor, control_typ funCtrTyp, const A&... a )
: functor_ ( functor ), funCtrTyp_ ( funCtrTyp ), a_ ( a... ) {}
stencil_typ Give_stencil_typ() const { return no_stencil; }
control_typ Give_control_typ() const { return funCtrTyp_; }
typedef DTyp_Result Result;
template <elementTyp TYP_EL>
inline DTyp_Result Give_data ( params_in ) const;
inline DTyp_Result Give_cell_hexahedra ( params_in_cell ) const;
template <elementTyp TYP_EL>
void Update ( int id ) const;
inline Blockgrid* Give_blockgrid() const { return std::get<1>(a_).Give_blockgrid(); };
template <class VType>
friend class Variable2D;
};
template <class DTyp_Result, class DTyp, class Func, typename... A>
template <elementTyp TYP_EL>
inline void
Exp_Functor<DTyp_Result, DTyp, Func, A...>::Update(int id) const
{
Update_private<TYP_EL>( id, typename Functor_gens<sizeof...(A)>::type() );
}
template <class DTyp_Result, class DTyp, class Func, typename... A>
template <elementTyp TYP_EL, int ...S>
inline void
Exp_Functor<DTyp_Result, DTyp, Func, A...>::Update_private ( int id, Functor_seq<S...> ) const {
Update_private<TYP_EL>( Update_private<TYP_EL>(id,std::get<S>(a_))... );
}
template <class DTyp_Result, class DTyp, class Func, typename... A>
template <elementTyp TYP_EL>
inline DTyp_Result
Exp_Functor<DTyp_Result, DTyp, Func, A...>::Give_data(params_in) const
{
return Give_data_private<TYP_EL>( params_out, typename Functor_gens<sizeof...(A)>::type() );
}
template <class DTyp_Result, class DTyp, class Func,typename... A>
inline DTyp_Result
Exp_Functor<DTyp_Result, DTyp, Func, A...>::Give_cell_hexahedra(params_in_cell) const
{
return Give_cell_hexahedra_private( params_out_cell, typename Functor_gens<sizeof...(A)>::type() );
}
template <class DTyp_Result, class DTyp, class Func, typename... A>
template <elementTyp TYP_EL, int ...S>
inline DTyp_Result
Exp_Functor<DTyp_Result, DTyp, Func, A...>::Give_data_private ( params_in, Functor_seq<S...> ) const {
return functor_.evaluate ( std::get<S>(a_).template Give_data<TYP_EL> ( params_out )... );
}
template <class DTyp_Result, class DTyp, class Func, typename... A>
template <int ...S>
inline DTyp_Result
Exp_Functor<DTyp_Result, DTyp, Func, A...>::Give_cell_hexahedra_private ( params_in_cell, Functor_seq<S...> ) const {
return functor_.evaluate ( std::get<S>(a_).Give_cell_hexahedra ( params_out_cell )... );
}
template <class DTyp_Result, class DTyp, class Func>
class Functor {
public:
Functor ( Func& functor, control_typ funCtrTyp = thread_save ) : functor_ ( functor ), funCtrTyp_ ( funCtrTyp ) {};
template <typename... A>
inline Exp_Functor<DTyp_Result, DTyp, Func, A...>
operator() ( const A&... a ) const
{ return Exp_Functor<DTyp_Result, DTyp, Func, A...> ( functor_, funCtrTyp_, a... ); }
private:
Func& functor_;
control_typ funCtrTyp_;
};
#endif
template <class A, class DTyp_Result, class DTyp, class Func>
......
......@@ -57,7 +57,7 @@ void Cell_variable<std::complex<double> >::Print_VTK(std::ostream& Datei, double
for (id = 0; id < ug->Give_number_hexahedra(); ++id) {
if (marker == NULL || marker->Give_marker<hexahedronEl>(id) == yes_mark) {
Update<hexahedronEl>(id);
// Update<hexahedronEl>(id);
num_total += blockgrid->Give_N_total_hexahedron(id);
cell_total += (blockgrid->Give_Nx_hexahedron(id)) * (blockgrid->Give_Ny_hexahedron(id)) * (blockgrid->Give_Nz_hexahedron(id));
}
......
......@@ -739,7 +739,7 @@ void Cell_variable<DTyp>::Print_VTK(std::ostream& Datei,double (*convert)(DTyp x
for(id=0;id<ug->Give_number_hexahedra();++id) {
if(marker == NULL || marker->Give_marker<hexahedronEl>(id)==yes_mark) {
Update<hexahedronEl>(id);
// Update<hexahedronEl>(id);
num_total += blockgrid->Give_N_total_hexahedron(id);
cell_total += (blockgrid->Give_Nx_hexahedron(id))
*(blockgrid->Give_Ny_hexahedron(id))
......@@ -936,7 +936,7 @@ void Cell_variable<DTyp>::QPrint_VTK(QString DateiName,double (*convert)(DTyp x)
for(id=0;id<ug->Give_number_hexahedra();++id) {
if(marker == NULL || marker->Give_marker<hexahedronEl>(id)==yes_mark) {
Update<hexahedronEl>(id);
// Update<hexahedronEl>(id);
num_total += blockgrid->Give_N_total_hexahedron(id);
cell_total += (blockgrid->Give_Nx_hexahedron(id))
*(blockgrid->Give_Ny_hexahedron(id))
......@@ -1134,7 +1134,7 @@ void Cell_variable<DTyp>::QPrint_VTK(QString DateiName,complex<double> (*convert
for(id=0;id<ug->Give_number_hexahedra();++id) {
if(marker == NULL || marker->Give_marker<hexahedronEl>(id)==yes_mark) {
Update<hexahedronEl>(id);
// Update<hexahedronEl>(id);
num_total += blockgrid->Give_N_total_hexahedron(id);
cell_total += (blockgrid->Give_Nx_hexahedron(id))
*(blockgrid->Give_Ny_hexahedron(id))
......
......@@ -249,6 +249,8 @@ Variable<double>::Variable(Blockgrid& blockgrid_, double *data) :
blockgrid = &blockgrid_;
ug = blockgrid->Give_unstructured_grid();
totalNumberData = 0;
dataTotal = NULL;
specialVariableForOneBlock = true;
// Kopie der UG Daten zum Löschen
......@@ -380,6 +382,8 @@ Variable<double>::Variable(Blockgrid& blockgrid_, double **dataHex) :
blockgrid = &blockgrid_;
ug = blockgrid->Give_unstructured_grid();
totalNumberData = 0;
dataTotal = NULL;
specialVariableForOneBlock = true;
// Kopie der UG Daten zum Löschen
......
......@@ -215,16 +215,18 @@ inline Expr_Restriction_Iterdes<A> operator| ( const Expr<A>& a, const Iteration
class Assign_System;
template <class DTyp, class Vari>
class VariableVector;
template <class DTyp>
class Variable : public Expr<Variable< DTyp > >, public Object_based_on_ug {
template <class A, class ADTyp>
friend class Expr_Equation_of_Array;
friend class Expr_Equation_of_Array;
class Assign_System;
friend VariableVector<DTyp, Variable<DTyp> >;
public:
int checkThreshold(double threshold, int kz );
......@@ -362,8 +364,10 @@ class Variable : public Expr<Variable< DTyp > >, public Object_based_on_ug {
// copies data from a in hex_a to data in hex_b
void Copy_invert_z ( int hex_b, Variable<DTyp> a, int hex_a );
int getTotalNumberData() const { return totalNumberData; }
private:
inline DTyp* give_startTotal() const { assert(dataTotal!=NULL); return dataTotal; }
Blockgrid* blockgrid;
Unstructured_grid* ug;
......@@ -386,6 +390,8 @@ class Variable : public Expr<Variable< DTyp > >, public Object_based_on_ug {
// DTyp** data_interior_triangles; // num_triangles
// DTyp** data_exterior_triangles; // num_triangles
// for parallel
int my_rank;
MPI_Comm comm;
......@@ -401,7 +407,10 @@ class Variable : public Expr<Variable< DTyp > >, public Object_based_on_ug {
bool isIndeterminateTT(const double pV) { return (pV != pV); }
bool isInfiniteTT(const double pV) { return (fabs(pV) == std::numeric_limits<double>::infinity()); }
bool specialVariableForOneBlock;
// own data
int totalNumberData;
DTyp* dataTotal;
bool specialVariableForOneBlock; //> dann ist dataTotal nicht verwendbar
};
template <class DTyp>
......
......@@ -57,14 +57,104 @@ Variable<DTyp>::Variable(Blockgrid& blockgrid_ ) :
my_rank = ug->Give_my_rank();
comm = ug->Give_MPI_comm();
// Teil I
//------------
totalNumberData = 0;
// hexahedra
data_hexahedra = new DTyp*[ug->Give_number_hexahedra() ];
for ( int id=0; id<ug->Give_number_hexahedra(); ++id ) {
num_total = blockgrid->Give_N_total_hexahedron ( id );
if ( ug->Give_hexahedron ( id )->my_object ( my_rank ) ) {
data_hexahedra[id] = new DTyp[num_total];
totalNumberData = totalNumberData + num_total;
} else data_hexahedra[id] = NULL;
}
// quadrangles
data_quadrangles = new DTyp*[ug->Give_number_quadrangles() ];
for ( int id=0; id<ug->Give_number_quadrangles(); ++id ) {
num_total = blockgrid->Give_N_total_quadrangle ( id );
if ( ug->Give_quadrangle ( id )->my_object ( my_rank ) ) {
totalNumberData = totalNumberData + num_total;
} else {
data_quadrangles[id] = NULL;
}
}
data_interior_quadrangles = new DTyp*[ug->Give_number_quadrangles() ];
for ( int id=0; id<ug->Give_number_quadrangles(); ++id ) {
num_total = blockgrid->Give_N_total_quadrangle ( id );
if ( ug->Give_quadrangle ( id )->my_object ( my_rank ) ) {
totalNumberData = totalNumberData + num_total;
} else data_interior_quadrangles[id] = NULL;
}
data_exterior_quadrangles = new DTyp*[ug->Give_number_quadrangles() ];
for ( int id=0; id<ug->Give_number_quadrangles(); ++id ) {
if ( ug->Give_quadrangle ( id )->Give_exists_exterior() &&
ug->Give_quadrangle ( id )->my_object ( my_rank ) ) {
num_total = blockgrid->Give_N_total_quadrangle ( id );
totalNumberData = totalNumberData + num_total;
} else data_exterior_quadrangles[id] = NULL;
}
// edges
data_edges = new DTyp*[ug->Give_number_edges() ];
for ( int id=0; id<ug->Give_number_edges(); ++id ) {
num_total = blockgrid->Give_Nx_edge ( id ) +1;
if ( ug->Give_edge ( id )->my_object ( my_rank ) ) {
totalNumberData = totalNumberData + num_total;
} else data_edges[id] = NULL;
}
data_neighbor_edges = new DTyp**[ug->Give_number_edges() ];
for ( int id=0; id<ug->Give_number_edges(); ++id ) {
num_neighbor = ug->Give_edge ( id )->Give_number_neighbors();
if ( ug->Give_edge ( id )->my_object ( my_rank ) ) {
data_neighbor_edges[id] = new DTyp*[num_neighbor];
for ( int i=0; i<num_neighbor; ++i ) {
num_total = blockgrid->Give_Nx_edge ( id ) +1;
totalNumberData = totalNumberData + num_total;
}
} else data_neighbor_edges[id] = NULL;
}
// points
data_points = new DTyp*[ug->Give_number_points() ];
for ( int id=0; id<ug->Give_number_points(); ++id ) {
num_total = 1;
if ( ug->Give_point ( id )->my_object ( my_rank ) ) {
totalNumberData = totalNumberData + num_total;
} else data_points[id] = NULL;
}
data_neighbor_points = new DTyp*[ug->Give_number_points() ];
for ( int id=0; id<ug->Give_number_points(); ++id ) {
num_total = ug->Give_point ( id )->Give_number_neighbors();
if ( ug->Give_point ( id )->my_object ( my_rank ) ) {
totalNumberData = totalNumberData + num_total;
} else data_neighbor_points[id] = NULL;
}
// Teil II
//------------
dataTotal = new DTyp[totalNumberData];
int indexStart = 0;
// Teil III
//------------
// hexahedra
for ( int id=0; id<ug->Give_number_hexahedra(); ++id ) {
num_total = blockgrid->Give_N_total_hexahedron ( id );
if ( ug->Give_hexahedron ( id )->my_object ( my_rank ) ) {
data_hexahedra[id] = &(dataTotal[indexStart]);
indexStart = indexStart + num_total;
{
#pragma omp parallel for num_threads(UGBlocks::numThreadsToTake) if(UGBlocks::useOpenMP)
......@@ -75,12 +165,12 @@ Variable<DTyp>::Variable(Blockgrid& blockgrid_ ) :
}
// quadrangles
data_quadrangles = new DTyp*[ug->Give_number_quadrangles() ];
for ( int id=0; id<ug->Give_number_quadrangles(); ++id ) {
num_total = blockgrid->Give_N_total_quadrangle ( id );
if ( ug->Give_quadrangle ( id )->my_object ( my_rank ) ) {
data_quadrangles[id] = new DTyp[num_total];
data_quadrangles[id] = &(dataTotal[indexStart]);
indexStart = indexStart + num_total;
for ( int i=0; i<num_total; ++i )
data_quadrangles[id][i] = ( DTyp ) 0;
......@@ -89,44 +179,45 @@ Variable<DTyp>::Variable(Blockgrid& blockgrid_ ) :
}
}
data_interior_quadrangles = new DTyp*[ug->Give_number_quadrangles() ];
for ( int id=0; id<ug->Give_number_quadrangles(); ++id ) {
num_total = blockgrid->Give_N_total_quadrangle ( id );
if ( ug->Give_quadrangle ( id )->my_object ( my_rank ) ) {
data_interior_quadrangles[id] = new DTyp[num_total];
data_interior_quadrangles[id] = &(dataTotal[indexStart]);
indexStart = indexStart + num_total;
for ( int i=0; i<num_total; ++i )
data_interior_quadrangles[id][i] = ( DTyp ) 0;
} else data_interior_quadrangles[id] = NULL;
}
data_exterior_quadrangles = new DTyp*[ug->Give_number_quadrangles() ];
for ( int id=0; id<ug->Give_number_quadrangles(); ++id ) {
if ( ug->Give_quadrangle ( id )->Give_exists_exterior() &&
ug->Give_quadrangle ( id )->my_object ( my_rank ) ) {
num_total = blockgrid->Give_N_total_quadrangle ( id );
data_exterior_quadrangles[id] = new DTyp[num_total];
data_exterior_quadrangles[id] = &(dataTotal[indexStart]);
indexStart = indexStart + num_total;
for ( int i=0; i<num_total; ++i )
data_exterior_quadrangles[id][i] = ( DTyp ) 0;
} else data_exterior_quadrangles[id] = NULL;
}
// edges
data_edges = new DTyp*[ug->Give_number_edges() ];
for ( int id=0; id<ug->Give_number_edges(); ++id ) {
num_total = blockgrid->Give_Nx_edge ( id ) +1;
if ( ug->Give_edge ( id )->my_object ( my_rank ) ) {
data_edges[id] = new DTyp[num_total];
data_edges[id] = &(dataTotal[indexStart]);
indexStart = indexStart + num_total;
for ( int i=0; i<num_total; ++i )
data_edges[id][i] = ( DTyp ) 0;
} else data_edges[id] = NULL;
}
data_neighbor_edges = new DTyp**[ug->Give_number_edges() ];
for ( int id=0; id<ug->Give_number_edges(); ++id ) {
num_neighbor = ug->Give_edge ( id )->Give_number_neighbors();
......@@ -134,8 +225,10 @@ Variable<DTyp>::Variable(Blockgrid& blockgrid_ ) :
data_neighbor_edges[id] = new DTyp*[num_neighbor];
for ( int i=0; i<num_neighbor; ++i ) {
num_total = blockgrid->Give_Nx_edge ( id ) +1;
data_neighbor_edges[id][i] = new DTyp[num_total];
data_neighbor_edges[id][i] = &(dataTotal[indexStart]);
indexStart = indexStart + num_total;
for ( int j=0; j<num_total; ++j )
data_neighbor_edges[id][i][j] = ( DTyp ) 0;
}
......@@ -143,28 +236,30 @@ Variable<DTyp>::Variable(Blockgrid& blockgrid_ ) :
}
// points
data_points = new DTyp*[ug->Give_number_points() ];
for ( int id=0; id<ug->Give_number_points(); ++id ) {
num_total = 1;
if ( ug->Give_point ( id )->my_object ( my_rank ) ) {
data_points[id] = new DTyp[num_total];
data_points[id] = &(dataTotal[indexStart]);
indexStart = indexStart + num_total;
for ( int i=0; i<num_total; ++i )
data_points[id][i] = ( DTyp ) 0;
} else data_points[id] = NULL;
}
data_neighbor_points = new DTyp*[ug->Give_number_points() ];
for ( int id=0; id<ug->Give_number_points(); ++id ) {
num_neighbor = ug->Give_point ( id )->Give_number_neighbors();
num_total = ug->Give_point ( id )->Give_number_neighbors();
if ( ug->Give_point ( id )->my_object ( my_rank ) ) {
data_neighbor_points[id] = new DTyp[num_neighbor];
for ( int i=0; i<num_neighbor; ++i )
data_neighbor_points[id] = new DTyp[num_total];
data_neighbor_points[id] = &(dataTotal[indexStart]);
indexStart = indexStart + num_total;
for ( int i=0; i<num_total; ++i )
data_neighbor_points[id][i] = ( DTyp ) 0;
} else data_neighbor_points[id] = NULL;
}
}
}
template <class DTyp>
......@@ -179,14 +274,15 @@ Variable<DTyp>::~Variable()
template <class DTyp>
void Variable<DTyp>::Delete_data() {
int num_neighbor;
if ( ug==NULL ) return;
ug=NULL;
if ( data_hexahedra != NULL && (specialVariableForOneBlock==false)) {
for ( int i=0; i< ug_number_hexahedra; ++i )
if ( data_hexahedra[i] != NULL )
delete [] data_hexahedra[i];
int num_neighbor;
if(ug==NULL ) return;
ug=NULL;
if(specialVariableForOneBlock) { //spezielle Datenstruktur
if ( data_hexahedra != NULL) {
// for ( int i=0; i< ug_number_hexahedra; ++i )
// if ( (data_hexahedra[i] != NULL) && (specialVariableForOneBlock==false))
// delete [] data_hexahedra[i];
delete [] data_hexahedra;
}
data_hexahedra = NULL;
......@@ -254,6 +350,54 @@ void Variable<DTyp>::Delete_data() {
data_neighbor_points = NULL;
delete [] ug_edge_number_neighbors;
}
else {
delete [] dataTotal;
if ( data_hexahedra != NULL) {
delete [] data_hexahedra;