Re: [deal.II] Re: AMR , how to pass solution vector to refined mesh

2017-03-21 Thread Jaekwang Kim
Thank you!!
Just got what've meant. 
and fixed my code properly

Thanks ! 

Jaekwang Kim 

2017년 3월 21일 화요일 오후 12시 55분 7초 UTC-4, Jean-Paul Pelteret 님의 말:
>
> Hi Jaekwang,
>
> No, you've misunderstood in that I was just showing that to you as an 
> example. You don't need to use that exact Vector class. You were nearly at 
> the answer with what you've posted - you just need to read the compiler 
> error more carefully to understand what its telling you is wrong. The 
> deal.II BlockVector class is templatised on a number type, so must pass the 
> arguments along with the vector type when defining the vector template 
> argument of the SolutionTransfer class. So, in your case, this would be
>
> SolutionTransfer solution_transfer(dof_handler);
>>
>
> This I suspect will fix the problem you've shown above.
>
> Regards,
> Jean-Paul 
>

-- 
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] Re: AMR , how to pass solution vector to refined mesh

2017-03-21 Thread Jean-Paul Pelteret
Hi Jaekwang,

No, you've misunderstood in that I was just showing that to you as an 
example. You don't need to use that exact Vector class. You were nearly at 
the answer with what you've posted - you just need to read the compiler 
error more carefully to understand what its telling you is wrong. The 
deal.II BlockVector class is templatised on a number type, so must pass the 
arguments along with the vector type when defining the vector template 
argument of the SolutionTransfer class. So, in your case, this would be

SolutionTransfer solution_transfer(dof_handler);
>

This I suspect will fix the problem you've shown above.

Regards,
Jean-Paul 

-- 
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] Re: AMR , how to pass solution vector to refined mesh

2017-03-21 Thread Jaekwang Kim
thank you for your response. 
I am trying to following this... 

but it seems that I have to use the class, 
* SolutionTransfer* to  transfer 
block vector 

Without using MPI, isn't it possible to assess this class? like... 
SolutionTransfer , while it shows error ,

*error: **use of*

*  class template 'BlockVector' requires template arguments*

*SolutionTransfer 
solution_transfer(dof_handler)...*

* ^~~*

*/Users/kimjaekwang/Programs/dealii/include/deal.II/n*

For now I don't have mpi in my computer.If there is no way to do this 
without using MPI, i have to install..


Thank you. 



2017년 3월 21일 화요일 오전 4시 25분 37초 UTC-4, Jean-Paul Pelteret 님의 말:
>
> Dear Jaekwang,
>
> Step-31  
> demonstrates 
> how to use the SolutionTransfer class with BlockVectors. In short, you need 
> to specify the vector type as a template argument to the class. Here's how 
> its done in that tutorial:
>
> SolutionTransfer 
> 
> temperature_trans(temperature_dof_handler); // non-block vector
> SolutionTransfer 
> 
> stokes_trans(stokes_dof_handler); // block vector
> triangulation.prepare_coarsening_and_refinement 
> 
> ();
> temperature_trans.prepare_for_coarsening_and_refinement(x_temperature);
> stokes_trans.prepare_for_coarsening_and_refinement(x_stokes);
>
> I hope this helps,
> Jean-Paul
>
> On Tuesday, March 21, 2017 at 12:26:59 AM UTC+1, Jaekwang Kim wrote:
>>
>> Dear, Dr. Bangerth
>>
>> Adding up to this, may I ask you one more question?
>>
>> After this,,, I was trying to transfer my block vector solution through 
>> Solutiontransfer class. but I am having difficulty in this. 
>>
>> For example, I have fluid problem vector value solution (u_x, u_y, 
>> pressure)
>>
>> at refie_mesh function, I tried...
>>
>> template 
>>
>> void
>>
>> StokesProblem::refine_mesh () //AMR based on VELOCITY GRADIENT
>>
>> {
>>
>>
>>  const FEValuesExtractors::Vector velocities (0);
>>
>> 
>>
>>  Vector estimated_error_per_cell 
>> (triangulation.n_active_cells());
>>
>> 
>>
>>  KellyErrorEstimator::estimate (dof_handler,QGauss> >(degree+1),typename FunctionMap::type(),
>>
>>  solution,estimated_error_per_cell, 
>> fe.component_mask(velocities));
>>
>>  
>>
>>  GridRefinement::refine_and_coarsen_fixed_number 
>> (triangulation,estimated_error_per_cell,0.3, 0.0);
>>
>> 
>>
>> triangulation.prepare_coarsening_and_refinement ();
>>
>>
>>
>> SolutionTransfer solution_transfer(dof_handler); *// Here 
>> my doc hander might include all (u,v,p) solution *
>>
>>
>>
>>
>>
>> After this I reinitialized my previous solution, where my current 
>> solution will be interpolated, for newly refined dof_handler. 
>>
>> And When I tried to transfer my solution 
>>
>>
>> 
>> solution_transfer.prepare_for_coarsening_and_refinement(solution.block(0
>> ));
>>
>> *//since this function only takes vector type inputs... I assume 
>> that I cannot transfer whole solution (u,v,p) at once? *
>>
>> 
>>
>> triangulation.execute_coarsening_and_refinement();
>>
>> 
>>
>> 
>>
>> //Transfer solution
>>
>> solution_transfer.interpolate(solution.block(0), 
>> previous_solution.block(0));
>>
>> 
>>
>> 
>> solution_transfer.prepare_for_coarsening_and_refinement(solution.block(1
>> ));
>>
>> 
>>
>> solution_transfer.interpolate(solution.block(1), 
>> previous_solution.block(1));
>>
>>
>> but I run into this error. 
>> I think it is because there two lines are conflicting  because they 
>> don't have same number of dof_handler...
>>
>> 1. SolutionTransfer solution_transfer(dof_handler);
>>
>> 2. 
>> solution_transfer.prepare_for_coarsening_and_refinement(solution.block(0
>> ));
>>
>> will there be other easy way I can transfer vector-valued solution 
>> without having this difficulty? 
>>
>> I always appreciate your help !
>>
>> Thanks
>>
>> Jaekwang Kim 
>>
>> *An error occurred in line <253> of file 
>>  in 
>> function*
>>
>> *void dealii::SolutionTransfer<2, dealii::Vector, 
>> dealii::DoFHandler<2, 2> >::prepare_for_coarsening_and_refinement(const 
>> std::vector &) [dim = 2, VectorType = dealii::Vector, 
>> DoFHandlerType = dealii::DoFHandler<2, 2>]*
>>
>> *The violated condition was: *
>>
>> *all_in[i].size()==n_dofs_old*
>>
>> *The name and call sequence of the exception was:*
>>
>> *

Re: [deal.II] Re: AMR , how to pass solution vector to refined mesh

2017-03-21 Thread Jean-Paul Pelteret
Dear Jaekwang,

Step-31  
demonstrates 
how to use the SolutionTransfer class with BlockVectors. In short, you need 
to specify the vector type as a template argument to the class. Here's how 
its done in that tutorial:

SolutionTransfer 

temperature_trans(temperature_dof_handler); // non-block vector
SolutionTransfer 

stokes_trans(stokes_dof_handler); // block vector
triangulation.prepare_coarsening_and_refinement 

();
temperature_trans.prepare_for_coarsening_and_refinement(x_temperature);
stokes_trans.prepare_for_coarsening_and_refinement(x_stokes);

I hope this helps,
Jean-Paul

On Tuesday, March 21, 2017 at 12:26:59 AM UTC+1, Jaekwang Kim wrote:
>
> Dear, Dr. Bangerth
>
> Adding up to this, may I ask you one more question?
>
> After this,,, I was trying to transfer my block vector solution through 
> Solutiontransfer class. but I am having difficulty in this. 
>
> For example, I have fluid problem vector value solution (u_x, u_y, 
> pressure)
>
> at refie_mesh function, I tried...
>
> template 
>
> void
>
> StokesProblem::refine_mesh () //AMR based on VELOCITY GRADIENT
>
> {
>
>
>  const FEValuesExtractors::Vector velocities (0);
>
> 
>
>  Vector estimated_error_per_cell 
> (triangulation.n_active_cells());
>
> 
>
>  KellyErrorEstimator::estimate (dof_handler,QGauss >(degree+1),typename FunctionMap::type(),
>
>  solution,estimated_error_per_cell, fe.component_mask(velocities));
>
>  
>
>  GridRefinement::refine_and_coarsen_fixed_number 
> (triangulation,estimated_error_per_cell,0.3, 0.0);
>
> 
>
> triangulation.prepare_coarsening_and_refinement ();
>
>
>
> SolutionTransfer solution_transfer(dof_handler); *// Here 
> my doc hander might include all (u,v,p) solution *
>
>
>
>
>
> After this I reinitialized my previous solution, where my current solution 
> will be interpolated, for newly refined dof_handler. 
>
> And When I tried to transfer my solution 
>
>
> 
> solution_transfer.prepare_for_coarsening_and_refinement(solution.block(0
> ));
>
> *//since this function only takes vector type inputs... I assume 
> that I cannot transfer whole solution (u,v,p) at once? *
>
> 
>
> triangulation.execute_coarsening_and_refinement();
>
> 
>
> 
>
> //Transfer solution
>
> solution_transfer.interpolate(solution.block(0), 
> previous_solution.block(0));
>
> 
>
> 
> solution_transfer.prepare_for_coarsening_and_refinement(solution.block(1
> ));
>
> 
>
> solution_transfer.interpolate(solution.block(1), 
> previous_solution.block(1));
>
>
> but I run into this error. 
> I think it is because there two lines are conflicting  because they 
> don't have same number of dof_handler...
>
> 1. SolutionTransfer solution_transfer(dof_handler);
>
> 2. solution_transfer.prepare_for_coarsening_and_refinement(solution.block(
> 0));
>
> will there be other easy way I can transfer vector-valued solution without 
> having this difficulty? 
>
> I always appreciate your help !
>
> Thanks
>
> Jaekwang Kim 
>
> *An error occurred in line <253> of file 
>  in 
> function*
>
> *void dealii::SolutionTransfer<2, dealii::Vector, 
> dealii::DoFHandler<2, 2> >::prepare_for_coarsening_and_refinement(const 
> std::vector &) [dim = 2, VectorType = dealii::Vector, 
> DoFHandlerType = dealii::DoFHandler<2, 2>]*
>
> *The violated condition was: *
>
> *all_in[i].size()==n_dofs_old*
>
> *The name and call sequence of the exception was:*
>
> *ExcDimensionMismatch(all_in[i].size(),n_dofs_old)*
>
> *Additional Information: *
>
> *Dimension 238 not equal to 274*
>
>
>
>
>

-- 
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] Re: AMR , how to pass solution vector to refined mesh

2017-03-20 Thread Jaekwang Kim
Dear. Dr, Bangerth

Adding up to this, I want to ask one more question. 

I was trying to transfer 'vector-valuled' solution (Block vector type) as I 
did for scalar solution (Vector type).

but it seems that the command line 

*solution_transfer.prepare_for_coarsening_and_refinement(solution); *


*error: **no matching member*

*  function for call to 'prepare_for_coarsening_and_refinement'*

*solution_transfer.prepare_for_coarsening_and_refinement(solution);*


is only able to transfer scalar solution. since I am receiving error 
message. 


I think I have to transfer my fluid problem solution (u,v,p) each by each 
to refined mesh. 


How can I do this...? (Is there a short way that I can assess each solution 
vector that live in BlockVector ?


Always thank you. 


Jaekwang Kim  

-- 
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] Re: AMR , how to pass solution vector to refined mesh

2017-03-20 Thread Jaekwang Kim
Thank you ! 

You just pointed out exact problem that my code had!

I was not taking into constraints when I make new sparsity pattern! 


*  DoFTools::make_sparsity_pattern(dof_handler,*

*dsp,*

*constraints,*

*/*keep_constrained_dofs = */ false);*


2017년 3월 20일 월요일 오후 1시 3분 50초 UTC-4, Wolfgang Bangerth 님의 말:
>
> On 03/20/2017 10:58 AM, Jaekwang Kim wrote: 
> > 
> > I tried to assert assemble function as you suggested, but I didn't 
> > receive any error message. 
> > 
> > What make me more confuse me is the code is working with global 
> refinement. 
>
> Then are you building the sparsity pattern taking into account hanging 
> node constraints? Take a look how that is done in step-6, for example. 
>
> 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] Re: AMR , how to pass solution vector to refined mesh

