Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-29 Thread Wolfgang Bangerth
On 4/29/19 2:34 AM, Muhammad Mashhood wrote:
> Thank you professor for your concern. No I am currently not using the 
> debug mode

Then there is no point in continuing this discussion until you try in 
debug mode.

I have often made the point (and will make it again here) that a program 
that you have not tested in debug mode is likely going to produce wrong 
output. Nobody knows what your program does -- and 'nobody' includes 
'you' -- if you don't test it in debug mode.

Best
  Wolfgang

-- 

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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-29 Thread Muhammad Mashhood
Thank you professor for your concern. No I am currently not using the debug 
mode rather running it normally using the build targets technique you 
mentioned in tutorials for eclipse. Although it is not producing the error 
but which ever matrix I give to this function to write boundary rhs terms, 
it does not modify it or give the output in that vector. e.g. If i give 
"tmp" as zeros or non zeros entry vector as argument it still remains the 
same before and after running the function.  

On Saturday, April 27, 2019 at 5:26:03 AM UTC+2, Wolfgang Bangerth wrote:
>
> On 4/26/19 3:42 AM, Muhammad Mashhood wrote: 
> > Thank you Prof. Bangerth for the correction that was quit helping. 
> Currently 
> > the code started running but unfortunately the function is returning 
> with the 
> > zero "tmp" vector. Any possible correction? 
>
> Hm, I wonder if it is even implemented in the 1d case. Looking into the 
> deal.II source files, I can't see how your program actually runs without 
> producing an error. Are you using debug mode? 
>
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-26 Thread Wolfgang Bangerth
On 4/26/19 3:42 AM, Muhammad Mashhood wrote:
> Thank you Prof. Bangerth for the correction that was quit helping. Currently 
> the code started running but unfortunately the function is returning with the 
> zero "tmp" vector. Any possible correction?

Hm, I wonder if it is even implemented in the 1d case. Looking into the 
deal.II source files, I can't see how your program actually runs without 
producing an error. Are you using debug mode?

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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-26 Thread Muhammad Mashhood
It seems that "tmp" vector stays unchanged i.e. function is seemingly not 
assigning any face rhs values to "tmp" vector. 

On Friday, April 26, 2019 at 11:42:09 AM UTC+2, Muhammad Mashhood wrote:
>
> Thank you Prof. Bangerth for the correction that was quit helping. 
> Currently the code started running but unfortunately the function is 
> returning with the zero "tmp" vector. Any possible correction? 
>
>
>
>
>
>
> *tmp.reinit (solution.size());
> VectorTools::create_boundary_right_hand_side(dof_handler,  
>  QGauss(fe.degree+1),
> 
>  ConstantFunction(1), 
>  tmp);*
>
> Currently I also did not specify the id of the node where I want to 
> impose  "*ConstantFunction(1)*" value 1 supposing that the "
> *create_boundary_right_hand_side*" will apply it itself on both ends when 
> ids not specified explicitly. 
>
> On Thursday, April 25, 2019 at 8:49:04 PM UTC+2, Wolfgang Bangerth wrote:
>>
>> On 4/25/19 9:46 AM, Muhammad Mashhood wrote: 
>> > 
>> > As unlike the step-8 here in step-26 the rhs is being formed directly 
>> > globally as "system_rhs" using "create_right_hand_side()" function so 
>> > can I use the "create_boundary_right_hand_side()" function using 
>> > following lines of code? 
>>
>> It is definitely possible to *add* to the vector you get from 
>> create_boundary_rhs(). But in this call... 
>>
>> > / 
>> > / 
>> > /std::map::iterator 
>> > it=boundary_count.begin(); 
>> > 
>> >  VectorTools::create_boundary_right_hand_side(dof_handler, 
>> >   
>> >   QGauss(fe.degree+1), 
>> >   rhs_function, 
>> >   tmp,/ 
>> > / it->first);/ 
>> > where the "rhs_function" provides the values of /g0/ and /g1 /at 
>> > boundary node points and "it->first" is the boundary id where I want to 
>> > apply the BC. 
>>
>> ...you are asked to pass in a Quadrature, not a Quadrature. 
>> Consequently, the code does not compile. This is actually stated quite 
>> explicitly in the second part of the error message: 
>>
>> dealii::VectorTools::create_boundary_right_hand_side(const 
>> dealii::DoFHandler&, const dealii::Quadrature<(dim - 
>> 1)>&, const dealii::Function> VectorType::value_type>&, VectorType&, const std::set&) 
>> [with int dim = 1; int spacedim = 1; VectorType = 
>> dealii::Vector; typename VectorType::value_type = double] 
>> void create_boundary_right_hand_side 
>>  ^ 
>> /usr/local/include/deal.II/numerics/vector_tools.h:2105:8: note:   no 
>> known conversion for argument 2 from ‘dealii::QGauss<1>’ to ‘const 
>> dealii::Quadrature<0>&’ 
>>
>>
>> Best 
>>   WB 
>>
>> -- 
>>  
>> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-26 Thread Muhammad Mashhood
Thank you Prof. Bangerth for the correction that was quit helping. 
Currently the code started running but unfortunately the function is 
returning with the zero "tmp" vector. Any possible correction? 






