Exporting to VTK output
- JamesElgy
- Topic Author
- New Member
Less
More
1 year 9 months ago #4703
by JamesElgy
Exporting to VTK output was created by JamesElgy
Recently I've been considering some eddy current type problems involving thin skin depths, which I've been modelling as a conducting object of interest embedded in a larger non-conducting region.
To visualise the skin depth, I've been trying to output VTK files at different frequencies and, in order to reduce the size of the files, I've been trying to export files only showing elements in a specific subdomain. E.g. mesh.Material('cube'). My understanding is that I can specify elements when I export the vtk file using 'drawelems', however, when I do so it removes signficantly more elements than I expect.
I've attached the relevent part of my code. Is there something I'm doing wrong here? I would have expected it to show all the elements inside the cube. Any help would be appreciated.
Regards,
James
print(' creating vtk output', end='\r')
ThetaE1 = GridFunction(fes2)
ThetaE2 = GridFunction(fes2)
ThetaE3 = GridFunction(fes2)
ThetaE1.vec.FV().NumPy()[:] = Output[0]
ThetaE2.vec.FV().NumPy()[:] = Output[1]
ThetaE3.vec.FV().NumPy()[:] = Output[2]
E1Mag = CoefficientFunction(
sqrt(InnerProduct(ThetaE1.real, ThetaE1.real) + InnerProduct(ThetaE1.imag, ThetaE1.imag)))
E2Mag = CoefficientFunction(
sqrt(InnerProduct(ThetaE2.real, ThetaE2.real) + InnerProduct(ThetaE2.imag, ThetaE2.imag)))
E3Mag = CoefficientFunction(
sqrt(InnerProduct(ThetaE3.real, ThetaE3.real) + InnerProduct(ThetaE3.imag, ThetaE3.imag)))
Sols =
Sols.append(dom_nrs_metal)
Sols.append((ThetaE1 * 1j * Omega * sigma).real)
Sols.append((ThetaE1 * 1j * Omega * sigma).imag)
Sols.append((ThetaE2 * 1j * Omega * sigma).real)
Sols.append((ThetaE2 * 1j * Omega * sigma).imag)
Sols.append((ThetaE3 * 1j * Omega * sigma).real)
Sols.append((ThetaE3 * 1j * Omega * sigma).imag)
Sols.append(E1Mag * Omega * sigma)
Sols.append(E2Mag * Omega * sigma)
Sols.append(E3Mag * Omega * sigma)
vtk = VTKOutput(ma=mesh, coefs=Sols,
names=["Object", "E1real", "E1imag", "E2real", "E2imag", "E3real", "E3imag", "E1Mag",
"E2Mag", "E3Mag"], filename='test_file', subdivision=0, legacy=True)
ele_to_draw = mesh.Materials('cube').Mask()
vtk.Do( drawelems=ele_to_draw)
To visualise the skin depth, I've been trying to output VTK files at different frequencies and, in order to reduce the size of the files, I've been trying to export files only showing elements in a specific subdomain. E.g. mesh.Material('cube'). My understanding is that I can specify elements when I export the vtk file using 'drawelems', however, when I do so it removes signficantly more elements than I expect.
I've attached the relevent part of my code. Is there something I'm doing wrong here? I would have expected it to show all the elements inside the cube. Any help would be appreciated.
Regards,
James
print(' creating vtk output', end='\r')
ThetaE1 = GridFunction(fes2)
ThetaE2 = GridFunction(fes2)
ThetaE3 = GridFunction(fes2)
ThetaE1.vec.FV().NumPy()[:] = Output[0]
ThetaE2.vec.FV().NumPy()[:] = Output[1]
ThetaE3.vec.FV().NumPy()[:] = Output[2]
E1Mag = CoefficientFunction(
sqrt(InnerProduct(ThetaE1.real, ThetaE1.real) + InnerProduct(ThetaE1.imag, ThetaE1.imag)))
E2Mag = CoefficientFunction(
sqrt(InnerProduct(ThetaE2.real, ThetaE2.real) + InnerProduct(ThetaE2.imag, ThetaE2.imag)))
E3Mag = CoefficientFunction(
sqrt(InnerProduct(ThetaE3.real, ThetaE3.real) + InnerProduct(ThetaE3.imag, ThetaE3.imag)))
Sols =
Sols.append(dom_nrs_metal)
Sols.append((ThetaE1 * 1j * Omega * sigma).real)
Sols.append((ThetaE1 * 1j * Omega * sigma).imag)
Sols.append((ThetaE2 * 1j * Omega * sigma).real)
Sols.append((ThetaE2 * 1j * Omega * sigma).imag)
Sols.append((ThetaE3 * 1j * Omega * sigma).real)
Sols.append((ThetaE3 * 1j * Omega * sigma).imag)
Sols.append(E1Mag * Omega * sigma)
Sols.append(E2Mag * Omega * sigma)
Sols.append(E3Mag * Omega * sigma)
vtk = VTKOutput(ma=mesh, coefs=Sols,
names=["Object", "E1real", "E1imag", "E2real", "E2imag", "E3real", "E3imag", "E1Mag",
"E2Mag", "E3Mag"], filename='test_file', subdivision=0, legacy=True)
ele_to_draw = mesh.Materials('cube').Mask()
vtk.Do( drawelems=ele_to_draw)
Attachments:
1 year 9 months ago #4704
by schruste
Replied by schruste on topic Exporting to VTK output
Hi James,
The drawelems=... expects a BitArray w.r.t. the mesh elements, not the domains. You are rather prescribing the relevant domain indices. Indeed, drawing only certain materials would be a nice feature, but we haven't implemented this as of now, sorry.
Best,
Christoph
The drawelems=... expects a BitArray w.r.t. the mesh elements, not the domains. You are rather prescribing the relevant domain indices. Indeed, drawing only certain materials would be a nice feature, but we haven't implemented this as of now, sorry.
Best,
Christoph
- JamesElgy
- Topic Author
- New Member
Less
More
1 year 9 months ago #4705
by JamesElgy
Replied by JamesElgy on topic Exporting to VTK output
Ok, thanks for the quick reply Christoph.
James
James
Time to create page: 0.119 seconds