### Project a piece-wise constant from quadrilateral to triangle mesh

33

views

0

Hi FEniCS community,

I am trying to project a piece-wise constant from quadrilateral to triangle mesh as shown below

I am trying to project a piece-wise constant from quadrilateral to triangle mesh as shown below

```
from dolfin import *
import time
import os
import numpy as np
from scipy.stats import truncnorm
meshq =UnitSquareMesh.create( 32, 32, CellType.Type_quadrilateral)
mesh = UnitSquareMesh(32, 32)
PM = FunctionSpace(mesh, 'DG', 0)
KM = TensorFunctionSpace(mesh, "DG", 0)
PMq = FunctionSpace(meshq, 'DG', 0)
KMq = TensorFunctionSpace(meshq, "DG", 0)
porq = Function(PMq)
def get_truncated_normal(mean=0, sd=1, low=0, upp=10):
return truncnorm(\
(low - mean) / sd, (upp - mean) / sd, loc=mean, scale=sd)
por_mu = 0.3
por_sigma = 0.1
X = get_truncated_normal(mean=por_mu, sd=np.sqrt(por_sigma), low=0.0, upp=0.45)
porq.vector()[:] = X.rvs(len(porq.vector()))
por = project(porq,PM)
t=0.0
xdmpor = XDMFFile(mesh.mpi_comm(), "porosity.xdmf")
xdmporq = XDMFFile(mesh.mpi_comm(), "porosity.xdmf")
por.rename("por", "porosity")
porq.rename("porq", "porosityq")
xdmpor.write(por,t)
xdmporq.write(porq,t)
```

However, this error shows up

```
*** Error: Unable to intersect cell and point.
*** Reason: Intersection is only implemented for simplex meshes.
*** Where: This error was encountered inside Cell.cpp.
*** Process: 0
```

How can I fix this issue?

Sincerely,

Teeratorn

Community: FEniCS Project

### 1 Answer

2

This functionality is currently not supported. It would require geometric primitive operations between simplices and quadrilateral meshes to be implemented in DOLFIN.

Thank you very much!

written
22 hours ago by
Teeratorn Kadeethum

Please login to add an answer/comment or follow this question.