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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (show annotations)
Wed Feb 7 02:12:08 2018 UTC (20 months, 1 week ago) by jfenwick
File MIME type: text/x-python
File size: 3655 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1 ##############################################################################
2 #
3 # Copyright (c) 2003-2018 by The University of Queensland
4 # http://www.uq.edu.au
5 #
6 # Primary Business: Queensland, Australia
7 # Licensed under the Apache License, version 2.0
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 # Development 2012-2013 by School of Earth Sciences
12 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
13 #
14 ##############################################################################
15
16 from __future__ import print_function, division
17
18 __copyright__="""Copyright (c) 2003-2018 by The University of Queensland
19 http://www.uq.edu.au
20 Primary Business: Queensland, Australia"""
21 __license__="""Licensed under the Apache License, version 2.0
22 http://www.apache.org/licenses/LICENSE-2.0"""
23 __url__="https://launchpad.net/escript-finley"
24 """
25 this script generates dump files of various data type (scalar, vector, tensor)
26 on various function spaces.
27
28 The meshes are read from the MESH_DIRECTORY. filenames need to start with "mesh_" and
29 have the extension ".fly". Besides the mesh dump files (extension ".nc") and the
30 coresponding data files with extensions (_<fs_name>_s.nc, _<fs_name>_v.nc and _<fs_name>_t.nc where
31 <fs_name> is the name of the function space)
32
33 This script can run under MPI.
34
35 """
36
37 MESH_DIRECTORY="./tmp_meshes"
38 from esys.escript import *
39 from esys.finley import ReadMesh
40 import os
41
42 for root, dirs, files in os.walk(MESH_DIRECTORY, topdown=False):
43 for name in files:
44 f=name.split(".")
45 if f[0].startswith("mesh_") and f[-1]=="fly":
46 print("Reading "+os.path.join(MESH_DIRECTORY,name))
47 dom=ReadMesh(os.path.join(MESH_DIRECTORY,name),optimize=True)
48 for fs_name in ["ContinuousFunction", "Solution", "Function", "FunctionOnBoundary", "FunctionOnContactZero", "FunctionOnContactOne",
49 "ReducedContinuousFunction", "ReducedSolution", "ReducedFunction", "ReducedFunctionOnBoundary", "ReducedFunctionOnContactZero", "ReducedFunctionOnContactOne"]:
50 if fs_name == "ContinuousFunction":
51 fs = ContinuousFunction(dom)
52 if fs_name == "Solution":
53 fs = Solution(dom)
54 if fs_name == "Function":
55 fs = Function(dom)
56 if fs_name == "FunctionOnBoundary":
57 fs = FunctionOnBoundary(dom)
58 if fs_name == "FunctionOnContactZero":
59 fs = FunctionOnContactZero(dom)
60 if fs_name == "FunctionOnContactOne":
61 fs = FunctionOnContactOne(dom)
62 if fs_name == "ReducedContinuousFunction":
63 fs = ReducedContinuousFunction(dom)
64 if fs_name == "ReducedSolution":
65 fs = ReducedSolution(dom)
66 if fs_name == "ReducedFunction":
67 fs = ReducedFunction(dom)
68 if fs_name == "ReducedFunctionOnBoundary":
69 fs = ReducedFunctionOnBoundary(dom)
70 if fs_name == "ReducedFunctionOnContactZero":
71 fs = ReducedFunctionOnContactZero(dom)
72 if fs_name == "ReducedFunctionOnContactOne":
73 fs = ReducedFunctionOnContactOne(dom)
74 x=fs.getX()
75 v=normalize(x)/clip(length(x-Vector(0.5,fs)), 1.e-8)
76 t=outer(v,x)
77 s=length(x-Vector(0.5,fs))
78 datasetName=f[0]+"_"+fs_name
79 try:
80 saveESD(datasetName, MESH_DIRECTORY, s=s, v=v, t=t)
81 except:
82 print("Could not save ESD file "+datasetName)
83

  ViewVC Help
Powered by ViewVC 1.1.26