Git Product home page Git Product logo

Comments (4)

nschloe avatar nschloe commented on June 12, 2024

How about a polygon?

from dmsh.

nschloe avatar nschloe commented on June 12, 2024

Closing for lack of feedback. Feel free to reopen at any time.

from dmsh.

oddroj avatar oddroj commented on June 12, 2024

Just wanted to note that you can do this for any contour, first by making an arbitrary function that outputs an array of [x,y] coordinates associated with the edges.

for a quarter ellipse...

import numpy as np

#This is in polar coordinates to generate equi-theta spaced points. Can do it in elliptical or whatever.

def EllipsePol(a,b,Points):
    theta=np.linspace(0,np.pi/2,Points)
    r = a*b/np.sqrt((b**2 -a**2)*np.cos(theta)**2 + a**2)
    theta=np.append(theta,0)
    r=np.append(r,0)
    return np.array([r,theta])

#Converts to Cartesian

def PolToCart(r,theta):
    x=r*np.cos(theta)
    y=r*np.sin(theta)    
    return np.array([x,y])

#Define A and B and resolution (How polygon-esque it is)
A=2
B=5
res=5

Points=PolToCart(EllipsePol(A,B,res)[0],EllipsePol(A,B,res)[1])
geo = dmsh.Polygon(Points.T)
X, cells = dmsh.generate(geo,.3)
dmsh.helpers.show(X, cells, geo)

yields

image

With a high resolution:
image

The weird elements are due to the spacing of the poly-points. See with equi-X spacing:

image

from dmsh.

nschloe avatar nschloe commented on June 12, 2024

The weird boundary on ellipse meshes are a known bug, see #44.

from dmsh.

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.