Beispiel #1
0
    def wrap_mesh(mesh):
        """
    Creates a WrappedMesh object from a mesh with cuboid shell as created by
    the magnum-msh script.

    *Arguments*
      mesh (:class:`dolfin.Mesh` or :class:`str`))
        The mesh including the cuboid shell (either mesh object or path to mesh file)
    """
        if type(mesh) is str:
            mesh = Mesh(mesh)
        return WrappedMesh.create(mesh, (1000, 1001, 1002, 1003), True)
Beispiel #2
0
  def wrap_mesh(mesh):
    """
    Creates a WrappedMesh object from a mesh with cuboid shell as created by
    the magnum-msh script.

    *Arguments*
      mesh (:class:`dolfin.Mesh` or :class:`str`))
        The mesh including the cuboid shell (either mesh object or path to mesh file)
    """
    if type(mesh) is str:
      mesh = Mesh(mesh)
    return WrappedMesh.create(mesh, (1000, 1001, 1002, 1003), True)
Beispiel #3
0
    def create_mesh(*args, **kwargs):
        """
    Creates a WrappedMesh suited for the application of the shell-
    transformation method. Either takes a filename as first argument
    to load the meshed sample or sizes and discretization of a cuboid
    sample.

    *Example*

        .. code-block:: python
            # load from file
            mesh = DemagField.create_mesh("sphere.msh", d=2, margin=0.1, n=(10, 10, 10))

            # create cuboid mesh of size 1.0 x 1.0 x 1.0
            mesh = DemagField.create_mesh((1.0, 1.0, 1.0), (10, 10, 10), d=2)

    *Arguments*
        d
            Number of shell layers.
        scale
            Scale factor used for mesh generation.
        margin
            Margin to the sample when loading sample mesh from a file.
        n
            Discretization of inner cuboid when loading sample mesh from a file.
    """

        mesher = Mesher()

        if isinstance(args[0], str):
            mesher.read_file(args[0])
        elif isinstance(args[0],
                        (list, tuple)) and isinstance(args[1], (list, tuple)):
            mesher.create_cuboid(args[0], args[1])
        else:
            error("Arguments not supported.")

        d = kwargs.pop('d', 1)
        scale = kwargs.pop('scale', 1.0)
        mesher.create_shell(d, **kwargs)

        mesh = mesher.mesh(scale)

        return WrappedMesh.create(
            mesh, 0, {'sample_size': mesher.get_sample_size(scale=scale)})
Beispiel #4
0
  def create_mesh(*args, **kwargs):
    """
    Creates a WrappedMesh suited for the application of the shell-
    transformation method. Either takes a filename as first argument
    to load the meshed sample or sizes and discretization of a cuboid
    sample.

    *Example*

        .. code-block:: python
            # load from file
            mesh = DemagField.create_mesh("sphere.msh", d=2, margin=0.1, n=(10, 10, 10))

            # create cuboid mesh of size 1.0 x 1.0 x 1.0
            mesh = DemagField.create_mesh((1.0, 1.0, 1.0), (10, 10, 10), d=2)

    *Arguments*
        d
            Number of shell layers.
        scale
            Scale factor used for mesh generation.
        margin
            Margin to the sample when loading sample mesh from a file.
        n
            Discretization of inner cuboid when loading sample mesh from a file.
    """
        
    mesher = Mesher()

    if isinstance(args[0], str):
      mesher.read_file(args[0])
    elif isinstance(args[0], (list, tuple)) and isinstance(args[1], (list, tuple)):
      mesher.create_cuboid(args[0], args[1])
    else:
      error("Arguments not supported.")

    d     = kwargs.pop('d', 1)
    scale = kwargs.pop('scale', 1.0)
    mesher.create_shell(d, **kwargs)

    mesh    = mesher.mesh(scale)

    return WrappedMesh.create(mesh, 0, {'sample_size': mesher.get_sample_size(scale=scale)})