MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / ExportCoefficientFunction

Function ExportCoefficientFunction

fem/python_fem.cpp:317–1685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315
316
317void 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(
325Returns new CoefficientFunction with values then_obj if c1 is positive and else_obj else.
326
327Parameters:
328
329c1 : ngsolve.CoefficientFunction
330 Indicator function
331
332then_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
336else_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(
350CoefficientFunction for x, y, z.
351
352Parameters:
353
354direction : 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");

Callers 1

Calls 15

IfPosFunction · 0.85
MakeCoefficientFunction · 0.85
argFunction · 0.85
docu_stringFunction · 0.85
ExportStdMathFunctionsFunction · 0.85
CreateWrapperCFFunction · 0.85
EvalFunction · 0.85
MakeTrafoCFFunction · 0.85
InitSliceFunction · 0.85

Tested by

no test coverage detected