(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#include <cstdlib> | |
#include <iostream> | |
#include <math.h> | |
using namespace std; | |
/// matrix dimensions n >= m for my use case | |
const int n = 3; | |
const int m = 2; |
bool test_tetgen() { | |
/// grid management | |
Grid g; | |
ug::SubsetHandler sh(g); | |
g.attach_to_vertices(ug::aPosition); | |
ug::Grid::VertexAttachmentAccessor<ug::APosition3> aaPos(g, ug::aPosition); | |
/// unit cube | |
ug::RegularVertex* temp1 = *g.create<ug::RegularVertex>(); | |
ug::RegularVertex* temp2 = *g.create<ug::RegularVertex>(); |
------------------------------------------------------------------------------- | |
-- PARAMETERS | |
------------------------------------------------------------------------------- | |
minParamA = 0 | |
maxParamA = 10 | |
stepParamA = 1 | |
------------------------------------------------------------------------------- | |
------------------------------------------------------------------------------- | |
------------------------------------------------------------------------------- |
template <typename TGridFunction> | |
void TestenSCV(SmartPtr<TGridFunction> spGridFct, | |
const char* cmp, const char* subset) { | |
SmartPtr<ug::MultiGridSubsetHandler> spSh = spGridFct->domain().get()->subset_handler(); | |
ug::MultiGridSubsetHandler* sh = spSh.get(); | |
int si = sh->get_subset_index(subset); | |
UG_COND_THROW(si == -1, "Subset not present!"); | |
int grid_level = sh->num_levels()-1; |
/// Collapse now | |
std::vector<Grid::traits<Edge>::secure_container>::iterator it = edgeContainers.begin(); | |
size_t numEdges = 4; | |
for (; it != edgeContainers.end(); ++it) { | |
UG_LOGN("edges contained in container: " << it->size()); | |
if (it->size() > numEdges) { | |
for (size_t i = 0; i < it->size()-numEdges; i++) { | |
UG_LOGN("Collapse " << i); | |
CollapseEdge(g, (*it)[0], (*it)[0]->vertex(0)); | |
} |
// Collapse edges | |
size_t beginningOfQuads = 2; | |
for (size_t i = 0; i < numQuads; i++) { | |
size_t numEdges = sh.num<Edge>(beginningOfQuads+i); | |
while (numEdges > 4) { | |
Edge* e = *sh.begin<Edge>(beginningOfQuads+i); | |
CollapseEdge(g, e, e->vertex(0)); | |
numEdges--; | |
} | |
} |
#include <iostream> | |
#include <vector> | |
#include <cmath> | |
#include <cstring> | |
#include <cstdlib> | |
#include <cstdio> | |
#include <cassert> | |
using namespace std; |
SelectSubsetElements<Vertex>(sel, sh, si, true); | |
std::vector<Vertex*> vrts; | |
vrts.assign(sel.vertices_begin(), sel.vertices_end()); | |
sel.clear(); | |
std::vector<Edge*> edges; | |
SelectSubsetElements<Edge>(sel, sh, si, true); | |
edges.assign(sel.edges_begin(), sel.edges_end()); | |
sel.clear(); |
SelectSubsetElements<Vertex>(sel, sh, si, true); | |
std::vector<Vertex*> vrts; | |
vrts.assign(sel.vertices_begin(), sel.vertices_end()); | |
sel.clear(); | |
std::vector<Edge*> edges; | |
SelectSubsetElements<Edge>(sel, sh, si, true); | |
edges.assign(sel.edges_begin(), sel.edges_end()); | |
sel.clear(); |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.