| 1 |
"""Unit tests for assembly""" |
| 2 |
|
| 3 |
# Copyright (C) 2018 Jorgen S. Dokken |
| 4 |
# |
| 5 |
# This file is part of DOLFIN. |
| 6 |
# |
| 7 |
# DOLFIN is free software: you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU Lesser General Public License as published by |
| 9 |
# the Free Software Foundation, either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# DOLFIN is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU Lesser General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU Lesser General Public License |
| 18 |
# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
# |
| 20 |
|
| 21 |
|
| 22 |
import pytest |
| 23 |
import numpy |
| 24 |
from dolfin import * |
| 25 |
|
| 26 |
from dolfin_utils.test import fixture, skip_in_parallel |
| 27 |
|
| 28 |
|
| 29 |
@skip_in_parallel |
| 30 |
def test_mesh_adaptation(): |
| 31 |
mesh = UnitSquareMesh(10,10) |
| 32 |
rmesh = adapt(mesh) |
| 33 |
assert(numpy.isclose(mesh.hmax()/rmesh.hmax(), 2)) |
| 34 |
|
| 35 |
|
| 36 |
@skip_in_parallel |
| 37 |
def test_cell_function_adaptation(): |
| 38 |
mesh = UnitSquareMesh(10,10) |
| 39 |
rmesh = adapt(mesh) |
| 40 |
mf = MeshFunction("size_t", mesh, mesh.topology().dim()) |
| 41 |
rmesh = adapt(mesh) |
| 42 |
rmf = adapt(mf,rmesh) |
| 43 |
assert(rmf.size() / mf.size() == 4) |
| 44 |
|
| 45 |
|
| 46 |
@skip_in_parallel |
| 47 |
def test_facet_function_adaptation(): |
| 48 |
# Facet Function refinement needs global parameter |
| 49 |
parameters["refinement_algorithm"] = "plaza_with_parent_facets" |
| 50 |
mesh = UnitSquareMesh(10,10) |
| 51 |
rmesh = adapt(mesh) |
| 52 |
mf = MeshFunction("size_t", mesh, mesh.topology().dim()-1) |
| 53 |
rmf = adapt(mf, rmesh) |
| 54 |
assert(len(rmf.array())/len(mf.array())==3.875) |