Beispiel #1
0
def create_metric_input():
    source = omega_h.MetricSource(omega_h.VARIATION, 2e-3, "u")
    metric_input = omega_h.MetricInput()
    metric_input.add_source(source)
    metric_input.should_limit_lengths = True
    metric_input.max_length = 1.0 / 2.0
    metric_input.should_limit_gradation = True

    return metric_input
Beispiel #2
0
def test_function():
    mesh = UnitSquareMesh(32, 32)
    mesh_osh = omega_h.new_empty_mesh()

    omega_h.mesh_from_dolfin_unit_square(mesh_osh, mesh)

    V = FunctionSpace(mesh, "Lagrange", 1)
    u = Function(V)

    omega_h.function_from_dolfin(mesh_osh, u, "u")
Beispiel #3
0
def test_mesh():
    mesh = UnitSquareMesh(32, 32)
    mesh_2 = UnitSquareMesh(12, 12)

    assert mesh.hash() != mesh_2.hash()

    mesh_osh = omega_h.new_empty_mesh()

    omega_h.mesh_from_dolfin_unit_square(mesh_osh, mesh)

    omega_h.mesh_to_dolfin(mesh_2, mesh_osh);

    assert mesh.hash() == mesh_2.hash()
Beispiel #4
0
    def __init__(self):
        comm_osh = omega_h.world()
        self.mesh_osh = omega_h.build_box(comm_osh, omega_h.Family.SIMPLEX,
                                          1.0, 1.0, 0.0, 32, 32, 0)
        self.mesh_osh.set_parting(omega_h.Parting.GHOSTED, 1)
        omega_h.add_implied_metric_tag(self.mesh_osh)
        self.mesh_osh.set_parting(omega_h.Parting.ELEM_BASED, 0)

        self.mesh = Mesh()
        omega_h.mesh_to_dolfin(self.mesh, self.mesh_osh)
Beispiel #5
0
# Solving the Poisson problem adaptively using Omega_h

from dolfin import *
from mshr import *
# In case omega_h is not in the default path, append the path where the PyOmega_h shared library is located
#import sys
#sys.path.append("/usr/local/lib/python3/dist-packages/")
import PyOmega_h as omega_h

#Init dolfin mesh

# Build mesh with omega_h & initialize metrics
comm_osh = omega_h.world()
mesh_osh = omega_h.build_box(comm_osh, omega_h.Family.SIMPLEX, 1.0, 1.0, 0.0,
                             32, 32, 0)
mesh_osh.balance()
mesh_osh.set_parting(omega_h.GHOSTED, 1)
omega_h.add_implied_metric_tag(mesh_osh)
mesh_osh.set_parting(omega_h.ELEM_BASED, 0)

maxiter = 20
i = 0

file_u = File("poisson_u.pvd")


def boundary(x):
    return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS


while (i < maxiter):
Beispiel #6
0
    return a, L


def create_metric_input():
    source = omega_h.MetricSource(omega_h.VARIATION, 2e-3, "u")
    metric_input = omega_h.MetricInput()
    metric_input.add_source(source)
    metric_input.should_limit_lengths = True
    metric_input.max_length = 1.0 / 2.0
    metric_input.should_limit_gradation = True

    return metric_input


while (True):
    omega_h.mesh_to_dolfin(mesh, mesh_osh)

    V = FunctionSpace(mesh, "Lagrange", 1)
    bc = DirichletBC(V, u0, boundary)
    a, L = create_weakforms(V)

    u = Function(V)
    solve(a == L, u, bc)

    omega_h.function_from_dolfin(mesh_osh, u._cpp_object, "u")

    file << (u, i)

    i = i + 1
    if (i == n):
        break
Beispiel #7
0
from dolfin import *
from mshr import *
import PyOmega_h as omega_h
import time
import logging

logging.getLogger('FFC').setLevel(logging.WARNING)
logging.getLogger('UFL').setLevel(logging.WARNING)
logging.getLogger('DOLFIN').setLevel(logging.WARNING)
set_log_level(logging.WARNING)
from numpy import linalg as LA

# Read Gmsh file
comm_world = omega_h.world()
mesh_osh = omega_h.gmsh_read_file(omega_h.path('wing_naca_3D_18.msh'),
                                  comm_world)
mesh_osh.balance()
mesh_osh.set_parting(omega_h.GHOSTED, 1)
omega_h.add_implied_metric_tag(mesh_osh)
mesh_osh.set_parting(omega_h.ELEM_BASED, 0)

XMIN = -1.52
XMAX = 3.8
YMIN = 1.35
YMAX = -1.35
ZMIN = 0.0
ZMAX = 1.35

# Simulation variables
T = 0.2  # final time
#num_steps = 10  # number of time steps