A bug of visualization with VISIT

34 views
Skip to first unread message

Jiaqi Zhang

unread,
Feb 21, 2017, 11:32:12 PM2/21/17
to deal.II User Group
Hello,

I am not sure if this is the right place to report this.

In one of the following figures, the color plot doesn't math the contour plot, is this the problem with VISIT?

I am using DEAL.II 8.4.1.

void check_shape_functions(){
std::cout<<"checking shape functions:\n";
const unit degree = 2;
Triangulation<2>      triangulation;
GridGenerator::hyper_cube(triangulation, 0, 1, true);
FE_DGP<2>             fe(degree);
DoFHandler<2>         dof_handler(triangulation);
dof_handler.distribute_dofs (fe);

QGauss<2> quadrature(degree +1);
FEValues<2> fe_val(fe, quadrature, update_values | update_gradients | update_JxW_values | update_hessians |update_quadrature_points);

const unit dof_per_cell = fe.dofs_per_cell;
typename DoFHandler<2>::active_cell_iterator
cell = dof_handler.begin_active();

fe_val.reinit(cell);
const std::vector<Point<2>> &q_points = fe_val.get_quadrature_points();
unit q=0;
std::cout<<"at point "<<q_points[q]<<"\n";
for (unit i=0; i<dof_per_cell; ++i){
std::cout<<"i="<<i<<" val = "<< fe_val.shape_value(i,q)<<
" grad = "<<fe_val.shape_grad(i,q)<<
" gradgrad = "<< fe_val.shape_hessian(i,q)<<
"\n";

}

Vector<double> sol;
sol.reinit(dof_handler.n_dofs());
sol[0] = 1.02708;
sol[1] = 0.00341325;
sol[2] = 0.0261353;
sol[3] = 0.00341325;
sol[4] = -0.0589509;
sol[5] = 0.0261353;
DataOut<2> data_out;
data_out.attach_dof_handler (dof_handler);
data_out.add_data_vector (sol, "u", DataOut<2>::type_dof_data);
data_out.build_patches();
//output filename
std::ostringstream  filename;

filename << "test_bottom_right.vtk";
std::ofstream output (filename.str().c_str());
// data_out.write_vtu(output);
data_out.write_vtk (output);

}



Thanks,
Jiaqi
plottingBug-0002.png
plottingBug-0003.png

Wolfgang Bangerth

unread,
Feb 21, 2017, 11:39:41 PM2/21/17
to dea...@googlegroups.com
On 02/21/2017 09:32 PM, Jiaqi Zhang wrote:
>
> I am not sure if this is the right place to report this.
>
> In one of the following figures, the color plot doesn't math the contour plot,
> is this the problem with VISIT?

Can you explain how the way you created the two figures differ?

Visit visualizes things by splitting each quad into two along one of the two
diagonals, and then using a linear approximation on each triangle. These do
not necessarily correspond to the bilinear function that you are outputting,
and may be the difference between the pseudocolor plot and the isocontour plot
(neither of which are equal to the P2 function in deal.II).

You can probably get a better picture by providing a positive argument to the
build_patches() function.

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Jiaqi ZHANG

unread,
Feb 22, 2017, 8:41:54 AM2/22/17
to deal.II User Group, bang...@colostate.edu
Dear Prof. Bangerth,

Thanks for your reply.
Two figures come from two different Vectors.
The one that color plot doesn't match the contour plot is Solution1:
sol[0] = 1.02708;
sol[1] = 0.00341325;
sol[2] = 0.0261353;
sol[3] = 0.00341325;
sol[4] = -0.0589509;
sol[5] = 0.0261353;


while the other one is Solution2
sol[0] = 1.02708;
sol[1] = -0.00341325;
sol[2] = 0.0261353;
sol[3] = 0.00341325;
sol[4] = 0.0589509;
sol[5] = 0.0261353;
Soluiton2 is fine. For Solution1, I checked the result with MATLAB, the contour plot is right.
I also follow your instruction and tried data_out.build_patches(2). For Solution2, it is almost
the same, but Solution1 is very different from that when data_out.build_patches() is used. 
By the way, VISIT version is 2.10.3.


Thanks,
Jiaqi

在 2017年2月21日星期二 UTC-5下午11:39:41,Wolfgang Bangerth写道:
figure1.png
figure2.png

Bruno Turcksin

unread,
Feb 22, 2017, 9:13:29 AM2/22/17
to deal.II User Group, bang...@colostate.edu
Hi,

while it looks strange I don't think there is any problem. In plottingBug-0002.png, Visit only knows the value at the four vertices of the domain and then it tries to "fill" the domain with a possible solution. In figure1.png, you give Visit the values on 9 points and thus, it has more information on how to fill the domain. If you compare the two figures, you can see that the solution on the four vertices is the same. If you use data_out.build_patches(3), you will get another solution closer to what you expect. The reason why, it looks good on figure2 is because, like Wolfgang said, Visit split the domain on triangle and then does a linear approximation. In case 2, the triangles are aligned with the solution, while in case 1 there are not (the domain is split in two triangle with a common edge going from top left to bottom right).

Best,

Bruno

Jiaqi ZHANG

unread,
Feb 22, 2017, 9:43:01 AM2/22/17
to deal.II User Group, bang...@colostate.edu
Hey Bruno,

Thanks for your reply, that makes sense to me now.

Best,
Jiaqi

在 2017年2月22日星期三 UTC-5上午9:13:29,Bruno Turcksin写道:

Wolfgang Bangerth

unread,
Feb 22, 2017, 11:58:06 PM2/22/17
to dea...@googlegroups.com
On 02/22/2017 06:41 AM, Jiaqi ZHANG wrote:
> Soluiton2 is fine. For Solution1, I checked the result with MATLAB, the
> contour plot is right.
> I also follow your instruction and tried data_out.build_patches(2).

Try build_patches(6) or build_patches(10).

As I stated, (i) what you output is not what is used internally in deal.II,
and (ii) what Visit plots is not what you output. But with higher arguments to
build_patches, you get closer in both regards.

Jiaqi ZHANG

unread,
Feb 24, 2017, 4:08:18 PM2/24/17
to deal.II User Group, bang...@colostate.edu
Hey Prof. Bangerth,

Thanks for your help again, I understand now :)

Best,
Jiaqi

在 2017年2月22日星期三 UTC-5下午11:58:06,Wolfgang Bangerth写道:
Reply all
Reply to author
Forward
0 new messages