On 19/10/2011 14:05, David Knezevic wrote:
> On 10/19/2011 07:41 AM, Matteo Semplice wrote:
>    
>> Using gmsh was indeed my first attempt, but something does not work here.
>> Consider the following geometry saved in squarewithhole.geo:
>> ---------
>> Point(1) = {0, 0, 0};
>> Point(2) = {0, 1, 0};
>> Point(3) = {1, 1, 0};
>> Point(4) = {1, 0, 0};
>> Point(5) = {.5, .2, 0};
>> Point(6) = {.2, .5, 0};
>> Point(7) = {.7, .5, 0};
>> Line(1) = {1, 4};
>> Line(2) = {4, 3};
>> Line(3) = {3, 2};
>> Line(4) = {2, 1};
>> Line(5) = {5, 7};
>> Line(6) = {7, 6};
>> Line(7) = {6, 5};
>> Line Loop(8) = {2, 3, 4, 1};
>> Line Loop(9) = {6, 7, 5};
>> Plane Surface(10) = {8, 9};
>> Physical Line("Dirichlet") = {2,3,4,1};
>> Physical Line("Neumann") = {6, 7, 5};
>> ----------
>> Either meshing with an interactive session of gmsh or with
>> $gmsh -2 squarewithole.geo
>> gives me a suarewithole.msh file, but then
>>
>> Mesh mesh;
>> std::cout<<  "read msh mesh..."<<std::endl;
>> GmshIO(mesh).read("squarewithole.msh");
>> std::cout<<  "done."<<std::endl;
>> mesh.print_info();
>> mesh.boundary_info->print_summary();
>>
>> gives the following output
>>
>> ==============
>> read msh mesh...
>> done.
>>   Mesh Information:
>>    mesh_dimension()=2
>>    spatial_dimension()=3
>>    n_nodes()=35
>>      n_local_nodes()=0
>>    n_elem()=0
>>      n_local_elem()=0
>>      n_active_elem()=0
>>    n_subdomains()=0
>>    n_processors()=1
>>    processor_id()=0
>>
>> Nodal Boundary conditions:
>> --------------------------
>>    (ID, number of nodes)
>>    (1, 28)
>>    (2, 7)
>> ==============
>>
>> So I get the correct number of boundary conditions, but the mesh has
>> no elements...
>>
>> What am I doing wrong?
>>      
>
> I believe once you have at least one physical in your .geo, then _only_
> the data associated with a physical gets written out to file. So, I
> think you need to add physicals for the "Surface" as well. (Note: this
> is related to gmsh, not to libMesh.)
>
> Does that work?
>
> David
>    
Well.... yes, but there are a couple of quirks:

1) The mesh must be initialized setting its dimension, like
     Mesh mesh(2);
since the Mesh constructor defauts to 1 and GmshIO::read_mesh chooses dim as
const unsigned int dim = mesh.mesh_dimension 
<http://libmesh.sourceforge.net/doxygen/classMeshBase.php#a81ce19df31062ba94d8fea90f050a649>();
and thus would not modify the mesh dimension.

2) mesh.prepare_for_use();
    is called after reading the mesh. I have no clue for this, but 
otherwise attempting to use the mesh complains about failing assertion 
mesh_is_prepared...

For the developers:
maybe both points could be made more prominent in the documentation of 
GmshIO::read? Something like:
"Note that for this method to work (in 2d and 3d) you have to set 
explicitly the mesh dimension prior to calling GmshIO::read and that 
Mesh::prepare_for_use() must be called after reading the mesh and before 
using it"

I think that the note is needed since the docs of the Mesh constructor 
is a bit misleading in saying:

libMesh::Mesh::Mesh ( unsigned int /dim/ = |1|) | [inline]|
Constructor. Takes |dim|, the dimension of the mesh. The mesh dimension 
can be changed (and may automatically be changed by mesh 
generation/loading) later.

Thanks a lot for your help!

Matteo

-- 
Matteo Semplice                         Dip. di Fisica e Matematica
Phone: 031-2386132                      Università dell'Insubria
Fax:   031-2386209                      Via Valleggio, 11
                                        22100 Como


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to