Philip Simons, I wrote some code into Gmsh to handle hex to tet interfaces. The interfaces can be accomplished with extruded or transfinite volumes. If I had the time I would improve the work I have done--I know a way to accomplish the interface with better element quality and more simplicity. Still, what is there now will give you a hex to tet interface.
I've attached a set of (poorly written) instructions to help you use the interface. You'll have to download the nightly build of Gmsh to use the features. Also, I've attached an example file that shows the Quad To Tri interfaces in action. Basically, the two methods: 1. Extrusions. You can extrude quads as hexahedra and apply the QuadTriSngl or QuadTriDbl keywords (as shown in the attached instructions). This will divide all the faces of the extrusion (except for the source surface) into triangles and the underlying elements are divided into pyramids and/or prisms accordingly to create the interface. So, to interface a surface to tets, extrude a few layers from a quad face with the QuadTri options and you'll cover your quads with an interface to triangles. So you know, the QuadTriSngl method is more of an academic exercise and gives the lowest element quality. The Dbl method gives better quality elements but requires two extrusion layers. Also, read the instructions about how side lateral interfaces are handled. For instance, you might not want to divide the laterals of an extrusion and there are options to prevent that. 2. Transfinite Volumes. This is conceptually easier than the extrusion approach. Simply create a transfinite volume and arbitrarily leave some faces NOT recombined. Then, use the QuadTri keyword on the volume (see instructions). The elements in the volume adjacent to any divided surface will be divided into pyramids and the rest of the elements will be hexahedra. Anyway, have fun experimenting with this. And if something goes wrong, please email me! (Note that there is a mild bug when you extrude an ustructured quad-triangle surface and try to use QuadTriSngl on a single extruded layer...you'll get a lot of error messages, but the mesh will still be valid. Again, just use QuadTriDbl or the transfinite method for best results, anyway). -Trevor Strickler ---------- Forwarded message ---------- > From: Philip Simons <[email protected]> > To: [email protected] > Cc: > Date: Mon, 30 Jan 2012 14:04:27 +0100 > Subject: [Gmsh] connecting structured to unstructured meshed volumes in 3D > Hello all, > > I saw several messages in the archive stating the (im)possibility to > connect structured volumes (HEX elements) to unstructured ones (TET > elements). I succeeded in coupling layered wedge (PRISM) elements to TET > elements, which already is quite nice for CFD boundary layers, but does > anyone know the status of the HEX to TET coupling, where pyramids should be > inserted in the unstructured volume to make the connections from QUADS > (side of the structured volume) to TETs? > > thanks, > > Philip > > > >
INFORMATION FOR QUADTRI PATCH VERSION 1.0 (May 31, 2011) All new code is written by Trevor S. Strickler <[email protected]> Trevor S. Strickler hereby transfers copyright of QuadTri files to Christophe Geuzaine and J.-F. Remacle with the understanding that his contribution shall be cited appropriately. All code reused from Gmsh is Copyright (C) 1997-2011 C. Geuzaine, J.-F. Remacle Gmsh is available at: www.geuz.org/gmsh See licensing information below. CONTENTS: 1. Introduction 2. Copyright and Licensing 3. How QuadTri works. a. For Transfinite Volumes. b. For Structured Extrusions. 4. Invoking QuadTri. a. For Transfinite Volumes. b. For Structured Extrusions. 5. How to modify Gmsh to use QuadTri. 6. Other information/suggestions. INTRODUCTION ---------------------------- The Quadrangle-to-Triangle interface allows the user to conformally subdivide elements along the top and lateral surfaces of an extruded, structured mesh region OR along any boundary of a transfinite mesh region so that the region has all triangles on these boundaries. Both the 2D surface elements and the 3D volume elements adjacent to the boundary surfaces are divided. This allows the convenient connection of regions with quadrangle-faced mesh elements to regions (structured or unstructured) that may be all tetrahedra. COPYRIGHT AND LICENSING ----------------------- QuadTri was written by Trevor S. Strickler <[email protected]>. It is written as an addition to the meshing code Gmsh, which is copyrighted by C. Geuzaine and J.-F. Remacle and distributed under the GNU Public License version 2 with an exception. QuadTri is released under the GNU Public License Version 2 with the SAME exceptions as for the current release of Gmsh as of April 21, 2011. See LICENSE.txt for more information. Trevor S. Strickler hereby transfers copyright of QuadTri files to Christophe Geuzaine and J.-F. Remacle with the understanding that his contribution shall be cited appropriately. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, Version 2, as published by the Free Software Foundation, or (at your option) any later version, with or without the exception given in the LICENSE.txt file supplied with this code and with Gmsh. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. HOW QUADTRI WORKS ----------------- The Quadrangle-to-Triangle interface (from here on referred to as QuadTri) allows the user to conformally subdivide elements along the top and lateral surfaces of an extruded, structured mesh region OR along any boundary of a transfinite mesh region so that the region has all triangles on these boundaries. Unstructured or structured tetrahedral regions can then be interfaced to these boundaries. QuadTri accomplishes by using a combination of pyramids, prisms, and tetrahedra to divide hexahedra, prisms, and possibly pyramids. a. FOR TRANSFINITE VOLUMES: The QuadTri algorithm for transfinite volumes is very simple. Any mesh elements in the transfinite volume that are adjacent to unrecombined, 2D boundary surface elements will be divided with a body-centered internal vertex, conformal to the surface mesh. Any mesh elements NOT needing division will be meshed as hexahedra or prisms. A transfinite volume with any combination of recombined and un-recombined transfinite boundary surfaces is valid when meshed with TransfQuadTri. This method works for both 5- and 6-sided transfinite volumes. b. STRUCTURED EXTRUSIONS: The QuadTri algorithm for structured extrusions ( from here on referred to as 'QuadTriExtruded') tries to make as few divisions as possible in order to keep the element number as low as possible. QuadTriExtruded works for regions having source surfaces that are all quads, all triangles, or mixed. Also, the user can choose to keep lateral boundaries recombined (where possible) and only divide the top surface into triangles. For structured extrusions, QuadTriExtruded is 'smart' about the boundary requirements of neighboring regions and will resolve lateral surface mesh conflicts where ever necessary. In other words, do not worry about conformality with lateral neighbors--QuadTriExtruded will not divide a lateral surface that must remain meshed as quadrangles, nor will it recombine a lateral surface that must remain as triangles. NOTE: The 'top' surface of a structured region is always divided by QuadTriExtruded. Also, laterals between two QuadTriExtruded regions are always recombined. There are actually two main QuadTriExtruded methods available to the user: the single-layer method and the double-layer method. Single-Layer method: This method attempts to subdivide the elements in an extruded, structured mesh region that are adjacent to the region's top and lateral surfaces WITHOUT adding any additional vertices. However, if, due to certain lateral boundary conditions, an element cannot be divided without additional vertices, an internal vertex is created at the vertex-based centroid of the element. The element is then divided using that vertex. When an internal vertex is created, a warning message is sent for each to alert the user. Because this subdivision method only requires one layer to interface quad faces to triangles, it is called the single-layer method. Double-Layer method: This method attempts to subdivide the elements in an extruded, structured mesh region that are adjacent to the region's top and lateral surfaces by creating additional face-centered vertices for each of the elements. The face-centered vertices are added at the centroids of horizontal, non-boundary element faces to allow the creation of pyramids with apexes at the added vertices ('horizontal' is referenced to the extrusion direction, which is vertical). This method requires that there be at least TWO layers in the extrusion so that these face-centered vertices are not added on external boundaries of the region. For this reason, the method is called the double-layer method. For extruded regions with more than two layers, there may be mesh elements having a face-centered vertex in both the top and bottom face. These elements are divided by creating prisms around a central 'axis' formed by the two face-centered vertices. These prisms may themselves be divided depending on lateral boundary conditions. There are advantages and disadvantages to each of these two methods: The single-layer method creates the least number of mesh elements, but the quality of the elements is slightly worse than for the double- layer method. Also, the single-layer method, in rare instances, may be unable to divide an element without adding a body-centered vertex; however, this is rare and *should* only be possible when the source surface has 2D elements with all vertices on a boundary AND if there are both recombined and unrecombined lateral surfaces in the extrusion--but even then it is unlikely. Even if a new vertex is created by the single-layer method, the mesh will still be conformal-- but some users may not want an irregular vertex pattern in their structured extrusions. INVOKING QUADTRI ---------------- a. FOR TRANSFINITE VOLUMES: The transfinite QuadTri algorithm may be applied by using the following command: TransfQuadTri { expression-list } | "*"; Where 'expression-list' is a list of volume numbers to apply QuadTri to. "*" is used to apply TransfQuadTri to all existing volumes. A transfinite volume with any combination of recombined and un-recombined transfinite boundary surfaces is valid when meshed with TransfQuadTri. When applied to non-Transfinite volumes, TransfQuadTri has NO effect on those volumes. b. FOR STRUCTURED EXTRUSIONS: QuadTri for structured extrusions (QuadTriExtruded) is invoked by using the appropriate keywords in the 'extrude-list layers' part of an 'Extrude' command for structured meshes. (see Gmsh manual for description of the 'Extrude' command for structured meshes). Note that the QuadTriExtruded commands only have an effect for the extrusion of a surface to create a region, AND only if the 'Recombine' option is used (there is no point in applying QuadTriExtruded to a fully subdivided region). The keywords (note that only the first letter must be capitalized): QuadTriSngl; (for the single-layer method) QuadTriDbl; (for the double-layer method) Permissible variants (shown here as regular expressions (regexp) ): Quad[tT]ri[sS]ngl; Quad[tT]ri[dD]bl; Optionally, for each of the two QuadTriExtruded methods, the user may choose to keep lateral surfaces of the region recombined (where possible) by using: QuadTriSngl Recomblaterals; QuadTriDbl Recomblaterals; Examples of Usage: single-layer method, recombine laterals: Extrude {0.0, 0.0, 1.0} {Surface {surf_num}; Layers {10}; Recombine; QuadTriSngl Recomblaterals; }; double-layer method, not using the recombine laterals option: Extrude {0.0, 0.0, 1.0} {Surface {surf_num}; Layers {10}; QuadTriDbl; Recombine; }; Let it be repeated: If the QuadTriExtruded region shares a lateral with another region, QuadTriExtruded will only divide (or not divide) that surface in a way that does not create conflicts between the regions, regardless of whether Recomblaterals was used or not. In other words, do not worry about conformality with lateral neighbors--QuadTriExtruded will not divide a lateral surface that must remain quadrangles, nor will it recombine a lateral surface that must remain triangles. HOW TO MODIFY GMSH TO USE QUADTRI --------------------------------------- One may simply merge the other files distributed with the QuadTri patch directly into the appropriate Gmsh directories and the changes to the source will be complete. The user can then compile the source as for the regular Gmsh version. Be careful not to get the /Mesh/CMakeLists.txt file confused with the CMakeLists.txt file in other directories!!!! 7. OTHER INFORMATION/SUGGESTIONS Volume sign of elements: Does it matter if the volume sign of the elements is positive or negative? I hope not. It is hard to make sure the elements are created with negative volume sign, and post-creation revert() costs execution speed. std::vector allocation: I have given some thought to memory management with respect to the allocation of certain std::vectors in Gmsh. After some testing, I found that execution time can be reduced for structured mesh generation by as much as 20% in some cases if certain vectors are allocated manually instead of automatically when the capacity is exceeded. Also, automatic reallocation sometimes allocates twice as much memory as needed in the end. The std::vectors I looked at include the hexahedra, prisms, pyramids, and tetrahedra pointer vectors. Also, the std::map _extrudedElements in ExtrudeParams::ExtrusionElementMap could be allocated and filled all at once AFTER all elements are created for a geometrical entity. I have found this does increase execution speed. Please consider the following function for ExtrudeParams: ***************************************** // This is a member function for the element map in ExtrudeParams. // This allows insertion of a whole vector at once. void ExtrudeParams:: ExtrusionElementMap::addExtrudedElemVector(MElement* source, std::vector<MElement*> *extrudedVector ) { std::map<MElement*,std::vector<MElement*> >::iterator it = _extrudedElements.find(source); if(it != _extrudedElements.end()){ it->second.reserve(it->second.size()+extrudedVector->size()); it->second.insert(it->second.end(), extrudedVector->begin(), extrudedVector->end()); } else { int totalNbElems = 0; for (int i = 0; i <_parent->mesh.NbLayer;i++) totalNbElems += _parent->mesh.NbElmLayer[i]; unsigned int new_cap = totalNbElems > extrudedVector->size() ? totalNbElems : extrudedVector->size(); // automatically creates source key in map (single argument 'insert' is also logarithmic too, just like this). std::vector<MElement*> *vec = &(_extrudedElements[source]); vec->reserve( new_cap ); vec->insert( vec->end(), extrudedVector->begin(), extrudedVector->end()); } } ******************************************[Gmsh Main Directory]/Geo/ExtrudeParams.cpp
tunnel_test.geo
Description: Binary data
_______________________________________________ gmsh mailing list [email protected] http://www.geuz.org/mailman/listinfo/gmsh
