https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: a57c08dd8891d9efae6fbbad9a343f7149da3aa1 authored by Wenqing Wang on 04 June 2021, 13:34:00 UTC
[NumLib] Add a restriction to map the local dNdx to the global
Tip revision: a57c08d
MeshNodesAlongSurface.cpp
/**
 * \author Norihiro Watanabe
 * \date   2014-03-14
 *
 * \file
 * \copyright
 * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 */

#include "MeshNodesAlongSurface.h"

#include <algorithm>

#include "BaseLib/quicksort.h"
#include "GeoLib/Surface.h"
#include "MathLib/MathTools.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/Node.h"

namespace MeshGeoToolsLib
{
MeshNodesAlongSurface::MeshNodesAlongSurface(MeshLib::Mesh const& mesh,
                                             GeoLib::Surface const& sfc,
                                             double epsilon_radius,
                                             SearchAllNodes search_all_nodes)
    : _mesh(mesh), _sfc(sfc)
{
    auto const& mesh_nodes = _mesh.getNodes();
    const std::size_t n_nodes(search_all_nodes == SearchAllNodes::Yes
                                  ? _mesh.getNumberOfNodes()
                                  : _mesh.getNumberOfBaseNodes());
    // loop over all nodes
    for (std::size_t i = 0; i < n_nodes; i++)
    {
        auto* node = mesh_nodes[i];
        if (!sfc.isPntInBoundingVolume(*node, epsilon_radius))
        {
            continue;
        }
        if (sfc.isPntInSfc(*node, epsilon_radius))
        {
            _msh_node_ids.push_back(node->getID());
        }
    }
}

MeshLib::Mesh const& MeshNodesAlongSurface::getMesh() const
{
    return _mesh;
}

std::vector<std::size_t> const& MeshNodesAlongSurface::getNodeIDs() const
{
    return _msh_node_ids;
}

GeoLib::Surface const& MeshNodesAlongSurface::getSurface() const
{
    return _sfc;
}

}  // end namespace MeshGeoToolsLib
back to top