*tmp.reinit (solution.size());
VectorTools::create_boundary_right_hand_side(dof_handler,  
 QGauss(fe.degree+1),

 ConstantFunction(1), 
 tmp);*

Currently I also did not specify the id of the node where I want to impose  
"*ConstantFunction(1)*" value 1 supposing that the "
*create_boundary_right_hand_side*" will apply it itself on both ends when 
ids not specified explicitly. 

On Thursday, April 25, 2019 at 8:49:04 PM UTC+2, Wolfgang Bangerth wrote:
>
> On 4/25/19 9:46 AM, Muhammad Mashhood wrote: 
> > 
> > As unlike the step-8 here in step-26 the rhs is being formed directly 
> > globally as "system_rhs" using "create_right_hand_side()" function so 
> > can I use the "create_boundary_right_hand_side()" function using 
> > following lines of code? 
>
> It is definitely possible to *add* to the vector you get from 
> create_boundary_rhs(). But in this call... 
>
> > / 
> > / 
> > /std::map::iterator 
> > it=boundary_count.begin(); 
> > 
> >  VectorTools::create_boundary_right_hand_side(dof_handler, 
> >   
> >   QGauss(fe.degree+1), 
> >   rhs_function, 
> >   tmp,/ 
> > / it->first);/ 
> > where the "rhs_function" provides the values of /g0/ and /g1 /at 
> > boundary node points and "it->first" is the boundary id where I want to 
> > apply the BC. 
>
> ...you are asked to pass in a Quadrature, not a Quadrature. 
> Consequently, the code does not compile. This is actually stated quite 
> explicitly in the second part of the error message: 
>
> dealii::VectorTools::create_boundary_right_hand_side(const 
> dealii::DoFHandler&, const dealii::Quadrature<(dim - 
> 1)>&, const dealii::Function VectorType::value_type>&, VectorType&, const std::set&) 
> [with int dim = 1; int spacedim = 1; VectorType = 
> dealii::Vector; typename VectorType::value_type = double] 
> void create_boundary_right_hand_side 
>  ^ 
> /usr/local/include/deal.II/numerics/vector_tools.h:2105:8: note:   no 
> known conversion for argument 2 from ‘dealii::QGauss<1>’ to ‘const 
> dealii::Quadrature<0>&’ 
>
>
> Best 
>   WB 
>
> -- 
>  
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-25 Thread Wolfgang Bangerth
On 4/25/19 9:46 AM, Muhammad Mashhood wrote:
> 
> As unlike the step-8 here in step-26 the rhs is being formed directly 
> globally as "system_rhs" using "create_right_hand_side()" function so 
> can I use the "create_boundary_right_hand_side()" function using 
> following lines of code?

It is definitely possible to *add* to the vector you get from 
create_boundary_rhs(). But in this call...

> /
> /
> /    std::map::iterator 
> it=boundary_count.begin();
> 
>      VectorTools::create_boundary_right_hand_side(dof_handler,
>  
>   QGauss(fe.degree+1),
>                                                       rhs_function,
>                                                       tmp,/
> / it->first);/
> where the "rhs_function" provides the values of /g0/ and /g1 /at 
> boundary node points and "it->first" is the boundary id where I want to 
> apply the BC.

...you are asked to pass in a Quadrature, not a Quadrature. 
Consequently, the code does not compile. This is actually stated quite 
explicitly in the second part of the error message:

