diff --git a/src/multi-body-problem-data/grid/mygrids.cc b/src/multi-body-problem-data/grid/mygrids.cc index e18f316b7f6a787f4ca917dc9ede3fc9968b1266..874f4c6edadb6a6dff2e1db1b5e00cf303d66756 100644 --- a/src/multi-body-problem-data/grid/mygrids.cc +++ b/src/multi-body-problem-data/grid/mygrids.cc @@ -85,6 +85,7 @@ template <class Grid> GridsConstructor<Grid>::GridsConstructor(const std::vector } grids[idx] = std::shared_ptr<Grid>(gridFactories[idx].createGrid()); + grids[idx]->setRefinementType(Grid::RefinementType::COPY); } } diff --git a/src/multi-body-problem.cc b/src/multi-body-problem.cc index 5c7dc0bc214b65493dedeb18b0d8ad5985188096..51f691ad52e23360dd4d56a0f367315a926fbc81 100644 --- a/src/multi-body-problem.cc +++ b/src/multi-body-problem.cc @@ -182,11 +182,18 @@ int main(int argc, char *argv[]) { // ---------------------------- contactNetwork.assemble(); - const auto & coarseContactNetwork = *contactNetwork.level(0); - const auto & fineContactNetwork = *contactNetwork.level(1); + /* std::vector<Vector> def(bodyCount); + for (size_t i=0; i<bodyCount; i++) { + def[i].resize(contactNetwork.body(i)->nVertices()); + def[i] = 1; + } + contactNetwork.setDeformation(def);*/ + + const auto & coarseContactNetwork = *contactNetwork.level(3); + const auto & fineContactNetwork = *contactNetwork.level(4); SupportPatchFactory<typename ContactNetwork::LevelContactNetwork> supportPatchFactory(coarseContactNetwork, fineContactNetwork); size_t bodyID = 2; - size_t patchDepth = 0; + size_t patchDepth = 3; std::cout << std::endl; diff --git a/src/spatial-solving/preconditioners/supportpatchfactory.hh b/src/spatial-solving/preconditioners/supportpatchfactory.hh index a4a91be78eca6725613289d0b81b9d05c6217abf..8b191cf0ff9d2ae5543425752001d18b6cf3c36a 100644 --- a/src/spatial-solving/preconditioners/supportpatchfactory.hh +++ b/src/spatial-solving/preconditioners/supportpatchfactory.hh @@ -315,18 +315,23 @@ class SupportPatchFactory std::queue<BodyElement> patchSeeds; patchSeeds.push(seedElement); + std::set<size_t> visitedBodies; + for (size_t depth=0; depth<=patchDepth; depth++) { std::vector<BodyElement> nextSeeds; std::set<size_t> newPatchVertices; while (!patchSeeds.empty()) { const auto& patchSeed = patchSeeds.front(); - patchSeeds.pop(); size_t elemIdx = coarseIndices_.elementIndex(patchSeed.bodyID, patchSeed.element); - if (visitedElements.count(elemIdx)) + if (visitedElements.count(elemIdx)) { + patchSeeds.pop(); continue; + } + + visitedBodies.insert(patchSeed.bodyID); visitedElements.insert(elemIdx); @@ -363,7 +368,7 @@ class SupportPatchFactory size_t neighborIdx = coarseIndices_.elementIndex(neighbor.bodyID, neighbor.element); - if (visitedElements.count(neighborIdx)) + if (visitedElements.count(neighborIdx) || visitedBodies.count(neighbor.bodyID)) continue; std::vector<std::set<size_t>> dofs; @@ -404,7 +409,7 @@ class SupportPatchFactory size_t neighborIdx = coarseIndices_.elementIndex(neighbor.bodyID, neighbor.element); - if (visitedElements.count(neighborIdx)) + if (visitedElements.count(neighborIdx) || visitedBodies.count(neighbor.bodyID)) continue; newPatchVertices.insert(neighborFaceDofs_[faceIdx].begin(), neighborFaceDofs_[faceIdx].end()); @@ -414,6 +419,8 @@ class SupportPatchFactory } } } + + patchSeeds.pop(); } for (size_t i=0; i<nextSeeds.size(); i++) { @@ -499,7 +506,7 @@ class SupportPatchFactory const auto& gridView = fineContactNetwork_.body(coarseElem.bodyID)->gridView(); const size_t bodyID = coarseElem.bodyID; - const auto coarseLevel = coarseElem.element.level(); + const auto coarseLevel = coarseContactNetwork_.body(coarseElem.bodyID)->level(); // search for parts of the global and inner boundary for (const auto& is : intersections(gridView, fineElem)) {