Using component mask to apply displacement boundary conditions

38 views
Skip to first unread message

Wasim Niyaz Munshi ce21d400

unread,
Sep 18, 2022, 8:51:46 AM9/18/22
to deal.II User Group
Hello everyone.

I am trying to specify x and y displacements separately in step 8 of the tutorial programs.
I am doing it as follows:

    FEValuesExtractors::Scalar u_x(0);
    FEValuesExtractors::Scalar u_y(1);

    ComponentMask u_x_mask = fe.component_mask(u_x);
    ComponentMask u_y_mask = fe.component_mask(u_y);

    std::map<types::global_dof_index,double> boundary_values;
    double u_x_values = 1.2; //x_displacment to be prescribed
    double u_y_values = 0.0; //y_displacment to be prescribed

    VectorTools::interpolate_boundary_values(dof_handler,
                                             0,
                                             Functions::ZeroFunction<dim>(dim),
                                             constraints); //imposing both u_x and u_y to be zero on boudaries with id=0
    VectorTools::interpolate_boundary_values(dof_handler,
                                                 1,
                                                 Functions::ConstantFunction<dim>(dim)(u_x_values,2),boundary_values,u_x_mask,
                                                 constraints);//imposing u_x=1 on boudaries with id=1
    VectorTools::interpolate_boundary_values(dof_handler,
                                                     1,
                                                     Functions::ConstantFunction<dim>(dim)(u_y_values,2),boundary_values,u_y_mask,
                                                     constraints);//imposing u_y=0 on boudaries with id=1

It gives the following error:
error: no matching function for call to ‘interpolate_boundary_values.
I think I am doing mistake in the arguments but I am unable to figure it out.
Can someone please help me with this? I am just getting started with deal.ii

Thank You!

Wolfgang Bangerth

unread,
Sep 18, 2022, 5:39:24 PM9/18/22
to dea...@googlegroups.com
On 9/18/22 06:51, Wasim Niyaz Munshi ce21d400 wrote:
> VectorTools::interpolate_boundary_values(dof_handler,
>                                                      1,
>  Functions::ConstantFunction<dim>(dim)(u_y_values,2),boundary_values,u_y_mask,
>                                                      constraints);

You are providing both the 'boundary_values' std::map object, and the
'constraints' AffineConstraints object. There are two versions of this
function, one for each kind, but you can only provide one of these objects to
each.

Best
W.

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

Wasim Niyaz Munshi ce21d400

unread,
Sep 19, 2022, 9:18:23 AM9/19/22
to dea...@googlegroups.com
Thank You.
I went through the documentations and realized that in step 8 Dirichlet boundary conditions are being applied using the constraint object. Hence, we only need to pass the constraint object to VectorTools::interpolate_boundary_values. No need to pass the 'boundary_values' std::map object.
I made that change as follows:
FEValuesExtractors::Scalar u_x(0);
    FEValuesExtractors::Scalar u_y(1);

    ComponentMask u_x_mask = fe.component_mask(u_x);
    ComponentMask u_y_mask = fe.component_mask(u_y);

    double u_x_values = 1.2;
    double u_y_values = 0.0;


    VectorTools::interpolate_boundary_values(dof_handler,
                                             0,
                                             Functions::ZeroFunction<dim>(dim),
                                             constraints); //imposing both u_x and u_y to be zero on boudaries with id=0
    VectorTools::interpolate_boundary_values(dof_handler,
                                                 1,
Functions::ConstantFunction<dim>(dim)(u_x_values,2),constraints,u_x_mask);
                                                 //imposing u_x=1.2 on boudaries with id=1
    VectorTools::interpolate_boundary_values(dof_handler,
                                                     1,
                                                     Functions::ConstantFunction<dim>(dim)(u_y_values,2),constraints,u_y_mask

                                                     );//imposing u_y=0 on boudaries with id=1
   
Now, it gives the following error:
error: no match for call to ‘(dealii::Functions::ConstantFunction<2, double>) (double&, int)’
 Functions::ConstantFunction<dim>(dim)(u_x_values,dim),constraints,u_x_mask);
It gives the same error for u_y also.

--
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 a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/jEO3kQ-d9Cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/408279cc-c18c-9526-8931-705ddd7c6b12%40colostate.edu.

Wolfgang Bangerth

unread,
Sep 19, 2022, 9:33:39 AM9/19/22
to dea...@googlegroups.com
On 9/19/22 07:18, Wasim Niyaz Munshi ce21d400 wrote:
> Functions::ConstantFunction<dim>(dim)(u_y_values,2),constraints,u_y_mask
>                                                      );//imposing u_y=0 on
> boudaries with id=1
> Now, it gives the following error:
> error: no match for call to ‘(dealii::Functions::ConstantFunction<2, double>)
> (double&, int)’
>  Functions::ConstantFunction<dim>(dim)(u_x_values,dim),constraints,u_x_mask);
> It gives the same error for u_y also.

This is because the syntax
Functions::ConstantFunction<dim>(dim)(u_y_values,2)
makes no sense. You need the <dim>, but not (dim).
Reply all
Reply to author
Forward
0 new messages