2017-03-20 Thread Wolfgang Bangerth

On 03/20/2017 10:58 AM, Jaekwang Kim wrote:


I tried to assert assemble function as you suggested, but I didn't
receive any error message.

What make me more confuse me is the code is working with global refinement.


Then are you building the sparsity pattern taking into account hanging 
node constraints? Take a look how that is done in step-6, for example.


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] Re: AMR , how to pass solution vector to refined mesh

2017-03-20 Thread Jaekwang Kim


Thanks for your response. 

I tried to assert assemble function as you suggested, but I didn't receive 
any error message. 

What make me more confuse me is the code is working with global refinement.

if I input 100% cells to be refined.. 


 GridRefinement::refine_and_coarsen_fixed_number (triangulation,

 
estimated_error_per_cell,

 *1.0, 0.0);*


if I input 90 cells to be refined, it goes at least one cycle, 

but same or less than 80 cell, I keep receiving error message that... 

Might AMR be related to my program?  

 


*An error occurred in line <1668> of file 

 
in function*

*void dealii::internals::dealiiSparseMatrix::add_value(const LocalType, 
const size_type, const size_type, SparseMatrixIterator &) 
[SparseMatrixIterator = dealii::SparseMatrixIterators::Iterator, LocalType = double]*

*The violated condition was: *

*matrix_values->column() == column*

