Commit f99a441a authored by Phillip Lino Rall's avatar Phillip Lino Rall
Browse files

Merge branch 'master' of i10git.cs.fau.de:er96apow/UGBlocks_V3

parents a56bbac4 5affe25d
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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>
......@@ -233,6 +100,27 @@ Exp_Functor1<A, DTyp_Result, DTyp, Func>::Give_fromTotal(int i) const {
/** \addtogroup ExpressionTemplates **/
/* @{ */
/**
* The class Func must contain a member function
* DTyp Func::evalute(DTyp x);
* Then, one apply Functor1 as follows
* \verbatim
* class Func test{
* public:
* Func(double f) : mf(f) {};
* double evaluate(double x) { return x * mf; }
* private:
* double mf;
* };
* .....
*
* Func multiplyFive(5.0);
* Functor1 multiplyFiveFunc(multiplyFive);
* .....
*
* a = multiplyFiveFunc(b);
* \endverbatim
**/
template <class DTyp_Result, class DTyp, class Func>
class Functor1 {
public:
......@@ -254,7 +142,6 @@ class Functor1 {
* 2 arguments
**/
template <class A, class B, class DTyp_Result, class DTyp, class Func>
class Exp_Functor2
: public Expr<Exp_Functor2<A, B, DTyp_Result, DTyp, Func> > {
const A& a_;
......@@ -317,6 +204,11 @@ Exp_Functor2<A, B, DTyp_Result, DTyp, Func>::Give_fromTotal(int i) const {
/** \addtogroup ExpressionTemplates **/
/* @{ */
/**
* The class Func must contain a member function
* DTyp Func::evalute(DTyp x, DTyp y);
* see Functor1
**/
template <class DTyp_Result, class DTyp, class Func>
class Functor2 {
......@@ -420,8 +312,12 @@ Exp_Functor3<A, B, C, DTyp_Result, DTyp, Func>::Give_fromTotal(int i) const {
/** \addtogroup ExpressionTemplates **/
/* @{ */
/**
* The class Func must contain a member function
* DTyp Func::evalute(DTyp x, DTyp y, DTyp z);
* see Functor1
**/
template <class DTyp_Result, class DTyp, class Func>
class Functor3 {
public:
......@@ -510,8 +406,12 @@ Exp_Functor4<A, B, C, D, DTyp_Result, DTyp, Func>::Give_cell_hexahedra ( params_
/** \addtogroup ExpressionTemplates **/
/* @{ */
/**
* The class Func must contain a member function
* DTyp Func::evalute(DTyp x, DTyp y);
* see Functor1
**/
template <class DTyp_Result, class DTyp, class Func>
class Functor4 {
public:
......
......@@ -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));
}
......
......@@ -746,7 +746,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))
......@@ -943,7 +943,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))
......@@ -1141,7 +1141,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 );
......@@ -365,8 +367,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;
......@@ -389,6 +393,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;
......@@ -404,7 +410,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 )