~vcs-imports/escript-finley/trunk

« back to all changes in this revision

Viewing changes to dudley/py_src/readers.py

  • Committer: jfenwick
  • Date: 2010-10-11 01:48:14 UTC
  • Revision ID: svn-v4:77569008-7704-0410-b7a0-a92fef0b09fd:trunk:3259
Merging dudley and scons updates from branches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
########################################################
 
3
#
 
4
# Copyright (c) 2003-2010 by University of Queensland
 
5
# Earth Systems Science Computational Center (ESSCC)
 
6
# http://www.uq.edu.au/esscc
 
7
#
 
8
# Primary Business: Queensland, Australia
 
9
# Licensed under the Open Software License version 3.0
 
10
# http://www.opensource.org/licenses/osl-3.0.php
 
11
#
 
12
########################################################
 
13
 
 
14
__copyright__="""Copyright (c) 2003-2010 by University of Queensland
 
15
Earth Systems Science Computational Center (ESSCC)
 
16
http://www.uq.edu.au/esscc
 
17
Primary Business: Queensland, Australia"""
 
18
__license__="""Licensed under the Open Software License version 3.0
 
19
http://www.opensource.org/licenses/osl-3.0.php"""
 
20
__url__="https://launchpad.net/escript-finley"
 
21
 
 
22
"""
 
23
some mesh handling
 
24
 
 
25
:var __author__: name of author
 
26
:var __licence__: licence agreement
 
27
:var __url__: url entry point on documentation
 
28
:var __version__: version
 
29
:var __date__: date of the version
 
30
"""
 
31
 
 
32
__author__="Lutz Gross, l.gross@uq.edu.au, Joel Fenwick"
 
33
 
 
34
from esys.escript import *
 
35
from esys.pycad.gmsh import Design as GMSHDesign
 
36
from dudleycpp import ReadGmsh
 
37
 
 
38
def MakeDomain(design,integrationOrder=-1, reducedIntegrationOrder=-1, optimizeLabeling=True, useMacroElements=False):
 
39
    """
 
40
    Creates a Dudley `Domain` from a `esys.pycad.design.Design` object.
 
41
    Currently only gmsh is supported.
 
42
 
 
43
    :param design: the geometry
 
44
    :type design: `esys.pycad.design.Design`
 
45
    :param integrationOrder: integration order. If -1 the default is used.
 
46
    :type integrationOrder: ``int``
 
47
    :param reducedIntegrationOrder: reduced integration order. If -1 the
 
48
                                    default is used.
 
49
    :type reducedIntegrationOrder: ``int``
 
50
    :param optimizeLabeling: if set the labeling of the mesh nodes is optimized
 
51
    :type optimizeLabeling: ``bool``
 
52
    :param useMacroElements: uses macro elements.
 
53
    :type useMacroElements: ``bool``
 
54
    :return: the Finley domain defined by the design
 
55
    :rtype: `Domain`
 
56
    """
 
57
    if useMacroElements:
 
58
        raise TypeError("Dudley does not support macro elements")
 
59
    if isinstance(design, GMSHDesign):
 
60
        design.setElementOrder(1)
 
61
        ff=design.getFileFormat()
 
62
        design.setFileFormat(design.GMSH)
 
63
        mshname=design.getMeshHandler()
 
64
        dom = ReadGmsh(mshname,
 
65
                       design.getDim(),
 
66
                       integrationOrder,
 
67
                       reducedIntegrationOrder,
 
68
                       optimizeLabeling,
 
69
                       useMacroElements)
 
70
        design.setFileFormat(ff)
 
71
    else:
 
72
        raise TypeError("Dudley does not support %s designs."%design.__class__.__name__)
 
73
    # fill in the tag map
 
74
    design.getTagMap().passToDomain(dom)
 
75
    return dom
 
76