Editing Fem-fenics

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1,091: Line 1,091:
pkg load fem-fenics msh
pkg load fem-fenics msh


# Create mesh
x = y = linspace (0, 1, 65);
[msh, facets] = Mesh (msh2m_structured_mesh (x, y, 0, 4:-1:1));




Line 1,117: Line 1,114:




# Create mesh
x = y = linspace (0, 1, 65);
[msh, facets] = Mesh (msh2m_structured_mesh (x, y, 0, 4:-1:1));




Line 1,151: Line 1,156:


# Define subdomains
# Define subdomains


domains = MeshFunction ("dx", msh, 2, 0);
domains = MeshFunction ("dx", msh, 2, 0);
obstacle = SubDomain (@(x,y) (y >= 0.5) && (y <= 0.7) && ...
obstacle = SubDomain (@(x,y) (y >= 0.5) && (y <= 0.7) && ...
                       (x >= 0.2) && (x <= 1.0), false);
                       (x >= 0.2) && (x <= 1.0), false);
Line 1,196: Line 1,196:
from dolfin import *
from dolfin import *


# Define mesh
# Create classes for defining parts of the boundaries and the interior
 
# of the domain
mesh = UnitSquareMesh(64, 64)
 
# Create classes for defining parts of the boundaries
class Left(SubDomain):
class Left(SubDomain):
   def inside(self, x, on_boundary):
   def inside(self, x, on_boundary):
Line 1,216: Line 1,213:
   def inside(self, x, on_boundary):
   def inside(self, x, on_boundary):
     return near(x[1], 1.0)
     return near(x[1], 1.0)
class Obstacle(SubDomain):
  def inside(self, x, on_boundary):
    return (between(x[1], (0.5, 0.7)) and between(x[0], (0.2, 1.0)))


# Initialize sub-domain instances
# Initialize sub-domain instances
Line 1,222: Line 1,223:
right = Right()
right = Right()
bottom = Bottom()
bottom = Bottom()
# Define mesh
mesh = UnitSquareMesh(64, 64)


# Initialize mesh function for boundary domains
# Initialize mesh function for boundary domains
Line 1,256: Line 1,261:


# Initialize mesh function for interior domains
# Initialize mesh function for interior domains
class Obstacle(SubDomain):
  def inside(self, x, on_boundary):
    return (between(x[1], (0.5, 0.7)) and between(x[0], (0.2, 1.0)))
obstacle = Obstacle()
obstacle = Obstacle()
domains = CellFunction("size_t", mesh)
domains = CellFunction("size_t", mesh)
domains.set_all(0)
domains.set_all(0)


obstacle.mark(domains, 1)
obstacle.mark(domains, 1)
Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Templates used on this page: