Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lr multipatch refinement alternative #207

Closed

Conversation

VikingScientist
Copy link
Contributor

Fixes LR multipatch refinement in two steps:

  • by using existing MLGN arrays to pass boundary functions to neighbouring patches (with the additional logic of finding boundary functions completely covered by requested refinement indices)
  • interior refinement is done by picking all overlapping functions of all boundary functions on both sides of the boundary. This is needed since LR meshes requires the mesh inside the patch to match near the boundary.

@VikingScientist
Copy link
Contributor Author

Illustration of why we need interior mesh-matching in addition to just the one on the boundary. This is why we need the proposed step 2

c0-matching-lr

@VikingScientist
Copy link
Contributor Author

Note: The above mesh is quartic p=4 (since functions go across 6 mesh lines). The proposed solution errs on the side of caution and creates a matching mesh p+1=5 elements into the mesh. This is by picking all interior functions that overlap with the shared boundary functions.

Copy link
Member

@akva2 akva2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

picking on the cosmetics first. also debug output needs to go.

@@ -307,6 +307,26 @@ IntVec ASMunstruct::getFunctionsForElements (const IntVec& elements)
return result;
}

IntVec ASMunstruct::getBoundaryNodesCovered (const IntVec& nodes) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additional space between functions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enig, Den uskrevne IFEM-standarden sier 2 blanke linjer.

