# No logging output from FFCX

I modified the poisson example so it should give me some information on the FFCX compilation, but unfortunately, it does not. Any hints what I’m doing wrong?

``````#!/usr/bin/env python3
from mpi4py import MPI
from petsc4py import PETSc

import numpy as np

import ufl
from dolfinx.fem import Function, assemble_scalar, form, functionspace
from dolfinx.fem.petsc import LinearProblem
from dolfinx.io import XDMFFile
from dolfinx.mesh import create_unit_square
from ufl import dx, grad, inner

# Wavenumber
k0 = 9 * np.pi

# Approximation space polynomial degree
deg = 1

# Number of elements in each direction of the mesh
n_elem = 128

msh = create_unit_square(MPI.COMM_WORLD, n_elem, n_elem)

# Source amplitude
if np.issubdtype(PETSc.ScalarType, np.complexfloating):  # type: ignore
A = PETSc.ScalarType(1 + 1j)  # type: ignore
else:
A = 1

# Test and trial function space
V = functionspace(msh, ("Lagrange", deg))

# Define variational problem
u, v = ufl.TrialFunction(V), ufl.TestFunction(V)
f = Function(V)
f.interpolate(lambda x: A * k0**2 * np.cos(k0 * x[0]) * np.cos(k0 * x[1]))
a = inner(grad(u), grad(v)) * dx - k0**2 * inner(u, v) * dx
L = inner(f, v) * dx

# Compute solution
uh = Function(V)
uh.name = "u"
problem = LinearProblem(a, L, u=uh, petsc_options={"ksp_type": "preonly", "pc_type": "lu"}, form_compiler_options={"verbosity": 10})
problem.solve()

# Save solution in XDMF format (to be viewed in ParaView, for example)
with XDMFFile(
MPI.COMM_WORLD, "out_helmholtz/plane_wave.xdmf", "w", encoding=XDMFFile.Encoding.HDF5
) as file:
file.write_mesh(msh)
file.write_function(uh)
``````

Also, is there a way to let me know whenever a compilation happens in this script, i.e. settings the form compiler option globally rather than at one particular form or problem? Ideally without creating a ffcx_options.json file. Btw, I’ve tried that also, and that did not work either.

ffcx version 0.8.0
dolfinx version 0.8.0
python version 3.12.2
MacOSX 14.5

`ffcx` uses a logger from the python `logging` library ffcx/ffcx/__init__.py at 20f0dbdf1cb97a6a280849536d1b94b959f0e0ca · FEniCS/ffcx · GitHub

Can you getting that same logger and changing the `level`?

So I added the following after the FEniCS imports, assuming this is what you meant. Unfortunately, still no output.

``````...
from ufl import dx, grad, inner

import logging
logger = logging.getLogger("ffcx")
logger.setLevel(10)

# Wavenumber
k0 = 4 * np.pi
...
``````

I would do something along the lines of:

``````import logging

from mpi4py import MPI
import dolfinx
import ufl
import ffcx
options = ffcx.get_options({"verbosity": 10})

logging.basicConfig()

mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
J = 1 * ufl.dx(domain=mesh)
dolfinx.fem.form(J, form_compiler_options=options)
``````

which yields:

``````INFO:ffcx:Final option values
INFO:ffcx:{'epsilon': 1e-14,
'scalar_type': <class 'numpy.float64'>,
'sum_factorization': False,
'table_atol': 1e-09,
'table_rtol': 1e-06,
'verbosity': 1}
INFO:ffcx:Final option values
INFO:ffcx:{'epsilon': 1e-14,
'scalar_type': <class 'numpy.float64'>,
'sum_factorization': False,
'table_atol': 1e-09,
'table_rtol': 1e-06,
'verbosity': 1}
INFO:ffcx:*******************************************************************************
INFO:ffcx:Compiler stage 1: Analyzing UFL objects
INFO:ffcx:*******************************************************************************
INFO:ffcx:Integral 0, integral group 0:
INFO:ffcx:Compiler stage 1 finished in 0.0341 seconds.
INFO:ffcx:*******************************************************************************
INFO:ffcx:Compiler stage 2: Computing intermediate representation of objects
INFO:ffcx:*******************************************************************************
INFO:ffcx:Computing IR for integral in integral group 0
INFO:ffcx:Computing IR for form 0
INFO:ffcx:Compiler stage 2 finished in 0.0085 seconds.
INFO:ffcx:*******************************************************************************
INFO:ffcx:Compiler stage 3: Generating code
INFO:ffcx:*******************************************************************************
INFO:ffcx:Generating code for integral:
INFO:ffcx:--- type: cell
INFO:ffcx:--- name: integral_cf300663e5655cc5df57ced894f7f3bf99c04c6d
INFO:ffcx:Generating code for form:
INFO:ffcx:--- rank: 0
INFO:ffcx:--- name: form_49433a30d987ab3f0fca907e7d46f6f88db3cfb2
INFO:ffcx:Generating code for file
INFO:ffcx:Compiler stage 3 finished in 0.0020 seconds.
INFO:ffcx:*******************************************************************************
INFO:ffcx:Compiler stage 5: Formatting code
INFO:ffcx:*******************************************************************************
INFO:ffcx:Compiler stage 4 finished in 0.0001 seconds.
INFO:ffcx:###############################################################################
INFO:ffcx:Calling JIT C compiler
INFO:ffcx:###############################################################################
``````

You would need to pass the options around (I guess the only workaround would be to make the json file.

``````import logging

from mpi4py import MPI
import dolfinx
import ufl

import json

logging.basicConfig()
json.dump({"verbosity": 10}, open("ffcx_options.json", mode="w"))

mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
J = 1 * ufl.dx(domain=mesh)
dolfinx.fem.form(J)
``````