21 if(elements.size() && (saveAll || ge->
physicals.size())) {
22 const char *typ = elements[0]->getStringForINP();
24 const char *str = (ge->
dim() == 3) ?
"Volume" :
25 (ge->
dim() == 2) ?
"Surface" :
26 (ge->
dim() == 1) ?
"Line" :
28 fprintf(fp,
"*ELEMENT, type=%s, ELSET=%s%d\n", typ, str, ge->
tag());
29 for(std::size_t i = 0; i < elements.size(); i++)
30 elements[i]->writeINP(fp, elements[i]->getNum());
41 (dim == 3) ?
"PhysicalVolume" :
42 (dim == 2) ?
"PhysicalSurface" :
43 (dim == 1) ?
"PhysicalLine" :
48 for(std::size_t i = 0; i < name.size(); i++)
49 if(name[i] ==
' ') name[i] =
'_';
54 int saveGroupsOfElements,
int saveGroupsOfNodes,
57 FILE *fp =
Fopen(name.c_str(),
"w");
59 Msg::Error(
"Unable to open file '%s'", name.c_str());
66 std::vector<GEntity *> entities;
69 fprintf(fp,
"*Heading\n");
70 fprintf(fp,
" %s\n", name.c_str());
72 fprintf(fp,
"*NODE\n");
73 for(std::size_t i = 0; i < entities.size(); i++)
74 for(std::size_t j = 0; j < entities[i]->mesh_vertices.size(); j++)
75 entities[i]->mesh_vertices[j]->
writeINP(fp, scalingFactor);
77 fprintf(fp,
"******* E L E M E N T S *************\n");
84 if(saveGroupsOfElements >= 0 || ((-saveGroupsOfElements / 1) % 10)){
89 if(saveGroupsOfElements >= 0 || ((-saveGroupsOfElements / 10) % 10)){
94 if(saveGroupsOfElements >= 0 || ((-saveGroupsOfElements / 100) % 10)){
100 if(saveGroupsOfElements >= 0 || ((-saveGroupsOfElements / 1000) % 10)){
109 std::map<int, std::vector<GEntity *> > groups[4];
112 if(saveGroupsOfElements) {
119 for(
int dim = 1; dim <= 3; dim++) {
120 if(saveGroupsOfElements > 0 ||
121 (saveGroupsOfElements < 0 &&
122 ((-saveGroupsOfElements / (
int)std::pow(10, dim)) % 10) == 1)) {
123 for(
auto it = groups[dim].begin(); it != groups[dim].end(); it++) {
124 std::vector<GEntity *> &ent = it->second;
125 fprintf(fp,
"*ELSET,ELSET=%s\n",
128 for(std::size_t i = 0; i < ent.size(); i++) {
129 for(std::size_t j = 0; j < ent[i]->getNumMeshElements(); j++) {
130 MElement *e = ent[i]->getMeshElement(j);
131 if(n && !(n % 10)) fprintf(fp,
"\n");
132 fprintf(fp,
"%lu, ", e->
getNum());
142 if(saveGroupsOfNodes) {
143 for(
int dim = 0; dim <= 3; dim++) {
148 if(saveGroupsOfNodes > 0 ||
149 (saveGroupsOfNodes < 0 &&
150 ((-saveGroupsOfNodes / (
int)std::pow(10, dim)) % 10) == 1)) {
151 for(
auto it = groups[dim].begin(); it != groups[dim].end(); it++) {
152 std::set<MVertex *, MVertexPtrLessThan> nodes;
153 std::vector<GEntity *> &ent = it->second;
154 for(std::size_t i = 0; i < ent.size(); i++) {
155 for(std::size_t j = 0; j < ent[i]->getNumMeshElements(); j++) {
156 MElement *e = ent[i]->getMeshElement(j);
161 fprintf(fp,
"*NSET,NSET=%s\n",
164 for(
auto it2 = nodes.begin(); it2 != nodes.end(); it2++) {
165 if(n && !(n % 10)) fprintf(fp,
"\n");
166 fprintf(fp,
"%ld, ", (*it2)->getIndex());
178 if(saveGroupsOfNodes < 0 &&
179 ((-saveGroupsOfNodes / (
int)std::pow(10, dim)) % 10) == 2) {
180 std::vector<GEntity *> ent;
182 for(std::size_t i = 0; i < ent.size(); i++) {
183 std::set<MVertex *, MVertexPtrLessThan> nodes;
184 for(std::size_t j = 0; j < ent[i]->getNumMeshElements(); j++) {
185 MElement *e = ent[i]->getMeshElement(j);
190 fprintf(fp,
"*NSET,NSET=%s%d\n",
191 (dim == 3) ?
"Volume" : (dim == 2) ?
"Surface" :
192 (dim == 1) ?
"Line" :
"Point", ent[i]->tag());
194 for(
auto it2 = nodes.begin(); it2 != nodes.end(); it2++) {
195 if(n && !(n % 10)) fprintf(fp,
"\n");
196 fprintf(fp,
"%ld, ", (*it2)->getIndex());