Re: [deal.II] VectorTools::interpolate_boundary_values doesn't work for DG

2023-03-13 Thread Abbas
Thank you Prof. Bangerth. 
I am always greatfull for your input. 
On Friday, March 10, 2023 at 10:27:49 PM UTC+1 Wolfgang Bangerth wrote:

> On 3/8/23 07:49, Abbas wrote:
> > 
> > I am solving a nonlinear problem with DG and my BCs are in the weak 
> form. It 
> > would be helpful if I start with a solution vector that is closer to the 
> > prescribed solution so I won't have to do iterations otherwise would 
> have been 
> > unnecessary.
> > For a purely linear problem, I need to do two non_linear iterations to 
> > converge instead of 1.
> > If I can't use VectorTools::interpolate_boundary_values what are my 
> options? 
> > Does VectorTools::project_boundary_values work in that case?
>
> No, it also needs to know which DoFs are located on the boundary, but for 
> DG 
> elements no DoFs are logically on the boundary.
>
> I don't see a good solution to your problem that uses what's already in 
> the 
> library. I imagine that using code similar to what's in 
> interpolate_boundary_values() but using a different way of finding out 
> which 
> DoF's support point is physically (though not logically) located on the 
> boundary, this all could be implemented in 200 lines of code. But there is 
> nothing simple the obvious already provides you for this case.
>
> Best
> W.
>
> -- 
> 
> Wolfgang Bangerth email: bang...@colostate.edu
> www: http://www.math.colostate.edu/~bangerth/
>
>
>

-- 
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/4334127b-3826-404a-b4e4-8180b0def2b5n%40googlegroups.com.


Re: [deal.II] VectorTools::interpolate_boundary_values doesn't work for DG

2023-03-10 Thread Wolfgang Bangerth

On 3/8/23 07:49, Abbas wrote:


I am solving a nonlinear problem with DG and my BCs are in the weak form. It 
would be helpful if I start with a solution vector that is closer to the 
prescribed solution so I won't have to do iterations otherwise would have been 
unnecessary.
For a purely linear problem, I need to do two non_linear iterations to 
converge instead of 1.
If I can't use VectorTools::interpolate_boundary_values what are my options? 
Does VectorTools::project_boundary_values work in that case?


No, it also needs to know which DoFs are located on the boundary, but for DG 
elements no DoFs are logically on the boundary.


I don't see a good solution to your problem that uses what's already in the 
library. I imagine that using code similar to what's in 
interpolate_boundary_values() but using a different way of finding out which 
DoF's support point is physically (though not logically) located on the 
boundary, this all could be implemented in 200 lines of code. But there is 
nothing simple the obvious already provides you for this case.


Best
 W.

--

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


--
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/75e595c3-deba-c1e6-5cb4-9b6fb964d7b5%40colostate.edu.


Re: [deal.II] VectorTools::interpolate_boundary_values doesn't work for DG

2023-03-08 Thread Abbas
I would still want to initialise my solution vector to the values which are 
prescribed at the boundary before solving.   
Context: 
I am solving a nonlinear problem with DG and my BCs are in the weak form. 
It would be helpful if I start with a solution vector that is closer to the 
prescribed solution so I won't have to do iterations otherwise would have 
been unnecessary.
For a purely linear problem, I need to do two non_linear iterations to 
converge instead of 1. 
If I can't use VectorTools::interpolate_boundary_values what are my 
options? Does VectorTools::project_boundary_values work in that case? 

On Friday, January 6, 2023 at 7:29:17 PM UTC+1 Wolfgang Bangerth wrote:

>
> > It's cool how dealii is consitent with the maths.
> > Maybe @Wolfgang would agree that this should have thrown an exception in 
> Debug?
>
> In principle yes, but I don't know how to write such an assertion given 
> the 
> generality of the function (for the hp and non-hp case, and when selecting 
> only a subset of vector components). I will see if I can at least add 
> assertions for some simple cases.
>
> Best
> W.
>
> -- 
> 
> Wolfgang Bangerth email: bang...@colostate.edu
> www: http://www.math.colostate.edu/~bangerth/
>
>
>

-- 
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/582227f6-425d-4a06-acbc-5db23dcea79bn%40googlegroups.com.


Re: [deal.II] VectorTools::interpolate_boundary_values doesn't work for DG

2023-01-06 Thread Wolfgang Bangerth




It's cool how dealii is consitent with the maths.
Maybe @Wolfgang would agree that this should have thrown an exception in Debug?


In principle yes, but I don't know how to write such an assertion given the 
generality of the function (for the hp and non-hp case, and when selecting 
only a subset of vector components). I will see if I can at least add 
assertions for some simple cases.


Best
 W.

--

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


--
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/ff359e04-49a6-3472-ff3f-cdd4712391e9%40colostate.edu.


