2020-03-11 21:22:39 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
fenicsScript = pkgs.writeScript "poisson.py" ''
|
|
|
|
#!/usr/bin/env python
|
|
|
|
from dolfin import *
|
|
|
|
|
|
|
|
mesh = UnitSquareMesh(4, 4)
|
|
|
|
V = FunctionSpace(mesh, "Lagrange", 1)
|
|
|
|
|
|
|
|
def boundary(x):
|
|
|
|
return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS
|
|
|
|
|
|
|
|
u0 = Constant(0.0)
|
|
|
|
bc = DirichletBC(V, u0, boundary)
|
|
|
|
|
|
|
|
u = TrialFunction(V)
|
|
|
|
v = TestFunction(V)
|
|
|
|
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)
|
|
|
|
g = Expression("sin(5*x[0])", degree=2)
|
|
|
|
a = inner(grad(u), grad(v))*dx
|
|
|
|
L = f*v*dx + g*v*ds
|
|
|
|
|
|
|
|
u = Function(V)
|
|
|
|
solve(a == L, u, bc)
|
|
|
|
print(u)
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
name = "fenics";
|
|
|
|
meta = {
|
2021-01-10 19:08:30 +00:00
|
|
|
maintainers = with pkgs.lib.maintainers; [ knedlsepp ];
|
2020-03-11 21:22:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
fenicsnode = { pkgs, ... }: {
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
gcc
|
|
|
|
(python3.withPackages (ps: with ps; [ fenics ]))
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
testScript =
|
|
|
|
{ nodes, ... }:
|
|
|
|
''
|
|
|
|
start_all()
|
python3Packages.fenics: fix build, pin to older boost (#166728)
* python3Packages.fenics: fix build, pin to older boost
Looking at upstream, there are various issues with newer boost.
(At least some of them have been since fixed)
For now, fix the build by using a version of boost that works
with the current version.
Error here was complaining about `std::min_element`,
which is no longer available, apparently, due to newer boost
no longer (transitively) including <algorithm>.
This was added in C++17, so I'm not sure the cmake flag
specifying dolfin built with C++11 makes sense or is used.
Leaving for now :).
* nixos/tests/fenics: fix name of machine/node in script
Still fails for now.
* python3Packages.fenics: fix accidentally changed strings in subst
Looks like in migration to pkg-config this was erroneously
changed from `pkgconfig` (python package, and source string)
to `pkg-config` (nix package name, tool name).
(see 9bb3fccb5b55326cb3c2c507464a8a28d44d1730)
Fixes the NixOS test.
2022-04-15 01:37:20 +01:00
|
|
|
fenicsnode.succeed("${fenicsScript}")
|
2020-03-11 21:22:39 +00:00
|
|
|
'';
|
|
|
|
})
|