Ejemplo n.º 1
0
 def make_ds(mesh):
     surface = AutoSubDomain(lambda x: "on_boundary" and near(x[0], 1))
     boundaries = FacetFunction("size_t", mesh)
     boundaries.set_all(0)
     surface.mark(boundaries, 1)
     ds = Measure("ds", subdomain_data=boundaries)
     return ds
Ejemplo n.º 2
0
    path.join(rel_path, "mesh", "von_karman_street_FSI_structure_refine2.xml"))

# Function space
V = VectorFunctionSpace(mesh, "CG", 2)
VV = V * V

# Get the point [0.2,0.6] at the end of bar
for coord in mesh.coordinates():
    if coord[0] == 0.6 and (0.2 - DOLFIN_EPS <= coord[1] <= 0.2 + DOLFIN_EPS):
        #print coord
        break

BarLeftSide = AutoSubDomain(lambda x: "on_boundary" and \
                            (((x[0] - 0.2) * (x[0] - 0.2) +
                                (x[1] - 0.2) * (x[1] - 0.2) < 0.0505*0.0505 )
                                and x[1] >= 0.19 \
                                and x[1] <= 0.21 \
                                and x[0] > 0.2)
                            )

boundaries = FacetFunction("size_t", mesh)
boundaries.set_all(0)
BarLeftSide.mark(boundaries, 1)

# BCs
bc1 = DirichletBC(VV.sub(0), ((0, 0)), boundaries, 1)
bc2 = DirichletBC(VV.sub(1), ((0, 0)), boundaries, 1)
bcs = [bc1, bc2]

# Parameters:
rho_s = 1.0e3
Ejemplo n.º 3
0
# Trial and Test Functions
du = TrialFunction(V)
v = TestFunction(V)

u_np1 = Function(V)
saved_u_old = Function(V)

# function known from previous timestep
u_n = Function(V)
v_n = Function(V)
a_n = Function(V)

f_N_function = interpolate(Expression(("1", "0"), degree=1), V)
u_function = interpolate(Expression(("0", "0"), degree=1), V)

coupling_boundary = AutoSubDomain(neumann_boundary)
fixed_boundary = AutoSubDomain(clamped_boundary)

precice = Adapter(adapter_config_filename="precice-adapter-config-fsi-s.json")

# Initialize the coupling interface
precice_dt = precice.initialize(coupling_boundary,
                                read_function_space=V,
                                write_object=V,
                                fixed_boundary=fixed_boundary)

fenics_dt = precice_dt  # if fenics_dt == precice_dt, no subcycling is applied
# fenics_dt = 0.02  # if fenics_dt < precice_dt, subcycling is applied
dt = Constant(np.min([precice_dt, fenics_dt]))

# clamp the beam at the bottom
# Trial and Test Functions
du = TrialFunction(V)
v = TestFunction(V)

u_np1 = Function(V)
saved_u_old = Function(V)

# function known from previous timestep
u_n = Function(V)
v_n = Function(V)
a_n = Function(V)

f_N_function = interpolate(Expression(("1", "0"), degree=1), V)
u_function = interpolate(Expression(("0", "0"), degree=1), V)

coupling_boundary = AutoSubDomain(Neumann_Boundary)

# create subdomain that resembles the

## get the adapter ready

#read fenics-adapter json-config-file)

if Case is not StructureCase.RFERENCE:

    if Case is StructureCase.DUMMY2D:
        adapter_config_filename = "precice-adapter-config-fsi-dummy.json"
    elif Case is StructureCase.OPENFOAM:
        adapter_config_filename = "precice-adapter-config-fsi-s.json"

    elif Case is StructureCase.DUMMY3D:
Ejemplo n.º 5
0
# displacement fields
u_np1 = Function(V)
saved_u_old = Function(V)

# function known from previous timestep
u_n = Function(V)
v_n = Function(V)
a_n = Function(V)

# initial value for force and displacement field
f_N_function = interpolate(Expression(("1", "0"), degree=1), V)
u_function = interpolate(Expression(("0", "0"), degree=1), V)

# define coupling boundary
coupling_boundary = AutoSubDomain(remaining_boundary)

# create subdomain that resembles the

# get the adapter ready

# read fenics-adapter json-config-file)
adapter_config_filename = "precice-adapter-config-fsi-s.json"

# create Adapter
precice = Adapter(adapter_config_filename)

# create subdomains used by the adapter
clamped_boundary_domain = AutoSubDomain(left_boundary)
force_boundary = AutoSubDomain(remaining_boundary)
Ejemplo n.º 6
0
# Trial and Test Functions
du = TrialFunction(V)
v = TestFunction(V)

u_np1 = Function(V)
saved_u_old = Function(V)

# function known from previous timestep
u_n = Function(V)
v_n = Function(V)
a_n = Function(V)

f_N_function = interpolate(Expression(("1", "0"), degree=1), V)
u_function = interpolate(Expression(("0", "0"), degree=1), V)

coupling_boundary = AutoSubDomain(Neumann_Boundary)

# create subdomain that resembles the

## get the adapter ready

#read fenics-adapter json-config-file)

adapter_config_filename = "precice-adapter-config-fsi-s.json"

precice = Adapter(adapter_config_filename)

clamped_boundary_domain = AutoSubDomain(clamped_boundary)
precice_dt = precice.initialize(coupling_subdomain=coupling_boundary,
                                mesh=mesh,
                                read_field=f_N_function,
Ejemplo n.º 7
0
# Trial and Test Functions
du = TrialFunction(V)
v = TestFunction(V)

u_np1 = Function(V)
saved_u_old = Function(V)

# function known from previous timestep
u_n = Function(V)
v_n = Function(V)
a_n = Function(V)

f_N_function = interpolate(Expression(("1", "0"), degree=1), V)
u_function = interpolate(Expression(("0", "0"), degree=1), V)

coupling_boundary = AutoSubDomain(Neumann_Boundary)


def empty(x, on_boundary):
    return False


empty_domain = AutoSubDomain(empty)


def non_dir_boundary(x, on_boundary):
    return on_boundary and not clamped_boundary(x, on_boundary)


non_dir_domain = AutoSubDomain(non_dir_boundary)