MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / NGS_DLL_HEADER ExportNgsolve

Function NGS_DLL_HEADER ExportNgsolve

solve/python_solve.cpp:15–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13void ExportVisFunctions(py::module &m);
14
15void NGS_DLL_HEADER ExportNgsolve(py::module &m ) {
16 m.def ("__Cleanup", []()
17 {
18 GetPreconditionerClasses().Cleanup();
19 }
20 );
21
22 m.def ("Tcl_Eval", &Ng_TclCmd);
23
24 m.def ("Draw", [](shared_ptr<CoefficientFunction> cf, variant<shared_ptr<MeshAccess>, Region*> ma_or_region, string name,
25 int sd, bool autoscale, double min, double max,
26 bool draw_vol, bool draw_surf, bool reset, string title, string number_format, string unit, py::kwargs kwargs)
27 {
28 if (cf == nullptr)
29 throw Exception("In Draw: invalid object to draw");
30
31 if (reset)
32 {
33 Ng_TclCmd ("set ::visoptions.deformation 0;\n");
34 Ng_TclCmd ("Ng_Vis_Set parameters;\n");
35 Ng_ClearSolutionData();
36 }
37 shared_ptr<MeshAccess> ma;
38 if(ma_or_region.index() == 0)
39 ma = get<shared_ptr<MeshAccess>>(ma_or_region);
40 else
41 ma = get<Region*>(ma_or_region)->Mesh();
42 ma->SelectMesh();
43 netgen::SolutionData * vis;
44 if(dynamic_cast<ProlongateCoefficientFunction *>(cf.get()))
45 {
46 shared_ptr<CoefficientFunction> wrapper(new ProlongateCoefficientFunctionVisualization(*static_cast<ProlongateCoefficientFunction *>(cf.get())));
47 vis = new VisualizeCoefficientFunction (ma, wrapper);
48 }
49 else
50 vis = new VisualizeCoefficientFunction (ma, cf);
51 Ng_SolutionData soldata;
52 Ng_InitSolutionData (&soldata);
53
54 soldata.name = name;
55 soldata.title = title;
56 soldata.number_format = number_format;
57 soldata.unit = unit;
58 soldata.data = 0;
59 soldata.components = cf -> Dimension();
60 if (cf->IsComplex()) soldata.components *= 2;
61 soldata.iscomplex = cf -> IsComplex();
62 soldata.draw_surface = draw_surf;
63 soldata.draw_volume = draw_vol;
64 if(kwargs.contains("surfaces"))
65 soldata.draw_surfaces = py::cast<shared_ptr<BitArray>>(kwargs["surfaces"]);
66 if(kwargs.contains("volumes"))
67 soldata.draw_volumes = py::cast<shared_ptr<BitArray>>(kwargs["volumes"]);
68 if(ma_or_region.index() == 1)
69 {
70 auto reg = get<Region*>(ma_or_region);
71 if(reg->VB() == VOL)
72 soldata.draw_volumes = make_shared<BitArray>(reg->Mask());

Callers

nothing calls this directly

Calls 12

ToStringFunction · 0.85
argFunction · 0.85
docu_stringFunction · 0.85
ExportVisFunctionsFunction · 0.85
GetMeshAccessMethod · 0.80
GetFESpaceMethod · 0.80
getMethod · 0.45
DimensionMethod · 0.45
IsComplexMethod · 0.45
VBMethod · 0.45
GetDimensionMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected