The assignment of solution variable

36 views
Skip to first unread message

Toddy Liu

unread,
Dec 22, 2021, 4:16:00 AM12/22/21
to deal.II User Group
Dear Deal.II community,

I'm getting trouble in changing the values of my solution variable Phi. Firstly, I create a R20 circle whose center is located at the center of the square domain by using VectorTools::interpolate(dof_handler, user_defined_function, solution_Phi). After creating this circle and several program loops, the radius of this circle grows up to about 40,  as shown below, solution_Phi inside the circle is 1(denoted by red color) while outside the circle is -1(denoted by blue color). Here comes my problem, are there any practical ways to assign those solution_Phi who is located at the top half of the square domain(y>=60) to -1 while others(y<60) keep unchanged?
1.jpeg

Any suggestions or help will be appreciated!
Thank you very much.

Best, 
Toddy

Wolfgang Bangerth

unread,
Dec 22, 2021, 12:14:31 PM12/22/21
to dea...@googlegroups.com
On 12/22/21 2:15 AM, Toddy Liu wrote:
> Dear Deal.II community,
>
> I'm getting trouble in changing the values of my solution variable Phi.
> Firstly, I create a R20 circle whose center is located at the center of the
> square domain by using VectorTools::interpolate(dof_handler,
> user_defined_function, solution_Phi). After creating this circle and several
> program loops, the radius of this circle grows up to about 40,  as shown
> below, solution_Phi inside the circle is 1(denoted by red color) while outside
> the circle is -1(denoted by blue color). Here comes my problem, are there any
> practical ways to assign those solution_Phi who is located at the top half of
> the square domain(y>=60) to -1 while others(y<60) keep unchanged?

If I understand what you want to do correctly, then it isn't actually about
the circle, but you want to do something like VectorTools::interpolate but
only for degrees of freedom that satisfy a certain condition?

There isn't anything of this sort readily available in deal.II, but (as so
often) something like this can be found in ASPECT. Take a look at the ideas here:

https://github.com/geodynamics/aspect/blob/master/cookbooks/prescribed_velocity/prescribed_velocity.cc#L238-L264
This code creates constraints for individual DoFs, but you could as well just
write the corresponding values into your solution vector.

Best
W.


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

Toddy Liu

unread,
Dec 23, 2021, 8:45:16 AM12/23/21
to deal.II User Group
Professor Wolfgang,

That's exactly what I need and thank you for your help.

Best,
Toddy

Reply all
Reply to author
Forward
0 new messages