Hi all,
I want to create a 2D domain in deal.II with an internal, curve interface $\Gamma$. A simple example of what I want to create is in the attached screenshot (credit to
Bartels, Bonito & Tscherner).
In short, does anyone have any suggestions for how to do this?
The critical thing is that upon mesh refinement, deal.II knows where my interface is and adds points accordingly (of course, this issue is already discussed in Step-1). Here, however, the 1D manifold is internal, so maybe this changes things?
What I tried so far is the following:
I have an analytic expression for my curve (i.e. it can be written in the form $(\Gamma(y), y)$), so I created two different triangulation objects using the
GridGenerator::subdivided_hyper_rectangle
and
GridTools::transform
functions. Then, I tried to merge them together. However, I am receiving an error:
"An error occurred in line <1235> of file <dealii/source/grid/grid_tools.cc> in function
void dealii::GridTools::{anonymous}::AdjacentCells<2>::push_back(const dealii::GridTools::{anonymous}::AdjacentCell&)
The violated condition was:
adjacent_cells[1].cell_index == numbers::invalid_unsigned_int"
Of course, I know that the vertices along the common interface, in this case $\Gamma$, need to be aligned. I believe that this is indeed the case.
My code is simple enough:
void grid_10()
{
const int N = 14;
// create 1st triang
Triangulation<2> tri_1;
std::vector<unsigned int> repetitions(2);
repetitions[0] = N;
repetitions[1] = N;
GridGenerator::subdivided_hyper_rectangle(tri_1,
repetitions,
Point<2>(0.0, 0.0),
Point<2>(2./3., 1.));
GridTools::transform(
[](const Point<2> &in) {
if (in[0] < 0.5)
{
return in;
}
else
{
return Point<2>(2./3. - 1./6.*std::sin(numbers::PI * in[1]), in[1]);
}
},
tri_1);
// create 2nd triang
Triangulation<2> tri_2;
repetitions[0] = N;
repetitions[1] = N;
GridGenerator::subdivided_hyper_rectangle(tri_2,
repetitions,
Point<2>(2./3., 0),
Point<2>(1., 1.));
GridTools::transform(
[](const Point<2> &in) {
if (in[0] > 0.7)
{
return in;
}
else
{
return Point<2>(2./3. - 1./6.*std::sin(numbers::PI * in[1]), in[1]);
}
},
tri_2);
// merge them
Triangulation<2> triangulation;
GridGenerator::merge_triangulations(tri_1,tri_2,triangulation);
print_mesh_info(triangulation, "grid.vtu");
}
Is there an obvious error that I am missing?
Even more critically, will this even accomplish what I want? I see in the "merge_triangulations" documentation that " In particular, manifolds attached to the two input triangulations will be lost in the result triangulation."
Any help is greatly appreciated. Thank you!
Best regards,
-Sean