@@ -361,70 +361,75 @@ void LumpedPortOperator::PrintBoundaryInfo(const IoData &iodata, const mfem::Par
361361 {
362362 return ;
363363 }
364-
365- fmt::memory_buffer buf{}; // Output buffer & buffer append lambda for cleaner code
366- auto to = [](auto &buf, auto fmt, auto &&...args )
367- { fmt::format_to (std::back_inserter (buf), fmt, std::forward<decltype (args)>(args)...); };
364+ fmt::memory_buffer buffer{};
365+ auto out = fmt::appender{buffer};
368366 using VT = Units::ValueType;
369367
370368 // Print out BC info for all port attributes, for both active and inactive ports.
371- to (buf , " \n Configuring Robin impedance BC for lumped ports at attributes:\n " );
369+ fmt::format_to (out , " \n Configuring Robin impedance BC for lumped ports at attributes:\n " );
372370 for (const auto &[idx, data] : ports)
373371 {
374372 for (const auto &elem : data.elems )
375373 {
376374 for (auto attr : elem->GetAttrList ())
377375 {
378- to (buf , " {:d}:" , attr);
376+ fmt::format_to (out , " {:d}:" , attr);
379377 if (std::abs (data.R ) > 0.0 )
380378 {
381379 double Rs = data.R * data.GetToSquare (*elem);
382- to (buf, " Rs = {:.3e} Ω/sq," , iodata.units .Dimensionalize <VT ::IMPEDANCE >(Rs));
380+ fmt::format_to (out, " Rs = {:.3e} Ω/sq," ,
381+ iodata.units .Dimensionalize <VT ::IMPEDANCE >(Rs));
383382 }
384383 if (std::abs (data.L ) > 0.0 )
385384 {
386385 double Ls = data.L * data.GetToSquare (*elem);
387- to (buf, " Ls = {:.3e} H/sq," , iodata.units .Dimensionalize <VT ::INDUCTANCE >(Ls));
386+ fmt::format_to (out, " Ls = {:.3e} H/sq," ,
387+ iodata.units .Dimensionalize <VT ::INDUCTANCE >(Ls));
388388 }
389389 if (std::abs (data.C ) > 0.0 )
390390 {
391391 double Cs = data.C / data.GetToSquare (*elem);
392- to (buf, " Cs = {:.3e} F/sq," , iodata.units .Dimensionalize <VT ::CAPACITANCE >(Cs));
392+ fmt::format_to (out, " Cs = {:.3e} F/sq," ,
393+ iodata.units .Dimensionalize <VT ::CAPACITANCE >(Cs));
393394 }
394- to (buf, " n = ({:+.1f})\n " , fmt::join (mesh::GetSurfaceNormal (mesh, attr), " ," ));
395+ fmt::format_to (out, " n = ({:+.1f})\n " ,
396+ fmt::join (mesh::GetSurfaceNormal (mesh, attr), " ," ));
395397 }
396398 }
397399 }
398400
399401 // Print out port info for all active ports.
400- fmt::memory_buffer buf_a {};
402+ fmt::memory_buffer buffer_active {};
401403 for (const auto &[idx, data] : ports)
402404 {
403405 if (!data.active )
404406 {
405407 continue ;
406408 }
407- to (buf_a, " Index = {:d}: " , idx) ;
409+ std::vector<std::string> active_port_str ;
408410 if (std::abs (data.R ) > 0.0 )
409411 {
410- to (buf_a, " R = {:.3e} Ω," , iodata.units .Dimensionalize <VT ::IMPEDANCE >(data.R ));
412+ active_port_str.emplace_back (
413+ fmt::format (" R = {:.3e} Ω" , iodata.units .Dimensionalize <VT ::IMPEDANCE >(data.R )));
411414 }
412415 if (std::abs (data.L ) > 0.0 )
413416 {
414- to (buf_a, " L = {:.3e} H," , iodata.units .Dimensionalize <VT ::INDUCTANCE >(data.L ));
417+ active_port_str.emplace_back (
418+ fmt::format (" L = {:.3e} H" , iodata.units .Dimensionalize <VT ::INDUCTANCE >(data.L )));
415419 }
416420 if (std::abs (data.C ) > 0.0 )
417421 {
418- to (buf_a, " C = {:.3e} F," , iodata.units .Dimensionalize <VT ::CAPACITANCE >(data.C ));
422+ active_port_str.emplace_back (fmt::format (
423+ " C = {:.3e} F" , iodata.units .Dimensionalize <VT ::CAPACITANCE >(data.C )));
419424 }
420- buf_a. resize (buf_a. size () - 1 ); // Remove last ","
421- to (buf_a , " \n " );
425+ fmt::format_to (fmt::appender{buffer_active}, " Index = {:d}: {} \n " , idx,
426+ fmt::join (active_port_str , " , " ) );
422427 }
423- if (buf_a .size () > 0 )
428+ if (buffer_active .size () > 0 )
424429 {
425- to (buf , " \n Configuring lumped port circuit properties:\n " );
426- buf .append (buf_a );
427- buf_a .clear ();
430+ fmt::format_to (out , " \n Configuring lumped port circuit properties:\n " );
431+ buffer .append (buffer_active );
432+ buffer_active .clear ();
428433 }
429434
430435 // Print some information for excited lumped ports.
@@ -439,17 +444,18 @@ void LumpedPortOperator::PrintBoundaryInfo(const IoData &iodata, const mfem::Par
439444 {
440445 for (auto attr : elem->GetAttrList ())
441446 {
442- to (buf_a , " {:d}: Index = {:d}\n " , attr, idx);
447+ fmt::format_to (fmt::appender{buffer_active} , " {:d}: Index = {:d}\n " , attr, idx);
443448 }
444449 }
445450 }
446- if (buf_a .size () > 0 )
451+ if (buffer_active .size () > 0 )
447452 {
448- to (buf, " \n Configuring lumped port excitation source term at attributes:\n " );
449- buf.append (buf_a);
453+ fmt::format_to (out,
454+ " \n Configuring lumped port excitation source term at attributes:\n " );
455+ buffer.append (buffer_active);
450456 }
451457
452- Mpi::Print (" {}" , fmt::to_string (buf ));
458+ Mpi::Print (" {}" , fmt::to_string (buffer ));
453459}
454460
455461const LumpedPortData &LumpedPortOperator::GetPort (int idx) const
0 commit comments