20 template<
typename TMethod,
22 typename TGrid =
typename std::conditional<stressType==Piola,Grid<Reference>,
Grid<Current>>::type>
32 TGrid* pgrid): name(name),pgrid(pgrid),method(method)
34 field.resize(pgrid->ngrid);
35 for(
auto& matrix : field)
36 matrix= Matrix3d::Zero();
39 TGrid* pgrid): pgrid(pgrid),method(method)
41 field.resize(pgrid->ngrid);
42 for(
auto& matrix : field)
43 matrix= Matrix3d::Zero();
49 MY_ERROR(
"Stress object created without specifying a name. Use write(filename) instead of write()");
50 std::ofstream file(name+
".stress");
52 file << field.size() <<
"\n";
55 Eigen::IOFormat fmt(Eigen::FullPrecision, 0,
" ",
"\n",
"",
"",
"");
56 for (
auto& stress : field)
58 Eigen::Map<Eigen::Matrix<double,1,DIM*DIM>> stressRow(stress.data(), stress.size());
59 file << pgrid->coordinates[index].format(fmt) << std::setw(5) << stressRow.format(fmt) << std::endl;
64 void write(
const std::string& filename)
69 std::cout <<
"Stress object created with name " << name <<
". Ignoring the filename: " << filename <<
"." << std::endl;
const Method< TMethod > & method
std::vector< Matrix3d > field
#define MY_ERROR(message)
Stress(std::string name, const Method< TMethod > &method, TGrid *pgrid)
void write(const std::string &filename)
Stress(const Method< TMethod > &method, TGrid *pgrid)