def gmsh_grid_adapt2D(out_dim=(100.0, 100.0), in_dim=(50.0, 50.0), out_res=
    (10.0, 10.0), in_res=(5.0, 5.0), out_pos=(0.0, 0.0), in_pos=(25.0, 25.0
    ), z_pos=0.0):
    """Generate the 2D mesh adapter."""
    try:
        from pygmsh import Geometry
    except ImportError:
        from pygmsh.built_in import Geometry
    geo = Geometry()
    code = ['outx = {};'.format(out_dim[0]), 'outy = {};'.format(out_dim[1]
        ), 'inx = {};'.format(in_dim[0]), 'iny = {};'.format(in_dim[1]),
        'grioutx = {};'.format(out_res[0]), 'griouty = {};'.format(out_res[
        1]), 'grix = {};'.format(in_res[0]), 'griy = {};'.format(in_res[1]),
        'obx = {};'.format(out_pos[0]), 'oby = {};'.format(out_pos[1]),
        'ibx = {};'.format(in_pos[0]), 'iby = {};'.format(in_pos[1]),
        'bz = {};'.format(z_pos),
        'Point(1) = {obx,       oby,        bz,         grioutx};',
        'Point(2) = {obx+outx,  oby,        bz,         grioutx};',
        'Point(3) = {obx+outx,  oby+outy,   bz,         grioutx};',
        'Point(4) = {obx,       oby+outy,   bz,         grioutx};',
        'Point(9) =  {ibx,      iby,        bz,         grix};',
        'Point(10) = {ibx+inx,  iby,        bz,         grix};',
        'Point(11) = {ibx+inx,  iby+iny,    bz,         grix};',
        'Point(12) = {ibx,      iby+iny,    bz,         grix};',
        'Line(1) = {1, 2}; //s top', 'Line(2) = {2, 3}; //e top',
        'Line(3) = {3, 4}; //n top', 'Line(4) = {4, 1}; //w top',
        'Line(13) = {9, 10}; //s top', 'Line(14) = {10, 11}; //e top',
        'Line(15) = {11, 12}; //n top', 'Line(16) = {12, 9}; //w top',
        'Line Loop(26) = {1, 2, 3, 4};',
        'Line Loop(27) = {13, 14, 15, 16};',
        'Plane Surface(28) = {26, 27};',
        'Transfinite Line{1, 3} = outx/grioutx + 1;',
        'Transfinite Line{2, 4} = outy/griouty + 1;',
        'Transfinite Line{13, 15} = inx/grix + 1;',
        'Transfinite Line{14, 16} = iny/griy + 1;']
    geo.add_raw_code(code)
    return geo
