Preprocessing

Asked by Essi Colo

I need to create a mesh consisting in a trapezoid lying on a rectangle, but found no information about how to create meshes that are not single basic geometries. I'm guessing that most FeniCS users use external preprocessor / CAD / mesher for more complex geometries. Which software do you use? Why?

Regards,

S.-É. Parent
Canada

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

Revision history for this message
Anders Logg (logg) said :
#1

On Sun, May 06, 2012 at 03:35:37PM -0000, Serge-Étienne Parent wrote:
> New question #196252 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/196252
>
> I need to create a mesh consisting in a trapezoid lying on a rectangle, but found no information about how to create meshes that are not single basic geometries. I'm guessing that most FeniCS users use external preprocessor / CAD / mesher for more complex geometries. Which software do you use? Why?

Preprocessing is currently underdeveloped in FEniCS.

There's a jungle of different preprocessors that can be used for
different purposes or in combination. My favorite is Netgen which
unfortunately seems to no longer be maintained and it only handles 3D
(not 2D).

We are currently working on adding Netgen-like capabilities to FEniCS,
both as part of DOLFIN (C++ and Python) and as a GUI. This will be
based on CSG (Constructive Solid Geometry) using CGAL as the backend.
Basic primitives (box, cylinder etc) are now in place and can be
added, subtracted and meshed but quite a bit of development remains
before this can be merged into trunk. You can follow the progress here:

  https://code.launchpad.net/~dolfin-core/dolfin/dolfin-csg

There is currently a simple Python-based CSG interface available in
the DOLFIN Python interface (development version). Take a look at the
demo demo/undocumented/netgen/python/.

--
Anders

Revision history for this message
Essi Colo (essicolo) said :
#2

