Comments (9)
Note: to create a mesh of disconnected vertices (i.e. a point cloud) you need tdim=0
from fenics-adapter.
I investigated this issue a bit. Main problem with FEniCS is that it does not provide the VertexOnlyMesh
needed for this purpose. We could try adapting the firedrake
version of VertexOnlyMesh
to also make it available in FEniCS. This is a bigger issue, though.
from fenics-adapter.
I tried to create a mesh myself. I will provide the example code below. Note that the example is not working. I guess it is just not that simple to have a mesh without connectivity in FEniCS.
import fenics
import numpy as np
from fenics import Mesh, MeshEditor, FunctionSpace
# using https://bitbucket.org/fenics-project/dolfin/src/b55804ecca7d010ff976967af869571b56364975/dolfin/generation/IntervalMesh.cpp#lines-76:98 as template
N = 5 # we want to work with 5 vertices on the mesh
gdim = 2 # geometric dimension
tdim = 0 # topological dimension
vertices = np.random.rand(N, gdim)
mesh = Mesh() # empty mesh
editor = MeshEditor()
editor.open(mesh, type="interval", tdim=tdim, gdim=gdim) # here type="point" or type="vertex" would be a reasonable choice, but also leads to an error.
editor.init_vertices_global(N,N)
for i in range(N):
editor.add_vertex(i, vertices[i,:])
editor.close()
V = FunctionSpace(mesh, "DG", 0)
Edit: Updated following advice in #119 (comment), creating the FunctionSpace
still fails, but we get a few steps further. Thanks!
from fenics-adapter.
Neither
editor.open(mesh, type="point", tdim=tdim, gdim=gdim)
nor
editor.open(mesh, type="vertex", tdim=tdim, gdim=gdim)
work. Looking at the ufl package it looks like vertex
is the correct type. However, the editor
only accepts point
.
from fenics-adapter.
UFL should support vertex cells - at least I added such support to the github hosted FEniCS/ufl repository which I believe is the current UFL core and appears to be newer than the bitbucket one you pointed to. Not sure which you get when you import fenics
as you do in your example mind you.
from fenics-adapter.
Relevant PR FEniCS/ufl#30
from fenics-adapter.
UFL should support vertex cells - at least I added such support to the github hosted FEniCS/ufl repository which I believe is the current UFL core and appears to be newer than the bitbucket one you pointed to. Not sure which you get when you
import fenics
as you do in your example mind you.
@ReubenHill On the ufl side vertex
makes totally sense. I'm currently confused about the point
which the editor
expects. Looking at the dolfinx implementation I still see point
, but not a vertex
. I have the impression that dolfinx provides a point
to ufl, but ufl expects a vertex
:
ufl.Cell
gets aself.topology.cell_name()
self.topology.cell_name()
provides a string based onself.cell_type()
cell_type()
is provided byTopology
Topology
has amesh::CellType
- But
mesh::CellType
is apoint
, not avertex
Since I'm lacking a bit background in DolfinX and UFL, I'm not sure whether this is an issue or I'm just missing something.
from fenics-adapter.
point
and vertex
are often used synonymously, but it seems that, in UFL at least, vertex
is the term used to refer to a 0D simplex (see https://github.com/FEniCS/ufl/blob/master/ufl/cell.py).
It looks like the issue you are running into is trying to get the translation from the symbolic representation of a mesh of disconnected vertices (which you should be able to create in pure UFL as a ufl.mesh
with a UFL ufl.FiniteElement(the_ufl_mesh, "DG", 0)
defined on it) to the numerical implementation. The numerical implementation I have done is in firedrake and you're, I believe, trying to do the same thing in FEniCSx.
Assuming that FEniCSx makes use of the UFL domain and mesh abstractions for symbolically describing meshes then the symbolic bit is done and shouldn't need any UFL changes.
Looking at what I had to do in firedrake might be instructive to see what you need to change in FEniCSx to get this numerically represented but I honestly can't say for sure since I'm not a FEniCSx developer. Hopefully the above is helpful nonetheless.
from fenics-adapter.
I asked a question about this issue in the FEniCS discourse forum (https://fenicsproject.discourse.group/t/unclear-how-to-use-mesheditor-with-pointcloud/5660). @ReubenHill Thanks for the explanation!
from fenics-adapter.
Related Issues (20)
- Outdated documentation regarding actions HOT 4
- Homogenize citation information HOT 4
- Support FEniCSx HOT 1
- The Config object can not find the adapter configuration file HOT 1
- Error at any run: "Illegal instruction (core dumped)" on Ubuntu 21.10
- Restrictions on using adapter for 3D cases HOT 7
- Painfully slow mapping with volumetric coupling HOT 1
- Installation issues for fenics version (2:0.4.1.2) HOT 5
- Mesh connectivity information not defined for all scenarios in 2D and 3D cases
- Remove duplicates in citation information HOT 1
- precice/fenics-adapter:latest is not stable but the develop release HOT 2
- Volume coupling and nearest projection mapping do not integrate well and are untested
- recommended install fails under Ubuntu HOT 3
- Make limitations of the adapter more evident in the documentation
- Double-boundary points warning HOT 2
- Support checkpointing of multiple fields
- Support `numpy >= 2` ? HOT 1
- Use `tox` for testing
- Introduce `pyproject.toml` HOT 1
- `mpi4py` version 4.0.0 prevents installation of FEniCS adapter
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 fenics-adapter.