fastfem.mesh
¶
The fastfem.mesh
package contains utilities for generating and reading meshes.
RectangleMesh
dataclass
¶
Bases: Mesh
A class that is identical to the Mesh
class, but with typing hints for a
rectangle mesh.
Source code in fastfem/mesh/fundamentals.py
Line
dataclass
¶
Create a line with the given points.
Parameters:
-
start_point
(Point
) –The start point of the line.
-
end_point
(Point
) –The end point of the line.
-
number_of_nodes
(Optional[int]
, default:None
) –The number of nodes on the line. If provided, the line will be transfinite. Defaults to None.
-
domain_name
(Optional[str]
, default:None
) –The name of the domain the line belongs to. Defaults to None.
Source code in fastfem/mesh/generator.py
Mesh
dataclass
¶
Source code in fastfem/mesh/generator.py
nodes: dict[int, np.ndarray]
property
¶
Return all the nodes.
number_of_nodes: int
property
¶
Return the number of nodes.
__getitem__(key)
¶
Return the mesh of the domain with the given name.
Parameters:
-
key
(str
) –The name of the domain.
Returns:
-
Domain
–List of submeshes of the domain. Submeshes are required because each domain
-
Domain
–can have multiple element types.
Source code in fastfem/mesh/generator.py
__contains__(key)
¶
Check if the mesh has a domain with the given name.
Parameters:
-
key
(str
) –The name of the domain.
Returns:
-
bool
–True if the domain exists, otherwise False.
Source code in fastfem/mesh/generator.py
Point
dataclass
¶
Create a point with the given coordinates.
Parameters:
-
x
(float
) –The x-coordinate of the point.
-
y
(float
) –The y-coordinate of the point.
-
z
(float
) –The z-coordinate of the point.
-
domain_name
(Optional[str]
, default:None
) –The name of the domain the point belongs to. Defaults to None.
Source code in fastfem/mesh/generator.py
Submesh
dataclass
¶
Source code in fastfem/mesh/generator.py
Surface
dataclass
¶
Create a surface with the given lines.
Parameters:
-
outer_lines
(list[Line]
) –The lines that form the surface. The lines must be connected (each line's end point is the start point of the next line).
-
inner_lines
(Optional[list[Line]]
, default:None
) –The lines that form the holes in the surface. Defaults to None.
-
transfinite
(bool
, default:False
) –If True, the surface will be transfinite. If transfinite, all the lines' number_of_nodes argument must be provided, and the surface must have 3 or 4 lines, and there should be no inner lines. Defaults to False.
-
element_type
(TwoDElementType
, default:'triangle'
) –The type of element to uFse. Defaults to "triangle". domain_name: The name of the domain the surface belongs to. Defaults to None.
Source code in fastfem/mesh/generator.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
|
create_a_rectangle_mesh(horizontal_length, vertical_length, nodes_in_horizontal_direction=None, nodes_in_vertical_direction=None, element_type='quadrangle', file_name=None)
¶
Create a 2D mesh of a rectangle.
Parameters:
-
horizontal_length
(float
) –The horizontal length of the rectangle.
-
vertical_length
(float
) –The vertical length of the rectangle.
-
nodes_in_horizontal_direction
(Optional[int]
, default:None
) –The number of nodes in the horizontal direction. Defaults to None.
-
nodes_in_vertical_direction
(Optional[int]
, default:None
) –The number of nodes in the vertical direction. Defaults to None.
-
element_type
(TwoDElementType
, default:'quadrangle'
) –The type of element to use. Defaults to "quadrangle".
-
file_name
(Optional[Path]
, default:None
) –The file name to save the mesh to. Defaults to None.
Returns:
-
RectangleMesh
–The mesh of the rectangle.
Source code in fastfem/mesh/fundamentals.py
create_a_square_mesh(side_length, nodes_in_horizontal_direction=None, nodes_in_vertical_direction=None, element_type='quadrangle', file_name=None)
¶
Create a 2D mesh of a square.
Parameters:
-
side_length
(float
) –The side length of the square.
-
nodes_in_horizontal_direction
(Optional[int]
, default:None
) –The number of nodes in the horizontal direction. Defaults to None.
-
nodes_in_vertical_direction
(Optional[int]
, default:None
) –The number of nodes in the vertical direction. Defaults to None.
-
element_type
(TwoDElementType
, default:'quadrangle'
) –The type of element to use. Defaults to "quadrangle".
Source code in fastfem/mesh/fundamentals.py
mesh(file_name=None)
¶
Create a mesh from all the created geometric entities so far and return it as a
Mesh
object. If a file name is provided, write the mesh to the file in the Gmsh
format.
Parameters:
-
file_name
(Optional[Path]
, default:None
) –The name of the file to write the mesh to. For example, "mesh.msh".
Returns:
-
Mesh
–The mesh as a
Mesh
object.