diff --git a/apf/apfAggregateNumbering.cc b/apf/apfAggregateNumbering.cc index 4e77a9578..17099d815 100644 --- a/apf/apfAggregateNumbering.cc +++ b/apf/apfAggregateNumbering.cc @@ -1,4 +1,5 @@ #include "apfAggregateNumbering.h" +#include "apfAggregateNumberingClass.h" #include "apfField.h" #include "apfNumberingClass.h" #include "apfTagData.h" @@ -8,51 +9,9 @@ #include namespace apf { - template - class AggregateNumberingOf : public NumberingOf - { - public: - AggregateNumberingOf() - : NumberingOf() - , nd_ids(NULL) - , shr(NULL) - , blks_per_nd(0) - , dofs_per_blk(0) - , slf(-1) - , strds() - , frsts() - , lcl_strd(0) - { } - void init(const char * n, - Mesh * m, - Sharing * sh, - FieldShape * s, - int blks, - int bs); - void init(Field * f, Sharing * sh, int blks, int bs); - void globalize(); - virtual void getAll(MeshEntity * e, T * dat); - virtual T get(MeshEntity * e, int nd, int cmp); - virtual void set(MeshEntity*,int,int,T) {} - Sharing * getSharing() const { return shr; } - void setSharing(Sharing * s) { shr = s; } - int countBlocks() const { return blks_per_nd; } - int blockSize() const { return dofs_per_blk; } - T getLocalStride() const { return lcl_strd; } - T getScopeStride() const { return strds[slf]; } - T getLocalFirstDof() const { return frsts[slf]; } - T getStride(int peer) const { return strds[peer]; }; - T getFirstDof(int peer) const { return frsts[peer]; } - private: - FieldDataOf * nd_ids; - Sharing * shr; - int blks_per_nd; - int dofs_per_blk; - int slf; - DynamicArray strds; - DynamicArray frsts; - int lcl_strd; - }; + // explicit instantiations + template class AggregateNumberingOf; + template class AggregateNumberingOf; // this assumes that the ranks returned by a sharing // do not change when the pcu comm changes // if the sharing can handle the pcu comm changing @@ -288,16 +247,11 @@ namespace apf getAll(e,&data[0]); return data[nd*cmps + cmp]; } - // explicit instantiations - template class AggregateNumberingOf; - template class AggregateNumberingOf; - typedef AggregateNumberingOf AggNumbering; - typedef AggregateNumberingOf GlobalAggNumbering; - Numbering * createAggNumbering(Field * f, - int blocks, - int dofs_per_block, - MPI_Comm cm, - Sharing * share) + AggNumbering * createAggNumbering(Field * f, + int blocks, + int dofs_per_block, + MPI_Comm cm, + Sharing * share) { bool dlt = false; if(!share) @@ -330,13 +284,13 @@ namespace apf f->getMesh()->addNumbering(n); return n; } - Numbering * createAggNumbering(Mesh * m, - const char * name, - FieldShape * shape, - int blocks, - int dofs_per_block, - MPI_Comm cm, - Sharing * share) + AggNumbering * createAggNumbering(Mesh * m, + const char * name, + FieldShape * shape, + int blocks, + int dofs_per_block, + MPI_Comm cm, + Sharing * share) { bool dlt = false; if(!share) @@ -364,4 +318,17 @@ namespace apf m->addNumbering(n); return n; } + /* Public API */ + Numbering * getNumbering(AggNumbering * n) + { + return static_cast(n); + } + int countBlocks(AggNumbering * n) + { + return n->blockSize(); + } + int countDOFsPerBlock(AggNumbering * n) + { + return n->blockSize(); + } } diff --git a/apf/apfAggregateNumbering.h b/apf/apfAggregateNumbering.h index 1989859e2..ff2715fb5 100644 --- a/apf/apfAggregateNumbering.h +++ b/apf/apfAggregateNumbering.h @@ -2,21 +2,36 @@ #define APF_AGGREGATE_NUMBERING_H_ #include "apfNew.h" #include "apfMesh.h" +#include "apfNumbering.h" #include namespace apf { - Numbering * createAggNumbering(Field * f, - int blocks, - int dofs_per_block, - MPI_Comm cm, - Sharing * share = NULL); - Numbering * createAggNumbering(Mesh * m, - const char * name, - FieldShape * shape, - int blocks, - int dofs_per_block, - MPI_Comm cm, - Sharing * share = NULL); + // class declaration + template + class AggregateNumberingOf; + typedef AggregateNumberingOf AggNumbering; + typedef AggregateNumberingOf GlobalAggNumbering; + // numbering creation functions + AggNumbering * createAggNumbering(Field * f, + int blocks, + int dofs_per_block, + MPI_Comm cm, + Sharing * share = NULL); + AggNumbering * createAggNumbering(Mesh * m, + const char * name, + FieldShape * shape, + int blocks, + int dofs_per_block, + MPI_Comm cm, + Sharing * share = NULL); + /* + * @brief Since the class implementation is not public + * we need an API to up-cast AggNumbering to + * Numbering. + */ + Numbering * getNumbering(AggNumbering * n); + int countBlocks(AggNumbering * n); + int countDOFsPerBlock(AggNumbering * n); } #endif /****************************************************************************** diff --git a/apf/apfAggregateNumberingClass.h b/apf/apfAggregateNumberingClass.h new file mode 100644 index 000000000..ae6e4c1dd --- /dev/null +++ b/apf/apfAggregateNumberingClass.h @@ -0,0 +1,53 @@ +#ifndef APF_AGGREGATE_NUMBERING_CLASS_H_ +#define APF_AGGREGATE_NUMBERING_CLASS_H_ +#include "apfFieldData.h" +#include "apfNumberingClass.h" +namespace apf +{ + template + class AggregateNumberingOf : public NumberingOf + { + public: + AggregateNumberingOf() + : NumberingOf() + , nd_ids(NULL) + , shr(NULL) + , blks_per_nd(0) + , dofs_per_blk(0) + , slf(-1) + , strds() + , frsts() + , lcl_strd(0) + { } + void init(const char * n, + Mesh * m, + Sharing * sh, + FieldShape * s, + int blks, + int bs); + void init(Field * f, Sharing * sh, int blks, int bs); + void globalize(); + virtual void getAll(MeshEntity * e, T * dat); + virtual T get(MeshEntity * e, int nd, int cmp); + virtual void set(MeshEntity*,int,int,T) {} + Sharing * getSharing() const { return shr; } + void setSharing(Sharing * s) { shr = s; } + int countBlocks() const { return blks_per_nd; } + int blockSize() const { return dofs_per_blk; } + T getLocalStride() const { return lcl_strd; } + T getScopeStride() const { return strds[slf]; } + T getLocalFirstDof() const { return frsts[slf]; } + T getStride(int peer) const { return strds[peer]; }; + T getFirstDof(int peer) const { return frsts[peer]; } + private: + FieldDataOf * nd_ids; + Sharing * shr; + int blks_per_nd; + int dofs_per_blk; + int slf; + DynamicArray strds; + DynamicArray frsts; + int lcl_strd; + }; +} +#endif