50ContactSearchAlgorithm_Surface2FESurface_3d_SweepAndPrune :: initialize()
54 unsigned int n = n_slaves + n_masters;
56 aabbs.resize(n_slaves + n_masters);
59 for (
int axis=0; axis<3; axis++) {
62 for (
unsigned int i = 0; i < n; ++i) {
63 bool isSlave = i >= n_masters;
64 const auto& aabb =
aabbs[i];
65 for (
unsigned int axis = 0; axis < 3; ++axis) {
66 auto& bounds = this->
boundss[axis];
81 for (
int axis = 0; axis < 3; ++axis) {
82 auto& bounds = this->
boundss[axis];
84 potentialPairsPerAxis.clear();
85 std::sort(bounds.begin(), bounds.end(), [](
const Bound& a,
const Bound& b) {
86 return a.value < b.value;
88 unsigned int nBounds = bounds.size();
89 for (
size_t i = 0; i < nBounds - 1; ++i) {
90 const auto& bi = bounds[i];
91 if (!bi.isMin)
continue;
92 for (
size_t j = i + 1; j < nBounds; ++j) {
93 const auto& bj = bounds[j];
95 if (bi.id == bj.id)
break;
97 if (!bj.isMin)
continue;
98 if (bi.isSlave == bj.isSlave)
continue;
100 unsigned int i_master;
101 unsigned int i_slave;
109 IJ ij = {i_master, i_slave};
111 potentialPairsPerAxis.insert(ij);
119 for (
const auto& ij : potentialPairsPerAxis0) {
121 contains(potentialPairsPerAxis1, ij)
123 contains(potentialPairsPerAxis2, ij)
132ContactSearchAlgorithm_Surface2FESurface_3d_SweepAndPrune :: updateAABBs()
134 unsigned int index = 0;
137 for (
unsigned int i = 1; i <= n_masters; ++i) {
139 auto aabb = master->computeAABB();
145 auto aabb = slave->computeSlaveAABB();
153ContactSearchAlgorithm_Surface2FESurface_3d_SweepAndPrune :: updateBoundss()
157 for (
int axis = 0; axis < 2; ++axis) {
159 (axis == 0) ? std::get<0>(this->
boundss)
161 (axis == 1) ? std::get<1>(this->
boundss)
165 for (
auto& b : bounds) {
166 const auto& aabb =
aabbs[b.id];
167 b.value = b.isMin ? aabb.min[axis] : aabb.max[axis];
202ContactSearchAlgorithm_Surface2FESurface_3d_SweepAndPrune :: solveInversion(
214 }
else if (axis == 1) {
224 unsigned int i_master;
225 unsigned int i_slave;
233 IJ ij = {i_master, i_slave};
235 potentialPairsPerAxis1.insert(ij);
237 contains(potentialPairsPerAxis2, ij)
239 contains(potentialPairsPerAxis3, ij)
244 potentialPairsPerAxis1.erase(ij);
250ContactSearchAlgorithm_Surface2FESurface_3d_SweepAndPrune :: updateContactPairs(
TimeStep *tStep)
258 std::map<unsigned int, std::vector<unsigned int>> slave2masters;
260 auto [i_master, i_slave] = ij;
261 if (slave2masters.find(i_slave) == slave2masters.end()) {
262 slave2masters[i_slave] = {};
264 slave2masters[i_slave].push_back(i_master);
274 for (
auto [i_slave_plus_n_masters, i_masters] : slave2masters) {
275 unsigned int i_slave = i_slave_plus_n_masters - n_masters;
278 int closestContactElementId = -1;
281 for (
unsigned int i_master_0 : i_masters ) {
282 unsigned int i_master = i_master_0 + 1;
284 auto [inElement,localCoords, newGap,normal, t1, t2] = this->
masterContactSurface->findContactPointInElement_3d(slavePoint, contactElement, tStep);
286 if ( closestContactElementId == -1. || newGap < gap ) {
288 normalVector = normal;
291 contactPointLocalCoordinates = localCoords;
292 closestContactElementId = contactElement->giveNumber();
296 if (closestContactElementId) {
297 auto master_point = std::make_unique<FEContactPoint_Master>(this->
masterContactSurface, closestContactElementId, 2, contactPointLocalCoordinates);
298 cp->setMasterContactPoint(std::move(master_point));
299 cp->setNormalGap(gap);
300 cp->setNormalVector(normalVector);
301 cp->setTangentVector1(tangentVector1);
302 cp->setTangentVector2(tangentVector2);