#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pygmsh as pg
import numpy as np


def generate():
    '''Pipe with double-ring enclosure, rotated in space.
    '''
    geom = pg.Geometry()

    R = pg.rotation_matrix([1, 1, 0], np.pi/6.0)
    geom.add_pipe(
            inner_radius=0.3,
            outer_radius=0.4,
            length=1.0,
            R=R,
            lcar=0.04
            )

    R = np.array([
        [0.0, 0.0, 1.0],
        [0.0, 1.0, 0.0],
        [1.0, 0.0, 0.0]
        ])
    geom.add_pipe(
            inner_radius=0.3,
            outer_radius=0.4,
            length=1.0,
            lcar=0.04,
            R=R,
            variant='circle_extrusion'
            )

    return geom, 0.5317080205627609


if __name__ == '__main__':
    import meshio
    geometry, vol = generate()
    out = pg.generate_mesh(geometry)
    meshio.write('pipes.vtu', *out)

@@ -189,16 +189,47 @@
 etry()%0A%0A
+    sqrt2on2 = 0.5*np.sqrt(2.)%0A
     R = 
@@ -252,12 +252,26 @@
 ix(%5B
-1, 1
+sqrt2on2, sqrt2on2
 , 0%5D
@@ -764,24 +764,25 @@
 , 0.
-5317080205627609
+43988203517453256
 %0A%0A%0Ai

update test