10 Chi::log.
Log() <<
"Printing SLDFE-Quadrature to file.";
12 std::ofstream vert_file,cell_file,points_file,python_file;
16 for (
int v=0; v<4; ++v)
18 auto& v0 = sq.vertices_xyz_prime[v];
19 auto& v1 = sq.vertices_xyz_prime[(v<3)? v+1 : 0];
21 for (
int d=0; d<=10; ++d)
23 auto vert = (1.0-d/10.0)*v0 + (d/10.0)*v1;
24 vert = vert*sq.octant_modifier;
26 vert_file << vert.x <<
" " << vert.y <<
" " << vert.z <<
"\n";
37 for (
const auto& vert : sq.vertices_xyz)
38 for (
int d=0; d<=10; ++d)
39 cell_file << vi++ <<
" ";
45 double total_weight=0.0;
51 for (
const auto& point : sq.sub_sqr_points)
54 for (
int i=0; i<3; ++i)
55 points_file << point[i] <<
" ";
56 points_file << sq.sub_sqr_weights[ss];
57 total_weight += sq.sub_sqr_weights[ss];
66 "import matplotlib.pyplot as plt\n"
67 "from mpl_toolkits import mplot3d\n"
68 "import mpl_toolkits.mplot3d.art3d as art3d\n"
69 "import mpl_toolkits.mplot3d as ax3\n"
70 "import matplotlib.transforms as mpltransform\n"
72 "import numpy as np\n"
75 "#====================================== Read vertices\n"
78 "for line in verts_file:\n"
79 " words = line.split()\n"
80 " verts.append(np.array([float(words[0]),float(words[1]),float(words[2])]))\n"
81 "verts_file.close()\n"
83 "#====================================== Read cells\n"
86 "for line in cells_file:\n"
87 " words = line.split()\n"
89 " for word in words:\n"
90 " cell.append(int(word))\n"
91 " cells.append(cell)\n"
92 "cells_file.close()\n"
94 "#====================================== Read points\n"
98 "for line in points_file:\n"
99 " words = line.split()\n"
101 " for word in words:\n"
102 " point.append(float(word))\n"
103 " points.append(point)\n"
104 " weightsum += point[3]\n"
105 "points_file.close()\n"
107 "print(\"Weightsum check: \",weightsum,weightsum/4/math.pi)\n"
109 "points_array = np.array(points)\n"
111 "#====================================== Generate polygons\n"
113 "for cell in cells:\n"
115 " vertex_list = []\n"
116 " for index in cell:\n"
117 " vertex_list.append(verts[index])\n"
119 " polygon = art3d.Poly3DCollection([vertex_list])\n"
120 " polygon.set_color([1.0,1.0,1.0,1.0])\n"
121 " polygon.set_edgecolor([0.0,0.0,0.0,1.0])\n"
122 " patches.append(polygon)\n"
124 "#====================================== Plot polygons\n"
125 "fig = plt.figure(figsize=(10,8.5))\n"
126 "ax = ax3.Axes3D(fig, proj_type = 'ortho')\n"
128 "ax.view_init(20,25)\n"
130 "end = int(len(patches)/limit)\n"
131 "for poly in patches[0:end]:\n"
132 " ax.add_collection3d(poly)\n"
134 "avg_weight = 0.5*math.pi/len(points)\n"
136 "psize=min(160.0,160*(1.0/avg_weight)*(48/len(points)))\n"
138 "# print(len(points))\n"
139 "end = int(len(points_array)/limit)\n"
140 "# ax.scatter3D(points_array[0:end,0],\n"
141 "# points_array[0:end,1],\n"
142 "# points_array[0:end,2],depthshade=False,\n"
143 "# s=psize*points_array[:,3],c=[[0,0,0,1]])\n"
147 " ax.set_xlim([0.0,1.0])\n"
148 " ax.set_ylim([0.0,1.0])\n"
149 " ax.set_zlim([0.0,1.0])\n"
151 " ax.set_xlim([-1.0,1.0])\n"
152 " ax.set_ylim([-1.0,1.0])\n"
153 " ax.set_zlim([-1.0,1.0])\n"
156 "ax.set_xlabel(r\"$\\mu$\")\n"
157 "ax.set_ylabel(r\"$\\eta$\")\n"
158 "ax.set_zlabel(r\"$\\xi$\")\n"
162 Chi::log.
Log() <<
"Done printing SLDFE-Quadrature to file.";
LogStream Log(LOG_LVL level=LOG_0)
void PrintQuadratureToFile()
std::vector< SphericalQuadrilateral > deployed_SQs_
std::string output_filename_prefix_