/[escript]/trunk/finley/py_src/readers.py
ViewVC logotype

Annotation of /trunk/finley/py_src/readers.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (hide annotations)
Mon Jan 20 03:37:18 2020 UTC (12 months ago) by uqaeller
File MIME type: text/x-python
File size: 4309 byte(s)
Updated the copyright header.


1 jfenwick 3912 # -*- coding: utf-8 -*-
2 ksteube 1809
3 jfenwick 3981 ##############################################################################
4 ksteube 1312 #
5 uqaeller 6939 # Copyright (c) 2003-2020 by The University of Queensland
6 jfenwick 3981 # http://www.uq.edu.au
7 ksteube 1312 #
8 ksteube 1809 # Primary Business: Queensland, Australia
9 jfenwick 6112 # Licensed under the Apache License, version 2.0
10     # http://www.apache.org/licenses/LICENSE-2.0
11 ksteube 1312 #
12 jfenwick 3981 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
13 jfenwick 4657 # Development 2012-2013 by School of Earth Sciences
14     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
15 uqaeller 6939 # Development from 2019 by School of Earth and Environmental Sciences
16 jfenwick 3981 #
17     ##############################################################################
18 ksteube 1312
19 sshaw 5706 from __future__ import print_function, division
20    
21 uqaeller 6939 __copyright__="""Copyright (c) 2003-2020 by The University of Queensland
22 jfenwick 3981 http://www.uq.edu.au
23 ksteube 1809 Primary Business: Queensland, Australia"""
24 jfenwick 6112 __license__="""Licensed under the Apache License, version 2.0
25     http://www.apache.org/licenses/LICENSE-2.0"""
26 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
27 ksteube 1809
28 gross 934 """
29 caltinay 2180 some mesh handling
30 gross 934
31 jfenwick 2625 :var __author__: name of author
32     :var __licence__: licence agreement
33     :var __url__: url entry point on documentation
34     :var __version__: version
35     :var __date__: date of the version
36 gross 934 """
37    
38     __author__="Lutz Gross, l.gross@uq.edu.au"
39    
40     from esys.pycad.gmsh import Design as GMSHDesign
41 jfenwick 4945 from .factorywrappers import ReadGmsh, ReadMesh
42     from .finleycpp import LoadMesh
43 gross 934
44 gross 2748 def MakeDomain(design,integrationOrder=-1, reducedIntegrationOrder=-1, optimizeLabeling=True, useMacroElements=False):
45 caltinay 2180 """
46 jfenwick 2625 Creates a Finley `Domain` from a `esys.pycad.design.Design` object.
47 caltinay 2180 Currently only gmsh is supported.
48 gross 934
49 jfenwick 2625 :param design: the geometry
50     :type design: `esys.pycad.design.Design`
51     :param integrationOrder: integration order. If -1 the default is used.
52     :type integrationOrder: ``int``
53     :param reducedIntegrationOrder: reduced integration order. If -1 the
54 caltinay 2180 default is used.
55 jfenwick 2625 :type reducedIntegrationOrder: ``int``
56     :param optimizeLabeling: if set the labeling of the mesh nodes is optimized
57     :type optimizeLabeling: ``bool``
58 gross 2748 :param useMacroElements: uses macro elements.
59     :type useMacroElements: ``bool``
60 jfenwick 2625 :return: the Finley domain defined by the design
61     :rtype: `Domain`
62 caltinay 2180 """
63     if isinstance(design, GMSHDesign):
64 gross 2748 if useMacroElements: design.setElementOrder(2)
65 gross 2717 ff=design.getFileFormat()
66     design.setFileFormat(design.GMSH)
67 caltinay 2180 mshname=design.getMeshHandler()
68     dom = ReadGmsh(mshname,
69     design.getDim(),
70     integrationOrder,
71     reducedIntegrationOrder,
72 gross 2748 optimizeLabeling,
73     useMacroElements)
74 gross 2717 design.setFileFormat(ff)
75 caltinay 2180 else:
76     raise TypeError("Finley does not support %s designs."%design.__class__.__name__)
77     # fill in the tag map
78     design.getTagMap().passToDomain(dom)
79     return dom
80    
81 jfenwick 3912 def GetMeshFromFile(filename, **kwargs):
82     """
83     Reads a mesh from a file, determines the reader to use based on the file
84     extension. All cases require a filename and gmsh files require a number
85     of dimensions (it doesn't hurt to pass this in all the time). Other
86     keyword args come from the underlying reader functions.
87     """
88     spl=filename.split('.')
89     ext=spl[len(spl)-1]
90     # extract possible params
91     integrationOrder=-1
92 jfenwick 4019 if "integrationOrder" in kwargs:
93 jfenwick 3912 integrationOrder=kwargs["integrationOrder"]
94     reducedIntegrationOrder=-1
95 jfenwick 4019 if "reducedIntegrationOrder" in kwargs:
96 jfenwick 3912 integrationOrder=kwargs["reducedIntegrationOrder"]
97     optimize=True
98 jfenwick 4019 if "optimize" in kwargs:
99 jfenwick 3912 integrationOrder=kwargs["optimize"]
100     useMacroElements=False
101 jfenwick 4019 if "useMacroElements" in kwargs:
102 jfenwick 3912 integrationOrder=kwargs["useMacroElements"]
103     if ext=="fly":
104     return ReadMesh(filename, integrationOrder, reducedIntegrationOrder, optimize)
105     elif ext=="msh":
106 jfenwick 4019 if not "numDim" in kwargs:
107 jfenwick 4018 raise ValueError("The numDim argument is required in order to read .msh files.")
108 jfenwick 3912 return ReadGmsh(filename, kwargs['numDim'], integrationOrder, reducedIntegrationOrder, optimize, useMacroElements)
109     else:
110     # return LoadMesh(filename)
111     raise ValueError("Unsupported extension .%s"%ext)

  ViewVC Help
Powered by ViewVC 1.1.26