A mesh that supports access to the actual elements with the numerical data they contain. More...
#include <Accessible_mesh.hpp>
Classes | |
class | Masked_mesh |
Creates a mask that allows kernel operations to be performed on a subset of the elements. More... | |
Public Types | |
typedef Vector_view< Vertex &, Vertex::Non_transferable_ptr, &ptr_convert< Vertex &, Vertex::Non_transferable_ptr > > | vertex_view |
convenience typedef for the Vector_view used to access Vertex objects | |
Public Member Functions | |
Accessible_mesh (Storage_params params, double root_size) | |
Accessible_mesh (std::string file_name, std::vector< Flow_bc * > extremal_bcs, Surface_geom *=nullptr, Flow_bc *surface_bc=nullptr) | |
Reads mesh from a file created by Mesh::write . | |
Accessible_mesh (std::string file_name, std::vector< Flow_bc * >, std::vector< Mesh_bc * >) | |
Reads mesh from a file created by Mesh::write . | |
double | root_size () override |
Storage_params | storage_params () |
View_by_type< Element > & | cartesian () |
View_by_type< Deformed_element > & | deformed () |
int | add_element (int ref_level, bool is_deformed, std::vector< int > position) override |
Element & | element (int ref_level, bool is_deformed, int serial_n) |
Access an element. If the parameters to not describe an existing element, throw an exception. | |
Sequence< Element & > & | elements () |
access all elements, both Cartesian and deformed | |
Sequence< Kernel_element & > & | kernel_elements () |
void | connect_cartesian (int ref_level, std::array< int, 2 > serial_n, Con_dir< Element > dir, std::array< bool, 2 > is_deformed={false, false}) override |
void | connect_deformed (int ref_level, std::array< int, 2 > serial_n, Con_dir< Deformed_element > direction) override |
Specify that two elements are connected via a deformed face. Requires both elements to be deformed. | |
void | connect_hanging (int coarse_ref_level, int coarse_serial, std::vector< int > fine_serial, Con_dir< Deformed_element >, bool coarse_deformed=false, std::vector< bool > fine_deformed={false, false, false, false}, std::array< bool, 2 > stretch={false, false}) override |
Sequence< Element_connection & > & | element_connections () |
int | add_boundary_condition (Flow_bc *, Mesh_bc *) override |
Acquires owenership of *flow_bc and *mesh_bc and constructs a Boundary_condition from them. | |
void | connect_boundary (int ref_level, bool is_deformed, int element_serial_n, int i_dim, int face_sign, int bc_serial_n) override |
Connect a face of an element to a boundary condition. | |
void | disconnect_boundary (int bc_sn) override |
delete all boundary connections involving a certain boundary condition | |
void | cleanup () override |
Does some work that has to happen after you manually add elements and/or connections. | |
void | add_tree (std::vector< Flow_bc * > extremal_bcs, Mat<> origin=Mat<>::Zero(3)) override |
Initializes meshing with bin/quad/octree topology. | |
void | set_surface (Surface_geom *geometry, Flow_bc *surface_bc, Eigen::VectorXd flood_fill_start=Eigen::VectorXd::Zero(3)) override |
Defines the surface geometry to be meshed as a boundary. | |
void | relax_and_match (int n_relax=0, double factor=.9) override |
void | set_unref_locks (std::function< bool(Element &)> lock_if=criteria::never) override |
bool | update (std::function< bool(Element &)> refine_criterion=criteria::always, std::function< bool(Element &)> unrefine_criterion=criteria::never) override |
Updates tree mesh based on user-supplied (un)refinement criteria. | |
void | set_all_smooth () override |
sets need_smooth to true for all vertices to perform global relaxation | |
void | relax (double factor=0.9) override |
Relax the vertices to improve mesh quality. | |
int | surface_bc_sn () override |
what is the serial number of the geometry surface BC? | |
Surface_geom & | surface_geometry () |
void | reset_masks () |
Resets effective number of masks created to 0 and invalidates existing masks. | |
std::vector< std::unique_ptr< Masked_mesh > > | preti_masks (const Basis &) |
Experimental feature. Ignore for now. | |
Vector_view< Boundary_condition &, Boundary_condition > | boundary_conditions () |
Boundary_condition & | boundary_condition (int bc_sn) |
get a boundary condition owned by this mesh by its serial number | |
Sequence< Boundary_connection & > & | boundary_connections () |
Sequence< Refined_face & > & | refined_faces () |
Sequence< Hanging_vertex_matcher & > & | hanging_vertex_matchers () |
int | n_elements () override |
number of elements currently in the mesh | |
Connection_validity | valid () override |
Returns a Connection_validity object describing whether the mesh connectivity is valid. | |
vertex_view | vertices () |
void | extrude (bool collapse=false, double offset=0, bool force=false) override |
void | connect_rest (int bc_sn) override |
connects all yet-unconnected faces to a boundary condition specified by serial number | |
std::vector< elem_handle > | elem_handles () override |
get handles for all elements currently in the mesh, in no particular order (mostly for testing/debugging) | |
Vector_view< Element_connection &, Element_face_connection< Deformed_element > *, ptr_convert< Element_connection &, Element_face_connection< Deformed_element > * > > | extruded_connections () |
void | write (std::string file_name) override |
void | export_polymesh (std::string dir_name) override |
write the mesh in the OpenFOAM PolyMesh format | |
const Stopwatch_tree & | stopwatch_tree () const override |
Obtain performance data. | |
template<> | |
Mesh_by_type< Element > & | mbt () |
template<> | |
Mesh_by_type< Deformed_element > & | mbt () |
![]() | |
void | extrude (Layer_sequence layers) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Public Attributes | |
double | buffer_dist |
how far must the center of an element be from the geometry relative to the nominal size | |
Protected Member Functions | |
void | reset_verts () override |
void | restore_verts () override |
A mesh that supports access to the actual elements with the numerical data they contain.
This level of access is required by the numerical scheme but should be hidden from the library user, who should not be concerned with numerical details.
hexed::Accessible_mesh::Accessible_mesh | ( | Storage_params | params, |
double | root_size ) |
hexed::Accessible_mesh::Accessible_mesh | ( | std::string | file_name, |
std::vector< Flow_bc * > | extremal_bcs, | ||
Surface_geom * | geometry = nullptr, | ||
Flow_bc * | surface_bc = nullptr ) |
Reads mesh from a file created by Mesh::write
.
Acquires ownership of boundary condition pointers. This variant is only for tree meshing. The surface boundary condition and geometry arguments must be specified iff the original mesh had a surface geometry (else exception).
hexed::Accessible_mesh::Accessible_mesh | ( | std::string | file_name, |
std::vector< Flow_bc * > | flow_bcs, | ||
std::vector< Mesh_bc * > | mesh_bcs ) |
Reads mesh from a file created by Mesh::write
.
Acquires ownership of boundary condition pointers. This variant is not for tree meshing.
|
overridevirtual |
Acquires owenership of *flow_bc
and *mesh_bc
and constructs a Boundary_condition
from them.
Returns a serial number which uniquely identifies the new boundary condition among this Mesh
's boundary conditions. It is recommended to use this with new
, like the constructor for std::unique_ptr
.
Implements hexed::Mesh.
|
overridevirtual |
Add an element at specified nominal position and serial number which uniquely identifies it among elements of this mesh with the same refinement level and deformedness.
Implements hexed::Mesh.
|
overridevirtual |
Initializes meshing with bin/quad/octree topology.
Creates a tree initialized with one element with ref level 0. Technically, free-form elements can also be created in the same mesh, but they will not be connected to the tree. Only one tree can be created. Connections and boundary conditions are set automatically for tree elements, so tree meshes should always automatically be valid unless you explicitly invalidate it with Mesh::disconnect_boundary
.
extremal_bcs | Boundary conditions to apply to elements with exposed faces at the extremal boundaries of the tree. Takes ownership of objects that the vector entries point to. It must contain exactly 2*n_dim entries. E.g. extremal_bcs[0] is the boundary condition to apply to the minimum \(x_0\) face, extremal_bcs[1] is the BC for the maximum \(x_0\) face, extremal_bcs[2] is for minimum \(x_1\). |
origin | The minimal corner of the tree root will be located at origin . |
Implements hexed::Mesh.
|
inline |
|
inline |
|
inline |
|
overridevirtual |
Does some work that has to happen after you manually add elements and/or connections.
Implements hexed::Mesh.
|
overridevirtual |
Connect a face of an element to a boundary condition.
This BC will now be applied to that face. i_dim
and face_sign
are used to identify which face of the element is participating in the boundary condition.
Implements hexed::Mesh.
|
overridevirtual |
Specify that two elements are connected via a Cartesian face. Note: although the interface is stipulated to be Cartesian, the elements themselves can be deformed
Implements hexed::Mesh.
|
overridevirtual |
Specify that two elements are connected via a deformed face. Requires both elements to be deformed.
Implements hexed::Mesh.
|
overridevirtual |
specify that an element of refinement level coarse_ref_level
is connected to some elements of refinement level coarse_ref_level + 1
. Coarse element comes first in Con_dir
. coarse_deformed
and fine_deformed
specify whether the elements are Cartesian or deformed. If any of the elements are Cartesian, the entire face is assumed to be Cartesian. In this case, all the vertices must occupy their nominal positions and the Con_dir
must be appropriate for a Cartesian connection. If these requirements are not satisfied, the invocation is incorrect. The number of fine elements can be any power of 2 (with a maximum of 2^(n_dim - 1
)). In order to match the faces when less than the maximum number of elements is used, stretch
specifies along which dimensions the fine elements are to be stretched to match the coarse. Only the first n_dim - 1
elements of stretch
are meaningful. The rest are ignored.
Implements hexed::Mesh.
|
overridevirtual |
connects all yet-unconnected faces to a boundary condition specified by serial number
Implements hexed::Mesh.
|
inline |
|
overridevirtual |
delete all boundary connections involving a certain boundary condition
Implements hexed::Mesh.
|
overridevirtual |
get handles for all elements currently in the mesh, in no particular order (mostly for testing/debugging)
Implements hexed::Mesh.
|
inline |
|
overridevirtual |
write the mesh in the OpenFOAM PolyMesh format
Implements hexed::Mesh.
|
overridevirtual |
Extrudes a layer of elements from unconnected faces:
collapse == true
then the new elements will be collapsed in the extrusion direction, such that they have zero volume and exist purely on the extruded face. If the mesh has already been extruded once and offset
is specified, the interior vertices of the extruded element will then be moved some distance toward the interior neighbor depending on the value of offset
, where offset == 0
yields no motion and offset == 1
moves them exactly to the neighbor. If the mesh has not been extruded, the vertices shall be moved in an unspecified manner (but maintaining a valid mesh state). Offsetting thus provides a rudimentary way of creating anisotropic wall layers. If force == false
(default) then in a tree mesh, only tree elements will be extruded from (which is necessary because some of the extruded elements from the previous refinement sweep may have non-surface-facing exposed faces). If force == true
then all exposed faces will be extruded from. Implements hexed::Mesh.
|
inline |
|
inline |
|
inlineoverridevirtual |
number of elements currently in the mesh
Implements hexed::Mesh.
std::vector< std::unique_ptr< Accessible_mesh::Masked_mesh > > hexed::Accessible_mesh::preti_masks | ( | const Basis & | basis | ) |
Experimental feature. Ignore for now.
Has to do with an experimental performance-enhancing feature where anisotropic elements are updated more frequently than isotropic ones. Not ready for production use, although it was the motivation for the Masked_mesh
feature.
|
inline |
|
overridevirtual |
Relax the vertices to improve mesh quality.
By default, relaxation is performed incrementally—only vertices of elements that are new in the most recent update()
cycle are smoothed. To smooth all, call set_all_smooth()
.
factor | A larger number yields more change in the mesh. 0 => no update, 1 => "full" update, > 1 allowed but suspect |
Implements hexed::Mesh.
|
overridevirtual |
Implements hexed::Mesh.
void hexed::Accessible_mesh::reset_masks | ( | ) |
Resets effective number of masks created to 0 and invalidates existing masks.
Masked_mesh
|
overrideprotectedvirtual |
Implements hexed::Mesh.
|
overrideprotectedvirtual |
Implements hexed::Mesh.
|
inlineoverridevirtual |
Implements hexed::Mesh.
|
overridevirtual |
sets need_smooth
to true
for all vertices to perform global relaxation
(only effective until the next update()
cycle)
Implements hexed::Mesh.
|
overridevirtual |
Defines the surface geometry to be meshed as a boundary.
Acquires ownership of the objects pointed to geometry
and surface_bc
. The geometric surface represented by geometry
is now a boundary of the domain and its boundary condition is surface_bc
. The flood fill algorithm is then executed starting at flood_fill_start
to determine which elements are in the domain and extrusion is executed to create a suitably body-fitted mesh. flood_fill_start
must have at least n_dim
entries and extra entries are ignored. If the mesh is excessively coarse, there may be no elements in the domain as they are all too close to the surfaces. So, Mesh::update
should be calling a few times before Mesh::set_surfaces
. Any surfaces defined by previous invokations of set_surface
are forgotten. sets the Element::unrefinement_locked
member of all elements
Implements hexed::Mesh.
|
overridevirtual |
Implements hexed::Mesh.
|
inlineoverridevirtual |
Obtain performance data.
Implements hexed::Mesh.
|
inlineoverridevirtual |
what is the serial number of the geometry surface BC?
Implements hexed::Mesh.
|
overridevirtual |
Updates tree mesh based on user-supplied (un)refinement criteria.
Evaluates refine_criterion
and unrefine_criterion
on every element in the tree (if a tree exists). Whenever refine_criterion
is true
and unrefine_criterion
is false
, that element is refined. Whenever unrefine_criterion
is true
and refine_criterion
is false
for a complete group of sibling elements, that group is unrefined. Since extruded elements cannot be directly refined or unrefined, their extrusion parents inherit their (un)refinement flags and any unrefinement locks. In order to satisfy some criteria regarding the refinement level of neighbors, some additional elements may be refined and some elements may not be unrefined. Both criteria must be thread-safe and must not depend on the order in which elements are processed. The flood fill and extrusion are also updated.
true
if the mesh was changed, else false
Implements hexed::Mesh.
|
overridevirtual |
Returns a Connection_validity
object describing whether the mesh connectivity is valid.
Suggested uses:
if (mesh.valid()) {\\...do something that requires a valid mesh}
mesh.valid().assert_valid();
Implements hexed::Mesh.
Accessible_mesh::vertex_view hexed::Accessible_mesh::vertices | ( | ) |
|
overridevirtual |
Implements hexed::Mesh.
double hexed::Accessible_mesh::buffer_dist |
how far must the center of an element be from the geometry relative to the nominal size
Defaults to \( \frac{\sqrt{n_d}}{2} \). You can modify it, but it cannot be less than this.