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

Function ExportPml

comp/python_comp_mesh.cpp:1123–1484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1121
1122
1123void ExportPml(py::module &m)
1124{
1125 typedef CoefficientFunction CF;
1126 typedef PML_Transformation PML;
1127 py::class_<PML, shared_ptr<PML>>(m, "PML", R"raw_string(Base PML object
1128
1129can only be created by generator functions. Use PML(x, [y, z]) to evaluate the scaling.)raw_string")
1130 .def("__call__", [](py::args varargs) {
1131 auto self = py::extract<shared_ptr<PML>>(varargs[0])();
1132 int dim = self->GetDimension();
1133 Vector<double> hpoint(dim);
1134 hpoint = 0.;
1135 for (int i : Range(min(int(py::len(varargs)-1),dim)))
1136 hpoint[i] = py::extract<double>(varargs[i+1])();
1137 Vector<Complex> point(dim);
1138 Matrix<Complex> jac(dim,dim);
1139 self->MapPointV(hpoint,point,jac);
1140 return point;
1141 },"map a point")
1142 .def("__str__", [] (shared_ptr<PML> self) { return ToString(*self); } )
1143 .def("call_jacobian", [](py::args varargs) {
1144 auto self = py::extract<shared_ptr<PML>>(varargs[0])();
1145 int dim = self->GetDimension();
1146 Vector<double> hpoint(dim);
1147 hpoint = 0.;
1148 for (int i : Range(min(int(py::len(varargs)-1),dim)))
1149 hpoint[i] = py::extract<double>(varargs[i+1])();
1150 Vector<Complex> point(dim);
1151 Matrix<Complex> jac(dim,dim);
1152 self->MapPointV(hpoint,point,jac);
1153 return jac;
1154 },"evaluate PML jacobian at point x, [y, z]")
1155 .def_property_readonly("dim", [] (shared_ptr<PML> self) {return self->GetDimension(); },
1156 "dimension")
1157 .def_property_readonly("PML_CF", [](shared_ptr<PML> self)->shared_ptr<CF> {
1158 return make_shared<PML_CF> (self);
1159 },
1160 "the scaling as coefficient function")
1161 .def_property_readonly("Jac_CF", [](shared_ptr<PML>self)->shared_ptr<CF> {
1162 return make_shared<PML_Jac> (self);
1163 },
1164 "the jacobian of the PML as coefficient function")
1165 .def_property_readonly("Det_CF", [](shared_ptr<PML> self)->shared_ptr<CF> {
1166 return make_shared<PML_Det> (self);
1167 },
1168 "the determinant of the jacobian as coefficient function")
1169 .def_property_readonly("JacInv_CF", [](shared_ptr<PML> self)->shared_ptr<CF> {
1170 return make_shared<PML_JacInv> (self);
1171 },
1172 "the inverse of the jacobian as coefficient function")
1173 .def("__add__", [](shared_ptr<PML> pml1, shared_ptr<PML> pml2)
1174 -> shared_ptr<PML>
1175 {
1176 int dim = pml1->GetDimension();
1177 if (pml2->GetDimension() != dim)
1178 throw Exception("Dimensions do not match");
1179 switch (dim)
1180 {

Callers 1

ExportNgcompMeshFunction · 0.85

Calls 10

ToStringFunction · 0.85
argFunction · 0.85
MapPointVMethod · 0.80
RangeFunction · 0.50
ComplexFunction · 0.50
GetDimensionMethod · 0.45
checkMethod · 0.45
SetSizeMethod · 0.45
DimensionMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected