Yufei:
I looked at your input file, and the error message is correct. The relevant part of 3D.mphtxt looks as follows:

```
1 # number of element types

# Type #0

3 edg # type name


2 # number of vertices per element
24584 # number of elements
# Elements
0 1
2 1
...
```

What this part of the file says is "there is only one type of cells", "all cells have type 3 (edges)" where edge=1d line segments, and "here are 24584 cells of this type", with each of the line segments described by two vertex numbers.

In other words, the file you saved only contains line segments in 3d, but no quadrilaterals or triangles. You'll have to figure out how to save the information you really want, namely cells, rather than just these edges.

Best
 W.



On 3/10/24 23:50, Yufei Fang wrote:
*** Caution: EXTERNAL Sender ***

Sir Chen, thanks for your reply,
I changed the code to
"
Triangulation<2,3> triangulation;
GridIn<2,3> grid_in;
"
However, it still doesn't work, and the error message is the same as before:
"
An error occurred in line <2264> of file </home/fomebody/dealii-9.5.1/source/grid/tria.cc> in function     static void dealii::internal::TriangulationImplementation::Implementation::create_triangulation(const std::vector<dealii::Point<spacedim> >&, const std::vector<dealii::CellData<dim> >&, const dealii::SubCellData&, dealii::Triangulation<dim, spacedim>&) [with int dim = 2; int spacedim = 3]
The violated condition was:
     cells.size() > 0
Additional information:
     No cells given
"
😭
Here is my .mphtxt, can you help me check where the problem is?

On Friday, March 8, 2024 at 3:57:14 PM UTC+8 hkch...@gmail.com wrote:

    Hi Yufei Fang,

    changing the origin code to the followeing will be  ok.


    void run3D()
    {
    Triangulation<2,3> triangulation;
    GridIn<2,3> grid_in;

    grid_in.attach_triangulation(triangulation);
    std::ifstream input_file("../resource/3D.mphtxt");
    grid_in.read_comsol_mphtxt(input_file);

    std::ofstream out("grid3D.vtk");
    GridOut       grid_out;
    grid_out.write_vtk(triangulation, out);
    std::cout << "Grid written to grid.vtk" << std::endl;
    }

    int main()
    {
    run3D();
    }


    Chen

    Yufei Fang <sjt...@gmail.com> 于2024年3月6日周三 17:48写道:

        I'm trying to import the mesh from COMSOL to triangulation.

        comsol_4IaAE9lQVf.png
        it's an air-supported membrane structure, the mesh consists of free
        triangular or free quad. both are failed.
        *here is my code:*
        "
        void run3D()
        {
        Triangulation<3> triangulation;
        GridIn<3> grid_in;
        grid_in.attach_triangulation(triangulation);
        std::ifstream input_file("../resource/3D.mphtxt");
        grid_in.read_comsol_mphtxt(input_file);

        std::ofstream out("grid3D.vtk");
        GridOut       grid_out;
        grid_out.write_vtk(triangulation, out);
        std::cout << "Grid written to grid.vtk" << std::endl;
        }

        int main()
        {
        run3D();
        }
        "
        the error is:
        "
        An error occurred in line <2264> of file
        </home/fomebody/dealii-9.5.1/source/grid/tria.cc> in function
             static void
        dealii::internal::TriangulationImplementation::Implementation::create_triangulation(const 
std::vector<dealii::Point<spacedim> >&, const std::vector<dealii::CellData<dim> >&, const 
dealii::SubCellData&, dealii::Triangulation<dim, spacedim>&) [with int dim = 3; int spacedim = 3]
        The violated condition was:
             cells.size() > 0
        Additional information:
             No cells given
        "
        my question is:
        1. how to import such a mesh into dealii;
        2. the tutorial said triangular and tetrahedral cannot be imported in
        dealii, but i can import triangular or tetrahedral element by
        gridin_COMSOL_mphtxt, is it controdicory?

--
        The deal.II project is located at http://www.dealii.org/
        <http://www.dealii.org/>
        For mailing list/forum options, see
        https://groups.google.com/d/forum/dealii?hl=en
        <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+un...@googlegroups.com.

        To view this discussion on the web visit
        
https://groups.google.com/d/msgid/dealii/6e0e1c38-5aef-4b9a-bddc-a14a8bc07f0bn%40googlegroups.com
 
<https://groups.google.com/d/msgid/dealii/6e0e1c38-5aef-4b9a-bddc-a14a8bc07f0bn%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
The deal.II project is located at http://www.dealii.org/ <http://www.dealii.org/> For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en <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 <mailto:dealii+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/065ad604-64c8-45c2-bad3-9df142c870f2n%40googlegroups.com <https://groups.google.com/d/msgid/dealii/065ad604-64c8-45c2-bad3-9df142c870f2n%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
------------------------------------------------------------------------
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/271248ce-10e2-4079-89d5-ff5136a31aaf%40colostate.edu.

Reply via email to