Note that using a custum export (bas) template, I could export a mesh created in GiD (http://www.gidhome.com) and import it into FeniCS. Here is the content of the bas file (GiD export template) for tetrahedrons.

*#FILE_EXTENSION .xml
*realformat "%-f"
<?xml version="1.0"?>
<dolfin xmlns:dolfin="http://fenicsproject.org">
  <mesh celltype="tetrahedron" dim="3">
    <vertices size="*npoin">
*loop nodes
      <vertex index="*operation(nodesnum-1)" x="*nodescoord(1)" y="*nodescoord(2)" z="*nodescoord(3)"/>
*end nodes
    </vertices>
    <cells size="*nelem">
*loop elems
      <tetrahedron index="*operation(elemsnum-1)" v0="*operation(elemsconec(1)-1)" v1="*operation(elemsconec(2)-1)" v2="*operation(elemsconec(3)-1)" v3="*operation(elemsconec(4)-1)" />
*end elems
    </cells>
  </mesh>
</dolfin>

Revision history for this message
Essi Colo (essicolo) said :
#3

Thanks Anders Logg, that solved my question.

Revision history for this message
Anders Logg (logg) said :
#4

Thanks, I've added this file now (as DOLFIN.bas) in the utils/gid
directory of DOLFIN. It might be useful for others.

--
Anders

On Wed, May 09, 2012 at 03:41:03PM -0000, Serge-Étienne Parent wrote:
> Question #196252 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/196252
>
> Serge-Étienne Parent posted a new comment:
> Note that using a custum export (bas) template, I could export a mesh
> created in GiD (http://www.gidhome.com) and import it into FeniCS. Here
> is the content of the bas file (GiD export template) for tetrahedrons.
>
> *#FILE_EXTENSION .xml
> *realformat "%-f"
> <?xml version="1.0"?>
> <dolfin xmlns:dolfin="http://fenicsproject.org">
> <mesh celltype="tetrahedron" dim="3">
> <vertices size="*npoin">
> *loop nodes
> <vertex index="*operation(nodesnum-1)" x="*nodescoord(1)" y="*nodescoord(2)" z="*nodescoord(3)"/>
> *end nodes
> </vertices>
> <cells size="*nelem">
> *loop elems
> <tetrahedron index="*operation(elemsnum-1)" v0="*operation(elemsconec(1)-1)" v1="*operation(elemsconec(2)-1)" v2="*operation(elemsconec(3)-1)" v3="*operation(elemsconec(4)-1)" />
> *end elems
> </cells>
> </mesh>
> </dolfin>
>

Revision history for this message
Essi Colo (essicolo) said :
#5

What do the modifiers refer to in subdomains.xml.gz?

The mesh_value_collection tag contains three modifiers: type, dim and size.
* I suppose that type is the type of index, i.e. unsigned integers: uint
* I also suppose that the size is the number of cells, right?
* dim might be a short for "dimension", but the example is in 2D and in the xml, it is specified that dim="1"

In the value tag, there are specifications for cell_index, local_entry and value.
* cell_index refers to the index in the mesh definition, right?
* local_entry seems to me to refer to the subdomain tag.
* As for value, I don't know

Thanks for the info.

Revision history for this message
Anders Logg (logg) said :
#6

On Tue, May 15, 2012 at 02:15:44PM -0000, Serge-Étienne Parent wrote:
> Question #196252 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/196252
>
> Status: Solved => Open
>
> Serge-Étienne Parent is still having a problem:
> What do the modifiers refer to in subdomains.xml.gz?
>
> The mesh_value_collection tag contains three modifiers: type, dim and size.
> * I suppose that type is the type of index, i.e. unsigned integers:
> uint

Yes.

> * I also suppose that the size is the number of cells, right?

No, it's the number of values. Values may be assigned to a subset.

> * dim might be a short for "dimension", but the example is in 2D and in the xml, it is specified that dim="1"

dim is the dimension of the entities for which you specify the
values, so 1 means edges.

> In the value tag, there are specifications for cell_index, local_entry and value.
> * cell_index refers to the index in the mesh definition, right?
> * local_entry seems to me to refer to the subdomain tag.
> * As for value, I don't know

cell_index is the cell associated with the entity on which the value
is specified (so for a facet, the index of a cell to which the facet
belongs).

local_entity is the index of the entity relative to the local cell (so
for a facet whether it is facet 0, 1, 2 or 4 of the cell indicated by
cell_index.

value is simply the value associated to that entity.

--
Anders

Revision history for this message
Johan Hake (johan-hake) said :
#7

A nice way of better understanding the values is to store a mesh with
some predefined facet and cell domains.

   mesh = UnitCube(2,2,2)
   facet_domain = AutoSubDomain(lambda x,on_boundary:x[0]<=0.5 \
                  and on_boundary)
   cell_domain = AutoSubDomain(lambda x,on_boundary:x[0]<=0.5)
   facet_domain.mark_facets(mesh, 1)
   cell_domain.mark_cells(mesh, 2)
   File("mesh.xml") << mesh

Then you will see how the meshvalue collections are stored.

Johan

On 05/19/2012 02:01 PM, Anders Logg wrote:
> Question #196252 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/196252
>
> Status: Open => Answered
>
> Anders Logg proposed the following answer:
> On Tue, May 15, 2012 at 02:15:44PM -0000, Serge-Étienne Parent wrote:
>> Question #196252 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/196252
>>
>> Status: Solved => Open
>>
>> Serge-Étienne Parent is still having a problem:
>> What do the modifiers refer to in subdomains.xml.gz?
>>
>> The mesh_value_collection tag contains three modifiers: type, dim and size.
>> * I suppose that type is the type of index, i.e. unsigned integers:
>> uint
>
> Yes.
>
>> * I also suppose that the size is the number of cells, right?
>
> No, it's the number of values. Values may be assigned to a subset.
>
>> * dim might be a short for "dimension", but the example is in 2D and
> in the xml, it is specified that dim="1"
>
> dim is the dimension of the entities for which you specify the
> values, so 1 means edges.
>
>> In the value tag, there are specifications for cell_index, local_entry and value.
>> * cell_index refers to the index in the mesh definition, right?
>> * local_entry seems to me to refer to the subdomain tag.
>> * As for value, I don't know
>
> cell_index is the cell associated with the entity on which the value
> is specified (so for a facet, the index of a cell to which the facet
> belongs).
> local_entity is the index of the entity relative to the local cell (so
> for a facet whether it is facet 0, 1, 2 or 4 of the cell indicated by
> cell_index.
>
> value is simply the value associated to that entity.
>
> --
> Anders
>

Revision history for this message
Essi Colo (essicolo) said :
#8

Thanks for the info, but I will not be able to get trhough it without exhaustive documentation. Is the xml mesh format documented somewhere?

Revision history for this message
Anders Logg (logg) said :
#9

On Sun, Jun 03, 2012 at 01:50:45AM -0000, Serge-Étienne Parent wrote:
> Question #196252 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/196252
>
> Status: Answered => Open
>
> Serge-Étienne Parent is still having a problem:
> Thanks for the info, but I will not be able to get trhough it without
> exhaustive documentation. Is the xml mesh format documented somewhere?

Yes, in the book and in the many demos.

--
Anders

Can you help with this problem?

Provide an answer of your own, or ask Essi Colo for more information if necessary.

To post a message you must log in.