Re: [deal.II] output derived quanteties (gradients of vector valued solution like strain)

2023-03-10 Thread Wolfgang Bangerth

On 3/10/23 13:05, Konrad Schneider wrote:

**

Thanks. That was too easy. How should one know this...
Actually in the documentation 
(https://www.dealii.org/current/doxygen/deal.II/classDataPostprocessorTensor.html) the command

data_out.write_vtk (output);

appears in the example. Maybe it should be changed to

data_out.write_vtu (output);

Furthermore, may I suggest, that it might be of some value to add the data 
output of stresses to one of the elasticity tutorials (maybe add it to 
step-8), since evaluating stresses (especially von mises stresses) is one of 
the major tasks in "pure" solid mechanics plus there is this pitfall that we 
have to use the vtu-format for tensor data.


Konrad,
yes, this had been pointed out a couple of months ago, and the current 
developer documentation already points that out as well:

https://www.dealii.org/developer/doxygen/deal.II/classDataPostprocessorTensor.html

I've taken the liberty to also write a patch that makes the error message 
clearer:
https://github.com/dealii/dealii/pull/14875

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/0c523295-9d15-7c82-1f67-355e25f66840%40colostate.edu.


Re: [deal.II] output derived quanteties (gradients of vector valued solution like strain)

2023-03-10 Thread Konrad Schneider
Thanks. That was too easy. How should one know this...
Actually in the documentation 
(https://www.dealii.org/current/doxygen/deal.II/classDataPostprocessorTensor.html)
 
the command
 
data_out.write_vtk (output);

appears in the example. Maybe it should be changed to 

data_out.write_vtu (output);

Furthermore, may I suggest, that it might be of some value to add the data 
output of stresses to one of the elasticity tutorials (maybe add it to 
step-8), since evaluating stresses (especially von mises stresses) is one 
of the major tasks in "pure" solid mechanics plus there is this pitfall 
that we have to use the vtu-format for tensor data.

But thanks anyway for the quick response (again).

Best regards
Konrad

Wolfgang Bangerth schrieb am Freitag, 10. März 2023 um 20:35:09 UTC+1:

> On 3/10/23 07:41, Konrad Schneider wrote:
> > 
> > I am using deal.ii version 9.4 and am wondering what I did wrong here. 
> Do you 
> > have any suggestions?
>
> The VTK writer simply doesn't support writing tensor data. Use the VTU 
> writer 
> instead.
>
> 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/c5d4f3f2-e741-4008-a712-e7d108fb7064n%40googlegroups.com.


Re: [deal.II] output derived quanteties (gradients of vector valued solution like strain)

2023-03-10 Thread Wolfgang Bangerth

On 3/10/23 07:41, Konrad Schneider wrote:


I am using deal.ii version 9.4 and am wondering what I did wrong here. Do you 
have any suggestions?


The VTK writer simply doesn't support writing tensor data. Use the VTU writer 
instead.


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/238bfb06-e8e6-88ce-295f-fa9f4f5ed78b%40colostate.edu.


[deal.II] output derived quanteties (gradients of vector valued solution like strain)

2023-03-10 Thread Konrad Schneider
Dear Forum,
I tried to follow the instructions of the DataPostprocessorTensor class to 
output the gradient of a vector valued solution. Therefore I tried to adopt 
step-8. However, I am getting the following error message:

An error occurred in line <5640> of file 
 in function
void dealii::DataOutBase::write_vtk(const 
std::vector >&, const 
std::vector >&, const 
std::vector, 
std::allocator >, 
dealii::DataComponentInterpretation::DataComponentInterpretation> >&, const 
dealii::DataOutBase::VtkFlags&, std::ostream&) [with int dim = 2; int 
spacedim = 2; std::ostream = std::basic_ostream]
The violated condition was: 
std::get<3>(nonscalar_data_range) != 
DataComponentInterpretation::component_is_part_of_tensor
Additional information: 
You are trying to use functionality in deal.II that is currently not
implemented. In many cases, this indicates that there simply didn't
appear much of a need for it, or that the author of the original code
did not have the time to implement a particular case. If you hit this
exception, it is therefore worth the time to look into the code to
find out whether you may be able to implement the missing
functionality. If you do, please consider providing a patch to the
deal.II development sources (see the deal.II website on how to
contribute).

I am using deal.ii version 9.4 and am wondering what I did wrong here. Do 
you have any suggestions?
Best regards 
Konrad

-- 
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/a04ecfe4-3518-4253-930e-addb6f619fd4n%40googlegroups.com.
#include 
#include 
#include 
 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
 
#include 
#include 
#include 
 
#include 
#include 
 
#include 
 
#include 
#include 
#include 
#include 
 
#include 
#include 
 
#include 
#include 
 
namespace Step8
{
  using namespace dealii;
  
template 
class ElasticProblem{
  public:
ElasticProblem();
void run();
  
  private:
void setup_system();
void assemble_system();
void solve();
void refine_grid();
void output_results() const;
Triangulation triangulation;
DoFHandlerdof_handler;
FESystem fe;
AffineConstraints constraints;
SparsityPattern  sparsity_pattern;
SparseMatrix system_matrix;
Vector solution;
Vector system_rhs;
};
 
template 
void right_hand_side(const std::vector> &points,std::vector> &  values){
  AssertDimension(values.size(), points.size());
  Assert(dim >= 2, ExcNotImplemented());
  Point point_1, point_2;
  point_1(0) = 0.5;
  point_2(0) = -0.5;
  for (unsigned int point_n = 0; point_n < points.size(); ++point_n)
{
  if (((points[point_n] - point_1).norm_square() < 0.2 * 0.2) ||
  ((points[point_n] - point_2).norm_square() < 0.2 * 0.2))
values[point_n][0] = 1.0;
  else
values[point_n][0] = 0.0;

  if (points[point_n].norm_square() < 0.2 * 0.2)
values[point_n][1] = 1.0;
  else
values[point_n][1] = 0.0;
}
}

template 
ElasticProblem::ElasticProblem()
  : dof_handler(triangulation)
  , fe(FE_Q(1), dim)
{}
 
template 
void ElasticProblem::setup_system()
{
  dof_handler.distribute_dofs(fe);
  solution.reinit(dof_handler.n_dofs());
  system_rhs.reinit(dof_handler.n_dofs());

  constraints.clear();
  DoFTools::make_hanging_node_constraints(dof_handler, constraints);
  VectorTools::interpolate_boundary_values(dof_handler,
0,
Functions::ZeroFunction(dim),
constraints);
  constraints.close();

  DynamicSparsityPattern dsp(dof_handler.n_dofs(), 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);
}
 
template 
void ElasticProblem::assemble_system()
{
  QGauss quadrature_formula(fe.degree + 1);
  FEValues fe_values(fe,
  quadrature_formula,
  update_values | update_gradients |
  update_quadrature_points | update_JxW_values);
  const unsigned int dofs_per_cell = fe.n_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);

  std::vector lambda_values(n_q_points)