hexed 0.4.0
 
Loading...
Searching...
No Matches
hexed::Accessible_mesh Class Reference

A mesh that supports access to the actual elements with the numerical data they contain. More...

#include <Accessible_mesh.hpp>

Inheritance diagram for hexed::Accessible_mesh:
hexed::Mesh

Classes

class  Masked_mesh
 Creates a mask that allows kernel operations to be performed on a subset of the elements. More...
 

Public Member Functions

 Accessible_mesh (Storage_params params, double root_size, Turbulence_model turb)
 
 Accessible_mesh (std::string file_name, std::vector< std::shared_ptr< Flow_bc > > extremal_bcs, Turbulence_model, std::shared_ptr< Surface_geom >={}, std::shared_ptr< Flow_bc > surface_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 ()
 
Elementelement (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, Connection_direction dir, std::array< bool, 2 > is_deformed={false, false}) override
 
void connect_deformed (int ref_level, std::array< Int, 2 > serial_n, Connection_direction 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, Connection_direction, bool coarse_deformed=false, std::vector< bool > fine_deformed={false, false, false, false}, std::array< bool, 2 > stretch={false, false}) override
 
next::Sequence< Neighbor_connection & > neighbor_connections (bool is_deformed)
 
next::Sequence< std::vector< Face_refinement > & > face_refinements ()
 
int add_boundary_condition (std::shared_ptr< Flow_bc >) override
 Acquires owenership of *flow_bc and adds it as a boundary condition. 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.
 
void connect_boundary (int ref_level, bool is_deformed, Int element_serial_n, int i_dim, int face_sign, int bc_serial_n) override
 
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.
 
next::Sequence< next::Vertex & > shape_vertices ()
 
next::Sequence< next::Vertex & > shape_boundary_vertices ()
 
void add_tree (std::vector< std::shared_ptr< Flow_bc > > extremal_bcs, Mat<> origin=Mat<>::Zero(3)) override
 Initializes meshing with bin/quad/octree topology.
 
void set_surface (std::shared_ptr< Surface_geom > geometry, std::shared_ptr< 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 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.
 
Adaptation_result plan_adaptation (std::function< bool(Element &, int)> refine_criterion, std::function< bool(Element &, int)> unrefine_criterion, bool set_floor) override
 
void execute_adaptation () override
 
int surface_bc_sn () override
 
Surface_geomsurface_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 &, bool iso)
 Experimental feature. Ignore for now.
 
next::Sequence< Flow_bc & > boundary_conditions ()
 
Flow_bcboundary_condition (int bc_sn)
 get a boundary condition owned by this mesh by its serial number
 
next::Sequence< Boundary_connection & > boundary_connections ()
 
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.
 
void assert_valid ()
 if any invalid mesh connections are found, throws an exception with a diagnostic visualization
 
void extrude (bool collapse=false, 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_handleelem_handles () override
 get handles for all elements currently in the mesh, in no particular order (mostly for testing/debugging)
 
void write (std::string file_name) override
 
void export_polymesh (std::string dir_name) override
 write the mesh in the OpenFOAM PolyMesh format
 
void visualize_deformed (std::string format, std::string file_name, double time=0)
 
void visualize (std::string format, std::string file_name, double time=0) override
 visualize the mesh
 
const Stopwatch_treestopwatch_tree () const override
 Obtain performance data.
 
template<>
Mesh_by_type< Element > & mbt ()
 
template<>
Mesh_by_type< Deformed_element > & mbt ()
 
Automated tree meshing
observers
I/O

write this mesh to a file to be reused in another simulation

Public Attributes

double buffer_dist
 how far must the center of an element be from the geometry relative to the nominal size
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Accessible_mesh() [1/2]

hexed::Accessible_mesh::Accessible_mesh ( Storage_params params,
double root_size,
Turbulence_model turb )
Parameters
paramsparameters specifying what data is stored in each Element (row size, number of dimensions, etc.)
root_sizedefines the root_size of the mesh.
turbdefines the turbulence model that will be used by the solver, which is relevant because it determines the amound of memory that must be allocated for each element.

◆ Accessible_mesh() [2/2]

hexed::Accessible_mesh::Accessible_mesh ( std::string file_name,
std::vector< std::shared_ptr< Flow_bc > > extremal_bcs,
Turbulence_model turb,
std::shared_ptr< Surface_geom > geometry = {},
std::shared_ptr< Flow_bc > surface_bc = {} )

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).

Member Function Documentation

◆ add_boundary_condition()

int hexed::Accessible_mesh::add_boundary_condition ( std::shared_ptr< Flow_bc > flow_bc)
overridevirtual

Acquires owenership of *flow_bc and adds it as a boundary condition. 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.

◆ add_tree()

void hexed::Accessible_mesh::add_tree ( std::vector< std::shared_ptr< Flow_bc > > extremal_bcs,
Mat<> origin = Mat<>::Zero(3) )
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.

Parameters
extremal_bcsBoundary 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\).
originThe minimal corner of the tree root will be located at origin.

Implements hexed::Mesh.

◆ boundary_conditions()

next::Sequence< Flow_bc & > hexed::Accessible_mesh::boundary_conditions ( )
Returns
a view of all Bounday_condition objects owned by this mesh

◆ boundary_connections()

next::Sequence< Boundary_connection & > hexed::Accessible_mesh::boundary_connections ( )
Returns
a view of all connections between an element and a boundary condition

◆ cartesian()

View_by_type< Element > & hexed::Accessible_mesh::cartesian ( )
inline
Returns
a View_by_type containing only the Cartesian elements in the mesh

◆ cleanup()

