Comments (8)
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.
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.
"You could set num_lloyd_steps to 0" ... didn't help for me. I get the same Error as before.
from pygmsh.
Ah. This is a failure in gmsh itself. Try setting num_quad_lloyd_steps
to 0
.
from pygmsh.
Explanation: There is
- "quad Lloyd" from gmsh (which puts the cells in a "quad"-type mesh) and
- (actual) Lloyd from voropy.
from pygmsh.
"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.
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.
Then that's the way we'll do it. I just released 4.0.3 with your proposed change.
from pygmsh.
Related Issues (20)
- Unable to create Second Order Incomplete elements
- Error and warnings in tests
- The example "ball with mesh refinement" prints errors: TypeError: <lambda>() takes 5 positional arguments but 6 were given
- The "Flat shapes" section in the README has some broken links for images
- add_surface with occ geometry kernel broken HOT 1
- How to generate tetrahedron from a mesh?
- Error with set_mesh_size_callback HOT 1
- Removing isolated solid phases
- Supress output console
- Support calling add_physical multiple times with the same label
- Raw code alternative for periodic curve
- How to create a rotationally symmetric geometry HOT 1
- Generate Hexahedral mesh inside complex geometry using gmsh
- py30-pygmsh missing dependencies gmsh (macport installation)
- Alternative for add_raw_code in pygmsh 7.1.17
- Creating Meshes with no Quads
- It is recommended to upgrade to python 3.12
- Several warnings around pytest
- Removing surface and point after creating Volume
- Does the pygmesh installer seem to have stopped being updated?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygmsh.