How to apply Spherical Manifold

36 צפיות
מעבר להודעה הראשונה שלא נקראה

Deepika Kushwah

לא נקראה,
20 בפבר׳ 2023, 1:08:3620.2.2023
עד dea...@googlegroups.com
Hello Everyone,

I have created a merged geometry by using subdivided_hyper_cube and two hyper_ball functions. See below 
20.png
 Now I want to apply a Spherical Manifold in place of the default manifold. I have tried the following code but it is not working for both hyper_ball simultaneously. 

 std::vector< unsigned int > repetitions(4);
  GridGenerator::subdivided_hyper_cube(tria_1, 4, -1., 1.);
 
  std::set<typename Triangulation<2>::active_cell_iterator> cells_to_remove;
 
  for (auto &cell : tria_1.active_cell_iterators())
      {
        if ((cell->center()[0] == -0.25) && (cell->center()[1] == -0.25))
        {
        cells_to_remove.insert(cell);
        }
        if ((cell->center()[0] == 0.25) && (cell->center()[1] == 0.25))
       {
        cells_to_remove.insert(cell);
       }
      }
   
  GridGenerator::create_triangulation_with_removed_cells(tria_1, cells_to_remove,tria_2);
    Point<2> center (-.25,-.25);
    GridGenerator::hyper_ball (tria_3, center, 0.354);
 
   GridGenerator::merge_triangulations (tria_2, tria_3,triangulation);
   
  Point<2> center_1 (.25,.25);
  GridGenerator::hyper_ball (tria_4, center_1, 0.354);
 
  GridGenerator::merge_triangulations (triangulation, tria_4, tri);
 

 //tri.reset_all_manifolds();
//tri.set_all_manifold_ids(0);
 
 SphericalManifold<2> manifold_neg(center);
 SphericalManifold<2> manifold_pos(center_1);
 
 tri.set_all_manifold_ids_on_boundary(0);
 tri.set_manifold (0, manifold_neg);
 tri.set_all_manifold_ids_on_boundary(0);
 tri.set_manifold (0, manifold_pos);

 
  tri.refine_global(3);

The output of the code is:
image.png

I want to apply a spherical manifold for both hyper_balls. Can you please suggest to me how I can do this? 


Thanks and Regard,
Deepika

**************************************************************************
This e-mail is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. If you are not the
intended recipient, please contact the sender by reply e-mail and destroy
all copies and the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email
is strictly prohibited and appropriate legal action will be taken.
************************************************************************************************

Luca Heltai

לא נקראה,
20 בפבר׳ 2023, 2:04:3420.2.2023
עד dea...@googlegroups.com
You should set the manifold ids of the two regions to different numbers, and add the second manifold with the second id you choose,  otherwise the second call is simply overwriting the first one, and they are both described by the last manifold. 

Luca

Il giorno 20 feb 2023, alle ore 07:08, Deepika Kushwah <deepika...@iitgoa.ac.in> ha scritto:


Hello Everyone,

I have created a merged geometry by using subdivided_hyper_cube and two hyper_ball functions. See below 
<image.png>


I want to apply a spherical manifold for both hyper_balls. Can you please suggest to me how I can do this? 


Thanks and Regard,
Deepika

**************************************************************************
This e-mail is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. If you are not the
intended recipient, please contact the sender by reply e-mail and destroy
all copies and the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email
is strictly prohibited and appropriate legal action will be taken.
************************************************************************************************

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAKTdrpps7Cs2Nbt8YeNa%3Dw1RZL8qX6msXVvOxorY-2CRPEXGDg%40mail.gmail.com.

Deepika Kushwah

לא נקראה,
20 בפבר׳ 2023, 2:36:0120.2.2023
עד dea...@googlegroups.com
Thank you for your response.

I have also tried to set the manifold ids of the two regions with two different numbers but the problem is not solved yet.
image.png
image.png
What else can I do?


Thanks,
Deepika

Luca Heltai

לא נקראה,
20 בפבר׳ 2023, 3:30:1020.2.2023
עד Deal.II Users
At the moment, you are setting the manifold ID on the boundary of your *domain* with the call to


tri.set_all_manifold_ids_on_bounary(4);
tri.set_manifold (4, manifold_neg);

And then you are telling the triangulation to use on it the SphericalManifold<2> manifold_neg(center).
Then you re-do the same thing (i.e., you define all boundaries *of the triangulation*) with the other id (5), and again set another manifold


tri.set_all_manifold_ids_on_bounary(5);
tri.set_manifold (5, manifold_neg);

The effect of this is: your domain *boundary* now has id 5, and in fact the faces of the boundary, upon refinement try to refine according to polar coordinates around the center of `manifold_neg`.

what you really want to do is to identify the regions you want to behave like manifold_neg (NOT the domain boundary, so the call to tri.set_all_manifold_ids_on_bounary should not be there).

in your first picture, identify the cells that belong to id 4:

for cell in first region:
cell->set_all_boundary_ids(4);

then do the same with the second region:

for cell in first region:
cell->set_all_boundary_ids(5);

and at this point instruct the triangulation that those two different region, follow different manifold rules:

tri.set_manifold (4, manifold_neg);
tri.set_manifold (5, manifold_pos);

The logic here is this one:

1. identify what region is described by what manifold (cell, face, line, etc. ->set_manifold_id(…)) using an identification (a manifold id)
2. tell the triangulation that the region identified by the chosen manifold id must obey the given manifold description (tria.set_manifold(manifold_id, manifold_object)

You are doing this with the boundary of the domain (that has nothing to do with the regions you colored differently), and you are assigning *the same id* to the two regions, so the triangulation does what you asked for: it uses only one descriptor (because the other id is not present in the triangulation), and it uses it in both regions *and* on the boundary.

L.




> On 20 Feb 2023, at 8:35, Deepika Kushwah <deepika...@iitgoa.ac.in> wrote:
>
> Thank you for your response.
>
> I have also tried to set the manifold ids of the two regions with two different numbers but the problem is not solved yet.
> <image.png>
> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAKTdrprySqN1-Q3jW%3DQtX1vr5wE%3D4whp%3Dh_kRs7mWmWqzv9xFg%40mail.gmail.com.

Deepika Kushwah

לא נקראה,
20 בפבר׳ 2023, 22:37:1920.2.2023
עד dea...@googlegroups.com
Thank you very much sir for your explanation.

I have assigned material id to different domains. Now I am trying to set spherical manifold id by using the following code

 
  for (const auto &cell : tri.cell_iterators())
   {
     double v = (cell->center()[0])*(cell->center()[1]) ;
       
      if ((cell->center()[0] > -0.5) && (cell->center()[1] > -0.5) && (cell->center()[0] < 0.5) && (cell->center()[1] < 0.5) && v>0)
      {
     cell->set_material_id(15);
      }
     
     else
     {
     cell->set_material_id(20);
     }
  }
 
     for (auto &cell : tri.active_cell_iterators())
      {
        if ((cell->center()[0] == -0.25) && (cell->center()[1] == -0.25) && cell->material_id() == 15)
        {
       cell->set_all_manifold_ids(10);
        }
       if ((cell->center()[0] == 0.25) && (cell->center()[1] == 0.25) && cell->material_id() == 15)
        {
       cell->set_all_manifold_ids(12);
        }
     }  

 tri.reset_all_manifolds();
//tri.set_all_manifold_ids(0);
 
 
const SphericalManifold<2> manifold_neg(center);
 //tri.set_all_manifold_ids_on_boundary(10);
  tri.set_manifold (10, manifold_neg);
 
//tri.set_all_manifold_ids_on_boundary(12);
const  SphericalManifold<2> manifold_pos(center_1);
 tri.set_manifold (12, manifold_pos);
 
 tri.refine_global(3);

but it is showing the following error:
image.png

I am not understanding the meaning of this, can you please elaborate it. 


Thanks 
Deepika

Daniel Arndt

לא נקראה,
21 בפבר׳ 2023, 10:12:3221.2.2023
עד dea...@googlegroups.com
Deepika,

By default, the manifold_id is set to 0 on the boundary faces, 1 on the boundary cells, and numbers::flat_manifold_id on the central cell and on internal faces. A SphericalManifold is attached by default to the boundary faces for correct placement of boundary vertices upon refinement and to be able to use higher-order mappings.

It seems that you are trying to assign a SphericalManifold object to the central cell. This doesn't work properly because the manifold is singular at the center. Instead, you should only assign it to the boundary cells of the hyper ball parts of your triangulation. If the mesh doesn't look good enough after refining, you also might want to have a look at https://www.dealii.org/current/doxygen/deal.II/classTransfiniteInterpolationManifold.html and https://www.dealii.org/current/doxygen/deal.II/step_65.html.

Best,
Daniel



Deepika Kushwah

לא נקראה,
22 בפבר׳ 2023, 3:07:4422.2.2023
עד dea...@googlegroups.com
Thank you so much.

Now it is working fine. :-)



Thanks & Regards,
Deepika

השב לכולם
השב למחבר
העבר לנמענים
0 הודעות חדשות