Skip to content

Commit

Permalink
Merge branch 'BoundingBoxBoundaryGen' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBEllis authored Sep 4, 2024
2 parents d37f73c + 03b6286 commit 867f064
Show file tree
Hide file tree
Showing 14 changed files with 753 additions and 71 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ There are several flags you can pass to the example binaries. These influence th
| `--max_tri` | Prints a help message showing all of the options detailed here. |
| `--bound_subdiv` | Defines the number of subdivisions along one edge of the cubic boundary. |
| `--bound_len` | Defines the edge length of the cubic boundary of the vacuum region |
| `--boundary_type` | Defines the type of boundary generated. Set to either ``Cube`` or ``Bbox`` |
| `--scale_[x,y,z]` | If using the `Bbox` boundary type, use these options to specify the scaling factor used for each dimension. By default each dimension is given a scale factor of 1.2 (i.e. 120%) |
| `--sideset_one_id` | For a coil problem, this option defines the ID of your first coil sideset that you want to be coplanar with the boundary. |
| `--sideset_two_id` | For a coil problem, this option defines the ID of your second coil sideset that you want to be coplanar with the boundary. |

Expand Down
9 changes: 0 additions & 9 deletions VacuumMeshing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ option(LIBIGL_INSTALL "Enable installation of libigl targets" ON)

# libigl module options
option(LIBIGL_EMBREE "Build target igl::embree" ON)
option(LIBIGL_GLFW "Build target igl::glfw" OFF)
option(LIBIGL_IMGUI "Build target igl::imgui" OFF)
option(LIBIGL_OPENGL "Build target igl::opengl" OFF)
option(LIBIGL_PNG "Build target igl::png" OFF)
option(LIBIGL_PREDICATES "Build target igl::predicates" OFF)
option(LIBIGL_XML "Build target igl::xml" OFF)
option(LIBIGL_COPYLEFT_CGAL "Build target igl_copyleft::cgal" OFF)
option(LIBIGL_COPYLEFT_COMISO "Build target igl_copyleft::comiso" OFF)
option(LIBIGL_COPYLEFT_CORE "Build target igl_copyleft::core" ON)
option(LIBIGL_COPYLEFT_CORK "Build target igl_copyleft::cork" OFF)
option(LIBIGL_COPYLEFT_TETGEN "Build target igl_copyleft::tetgen" ON)
option(LIBIGL_RESTRICTED_TRIANGLE "Build target igl_restricted::triangle" ON)

Expand Down
43 changes: 42 additions & 1 deletion VacuumMeshing/include/BoundaryGeneration/BoundaryGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,31 @@ class BoundaryGenerator {
virtual void addBoundary(double length, int subdivisions,
std::string tri_flags);


/** Method generates a rectangular mesh comprised of tri elements.
\c verts will be populated with the vertex data, \c elems will be populated
with the element connectivity data. \c x_dim and \c y_dim will allow the
user to change the length of the edges of the square. \c x_subdiv and \c y_subdiv will allow
you to set how many elements there should be per edge*/
void genTriangulatedRect(Eigen::MatrixXd &rect_verts,
Eigen::MatrixXi &rect_elems, double x_dim, double y_dim,
int x_subdiv, int y_subdiv, std::string tri_flags);

/** Method generates a rectangular boundary comprised of just edge elements, i.e. the perimeter of the rectangle.
\c verts will be populated with the vertex data, \c elems will be populated
with the element connectivity data. \c x_dim and \c y_dim will allow the
user to change the length of the edges of the square. \c x_subdiv and \c y_subdiv will allow
you to set how many elements there should be per edge*/
void genRect(Eigen::MatrixXd &edge_verts,
Eigen::MatrixXi &edge_elems, double x_dim, double y_dim,
int x_subdiv, int y_subdiv);

/** Method generates a square boundary comprised of just edge elements.
\c verts will be populated with the vertex data, \c elems will be populated
with the element connectivity data. \c length and \c subdivisions allow the
user to change the length of the edges of the square, as well as how many
elements there should be per edge*/
void genSquare(Eigen::MatrixXd &verts, Eigen::MatrixXi &elems, double length,
void genSquare(Eigen::MatrixXd &edge_verts, Eigen::MatrixXi &edge_elems, double length,
int subdivisions);

/** Method for combining two libigl meshes that you are SURE do NOT intersect
Expand All @@ -61,10 +80,30 @@ class BoundaryGenerator {
Eigen::MatrixXi &boundary_elements, double length,
int subdivisions, std::string tri_flags);

/** Generates a cuboid boundary based off of the bounding box dimensions of the input mesh */
void genBoundingBoxBoundary(Eigen::MatrixXd &boundary_vertices,
Eigen::MatrixXi &boundary_elements,
double scaling_x, double scaling_y,
double scaling_z, int subdivisions,
std::string tri_flags);


/** Function overload that accepts one scaling factor for all dimensions */
void genBoundingBoxBoundary(Eigen::MatrixXd &boundary_vertices,
Eigen::MatrixXi &boundary_elements,
double scaling_factor, int subdivisions,
std::string tri_flags);

void addBoundingBoxBoundary(double scaling_x, double scaling_y, double scaling_z,
int subdivisions, std::string tri_flags);

void translateMesh(Eigen::MatrixXd &verts, Eigen::Vector3d translationVector);

void translateMesh(Eigen::MatrixXd &verts, std::vector<double> &translationVector);

void getBoundaryDimensions(double scaling_factor);

void getBoundaryDimensions(double scaling_x, double scaling_y, double scaling_z);

/**Checks to see if the boundary will overlap with component mesh.*/
void checkBoundary(const double &length);
Expand All @@ -84,5 +123,7 @@ class BoundaryGenerator {

std::vector<double> centroid_;

double bb_x_dim, bb_y_dim, bb_z_dim;

private:
};
34 changes: 34 additions & 0 deletions VacuumMeshing/include/BoundaryGeneration/CoilBoundaryGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class CoilBoundaryGenerator : public BoundaryGenerator {
virtual void addBoundary(const double length, const int subdivisions,
const std::string tri_flags) override;

void addCoilBoundingBoxBoundary(const double scaling_x,
const double scaling_y,
const double scaling_z,
const int subdivisions,
const std::string tri_flags);

/** Method to generate the boundary for a coil. A method exists specifically
for coils, as often the boundary needs to be coplanar with some coil "in"
and "out" sidesets. This method will generate the correct boundary for a
Expand All @@ -24,6 +30,14 @@ vertices and faces (vertice connectivity data)*/
void generateCoilBoundary(const double length, const int subdivisions,
const std::string tri_flags);



void generateCoilBoundingBoxBoundary(const double scaling_x,
const double scaling_y,
const double scaling_z,
const int subdivisions,
const std::string tri_flags);

/** Method takes in an Eigen::Matrix "basis_matrix" by reference. This matrix
will be populated with the basis vectors for a cartesian coordinate system.
The new systems "XY" plane is defined by 3 points contained within
Expand Down Expand Up @@ -60,6 +74,13 @@ tri mesh will be stored.*/
Eigen::MatrixXi &tri_elems, double length,
int subdivisions, std::string tri_flags);


void generateCoilFaceBound(
const Eigen::MatrixXd &verts, const Eigen::MatrixXi &elems,
const Eigen::MatrixXd &holes, Eigen::MatrixXd &tri_vertices,
Eigen::MatrixXi &tri_elems, double x_dim, double y_dim, int x_subdiv, int y_subdiv,
std::string tri_flags);

/** Method for generating the face of the cubic boundary that is coplanar with
the coil sidesets. Here V and F are the vertices and faces(connectivity
data) for the input mesh, which is probably composed of 2D edge elements.
Expand All @@ -76,6 +97,13 @@ tri mesh will be stored.*/
void genSidesetBounds(Eigen::MatrixXd &verts, Eigen::MatrixXi &elems,
const double length, const int subdivisions);

void genSidesetBounds(Eigen::MatrixXd &verts,
Eigen::MatrixXi &elems,
const double x_dim,
const double y_dim,
const int x_subdiv,
const int y_subdiv);

void genSidesetBounds(libMesh::Mesh &sideset_mesh,
libMesh::Mesh &remaining_boundary);

Expand All @@ -100,6 +128,10 @@ tri mesh will be stored.*/
Eigen::MatrixXi &triElems, double length,
int subdivisions, std::string tri_flags);

void genRemainingFiveBoundaryFaces(Eigen::MatrixXd &tri_vertices, Eigen::MatrixXi &tri_elems,
double x_dim, double y_dim, double z_dim,
int x_subdiv, int y_subdiv, int z_subdiv, std::string tri_flags);

/** For our coil problem, to generate the part of the boundary that is
coplanar with the coil sidesets correctly*/
void getCoplanarSeedPoints(libMesh::Mesh &mesh, Eigen::MatrixXd &seed_points);
Expand All @@ -108,4 +140,6 @@ tri mesh will be stored.*/
private:
const int coil_sideset_one_id;
const int coil_sideset_two_id;

double coil_sideset_elevation_;
};
14 changes: 14 additions & 0 deletions VacuumMeshing/include/Utils/parseFlags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,23 @@ struct inputFlags {

int coil_sideset_two_id = 2;

// Scaling factors for bounding box generation, default is 120% scaling on all axes
double scale_factor_x = 1.2;
double scale_factor_y = 1.2;
double scale_factor_z = 1.2;

void setSwitches();
// Method to print help message
void helpMessage();

enum BoundaryType{
CUBE,
BOUNDING_BOX
};

BoundaryType bound_type = CUBE;

std::unordered_map<std::string, BoundaryType> boundMap{{"Cube", CUBE}, {"BBox", BOUNDING_BOX}};
};

// Function that will return an inputFlags struct from which we can access CLI
Expand Down
7 changes: 5 additions & 2 deletions VacuumMeshing/include/VacuumGeneration/VacuumGenerator.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "Utils/libmeshConversions.hpp"
#include "Utils/utils.hpp"
#include "libmesh/mesh.h"
#include <filesystem>
#include <igl/copyleft/tetgen/tetrahedralize.h>
Expand Down Expand Up @@ -56,12 +56,15 @@ class VacuumGenerator {
// Get seeds
Eigen::MatrixXd getSeeds(libMesh::Mesh mesh) const;

// Get tolerance for mesh merging
void setMergeToleranceAuto();

protected:
// References to mesh objects passed in via constructor
libMesh::Mesh &mesh_, &boundary_mesh_, &surface_mesh_, &vacuum_mesh_;

// Tolerance value used for rTree merging
double merge_tolerance_ = 1e-07;
double mesh_merge_tolerance_;
double seeding_tolerance_ = 1e-07;

const std::multimap<unsigned int, unsigned int>* surface_face_map_;
Expand Down
Loading

0 comments on commit 867f064

Please sign in to comment.