GRINS-0.8.0
|
#include <rayfire_mesh.h>
Public Member Functions | |
RayfireMesh (libMesh::Point &origin, libMesh::Real theta) | |
2D Constructor More... | |
RayfireMesh (libMesh::Point &origin, libMesh::Real theta, libMesh::Real phi) | |
3D Constructor More... | |
RayfireMesh (const GetPot &input, const std::string &qoi_string) | |
Input File Constructor. More... | |
RayfireMesh (const RayfireMesh &original) | |
Copy Constructor. More... | |
void | init (const libMesh::MeshBase &mesh_base) |
Initialization. More... | |
const libMesh::Elem * | map_to_rayfire_elem (const libMesh::dof_id_type elem_id) |
This function takes in an elem_id on the main mesh and returns an elem from the 1D rayfire mesh. More... | |
void | elem_ids_in_rayfire (std::vector< libMesh::dof_id_type > &id_vector) const |
Returns a vector of elem IDs that are currently along the rayfire. More... | |
void | reinit (const libMesh::MeshBase &mesh_base) |
Checks for refined and coarsened main mesh elements along the rayfire path. More... | |
Private Member Functions | |
RayfireMesh () | |
User should never call the default constructor. More... | |
libMesh::Elem * | get_rayfire_elem (const libMesh::dof_id_type elem_id) |
Private function to get a rayfire elem from main_mesh elem ID. More... | |
const libMesh::Elem * | get_next_elem (const libMesh::Elem *cur_elem, libMesh::Point &start_point, libMesh::Point &end_point, bool same_parent=false) |
Calculate the intersection point. More... | |
bool | check_valid_point (libMesh::Point &intersection_point, libMesh::Point &start_point, const libMesh::Elem &edge_elem, libMesh::Point &next_point) |
Ensure the calculated intersection point is on the edge_elem and is not the start_point. More... | |
const libMesh::Elem * | get_correct_neighbor (libMesh::Point &start_point, libMesh::Point &end_point, const libMesh::Elem *cur_elem, unsigned int side, bool same_parent) |
Knowing the end_point, get the appropraite next elem along the path. More... | |
void | check_origin_on_boundary (const libMesh::Elem *start_elem) |
Ensure the supplied origin is on a boundary of the mesh. More... | |
const libMesh::Elem * | get_start_elem (const libMesh::MeshBase &mesh_base) |
Get the correct starting elem corresponding to _origin. More... | |
bool | validate_edge (const libMesh::Point &start_point, const libMesh::Point &end_point, const libMesh::Elem *side_elem, const libMesh::Elem *neighbor) |
Ensures the rayfire doesn't wander into the middle of an elem. More... | |
bool | rayfire_in_elem (const libMesh::Point &end_point, const libMesh::Elem *elem) |
Walks a short distance along the rayfire and checks if elem contains that point. More... | |
bool | newton_solve_intersection (libMesh::Point &initial_point, const libMesh::Elem *edge_elem, libMesh::Point &intersection_point) |
Iterative solver for calculating the intersection point of the rayfire on the side of an elem. More... | |
void | refine (const libMesh::Elem *main_elem, libMesh::Elem *rayfire_elem) |
Refinement of a rayfire element whose main mesh counterpart was refined. More... | |
void | coarsen (const libMesh::Elem *rayfire_elem) |
Coarsening of a rayfire element whose main mesh counterpart was coarsened. More... | |
Private Attributes | |
const unsigned int | _dim |
Dimension of the main mesh. More... | |
libMesh::Point | _origin |
Origin point. More... | |
libMesh::Real | _theta |
Rayfire Spherical polar angle (in radians) More... | |
libMesh::Real | _phi |
Rayfire Spherical azimuthal angle (in radians) More... | |
libMesh::UniquePtr< libMesh::Mesh > | _mesh |
Internal 1D mesh of EDGE2 elements. More... | |
std::map< libMesh::dof_id_type, libMesh::dof_id_type > | _elem_id_map |
Map of main mesh elem_id to rayfire mesh elem_id. More... | |
This class performs a rayfire across a given mesh. The user supplies an origin point on the mesh boundary, and spherical angle(s) theta (and phi for 3D) to describe the direction of the rayfire. As is standard in spherical coordinates, theta is the angle from the x-axis in the xy-plane, with counterclockwise being positive. -2π ≤ theta ≤ +2π. Phi is the angle from the xy-plane, with phi>0 being in the positive half of the z-plane. -π ≤ phi ≤ +π
Starting at the given origin point, this class will walk in a straight line across the mesh in the prescribed direction. On each element along the line, the class will calculate the point where it enters and leaves that element. Knowing the entering and exiting points, an EDGE2 element is created with those points as nodes, and is added to an internal 1D mesh. This repeats until a main mesh boundary is reached.
The intent of this class is to use the 1D mesh to integrate quantities along the rayfire path. Using the map_to_rayfire_elem() function, a separate integration class can access the 1D elements, prescribe a desired quadrature rule, and perform integration directly along the line, rather than using the entire 2D/3D elements of the main mesh.
Refinement and coarsening of the rayfire mesh are supported through the reinit() function.
Definition at line 65 of file rayfire_mesh.h.
GRINS::RayfireMesh::RayfireMesh | ( | libMesh::Point & | origin, |
libMesh::Real | theta | ||
) |
2D Constructor
This is restricted to 2D meshes. The init() function must be called to perform the actual rayfire.
origin | Origin point (x,y) of the rayfire on mesh boundary |
theta | Spherical polar angle (in radians) |
Definition at line 51 of file rayfire_mesh.C.
References _theta, and GRINS::Constants::pi.
GRINS::RayfireMesh::RayfireMesh | ( | libMesh::Point & | origin, |
libMesh::Real | theta, | ||
libMesh::Real | phi | ||
) |
3D Constructor
This is restricted to 3D meshes. The init() function must be called to perform the actual rayfire.
origin | Origin point (x,y,z) of the rayfire on mesh boundary |
theta | Spherical polar angle (in radians) |
phi | Spherical azimuthal angle (in radians) |
Definition at line 41 of file rayfire_mesh.C.
GRINS::RayfireMesh::RayfireMesh | ( | const GetPot & | input, |
const std::string & | qoi_string | ||
) |
Input File Constructor.
Creates rayfire from parameters specified in input file section: QoI/'qoi_string'/Rayfire/
Definition at line 61 of file rayfire_mesh.C.
References _origin, _theta, and GRINS::Constants::pi.
GRINS::RayfireMesh::RayfireMesh | ( | const RayfireMesh & | original | ) |
Copy Constructor.
Required to deep-copy _mesh and _elem_id_map
Definition at line 92 of file rayfire_mesh.C.
References _elem_id_map, and _mesh.
|
private |
User should never call the default constructor.
|
private |
Ensure the supplied origin is on a boundary of the mesh.
Definition at line 247 of file rayfire_mesh.C.
References _origin.
Referenced by init().
|
private |
Ensure the calculated intersection point is on the edge_elem and is not the start_point.
Definition at line 355 of file rayfire_mesh.C.
Referenced by get_next_elem().
|
private |
Coarsening of a rayfire element whose main mesh counterpart was coarsened.
Definition at line 731 of file rayfire_mesh.C.
References _elem_id_map, _mesh, _origin, and get_rayfire_elem().
Referenced by reinit().
void GRINS::RayfireMesh::elem_ids_in_rayfire | ( | std::vector< libMesh::dof_id_type > & | id_vector | ) | const |
Returns a vector of elem IDs that are currently along the rayfire.
Definition at line 187 of file rayfire_mesh.C.
References _elem_id_map, and _mesh.
|
private |
Knowing the end_point, get the appropraite next elem along the path.
Definition at line 432 of file rayfire_mesh.C.
References rayfire_in_elem(), and validate_edge().
Referenced by get_next_elem().
|
private |
Calculate the intersection point.
[out] | end_point | The intersection point in (x,y) coordinates |
Definition at line 323 of file rayfire_mesh.C.
References check_valid_point(), get_correct_neighbor(), and newton_solve_intersection().
Referenced by init(), and refine().
|
private |
Private function to get a rayfire elem from main_mesh elem ID.
Does not return a const pointer, and is used within this class to simplify rayfire elem access.
Also used by map_to_rayfire_elem(), which adds a const to prevent modification outside this class.
Definition at line 308 of file rayfire_mesh.C.
References _elem_id_map, and _mesh.
Referenced by coarsen(), and map_to_rayfire_elem().
|
private |
Get the correct starting elem corresponding to _origin.
Definition at line 275 of file rayfire_mesh.C.
References _origin, and rayfire_in_elem().
Referenced by init().
void GRINS::RayfireMesh::init | ( | const libMesh::MeshBase & | mesh_base | ) |
Initialization.
This function performs the rayfire and assembles the 1D mesh. Call this immediately after the constructor. Must be called before any refinements of the main mesh.
mesh_base | Reference to the main mesh |
Definition at line 104 of file rayfire_mesh.C.
References _dim, _elem_id_map, _mesh, _origin, check_origin_on_boundary(), get_next_elem(), and get_start_elem().
const libMesh::Elem * GRINS::RayfireMesh::map_to_rayfire_elem | ( | const libMesh::dof_id_type | elem_id | ) |
This function takes in an elem_id on the main mesh and returns an elem from the 1D rayfire mesh.
elem_id | The ID of the elem on the main mesh |
Definition at line 181 of file rayfire_mesh.C.
References get_rayfire_elem().
|
private |
Iterative solver for calculating the intersection point of the rayfire on the side of an elem.
The rayfire line can be represented in point-slope form:
y-y0 = m(x-x0)
where m is the slope and (x0,y0) is the known initial_point. To find the intersection point, we will use a parametric representation of the edge utilizing the shape functions as such:
X(ξ) = sum( xj φj(ξ) )
Y(ξ) = sum( yj φj(ξ) )
where xj and yj are the node x- and y-coordinates, respectively, and φj is the value of shape function j at reference coordinate ξ
The intersection point is then where the x and y coordinates from the point-slope equation equal the X and Y coordinates from the parametric equations for the given edge, respectively. We can then form a residual by substituting the parametric coordinates into the point slope form and bringing all terms to one side of the equation as:
f = 0 = m(X(ξ)-x0) - (Y(ξ)-y0)
The residual is then a function of a single parameter, namely the reference coordinate ξ. The derivative is rather trivial and can be expressed as
df = m*dX - dY
where
dX = sum( xj dφj/dξ )
dY = sum( yj dφj/dξ )
[out] | intersection_point | The calculated intersection point (only set if convergence is achieved) |
Definition at line 541 of file rayfire_mesh.C.
References _theta.
Referenced by get_next_elem().
|
private |
Walks a short distance along the rayfire and checks if elem contains that point.
Definition at line 372 of file rayfire_mesh.C.
References _theta.
Referenced by get_correct_neighbor(), get_start_elem(), and refine().
|
private |
Refinement of a rayfire element whose main mesh counterpart was refined.
Definition at line 618 of file rayfire_mesh.C.
References _elem_id_map, _mesh, _origin, get_next_elem(), and rayfire_in_elem().
Referenced by reinit().
void GRINS::RayfireMesh::reinit | ( | const libMesh::MeshBase & | mesh_base | ) |
Checks for refined and coarsened main mesh elements along the rayfire path.
They are then passed to refine() and coarsen(), respectively, to update the rayfire mesh.
Only 1 level of refinement and/or coarsening can be done between reinit() calls. Note that this is not limited to doing either refinement or coarsening between reinits. Both can be done on different elements, as long as they are only 1 level in either direction.
mesh | reference to main mesh, needed to get Elem* from the stored elem_id's |
Definition at line 198 of file rayfire_mesh.C.
References _elem_id_map, _mesh, coarsen(), and refine().
|
private |
Ensures the rayfire doesn't wander into the middle of an elem.
Definition at line 392 of file rayfire_mesh.C.
Referenced by get_correct_neighbor().
|
private |
|
private |
Map of main mesh elem_id to rayfire mesh elem_id.
Definition at line 151 of file rayfire_mesh.h.
Referenced by coarsen(), elem_ids_in_rayfire(), get_rayfire_elem(), init(), RayfireMesh(), refine(), and reinit().
|
private |
Internal 1D mesh of EDGE2 elements.
Definition at line 148 of file rayfire_mesh.h.
Referenced by coarsen(), elem_ids_in_rayfire(), get_rayfire_elem(), init(), RayfireMesh(), refine(), and reinit().
|
private |
Origin point.
Definition at line 139 of file rayfire_mesh.h.
Referenced by check_origin_on_boundary(), coarsen(), get_start_elem(), init(), RayfireMesh(), and refine().
|
private |
Rayfire Spherical azimuthal angle (in radians)
Definition at line 145 of file rayfire_mesh.h.
|
private |
Rayfire Spherical polar angle (in radians)
Definition at line 142 of file rayfire_mesh.h.
Referenced by newton_solve_intersection(), rayfire_in_elem(), and RayfireMesh().