7#include <deal.II/base/point.h>
9#include <deal.II/grid/manifold_lib.h>
11#include <deal.II/opencascade/manifold_lib.h>
12#include <deal.II/opencascade/utilities.h>
22 "Type of manifold description.");
26 Utilities::int_to_string(i_bc, 2),
27 Patterns::List(Patterns::Integer()),
28 "IDs of boundaries to which the manifold will be applied");
30 prm.declare_entry(
"cad file",
33 "CAD file name (IGES or STEP)");
38 "Scale factor applied to the CAD file once read. OpenCASCADE reads CAD "
39 "files in millimeters, so the default (1e-3) yields meters");
43 Patterns::List(Patterns::Double()),
44 "Point coordinates describing the spherical or cylindrical manifold");
45 prm.declare_entry(
"direction vector",
47 Patterns::List(Patterns::Double()),
48 "Central axis describing the cylindrical manifold");
55 std::vector<unsigned int> ids_current =
58 for (
const unsigned int id : ids_current)
61 this->
ids.emplace_back(
id);
64 this->
cad_files.emplace_back(prm.get(
"cad file"));
66 prm.get_double(
"cad scale factor"));
72 unsigned int subsection_max_size)
74 prm.enter_subsection(
"manifolds");
76 prm.declare_entry(
"number",
79 "Number of manifolds");
80 for (
unsigned int i = 0; i < subsection_max_size; i++)
82 prm.enter_subsection(
"manifold " + Utilities::int_to_string(i));
84 prm.leave_subsection();
87 prm.leave_subsection();
93 prm.enter_subsection(
"manifolds");
99 prm.enter_subsection(
"manifold " + Utilities::int_to_string(i));
101 prm.leave_subsection();
104 prm.leave_subsection();
108template <
int dim,
int spacedim>
111 parallel::DistributedTriangulationBase<dim, spacedim> &triangulation,
114 for (
unsigned int i = 0; i < manifolds.
types.size(); ++i)
119 Point<spacedim> circle_center(
122 SphericalManifold<dim, spacedim> manifold_description(circle_center);
123 triangulation.set_manifold(manifolds.
ids[i], manifold_description);
125 else if (manifolds.
types[i] ==
128 if constexpr (spacedim == 3)
131 Point<spacedim> point_on_axis(
136 Tensor<1, spacedim> cylinder_axis(
140 CylindricalManifold<dim, spacedim> manifold_description(
141 cylinder_axis, point_on_axis);
142 triangulation.set_manifold(manifolds.
ids[i],
143 manifold_description);
146 throw std::runtime_error(
147 "Cylindrical manifolds are not supported in 2D");
149 else if (manifolds.
types[i] ==
163 throw std::runtime_error(
"Unsupported manifolds type");
174 throw std::runtime_error(
"CAD manifolds are not supported in 2D");
184 throw std::runtime_error(
"CAD manifolds are not supported in 2D/3D");
187#ifdef DEAL_II_WITH_OPENCASCADE
190 const std::string &cad_name,
191 const unsigned int manifold_id,
193 const double cad_scale_factor)
195 TopoDS_Shape cad_surface =
197 OpenCASCADE::read_STEP(cad_name, cad_scale_factor) :
198 OpenCASCADE::read_IGES(cad_name, cad_scale_factor);
201 for (
const auto &cell : triangulation.active_cell_iterators())
203 for (
const auto &face : cell->face_iterators())
205 if (face->boundary_id() == manifold_id)
207 face->set_all_manifold_ids(manifold_id);
213 const double tolerance = OpenCASCADE::get_shape_tolerance(cad_surface) * 5;
217 OpenCASCADE::NormalToMeshProjectionManifold<3, 3> normal_projector(
218 cad_surface, tolerance);
220 triangulation.set_manifold(manifold_id, normal_projector);
230 throw std::runtime_error(
231 "CAD manifolds require DEAL_II to be compiled with OPENCASCADE");
238 parallel::DistributedTriangulationBase<2> &triangulation,
243 parallel::DistributedTriangulationBase<3> &triangulation,
248 parallel::DistributedTriangulationBase<2, 3> &triangulation,
Manifolds - This class manages attaching manifolds to faces when a manual attachment is required (for...
void parse_boundary(const ParameterHandler &prm)
void declare_parameters(ParameterHandler &prm, unsigned int subsection_max_size)
Declare the manifold parameters.
std::vector< unsigned int > ids
std::vector< std::string > cad_files
static void declareDefaultEntry(ParameterHandler &prm, unsigned int i_bc)
Declare the default parameters for one manifold subsection.
std::vector< ManifoldType > types
std::vector< std::string > manifold_direction
unsigned int number_of_manifolds_subsections
std::vector< double > cad_scale_factors
std::vector< std::string > manifold_point
void parse_parameters(ParameterHandler &prm)
Parse the manifold parameters.
Tensor< 1, spacedim > value_string_to_tensor(const std::string &value_string)
Return the tensor corresponding to the value_string. If the dimension correspondence of the value_str...
std::vector< T > convert_string_to_vector(const ParameterHandler &prm, const std::string &entry_string)
Return the vector of size N of entry @entry_string. If the entry is specified in the ....
EnumType string_to_enum(const std::string &name)
Return the enumerator whose identifier is name, e.g. to parse the value of a parameter entry into its...
void declare_enum_entry(ParameterHandler &prm, const std::string &entry_name, const EnumType default_value, const std::string &description, const DeprecatedEnumNames< EnumType > &deprecated_names={}, const std::vector< EnumType > &allowed_values={})
Declare a parameter entry whose value is an enumerator. The default value, the accepted values and th...
void attach_manifolds_to_triangulation(parallel::DistributedTriangulationBase< dim, spacedim > &triangulation, Parameters::Manifolds manifolds)
Attaches manifold to boundaries of the triangulation.
void attach_cad_to_manifold(parallel::DistributedTriangulationBase< 2 > &, const std::string &, const unsigned int, const Parameters::Manifolds::ManifoldType, const double)
Attaches CAD manifolds using IGES or STEP files to boundaries of the triangulation....