On 3/25/24 09:13, Tim hyvärinen wrote:

Let's say we have a 3-components vector-valued unknown. Geometry domain is  2 * 2 * 2 size cube.  I want to set Dofs, which are inside ball x^2+y^2+z^2=1,  to be  (1, 1, 1) at every vertex. While the rest of Dofs of the cube to be (1,0,0) at very vertex.

I went through docs of DoFHandler,  DoFTools, ComponentMask and CellAccessor. Unfortunately, I only figured out that I can access certain DoFs in solution vector by loop over IndexSet, which is generated by DoFTools::extract_dofs(DofHandler., ComponentMask). I still no idea how to control the access through geometric information i.g., vertex's coordinates.

Tim:
you need to turn the problem around. You're *first* trying to partition your DoFs into ones inside/outside the sphere and in a *second* step for each element of the set assign them a value. Instead, combine the steps: think of it as a loop over all DoFs and for each you determine whether it is inside or outside the sphere, and assign a value.

In practice, the way to do this is to call
  VectorTools::interpolate()
with a function object that will look like this:

  class StartingValues : public Function<dim>
  {
    double vector_value (const Point<dim> &p) {
      if (p inside sphere)
        return 1,1,1
      else
        return 1,0,0
    }
  };

Best
 W.

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/79952735-7cbb-483d-bb3d-3815e1ec9e0c%40colostate.edu.

Reply via email to