| 315 | |
| 316 | |
| 317 | void ExportCoefficientFunction(py::module &m) |
| 318 | { |
| 319 | m.def ("IfPos", [] (shared_ptr<CF> c1, py::object then_obj, py::object else_obj) |
| 320 | { |
| 321 | return IfPos(c1, |
| 322 | MakeCoefficient(then_obj), |
| 323 | MakeCoefficient(else_obj)); |
| 324 | }, py::arg("c1"), py::arg("then_obj"), py::arg("else_obj") ,docu_string(R"raw_string( |
| 325 | Returns new CoefficientFunction with values then_obj if c1 is positive and else_obj else. |
| 326 | |
| 327 | Parameters: |
| 328 | |
| 329 | c1 : ngsolve.CoefficientFunction |
| 330 | Indicator function |
| 331 | |
| 332 | then_obj : object |
| 333 | Values of new CF if c1 is positive, object must be implicitly convertible to |
| 334 | ngsolve.CoefficientFunction. See help(:any:`CoefficientFunction` ) for information. |
| 335 | |
| 336 | else_obj : object |
| 337 | Values of new CF if c1 is not positive, object must be implicitly convertible to |
| 338 | ngsolve.CoefficientFunction. See help(:any:`CoefficientFunction` ) for information. |
| 339 | |
| 340 | )raw_string")) |
| 341 | ; |
| 342 | m.def("IfPos", py::vectorize([](double x, double then, double else_) { |
| 343 | return x > 0 ? then : else_; |
| 344 | })); |
| 345 | |
| 346 | m.def("CoordCF", |
| 347 | [] (int direction) |
| 348 | { return MakeCoordinateCoefficientFunction(direction); }, py::arg("direction"), |
| 349 | docu_string(R"raw_string( |
| 350 | CoefficientFunction for x, y, z. |
| 351 | |
| 352 | Parameters: |
| 353 | |
| 354 | direction : int |
| 355 | input direction |
| 356 | |
| 357 | )raw_string")); |
| 358 | |
| 359 | class MeshSizeCF : public CoefficientFunctionNoDerivative |
| 360 | { |
| 361 | public: |
| 362 | MeshSizeCF () : CoefficientFunctionNoDerivative(1, false) { ; } |
| 363 | virtual double Evaluate (const BaseMappedIntegrationPoint & ip) const override |
| 364 | { |
| 365 | if (ip.IP().FacetNr() != -1) // on a boundary facet of the element |
| 366 | { |
| 367 | double det = 1; |
| 368 | switch (ip.DimSpace()) |
| 369 | { |
| 370 | case 1: det = fabs (static_cast<const MappedIntegrationPoint<1,1>&> (ip).GetJacobiDet()); break; |
| 371 | case 2: det = fabs (static_cast<const MappedIntegrationPoint<2,2>&> (ip).GetJacobiDet()); break; |
| 372 | case 3: det = fabs (static_cast<const MappedIntegrationPoint<3,3>&> (ip).GetJacobiDet()); break; |
| 373 | default: |
| 374 | throw Exception("Illegal dimension in MeshSizeCF"); |
no test coverage detected