dealii::VectorTools::create_boundary_right_hand_side(const 
dealii::DoFHandler&, const dealii::Quadrature<(dim - 
1)>&, const dealii::Function&, VectorType&, const std::set&) 
[with int dim = 1; int spacedim = 1; VectorType = 
dealii::Vector; typename VectorType::value_type = double]
void create_boundary_right_hand_side
 ^
/usr/local/include/deal.II/numerics/vector_tools.h:2105:8: note:   no 
known conversion for argument 2 from ‘dealii::QGauss<1>’ to ‘const 
dealii::Quadrature<0>&’


Best
  WB

-- 

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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-25 Thread Muhammad Mashhood
In the weak form after Neuman BC implementation for equation in step-26 i 
got following additional terms contributing in rhs:

*for 1D domain x = [0, 1]*

*system_rhs + k_n * [ g1 * phi_(x1) - g0 * phi_(x0) ], where g0 and g1 are 
the flux values at boundary nodes and phi_(x0), phi_(x1) are shape 
functions at these boundary nodes on both ends of a bar.*

As unlike the step-8 here in step-26 the rhs is being formed directly 
globally as "system_rhs" using "create_right_hand_side()" function so can I 
use the "create_boundary_right_hand_side()" function using following lines 
of code?






*std::map::iterator 
it=boundary_count.begin();
VectorTools::create_boundary_right_hand_side(dof_handler,
 QGauss(fe.degree+1),
 rhs_function,
 tmp,*
* it->first);*
where the "rhs_function" provides the values of *g0* and *g1 *at boundary 
node points and "it->first" is the boundary id where I want to apply the 
BC. So far I have tried it from my side but giving the following error:











































*/home/muhammad/software/dealii-8.5.0/examples/step-26/step-26.cc:602:53: 
error: no matching function for call to 
‘create_boundary_right_hand_side(dealii::DoFHandler<1>&, dealii::QGauss<1>, 
Step26::RightHandSide<1>&, dealii::Vector&)’ 
VectorTools::create_boundary_right_hand_side(dof_handler,   
  
^In file included from 
/home/muhammad/software/dealii-8.5.0/examples/step-26/step-26.cc:46:0:/usr/local/include/deal.II/numerics/vector_tools.h:2090:8:
 
note: candidate: template void 
dealii::VectorTools::create_boundary_right_hand_side(const 
dealii::Mapping&, const dealii::DoFHandler&, 
const dealii::Quadrature<(dim - 1)>&, const dealii::Function&, VectorType&, const std::set&)   void create_boundary_right_hand_side (const 
Mapping,
^/usr/local/include/deal.II/numerics/vector_tools.h:2090:8: note:   
template argument deduction/substitution 
failed:/home/muhammad/software/dealii-8.5.0/examples/step-26/step-26.cc:602:53: 
note:   ‘dealii::DoFHandler<1>’ is not derived from ‘const 
dealii::Mapping’ 
VectorTools::create_boundary_right_hand_side(dof_handler,   
  
^In file included from 
/home/muhammad/software/dealii-8.5.0/examples/step-26/step-26.cc:46:0:/usr/local/include/deal.II/numerics/vector_tools.h:2105:8:
 
note: candidate: void 
dealii::VectorTools::create_boundary_right_hand_side(const 
dealii::DoFHandler&, const dealii::Quadrature<(dim - 1)>&, 
const dealii::Function&, 
VectorType&, const std::set&) [with int dim = 1; int 
spacedim = 1; VectorType = dealii::Vector; typename 
VectorType::value_type = double]   void 
create_boundary_right_hand_side
^/usr/local/include/deal.II/numerics/vector_tools.h:2105:8: note:   no 
known conversion for argument 2 from ‘dealii::QGauss<1>’ to ‘const 
dealii::Quadrature<0>&’/usr/local/include/deal.II/numerics/vector_tools.h:2119:8:
 
note: candidate: template void 
dealii::VectorTools::create_boundary_right_hand_side(const 
dealii::hp::MappingCollection&, const 
dealii::hp::DoFHandler&, const dealii::hp::QCollection<(dim 
- 1)>&, const dealii::Function&, 
VectorType&, const std::set&)   void 
create_boundary_right_hand_side
^/usr/local/include/deal.II/numerics/vector_tools.h:2119:8: note:   
template argument deduction/substitution 
failed:/home/muhammad/software/dealii-8.5.0/examples/step-26/step-26.cc:602:53: 
note:   ‘dealii::DoFHandler<1>’ is not derived from ‘const 
dealii::hp::MappingCollection’ 
VectorTools::create_boundary_right_hand_side(dof_handler,   
  
^In file included from 
/home/muhammad/software/dealii-8.5.0/examples/step-26/step-26.cc:46:0:/usr/local/include/deal.II/numerics/vector_tools.h:2136:8:
 
note: candidate: template void 
dealii::VectorTools::create_boundary_right_hand_side(const 
dealii::hp::DoFHandler&, const dealii::hp::QCollection<(dim 
- 1)>&, const dealii::Function&, 
VectorType&, const std::set&)   void 
create_boundary_right_hand_side
^/usr/local/include/deal.II/numerics/vector_tools.h:2136:8: note:   
template argument deduction/substitution 
failed:/home/muhammad/software/dealii-8.5.0/examples/step-26/step-26.cc:602:53: 
note:   ‘dealii::DoFHandler<1>’ is not derived from ‘const 
dealii::hp::DoFHandler’ 
VectorTools::create_boundary_right_hand_side(dof_handler,   
  
^make[3]: *** [CMakeFiles/step-26.dir/step-26.cc.o] Error 
1CMakeFiles/step-26.dir/build.make:62: recipe for target 
'CMakeFiles/step-26.dir/step-26.cc.o' failedmake[2]: *** 
[CMakeFiles/step-26.dir/all] Error 2make[3]: Leaving directory 

Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-17 Thread Wolfgang Bangerth
On 4/17/19 10:09 AM, Muhammad Mashhood wrote:
> Thank you I will try this way and what about changing the Thermal 
> Diffusion "k" value in this step-26 case. As currently it is 1 but if I 
> want to change it shall I multiply value of "k" thermal diffusivity with 
> Laplace Matrix "A" or is there another already developed way in deal.ii 

You just need to put the relevant factor into the formula at the 
appropriate place where you implement the boundary term. If you write 
out the weak form of your equation, you will see where that needs to be 
done.

You may also want to look at step-5 and step-6 to see where the 
diffusion coefficient appears in the definition of the weak form.

Best
  WB

-- 

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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-17 Thread Muhammad Mashhood
Thank you I will try this way and what about changing the Thermal Diffusion 
"k" value in this step-26 case. As currently it is 1 but if I want to 
change it shall I multiply value of "k" thermal diffusivity with Laplace 
Matrix "A" or is there another already developed way in deal.ii ? Thank you 
in advance! 

On Wednesday, April 10, 2019 at 4:16:02 PM UTC+2, Wolfgang Bangerth wrote:
>
> On 4/10/19 4:52 AM, Muhammad Mashhood wrote: 
> > 
> > _But the step-26 which I am now concerned about is directly forming rhs 
> > somehow using the function:_ 
> > 
> >  RightHandSide rhs_function; 
> >  rhs_function.set_time(time); 
> >  VectorTools::create_right_hand_side(dof_handler, 
> >  QGauss(fe.degree+1), 
> >  rhs_function, 
> >  tmp); 
> > So how can I possibly implement heat flux on cell faces in this example 
> case 
> > step-26 ? If I can, then I guess my problem is solved to learn 
> implementing 
> > Neuman BC for Heat equation in deal.ii. Thank you very much in advance? 
>
> You just need to replace the call to this one function by something like 
> the 
> code snippet you had shown above. 
>
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-10 Thread Wolfgang Bangerth
On 4/10/19 4:52 AM, Muhammad Mashhood wrote:
> 
> _But the step-26 which I am now concerned about is directly forming rhs 
> somehow using the function:_
> 
>      RightHandSide rhs_function;
>      rhs_function.set_time(time);
>      VectorTools::create_right_hand_side(dof_handler,
>      QGauss(fe.degree+1),
>      rhs_function,
>      tmp);
> So how can I possibly implement heat flux on cell faces in this example case 
> step-26 ? If I can, then I guess my problem is solved to learn implementing 
> Neuman BC for Heat equation in deal.ii. Thank you very much in advance?

You just need to replace the call to this one function by something like the 
code snippet you had shown above.

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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-10 Thread Muhammad Mashhood
Dear Prof. Bangerth,
 Thank you for the guidance and correction. 
I got the point now that for Neuman conditions I shall iterate for face 
cells along desired edge for imposing condition like in the previous case 
of step-8. I also went through the step-7, thank you for the guidance it 
made me understand more about the face_cell_values for making rhs. As far 
as I have understood the step-7 is iterating through each cell and 
implementing simply the Neuman condition at the face cells:

for (; cell!=endc; ++cell)
{
cell_matrix = 0;
cell_rhs = 0;
fe_values.reinit 

 
(cell);
right_hand_side.value_list (fe_values.get_quadrature_points 

(),
rhs_values);
for (unsigned int q_point=0; q_pointhttps://www.dealii.org/current/doxygen/deal.II/classFEValuesBase.html#ac4cee7628c2903a89c5c399fddeb00a5>(i,q_point)
 
*
fe_values.shape_grad 

(j,q_point)
+
fe_values.shape_value 
(i,q_point)
 
*
fe_values.shape_value 
(j,q_point))
 
*
fe_values.JxW 

(q_point));
cell_rhs(i) += (fe_values.shape_value 
(i,q_point)
 
*
rhs_values [q_point] *
fe_values.JxW 

(q_point));
}
for (unsigned int face_number=0; 
face_number::faces_per_cell; ++face_number)
if (cell->face(face_number)->at_boundary()
&&
(cell->face(face_number)->boundary_id() == 1))
{
fe_face_values.reinit 

 
(cell, face_number);
for (unsigned int q_point=0; q_pointhttps://www.dealii.org/current/doxygen/deal.II/classFEValuesBase.html#ab1aa3aa2940125b47df95ff82ad733b9>(q_point))
 
*
fe_face_values.normal_vector 

(q_point));
for (unsigned int i=0; ihttps://www.dealii.org/current/doxygen/deal.II/classFEValuesBase.html#abe4de48ff59778bb82a0ec13037804aa>(i,q_point)
 
*
fe_face_values.JxW 

(q_point));
}
}
cell->get_dof_indices (local_dof_indices);
for (unsigned int i=0; i rhs_function;
rhs_function.set_time(time);
VectorTools::create_right_hand_side(dof_handler,
QGauss(fe.degree+1),
rhs_function,
tmp);
So how can I possibly implement heat flux on cell faces in this example 
case step-26 ? If I can, then I guess my problem is solved to learn 
implementing Neuman BC for Heat equation in deal.ii. Thank you very much in 
advance? 



On Wednesday, April 10, 2019 at 5:56:46 AM UTC+2, Wolfgang Bangerth wrote:
>
> On 4/9/19 10:01 AM, Muhammad Mashhood wrote: 
> > I want to apply the heat flux BC on one of the edge instead i.e. *dU(t, 
> x, 
> > y=1)/dy* at top. For this so far I could only find a method to make a 
> heat 
> > source using the already present function as follows: 
>
> I don't know how you use the class you implement, but I would try to avoid 
> all 
> confusion by naming the class RightHandSide: This is the name we generally 
> use 
> for forcing terms of the differential equation, and not for the right hand 
> side of boundary conditions. 
>
> Just like for your previous question, it is not correct to "convert" the 
> right 
> hand side of a boundary condition into a right hand side of the equation. 
> This 
> is mathematically not correct and will not lead to the correct solution. 
>
> Have you looked at step-7? This program deals with Neumann boundary 
> conditions 
> and may have exactly what you are looking for. 
>
> 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 

Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-09 Thread Wolfgang Bangerth
On 4/9/19 10:01 AM, Muhammad Mashhood wrote:
> I want to apply the heat flux BC on one of the edge instead i.e. *dU(t, x, 
> y=1)/dy* at top. For this so far I could only find a method to make a heat 
> source using the already present function as follows:

I don't know how you use the class you implement, but I would try to avoid all 
confusion by naming the class RightHandSide: This is the name we generally use 
for forcing terms of the differential equation, and not for the right hand 
side of boundary conditions.

Just like for your previous question, it is not correct to "convert" the right 
hand side of a boundary condition into a right hand side of the equation. This 
is mathematically not correct and will not lead to the correct solution.

Have you looked at step-7? This program deals with Neumann boundary conditions 
and may have exactly what you are looking for.

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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-09 Thread Muhammad Mashhood
Sorry if it is not clear. Sure I will explain it a bit more.
In step-26 of tutorials, the (temperature application) Dirchlet BC is 
already implemented. I want to apply the heat flux BC on one of the edge 
instead i.e. *dU(t, x, y=1)/dy* at top. For this so far I could only find a 
method to make a heat source using the already present function as follows:

  template
  class RightHandSide : public Function
  {
  public:
RightHandSide ()
  :
  Function(),
  period (0.2)
{}

virtual double value (const Point ,
  const unsigned int component = 0) const;

  private:
const double period;
  };



  template
  double RightHandSide::value (const Point ,
const unsigned int component) const
  {
(void) component;
Assert (component == 0, ExcIndexRange(component, 0, 1));
Assert (dim == 2, ExcNotImplemented());

const double time = this->get_time();
const double point_within_period = (time/period - 
std::floor(time/period));

if ((point_within_period >= 0.0) && (point_within_period <= 0.2))
  {
if ((p[0] > 0.5) && (p[1] > -0.5))
  return 2;
else
  return 0;
  }
else if ((point_within_period >= 0.5) && (point_within_period <= 0.7))
  {
if ((p[0] > -0.5) && (p[1] > 0.5))
  return 2;
else
  return 0;
  }
else
  return 0;
///
// Applying the Neumann BC in the form of flux producing source or sink 
at top boundary
///

if ((point_within_period >= 0.0) && (point_within_period <= 0.2))
  {

if (p[1] > 0.99)
  return 100;
else
  return 0;

  }

  }

So the question is that is it valid Idea or there can be other idea to 
apply heat flux on the boundary edge in deal.ii step-26 code? Thank you!

On Tuesday, April 9, 2019 at 5:23:04 PM UTC+2, Wolfgang Bangerth wrote:
>
> On 4/9/19 3:44 AM, Muhammad Mashhood wrote: 
> > Thank you very much Prof. Bangerth. The Neuman condition is now 
> implemented 
> > successfully on the face elements in relatively simpler way (which you 
> > proposed for me). Now I have moved ahead to implement the flux BC on the 
> top 
> > edge of square plate and I am taking help of your tutorial step-26. But 
> in 
> > this code the structure is a bit different than the step-8 i.e. the 
> *cell_rhs 
> > *looks like being formed now in *create_right_hand_side* function. 
> > So my question is that can I simply use the heat source code of 
> following 
> > function: 
> > *template 
> >double RightHandSide::value (const Point , 
> >  const unsigned int component) 
> const* 
> > 
> > to select the points of top edge of the domain to declare the flux input 
> or 
> > Neuman BC (i.e. in other words moving source on top and source now 
> putting 
> > heat inside the domain) or there is other valid way for that? Thank you 
> in 
> > advance for your suggestion! 
>
> I don't think I fully understand what you want to do. Can you state in 
> formulas what you want to implement? How does your boundary conditions 
> look like? 
>
> Best 
>   WB 
>
> -- 
>  
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-09 Thread Wolfgang Bangerth
On 4/9/19 3:44 AM, Muhammad Mashhood wrote:
> Thank you very much Prof. Bangerth. The Neuman condition is now implemented 
> successfully on the face elements in relatively simpler way (which you 
> proposed for me). Now I have moved ahead to implement the flux BC on the top 
> edge of square plate and I am taking help of your tutorial step-26. But in 
> this code the structure is a bit different than the step-8 i.e. the *cell_rhs 
> *looks like being formed now in *create_right_hand_side* function.
> So my question is that can I simply use the heat source code of following 
> function:
> *template
>    double RightHandSide::value (const Point ,
>      const unsigned int component) const*
> 
> to select the points of top edge of the domain to declare the flux input or 
> Neuman BC (i.e. in other words moving source on top and source now putting 
> heat inside the domain) or there is other valid way for that? Thank you in 
> advance for your suggestion!

I don't think I fully understand what you want to do. Can you state in 
formulas what you want to implement? How does your boundary conditions look 
like?

Best
  WB

-- 

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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-09 Thread Muhammad Mashhood
Thank you very much Prof. Bangerth. The Neuman condition is now implemented 
successfully on the face elements in relatively simpler way (which you 
proposed for me). Now I have moved ahead to implement the flux BC on the 
top edge of square plate and I am taking help of your tutorial step-26. But 
in this code the structure is a bit different than the step-8 i.e. the 
*cell_rhs 
*looks like being formed now in *create_right_hand_side* function. 
So my question is that can I simply use the heat source code of following 
function:


*template  double RightHandSide::value (const Point 
,const unsigned int component) const*

to select the points of top edge of the domain to declare the flux input or 
Neuman BC (i.e. in other words moving source on top and source now putting 
heat inside the domain) or there is other valid way for that? Thank you in 
advance for your suggestion!  


On Thursday, April 4, 2019 at 3:10:35 PM UTC+2, Wolfgang Bangerth wrote:
>
> On 4/4/19 4:05 AM, Muhammad Mashhood wrote: 
> > 
> >   for (unsigned int f=0; f :: faces_per_cell; ++f) 
> >  if (cell->face(f)->at_boundary() ) 
> >  { 
> >  fe_face_values.reinit (cell,f); 
> >  for (unsigned int i=0; i >{ 
> >  const unsigned int 
> >  component_i = 
> fe.system_to_component_index(i).first; 
> > 
> >  for (unsigned int q_point=0; 
> q_point > ++q_point) 
> >cell_rhs(i) += 
> fe_face_values.shape_value(i,q_point) * 
> >   rhs_values[q_point][component_i] * 
> >   fe_face_values.JxW(q_point); 
> >  } 
> >  } 
> > 
> > 
> >   Where the *"rhs_values"* are being extracted from my previously 
> mentioned 
> > function "*right_hand_side (fe_values.get_quadrature_points(), 
> rhs_values, 
> > cell);"* in a same loop of "*for (; cell!=endc; ++cell)" *and the code 
> for 
> > this "*right_hand_side" *function is that which I mentioned previously. 
> > In my limited knowledge I am going through each face in cell as in 2D 
> there 
> > are four edges are present and I want to choose the edge number 3 (which 
> is 
> > upper outer edge in my example case). 
>
> The way you do things here does not work. You are assembling boundary 
> terms on 
> an individual face here. You need to evaluate the rhs_values *for this 
> particular face*. In other words, you need to call the function you showed 
> us with 
>fe_face_values.get_quadrature_points() 
> (not fe_values.get_quadrature_points()), and not with an iterator to the 
> cell 
> but with an iterator to the face. 
>
> This way, you do not need the function you showed us guess whether a 
> quadrature point is near a particular boundary -- the function already 
> *knows* 
> that the quadrature points lie on that boundary, because it is only called 
> for 
> such points. 
>
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-04 Thread Wolfgang Bangerth
On 4/4/19 4:05 AM, Muhammad Mashhood wrote:
> 
>   for (unsigned int f=0; f :: faces_per_cell; ++f)
>          if (cell->face(f)->at_boundary() )
>          {
>              fe_face_values.reinit (cell,f);
>      for (unsigned int i=0; i    {
>      const unsigned int
>      component_i = fe.system_to_component_index(i).first;
> 
>      for (unsigned int q_point=0; q_point ++q_point)
>    cell_rhs(i) += fe_face_values.shape_value(i,q_point) *
>   rhs_values[q_point][component_i] *
>   fe_face_values.JxW(q_point);
>      }
>          }
> 
> 
>   Where the *"rhs_values"* are being extracted from my previously mentioned 
> function "*right_hand_side (fe_values.get_quadrature_points(), rhs_values, 
> cell);"* in a same loop of "*for (; cell!=endc; ++cell)" *and the code for 
> this "*right_hand_side" *function is that which I mentioned previously.
> In my limited knowledge I am going through each face in cell as in 2D there 
> are four edges are present and I want to choose the edge number 3 (which is 
> upper outer edge in my example case).

The way you do things here does not work. You are assembling boundary terms on 
an individual face here. You need to evaluate the rhs_values *for this 
particular face*. In other words, you need to call the function you showed us 
with
   fe_face_values.get_quadrature_points()
(not fe_values.get_quadrature_points()), and not with an iterator to the cell 
but with an iterator to the face.

This way, you do not need the function you showed us guess whether a 
quadrature point is near a particular boundary -- the function already *knows* 
that the quadrature points lie on that boundary, because it is only called for 
such points.

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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-04 Thread Muhammad Mashhood
Thank you Prof. Bangerth for your quick concern. I am on basic level for 
FEM code programming especially deal.ii and also quite only a bit familiar 
with object oriented programming in C++. 
Sorry if my question was not clear, let me explain it a bit:
Actually, I am trying to follow the tutorial step-8 for extending it to 
applying BC upon the labelled edges during meshing in mesh generator. I am 
quit successful in applying Dirchlet (displacement) BC simply using 
function "interpolate_boundary_values()". Now it is time to apply Neumann 
(force) BC. 
For this yes you guessed right that I am using "FEFaceValues" in following 
code as per tutorials:

 for (unsigned int f=0; f :: faces_per_cell; ++f)  
if (cell->face(f)->at_boundary() )
{
fe_face_values.reinit (cell,f);
for (unsigned int i=0; i
> On 4/3/19 8:04 AM, Muhammad Mashhood wrote: 
> > 
> > I am trying to apply the Neumann 
> (force) 
> > BC on the edge using the right_hand_side() function which I modified as 
> following: 
> > 
> > 
> > void right_hand_side (const std::vector > ,   // the 
> active 
> > cell is also imported when right hand side is called to induce some 
> Neumann BC 
> >  std::vector >   , 
> >  typename DoFHandler::active_cell_iterator 
> & 
> > cell_in_rhs) 
> > 
> > for (unsigned int f=0; f < GeometryInfo :: faces_per_cell; ++f) 
> >  { 
> >  if (cell_in_rhs->face(f)->at_boundary() && 
> > cell_in_rhs->face(f)->boundary_id() == 3) 
> >  { 
> >  std::cout << "points.size(): "<< 
> points.size()<<" 
> > :"< >  values[0][1] = 2.0; 
> >  values[2][1] = 2.0; 
> > 
> >  } 
> >   } 
> > 
>
> I don't think I understand this code. The Neumann boundary conditions only 
> appear in *boundary* integrals. How are you using the function you have 
> here? 
> For integrals over cells (using FEValues) or integrals over faces 
> (FEFaceValues)? If it is the latter, you are integrating over *one 
> specific 
> face* of the current cell, so it makes no sense to loop over all faces 
> *within 
> this function*. 
>
> 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.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-03 Thread Wolfgang Bangerth
On 4/3/19 8:04 AM, Muhammad Mashhood wrote:
> 
>     I am trying to apply the Neumann (force) 
> BC on the edge using the right_hand_side() function which I modified as 
> following:
> 
> 
> void right_hand_side (const std::vector > ,   // the active 
> cell is also imported when right hand side is called to induce some Neumann BC
>      std::vector >   ,
>                          typename DoFHandler::active_cell_iterator & 
> cell_in_rhs)
> 
> for (unsigned int f=0; f < GeometryInfo :: faces_per_cell; ++f)
>                  {
>                      if (cell_in_rhs->face(f)->at_boundary() && 
> cell_in_rhs->face(f)->boundary_id() == 3)
>                          {
>                              std::cout << "points.size(): "<< 
> points.size()<<" 
> :"<                              values[0][1] = 2.0;
>                              values[2][1] = 2.0;
> 
>                          }
>                                   }
> 

I don't think I understand this code. The Neumann boundary conditions only 
appear in *boundary* integrals. How are you using the function you have here? 
For integrals over cells (using FEValues) or integrals over faces 
(FEFaceValues)? If it is the latter, you are integrating over *one specific 
face* of the current cell, so it makes no sense to loop over all faces *within 
this function*.

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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Imposing the Neumann BC using right_hand_side() function

2019-04-03 Thread Muhammad Mashhood
Dear group members, 
   I am trying to apply the Neumann (force) 
BC on the edge using the right_hand_side() function which I modified as 
following:


void right_hand_side (const std::vector > ,   // the 
active cell is also imported when right hand side is called to induce some 
Neumann BC
std::vector >   ,
typename DoFHandler::active_cell_iterator & 
cell_in_rhs)

for (unsigned int f=0; f < GeometryInfo :: faces_per_cell; ++f)
{
if (cell_in_rhs->face(f)->at_boundary() && 
cell_in_rhs->face(f)->boundary_id() == 3)
{
std::cout << "points.size(): "<< 
points.size()<<" :"