geo->generateIDs();
IntVec oneBoundary, result;
int numbEdges = (getNoParamDim() == 2) ? 4 : 6;
for(int edge=1; edge<=numbEdges; edge++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space between for and (

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Du har ikke korrigert dette (samt for alle ditto)?? Dessuten dobbel space før edge++

for(int edge=1; edge<=numbEdges; edge++)
{
getBoundaryNodes(edge, oneBoundary); // this returns a 1-indexed list
for(const int i : nodes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

{
getBoundaryNodes(edge, oneBoundary); // this returns a 1-indexed list
for(const int i : nodes)
for(const int j : oneBoundary)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

getBoundaryNodes(edge, oneBoundary); // this returns a 1-indexed list
for(const int i : nodes)
for(const int j : oneBoundary)
if(geo->getBasisfunction(i)->contains(*geo->getBasisfunction(j-1)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

{
IntVec result;
geo->generateIDs();
for(const int i : nodes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

for(const int i : nodes)
{
LR::Basisfunction *b = geo->getBasisfunction(i);
for(auto el : b->support()) // for all elements where *b has support
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

{
LR::Basisfunction *b = geo->getBasisfunction(i);
for(auto el : b->support()) // for all elements where *b has support
for(auto basis : el->support()) // for all functions on this element
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

{
pch = dynamic_cast<ASMunstruct*>(myModel[i]);
IntVec secondary = pch->getOverlappingNodes(conformingIndicies[i]);
for(int j : conformingIndicies[i]) // add refinement from neighbours
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

refineIndices[i].push_back(j);

for(int j : secondary) // add depth refinement to make it conforming
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@akva2
Copy link
Member

akva2 commented Oct 12, 2017

bruker jeg den reduce footprint så sier frac 'frac you'.

@VikingScientist
Copy link
Contributor Author

multipatch-lshape-problems

This is the setup which requires the reduced footprint commit. The proposed setup managed to pass covered boundary functions (blue) to their respective connected patches (green), but the problem arised when interior mesh was to be refined. By taking all functions with overlapping support (yellow) one might actually hit another patch boundary and this is not detected and the gray function is never added.

The proposed solution in 7da3af4 tries to only pick (yellow) functions which support does not grow in the boundary tangent direction, but only in the boundary normal direction.

@VikingScientist VikingScientist force-pushed the lr-multipatch-alternative branch 2 times, most recently from a8d705d to b8d9a62 Compare October 12, 2017 13:37
@VikingScientist
Copy link
Contributor Author

Updated... fixed all boundary cases, and made the code all pretty

@VikingScientist
Copy link
Contributor Author

jenkins build this with downstreams ifem-poisson=13 ifem-elasiticity=37 please

@VikingScientist
Copy link
Contributor Author

jenkins build this with downstreams ifem-poisson=13 ifem-elasticity=37 please

@VikingScientist VikingScientist force-pushed the lr-multipatch-alternative branch 3 times, most recently from fffbbfa to 7138a12 Compare October 13, 2017 12:57
@VikingScientist
Copy link
Contributor Author

jenkins build this with downstreams ifem-poisson=13 ifem-elasticity=37 ifem-stokes=77 please

1 similar comment
@VikingScientist
Copy link
Contributor Author

jenkins build this with downstreams ifem-poisson=13 ifem-elasticity=37 ifem-stokes=77 please

@VikingScientist
Copy link
Contributor Author

Is this OK? Can we put this on trunk now? I can't make Jenkins run the tests for some reason 😢

@akva2
Copy link
Member

akva2 commented Oct 16, 2017

jenkins build this with downstreams ifem-poisson=13 ifem-elasticity=37 ifem-stokes=77 please

@VikingScientist VikingScientist force-pushed the lr-multipatch-alternative branch from 7138a12 to 225e9af Compare October 17, 2017 06:40
@VikingScientist
Copy link
Contributor Author

Squashed fixup commits. Ready for merge. Also Elasticity, Poisson and Stokes

Copy link
Contributor

@kmokstad kmokstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prøvde å gå gjennom, og fant en del ting å pirke på.
Alt dette henger mer eller mindre sammen så vidt jeg kan se, så jeg tror man med fordel kan squashe alt (eller det meste) til end commit. Da er det enklere å gjøre effektiv review,

//! \param nodes List of (0-indexed) patch local node IDs
//! \returns Node IDs (0-indexed) for boundary functions whos support is
// completely covered by the union of the support in the input array
virtual IntVec getBoundaryNodesCovered(const IntVec& nodes) const ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fjern space før ; og det holder med en space etter \param og \return i doxyen, og siden nodes kun er input, bruk \param[in]. One spell error too (whos --> whose).

@@ -307,6 +307,26 @@ IntVec ASMunstruct::getFunctionsForElements (const IntVec& elements)
return result;
}

IntVec ASMunstruct::getBoundaryNodesCovered (const IntVec& nodes) const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enig, Den uskrevne IFEM-standarden sier 2 blanke linjer.

geo->generateIDs();
IntVec oneBoundary, result;
int numbEdges = (getNoParamDim() == 2) ? 4 : 6;
for(int edge=1; edge<=numbEdges; edge++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Du har ikke korrigert dette (samt for alle ditto)?? Dessuten dobbel space før edge++

std::sort(result.begin(), result.end());
auto last = std::unique(result.begin(), result.end());
result.erase(last, result.end());
return result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magefølelsen sier at du vel trenger å inkludere <algorithm>for at dette skal bygge over alt?

Men, et bedre alternative er kanskje å bruke std::set<int> result i stedet og så return IntVec(result.begin(),result.end());. Da vil sorteringen og uniqueifiseringen komme på kjøpet.

@@ -27,6 +27,8 @@
#include <sstream>
#include <numeric>

using namespace std;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nei, vi vil ikke ha denne her eller andre steder. Vi bruker std::-scoping der det trengs,

cout << j << endl;
cout << " Covered (boundary) indices:\n";
for(int j : bndry_nodes)
cout << j << endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dette er vel mer debug-output som bør gjemmes unna i en #ifdef SP_DEBUG eller noe?
Og legg til std::cout hvis utskriften ønske beholdes.

std::sort(refineIndices[i].begin(), refineIndices[i].end());
auto last = std::unique(refineIndices[i].begin(), refineIndices[i].end());
refineIndices[i].erase(last, refineIndices[i].end());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Her også, vurder å bruke std::set<int>i stedet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Innser nå at mye av det jeg kommenterte på i første commit er endret på i denne. Da burde heller de to committene vært squashet til en for å gjøre review-prosessen enklere og ryddigere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hvis du klikker på "Files changed" istedenfor "commits" øverst, så får du diff'en til hele pull requesten. Essensielt det du spør om: slik ting hadde sett ut hvis alt hadde blitt most til en enkelt commit.

Jeg tror ikke review hadde blitt enklere med få commits, tvert imot da man mister commit messages og en del logikk til hvorfor ting blir som de blir. Jeg kan derimot se argumentet med at man ikke vil ha for mange intermediate states i historikken der programmet dumper ut unødvendig mye debug print (som her hos meg) eller værst av alt: ikke kompilerer (skal ikke være tilfellet her). Hvis det fortsatt er ønskelig, så moser jeg alt sammen til en stor commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all del, alt trenger ikke å være en stor commit, men de committene som er der bør vær logisk inndelt så langt det går. Ihvertfall trengs ikke fjernings av debug print, dokumentasjons-endringer, etc. være separat. De kan med fordel inkluderes i de forrige der de hører best hjemme.

@@ -142,8 +142,9 @@ class ASMunstruct : public ASMbase

//! \brief Return all functions whos support overlap with the input functions
//! \param nodes List of (0-indexed) patch local node IDs (typically requested by adaptive refinement)
//! \param dir In which parametric direction the basis functions are allowed to have bigger support (-1 for all)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\param[in] dir

for (size_t j = 0; j < myModel.size(); j++)
{
std::sort(conformingIndicies[j].begin(), conformingIndicies[j].end());
auto last = std::unique(conformingIndicies[j].begin(), conformingIndicies[j].end());
conformingIndicies[j].erase(last, conformingIndicies[j].end());
for(int l : conformingIndicies[j])
cout << "#"<<j<<": "<<l << endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Og der forsvant debug-output'en gitt. dvs. min kommentering på det i forrige commit var bortkasta. Dette understrerker at det er viktig å squase slike endringer også før review.

for (size_t i = 0; i < myModel.size(); i++)
{
std::sort(conformingIndicies[i].begin(), conformingIndicies[i].end());
auto last = std::unique(conformingIndicies[i].begin(), conformingIndicies[i].end());
conformingIndicies[i].erase(last, conformingIndicies[i].end());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, consider using std::set<int>?

@VikingScientist VikingScientist force-pushed the lr-multipatch-alternative branch from 39d0e53 to f8a0d31 Compare October 18, 2017 07:20
@VikingScientist
Copy link
Contributor Author

All requested changes fixed

@VikingScientist VikingScientist force-pushed the lr-multipatch-alternative branch from f8a0d31 to e573c49 Compare October 18, 2017 09:03
@VikingScientist
Copy link
Contributor Author

Is this ready for merging?

@kmokstad
Copy link
Contributor

Well, I looked at it again tonight as I cloned your branch anyway to check it on the Hemisphere problem. And I found several smaller/cosmetic issues I would like to correct. But to save you the burden for more "kverulering" from me, I did a rebase myself. See the branch kmokstad:lr-multipatch-alternative. You'll find most of your commits there (except two) such that the history is intact, but without some cosmetic backs-and-forth. The main difference is more use of std::set instead of vector, but the results should be unchanged. Check if you agree, then you can merge that one.

@kmokstad
Copy link
Contributor

kmokstad commented Nov 7, 2017

#215 have now been merged instead, so this one is therefore obsolete.

@kmokstad kmokstad closed this Nov 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants