Re: [deal.II] How to make G vector in lecture 21.65

2017-03-21 Thread Wolfgang Bangerth

On 03/21/2017 05:11 AM, hanks0...@gmail.com wrote:


At first, the reason why I would like to make vector G by myself (without
using VectorTools::interpolate_boundary_values) is that I would like to input
calculated values (not just function of position) on the boundary.

I would like to solve free boundary problem. So, the boundary condition would
be calculated from sources(current in coils) and line integral of green
function and so on

Especially, the calculation of boundary values includes the line integral,
that is why I want to use an assembly step.

So, do you think it is hard to apply boundary condition without using
VectorTools::interpolate_boundary_values...?


No. But I would advise to take a look at the implementation of that function 
(in include/deal.II/numerics/vector_tools.template.h IIRC).


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] How to make G vector in lecture 21.65

2017-03-21 Thread hanks0227
Dr. Bangerth,

Thank you for the kind explanation.

Now, I understand what is wrong...

I'm really sorry but, could I have one more question?

>
> The approach you use, making things look like an assembly step, is not 
> appropriate for what you want to do. I would just call 
> VectorTools::interpolate_boundary_values to get the pairs of dof_index 
> and value, and then convert the result of that function into a vector. 
>
> At first, the reason why I would like to make vector G by myself (without 
using VectorTools::interpolate_boundary_values) is that I would like to 
input calculated values (not just function of position) on the boundary.

I would like to solve free boundary problem. So, the boundary condition 
would be calculated from sources(current in coils) and line integral of 
green function and so on

Especially, the calculation of boundary values includes the line integral, 
that is why I want to use an assembly step.

So, do you think it is hard to apply boundary condition without using 
VectorTools::interpolate_boundary_values...? 

Thank you.

Kyusik.
 

-- 
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] How to make G vector in lecture 21.65

2017-03-20 Thread Wolfgang Bangerth

On 03/19/2017 09:21 PM, hanks0...@gmail.com wrote:

As you can see above, what I change here is
1. const unsigned int   dofs_per_cell   = fe.dofs_per_cell;  ->   const
unsigned int   dofs_per_face   = fe.dofs_per_face;

2. Vector  local_rhs(dofs_per_cell);  ->   Vector
local_rhs (dofs_per_face);

3.std::vector local_dof_indices
(dofs_per_cell);  ->  std::vector
local_dof_indices (dofs_per_face);

