Coder Social home page Coder Social logo

Voropy throws AssertionError about pygmsh HOT 8 CLOSED

nschloe avatar nschloe commented on July 26, 2024
Voropy throws AssertionError

from pygmsh.

Comments (8)

nschloe avatar nschloe commented on July 26, 2024

You could set num_lloyd_steps to 0, that'll probably help.

Interesting that this fails though. Could you generate a small example that reproduces the error and post it here?

from pygmsh.

MuellerSeb avatar MuellerSeb commented on July 26, 2024
import pygmsh as pg
from pygmsh.built_in import Geometry


def gmsh_grid_adapt2D(out_dim=(100., 100.),
                      in_dim=(50., 50.),
                      out_res=(10., 10.),
                      in_res=(5., 5.),
                      out_pos=(0., 0.),
                      in_pos=(25., 25.),
                      z_pos=0.):
    '''
    Generate the 2D mesh adapter.
    '''
    geo = Geometry()
    code = [
        # "// size of the outer block",
        "outx = {};".format(out_dim[0]),
        "outy = {};".format(out_dim[1]),
        # "// size of the inner block",
        "inx = {};".format(in_dim[0]),
        "iny = {};".format(in_dim[1]),
        # "// outer grid resolution",
        "grioutx = {};".format(out_res[0]),
        "griouty = {};".format(out_res[1]),
        # "// inner grid resolution",
        "grix = {};".format(in_res[0]),
        "griy = {};".format(in_res[1]),
        # "// position of the outer block",
        "obx = {};".format(out_pos[0]),
        "oby = {};".format(out_pos[1]),
        # "// position of the inner block",
        "ibx = {};".format(in_pos[0]),
        "iby = {};".format(in_pos[1]),
        # "// z-position of the block",
        "bz = {};".format(z_pos),
        # "// outer block points",
        "Point(1) = {obx,       oby,        bz,         grioutx};",
        "Point(2) = {obx+outx,  oby,        bz,         grioutx};",
        "Point(3) = {obx+outx,  oby+outy,   bz,         grioutx};",
        "Point(4) = {obx,       oby+outy,   bz,         grioutx};",
        # "// inner block points",
        "Point(9) =  {ibx,      iby,        bz,         grix};",
        "Point(10) = {ibx+inx,  iby,        bz,         grix};",
        "Point(11) = {ibx+inx,  iby+iny,    bz,         grix};",
        "Point(12) = {ibx,      iby+iny,    bz,         grix};",
        # "// outer block lines",
        "Line(1) = {1, 2}; //s top",
        "Line(2) = {2, 3}; //e top",
        "Line(3) = {3, 4}; //n top",
        "Line(4) = {4, 1}; //w top",
        # "// inner block lines",
        "Line(13) = {9, 10}; //s top",
        "Line(14) = {10, 11}; //e top",
        "Line(15) = {11, 12}; //n top",
        "Line(16) = {12, 9}; //w top",
        # "// top surface",
        "Line Loop(26) = {1, 2, 3, 4};",
        "Line Loop(27) = {13, 14, 15, 16};",
        "Plane Surface(28) = {26, 27};",
        # "// make the outer sides rectengular",
        "Transfinite Line{1, 3} = outx/grioutx + 1;",
        "Transfinite Line{2, 4} = outy/griouty + 1;",
        # "// make the inner sides rectengular",
        "Transfinite Line{13, 15} = inx/grix + 1;",
        "Transfinite Line{14, 16} = iny/griy + 1;"]
    geo.add_raw_code(code)
    return geo

testgeo = gmsh_grid_adapt2D()

points, cells, __, __, __ = pg.generate_mesh(testgeo,
                                             num_lloyd_steps=0,
                                             dim=2)

from pygmsh.

MuellerSeb avatar MuellerSeb commented on July 26, 2024

"You could set num_lloyd_steps to 0" ... didn't help for me. I get the same Error as before.

from pygmsh.

nschloe avatar nschloe commented on July 26, 2024

Ah. This is a failure in gmsh itself. Try setting num_quad_lloyd_steps to 0.

from pygmsh.

nschloe avatar nschloe commented on July 26, 2024

Explanation: There is

  • "quad Lloyd" from gmsh (which puts the cells in a "quad"-type mesh) and
  • (actual) Lloyd from voropy.

from pygmsh.

MuellerSeb avatar MuellerSeb commented on July 26, 2024

"Try setting num_quad_lloyd_steps to 0" ... still throws the same Error. Does it work for you with the example from above?

from pygmsh.

MuellerSeb avatar MuellerSeb commented on July 26, 2024

My suggestion would be to replace the lines 147-158 in helpers.py with:

    if num_lloyd_steps > 0:
        if verbose:
            print('Lloyd smoothing...')
        # find submeshes
        a = cell_data['triangle']['geometrical']
        # http://stackoverflow.com/q/42740483/353337
        submesh_bools = {v: v == a for v in numpy.unique(a)}

        X, cells['triangle'] = voropy.smoothing.lloyd_submesh(
                X, cells['triangle'], submesh_bools,
                tol=0.0, max_steps=num_lloyd_steps,
                verbose=False
                )

that solves the problem for me ;)

from pygmsh.

nschloe avatar nschloe commented on July 26, 2024

Then that's the way we'll do it. I just released 4.0.3 with your proposed change.

from pygmsh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.