| 1 |
# Copyright (C) 2005-2010 Anders Logg |
| 2 |
# |
| 3 |
# This file is part of DOLFIN. |
| 4 |
# |
| 5 |
# DOLFIN is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU Lesser General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# DOLFIN is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU Lesser General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU Lesser General Public License |
| 16 |
# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
# |
| 18 |
# Recompile all ffc forms (use when FFC has been updated) |
| 19 |
# This script should be run from the top level directory. |
| 20 |
|
| 21 |
import os |
| 22 |
import ffc |
| 23 |
|
| 24 |
# Forms that need special options |
| 25 |
use_error = ["AdaptivePoisson.ufl", |
| 26 |
"AdaptiveNavierStokes.ufl", |
| 27 |
] |
| 28 |
|
| 29 |
use_representation = {"HyperElasticity.ufl": "uflacs", |
| 30 |
"CahnHilliard2D.ufl": "uflacs", |
| 31 |
"CahnHilliard3D.ufl": "uflacs", |
| 32 |
} |
| 33 |
|
| 34 |
use_split = ["Poisson2D_1.ufl", |
| 35 |
"Poisson2D_2.ufl", |
| 36 |
"Poisson2D_3.ufl", |
| 37 |
"Poisson2D_4.ufl", |
| 38 |
"Poisson2D_5.ufl", |
| 39 |
"Poisson3D_1.ufl", |
| 40 |
"Poisson3D_2.ufl", |
| 41 |
"Poisson3D_3.ufl", |
| 42 |
"Poisson3D_4.ufl", |
| 43 |
"Poisson3D_5.ufl", |
| 44 |
"CahnHilliard2D.ufl", |
| 45 |
"CahnHilliard3D.ufl", |
| 46 |
] |
| 47 |
|
| 48 |
# Forms for which we don't want to generate functions for evaluating |
| 49 |
# the basis |
| 50 |
skip_basis = ["Poisson2D_5.ufl", "Poisson3D_4.ufl"] |
| 51 |
|
| 52 |
# Directories to scan |
| 53 |
subdirs = ["demo", "bench", "test"] |
| 54 |
|
| 55 |
# Compile all form files |
| 56 |
topdir = os.getcwd() |
| 57 |
for subdir in subdirs: |
| 58 |
for root, dirs, files in os.walk(subdir): |
| 59 |
# Check for .ufl files |
| 60 |
formfiles = [f for f in files if f[-4:] == ".ufl"] |
| 61 |
if not formfiles: |
| 62 |
continue |
| 63 |
|
| 64 |
# Compile files |
| 65 |
os.chdir(root) |
| 66 |
print("Compiling %d forms in %s..." % (len(formfiles), root)) |
| 67 |
for f in formfiles: |
| 68 |
args = ["-l", "dolfin"] |
| 69 |
args.append("-s") |
| 70 |
args.append("-O") |
| 71 |
|
| 72 |
args.append("-r") |
| 73 |
args.append(use_representation.get(f, "auto")) |
| 74 |
|
| 75 |
if f in use_split: |
| 76 |
args.append("-fsplit") |
| 77 |
|
| 78 |
if f in use_error: |
| 79 |
args.append("-e") |
| 80 |
|
| 81 |
if f in skip_basis: |
| 82 |
args.append("-fno-evaluate_basis") |
| 83 |
args.append("-fno-evaluate_basis_derivatives") |
| 84 |
|
| 85 |
args.append(f) |
| 86 |
|
| 87 |
command = "ffc " + " ".join(args) # + " >> compile.log" |
| 88 |
print(command) |
| 89 |
|
| 90 |
ret = ffc.main(args) |
| 91 |
if ret != 0: |
| 92 |
raise RuntimeError("Unable to compile form: %s/%s" % (root, f)) |
| 93 |
os.chdir(topdir) |