Applying multiple in-homogeneous Dirichlet boundary condition

28 views
Skip to first unread message

Mohammad Amir Kiani Fordoei

unread,
Jun 7, 2023, 11:55:15 AM6/7/23
to deal.II User Group
Hello
I am trying to extend step-18 to a runtime program.
To this end, I generate a triangulation made of several generate_from_name_and_arguments and merged them.
then I assigned locus of various boundary id to that merged triangulation (obviously only at-boundary faces).
Now I would like to apply non-homogeneous Dirichlet boundary values to each boundary id through looping over boundary ids and using VectorTools::interpolate_boundary_values.
As follow:

for (unsigned int i=0;i<=Number_of_DBC;i++)
{
VectorTools::interpolate_boundary_values(
dof_handler,
i,
IncrementalBoundaryValues<dim>(present_time, present_timestep),
boundary_values);
}

And modifying IncrementalBoundaryValues<dim>::vector_value to this:

template <int dim>
void
IncrementalBoundaryValues<dim>::vector_value(const Point<dim> & /*p*/,
Vector<double> &values) const
{
AssertDimension(values.size(), dim);
std::vector<double> Displacement_Magnitude_Factor (3,0);
for (int k=0;k<3;k++)
{
double disp_mag_factor;
std::cout<< "Please Enter component "<<k+1<<" of Displacement Magnitude Factor for Boundary id= "
//<< boundary_id
<<std::endl;
std::cin>> disp_mag_factor;

Displacement_Magnitude_Factor[k]=disp_mag_factor;
}

values (0)=Displacement_Magnitude_Factor[0] * present_timestep * velocity;

values (1)=Displacement_Magnitude_Factor[1]*present_timestep * velocity;

values (2)=Displacement_Magnitude_Factor[2]*present_timestep * velocity; }

But it seems that my program enter an infinite loop.
In summary, how I can set non-homogeneous Dirichlet boundary condition with user-defined vector <dim> during runtime?
I'm stuck in this part. unfortunately compiler does not alert any problem. I tried to find a solution on group but I couldn't find anything in this matter.
Only this seems similar to my problem: https://groups.google.com/g/dealii/c/YFEhCYA5gsY/m/q7ZT5IKZ5owJ
But, unfortunately I couldn't understand.
I would appreciate any help.

Wolfgang Bangerth

unread,
Jun 7, 2023, 1:20:25 PM6/7/23
to dea...@googlegroups.com
On 6/7/23 09:55, Mohammad Amir Kiani Fordoei wrote:
>
> template <int dim>
> void
> IncrementalBoundaryValues<dim>::vector_value(const Point<dim> & /*p*/,
> Vector<double> &values) const
> {
> AssertDimension(values.size(), dim);
> std::vector<double> Displacement_Magnitude_Factor (3,0);
> for (int k=0;k<3;k++)
> {
> double disp_mag_factor;
> std::cout<< "Please Enter component "<<k+1<<" of Displacement Magnitude Factor
> for Boundary id= "
> //<< boundary_id
> <<std::endl;
> std::cin>> disp_mag_factor;
>
> Displacement_Magnitude_Factor[k]=disp_mag_factor;
> }
>
> values (0)=Displacement_Magnitude_Factor[0] * present_timestep * velocity;
>
> values (1)=Displacement_Magnitude_Factor[1]*present_timestep * velocity;
>
> values (2)=Displacement_Magnitude_Factor[2]*present_timestep * velocity; }
>
> But it seems that my program enter an infinite loop.

I bet that's not actually true. It just so happens that
interpolate_boundary_values() wants to know the values of the
IncrementalBoundary function *at a lot of points*. You can output which point
that is in the prompt where you print to std::cout -- these points will be
different. You just ran out of patience entering numbers via std::cin :-)

You just need a better design where you don't have to enter numbers for every
single evaluation point.

Best
W.

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


Reply all
Reply to author
Forward
0 new messages