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

Function GetData

python/webgui.py:107–203  ·  view source on GitHub ↗
(obj, args, kwargs)

Source from the content-addressed store, hash-verified

105
106@register_draw_type(ngs.Mesh, ngs.CoefficientFunction, ngs.GridFunction, ngs.comp.GridFunctionCoefficientFunction)
107def GetData(obj, args, kwargs):
108 regions = {}
109
110 cf = None
111 if isinstance(obj, ngs.GridFunction):
112 cf = obj
113 mesh = obj.space.mesh
114 if len(args) and isinstance(args[0], (ngs.Region, ngs.Mesh)):
115 mesh = args[0]
116 elif isinstance(obj, ngs.CoefficientFunction):
117 cf = obj
118 if len(args)<1:
119 raise RuntimeError("Cannot draw CoefficientFunction without mesh")
120 mesh = args[0]
121 else:
122 # assume, mesh is given
123 mesh = obj
124
125 # got one region as input: draw only on region and region.Boundaries()
126 if isinstance(mesh, ngs.comp.Region):
127 region = mesh
128 mesh = region.mesh
129 regions[region.VB()] = region
130 while region.VB() != ngs.BBND:
131 bnd_reg = region.Boundaries()
132 regions[bnd_reg.VB()] = bnd_reg
133 region = bnd_reg
134
135 # draw exactly on given list of regions (no regions.Boundaries())
136 elif isinstance(mesh, list):
137 regions = {}
138 list_ = mesh
139 mesh = None
140 for reg in list_:
141 if isinstance(reg, ngs.comp.Region):
142 mesh = reg.mesh
143 regions[reg.VB()] = reg
144 if isinstance(reg, ngs.comp.VorB):
145 regions[reg] = reg
146 if mesh is None:
147 raise RuntimeError("missing mesh/region")
148
149 # draw on whole mesh
150 elif isinstance(mesh, ngs.comp.Mesh):
151 for vb in [ngs.VOL, ngs.BND, ngs.BBND]:
152 regions[vb] = vb
153 else:
154 raise RuntimeError("invalid input mesh")
155
156 # fill with empty regions
157 for vb in [ngs.VOL, ngs.BND, ngs.BBND]:
158 if vb not in regions:
159 regions[vb] = mesh.Region(vb, None)
160
161 if 'intpoints' not in kwargs:
162 kwargs['intpoints'] = None
163 d = BuildRenderData(mesh, cf, order=kwargs['order'], draw_surf=kwargs['draw_surf'], draw_vol=kwargs['draw_vol'], intpoints=kwargs['intpoints'], deformation=kwargs['deformation'], regions=regions, objects=kwargs['objects'], nodal_p1=kwargs['nodal_p1'], settings=kwargs['settings'])
164

Callers

nothing calls this directly

Calls 4

BuildRenderDataFunction · 0.85
VBMethod · 0.45
RegionMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected