66 if (m_spLSF.invalid ())
return 1;
70 UG_THROW (
"LevSetGFsimpleExtrapolation: Hanging nodes are not supported.");
73 UG_ASSERT (g_level >= 0 && (
size_t) g_level < m_vGLData.size (),
"Grid level of the level-set function mismatch!");
77 m_pElem = pElem; m_si = si; m_vCornerCoords = vCornerCoords;
81 spLSF->indices (pElem, m_indLSF,
false);
82 m_locLSF.resize (m_indLSF);
89 for (
size_t co = 0; co < n_co; co++)
91 if (corner_inside (co))
103 m_elemCenter = vCornerCoords[0];
104 for (
size_t co = 1; co < n_co; co++)
105 m_elemCenter += vCornerCoords[co];
106 m_elemCenter /= (
number) n_co;
109 if (m_excl_ssg.size () != 0)
111 Grid::vertex_traits::secure_container corner_list;
112 m_excl_ssg.subset_handler()->grid()->associated_elements (corner_list, pElem);
113 if (corner_list.size () != n_co)
114 UG_THROW (
"LevSetGFsimpleExtrapolation: Hanging nodes are not supported. - Illegal number of vertices in an element.");
115 for (
size_t co = 0; co < n_co; co++)
116 m_co_excluded [co] = m_excl_ssg.contains (m_excl_ssg.subset_handler()->get_subset_index (corner_list [co]));
119 for (
size_t co = 0; co < max_num_corners; co++)
120 m_co_excluded [co] =
false;
158 for (
size_t fct = 0; fct < locU.
num_all_fct (); fct++)
160 UG_THROW (
"LevSetGFsimpleExtrapolation:"
161 " Hanging nodes are not currently supported for the ghost-fluid method");
163 for (
size_t co = 0; co < TElem::NUM_VERTICES; co++)
164 if ((! corner_inside (co)) && (! corner_excluded (co)))
166 number t = m_locLSF.value (0, co) / m_locLSF.value (0, base_co);
167 for (
size_t fct = 0; fct < locU.
num_all_fct (); fct++)
168 switch (m_vICData[fct].bc_kind)
171 locU.
value (fct, co) = locU.
value (fct, base_co) * t + boundary_value (fct) * (1 - t);
174 case DIRICHLET_PLAIN_BC:
175 locU.
value (fct, co) = boundary_value (fct);
179 locU.
value (fct, co) = locU.
value (fct, base_co);
183 UG_THROW (
"LevSetGFsimpleExtrapolation: Unknown interface condition type.");
204 if (fct < 0 || fct >= m_vICData.size ())
205 UG_THROW (
"LevSetGFsimpleExtrapolation: Wrong function index.");
207 t_fs_bc bc_kind = m_vICData[fct].bc_kind;
208 number interface_val = boundary_value (fct);
210 for (
size_t co = 0; co < num_co; co++)
211 if ((! corner_inside (co)) && (! corner_excluded (co)))
216 number t = m_locLSF.value (0, co) / m_locLSF.value (0, base_co);
217 u [co] = u [base_co] * t + interface_val * (1 - t);
221 case DIRICHLET_PLAIN_BC:
222 u [co] = interface_val;
226 u [co] = u [base_co];
230 UG_THROW (
"LevSetGFsimpleExtrapolation: Unknown interface condition type.");
249 if (fct < 0 || fct >= m_vICData.size ())
250 UG_THROW (
"LevSetGFsimpleExtrapolation: Wrong function index.");
252 t_fs_bc bc_kind = m_vICData[fct].bc_kind;
253 number interface_val = boundary_value (fct);
255 for (
size_t co = 0; co < num_co; co++)
256 if ((! corner_inside (co)) && (! corner_excluded (co)))
258 size_t n_base_co = 0;
260 for (
size_t base_co = 0; base_co < num_co; base_co++)
261 if (corner_inside (base_co))
267 number t = m_locLSF.value (0, co) / m_locLSF.value (0, base_co);
268 u [co] += u [base_co] * t + interface_val * (1 - t);
272 case DIRICHLET_PLAIN_BC:
273 u [co] += interface_val;
277 u [co] += u [base_co];
281 UG_THROW (
"LevSetGFsimpleExtrapolation: Unknown interface condition type.");
285 UG_ASSERT (n_base_co != 0,
"LevSetGFsimpleExtrapolation:"
286 "Attempt to interpolate in an element that is not cut.");
323 for (
size_t co = 0; co < TElem::NUM_VERTICES; co++)
324 if ((! corner_inside (co)) && (! corner_excluded (co)))
326 number t = m_locLSF.value (0, co) / m_locLSF.value (0, base_co);
330 number & a_ij = locM.
value (row_fct, base_co, col_fct, co);
331 switch (m_vICData[col_fct].bc_kind)
334 locM.
value (row_fct, base_co, col_fct, base_co) += a_ij * t;
337 case DIRICHLET_PLAIN_BC:
342 locM.
value (row_fct, base_co, col_fct, base_co) += a_ij;
346 UG_THROW (
"LevSetGFsimpleExtrapolation: Unknown interface condition type.");
353 for (
size_t row_co = 0; row_co < TElem::NUM_VERTICES; row_co++)
354 if (row_co != base_co)
355 for (
size_t col_co = 0; col_co < TElem::NUM_VERTICES; col_co++)
358 locM.
value (row_fct, row_co, col_fct, col_co) = 0;
378 for (
size_t co = 0; co < TElem::NUM_VERTICES; co++)
379 if ((! corner_inside (co)) && (! corner_excluded (co)))
381 number t = m_locLSF.value (0, co) / m_locLSF.value (0, base_co);
385 number & a_ij = locM.
value (row_fct, base_co, col_fct, co);
386 switch (m_vICData[col_fct].bc_kind)
389 locM.
value (row_fct, base_co, col_fct, base_co) += a_ij * t;
390 locB.
value (row_fct, base_co) -= a_ij * boundary_value (col_fct) * (1 - t);
393 case DIRICHLET_PLAIN_BC:
394 locB.
value (row_fct, base_co) -= a_ij * boundary_value (col_fct);
398 locM.
value (row_fct, base_co, col_fct, base_co) += a_ij;
402 UG_THROW (
"LevSetGFsimpleExtrapolation: Unknown interface condition type.");
409 for (
size_t row_co = 0; row_co < TElem::NUM_VERTICES; row_co++)
410 if (row_co != base_co)
413 locB.
value (row_fct, row_co) = 0;
414 for (
size_t col_co = 0; col_co < TElem::NUM_VERTICES; col_co++)
416 locM.
value (row_fct, row_co, col_fct, col_co) = 0;
438 for (
size_t base_co = 0; base_co < TElem::NUM_VERTICES; base_co++)
439 if (corner_inside (base_co))
440 for (
size_t co = 0; co < TElem::NUM_VERTICES; co++)
441 if ((! corner_inside (co)) && (! corner_excluded (co)))
443 number t = m_locLSF.value (0, co) / m_locLSF.value (0, base_co);
447 number & a_ij = locM.
value (row_fct, base_co, col_fct, co);
448 switch (m_vICData[col_fct].bc_kind)
451 locM.
value (row_fct, base_co, col_fct, base_co) += a_ij * t;
452 locB.
value (row_fct, base_co) -= a_ij * boundary_value (col_fct) * (1 - t);
455 case DIRICHLET_PLAIN_BC:
456 locB.
value (row_fct, base_co) -= a_ij * boundary_value (col_fct);
460 locM.
value (row_fct, base_co, col_fct, base_co) += a_ij;
464 UG_THROW (
"LevSetGFsimpleExtrapolation: Unknown interface condition type.");
471 for (
size_t row_co = 0; row_co < TElem::NUM_VERTICES; row_co++)
472 if (! corner_inside (row_co))
475 locB.
value (row_fct, row_co) = 0;
476 for (
size_t col_co = 0; col_co < TElem::NUM_VERTICES; col_co++)
478 locM.
value (row_fct, row_co, col_fct, col_co) = 0;
489 m_vGLData.resize (0);
490 if (! m_spLSF.valid ())
return;
492 int finest_lev = m_spLSF->grid_level().level ();
497 finest_lev = approx_space->num_levels () - 1;
498 UG_ASSERT (finest_lev >= 0,
"Wrong finest grid level!");
501 m_vGLData.resize (finest_lev + 1);
502 m_vGLData[finest_lev].lsf_on_gl = m_spLSF;
503 m_vGLData[finest_lev].inject =
SPNULL;
506 for (
int fine_lev = finest_lev; fine_lev > 0; fine_lev--)
508 int coarse_lev = fine_lev - 1;
510 GridLevel coarse_gl (coarse_lev, view_type);
515 m_vGLData[coarse_lev].inject->set_levels (coarse_gl, fine_gl);
516 m_vGLData[coarse_lev].inject->init ();
545 if (m_spLSF.invalid ())
return;
551 if (level < 0 || (
size_t) level >= m_vGLData.size ())
552 UG_THROW (
"Attempt to assemble on a grid level where the LSF is undefined.");
556 std::vector<size_t> vLSFVertInd (1);
557 std::vector<size_t> vDefVertInd;
560 t_vert_iterator iter = dd->template begin<Vertex> ();
561 t_vert_iterator iterEnd = dd->template end<Vertex> ();
562 for (; iter != iterEnd; iter++)
567 if (m_excl_ssg.size () != 0 && m_excl_ssg.contains (m_excl_ssg.subset_handler()->get_subset_index (pVertex)))
571 if (spLSF->inner_algebra_indices (pVertex, vLSFVertInd) != 1)
572 UG_THROW (
"LevSetGFsimpleExtrapolation: Non-scalar Level-Set Function.");
573 if (lsf_inside (
BlockRef ((* spLSF) [vLSFVertInd[0]], 0)))
578 for (
size_t dof = 0; dof < n_dofs; dof++)
579 d [vDefVertInd[dof]] = 0;
597 if (m_spLSF.invalid ())
return;
603 if (level < 0 || (
size_t) level >= m_vGLData.size ())
604 UG_THROW (
"LevSetGFsimpleExtrapolation: Attempt to assemble on a grid level where the LSF is undefined.");
607 std::vector<size_t> vLSFVertInd (1);
608 std::vector<DoFIndex> multInd (1);
613 grid.attach_to_vertices (aBC);
614 grid.attach_to_vertices (aNumElem);
620 for (
size_t fct = 0; fct < dd->
num_fct (); fct++)
623 t_vert_iterator iter = dd->template begin<Vertex> ();
624 t_vert_iterator iterEnd = dd->template end<Vertex> ();
625 for (; iter != iterEnd; iter++)
629 aaNumElem [pVertex] = 0;
633 boost::mpl::for_each<AssembleElemList> (
SumUpNearIfOuterValues (
this, u, fct, dd, time, aaBC, aaNumElem));
647 if (m_excl_ssg.size () != 0 && m_excl_ssg.contains (si))
651 t_vert_iterator iter = dd->template begin<Vertex> (si);
652 t_vert_iterator iterEnd = dd->template end<Vertex> (si);
653 for (; iter != iterEnd; iter++)
658 if (spLSF->inner_algebra_indices (pVertex, vLSFVertInd) != 1)
659 UG_THROW (
"LevSetGFsimpleExtrapolation: Non-scalar Level-Set Function.");
660 if (lsf_inside (
BlockRef ((* spLSF) [vLSFVertInd[0]], 0)))
664 UG_THROW (
"LevSetGFsimpleExtrapolation: More than one DoF per vertex for a component. Not the Lagrange element?");
666 const uint nElem = aaNumElem [pVertex];
669 const number bcVal = aaBC [pVertex];
670 DoFRef (u, multInd[0]) = bcVal / nElem;
673 DoFRef (u, multInd[0]) = 0;
678 grid.detach_from_vertices (aNumElem);
679 grid.detach_from_vertices (aBC);
709 std::vector<DoFIndex> multInd (1);
712 t_elem_iterator iterEnd = dd->template end<TElem> (si);
713 for (t_elem_iterator iter = dd->template begin<TElem> (si); iter != iterEnd; iter++)
715 TElem * pElem = *iter;
718 Vertex * vVertex [TElem::NUM_VERTICES];
720 for (
size_t co = 0; co < TElem::NUM_VERTICES; co++)
721 vCornerCoords[co] = aaPos[vVertex[co] = pElem->vertex (co)];
725 (TElem::NUM_VERTICES, pElem, si, level,
false, vCornerCoords, time) != 0)
729 number vValue [TElem::NUM_VERTICES];
732 for (
size_t co = 0; co < TElem::NUM_VERTICES; co++)
735 UG_THROW (
"LevSetGFsimpleExtrapolation: More than one DoF per vertex for a component. Not the Lagrange element?");
736 if (corner_inside (co))
737 vValue[co] =
DoFRef (u, multInd[0]);
740 extrapolate_by_lsf (TElem::NUM_VERTICES, vValue, fct);
741 for (
size_t co = 0; co < TElem::NUM_VERTICES; co++)
742 if (! corner_inside (co))
744 aaBC[vVertex[co]] += vValue[co];
745 (aaNumElem[vVertex[co]])++;
764 if (m_spLSF.invalid ())
return;
770 if (level < 0 || (
size_t) level >= m_vGLData.size ())
771 UG_THROW (
"Attempt to assemble on a grid level where the LSF is undefined.");
775 std::vector<size_t> vLSFVertInd (1);
776 std::vector<size_t> vMatVertInd;
779 t_vert_iterator iter = dd->template begin<Vertex> ();
780 t_vert_iterator iterEnd = dd->template end<Vertex> ();
781 for (; iter != iterEnd; iter++)
786 if (m_excl_ssg.size () != 0 && m_excl_ssg.contains (m_excl_ssg.subset_handler()->get_subset_index (pVertex)))
790 if (spLSF->inner_algebra_indices (pVertex, vLSFVertInd) != 1)
791 UG_THROW (
"LevSetGFsimpleExtrapolation: Non-scalar Level-Set Function.");
792 if (lsf_inside (
BlockRef ((* spLSF) [vLSFVertInd[0]], 0)))
797 for (
size_t dof = 0; dof < n_dofs; dof++)