24 (dim == 3) ?
"PhysicalVolume" :
25 (dim == 2) ?
"PhysicalSurface" :
30 for(std::size_t i = 0; i < name.size(); i++)
31 if(name[i] ==
' ') name[i] =
'_';
35 static int partID(
int dim,
int num) {
return dim * 1000000 + num; }
41 if(elements.size() && (saveAll || ge->
physicals.size())) {
42 const char *typ = elements[0]->getStringForRAD();
45 fprintf(fp,
"%s/%d\n#SET_ELEMENT=%s%d\n", typ, pid,
48 for(std::size_t i = 0; i < elements.size(); i++)
49 elements[i]->writeRAD(fp, elements[i]->getNum());
55 int saveGroupsOfNodes,
double scalingFactor)
57 FILE *fp =
Fopen(name.c_str(),
"w");
59 Msg::Error(
"Unable to open file '%s'", name.c_str());
70 std::vector<GEntity *> entities;
72 std::string beginname = name;
73 std::size_t n = name.find_last_of(
"/");
74 if(n != std::string::npos) { beginname = name.substr(n + 1); }
76 n = beginname.find(
"_0000.rad");
77 if(n != std::string::npos) { beginname = beginname.substr(0, n); }
79 n = beginname.find(
".rad");
80 if(n != std::string::npos) { beginname = beginname.substr(0, n); }
82 fprintf(fp,
"#RADIOSS STARTER\n");
83 fprintf(fp,
"#---1----|----2----|----3----|----4----|----5----|----6----|"
84 "----7----|----8----|----9----|---10----|\n");
85 fprintf(fp,
"# Created by Gmsh, Radioss Mesh Interface by PaulAltair "
86 "sharp@altair.com\n");
87 fprintf(fp,
"#---1----|----2----|----3----|----4----|----5----|----6----|"
88 "----7----|----8----|----9----|---10----|\n");
89 fprintf(fp,
"/BEGIN\n");
90 fprintf(fp,
"%s\n", beginname.c_str());
91 fprintf(fp,
" 2022 0\n");
92 fprintf(fp,
" Mg mm s\n");
93 fprintf(fp,
" Mg mm s\n");
94 fprintf(fp,
"/NODE\n");
95 for(std::size_t i = 0; i < entities.size(); i++)
96 for(std::size_t j = 0; j < entities[i]->mesh_vertices.size(); j++)
97 entities[i]->mesh_vertices[j]->
writeRAD(fp, scalingFactor);
107 if(!(saveAll & 0x20))
112 if(!(saveAll & 0x80))
119 std::map<int, std::vector<GEntity *> > groups[4];
124 if(saveGroupsOfNodes & 0x2) {
125 for(
int dim = 0; dim <= 3; dim++) {
126 if(saveAll & (0x2 << (2 * dim)))
continue;
127 for(
auto it = groups[dim].begin(); it != groups[dim].end(); it++) {
128 std::vector<GEntity *> &entities = it->second;
130 for(std::size_t i = 0; i < entities.size(); i++) {
131 for(std::size_t j = 0; j < entities[i]->getNumMeshElements(); j++) {
132 MElement *e = entities[i]->getMeshElement(j);
134 const char *str = (e->
getDim() == 3) ?
"SOLID" :
135 (e->
getDim() == 2) ?
"SHELL" :
136 (e->
getDim() == 1) ?
"BEAM" :
138 fprintf(fp,
"*SET_%s_LIST\n$# %s\n%d", str,
142 fprintf(fp,
"\n%lu", e->
getNum());
144 fprintf(fp,
", %lu", e->
getNum());
148 if(n) fprintf(fp,
"\n");
154 if(saveGroupsOfNodes & 0x1) {
155 for(
int dim = 1; dim <= 3; dim++) {
156 for(
auto it = groups[dim].begin(); it != groups[dim].end(); it++) {
157 std::set<MVertex *> nodes;
158 std::vector<GEntity *> &entities = it->second;
159 for(std::size_t i = 0; i < entities.size(); i++) {
160 for(std::size_t j = 0; j < entities[i]->getNumMeshElements(); j++) {
161 MElement *e = entities[i]->getMeshElement(j);
166 fprintf(fp,
"*SET_NODE_LIST\n$# %s\n%d",
169 for(
auto it2 = nodes.begin(); it2 != nodes.end(); it2++) {
171 fprintf(fp,
"\n%ld", (*it2)->getIndex());
173 fprintf(fp,
", %ld", (*it2)->getIndex());
176 if(n) fprintf(fp,
"\n");