8#include <kernel/geometry/hit_test_factory.hpp>
9#include <kernel/analytic/function.hpp>
11#include <kernel/util/tiny_algebra.hpp>
12#include <kernel/analytic/parsed_function.hpp>
18#if defined(FEAT_HAVE_FPARSER) || defined(DOXYGEN)
37 template<
typename Mesh_>
39 public Factory< MeshPart<Mesh_> >
59 mutable::FunctionParser _parser;
64 _parser.AddConstant(
"pi", Math::pi<double>());
84 const int ret = _parser.Parse(formula.c_str(), vars.c_str());
87 String msg(_parser.ErrorMsg());
88 msg.append(
"\n>>> '");
91 if (ret <
int(formula.size()))
96 msg.append(
String(std::size_t(ret + 2),
'-'));
107 bool operator()(
const PointType& point)
const
113 const double val= _parser.Eval(vars.v);
116 switch (_parser.EvalError())
122 throw ParseError(
"Error in ParsedScalarFunction evaluation: division by zero");
125 throw ParseError(
"Error in ParsedScalarFunction evaluation: sqrt of negative value");
128 throw ParseError(
"Error in ParsedScalarFunction evaluation:logarithm of a negative value");
131 throw ParseError(
"Error in ParsedScalarFunction evaluation: illegal input value");
134 throw ParseError(
"Error in ParsedScalarFunction evaluation: maximum recursion depth reached");
137 throw ParseError(
"Error in ParsedScalarFunction evaluation: unknown error");
203 parse_filtered(formula, filter);
206 void parse(
const String& formula)
212 void parse_filtered(
const String& formula,
const MeshType& filter)
226 Intern::write_to_target_set<ShapeType>(target_set_holder,
_target_data);
234 virtual void fill_index_sets(std::unique_ptr<typename MeshType::IndexSetHolderType>&)
override
252 template<
typename Mesh_>
256 return factory.make();
275 template<
typename Mesh_>
279 return factory.make();
294 template<
typename Mesh_>
298 return factory.make_unique();
317 template<
typename Mesh_>
321 return factory.make_unique();
Mesh Factory class template.
Class template for partial meshes.
TargetSetHolder< ShapeType > TargetSetHolderType
Target set holder type.
std::map< String, std::unique_ptr< AttributeSetType > > AttributeSetContainer
submesh node bin container type
void parse(const String &formula)
Creates a ParsedHitFunction.
Parsed-Hit-Test Factory class template.
ParsedHitFunction _hit_func
class for parsed_hit_fuction
ParsedHitTestFactory(const Mesh_ &mesh, const MeshType &filter, const String &formula)
Creates the ParsedHitTestFactory.
Mesh_::VertexType PointType
mesh part type
MeshType::TargetSetHolderType TargetSetHolderType
target set holder type
virtual Index get_num_entities(int dim) override
ParsedHitTestFactory(const Mesh_ &mesh, const String &formula)
Creates the ParsedHitTestFactory.
const Mesh_ & _mesh
reference to the input mesh
MeshPart< Mesh_ > MeshType
mesh part type
Mesh_::ShapeType ShapeType
The shape type of the mesh.
std::vector< std::vector< Index > > _target_data
internal data storing the indices
static constexpr int world_dim
mesh world dimension
Class for parser related errors.
String class implementation.
Tiny Vector class template.
MeshPart< Mesh_ > make_meshpart_by_filtered_formula_hit_test(const Mesh_ &mesh, const MeshPart< Mesh_ > &filter, const String &formula)
Creates a new mesh-part from a formula hit-test function.
std::unique_ptr< MeshPart< Mesh_ > > make_unique_meshpart_by_formula_hit_test(const Mesh_ &mesh, const String &formula)
Creates a new mesh-part from a formula hit-test function.
std::unique_ptr< MeshPart< Mesh_ > > make_unique_meshpart_by_filtered_formula_hit_test(const Mesh_ &mesh, const MeshPart< Mesh_ > &filter, const String &formula)
Creates a new mesh-part from a formula hit-test function.
MeshPart< Mesh_ > make_meshpart_by_formula_hit_test(const Mesh_ &mesh, const String &formula)
Creates a new mesh-part from a formula hit-test function.
std::uint64_t Index
Index data type.