~pragmatic-core/pragmatic/scaling_optimisation

« back to all changes in this revision

Viewing changes to python/play_multigrid.py

  • Committer: kristian.jensen at ac
  • Date: 2014-01-06 15:59:39 UTC
  • Revision ID: kristian.jensen@ic.ac.uk-20140106155939-nc3lq1qwno29ssfi
files related to last commit added (oops), mesh definition function. Now metric DOFs are changed to vtx numbers (instead of the other way around), the surface mesh generator has been renamed and support for inputting a surface mesh has been added

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from dolfin import *
 
2
from adaptivity2 import refine_metric, adapt, metric_pnorm
 
3
set_log_level(WARNING)
 
4
 
 
5
def test_refine_metric():
 
6
  #  from mpi4py import MPI
 
7
  import sys
 
8
 
 
9
#  comm = MPI.COMM_WORLD
 
10
 
 
11
  # mesh = Mesh("greenland.xml.gz")
 
12
  mesh = UnitSquareMesh(100, 100)
 
13
 
 
14
  V = FunctionSpace(mesh, "CG", 2)
 
15
  f = interpolate(Expression("0.1*sin(50.*(2*x[0]-1)) + atan2(-0.1, (2.0*(2*x[0]-1) - sin(5.*(2*x[1]-1))))"), V)
 
16
 
 
17
  eta = 0.01
 
18
  #Mp = metric_pnorm(f, mesh, eta, max_edge_ratio=5)
 
19
  #mesh = adapt(Mp)
 
20
 
 
21
  if False:
 
22
    level = 0.5
 
23
    Mp = refine_metric(mesh_metric(mesh), level)
 
24
    new_mesh1 = adapt(Mp)
 
25
 
 
26
    level *= 0.5
 
27
    Mp = refine_metric(mesh_metric(mesh), level)
 
28
    new_mesh2 = adapt(Mp)
 
29
 
 
30
    level *= 0.5
 
31
    Mp = refine_metric(mesh_metric(mesh), level)
 
32
    new_mesh3 = adapt(Mp)
 
33
 
 
34
    level *= 0.5
 
35
    Mp = refine_metric(mesh_metric(mesh), level)
 
36
    new_mesh4 = adapt(Mp)
 
37
 
 
38
    level *= 0.5
 
39
    Mp = refine_metric(mesh_metric(mesh), level)
 
40
    new_mesh5 = adapt(Mp)
 
41
 
 
42
    level *= 0.5
 
43
    Mp = refine_metric(mesh_metric(mesh), level)
 
44
    new_mesh6 = adapt(Mp)
 
45
  else:
 
46
    eta *= 2
 
47
    Mp = metric_pnorm(f, mesh, eta, max_edge_ratio=5)
 
48
    new_mesh1 = adapt(Mp)
 
49
 
 
50
    eta *= 2
 
51
    Mp = metric_pnorm(f, mesh, eta, max_edge_ratio=5)
 
52
    new_mesh2 = adapt(Mp)
 
53
 
 
54
    eta *= 2
 
55
    Mp = metric_pnorm(f, mesh, eta, max_edge_ratio=5)
 
56
    new_mesh3 = adapt(Mp)
 
57
 
 
58
    eta *= 2
 
59
    Mp = metric_pnorm(f, mesh, eta, max_edge_ratio=5)
 
60
    new_mesh4 = adapt(Mp)
 
61
 
 
62
    eta *= 2
 
63
    Mp = metric_pnorm(f, mesh, eta, max_edge_ratio=5)
 
64
    new_mesh5 = adapt(Mp)
 
65
 
 
66
    eta *= 2
 
67
    Mp = metric_pnorm(f, mesh, eta, max_edge_ratio=5)
 
68
    new_mesh6 = adapt(Mp)
 
69
 
 
70
  # plot(Mp[0,0])
 
71
  # from IPython import embed
 
72
  # embed()
 
73
 
 
74
  plot(mesh, title="initial mesh")
 
75
  plot(new_mesh1, title="coarsen 1")
 
76
  plot(new_mesh2, title="coarsen 2")
 
77
  plot(new_mesh3, title="coarsen 3")
 
78
  plot(new_mesh4, title="coarsen 4")
 
79
  plot(new_mesh5, title="coarsen 5")
 
80
  plot(new_mesh6, title="coarsen 6")
 
81
 
 
82
  interactive()
 
83
  
 
84
if __name__=="__main__":
 
85
 test_refine_metric()
 
 
b'\\ No newline at end of file'