Re: [deal.II] VectorTools::interpolate_boundary_values doesn't work for DG

2023-01-04 Thread Abbas
Thank you Daniel. 

I was using penalties before taking this route, because I had artifacts at 
the boundary faces present at a corner between a Dirichlet and a Neuman BC 
edge. A problem I didn't have with CG.  My first intuition was to apply BCs 
strongly to fix this, but I don't think it will even if I were able to 
interpolate. 

It's cool how dealii is consitent with the maths.
Maybe @Wolfgang would agree that this should have thrown an exception in 
Debug?

On Wednesday, January 4, 2023 at 9:31:34 PM UTC+2 d.arnd...@gmail.com wrote:

> Abbas,
>
> Yes, FE_DGQ only defines dofs in the interior of cells. Thus, trying to 
> interpolate the boundary has no effect. You would normally use penalty 
> terms to prescribe boundary values for DG methods.
>
> Best,
> Daniel
>
> On Wed, Jan 4, 2023 at 6:04 PM Abbas  wrote:
>
>> Hello, 
>>
>> The VectorTools::interpolate_boundary_values function works for 
>> interpolating fe_Q functions but not fe_DGQ . 
>> Was this meant to be the case? 
>> I attached a minimal code that illustrates this.
>>
>>
>> -- 
>> 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+un...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/dealii/0a8d1da6-e564-45de-bc3d-1f5a9d5dfad9n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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/a8f4659b-c4e8-4a3d-81fc-ed802c7bd3bcn%40googlegroups.com.


Re: [deal.II] VectorTools::interpolate_boundary_values doesn't work for DG

2023-01-04 Thread Daniel Arndt
Abbas,

Yes, FE_DGQ only defines dofs in the interior of cells. Thus, trying to
interpolate the boundary has no effect. You would normally use penalty
terms to prescribe boundary values for DG methods.

Best,
Daniel

On Wed, Jan 4, 2023 at 6:04 PM Abbas  wrote:

> Hello,
>
> The VectorTools::interpolate_boundary_values function works for
> interpolating fe_Q functions but not fe_DGQ .
> Was this meant to be the case?
> I attached a minimal code that illustrates this.
>
>
> --
> 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/0a8d1da6-e564-45de-bc3d-1f5a9d5dfad9n%40googlegroups.com
> 
> .
>

-- 
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/CAOYDWbKhorQ25J5C0YJgHLbo2qq%3Dtrb6MzdPMi%2B_n4wrfh4nOg%40mail.gmail.com.


[deal.II] VectorTools::interpolate_boundary_values doesn't work for DG

2023-01-04 Thread Abbas
Hello, 

The VectorTools::interpolate_boundary_values function works for 
interpolating fe_Q functions but not fe_DGQ . 
Was this meant to be the case? 
I attached a minimal code that illustrates this.
   

-- 
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/0a8d1da6-e564-45de-bc3d-1f5a9d5dfad9n%40googlegroups.com.
#include 
#include 

#include 
#include 

#include 
#include 

#include 
#include 
#include 

#include 
using namespace dealii;
int main()

{
// create an feq obkect and interpolate a value of 1 at boundary 0
{
Triangulation<2> tria;
GridGenerator::hyper_cube(tria, 0, 1, true);
tria.refine_global(4);
FE_Q<2> fe(1);
DoFHandler<2> dof(tria);

Vector solution;

dof.distribute_dofs(fe);
solution.reinit(dof.n_dofs());

std::map boundary_values;
VectorTools::interpolate_boundary_values(dof,
 0,
 Functions::ConstantFunction<2>(1),
 boundary_values);
for (auto &boundary_value : boundary_values)
solution(boundary_value.first) = boundary_value.second;

DataOut<2> data_out;

data_out.attach_dof_handler(dof);
data_out.add_data_vector(solution, "solution");
data_out.build_patches();

const std::string filename = "solution-feq.vtu";
std::ofstream output(filename);
data_out.write_vtu(output);
}

// Same as above but
// we create an feGQq obkect and interpolate
{
Triangulation<2> tria;
GridGenerator::hyper_cube(tria, 0, 1, true);
tria.refine_global(4);
FE_DGQ<2> fe(1); // only difference between this and the above code 
DoFHandler<2> dof(tria);

Vector solution;

dof.distribute_dofs(fe);
solution.reinit(dof.n_dofs());

std::map boundary_values;
VectorTools::interpolate_boundary_values(dof,
 0,
 Functions::ConstantFunction<2>(1),
 boundary_values);
for (auto &boundary_value : boundary_values)
solution(boundary_value.first) = boundary_value.second;

DataOut<2> data_out;

data_out.attach_dof_handler(dof);
data_out.add_data_vector(solution, "solution");
data_out.build_patches();

const std::string filename = "solution-fedgq.vtu";
std::ofstream output(filename);
data_out.write_vtu(output);
}
}