https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: 51d08c6ee7d36532c90fb73a217fe1411d8fc314 authored by Lars Bilke on 20 April 2023, 12:43:09 UTC
Merge branch 'scikit-build-core' into 'master'
Tip revision: 51d08c6
MeshSurfaceExtraction.h
/**
 * \file
 * \author Karsten Rink
 * \date   2013-04-04
 * \brief  Definition of the MeshSurfaceExtraction class
 *
 * \copyright
 * Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#pragma once

#include <Eigen/Core>
#include <cstddef>
#include <vector>

#include "MeshLib/Mesh.h"
#include "MeshLib/Properties.h"

namespace MeshLib
{
// forward declarations
class Mesh;
class Element;
class Node;

/**
 * \brief A set of tools concerned with extracting nodes and elements from a
 * mesh surface
 */
class MeshSurfaceExtraction
{
public:
    /// Returns a vector of the areas assigned to each node on a surface mesh.
    static std::vector<double> getSurfaceAreaForNodes(
        const MeshLib::Mesh& mesh);

    /// Returns the surface nodes of a mesh.
    static std::vector<MeshLib::Node*> getSurfaceNodes(
        const MeshLib::Mesh& mesh, Eigen::Vector3d const& dir, double angle);

    /**
     * Returns the 2d-element mesh representing the surface of the given mesh.
     * \param subsfc_mesh The original mesh
     * \param dir The direction in which face normals have to
     * point to be considered surface elements
     * \param angle The angle of the allowed deviation from the
     * given direction (0 <= angle <= 90 degrees)
     * \param subsfc_node_id_prop_name The name of the \c PropertyVector in
     * the surface mesh the subsurface mesh node ids are stored to. If the
     * string is empty, there won't be such a \c PropertyVector.
     * \param subsfc_element_id_prop_name The name of the PropertyVector in
     * the surface mesh that stores the subsurface element ids. If the string
     * is empty, there won't be such a \c PropertyVector.
     * \param face_id_prop_name The name of the \c PropertyVector in the surface
     * mesh that stores the face number of the subsurface element that belongs
     * to the boundary. If the string is empty, there won't be such a \c
     * PropertyVector.
     * \return A 2D mesh representing the surface in direction dir
     */
    static MeshLib::Mesh* getMeshSurface(
        const MeshLib::Mesh& subsfc_mesh,
        Eigen::Vector3d const& dir,
        double angle,
        std::string_view subsfc_node_id_prop_name = "",
        std::string_view subsfc_element_id_prop_name = "",
        std::string_view face_id_prop_name = "");

private:
    /// Functionality needed for getSurfaceNodes() and getMeshSurface()
    static void get2DSurfaceElements(
        const std::vector<MeshLib::Element*>& all_elements,
        std::vector<MeshLib::Element*>& sfc_elements,
        std::vector<std::size_t>& element_to_bulk_element_id_map,
        std::vector<std::size_t>& element_to_bulk_face_id_map,
        Eigen::Vector3d const& dir,
        double angle,
        unsigned mesh_dimension);
};

namespace BoundaryExtraction
{
std::unique_ptr<MeshLib::Mesh> getBoundaryElementsAsMesh(
    MeshLib::Mesh const& bulk_mesh,
    std::string_view subsfc_node_id_prop_name,
    std::string_view subsfc_element_id_prop_name,
    std::string_view face_id_prop_name);
}

void addBulkIDPropertiesToMesh(
    MeshLib::Mesh& surface_mesh,
    std::string_view node_to_bulk_node_id_map_name,
    std::vector<std::size_t> const& node_to_bulk_node_id_map,
    std::string_view element_to_bulk_element_id_map_name,
    std::vector<std::size_t> const& element_to_bulk_element_id_map,
    std::string_view element_to_bulk_face_id_map_name,
    std::vector<std::size_t> const& element_to_bulk_face_id_map);

}  // namespace MeshLib
back to top