From 15bb9279d7e00886deec45691e482e8cbc29ea7d Mon Sep 17 00:00:00 2001 From: Morteza HS Date: Tue, 1 Jun 2021 15:54:01 -0400 Subject: [PATCH] Adds a new functionality to maDBG this debug functionality allows the uniform refinement of entities classified on a specific model entity as identified by a pair of integers (model dim, model tag) --- ma/maDBG.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ ma/maDBG.h | 6 +++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/ma/maDBG.cc b/ma/maDBG.cc index 808bedf3d..71d4459ea 100644 --- a/ma/maDBG.cc +++ b/ma/maDBG.cc @@ -10,6 +10,7 @@ #include "maDBG.h" #include "maShape.h" #include "maAdapt.h" +#include "maRefine.h" #include #include #include @@ -386,4 +387,48 @@ void visualizeSizeField( apf::destroyMesh(msf); } +struct SplitByTag : public ma::Predicate +{ + SplitByTag(ma::Adapt* a_, int type_, int tag_) : + a(a_), type(type_), tag(tag_) {} + bool operator() (ma::Entity* e) { + ma::Mesh* m = a->mesh; + int mtype = m->getModelType(m->toModel(e)); + int mtag = m->getModelTag(m->toModel(e)); + if (mtype != type) return false; + if (mtag != tag ) return false; + return true; + } + ma::Adapt* a; + int type; + int tag; +}; + +void uniformAdaptByModelTag( + apf::Mesh2* m, + int mtype, + int mtag, + int level) +{ + ma::Input* in = ma::configureUniformRefine(m, 0); + ma::validateInput(in); + ma::Adapt* a = new ma::Adapt(in); + for(int i = 0; i < level; i++) { + SplitByTag p(a, mtype, mtag); + ma::markEntities(a, 1, p, ma::SPLIT, ma::NEED_NOT_SPLIT, + ma::DONT_SPLIT | ma::NEED_NOT_SPLIT); + PCU_ALWAYS_ASSERT(ma::checkFlagConsistency(a,1,ma::SPLIT)); + ma::Refine* r = a->refine; + ma::resetCollection(r); + ma::collectForTransfer(r); + ma::collectForMatching(r); + ma::addAllMarkedEdges(r); + ma::splitElements(r); + ma::processNewElements(r); + ma::destroySplitElements(r); + ma::forgetNewEntities(r); + } + delete(a); +} + } diff --git a/ma/maDBG.h b/ma/maDBG.h index 751450aa3..027a245fd 100644 --- a/ma/maDBG.h +++ b/ma/maDBG.h @@ -67,6 +67,10 @@ void visualizeSizeField( int smapleSize[2], double userScale, const char* OutputPrefix); - +void uniformAdaptByModelTag( + apf::Mesh2* m, + int mtype, + int mtag, + int level); } #endif