void hexed::Accessible_mesh::cleanup ( )
overridevirtual

Does some work that has to happen after you manually add elements and/or connections.

Implements hexed::Mesh.

◆ connect_boundary()

void hexed::Accessible_mesh::connect_boundary ( int ref_level,
bool is_deformed,
Int element_serial_n,
int i_dim,
int face_sign,
int bc_serial_n )
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.

◆ connect_cartesian()

void hexed::Accessible_mesh::connect_cartesian ( int ref_level,
std::array< Int, 2 > serial_n,
Connection_direction dir,
std::array< bool, 2 > is_deformed = {false, false} )
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.

◆ connect_deformed()

void hexed::Accessible_mesh::connect_deformed ( int ref_level,
std::array< Int, 2 > serial_n,
Connection_direction direction )
overridevirtual

Specify that two elements are connected via a deformed face. Requires both elements to be deformed.

Implements hexed::Mesh.

◆ connect_hanging()

void hexed::Accessible_mesh::connect_hanging ( int coarse_ref_level,
Int coarse_serial,
std::vector< Int > fine_serial,
Connection_direction ,
bool coarse_deformed = false,
std::vector< bool > fine_deformed = {false, false, false, false},
std::array< bool, 2 > stretch = {false, false} )
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 Connection_direction. 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 Connection_direction 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.

◆ connect_rest()

void hexed::Accessible_mesh::connect_rest ( int bc_sn)
overridevirtual

connects all yet-unconnected faces to a boundary condition specified by serial number

Implements hexed::Mesh.

◆ deformed()

View_by_type< Deformed_element > & hexed::Accessible_mesh::deformed ( )
inline
Returns
a View_by_type containing only the deformed elements in the mesh

◆ disconnect_boundary()

void hexed::Accessible_mesh::disconnect_boundary ( int bc_sn)
overridevirtual

delete all boundary connections involving a certain boundary condition

Implements hexed::Mesh.

◆ elem_handles()

std::vector< Mesh::elem_handle > hexed::Accessible_mesh::elem_handles ( )
overridevirtual

get handles for all elements currently in the mesh, in no particular order (mostly for testing/debugging)

Implements hexed::Mesh.

◆ execute_adaptation()

void hexed::Accessible_mesh::execute_adaptation ( )
overridevirtual

Implements hexed::Mesh.

◆ export_polymesh()

void hexed::Accessible_mesh::export_polymesh ( std::string dir_name)
overridevirtual

write the mesh in the OpenFOAM PolyMesh format

Implements hexed::Mesh.

◆ extrude()

void hexed::Accessible_mesh::extrude ( bool collapse = false,
bool force = false )
overridevirtual

convenience typedef for the Vector_view used to access Vertex objects

Note
test for this is in test_Solver.cpp so that the result can be visualized

Implements hexed::Mesh.

◆ n_elements()

int hexed::Accessible_mesh::n_elements ( )
inlineoverridevirtual

number of elements currently in the mesh

Implements hexed::Mesh.

◆ plan_adaptation()

Mesh::Adaptation_result hexed::Accessible_mesh::plan_adaptation ( std::function< bool(Element &, int)> refine_criterion,
std::function< bool(Element &, int)> unrefine_criterion,
bool set_floor )
overridevirtual

Implements hexed::Mesh.

◆ preti_masks()

std::vector< std::unique_ptr< Accessible_mesh::Masked_mesh > > hexed::Accessible_mesh::preti_masks ( const Basis & basis,
bool iso )

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.

◆ reset_masks()

void hexed::Accessible_mesh::reset_masks ( )

Resets effective number of masks created to 0 and invalidates existing masks.

See also
Masked_mesh

◆ root_size()

double hexed::Accessible_mesh::root_size ( )
inlineoverridevirtual
Returns
Nominal size ( \(\Delta h\)) of elements with refinement level 0.

Implements hexed::Mesh.

◆ set_surface()

void hexed::Accessible_mesh::set_surface ( std::shared_ptr< Surface_geom > geometry,
std::shared_ptr< Flow_bc > surface_bc,
Eigen::VectorXd flood_fill_start = Eigen::VectorXd::Zero(3) )
overridevirtual

Defines the surface geometry to be meshed as a boundary.

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.

◆ set_unref_locks()

void hexed::Accessible_mesh::set_unref_locks ( std::function< bool(Element &)> lock_if = criteria::never)
overridevirtual

Implements hexed::Mesh.

◆ stopwatch_tree()

const Stopwatch_tree & hexed::Accessible_mesh::stopwatch_tree ( ) const
inlineoverridevirtual

Obtain performance data.

Implements hexed::Mesh.

◆ surface_bc_sn()

int hexed::Accessible_mesh::surface_bc_sn ( )
inlineoverridevirtual

what is the serial number of the geometry surface BC?

Implements hexed::Mesh.

◆ update()

bool hexed::Accessible_mesh::update ( std::function< bool(Element &)> refine_criterion = criteria::always,
std::function< bool(Element &)> unrefine_criterion = criteria::never )
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.

Returns
true if the mesh was changed, else false

Implements hexed::Mesh.

◆ valid()

Mesh::Connection_validity hexed::Accessible_mesh::valid ( )
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.

◆ visualize()

void hexed::Accessible_mesh::visualize ( std::string format,
std::string file_name,
double time = 0 )
overridevirtual

visualize the mesh

For debugging. For actual simulations, use Solver::visualize_field.

Implements hexed::Mesh.

◆ write()

void hexed::Accessible_mesh::write ( std::string file_name)
overridevirtual

Implements hexed::Mesh.

Member Data Documentation

◆ buffer_dist

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.


The documentation for this class was generated from the following files: