Skip to content

Commit db47193

Browse files
committed
Clean up capVol
- Replace writeCre with cs.save_file. - Replace ma::adaptVerbose with ma::adapt (the production version). - Remove ma::Input arguments which are just reinforcing the defaults. - If the defaults chagne we shouldn't force using the old ones. - Don't delete old mesh model before adapting. - Change CapstoneModule name. - Reorder mds mesh after conversion. Signed-off-by: Aiden Woodruff <[email protected]>
1 parent 0bc91a3 commit db47193

File tree

1 file changed

+8
-45
lines changed

1 file changed

+8
-45
lines changed

test/capVol.cc

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,6 @@ void myExit(int exit_code = EXIT_SUCCESS) {
3737
exit(exit_code);
3838
}
3939

40-
void writeCre(CapstoneModule& cs, const std::string& filename) {
41-
GeometryDatabaseInterface *gdbi = cs.get_geometry();
42-
MeshDatabaseInterface *mdbi = cs.get_mesh();
43-
AppContext *ctx = cs.get_context();
44-
45-
// Get the CRE writer.
46-
Writer *creWriter = get_writer(ctx, "Create Native Writer");
47-
if (!creWriter) {
48-
lion_eprint(1, "FATAL: Could not find the CRE writer.\n");
49-
myExit(EXIT_FAILURE);
50-
}
51-
52-
IdMapping idmapping;
53-
std::vector<M_MModel> mmodels;
54-
M_GModel gmodel;
55-
M_MModel mmodel;
56-
gdbi->get_current_model(gmodel);
57-
mdbi->get_current_model(mmodel);
58-
mmodels.clear();
59-
mmodels.push_back(mmodel);
60-
creWriter->write(ctx, gmodel, mmodels, filename.c_str(), idmapping);
61-
}
62-
6340
void printUsage(char *argv0) {
6441
printf("USAGE: %s [-agwvm] <size-field> <create_file.cre>\n", argv0);
6542
printf("Flags:\n"
@@ -139,7 +116,7 @@ int main(int argc, char** argv) {
139116
const std::string mdbName("Mesh Database : Create");
140117
const std::string adbName("Attribution Database : Create");
141118

142-
CapstoneModule cs("capTest", gdbName.c_str(), mdbName.c_str(), adbName.c_str());
119+
CapstoneModule cs("capVol", gdbName.c_str(), mdbName.c_str(), adbName.c_str());
143120

144121
GeometryDatabaseInterface *g = cs.get_geometry();
145122
MeshDatabaseInterface *m = cs.get_mesh();
@@ -172,7 +149,7 @@ int main(int argc, char** argv) {
172149
}
173150

174151
if (write_flag) {
175-
writeCre(cs, "core_capVol_before.cre");
152+
cs.save_file("core_capVol_before.cre", gmodel);
176153
}
177154

178155
// Calculate adjacencies.
@@ -189,13 +166,14 @@ int main(int argc, char** argv) {
189166
if (mds_flag) {
190167
adaptMesh = apf::createMdsMesh(apfCapMesh->getModel(), apfCapMesh);
191168
adaptMesh->verify();
169+
apf::reorderMdsMesh(adaptMesh);
170+
adaptMesh->verify();
192171
if (write_flag) {
193172
apf::writeVtkFiles("core_capVol_mds.vtk", adaptMesh);
194173
}
195174
apfCapMesh->setModel(nullptr); // Disown the model.
196175
delete apfCapMesh;
197176
apfCapMesh = nullptr;
198-
MG_API_CALL(m, delete_model(mmodel));
199177
}
200178

201179
// Choose appropriate size-field.
@@ -250,22 +228,7 @@ int main(int argc, char** argv) {
250228
in = ma::makeAdvanced(ma::configure(adaptMesh, sf));
251229
}
252230

253-
in->shouldSnap = true;
254-
in->shouldTransferParametric = true;
255-
in->shouldFixShape = true;
256-
in->shouldForceAdaptation = true;
257-
if (adaptMesh->getDimension() == 2)
258-
in->goodQuality = 0.04; // this is mean-ratio squared
259-
else // 3D meshes
260-
in->goodQuality = 0.027; // this is the mean-ratio cubed
261-
in->maximumIterations = 10;
262-
263-
if (verbose_flag) {
264-
// Adapt with verbose logging but without intermediate VTKs.
265-
ma::adaptVerbose(in, false);
266-
} else {
267-
ma::adapt(in);
268-
}
231+
ma::adapt(in);
269232

270233
if (volume_flag) {
271234
// We can't verify surface meshes.
@@ -275,19 +238,19 @@ int main(int argc, char** argv) {
275238
if (write_flag) {
276239
if (mds_flag) {
277240
apf::writeVtkFiles("core_capVol_after_mds.vtk", adaptMesh);
278-
MG_API_CALL(m, create_associated_model(mmodel, gmodel, "MDS Adapt"));
241+
MG_API_CALL(m, create_associated_model(mmodel, gmodel, "MeshAdapt"));
279242
MG_API_CALL(m, set_adjacency_state(REGION2FACE|REGION2EDGE|REGION2VERTEX|
280243
FACE2EDGE|FACE2VERTEX));
281244
MG_API_CALL(m, set_reverse_states());
282-
// MG_API_CALL(m, compute_adjacency());
245+
// MG_API_CALL(m, compute_adjacency()); // unnecessary because no elements?
283246
ma::Mesh* newCapMesh = apf::createMesh(m, g);
284247
apf::convert(adaptMesh, newCapMesh);
285248
apf::writeVtkFiles("core_capVol_after_cap.vtk", newCapMesh);
286249
apf::destroyMesh(newCapMesh);
287250
} else {
288251
apf::writeVtkFiles("core_capVol_after_cap.vtk", adaptMesh);
289252
}
290-
writeCre(cs, "core_capVol_after.cre");
253+
cs.save_file("core_capVol_after.cre", gmodel);
291254
}
292255

293256
/* PRINT ADAPTED MESH INFO */

0 commit comments

Comments
 (0)