[deal.II] Question regarding P:D:Tria

2017-03-04 Thread RAJAT ARORA
Hello all,

I am using deal.ii along with PetSc and P4est to solve a 3D solid mechanics 
problem.

I am using the GridGenerator::hyper_rectangle function to create a 
rectangular grid with 1000 X 500 X 1 (0.5 million) elements.

My question is: - since the coarsest mesh contains 0.5 million elements, 
does that mean all the processors have 0.5 million elements?
(I think the answer is yes, I read that the deal.ii (p4est) stores the 
coarsest mesh on all processors.)

I need a mesh (overall) which should be rectangular and should have 1000 X 
500 X 1 elements. Note: It should only have 1 element in the z-direction.
Is there any way such that I can have this mesh by not replicating the 
whole mesh on all processors as it takes a lot of memory. I thought of 
making a 2D mesh and then refining it and then extruding it using 
extrude::triangulation, but extrude triangulation does not work on refined 
meshes.


Any help will be appreciated.

Thanks again.

-- 
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] Re: any suggestion how to run same code repeatedly with different boundary condition ?

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

The error message is pointing you to the fact that when you call run() a 
second time you end up trying to rebuild the triangulation on top of the 
one that you have the first time run() was called. There are a few ways 
that you can work around this. Here are two suggestions:

1. Create a new instance of the laplace_problem each time you change the 
boundary value

  {

   bvalue = 1;

   Step4<2> laplace_problem_2d;

   laplace_problem_2d.run ();
  }

  {  

   bvalue = 2;
  Step4<2> laplace_problem_2d;

   laplace_problem_2d.run ();

 }


2. Separate the run() and make_grid() calls.

  {

   Step4<2> laplace_problem_2d;
  laplace_problem_2d.make_grid ();

 
   bvalue = 1;
   laplace_problem_2d.run ();//Remove make_grid() from run()

 

   bvalue = 2;

   laplace_problem_2d.run ();

 

 }

You could of change your boundary value in other way, such as in a for loop 
or using a MultipleParameterLoop 

.

I hope this helps you.

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.


[deal.II] any suggestion how to run same code repeatedly with different boundary condition ?

2017-03-04 Thread Jaekwang Kim
Hi all, I want to run same problem for different boundary condition values 
that will come globally... for example, 
if i want to run step-4 code with  different boundary condition, 


#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 


#include 

#include 

#include 


#include 


using namespace dealii;


double bvalue ;


template 

class Step4

{

public:

  Step4 ();

  void run ();


private:

  void make_grid ();

  void setup_system();

  void assemble_system ();

  void solve ();

  void output_results () const;


  Triangulation   triangulation;

  FE_Qfe;

  DoFHandler  dof_handler;


  SparsityPattern  sparsity_pattern;

  SparseMatrix system_matrix;


  Vector   solution;

  Vector   system_rhs;

};




template 

class RightHandSide : public Function

{

public:

  RightHandSide () : Function() {}


  virtual double value (const Point   &p,

const unsigned int  component = 0) const;

};




template 

class BoundaryValues : public Function

{

public:

  BoundaryValues () : Function() {}


  virtual double value (const Point   &p,

const unsigned int  component = 0) const;

};





template 

double RightHandSide::value (const Point &p,

  const unsigned int /*component*/) const

{

  double return_value = 0.0;

  for (unsigned int i=0; i

double BoundaryValues::value (const Point &p,

   const unsigned int /*component*/) const

{

double a = bvalue;

return a;

}








template 

Step4::Step4 ()

  :

  fe (1),

  dof_handler (triangulation)

{}




template 

void Step4::make_grid ()

{

  GridGenerator::hyper_cube (triangulation, -1, 1);

  triangulation.refine_global (4);


  std::cout << "   Number of active cells: "

<< triangulation.n_active_cells()

<< std::endl

<< "   Total number of cells: "

<< triangulation.n_cells()

<< std::endl;

}



template 

void Step4::setup_system ()

{

  dof_handler.distribute_dofs (fe);


  std::cout << "   Number of degrees of freedom: "

<< dof_handler.n_dofs()

<< std::endl;


  DynamicSparsityPattern dsp(dof_handler.n_dofs());

  DoFTools::make_sparsity_pattern (dof_handler, dsp);

  sparsity_pattern.copy_from(dsp);


  system_matrix.reinit (sparsity_pattern);


  solution.reinit (dof_handler.n_dofs());

  system_rhs.reinit (dof_handler.n_dofs());

}




template 

void Step4::assemble_system ()

{

  QGauss  quadrature_formula(2);


  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)

{

  fe_values.reinit (cell);

  cell_matrix = 0;

  cell_rhs = 0;


  for (unsigned int q_index=0; q_indexget_dof_indices (local_dof_indices);

  for (unsigned int i=0; i boundary_values;

  VectorTools::interpolate_boundary_values (dof_handler,

0,

BoundaryValues(),

boundary_values);

  MatrixTools::apply_boundary_values (boundary_values,

  system_matrix,

  solution,

  system_rhs);

}




template 

void Step4::solve ()

{

  SolverControl   solver_control (1000, 1e-12);

  SolverCG<>  solver (solver_control);

  solver.solve (system_matrix, solution, system_rhs,

PreconditionIdentity());


  std::cout << "   " << solver_control.last_step()

<< " CG iterations needed to obtain convergence."

<< std::endl;

}




template 

void Step4::output_results () const

{

  DataOut data_out;


  data_out.attach_dof_handler (dof_handler);

  data_out.add_data_vector (solution, "solution");


  data_out.build_patches ();


  std::ofstream output (dim == 2 ?

"solution-2d.vtk" :

"solution-3d.vtk");

  data_out.write_vtk (output);

}





template 

void Step4::run ()

{

  std::cout << "Solving problem in " << dim << " space dimensions." << 
std::endl;


  make_grid();

  setup_system ();

  assemble_system ();

  solve ();

  output_