nate-sime / dolfin_dg

Utility functions for the automatic generation of nonlinear DG FEM formulations using UFL
Other
18 stars 2 forks source link

Problem with CompressibleNavierStokesOperator. #3

Open dr-robertk opened 1 year ago

dr-robertk commented 1 year ago

Upon loading and using the CompressibleNavierStokesOperator I get the following error message. I trying to figure out whether this is a dune-fem bug, or a ufl problem. Would it be possible to double check with FEinCS (or FEniCSx) whether this still works?

Traceback (most recent call last):
  File "/home/robertk/work/Dune/stable/spacetimelobattocode/navierstokes/LobattoNavierStokes.py", line 118, in <module>
    F = SpatialOperator(L_h, V_h, time, dt, cfl=1)
  File "/home/robertk/work/Dune/stable/spacetimelobattocode/navierstokes/../common/spatialoperator.py", line 6, in __init__
    self._op = molGalerkin( L_h )
  File "/home/robertk/work/Dune/stable/dune-fem/build-cmake/python/dune/fem/operator/__init__.py", line 180, in molGalerkin
    return _galerkin(integrands, domainSpace=domainSpace, rangeSpace=rangeSpace,
  File "/home/robertk/work/Dune/stable/dune-fem/build-cmake/python/dune/fem/operator/__init__.py", line 105, in _galerkin
    integrands = makeIntegrands(domainSpace.gridView,integrands)
  File "/home/robertk/work/Dune/stable/dune-fem/build-cmake/python/dune/fem/model/_models.py", line 73, in integrands
    Integrands = integrands.load(view, form, *args,
  File "/home/robertk/work/Dune/stable/dune-fem/build-cmake/python/dune/models/integrands/load.py", line 293, in load
    module = builder.load(source.name(), source, "Integrands")
  File "/home/robertk/work/Dune/stable/dune-common/build-cmake/python/dune/generator/cmakebuilder.py", line 382, in load
    self._buildModule( moduleName, source, pythonName, extraCMake )
  File "/home/robertk/work/Dune/stable/dune-common/build-cmake/python/dune/generator/cmakebuilder.py", line 654, in _buildModule
    compilationMessage = self._configureWithMake( moduleName, source, pythonName )
  File "/home/robertk/work/Dune/stable/dune-common/build-cmake/python/dune/generator/cmakebuilder.py", line 630, in _configureWithMake
    code = str(source)
  File "/home/robertk/work/Dune/stable/dune-fem/build-cmake/python/dune/models/integrands/load.py", line 135, in __str__
    integrands = _compileUFL(self.integrands, self.form, *self.args, tempVars=self.tempVars)
  File "/home/robertk/work/Dune/stable/dune-fem/build-cmake/python/dune/models/integrands/ufl.py", line 236, in _compileUFL
    integrals = splitForm(form, [phi], boundaryId)
  File "/home/robertk/work/Dune/stable/dune-fem/build-cmake/python/dune/ufl/linear.py", line 186, in splitForm
    form = applyRestrictions(form)
  File "/home/robertk/work/Dune/stable/dune-fem/build-cmake/python/dune/ufl/applyrestrictions.py", line 42, in applyRestrictions
    return map_integrand_dags(RestrictionPropagator(), form, only_integral_type=integral_types)
  File "/home/robertk/work/Dune/stable/ufl/ufl/algorithms/map_integrands.py", line 46, in map_integrand_dags
    return map_integrands(lambda expr: map_expr_dag(function, expr, compress),
  File "/home/robertk/work/Dune/stable/ufl/ufl/algorithms/map_integrands.py", line 27, in map_integrands
    mapped_integrals = [map_integrands(function, itg, only_integral_type)
  File "/home/robertk/work/Dune/stable/ufl/ufl/algorithms/map_integrands.py", line 27, in <listcomp>
    mapped_integrals = [map_integrands(function, itg, only_integral_type)
  File "/home/robertk/work/Dune/stable/ufl/ufl/algorithms/map_integrands.py", line 35, in map_integrands
    return itg.reconstruct(function(itg.integrand()))
  File "/home/robertk/work/Dune/stable/ufl/ufl/algorithms/map_integrands.py", line 46, in <lambda>
    return map_integrands(lambda expr: map_expr_dag(function, expr, compress),
  File "/home/robertk/work/Dune/stable/ufl/ufl/corealg/map_dag.py", line 36, in map_expr_dag
    result, = map_expr_dags(function, [expression], compress=compress,
  File "/home/robertk/work/Dune/stable/ufl/ufl/corealg/map_dag.py", line 97, in map_expr_dags
    r = handlers[v._ufl_typecode_](v)
  File "/home/robertk/work/Dune/stable/dune-fem/build-cmake/python/dune/ufl/applyrestrictions.py", line 17, in restricted
    return map_expr_dag(RestrictionPropagator(expr.side()), expr.ufl_operands[0])
  File "/home/robertk/work/Dune/stable/ufl/ufl/corealg/map_dag.py", line 36, in map_expr_dag
    result, = map_expr_dags(function, [expression], compress=compress,
  File "/home/robertk/work/Dune/stable/ufl/ufl/corealg/map_dag.py", line 99, in map_expr_dags
    r = handlers[v._ufl_typecode_](v, *[vcache[u] for u in v.ufl_operands])
TypeError: RestrictionPropagator.variable() takes 3 positional arguments but 4 were given
LucasPa commented 9 months ago

Hello,

I tried to run the example compressible_navier_stokes_naca0012 but it failed with:

WARNING:py.warnings:/XXX/dolfin_dg/demo/dolfinx/compressible_navier_stokes_naca0012/dg_naca0012_2d.py:86: DeprecationWarning: This method is deprecated. Use FunctionSpace with an element shape argument instead
  V = dolfinx.fem.VectorFunctionSpace(mesh, ("DG", poly_o), dim=4)

Problem size: 18288 degrees of freedom
Traceback (most recent call last):
  File "/XXX/dolfin_dg/demo/dolfinx/compressible_navier_stokes_naca0012/dg_naca0012_2d.py", line 95, in <module>
    dolfinx.fem.Expression(gD_guess, V.element.interpolation_points()))
  File "/XXX/lib/python3.9/site-packages/dolfinx/fem/function.py", line 182, in __init__
    self._cpp_object = _create_expression(dtype)(ffi.cast("uintptr_t", ffi.addressof(self._ufcx_expression)),
TypeError: create_expression_complex128(): incompatible function arguments. The following argument types are supported:
    1. (expression: int, coefficients: List[dolfinx.cpp.fem.Function_complex128], constants: List[dolfinx.cpp.fem.Constant_complex128], argument_function_space: dolfinx::fem::FunctionSpace<double>) -> dolfinx.cpp.fem.Expression_complex128

Invoked with: <cdata 'uintptr_t' 23404907635552>, [], [<dolfinx.cpp.fem.Constant_float64 object at 0x15496affea30>, <dolfinx.cpp.fem.Constant_float64 object at 0x15496b73d030>, <dolfinx.cpp.fem.Constant_float64 object at 0x15496a47c2f0>], None

Moreover, the example in demo/dolfinx/advection raises the error:


Traceback (most recent call last):
  File "XXX/dolfin_dg/demo/dolfinx/advection/dg_linear_advection.py", line 44, in <module>
    F = ho.generate_fem_formulation(u, v)
  File "XXX/lib/python3.9/site-packages/dolfin_dg/operators.py", line 275, in generate_fem_formulation
    fos = dolfin_dg.primal.FirstOrderSystem(F_vec, L_vec, u, v)
  File "XXX/lib/python3.9/site-packages/dolfin_dg/primal/__init__.py", line 81, in __init__
    self.G_vec = [
  File "XXX/lib/python3.9/site-packages/dolfin_dg/primal/__init__.py", line 82, in <listcomp>
    dolfin_dg.math.homogenize(F_vec[i], u, L_vec[i](F_vec[i + 1](u)))
  File "XXX/lib/python3.9/site-packages/dolfin_dg/primal/__init__.py", line 60, in flux_guard
    return func(u, flux)
TypeError: F_c() takes 1 positional argument but 2 were given

PS: I use the complex version of dolfinx v.0.7


Since my last message, I installed the real version of dolfinx v.0.7. The demo compressible_navier_stokes_naca0012 can now compute the lift and drag:

DoFs: 18288, Drag: 6.37922e-02, Lift: 2.28879e-02

(are those the correct values?)

but still raises an error:

Traceback (most recent call last):
  File "/XXX/dolfin_dg/demo/dolfinx/compressible_navier_stokes_naca0012/dg_naca0012_2d.py", line 190, in <module>
    fi.write_function(u_vec.sub(0))
  File "/XXX/dolfinx/Dist/real/lib/python3.9/site-packages/dolfinx/io/utils.py", line 235, in write_function
    super().write_function(getattr(u, "_cpp_object", u), t, mesh_xpath)
RuntimeError: Function and Mesh dof layouts do not match. Maybe the Function needs to be interpolated?

However demo/dolfinx/advection still raises the same error as above :-(