Ejemplo n.º 1
0
def generate_test_mesh_and_field():
  '''We define a 1D mesh with two regions:
  
    |<---A--->|<--B-->|
    0 1 2 3 4 5 6 7 8 9
  
  We then define a field "vec" with 3 subfields:
  subfield 'vec_a' is defined in region A
  subfield 'vec_b' is defined in region B
  subfield 'vec_ab' is defined in both region A and B'''

  dim = 1
  m = nmesh.generate_1d_mesh([(0.0, 5.0), (5.0, 9.0)], 0.5)

  el_a = ocaml.make_element("vec_a", [3], dim, 1)
  el_b = ocaml.make_element("vec_b", [3], dim, 1)
  el_ab = ocaml.make_element("vec_ab", [3], dim, 1)

  els = [ocaml.empty_element,
         ocaml.fuse_elements(el_ab, el_a), # region A
         ocaml.fuse_elements(el_ab, el_b)] # region B

  def enumerated_list(l): return zip(range(len(l)), l)

  mwe = ocaml.make_mwe("vec",
                       m.raw_mesh, 
                       enumerated_list(els),
                       [],
                       [(1, ['vec_ab', 'vec_a']),
                        (2, ['vec_ab', 'vec_b'])])

  # Create the field and set it to 0 everywhere
  field = ocaml.raw_make_field(mwe, [lambda x, y: 0.0], "", "")
  return m, field
Ejemplo n.º 2
0
def fuse_elements(elem1, elem2):
    """
    Create an abstract element by fusing the contents of two abstract elements.
    """
    log.log(15, "Fusing elements XXX and XXX")
    return ocaml.fuse_elements(elem1, elem2)
Ejemplo n.º 3
0
def fuse_elements(elem1, elem2):
    """
    Create an abstract element by fusing the contents of two abstract elements.
    """
    log.log(15, "Fusing elements XXX and XXX")
    return ocaml.fuse_elements(elem1, elem2)