/[escript]/trunk/finley/test/python/generate_dumps.py
ViewVC logotype

Annotation of /trunk/finley/test/python/generate_dumps.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1869 - (hide annotations)
Thu Oct 9 08:34:40 2008 UTC (12 years, 9 months ago) by gross
File MIME type: text/x-python
File size: 3740 byte(s)
typo fixed.
1 gross 1815 ########################################################
2     #
3     # Copyright (c) 2003-2008 by University of Queensland
4     # Earth Systems Science Computational Center (ESSCC)
5     # http://www.uq.edu.au/esscc
6     #
7     # Primary Business: Queensland, Australia
8     # Licensed under the Open Software License version 3.0
9     # http://www.opensource.org/licenses/osl-3.0.php
10     #
11     ########################################################
12    
13     __copyright__="""Copyright (c) 2003-2008 by University of Queensland
14     Earth Systems Science Computational Center (ESSCC)
15     http://www.uq.edu.au/esscc
16     Primary Business: Queensland, Australia"""
17     __license__="""Licensed under the Open Software License version 3.0
18     http://www.opensource.org/licenses/osl-3.0.php"""
19     __url__="http://www.uq.edu.au/esscc/escript-finley"
20     """
21     this script generates dump files of various data type (scalar, vector, tensor)
22     on various function spaces.
23    
24     The meshes are read from the MESH_DIRECTORY. filenames need to start with "mesh_" and
25     have the extension ".fly". Besides the mesh dump files (extension ".nc") and the
26     coresponding data files with extensions (_<fs_name>_s.nc, _<fs_name>_v.nc and _<fs_name>_t.nc where
27     <fs_name> is the name of the function space)
28    
29     This script can run under MPI.
30    
31     """
32    
33     MESH_DIRECTORY="./tmp_meshes"
34     from esys.escript import *
35     from esys.finley import ReadMesh
36     import os
37    
38     for root, dirs, files in os.walk(MESH_DIRECTORY, topdown=False):
39     for name in files:
40     f=name.split(".")
41     if f[0].startswith("mesh_") and f[-1]=="fly":
42     print "start reading ",os.path.join(MESH_DIRECTORY,name)
43     dom=ReadMesh(os.path.join(MESH_DIRECTORY,name),optimize=True)
44     dom.dump(os.path.join(MESH_DIRECTORY,f[0]+".nc"))
45     for fs_name in ["ContinuousFunction", "Solution", "Function", "FunctionOnBoundary", "FunctionOnContactZero", "FunctionOnContactOne",
46     "ReducedContinuousFunction", "ReducedSolution", "ReducedFunction", "ReducedFunctionOnBoundary", "ReducedFunctionOnContactZero", "ReducedFunctionOnContactOne"]:
47     if fs_name == "ContinuousFunction":
48     fs= ContinuousFunction(dom)
49     if fs_name == "Solution":
50     fs= Solution(dom)
51     if fs_name == "Function":
52     fs= Function(dom)
53     if fs_name == "FunctionOnBoundary":
54     fs= FunctionOnBoundary(dom)
55     if fs_name == "FunctionOnContactZero":
56 gross 1869 fs = FunctionOnContactZero(dom)
57 gross 1815 if fs_name == "FunctionOnContactOne":
58     fs = FunctionOnContactOne(dom)
59     if fs_name == "ReducedContinuousFunction":
60     fs= ReducedContinuousFunction(dom)
61     if fs_name == "ReducedSolution":
62     fs= ReducedSolution(dom)
63     if fs_name == "ReducedFunction":
64     fs= ReducedFunction(dom)
65     if fs_name == "ReducedFunctionOnBoundary":
66     fs= ReducedFunctionOnBoundary(dom)
67     if fs_name == "ReducedFunctionOnContactZero":
68     fs == ReducedFunctionOnContactZero(dom)
69     if fs_name == "ReducedFunctionOnContactOne":
70     fs = ReducedFunctionOnContactOne(dom)
71     for type in [ "s", "v", "t" ]:
72     data_file=os.path.join(MESH_DIRECTORY,f[0]+"_"+fs_name+"_"+type+".nc")
73     x=fs.getX()
74     print "\t data file ",data_file
75     if type == "t":
76 gross 1869 n=normalize(x)/clip(length(x-Vector(0.5,fs)),1.e-8)
77 gross 1815 d=outer(n,x)
78     elif type == "v":
79 gross 1869 d=normalize(x)/clip(length(x-Vector(0.5,fs)),1.e-8)
80 gross 1815 else:
81     d=length(x-Vector(0.5,fs))
82     d.dump(data_file)

  ViewVC Help
Powered by ViewVC 1.1.26