94 std::vector<moonolith::Integer> &pairs)
102 std::vector<::moonolith::AABB<1, double>> src_boxes, dest_boxes;
106 ::moonolith::SerialHashGrid<1, double> grid;
107 return grid.detect(src_boxes, dest_boxes, pairs);
111 std::vector<::moonolith::AABB<2, double>> src_boxes, dest_boxes;
115 ::moonolith::SerialHashGrid<2, double> grid;
116 return grid.detect(src_boxes, dest_boxes, pairs);
120 std::vector<::moonolith::AABB<3, double>> src_boxes, dest_boxes;
124 ::moonolith::SerialHashGrid<3, double> grid;
125 return grid.detect(src_boxes, dest_boxes, pairs);
154 const bool verbose = impl_->verbose;
156 const auto &source_mesh = *impl_->source->GetMesh();
157 const auto &destination_mesh = *impl_->destination->GetMesh();
159 int dim = source_mesh.Dimension();
161 std::vector<::moonolith::Integer> pairs;
170 assert(
false &&
"NOT Supported!");
179 B = make_shared<SparseMatrix>(impl_->destination->GetNDofs(),
180 impl_->source->GetNDofs());
182 std::unique_ptr<BilinearFormIntegrator> mass_integr(
183 impl_->newBFormIntegrator());
185 if (impl_->assemble_mass_and_coupling_together)
187 impl_->mass_matrix = make_shared<SparseMatrix>(impl_->destination->GetNDofs(),
188 impl_->destination->GetNDofs());
194 double local_element_matrices_sum = 0.0;
196 long n_intersections = 0;
197 long n_candidates = 0;
201 for (
auto i_ptr : impl_->integrators)
203 max_q_order = std::max(i_ptr->GetQuadratureOrder(), max_q_order);
206 bool intersected =
false;
207 for (
auto it = begin(pairs); it != end(pairs); )
209 const int source_index = *it++;
210 const int destination_index = *it++;
212 auto &source_fe = *impl_->source->GetFE(source_index);
213 auto &destination_fe = *impl_->destination->GetFE(destination_index);
216 *impl_->destination->GetElementTransformation(destination_index);
222 const int src_order = src_order_mult * source_fe.GetOrder();
223 const int dest_order = dest_order_mult * destination_fe.GetOrder();
225 int contraction_order = src_order + dest_order;
227 if (impl_->assemble_mass_and_coupling_together)
229 contraction_order = std::max(contraction_order, 2 * dest_order);
232 const int order = contraction_order + dest_order_mult *
233 destination_Trans.
OrderW() + max_q_order;
236 cut->SetIntegrationOrder(order);
240 if (cut->BuildQuadrature(*impl_->source, source_index, *impl_->destination,
241 destination_index, source_ir, destination_ir))
243 impl_->source->GetElementVDofs(source_index, source_vdofs);
244 impl_->destination->GetElementVDofs(destination_index, destination_vdofs);
247 *impl_->source->GetElementTransformation(source_index);
250 for (
auto i_ptr : impl_->integrators)
254 i_ptr->AssembleElementMatrix(source_fe, source_ir, source_Trans,
255 destination_fe, destination_ir,
256 destination_Trans, cumulative_elemmat);
261 i_ptr->AssembleElementMatrix(source_fe, source_ir, source_Trans,
262 destination_fe, destination_ir,
263 destination_Trans, elemmat);
264 cumulative_elemmat += elemmat;
268 local_element_matrices_sum += Sum(cumulative_elemmat);
270 B->AddSubMatrix(destination_vdofs, source_vdofs, cumulative_elemmat,
273 if (impl_->assemble_mass_and_coupling_together)
275 mass_integr->SetIntRule(&destination_ir);
276 mass_integr->AssembleElementMatrix(destination_fe, destination_Trans, elemmat);
277 impl_->mass_matrix->AddSubMatrix(destination_vdofs, destination_vdofs, elemmat,
293 if (impl_->assemble_mass_and_coupling_together)
295 impl_->mass_matrix->Finalize();
300 mfem::out <<
"local_element_matrices_sum: " << local_element_matrices_sum
302 mfem::out <<
"B in R^(" << B->Height() <<
" x " << B->Width() <<
")"
305 mfem::out <<
"n_intersections: " << n_intersections
306 <<
", n_candidates: " << n_candidates <<
'\n';