本文整理汇总了C++中GridStorage::get方法的典型用法代码示例。如果您正苦于以下问题:C++ GridStorage::get方法的具体用法?C++ GridStorage::get怎么用?C++ GridStorage::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridStorage
的用法示例。
在下文中一共展示了GridStorage::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consolidateShadow
/**
* If during the refinement one or more points of the shadow register are added
* to the actual grid then we have to remove these points from the shadow storage.
*/
void PrewaveletGridGenerator::consolidateShadow() {
GridStorage* temp = new GridStorage(storage->dim());
for (size_t i = 0; i < shadowstorage->size(); i++) {
temp->insert(*shadowstorage->get(i));
}
shadowstorage->emptyStorage();
for (size_t i = 0; i < temp->size(); i++) {
if (storage->find(temp->get(i)) == storage->end()) {
shadowstorage->insert(*temp->get(i));
}
}
delete temp;
}
示例2: main
int main() {
// create a two-dimensional piecewise bilinear grid
size_t dim = 2;
Grid* grid = Grid::createLinearGrid(dim);
GridStorage* gridStorage = grid->getStorage();
std::cout << "dimensionality: " << gridStorage->dim() << std::endl;
// create regular grid, level 3
size_t level = 3;
GridGenerator* gridGen = grid->createGridGenerator();
gridGen->regular(level);
std::cout << "number of initial grid points: " << gridStorage->size() << std::endl;
// create coefficient vector
DataVector alpha(gridStorage->size());
alpha.setAll(0.0);
std::cout << "length of alpha vector: " << alpha.getSize() << std::endl;
GridIndex* gp;
// refine adaptively 5 times
for (int step = 0; step < 5; step++) {
// set function values in alpha
for (size_t i = 0; i < gridStorage->size(); i++) {
gp = gridStorage->get(i);
alpha[i] = f(gp->getCoord(0), gp->getCoord(1));
}
// hierarchize
SGPP::op_factory::createOperationHierarchisation(*grid)->doHierarchisation(
alpha);
// refine a single grid point each time
gridGen->refine(new SurplusRefinementFunctor(&alpha, 1));
std::cout << "refinement step " << step + 1 << ", new grid size: " << alpha.getSize()
<< std::endl;
// extend alpha vector (new entries uninitialized)
alpha.resize(gridStorage->size());
}
delete grid;
}
示例3: testHierarchisationDehierarchisation
void testHierarchisationDehierarchisation(SGPP::base::Grid* grid, size_t level,
SGPP::float_t (*func)(DataVector&),
SGPP::float_t tolerance = 0.0, bool naiveOp = false,
bool doStretch = false) {
GridGenerator* gridGen = grid->createGridGenerator();
gridGen->regular(level);
GridStorage* gridStore = grid->getStorage();
size_t dim = gridStore->dim();
Stretching* stretch = NULL;
if (doStretch) stretch = gridStore->getStretching();
DataVector node_values = DataVector(gridStore->size());
DataVector coords = DataVector(dim);
for (size_t n = 0; n < gridStore->size(); n++) {
if (doStretch) {
gridStore->get(n)->getCoordsStretching(coords, *stretch);
} else {
gridStore->get(n)->getCoords(coords);
}
node_values[n] = func(coords);
}
DataVector alpha = DataVector(node_values);
OperationHierarchisation* hierarchisation =
SGPP::op_factory::createOperationHierarchisation(*grid);
hierarchisation->doHierarchisation(alpha);
if (naiveOp == true) {
OperationNaiveEval* op = SGPP::op_factory::createOperationNaiveEval(*grid);
for (size_t n = 0; n < gridStore->size(); n++) {
if (doStretch) {
gridStore->get(n)->getCoordsStretching(coords, *stretch);
} else {
gridStore->get(n)->getCoords(coords);
}
SGPP::float_t eval = op->eval(alpha, coords);
BOOST_CHECK_CLOSE(eval, node_values[n], tolerance);
}
} else {
OperationEval* op = SGPP::op_factory::createOperationEval(*grid);
for (size_t n = 0; n < gridStore->size(); n++) {
if (doStretch) {
gridStore->get(n)->getCoordsStretching(coords, *stretch);
} else {
gridStore->get(n)->getCoords(coords);
}
SGPP::float_t eval = op->eval(alpha, coords);
BOOST_CHECK_CLOSE(eval, node_values[n], tolerance);
}
}
DataVector node_values_back = DataVector(alpha);
hierarchisation->doDehierarchisation(node_values_back);
for (size_t n = 0; n < gridStore->size(); n++) {
BOOST_CHECK_CLOSE(node_values_back[n], node_values[n], tolerance);
}
}