How to Set Two Constraints on A Single dof Index on Boundaries? (P=0 and \delta P = 0)

43 views
Skip to first unread message

Lex Lee

unread,
Jul 22, 2024, 9:55:30 AM7/22/24
to deal.II User Group
Hello Deal.ii Friends,

I want to set 2 constraints (P = 0 and \delta P = 0) on the scalar pressure variable on a single point (4, 0.1) at the outlet. Here, \delta P is the Newton's iteration update value for P.

I used "constraints_hp_nonzero" to interpolate the real boundary values for my physical problem and "constraints_newton_boundary" to interpolate the Newton updates values on the boundaries.

I found that one can only set one type of constraint on a singel index. Therefore, the following snippet code would generate errors, since I was trying to set 2 different constraints simultaneously on the same dof index. 

Point<dim> point(4.0, 0.1);
std::set<unsigned int> constrained_dofs;
const unsigned int pressure_component = extractor_stokes_pressure.component;
                    for (const auto &cell : dof_handler.active_cell_iterators())
                    {
                        if (cell->is_locally_owned() )
                        {
                            for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
                            {
                                if (cell->vertex(v).distance(point) < 1e-8)
                                {
                                    // get the index 
                                    unsigned int dof_index = cell->vertex_dof_index(v,
                                                                                    pressure_component);

                                    if (constrained_dofs.find(dof_index) == constrained_dofs.end())
                                    {
                                        pcout << "index" << dof_index << std::endl;
                                        //constraints_newton_boundary.add_line(dof_index);
                                       
                                        constraints_hp_nonzero.add_line(dof_index);
                                        constrained_dofs.insert(dof_index);
                                    }
                                }
                            }
                        }
                    }

Back to my problem. 

If I want to successfully impose the 2 constraints: P=0  and delta P=0 on point (4,0.1), does it exist a better way? Could you kindly give me some hints?


I appreciate any reply to my question here. 


Regards,
Lee

Wolfgang Bangerth

unread,
Jul 22, 2024, 1:56:21 PM7/22/24
to dea...@googlegroups.com

Lee:

> I want to set 2 constraints (P = 0 and \delta P = 0) on the scalar pressure
> variable on a single point (4, 0.1) at the outlet. Here, \delta P is the
> Newton's iteration update value for P.
>
> I used "constraints_hp_nonzero" to interpolate the real boundary values for my
> physical problem and "constraints_newton_boundary" to interpolate the Newton
> updates values on the boundaries.
>
> I found that one can only set one type of constraint on a singel index.
> Therefore, the following snippet code would generate errors, since I was
> trying to set 2 different constraints simultaneously on the same dof index.

What specifically is the error you get?

I must admit that I don't quite seem to understand what it is you are doing.
If you have a nonlinear (Newton) iteration, you are only solving for either P
or delta P at any given time. Specifically, I imagine that you are first
interpolating an initial guess (where you should apply the constraint for P)
and then you are only solving for updates (where you should apply the
constraint for delta P). You are not (or you *should* not be) applying two
constraints at the same time for the same DoF, but these two constraints apply
to entirely separate variables. In other words, without understanding what
your overall algorithm is, I can't...

> If I want to successfully impose the 2 constraints: P=0  and delta P=0 on
> point (4,0.1), does it exist a better way? Could you kindly give me some hints?

...quite understand what it is you are doing and why you are getting an error.

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/


Reply all
Reply to author
Forward
0 new messages