Skip to content
Snippets Groups Projects
Commit ab699046 authored by Bastian Telgen's avatar Bastian Telgen
Browse files

Merge ae108-meshing/main into '132-merge-ae108-meshing-into-ae108'

parent 6a0fe0d6
No related branches found
No related tags found
No related merge requests found
Pipeline #167914 failed
Showing
with 800 additions and 0 deletions
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/get_entities_of.h"
#include <gmsh.h>
#include <vector>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
std::vector<std::pair<int, int>> get_entities_of(const int dim) noexcept {
std::vector<std::pair<int, int>> entities;
gmsh::model::getEntities(entities, dim);
return entities;
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/get_nodes_of.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
template <std::size_t Dimension>
std::vector<Node<Dimension>>
get_nodes_of(const std::pair<int, int> &entity,
const bool remove_duplicates) noexcept {
std::vector<std::size_t> nodeTags;
std::vector<double> coord;
std::vector<double> _;
gmsh::model::mesh::getNodes(nodeTags, coord, _, entity.first, entity.second,
true, false);
std::vector<Node<Dimension>> nodes(nodeTags.size());
for (std::size_t i = 0; i < nodeTags.size(); i++) {
nodes[i].id = nodeTags[i];
std::copy_n(coord.begin() + i * 3, Dimension, nodes[i].position.begin());
}
if (remove_duplicates) {
std::sort(nodes.begin(), nodes.end());
nodes.erase(std::unique(nodes.begin(), nodes.end()), nodes.end());
}
return nodes;
}
template std::vector<Node<3>>
get_nodes_of<3>(const std::pair<int, int> &entity,
const bool keep_duplicates) noexcept;
template std::vector<Node<2>>
get_nodes_of<2>(const std::pair<int, int> &entity,
const bool keep_duplicates) noexcept;
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/get_normal_of.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
std::array<double, 3> get_normal_of(const int surface_tag) noexcept {
std::vector<double> normals;
gmsh::model::getNormal(surface_tag, {0, 0}, normals);
std::array<double, 3> normal;
std::copy_n(normals.begin(), 3, normal.begin());
return normal;
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/get_periodic_nodes_of.h"
#include <cassert>
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
std::pair<std::vector<std::size_t>, std::vector<std::size_t>>
get_periodic_nodes_of(const std::pair<int, int> &target_entity,
std::pair<int, int> *source_entity,
std::array<double, 16> *affine_transform) noexcept {
assert(target_entity.first == 1 || target_entity.first == 2);
std::vector<size_t> targetNodeTags, sourceNodeTags;
std::vector<double> _;
int source_tag;
std::vector<double> transform;
std::pair<std::vector<std::size_t>, std::vector<std::size_t>> node_tags;
gmsh::model::mesh::getPeriodicNodes(target_entity.first, target_entity.second,
source_tag, node_tags.first,
node_tags.second, transform, true);
if (source_entity) {
source_entity->first = target_entity.first;
source_entity->second = source_tag;
}
if (affine_transform)
std::move(transform.data(), transform.data() + 16,
affine_transform->begin());
return node_tags;
};
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/get_physical_groups.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
std::vector<std::pair<int, int>> get_physical_groups(const int dim) noexcept {
std::vector<std::pair<int, int>> entities;
gmsh::model::getPhysicalGroups(entities, dim);
return entities;
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/get_points_of.h"
#include <gmsh.h>
#include <set>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
std::vector<int> get_points_of(const std::pair<int, int> &entity) noexcept {
std::set<int> tags = {entity.second};
for (int dim = entity.first; dim > 0; dim--) {
std::set<int> dim_downward;
for (const auto &tag : tags) {
std::vector<int> upward, downward;
gmsh::model::getAdjacencies(dim, tag, upward, downward);
dim_downward.insert(downward.begin(), downward.end());
}
tags = dim_downward;
}
return std::vector(tags.begin(), tags.end());
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/heal_periodic_domains.h"
#include "ae108/meshing/cppgmsh/get_centroid_of.h"
#include "ae108/meshing/cppgmsh/get_entities_in.h"
#include "ae108/meshing/cppgmsh/heal_periodic_surfaces.h"
#include <Eigen/Dense>
#include <array>
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void heal_periodic_domains(const BoundingBox<std::array<double, 3>> &source,
const BoundingBox<std::array<double, 3>> &target,
const double tol) noexcept {
std::array<double, 3> translation;
Eigen::Map<Eigen::Vector3d>(translation.data()) =
Eigen::Map<const Eigen::Vector3d>(target.min.data()) -
Eigen::Map<const Eigen::Vector3d>(source.min.data());
for (const auto &source_surface : get_entities_in(source, 2)) {
const auto source_centroid = get_centroid_of(source_surface);
for (const auto &target_surface : get_entities_in(target, 2)) {
const auto target_centroid = get_centroid_of(target_surface);
if (Eigen::Map<const Eigen::Vector3d>(target_centroid.data())
.isApprox(
Eigen::Map<const Eigen::Vector3d>(source_centroid.data()) +
Eigen::Map<const Eigen::Vector3d>(translation.data()),
tol))
heal_periodic_surfaces(source_surface.second, target_surface.second,
translation);
}
}
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/heal_periodic_surfaces.h"
#include "ae108/meshing/cppgmsh/get_coords_of.h"
#include "ae108/meshing/cppgmsh/get_points_of.h"
#include <Eigen/Dense>
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void heal_periodic_surfaces(const int source_surface, const int target_surface,
const std::array<double, 3> &translation,
const double tol) noexcept {
for (const auto &source : get_points_of({2, source_surface})) {
std::array<double, 3> query;
Eigen::Map<Eigen::Vector3d>(query.data()) =
(Eigen::Map<const Eigen::Vector3d>(get_coords_of(source).data()) +
Eigen::Map<const Eigen::Vector3d>(translation.data()))
.eval();
bool target_found = false;
for (const auto &target : get_points_of({2, target_surface}))
target_found +=
Eigen::Map<const Eigen::Vector3d>(get_coords_of(target).data())
.isApprox(Eigen::Map<const Eigen::Vector3d>(query.data()), tol);
if (!target_found) {
const auto missing_point =
gmsh::model::occ::addPoint(query[0], query[1], query[2]);
std::vector<int> volumes, lines;
gmsh::model::getAdjacencies(2, target_surface, volumes, lines);
gmsh::vectorpair ov;
std::vector<gmsh::vectorpair> ovv;
if (volumes.size())
gmsh::model::occ::fragment(
[](const std::vector<int> &volumes) {
std::vector<std::pair<int, int>> volume_entities;
for (const auto &tag : volumes)
volume_entities.push_back({3, tag});
return volume_entities;
}(volumes),
{{0, missing_point}}, ov, ovv);
else
gmsh::model::occ::fragment({{2, target_surface}}, {{0, missing_point}},
ov, ovv);
}
}
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/import_shapes.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
std::vector<std::pair<int, int>>
import_shapes(const std::string &fileName, const bool highestDimOnly) noexcept {
std::vector<std::pair<int, int>> outDimTags;
gmsh::model::occ::importShapes(fileName, outDimTags, highestDimOnly);
return outDimTags;
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/intersect_entities.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
std::vector<std::pair<int, int>>
intersect_entities(const std::vector<std::pair<int, int>> &object_entities,
const std::vector<std::pair<int, int>> &tool_entities,
const bool remove_object, const bool remove_tool) noexcept {
std::vector<gmsh::vectorpair> temp;
gmsh::vectorpair intersected_entities;
gmsh::model::occ::intersect(object_entities, tool_entities,
intersected_entities, temp, -1, remove_object,
remove_tool);
return intersected_entities;
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/read_file.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void read_file(const std::string &fname) noexcept { gmsh::open(fname); }
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/remove_entities.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void remove_entities(const std::vector<std::pair<int, int>> &entities,
const bool recursive) noexcept {
gmsh::model::occ::remove(entities, recursive);
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/rotate_entities.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void rotate_entities(const std::vector<std::pair<int, int>> &entities,
const std::array<double, 3> &center,
const std::array<double, 3> &direction,
double angle) noexcept {
gmsh::model::occ::rotate(entities, center[0], center[1], center[2],
direction[0], direction[1], direction[2], angle);
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/set_domain_entities_periodic.h"
#include "ae108/meshing/cppgmsh/as_affine_transform.h"
#include "ae108/meshing/cppgmsh/get_centroid_of.h"
#include "ae108/meshing/cppgmsh/get_entities_in.h"
#include "ae108/meshing/cppgmsh/set_periodic.h"
#include <Eigen/Dense>
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void set_domain_entities_periodic(
const BoundingBox<std::array<double, 3>> &source,
const BoundingBox<std::array<double, 3>> &target, const int dim,
const double tol) noexcept {
assert(dim == 1 || dim == 2);
std::array<double, 3> translation;
Eigen::Map<Eigen::Vector3d>(translation.data()) =
Eigen::Map<const Eigen::Vector3d>(target.min.data()) -
Eigen::Map<const Eigen::Vector3d>(source.min.data());
for (const auto &source_surface : get_entities_in(source, dim))
for (const auto &target_surface : get_entities_in(target, dim))
if (Eigen::Map<const Eigen::Vector3d>(
get_centroid_of(target_surface).data())
.isApprox(
Eigen::Map<const Eigen::Vector3d>(
get_centroid_of(source_surface).data()) +
Eigen::Map<const Eigen::Vector3d>(translation.data()),
tol))
set_periodic({{2, target_surface.second}}, {2, source_surface.second},
as_affine_transform(translation));
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/set_expert_mode.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void set_expert_mode(const bool enable) noexcept {
gmsh::option::setNumber("General.ExpertMode", double(enable));
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/set_granularity.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void set_granularity(const double granularity) noexcept {
gmsh::vectorpair point_entitites;
gmsh::model::getEntities(point_entitites, 0);
gmsh::model::mesh::setSize(point_entitites, granularity);
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/set_periodic.h"
#include <cassert>
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void set_periodic(const std::vector<std::pair<int, int>> &target_entities,
const std::pair<int, int> &source_entity,
const std::array<double, 16> &affine_transform) noexcept {
assert(source_entity.first == 1 || source_entity.first == 2);
std::vector<int> target_tags;
for (const auto &target_entity : target_entities) {
assert(source_entity.first == target_entity.first);
target_tags.push_back(target_entity.second);
}
std::vector<double> transform(affine_transform.begin(),
affine_transform.end());
gmsh::model::mesh::setPeriodic(source_entity.first, target_tags,
{source_entity.second}, transform);
};
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/set_physical_group_of.h"
#include <cassert>
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
std::pair<int, int> set_physical_group_of(
const std::vector<std::pair<int, int>> &entities) noexcept {
assert(entities.size());
int dim = entities[0].first;
std::vector<int> tags;
tags.reserve(entities.size());
for (const auto &entity : entities) {
assert(dim == entity.first);
tags.push_back(entity.second);
};
return {dim, gmsh::model::addPhysicalGroup(dim, tags)};
;
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/synchronize.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
void synchronize() noexcept { gmsh::model::occ::synchronize(); }
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
// © 2021 ETH Zurich, Mechanics and Materials Lab
//
// ae108 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any
// later version.
//
// ae108 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ae108. If not, see <https://www.gnu.org/licenses/>.
#include "ae108/meshing/cppgmsh/translate_entities.h"
#include "ae108/meshing/cppgmsh/copy_entities.h"
#include <gmsh.h>
namespace ae108 {
namespace meshing {
namespace cppgmsh {
std::vector<std::pair<int, int>>
translate_entities(std::vector<std::pair<int, int>> entities,
const std::array<double, 3> &translation,
const bool copy) noexcept {
if (copy)
entities = copy_entities(entities);
gmsh::model::occ::translate(entities, translation[0], translation[1],
translation[2]);
return entities;
}
} // namespace cppgmsh
} // namespace meshing
} // namespace ae108
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment