Giter Club home page Giter Club logo

fmesh's Introduction

fmesh

fmesh is a header-only mesh library to handle fracture surfaces written in C++.

Motivation

When I started to write a hydraulic fracturing simulator as a part of my research, there is no open source library for surface meshes which allows fractures to branch. OpenMesh and Surface Mesh are only surface mesh libraries I found but either of them does not support branching surfaces because of their half-edge mesh structure. Therefore, I had to write my own mesh class specialized for fracture surfaces for my dissertation. This library is an extension of the mesh class.

Features

  • Header-only.
  • Supports both triangular and quadrilateral faces. Only uniform meshes are currently supported.
  • Supports fracture branching.
  • Type-safe indices (vertex_index/edge_index/face_index) to access mesh entities (vertices, edges, and faces).
  • Range-based for loops for mesh entities.
  • property_array for mapping mesh indices to corresponding mesh properties like Boost.PropertyMap.
  • property_registry for easy access to mesh properties.

Requirements

  • C++17 (might reduce this requirement in the future.)

Basic Examples

#include <vector>
#include "fmesh/fixed_size_face.hpp"
#include "fmesh/fracture_mesh.hpp"

using namespace fmesh;

struct point {
  double x;
  double y;
  double z;

  point() = default;
  point(double tx, double ty, double tz) : x{tx}, y{ty}, z{tz} {}
};

int main() {
  fracture_mesh<point, tri_face> mesh;

  // Add vertices
  std::vector<vertex_index> v_ids;
  v_ids.push_back(mesh.add_vertex(0.0, 0.0, 0.0));
  v_ids.push_back(mesh.add_vertex(1.0, 0.0, 0.0));
  v_ids.push_back(mesh.add_vertex(0.0, 0.0, 1.0));
  v_ids.push_back(mesh.add_vertex(1.0, 0.0, 1.0));
  v_ids.push_back(mesh.add_vertex(0.0, 0.0, 2.0));
  v_ids.push_back(mesh.add_vertex(2.0, 0.0, 0.5));

  // Add faces
  std::vector<face_index> f_ids;
  f_ids.push_back(mesh.add_face(v_ids[0], v_ids[1], v_ids[2]));
  f_ids.push_back(mesh.add_face(v_ids[1], v_ids[3], v_ids[2]));
  f_ids.push_back(mesh.add_face(v_ids[2], v_ids[3], v_ids[4]));
  f_ids.push_back(mesh.add_face(v_ids[1], v_ids[5], v_ids[3]));

  // Access to a point
  const auto& p1 = mesh.vertex(v_idx[0]);

  // Access to a face
  const auto& f1 = mesh.face(f_idx[0]);

  // Range-based for
  for (auto&& vi : mesh.vertices()) {
      const auto& p = mesh.vertex(vi);
      // ...
  }

  for (auto&& ei : mesh.edges()) {
      const auto& e = mesh.edge(ei);
      // ...
  }

  for (auto&& fi : mesh.faces()) {
      const auto& f = mesh.face(fi);
      // ...
  }

  // Invalidate vertices and faces
  mesh.invalidate(v_ids[0]);
  mesh.invalidate(f_ids[1]);

  // Remove invalid mesh entities
  mesh.remove_invalid_entities();
}

Planned Features

  • Supports heterogeneous meshes (faces can have different number of vertices).
  • I/O to VTK formats.
  • Implements fracture_mesh<...>::remove_invalid_entities() function.
  • Mesh intersection algorithms.

fmesh's People

Contributors

shohirose avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.