34 std::ofstream outfile;
35 outfile.open(filename);
39 outfile <<
"[" << curr_pos[0] <<
"," << curr_pos[1] <<
"," << curr_pos[2]
47 uint64_t num_iterations) {}
51 std::ofstream outfile;
52 outfile.open(filename);
56 outfile <<
"CellPos = zeros(" << num_cells <<
"," << 3 <<
");" << std::endl;
59 rm->ForEachAgent([&](
Agent* agent) {
61 outfile <<
"CellPos(" << i++ + 1 <<
",1:3) = [" << curr_pos[0] <<
","
62 << curr_pos[1] <<
"," << curr_pos[2] <<
"];" << std::endl;
69 uint64_t num_iterations) {}
74 std::ofstream outfile;
75 outfile.open(filename);
77 std::string space1 =
" ";
78 std::string space2 =
" ";
79 std::string space3 =
" ";
80 std::string space4 =
" ";
82 outfile <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
83 outfile <<
"<neuroml xmlns = \"http://morphml.org/neuroml/schema\""
86 <<
"xmlns:xsi = \"http://www.w3.org/2001/XMLSchema-instance\" "
88 outfile << space1 <<
"xmlns:meta = \"http://morphml.org/metadata/schema\" "
91 <<
"xsi:schemaLocation=\"http://morphml.org/neuroml/"
92 "schema NeuroML_Level3_v1.7.1.xsd\" "
94 outfile << space1 <<
"lengthUnits=\"micrometer\" " << std::endl;
96 outfile << space1 <<
"<cells>" << std::endl;
100 outfile << space2 <<
"<cell name=\"exz_lif\"> " << std::endl;
101 outfile << space3 <<
"<meta:properties>" << std::endl;
102 outfile << space4 <<
"<meta:property tag=\"PointNeuronModel\" value=\"yes\"/>"
104 outfile << space4 <<
"<meta:property tag=\"Class\" value=\"CbLifNeuron\"/>"
106 outfile << space4 <<
"<meta:property tag=\"Cm\" value=\"5e-10\"/>"
108 outfile << space4 <<
"<meta:property tag=\"Rm\" value=\"1e8\"/>"
110 outfile << space4 <<
"<meta:property tag=\"Vthresh\" value=\"-50e-3\"/>"
112 outfile << space4 <<
"<meta:property tag=\"Vresting\" value=\"-60e-3\"/>"
114 outfile << space4 <<
"<meta:property tag=\"Vreset\" value=\"-60e-3\"/>"
116 outfile << space4 <<
"<meta:property tag=\"Trefract\" value=\"5e-3\"/>"
118 outfile << space4 <<
"<meta:property tag=\"Vinit\" value=\"-60e-3\"/>"
120 outfile << space3 <<
"</meta:properties>" << std::endl;
121 outfile << space2 <<
"</cell>" << std::endl;
123 outfile << space2 <<
"<cell name=\"inh_lif\"> " << std::endl;
124 outfile << space3 <<
"<meta:properties>" << std::endl;
125 outfile << space4 <<
"<meta:property tag=\"PointNeuronModel\" value=\"yes\"/>"
127 outfile << space4 <<
"<meta:property tag=\"Class\" value=\"CbLifNeuron\"/>"
129 outfile << space4 <<
"<meta:property tag=\"Cm\" value=\"2e-10\"/>"
131 outfile << space4 <<
"<meta:property tag=\"Rm\" value=\"1e8\"/>"
133 outfile << space4 <<
"<meta:property tag=\"Vthresh\" value=\"-50e-3\"/>"
135 outfile << space4 <<
"<meta:property tag=\"Vresting\" value=\"-60e-3\"/>"
137 outfile << space4 <<
"<meta:property tag=\"Vreset\" value=\"-60e-3\"/>"
139 outfile << space4 <<
"<meta:property tag=\"Trefract\" value=\"5e-3\"/>"
141 outfile << space4 <<
"<meta:property tag=\"Vinit\" value=\"-60e-3\"/>"
143 outfile << space3 <<
"</meta:properties>" << std::endl;
144 outfile << space2 <<
"</cell>" << std::endl;
145 outfile << space1 <<
"</cells>" << std::endl;
152 outfile << std::endl;
153 outfile <<
"</neuroml>" << std::endl;
157 Log::Info(
"Exporter",
"Created NeuroML file");
161 uint64_t num_iterations) {}
165 uint64_t iteration) {
169 std::ofstream vtu(filename +
"-" + std::to_string(iteration) +
".vtu");
170 auto float_size =
sizeof(
real_t) * 8;
172 vtu <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" "
173 "byte_order=\"LittleEndian\">"
175 vtu <<
" <UnstructuredGrid>" << std::endl;
176 vtu <<
" <Piece NumberOfPoints=\"" << num_cells <<
"\" NumberOfCells=\""
177 << num_cells <<
"\">" << std::endl;
178 vtu <<
" <Points>" << std::endl;
179 vtu <<
" <DataArray type=\"Float" << float_size
180 <<
"\" NumberOfComponents=\"3\" "
183 rm->ForEachAgent([&](
Agent* agent) {
185 vtu <<
' ' << coord[0] <<
' ' << coord[1] <<
' ' << coord[2] << std::flush;
188 vtu <<
" </DataArray>" << std::endl;
189 vtu <<
" </Points>" << std::endl;
190 vtu <<
" <PointData>" << std::endl;
191 vtu <<
" <DataArray type=\"Float" << float_size
192 <<
"\" Name=\"Cell_ID\" "
193 "NumberOfComponents=\"1\" format=\"ascii\">"
196 for (
size_t i = 0; i < num_cells; i++) {
197 vtu <<
' ' << index++ << std::flush;
200 vtu <<
" </DataArray>" << std::endl;
201 vtu <<
" <DataArray type=\"Float" << float_size
202 <<
"\" Name=\"Adherence\" "
203 "NumberOfComponents=\"1\" format=\"ascii\">"
206 rm->ForEachAgent([&](
Agent* agent) {
207 if (
auto* cell =
dynamic_cast<Cell*
>(agent)) {
208 auto adhr = cell->GetAdherence();
209 vtu <<
' ' << adhr << std::flush;
214 vtu <<
" </DataArray>" << std::endl;
215 vtu <<
" <DataArray type=\"Float" << float_size
216 <<
"\" Name=\"Diameter\" "
217 "NumberOfComponents=\"1\" format=\"ascii\">"
219 rm->ForEachAgent([&](
Agent* agent) {
221 vtu <<
' ' << diam << std::flush;
225 vtu <<
" </DataArray>" << std::endl;
226 vtu <<
" <DataArray type=\"Float" << float_size
227 <<
"\" Name=\"Mass\" "
228 "NumberOfComponents=\"1\" format=\"ascii\">"
231 rm->ForEachAgent([&](
Agent* agent) {
232 if (
auto* cell =
dynamic_cast<Cell*
>(agent)) {
233 auto mass = cell->GetMass();
234 vtu <<
' ' << mass << std::flush;
239 vtu <<
" </DataArray>" << std::endl;
240 vtu <<
" <DataArray type=\"Float" << float_size
241 <<
"\" Name=\"Volume\" "
242 "NumberOfComponents=\"1\" format=\"ascii\">"
245 rm->ForEachAgent([&](
Agent* agent) {
246 if (
auto* cell =
dynamic_cast<Cell*
>(agent)) {
247 auto v = cell->GetVolume();
248 vtu <<
' ' << v << std::flush;
253 vtu <<
" </DataArray>" << std::endl;
254 vtu <<
" <DataArray type=\"Float" << float_size
255 <<
"\" Name=\"TractionForce\" "
256 "NumberOfComponents=\"3\" format=\"ascii\">"
259 rm->ForEachAgent([&](
Agent* agent) {
260 if (
auto* cell =
dynamic_cast<Cell*
>(agent)) {
261 auto& tracf = cell->GetTractorForce();
262 vtu <<
' ' << tracf[0] <<
' ' << tracf[1] <<
' ' << tracf[2]
268 vtu <<
" </DataArray>" << std::endl;
269 vtu <<
" </PointData>" << std::endl;
271 vtu <<
" <Cells>" << std::endl;
272 vtu <<
" <DataArray type=\"Int32\" Name=\"connectivity\" "
276 for (
size_t i = 0; i < num_cells; i++) {
277 vtu <<
' ' << index++ << std::flush;
280 vtu <<
" </DataArray>" << std::endl;
281 vtu <<
" <DataArray type=\"Int32\" Name=\"offsets\" "
284 for (
size_t i = 0; i < num_cells; i++) {
285 vtu <<
' ' << 1 << std::flush;
288 vtu <<
" </DataArray>" << std::endl;
289 vtu <<
" <DataArray type=\"Int32\" Name=\"types\" "
292 for (
size_t i = 0; i < num_cells; i++) {
293 vtu <<
' ' << 1 << std::flush;
296 vtu <<
" </DataArray>" << std::endl;
297 vtu <<
" </Cells>" << std::endl;
298 vtu <<
" </Piece>" << std::endl;
299 vtu <<
" </UnstructuredGrid>" << std::endl;
300 vtu <<
"</VTKFile>" << std::endl;
304 uint64_t num_iterations) {
305 std::ofstream pvd(filename +
".pvd");
308 pvd <<
"<?xml version=\"1.0\"?>" << std::endl;
309 pvd <<
"<VTKFile type=\"Collection\" version=\"0.1\" "
310 "byte_order=\"LittleEndian\">"
312 pvd <<
"<Collection>" << std::endl;
314 for (uint64_t i = 0; i < num_iterations; i++) {
315 pvd <<
"<DataSet timestep=\"" << (i * param->simulation_time_step)
316 <<
"\" group=\"\" part=\"0\" file=\"" << filename <<
'-' << i
321 pvd <<
"</Collection>" << std::endl;
322 pvd <<
"</VTKFile>" << std::endl;
337 throw std::invalid_argument(
"export format not recognized");