4.
for (unsigned int i=0; i
for (unsigned int i=0; iget_dof_indices (local_dof_indices);
   for (unsigned int i=0; i
cell->face(face_no)->get_dof_indices (local_dof_indices);
   for (unsigned int i=0; i

Re: [deal.II] How to make G vector in lecture 21.65

2017-03-19 Thread hanks0227
Dr. Bangerth,

Thank you very much for your kind reply.



> What is the content of 'constraints' in your case? 
>
>   DoFTools::make_hanging_node_constraints (dof_handler,
   constraints);

  VectorTools::interpolate_boundary_values (dof_handler,
0,
ZeroFunction(),
constraints);


  constraints.close ();

  DynamicSparsityPattern dsp(dof_handler.n_dofs());
  DoFTools::make_sparsity_pattern(dof_handler,
  dsp,
  constraints,
  /*keep_constrained_dofs = */ false);

  sparsity_pattern.copy_from(dsp);

  system_matrix.reinit (sparsity_pattern);
}

As you said in the lecture, I apply the ZeroFunction() for 
A*U_0=F-A*G_tilt
 

>
> This is not correct. You are computing the G vector as 
>G_i = \int_{\partial\Omega} \varphi_i(x) g(x) ds 
> i.e., as a boundary integral. But G should be the vector that 
> *interpolates* 
> g(x) on the boundary. 
>
> template 
void Step6::assemble_G () 
{
   const QGauss face_quadrature_formula(3);

FEFaceValues fe_face_values (fe, face_quadrature_formula,
  update_values | update_gradients |
  update_quadrature_points  | 
update_JxW_values);

const unsigned int   dofs_per_face   = fe.dofs_per_face;
const unsigned int   n_face_q_points = face_quadrature_formula.size();

Vector   local_rhs (dofs_per_face);
G_tilt.reinit (dof_handler.n_dofs());

std::vector local_dof_indices (dofs_per_face);

typename DoFHandler::active_cell_iterator
cell = dof_handler.begin_active(),
endc = dof_handler.end();
for (; cell!=endc; ++cell)
  {
local_rhs = 0;

for (unsigned int face_no=0; 
face_noat_boundary(face_no))
{
  fe_face_values.reinit (cell, face_no);

  for (unsigned int q=0; qface(face_no)->get_dof_indices (local_dof_indices);
}
for (unsigned int i=0; i   const 
unsigned int   dofs_per_face   = fe.dofs_per_face;

2. Vector  local_rhs(dofs_per_cell);  ->   Vector   
local_rhs (dofs_per_face);

3.std::vector local_dof_indices (dofs_per_cell); 
 ->  std::vector local_dof_indices (dofs_per_face);

4.
for (unsigned int i=0; i
for (unsigned int i=0; iget_dof_indices (local_dof_indices);
   for (unsigned int i=0; i
cell->face(face_no)->get_dof_indices (local_dof_indices);
   for (unsigned int i=0; i

Re: [deal.II] How to make G vector in lecture 21.65

2017-03-19 Thread Wolfgang Bangerth


Kyusik,


I'm studying Inhomogenous Dirichlet boundary conditions watching Lecture 21.65.

To practice this boundary condition, I'm trying to reproduce the result of
step-4(in which Inhomogenous Dirichlet boundary condition is used) in step-6.

As I learned in the lecture...

First, I assembled A and F with zero boundary condition by
template 
void Step6::assemble_system ()
{
  const QGauss  quadrature_formula(3);
  const RightHandSide right_hand_side;
  FEValues fe_values (fe, quadrature_formula,
   update_values|  update_gradients |
   update_quadrature_points  |  update_JxW_values);

  const unsigned int   dofs_per_cell = fe.dofs_per_cell;
  const unsigned int   n_q_points= quadrature_formula.size();

  FullMatrix   cell_matrix (dofs_per_cell, dofs_per_cell);
  Vector   cell_rhs (dofs_per_cell);

  std::vector local_dof_indices (dofs_per_cell);


  typename DoFHandler::active_cell_iterator
  cell = dof_handler.begin_active(),
  endc = dof_handler.end();
  for (; cell!=endc; ++cell)
{
  cell_matrix = 0;
  cell_rhs = 0;

  fe_values.reinit (cell);

  for (unsigned int q_index=0; q_indexget_dof_indices (local_dof_indices);
  constraints.distribute_local_to_global (cell_matrix,
  cell_rhs,
 local_dof_indices,
  system_matrix,
  system_rhs);
}
}


What is the content of 'constraints' in your case?



And then, I made G_tilt by...
template 
void Step6::assemble_G ()
{
   const QGauss face_quadrature_formula(3);

FEFaceValues fe_face_values (fe, face_quadrature_formula,
  update_values | update_gradients |
  update_quadrature_points  |
update_JxW_values);

const unsigned int   dofs_per_cell   = fe.dofs_per_cell;
const unsigned int   n_face_q_points = face_quadrature_formula.size();

Vector   local_rhs (dofs_per_cell);
G_tilt.reinit (dof_handler.n_dofs());

std::vector local_dof_indices (dofs_per_cell);

typename DoFHandler::active_cell_iterator
cell = dof_handler.begin_active(),
endc = dof_handler.end();
for (; cell!=endc; ++cell)
  {
local_rhs = 0;

for (unsigned int face_no=0; face_noat_boundary(face_no))
{
  fe_face_values.reinit (cell, face_no);

  for (unsigned int q=0; qget_dof_indices (local_dof_indices);
for (unsigned int i=0; i