*The name and call sequence of the exception was:*

*typename SparseMatrix::ExcInvalidIndex(row, column)*

*Additional Information: *

*You are trying to access the matrix entry with index <1,305>, but this 
entry does not exist in the sparsity pattern of this matrix.*


*The most common cause for this problem is that you used a method to build 
the sparsity pattern that did not (completely) take into account all of the 
entries you will later try to write into. An example would be building a 
sparsity pattern that does not include the entries you will write into due 
to constraints on degrees of freedom such as hanging nodes or periodic 
boundary conditions. In such cases, building the sparsity pattern will 
succeed, but you will get errors such as the current one at one point or 
other when trying to write into the entries of the matrix.*





template 

void nonlinear::refine_grid ()

{

Vector estimated_error_per_cell (triangulation.n_active_cells());

KellyErrorEstimator::estimate (dof_handler,

QGauss(3),

typename FunctionMap::type(),

solution,

estimated_error_per_cell);

GridRefinement::refine_and_coarsen_fixed_number (triangulation,

 
estimated_error_per_cell,

 1.0, 0.0);



/* You need to tranfer solution (n-1 step) domain into previous 
solution (n step)*/

   

triangulation.prepare_coarsening_and_refinement ();

SolutionTransfer solution_transfer(dof_handler);

solution_transfer.prepare_for_coarsening_and_refinement(solution);

triangulation.execute_coarsening_and_refinement(); // I think n_dof() 
has increased here. You need to check this if necessary

dof_handler.distribute_dofs(fe);



   // Vector tmp(dof_handler.n_dofs()); //tmp - n step dof



previous_solution.reinit (dof_handler.n_dofs());



solution_transfer.interpolate(solution, previous_solution);  // 
interpolate (input, output)





DynamicSparsityPattern dsp(dof_handler.n_dofs());

DoFTools::make_sparsity_pattern (dof_handler, dsp);

sparsity_pattern.copy_from(dsp);



solution.reinit (dof_handler.n_dofs());

system_matrix.reinit (sparsity_pattern);

system_rhs.reinit (dof_handler.n_dofs());



constraints.clear ();

DoFTools::make_hanging_node_constraints (dof_handler,

 constraints);

VectorTools::interpolate_boundary_values (dof_handler,1,

  BoundaryValues(),

  constraints);

constraints.close ();



}

-- 
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] Re: AMR , how to pass solution vector to refined mesh

2017-03-19 Thread Wolfgang Bangerth

On 03/17/2017 08:03 AM, Jaekwang Kim wrote:

After the first cycle, I am doing

template

voidnonlinear::refine_grid ()

{


Vector estimated_error_per_cell (triangulation.n_active_cells());

KellyErrorEstimator::estimate (dof_handler,

QGauss(3),

typenameFunctionMap::type(),

solution,

estimated_error_per_cell);

GridRefinement::refine_and_coarsen_fixed_number (triangulation,

 estimated_error_per_cell,

 0.3, 0.0);





triangulation.prepare_coarsening_and_refinement ();

SolutionTransfer solution_transfer(dof_handler);

solution_transfer.prepare_for_coarsening_and_refinement(solution);

triangulation.execute_coarsening_and_refinement(); // I think n_dof() has
increased here. You need to check this if necessary

dof_handler.distribute_dofs(fe);





previous_solution.reinit (dof_handler.n_dofs());



solution_transfer.interpolate(solution, previous_solution);



   DynamicSparsityPattern dsp(dof_handler.n_dofs());

DoFTools::make_sparsity_pattern (dof_handler, dsp);

sparsity_pattern.copy_from(dsp);



solution.reinit (dof_handler.n_dofs());

system_matrix.reinit (sparsity_pattern);

system_rhs.reinit (dof_handler.n_dofs());


}


I am sure that I am reinitialize matrixes...
but I am not sure about whether the redline is doing enough for
reinitialization of sparsity pattern


It looks like it, but it seems like it's not working, and just seeing the 
little code snippet is not enough for me to tell for sure. You'll have to 
debug what is going on. My first stab would be: At the beginning of your 
assembly function, put something like

  Assert (system_matrix.n() == dof_handler.n_dofs(), ExcInternalError());
to verify that indeed your matrix has the right size.

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] Re: AMR , how to pass solution vector to refined mesh

2017-03-17 Thread Wolfgang Bangerth

On 03/16/2017 08:38 PM, Jaekwang Kim wrote:


I think this two function do everything I needed... but when I run my code, I
run into error message when I assemble system in second time.
what might be the problem.?


As the error message says, you are trying to write into a matrix entry that 
does not exist. Did you re-initialize the sparsity pattern and matrix after 
you refined the mesh?


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.