18 std::string fileName = base_name;
19 fileName = fileName + std::to_string(
Chi::mpi.location_id);
20 fileName = fileName + std::string(
".py");
24 <<
"import numpy as np\n"
25 "import matplotlib.pyplot as plt\n"
29 std::string submod_name;
32 submod_name = base_name;
33 submod_name = submod_name + std::to_string(
Chi::mpi.location_id+1);
37 ofile <<
"import " << submod_name <<
"\n\n";
54 offset = std::string(
"");
61 submod_name = base_name;
62 submod_name = submod_name + std::to_string(
Chi::mpi.location_id+1);
64 ofile <<
"import " << submod_name <<
"\n\n";
77 <<
"def AddData" << ff <<
"(data" << ff <<
"):\n";
79 offset = std::string(
" ");
83 if ((not ff_ctx.interpolation_points_has_ass_cell[p]) &&
89 ofile << offset <<
"data" << ff <<
"[" << p <<
",0] = "
91 ofile << offset <<
"data" << ff <<
"[" << p <<
",1] = "
93 ofile << offset <<
"data" << ff <<
"[" << p <<
",2] = "
98 ofile << offset <<
"data" << ff <<
"[" << p <<
",3] = "
100 ofile << offset <<
"data" << ff <<
"[" << p <<
",4] = "
101 << ff_ctx.interpolation_points_values[p] <<
"\n";
106 ofile << offset <<
"done=True\n";
111 ofile << offset << submod_name
112 <<
".AddData" << ff <<
"(data" << ff <<
")\n";
125 <<
"def AddData" << ff <<
"(data" << ff <<
"):\n";
127 offset = std::string(
" ");
130 std::string op(
"= ");
131 if (
Chi::mpi.location_id != 0) op = std::string(
"+= ");
135 ofile << offset <<
"data" << ff <<
"[" << p <<
",0] = "
137 ofile << offset <<
"data" << ff <<
"[" << p <<
",1] = "
139 ofile << offset <<
"data" << ff <<
"[" << p <<
",2] = "
148 ofile << offset <<
"data" << ff <<
"[" << p <<
",3] = "
150 ofile << offset <<
"data" << ff <<
"[" << p <<
",4] " << op
153 ofile << offset <<
"done=True\n";
158 ofile << offset << submod_name
159 <<
".AddData" << ff <<
"(data" << ff <<
")\n";
166 ofile <<
"plt.figure(1)\n";
169 ofile <<
"plt.plot(data" << ff <<
"[:,3],data"
177 ofile <<
"plt.plot(data" << ff <<
"[:,3],data"
179 <<
",label=\"CustomArray" << ca <<
"\""
182 ofile <<
"plt.legend()\n"
183 "plt.grid(which='major')\n";
184 ofile <<
"plt.show()\n";
191 <<
"Exported Python files for field func \""
193 <<
"\" to base name \""
194 << base_name <<
"\" Successfully";
static chi::MPI_Info & mpi
LogStream Log(LOG_LVL level=LOG_0)
const int & location_id
Current process rank.
std::vector< chi_physics::FieldFunctionGridBasedPtr > field_functions_
void ExportPython(std::string base_name) override
std::vector< chi_mesh::Vector3 > interpolation_points_
std::vector< std::vector< double > > custom_arrays_
std::vector< FieldFunctionContext > ff_contexts_