|
3 | 3 | __copyright__ = "Copyright (C) 2014 " + __author__
|
4 | 4 | __license__ = "GNU Lesser GPL version 3 or any later version"
|
5 | 5 |
|
6 |
| -import os |
7 |
| -import platform |
8 |
| - |
9 |
| -from dolfin import Mesh, AutoSubDomain, near |
10 |
| - |
11 |
| -if not os.path.isfile("cylinder.xml"): |
12 |
| - if platform.system() == "Linux": |
13 |
| - os.system("wget -O cylinder.xml https://www.dropbox.com/s/d78g4cyjxl3ylay/cylinder.xml?dl=0") |
14 |
| - elif platform.system() == "Darwin": |
15 |
| - os.system("curl -L https://www.dropbox.com/s/d78g4cyjxl3ylay/cylinder.xml?dl=0 -o cylinder.xml") |
16 |
| - else: |
17 |
| - raise ImportError("Could not determine platform") |
18 |
| - |
19 |
| - # try: |
20 |
| - # os.system("gmsh mesh/cylinder.geo -2 -o mesh/cylinder.msh") |
21 |
| - # os.system("dolfin-convert mesh/cylinder.msh mesh/cylinder.xml") |
22 |
| - # os.system("rm mesh/cylinder.msh") |
23 |
| - # except RuntimeError: |
24 |
| - # os.system("wget -O cylinder.xml https://www.dropbox.com/s/d78g4cyjxl3ylay/cylinder.xml?dl=0") |
25 |
| - # raise "Gmsh is required to run this demo" |
26 |
| - |
27 |
| -mesh = Mesh("cylinder.xml") |
| 6 | +from dolfin import AutoSubDomain, near |
28 | 7 |
|
29 | 8 | H = 0.41
|
30 | 9 | L = 2.2
|
|
47 | 26 |
|
48 | 27 |
|
49 | 28 | # Overload post_import_problem to choose between the two cases
|
50 |
| -def post_import_problem(NS_parameters, commandline_kwargs, **NS_namespace): |
| 29 | +def post_import_problem(NS_parameters, mesh, commandline_kwargs, **NS_namespace): |
| 30 | + # If the mesh is a callable function, then create the mesh here. |
| 31 | + if callable(mesh): |
| 32 | + mesh = mesh(**NS_parameters) |
| 33 | + |
51 | 34 | """ Choose case - case could be defined through command line."""
|
52 | 35 | NS_parameters.update(commandline_kwargs)
|
53 | 36 | case = NS_parameters['case'] if 'case' in NS_parameters else 1
|
54 | 37 | Um = cases[case]["Um"]
|
55 | 38 | Re = cases[case]["Re"]
|
56 | 39 | Umean = 2. / 3. * Um
|
57 | 40 | nu = Umean * D / Re
|
58 |
| - NS_parameters.update(nu=nu, Re=Re, Um=Um, Umean=Umean) |
| 41 | + NS_parameters.update(nu=nu, Re=Re, Um=Um, Umean=Umean, mesh=mesh) |
59 | 42 |
|
60 | 43 | return NS_parameters
|
0 commit comments