MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / save_elem_scalar_field

Method save_elem_scalar_field

src/IO/MshSaver.cpp:229–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229void MshSaver::save_elem_scalar_field(const std::string& fieldname, const VectorF& field) {
230 assert(field.size() == m_num_elements);
231 fout << "$ElementData" << std::endl;
232 fout << 1 << std::endl; // num string tags.
233 fout << "\"" << fieldname << "\"" << std::endl;
234 fout << "1" << std::endl; // num real tags.
235 fout << "0.0" << std::endl; // time value.
236 fout << "3" << std::endl; // num int tags.
237 fout << "0" << std::endl; // the time step
238 fout << "1" << std::endl; // 1-component scalar field.
239 fout << m_num_elements << std::endl; // number of elements
240
241 if (m_binary) {
242 for (size_t i=0; i<m_num_elements; i++) {
243 int elem_idx = i+1;
244 fout.write((char*)&elem_idx, sizeof(int));
245 fout.write((char*)&field[i], sizeof(Float));
246 }
247 } else {
248 for (size_t i=0; i<m_num_elements; i++) {
249 int elem_idx = i+1;
250 fout << elem_idx << " " << field[i] << std::endl;
251 }
252 }
253
254 fout << "$EndElementData" << std::endl;
255 fout.flush();
256}
257
258void MshSaver::save_elem_vector_field(const std::string& fieldname, const VectorF& field) {
259 assert(field.size() == m_num_elements * m_dim);

Callers 1

write_attributeMethod · 0.80

Calls 2

sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected