← Back to team overview

dolfin team mailing list archive

Re: [Question #153448]: Importing mesh and entities

 

Question #153448 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/153448

    Status: Open => Answered

Johan Hake proposed the following answer:
On Wednesday April 20 2011 10:53:14 B. Emek Abali wrote:
> Question #153448 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/153448
> 
>     Status: Answered => Open
> 
> B. Emek Abali is still having a problem:
> its all greek even to me after many minutes of trial and error :)
> 
> Thanks Johan, now I get the idea more better, it is a much better idea
> to store in separate files, two open problems arise
> 
> first: only one material is written out, are all the meshfunction in
> that data? probably yes!

Yes that should be the case. You can just open it in a text editor and you 
should be able to get a notion of what the stored values are. They come at the 
end of the XML file in the meshfunction section.

> second: Illegal xml row index 2 out of range of (0 -1) if I try to run
> MeshFunction('uint', mesh, 'Output_material.xml')

Take a look in your file and check how many values are defined in the value 
meshfunction section. It should be one for each cell. It almost looks like the 
meshfunction only comes with two values, and the mesh comes with many more 
cells. Note the different between the number of different values and the 
actuall number of values. The former is two, I guess, in your case.

> 1014
>     for i, matname in enumerate(materials):
> ...
> ...
>                 handler.add_entity_meshfunction(elemids.index(elemid), i)
> 
> so it looks like (as you assumed) 'uint' and then the range 0 and 1
> holds true for my data with two materials. Why tries MeshFunction to
> reach also the number 2 in mesh, is there sth. wrong in the header ?

As I mentioned above. When the MeshFunction is read in it needs to read all 
values from the mesh function which is more than two. That equals the number 
of cells in the mesh.

> 1007
>     for matname, elsetids in material2elsetids.items():
>         if matname not in materials:
>             handler.error("Unknown material %s referred to for element sets
> %s" % (matname, ", ".join(elsetids)))
>         num_entities += len(elsetids)
>     handler.start_meshfunction("material", 3, num_entities)
> 
> 
> may be len(elsetids) is 2 (I have two materials) but it should be starting
> from 0 so num_entities += len(elsetids)-1   kind of thing?
> 
> but programming is not my branch, what do You think Johan, any specific
> hope :)

Not sure, but it definately looks like bug in MeshConverter...

Johan

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.