deal.ii step 49 debug error

73 views
Skip to first unread message

Nick Wang

unread,
Oct 29, 2020, 7:45:56 AM10/29/20
to deal.II User Group
Dear all, 
 
I try to run step-49 on my native windows, while debug error.
I find that the error emerges on that  
void grid_1()
{
  Triangulation<2> triangulation;

  GridIn<2> gridin;
  gridin.attach_triangulation(triangulation);
  std::ifstream f("example.msh");
  gridin.read_msh(f);

  print_mesh_info(triangulation, "grid-1.vtu");
}

I don't know why my debug error and I find the error maybe that
 gridin.read_msh(f);

If anyone else khow why please tell me.

Thank you!  

Wolfgang Bangerth

unread,
Oct 29, 2020, 11:24:51 AM10/29/20
to dea...@googlegroups.com

Nick,
We forgot to include two files in the 9.2 release, see
https://github.com/dealii/dealii/issues/10798
https://github.com/dealii/dealii/pull/10813
You need the example.msh file from here:
https://github.com/dealii/dealii/tree/master/examples/step-49

Best
W.

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

Nick Wang

unread,
Oct 29, 2020, 10:53:58 PM10/29/20
to deal.II User Group
 I replaced all the files in step-49, while still crashed during debugging
this is my code, I don't know why.

#include <deal.II/grid/tria.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/manifold_lib.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/grid_in.h>

#include <iostream>
#include <fstream>

#include <map>

using namespace dealii;

template <int dim>
void print_mesh_info(const Triangulation<dim>& triangulation,
    const std::string& filename)
{
    std::cout << "Mesh info:" << std::endl
        << " dimension: " << dim << std::endl
        << " no. of cells: " << triangulation.n_active_cells() << std::endl;

    {
        std::map<types::boundary_id, unsigned int> boundary_count;
        for (const auto& face : triangulation.active_face_iterators())
            if (face->at_boundary())
                boundary_count[face->boundary_id()]++;

        std::cout << " boundary indicators: ";
        for (const std::pair<const types::boundary_id, unsigned int>& pair :
            boundary_count)
        {
            std::cout << pair.first << "(" << pair.second << " times) ";
        }
        std::cout << std::endl;
    }

    std::ofstream out(filename);
    GridOut       grid_out;
    grid_out.write_vtu(triangulation, out);
    std::cout << " written to " << filename << std::endl << std::endl;
}

void grid_1()
{
    Triangulation<2> triangulation;

    GridIn<2> gridin;
    gridin.attach_triangulation(triangulation);
    std::ifstream f("example.msh");
    gridin.read_msh(f);

    print_mesh_info(triangulation, "grid-1.vtu");
}
int main()
{
    try
    {
        grid_1();
    }
    catch (std::exception& exc)
    {
        std::cerr << std::endl
            << std::endl
            << "----------------------------------------------------"
            << std::endl;
        std::cerr << "Exception on processing: " << std::endl
            << exc.what() << std::endl
            << "Aborting!" << std::endl
            << "----------------------------------------------------"
            << std::endl;

        return 1;
    }
    catch (...)
    {
        std::cerr << std::endl
            << std::endl
            << "----------------------------------------------------"
            << std::endl;
        std::cerr << "Unknown exception!" << std::endl
            << "Aborting!" << std::endl
            << "----------------------------------------------------"
            << std::endl;
        return 1;
    }
}
step-mesh.cc

Wolfgang Bangerth

unread,
Oct 29, 2020, 10:55:30 PM10/29/20
to dea...@googlegroups.com
On 10/29/20 8:53 PM, Nick Wang wrote:
>  I replaced all the files in step-49, while still crashed during debugging
> this is my code, I don't know why.

Nick -- did you also put the missing file in the directory in which you run
the executable? What is the concrete error message?

Nick Wang

unread,
Oct 29, 2020, 11:43:59 PM10/29/20
to deal.II User Group
yeah,  I also put the file in my exe.  but when I try to make the exe. 
it can't work well  and crash back .
I try to delete the step-49 grid 1 related  codes and it can work well , I get the vtu.

Nick Wang

unread,
Oct 29, 2020, 11:47:34 PM10/29/20
to deal.II User Group
I added a pause code to see where the problem is
I find when exe. this code and crash back
gridin.read_msh(f);

this is my code here 

void grid_1()
{
  std::string str("grid_1");
  std::cout << str << std::endl;
  std::system("pause");

  Triangulation<2> triangulation;
  std::system("pause");
  GridIn<2> gridin;
  std::system("pause");
  gridin.attach_triangulation(triangulation);
  std::system("pause");
  std::ifstream f("example.msh");
  str = "in file\n";
  std::cout << str << std::endl;
  std::system("pause");

  gridin.read_msh(f);

  print_mesh_info(triangulation, "grid-1.vtu");

Nick Wang

unread,
Oct 29, 2020, 11:50:24 PM10/29/20
to deal.II User Group

sorry,  After recompiling deal.II, it now works correctly.

Nick Wang

unread,
Oct 30, 2020, 3:05:04 AM10/30/20
to deal.II User Group
Thank you,  Bangerth ;
Best wishes!

Nick 

Reply all
Reply to author
Forward
0 new messages