@@ -157,6 +157,7 @@ int main(int argc, char **argv) {
157157 auto world = lib.world ();
158158 Omega_h::Mesh mesh (&lib);
159159 Omega_h::binary::read (argv[1 ], world, &mesh);
160+
160161 const auto prefix = std::string (argv[2 ]);
161162 // adaptRatio = 0.1 is used in scorec/core:cws/sprThwaites test/spr_test.cc
162163 const MeshField::Real adaptRatio = std::stof (argv[3 ]);
@@ -166,13 +167,21 @@ int main(int argc, char **argv) {
166167 argv[5 ]); // a value of 8 or 16 roughly maintains the boundary shape
167168 // in the downstream parts of the domain
168169 // where there is significant coarsening
169- std::cout << " input mesh: " << argv[1 ] << " outputMeshPrefix: " << prefix
170- << " adaptRatio: " << adaptRatio << " max_size: " << max_size
171- << " min_size: " << min_size << " \n " ;
170+ if (!mesh.comm ()->rank ()) {
171+ std::cout << " input mesh: " << argv[1 ] << " outputMeshPrefix: " << prefix
172+ << " adaptRatio: " << adaptRatio << " max_size: " << max_size
173+ << " min_size: " << min_size << " \n " ;
174+ }
172175 const auto outname = prefix + " _adaptRatio_" + std::string (argv[3 ]) +
173176 " _maxSz_" + std::to_string (max_size) + " _minSz_" +
174177 std::to_string (min_size);
175178
179+ // equally distribute elements among processes; required when loading a serial
180+ // mesh
181+ mesh.balance ();
182+ // Omega_h::project_by_fit used by spr requires ghosts
183+ mesh.set_parting (Omega_h_Parting::OMEGA_H_GHOSTED);
184+
176185 auto effectiveStrain = getEffectiveStrainRate (mesh);
177186 auto recoveredStrain = recoverLinearStrain (mesh, effectiveStrain);
178187 mesh.add_tag <Real>(VERT, " recoveredStrain" , 1 , recoveredStrain, false ,
@@ -203,10 +212,10 @@ int main(int argc, char **argv) {
203212 Omega_h::ArrayType::VectorND);
204213
205214 { // write vtk
206- const std::string vtkFileName = " beforeAdapt " + outname + " .vtk" ;
215+ const std::string vtkFileName = " beforeAdapt_ " + outname + " .vtk" ;
207216 Omega_h::vtk::write_parallel (vtkFileName, &mesh, 2 );
208217 const std::string vtkFileName_edges =
209- " beforeAdapt " + outname + " _edges.vtk" ;
218+ " beforeAdapt_ " + outname + " _edges.vtk" ;
210219 Omega_h::vtk::write_parallel (vtkFileName_edges, &mesh, 1 );
211220 }
212221
@@ -223,12 +232,14 @@ int main(int argc, char **argv) {
223232 printTriCount (&mesh, " afterAdapt" );
224233
225234 const auto sol = mesh.get_array <Omega_h::Real>(VERT, " solution_1" );
226- const auto sol_min = Omega_h::get_min (sol);
227- const auto sol_max = Omega_h::get_max (sol);
228- std::cout << " solution_1 min " << sol_min << " max " << sol_max << ' \n ' ;
235+ const auto sol_min = Omega_h::get_min (mesh.comm (), sol);
236+ const auto sol_max = Omega_h::get_max (mesh.comm (), sol);
237+ if (!mesh.comm ()->rank ()) {
238+ std::cout << " solution_1 min " << sol_min << " max " << sol_max << ' \n ' ;
239+ }
229240
230241 { // write vtk and osh for adapted mesh
231- const std::string outfilename = " afterAdapt " + outname;
242+ const std::string outfilename = " afterAdapt_ " + outname;
232243 Omega_h::vtk::write_parallel (outfilename + " .vtk" , &mesh, 2 );
233244 Omega_h::binary::write (outfilename + " .osh" , &mesh);
234245 std::cout << " wrote adapted mesh: " << outfilename + " .osh"
0 commit comments