Add StencilTables factory for tables concatenation

This commit is contained in:
manuelk 2014-11-13 14:03:21 -08:00
parent c6306b42c4
commit 5254fd58e7
2 changed files with 65 additions and 1 deletions

View File

@ -187,6 +187,55 @@ StencilTablesFactory::Create(TopologyRefiner const & refiner,
//------------------------------------------------------------------------------
StencilTables const *
StencilTablesFactory::Create(int numTables, StencilTables const ** tables) {
StencilTables * result = new StencilTables;
if ( (numTables<=0) or (not tables)) {
return result;
}
int ncvs = tables[0]->GetNumControlVertices(),
nstencils = 0,
nelems = 0;
for (int i=0; i<numTables; ++i) {
StencilTables const & st = *tables[i];
if (st.GetNumControlVertices()!=ncvs) {
return result;
}
nstencils += st.GetNumStencils();
nelems += (int)st.GetControlIndices().size();
}
result->resize(nstencils, nelems);
result->_numControlVertices = ncvs;
Index * indices = &result->_indices[0];
float * weights = &result->_weights[0];
for (int i=0; i<numTables; ++i) {
StencilTables const & st = *tables[i];
int size = (int)st._indices.size();
memcpy(indices, &st._indices[0], size*sizeof(Index));
memcpy(weights, &st._weights[0], size*sizeof(float));
indices += size;
weights += size;
}
// have to re-generate offsets from scratch
result->generateOffsets();
return result;
}
//------------------------------------------------------------------------------
LimitStencilTables const *
LimitStencilTablesFactory::Create(TopologyRefiner const & refiner,
LocationArrayVec const & locationArrays, StencilTables const * cvStencils,

View File

@ -83,11 +83,26 @@ public:
///
/// @param refiner The TopologyRefiner containing the topology
///
/// @param options Options controlling the creation of the tables
/// @param options Options controlling the creation of the tables
///
static StencilTables const * Create(TopologyRefiner const & refiner,
Options options = Options());
/// \brief Instantiates StencilTables by concatenating an array of existing
/// stencil tables.
///
/// \note This factory checks that the stencil tables point to the same set
/// of supporting control vertices - no re-indexing is done.
/// GetNumControlVertices() *must* return the same value for all input
/// tables.
///
/// @param numTables Number of input StencilTables
///
/// @param tables Array of input StencilTables
///
static StencilTables const * Create(int numTables, StencilTables const ** tables);
/// \brief Returns a KernelBatch applying all the stencil in the tables
/// to primvar data.
///