# V 0.5.0 codes aren't working in V 0.5.1

The code is similar to steady heat conduction with multiple boundary conditions from the tutorial. I’m importing a 3D mesh of a bracket. The rest of the code is pretty simple. It worked fine all these days in V 0.5.0 but doesn’t seem to work in V 0.5.1. I’m running FEniCSx on conda.

``````import time
start = time.time()

from dolfinx import fem
import ufl
from dolfinx.io import XDMFFile
from petsc4py import PETSc
from mpi4py import MPI

mesh, cell_tags, facet_tags = read_from_msh("bracket3D.msh", MPI.COMM_WORLD, 0, gdim=3)
fdim = mesh.topology.dim - 1

# Thermal Conductivity
kappa = fem.Constant(mesh, PETSc.ScalarType(100))

# Convection Heat Transfer Coefficient
r = fem.Constant(mesh, PETSc.ScalarType(10))

s = 24          # Ambient Temperature
g = -200        # Heat Flux
f = 10          # Heat Generation

# Continuous Lagrange Function Space for Temperature
V = fem.FunctionSpace(mesh, ("CG", 1))

u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

F = kappa * inner(grad(u), grad(v)) * dx - inner(f, v) * dx

ds = ufl.Measure("ds", domain=mesh, subdomain_data= facet_tags)

class CreateBoundaryCondition():
def __init__(self, type, marker, values):
self._type = type
if type == "DirichletBC":
facets = facet_tags.find(marker)
dofs = fem.locate_dofs_topological(V, fdim, facets)
self._bc = fem.dirichletbc(PETSc.ScalarType(values), dofs , V)
elif type == "NeumannBC":
self._bc = inner(values, v) * ds(marker)
elif type == "RobinBC":
self._bc = values[0] * inner(u-values[1], v)* ds(marker)
else:
raise TypeError("Unknown boundary condition: {0:s}".format(type))
@property
def bc(self):
return self._bc

@property
def type(self):
return self._type

# Define the Dirichlet condition
boundary_conditions = [CreateBoundaryCondition("DirichletBC", 52 , 100),
CreateBoundaryCondition("NeumannBC", 53, g),
CreateBoundaryCondition("DirichletBC", 54, 60),
CreateBoundaryCondition("RobinBC", 55, (r , s))]

bcs = []
for condition in boundary_conditions:
if condition.type == "DirichletBC":
bcs.append(condition.bc)
else:
F += condition.bc

# Solve linear variational problem
a = lhs(F)
L = rhs(F)
problem = fem.petsc.LinearProblem(a, L, bcs=bcs, petsc_options={"ksp_type": "cg", "ksp_rtol":1e-6, "ksp_atol":1e-10, "ksp_max_it": 1000})
uh = fem.Function(V)
uh = problem.solve()

end = time.time()
print("The time of execution of the program is :",(end-start), "s")

num_dofs = V.dofmap.index_map_bs * V.dofmap.index_map.size_global
print("DOFs :",num_dofs)

# Visualize solution
print("Plotting Temperature Contour using PyVista")
import pyvista
from dolfinx import plot

pyvista.set_jupyter_backend("ipygany")

pyvista_cells, cell_types, geometry = plot.create_vtk_mesh(V)
grid = pyvista.UnstructuredGrid(pyvista_cells, cell_types, geometry)
grid.point_data["Temperature"] = uh.x.array
grid.set_active_scalars("Temperature")

plotter = pyvista.Plotter()
plotter.view_zy()
plotter.show()
``````

This throws an error:

``````(fenicsx-0.5.1) varunkumar@Varuns-MacBook-Pro FEniCSx Codes % /opt/anaconda3/envs/fenicsx-0.5.1/bin/python "/Users/varunkumar/Documents/FEniCSx Codes/SteadyThermal.py"
Info    : 105 entities
Info    : 15603 nodes
Info    : 86592 elements
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Traceback (most recent call last):
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/usr/bin/clang' failed with exit code 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/cffi/ffiplatform.py", line 51, in _build
dist.run_command('build_ext')
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 84, in run
_build_ext.run(self)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
self.build_extensions()
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions
self._build_extensions_serial()
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial
self.build_extension(ext)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
_build_ext.build_extension(self, ext)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 547, in build_extension
objects = self.compiler.compile(
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py", line 599, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 188, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command '/usr/bin/clang' failed with exit code 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/varunkumar/Documents/FEniCSx Codes/SteadyThermal.py", line 27, in <module>
V = fem.FunctionSpace(mesh, ("CG", 1))
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/dolfinx/fem/function.py", line 457, in __init__
(self._ufcx_element, self._ufcx_dofmap), module, code = jit.ffcx_jit(
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/dolfinx/jit.py", line 56, in mpi_jit
return local_jit(*args, **kwargs)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/dolfinx/jit.py", line 206, in ffcx_jit
r = ffcx.codegeneration.jit.compile_elements([ufl_object], parameters=p_ffcx, **p_jit)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/ffcx/codegeneration/jit.py", line 126, in compile_elements
impl = _compile_objects(decl, elements, names, module_name, p, cache_dir,
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/ffcx/codegeneration/jit.py", line 252, in _compile_objects
ffibuilder.compile(tmpdir=cache_dir, verbose=True, debug=cffi_debug)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/cffi/api.py", line 725, in compile
return recompile(self, module_name, source, tmpdir=tmpdir,
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/cffi/recompiler.py", line 1564, in recompile
outputfilename = ffiplatform.compile('.', ext,
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/cffi/ffiplatform.py", line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File "/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.9/site-packages/cffi/ffiplatform.py", line 58, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: CompileError: command '/usr/bin/clang' failed with exit code 1
``````

Sometimes it threw an error during the assembly of the problem. Please tell me what should be done to fix it. Also, I made the mistake of deleting V 0.5.0. Please let me know if there is a way to install V 0.5.0 in conda.

This error seems Mac specific. @jackhale , @chris do you have any suggestions?

Could it be due to the Ventura OS update I installed right before this started? Also, I deleted conda and reinstalled it along V 0.5.2 today, which also gives the same error.

1 Like

Thank you so much. The tutorial codes are working now. But from dolfinx.io.gmshio import read_from_msh doesn’t seem to work in V 0.5.2.

``````from dolfinx.io.gmshio import read_from_msh
from mpi4py import MPI
from dolfinx import fem

mesh, cell_tags, facet_tags = read_from_msh("fins.msh", MPI.COMM_WORLD, 0, gdim=3)

print('Plotting mesh using PyVista')

from dolfinx import plot
import pyvista
topology, cell_types, geometry = plot.create_vtk_mesh(mesh, 3)
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)

plotter = pyvista.Plotter()
plotter.view_xy()
plotter.show()
``````

This code gives an error :

``````Traceback (most recent call last):
File "/Users/varunkumar/Documents/FEniCSx Codes/SteadyThermal.py", line 7, in <module>
Do you have Gmsh installed? `read_from_msh` uses the Gmsh Python API to read msh files