Skip to content

Commit

Permalink
#162: Sort imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ddundo committed Apr 16, 2024
1 parent 9af8bb9 commit 2e568ab
Show file tree
Hide file tree
Showing 52 changed files with 165 additions and 109 deletions.
6 changes: 3 additions & 3 deletions demos/burgers-hessian.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#
# As before, we copy over what is now effectively boiler plate to set up our problem. ::

from firedrake import *
import matplotlib.pyplot as plt
from animate.adapt import adapt
from animate.metric import RiemannianMetric
from goalie import *
import matplotlib.pyplot as plt
from firedrake import *

from goalie import *

fields = ["u"]

Expand Down
1 change: 1 addition & 0 deletions demos/burgers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# side. See the Firedrake demo for details on the discretisation used.

from firedrake import *

from goalie import *

# In this problem, we have a single prognostic variable,
Expand Down
1 change: 1 addition & 0 deletions demos/burgers1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# ::

from firedrake import *

from goalie_adjoint import *

# For ease, the field list and functions for obtaining the
Expand Down
2 changes: 1 addition & 1 deletion demos/burgers2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Again, begin by importing Goalie with adjoint mode activated. ::

from firedrake import *
from goalie_adjoint import *

from goalie_adjoint import *

set_log_level(DEBUG)

Expand Down
1 change: 1 addition & 0 deletions demos/burgers_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# Goalie. ::

from firedrake import *

from goalie_adjoint import *

set_log_level(DEBUG)
Expand Down
2 changes: 1 addition & 1 deletion demos/burgers_oo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# ::

from firedrake import *
from goalie_adjoint import *

from goalie_adjoint import *

set_log_level(DEBUG)

Expand Down
1 change: 1 addition & 0 deletions demos/burgers_time_integrated.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Begin by importing from Goalie and the first Burgers demo. ::

from firedrake import *

from goalie_adjoint import *

# Redefine the ``get_initial_condition``, ``get_function_spaces``,
Expand Down
1 change: 1 addition & 0 deletions demos/gray_scott.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# diffusivities and react with one another nonlinearly. ::

from firedrake import *

from goalie_adjoint import *

# The problem is defined on a doubly periodic mesh of squares. ::
Expand Down
1 change: 1 addition & 0 deletions demos/gray_scott_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# equations differ in both the diffusion and reaction terms. ::

from firedrake import *

from goalie_adjoint import *

# This time, we have two fields instead of one, as well as two function spaces. ::
Expand Down
1 change: 1 addition & 0 deletions demos/mesh_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# of both Firedrake and Goalie. ::

from firedrake import *

from goalie import *

# Again, turn debugging mode on to get verbose output. ::
Expand Down
2 changes: 1 addition & 1 deletion demos/ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
# First, import from the namespaces of Firedrake and Goalie. ::

from firedrake import *
from goalie import *

from goalie import *

# Next, create a simple :class:`~.TimeInterval` object to hold information related to
# the time discretisation. This is a simplified version of :class:`~.TimePartition`,
Expand Down
8 changes: 4 additions & 4 deletions demos/point_discharge2d-goal_oriented.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
# We copy over the setup as before. The only difference is that we import from
# `goalie_adjoint` rather than `goalie`. ::

from firedrake import *
import matplotlib.colors as mcolors
import matplotlib.pyplot as plt
from animate.adapt import adapt
from animate.metric import RiemannianMetric
from goalie_adjoint import *
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
from firedrake import *
from matplotlib import ticker

from goalie_adjoint import *

fields = ["c"]

Expand Down
4 changes: 2 additions & 2 deletions demos/point_discharge2d-hessian.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
# adaptation functionality from Firedrake, which can be found in ``firedrake.meshadapt``.
# ::

from firedrake import *
from animate.adapt import adapt
from animate.metric import RiemannianMetric
from goalie import *
from firedrake import *

from goalie import *

# We again consider the "point discharge with diffusion" test case from the
# `previous demo <./point_discharge2d.py.html>`__, approximating the tracer concentration
Expand Down
1 change: 1 addition & 0 deletions demos/point_discharge2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# As always, start by importing Firedrake and Goalie. ::

from firedrake import *

from goalie_adjoint import *

# We solve the advection-diffusion problem in :math:`\mathbb P1` space. ::
Expand Down
4 changes: 2 additions & 2 deletions demos/solid_body_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# adjoint mode activated. ::

from firedrake import *

from goalie_adjoint import *

# For simplicity, we use a :math:`\mathbb P1` space for each
Expand Down Expand Up @@ -113,9 +114,8 @@ def get_initial_condition(mesh_seq, field="c"):
# only the :meth:`get_function_spaces` and :meth:`get_initial_condition`
# methods implemented. ::

from firedrake.pyplot import tricontourf
import matplotlib.pyplot as plt

from firedrake.pyplot import tricontourf

mesh_seq = MeshSeq(
time_partition,
Expand Down
1 change: 0 additions & 1 deletion demos/solid_body_rotation_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from solid_body_rotation import *


fields = ["bell", "cone", "slot_cyl"]


Expand Down
11 changes: 6 additions & 5 deletions goalie/adjoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
Drivers for solving adjoint problems on sequences of meshes.
"""

from functools import wraps

import firedrake
from firedrake.petsc import PETSc
import numpy as np
from firedrake.adjoint import pyadjoint
from firedrake.petsc import PETSc

from .function_data import AdjointSolutionData
from .log import pyrint
from .mesh_seq import MeshSeq
from .options import GoalOrientedParameters
from .utility import AttrDict, norm
from .log import pyrint
from functools import wraps
import numpy as np


__all__ = ["AdjointMeshSeq", "annotate_qoi"]

Expand Down
4 changes: 2 additions & 2 deletions goalie/error_estimation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
Tools to automate goal-oriented error estimation.
"""

import firedrake
import ufl
from firedrake import Function, FunctionSpace
from firedrake.functionspaceimpl import WithGeometry
from firedrake.petsc import PETSc
import ufl


__all__ = ["get_dwr_indicator"]

Expand Down
4 changes: 3 additions & 1 deletion goalie/function_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Nested dictionaries of solution data :class:`~.Function`\s.
"""

import abc

import firedrake.function as ffunc
import firedrake.functionspace as ffs

from .utility import AttrDict
import abc

__all__ = [
"ForwardSolutionData",
Expand Down
13 changes: 7 additions & 6 deletions goalie/go_mesh_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
Drivers for goal-oriented error estimation on sequences of meshes.
"""

from .adjoint import AdjointMeshSeq
from .error_estimation import get_dwr_indicator
from .function_data import IndicatorData
from .log import pyrint
from firedrake import Function, FunctionSpace, MeshHierarchy, TransferManager
from firedrake.petsc import PETSc
from collections.abc import Iterable

import numpy as np
import ufl
from firedrake import Function, FunctionSpace, MeshHierarchy, TransferManager
from firedrake.petsc import PETSc

from .adjoint import AdjointMeshSeq
from .error_estimation import get_dwr_indicator
from .function_data import IndicatorData
from .log import pyrint

__all__ = ["GoalOrientedMeshSeq"]

Expand Down
2 changes: 1 addition & 1 deletion goalie/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Driver functions for mesh-to-mesh data transfer.
"""

from .utility import assemble_mass_matrix, cofunction2function, function2cofunction
import firedrake
from firedrake.functionspaceimpl import WithGeometry
from firedrake.petsc import PETSc
from petsc4py import PETSc as petsc4py

from .utility import assemble_mass_matrix, cofunction2function, function2cofunction

__all__ = ["transfer", "interpolate", "project"]

Expand Down
5 changes: 3 additions & 2 deletions goalie/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
Code mostly copied from `the Thetis project
<https://thetisproject.org>`__.
"""
import firedrake

import logging
from logging import DEBUG, WARNING, ERROR
from logging import DEBUG, ERROR, WARNING

import firedrake

__all__ = [
"logger",
Expand Down
1 change: 0 additions & 1 deletion goalie/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import ufl
import ufl.core.expr


__all__ = ["bessi0", "bessk0"]


Expand Down
11 changes: 6 additions & 5 deletions goalie/mesh_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
Sequences of meshes corresponding to a :class:`~.TimePartition`.
"""

from collections.abc import Iterable

import firedrake
import numpy as np
from animate.quality import QualityMeasure
from firedrake.adjoint import pyadjoint
from firedrake.adjoint_utils.solving import get_solve_blocks
from firedrake.petsc import PETSc
from firedrake.pyplot import triplot

from .function_data import ForwardSolutionData
from .interpolation import transfer
from .log import pyrint, debug, warning, info, logger, DEBUG
from .log import DEBUG, debug, info, logger, pyrint, warning
from .options import AdaptParameters
from animate.quality import QualityMeasure
from .utility import AttrDict, Mesh
from collections.abc import Iterable
import numpy as np


__all__ = ["MeshSeq"]

Expand Down
10 changes: 6 additions & 4 deletions goalie/metric.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""
Driver functions for metric-based mesh adaptation.
"""
from .log import debug
from animate.metric import RiemannianMetric
import firedrake
from firedrake.petsc import PETSc

from collections.abc import Iterable

import firedrake
import numpy as np
import ufl
from animate.metric import RiemannianMetric
from firedrake.petsc import PETSc

from .log import debug

__all__ = ["enforce_variable_constraints", "space_time_normalise", "ramp_complexity"]

Expand Down
2 changes: 1 addition & 1 deletion goalie/options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .utility import AttrDict
from animate.adapt import RiemannianMetric

from .utility import AttrDict

__all__ = [
"AdaptParameters",
Expand Down
1 change: 1 addition & 0 deletions goalie/point_seq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import firedrake
import firedrake.mesh as fmesh

from .mesh_seq import MeshSeq

__all__ = ["PointSeq"]
Expand Down
4 changes: 3 additions & 1 deletion goalie/time_partition.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""
Partitioning for the temporal domain.
"""
from .log import debug

from collections.abc import Iterable

import numpy as np

from .log import debug

__all__ = ["TimePartition", "TimeInterval", "TimeInstant"]

Expand Down
7 changes: 4 additions & 3 deletions goalie/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
Utility functions and classes for mesh adaptation.
"""

import os
from collections import OrderedDict

import firedrake
import firedrake.mesh as fmesh
from firedrake.petsc import PETSc
from firedrake.__future__ import interpolate
import numpy as np
import os
import ufl
from firedrake.__future__ import interpolate
from firedrake.petsc import PETSc


@PETSc.Log.EventDecorator()
Expand Down
4 changes: 3 additions & 1 deletion goalie_adjoint/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import absolute_import

from pyadjoint import no_annotations # noqa

from goalie import * # noqa
from goalie.adjoint import * # noqa
from goalie.go_mesh_seq import * # noqa
from pyadjoint import no_annotations # noqa
Loading

0 comments on commit 2e568ab

Please sign in to comment.