Skip to content

Commit

Permalink
IOSS: Clean up formatting (clang-format)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Aug 28, 2024
1 parent 98ef6fd commit ad7454e
Show file tree
Hide file tree
Showing 17 changed files with 1,024 additions and 1,022 deletions.
88 changes: 45 additions & 43 deletions packages/seacas/libraries/ioss/src/Ioss_DynamicTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <iosfwd> // for ostream
#include <sstream>
#include <string> // for string, operator<
#include <string> // for string, operator<
#include <strings.h>

namespace Ioss {
Expand All @@ -44,31 +44,32 @@ namespace Ioss {
* - TOPOLOGY_UNKNOWN: Something else, catchall option.
*/
enum TopologyModified {
TOPOLOGY_SAME = ( 0), //!< No change, also used for initialization
TOPOLOGY_REORDER = (1U << 0), //!< Data structures reordered on processor, no change between procs.
TOPOLOGY_SHUFFLE = (1U << 1), //!< Globally the same, data moved among processors.
TOPOLOGY_HADAPT = (1U << 2), //!< Elements split/combined; not moved cross-proc
TOPOLOGY_GEOMETRY = (1U << 3), //!< Geometry (mesh coordinates) modified. Restart needs to know this.
TOPOLOGY_CREATEFACE = (1U << 4), //!< Face/Edge are created/deleted.
TOPOLOGY_CREATEELEM = (1U << 5), //!< Elements are created/deleted.
TOPOLOGY_CREATENODE = (1U << 6), //!< Nodes are created/deleted.
TOPOLOGY_CREATEASSEMBLY = (1U << 7), //!< Assemblies are created/deleted.
TOPOLOGY_UNKNOWN = (1U << 8), //!< Unknown change, recreate from scratch.
TOPOLOGY_SAME = (0), //!< No change, also used for initialization
TOPOLOGY_REORDER =
(1U << 0), //!< Data structures reordered on processor, no change between procs.
TOPOLOGY_SHUFFLE = (1U << 1), //!< Globally the same, data moved among processors.
TOPOLOGY_HADAPT = (1U << 2), //!< Elements split/combined; not moved cross-proc
TOPOLOGY_GEOMETRY =
(1U << 3), //!< Geometry (mesh coordinates) modified. Restart needs to know this.
TOPOLOGY_CREATEFACE = (1U << 4), //!< Face/Edge are created/deleted.
TOPOLOGY_CREATEELEM = (1U << 5), //!< Elements are created/deleted.
TOPOLOGY_CREATENODE = (1U << 6), //!< Nodes are created/deleted.
TOPOLOGY_CREATEASSEMBLY = (1U << 7), //!< Assemblies are created/deleted.
TOPOLOGY_UNKNOWN = (1U << 8), //!< Unknown change, recreate from scratch.
};

enum class FileControlOption { CONTROL_NONE, CONTROL_AUTO_MULTI_FILE, CONTROL_AUTO_GROUP_FILE };

class IOSS_EXPORT DynamicTopologyObserver
{
public:
DynamicTopologyObserver(Region *region)
: m_region(region) {}
DynamicTopologyObserver(Region *region) : m_region(region) {}

virtual ~DynamicTopologyObserver() {}

virtual void reset_topology_modification_all();
virtual void reset_topology_modification();
virtual void set_topology_modification(unsigned int type);
virtual void reset_topology_modification_all();
virtual void reset_topology_modification();
virtual void set_topology_modification(unsigned int type);
virtual unsigned int get_topology_modification() const;

virtual unsigned int get_cumulative_topology_modification() const;
Expand All @@ -88,8 +89,8 @@ namespace Ioss {
void register_region(Region *region);
Region *get_region() const { return m_region; }

void register_notifier(DynamicTopologyNotifier *notifier);
DynamicTopologyNotifier* get_notifier() const { return m_notifier; }
void register_notifier(DynamicTopologyNotifier *notifier);
DynamicTopologyNotifier *get_notifier() const { return m_notifier; }

virtual void define_model();
virtual void write_model();
Expand All @@ -107,28 +108,29 @@ namespace Ioss {

DynamicTopologyNotifier *m_notifier{nullptr};

void check_region() const;
void check_region() const;
IOSS_NODISCARD const ParallelUtils &util() const;
void synchronize_topology_modified_flags();
void synchronize_topology_modified_flags();

void set_topology_modification_nl(unsigned int type);

private:
DynamicTopologyObserver();
};


class IOSS_EXPORT DynamicTopologyNotifier
{
public:
DynamicTopologyNotifier(const std::string& model_name)
: m_modelName(model_name) {}
DynamicTopologyNotifier(const std::string &model_name) : m_modelName(model_name) {}

virtual ~DynamicTopologyNotifier() = default;

std::string name() const { return m_modelName; }

std::vector<std::shared_ptr<DynamicTopologyObserver>> get_observers() const { return m_observers; }
std::vector<std::shared_ptr<DynamicTopologyObserver>> get_observers() const
{
return m_observers;
}

void register_observer(std::shared_ptr<DynamicTopologyObserver> observer);

Expand All @@ -138,27 +140,26 @@ namespace Ioss {

void set_topology_modification(unsigned int type);

template<typename ObserverType>
bool has_observer_type() const
template <typename ObserverType> bool has_observer_type() const
{
bool found = false;

for(const std::shared_ptr<DynamicTopologyObserver>& observer : m_observers) {
if (dynamic_cast<const ObserverType*>(observer.get()) != nullptr) {
for (const std::shared_ptr<DynamicTopologyObserver> &observer : m_observers) {
if (dynamic_cast<const ObserverType *>(observer.get()) != nullptr) {
found = true;
break;
}
}
return found;
}

template<typename ObserverType>
template <typename ObserverType>
std::vector<std::shared_ptr<ObserverType>> get_observer_type() const
{
std::vector<std::shared_ptr<ObserverType>> typed_observers;

for(const std::shared_ptr<DynamicTopologyObserver> &observer : m_observers) {
ObserverType* typed_observer = dynamic_cast<ObserverType*>(observer.get());
for (const std::shared_ptr<DynamicTopologyObserver> &observer : m_observers) {
ObserverType *typed_observer = dynamic_cast<ObserverType *>(observer.get());
if (typed_observer != nullptr) {
typed_observers.push_back(std::dynamic_pointer_cast<ObserverType>(observer));
}
Expand All @@ -168,37 +169,38 @@ namespace Ioss {
}

private:
const std::string m_modelName;
const std::string m_modelName;
std::vector<std::shared_ptr<DynamicTopologyObserver>> m_observers;
};


class IOSS_EXPORT DynamicTopologyBroker
{
public:
static DynamicTopologyBroker *broker();

void register_model(const std::string& model_name);
void remove_model(const std::string& model_name);
void register_model(const std::string &model_name);
void remove_model(const std::string &model_name);
void clear_models();

std::shared_ptr<DynamicTopologyNotifier> get_notifier(const std::string& model_name) const;
std::vector<std::shared_ptr<DynamicTopologyObserver>> get_observers(const std::string& model_name) const;
std::shared_ptr<DynamicTopologyNotifier> get_notifier(const std::string &model_name) const;
std::vector<std::shared_ptr<DynamicTopologyObserver>>
get_observers(const std::string &model_name) const;

void register_observer(const std::string& model_name, std::shared_ptr<DynamicTopologyObserver> observer);
void register_observer(const std::string& model_name, std::shared_ptr<DynamicTopologyObserver> observer, Region& region);
void register_observer(const std::string &model_name,
std::shared_ptr<DynamicTopologyObserver> observer);
void register_observer(const std::string &model_name,
std::shared_ptr<DynamicTopologyObserver> observer, Region &region);

void reset_topology_modification(const std::string& model_name);
void set_topology_modification(const std::string& model_name, unsigned int type);
void reset_topology_modification(const std::string &model_name);
void set_topology_modification(const std::string &model_name, unsigned int type);

private:
DynamicTopologyBroker() {};
DynamicTopologyBroker(DynamicTopologyBroker&);
DynamicTopologyBroker(DynamicTopologyBroker &);

std::map<std::string, std::shared_ptr<DynamicTopologyNotifier>> m_notifiers;
};


class IOSS_EXPORT DynamicTopologyFileControl
{
public:
Expand Down
34 changes: 21 additions & 13 deletions packages/seacas/libraries/ioss/src/Ioss_StructuredBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,18 @@ namespace Ioss {
{
auto lhzc = this->m_zoneConnectivity;
auto rhzc = rhs.m_zoneConnectivity;
Ioss::sort(lhzc.begin(), lhzc.end(), [](const ZoneConnectivity &l, const ZoneConnectivity &r) {
return l.m_connectionName < r.m_connectionName;});
Ioss::sort(rhzc.begin(), rhzc.end(), [](const ZoneConnectivity &l, const ZoneConnectivity &r) {
return l.m_connectionName < r.m_connectionName;});
Ioss::sort(lhzc.begin(), lhzc.end(),
[](const ZoneConnectivity &l, const ZoneConnectivity &r) {
return l.m_connectionName < r.m_connectionName;
});
Ioss::sort(rhzc.begin(), rhzc.end(),
[](const ZoneConnectivity &l, const ZoneConnectivity &r) {
return l.m_connectionName < r.m_connectionName;
});
if (!vec_equal(lhzc, rhzc)) {
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Zone Connectivity mismatch (size {} vs {})\n",
this->m_zoneConnectivity.size(), rhs.m_zoneConnectivity.size());
same = false;
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Zone Connectivity mismatch (size {} vs {})\n",
this->m_zoneConnectivity.size(), rhs.m_zoneConnectivity.size());
same = false;
}
}

Expand All @@ -558,13 +562,17 @@ namespace Ioss {
{
auto lhbc = this->m_boundaryConditions;
auto rhbc = rhs.m_boundaryConditions;
Ioss::sort(lhbc.begin(), lhbc.end(), [](const BoundaryCondition &l, const BoundaryCondition &r) {
return l.m_bcName < r.m_bcName;});
Ioss::sort(rhbc.begin(), rhbc.end(), [](const BoundaryCondition &l, const BoundaryCondition &r) {
return l.m_bcName < r.m_bcName;});
Ioss::sort(lhbc.begin(), lhbc.end(),
[](const BoundaryCondition &l, const BoundaryCondition &r) {
return l.m_bcName < r.m_bcName;
});
Ioss::sort(rhbc.begin(), rhbc.end(),
[](const BoundaryCondition &l, const BoundaryCondition &r) {
return l.m_bcName < r.m_bcName;
});
if (!vec_equal(lhbc, rhbc)) {
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Boundary Conditions mismatch\n");
same = false;
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Boundary Conditions mismatch\n");
same = false;
}
}

Expand Down
9 changes: 4 additions & 5 deletions packages/seacas/libraries/ioss/src/adios/AdiosWrapper.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ namespace Ioad {
AdiosWrapper::AdiosWrapper(Ioss_MPI_Comm comm, const std::string &filename, bool is_input,
unsigned long rank, const Ioss::PropertyManager &properties)
#if ADIOS2_USE_MPI
: adios2::ADIOS(comm),
: adios2::ADIOS(comm),
#else
: adios2::ADIOS(),
: adios2::ADIOS(),
#endif
adios2::IO(IOInit(properties, is_input)),
adios2::Engine(EngineInit(filename, is_input)), m_Rank(rank), m_Communicator(comm),
m_OpenStep(false)
adios2::IO(IOInit(properties, is_input)), adios2::Engine(EngineInit(filename, is_input)),
m_Rank(rank), m_Communicator(comm), m_OpenStep(false)
{
}

Expand Down
25 changes: 13 additions & 12 deletions packages/seacas/libraries/ioss/src/adios/Ioad_DatabaseIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ namespace Ioad {
size_t data_size) const override;
int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
size_t data_size) const override;
int64_t get_field_internal(const Ioss::StructuredBlock */* sb */, const Ioss::Field &/*field*/,
void */*data*/, size_t /*data_size*/) const override
int64_t get_field_internal(const Ioss::StructuredBlock * /* sb */,
const Ioss::Field & /*field*/, void * /*data*/,
size_t /*data_size*/) const override
{
return -1;
}
int64_t get_field_internal(const Ioss::Assembly */*sb*/, const Ioss::Field &/*field*/, void */*data*/,
size_t /*data_size*/) const override
int64_t get_field_internal(const Ioss::Assembly * /*sb*/, const Ioss::Field & /*field*/,
void * /*data*/, size_t /*data_size*/) const override
{
return -1;
}
int64_t get_field_internal(const Ioss::Blob */*sb*/, const Ioss::Field &/*field*/, void */*data*/,
size_t /*data_size*/) const override
int64_t get_field_internal(const Ioss::Blob * /*sb*/, const Ioss::Field & /*field*/,
void * /*data*/, size_t /*data_size*/) const override
{
return -1;
}
Expand Down Expand Up @@ -120,18 +121,18 @@ namespace Ioad {
size_t data_size) const override;
int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
size_t data_size) const override;
int64_t put_field_internal(const Ioss::StructuredBlock */*sb*/, const Ioss::Field &/*field*/,
void */*data*/, size_t /*data_size*/) const override
int64_t put_field_internal(const Ioss::StructuredBlock * /*sb*/, const Ioss::Field & /*field*/,
void * /*data*/, size_t /*data_size*/) const override
{
return -1;
}
int64_t put_field_internal(const Ioss::Assembly */*sb*/, const Ioss::Field &/*field*/, void */*data*/,
size_t /*data_size*/) const override
int64_t put_field_internal(const Ioss::Assembly * /*sb*/, const Ioss::Field & /*field*/,
void * /*data*/, size_t /*data_size*/) const override
{
return -1;
}
int64_t put_field_internal(const Ioss::Blob */*sb*/, const Ioss::Field &/*field*/, void */*data*/,
size_t /*data_size*/) const override
int64_t put_field_internal(const Ioss::Blob * /*sb*/, const Ioss::Field & /*field*/,
void * /*data*/, size_t /*data_size*/) const override
{
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
// See packages/seacas/LICENSE for details

#include <Ioss_Utils.h>
#include <catalyst/Iocatalyst_CatalystLogging.h>
#include <fstream>
#include <iostream>
#include <time.h>
#include <catalyst/Iocatalyst_CatalystLogging.h>

namespace Iocatalyst {

Expand Down
Loading

0 comments on commit ad7454e

Please sign in to comment.