Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe Improvements #79

Merged
merged 15 commits into from
Dec 22, 2023
58 changes: 48 additions & 10 deletions src/describe.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#include <Omega_h_element.hpp>
#include <Omega_h_file.hpp>
#include <Omega_h_tag.hpp>
#include <Omega_h_array_ops.hpp>

template <typename T>
void printTagInfo(Omega_h::Mesh mesh, std::ostringstream& oss, int dim, int tag, std::string type) {
auto tagbase = mesh.get_tag(dim, tag);
auto array = Omega_h::as<T>(tagbase)->array();

Omega_h::Real min = get_min(array);
Omega_h::Real max = get_max(array);

oss << "(" << tagbase->name().c_str() << ", " << dim << ", " << type << ")\n";
oss << "\tNum Components: " << tagbase->ncomps() << "\n";
oss << "\tMin, Max: " << min << ", " << max << "\n\n";
Angelyr marked this conversation as resolved.
Show resolved Hide resolved
}

template <typename T>
int getNumEq(Omega_h::Mesh mesh, std::string tagname, int dim, int value) {
auto array = mesh.get_array<T>(dim, tagname);
auto each_eq_to = Omega_h::each_eq_to<T>(array, value);
return Omega_h::get_sum(each_eq_to);
}

int main(int argc, char** argv)
{
Expand All @@ -9,7 +30,7 @@ int main(int argc, char** argv)
Omega_h::Mesh mesh = Omega_h::read_mesh_file(argv[1], lib.world());

auto verbose = false;
if (argc == 3) verbose = (std::string(argv[2]) == "on");
if (argc >= 3) verbose = (std::string(argv[2]) == "on");
Angelyr marked this conversation as resolved.
Show resolved Hide resolved

const int rank = comm->rank();

Expand All @@ -34,22 +55,18 @@ int main(int argc, char** argv)
for(int dim=0; dim < mesh.dim(); dim++)
oss << "(" << dim << ", " << counts[dim] << ", " << imb[dim] << ")\n";

oss << "\nTags by Dimension: (Dim, Tag, Size per Entity)\n";
oss << "\nTag Properties by Dimension: (Name, Dim, Type)\n";
Angelyr marked this conversation as resolved.
Show resolved Hide resolved
for (int dim=0; dim < mesh.dim(); dim++)
for (int tag=0; tag < mesh.ntags(dim); tag++) {
auto tagbase = mesh.get_tag(dim, tag);
int size;
if (tagbase->type() == OMEGA_H_I8)
size = mesh.get_tag<Omega_h::I8>(dim, tagbase->name())->array().size();
printTagInfo<Omega_h::I8>(mesh, oss, dim, tag, "I8");
if (tagbase->type() == OMEGA_H_I32)
size = mesh.get_tag<Omega_h::I32>(dim, tagbase->name())->array().size();
printTagInfo<Omega_h::I32>(mesh, oss, dim, tag, "I32");
if (tagbase->type() == OMEGA_H_I64)
size = mesh.get_tag<Omega_h::I64>(dim, tagbase->name())->array().size();
printTagInfo<Omega_h::I64>(mesh, oss, dim, tag, "I64");
if (tagbase->type() == OMEGA_H_F64)
size = mesh.get_tag<Omega_h::Real>(dim, tagbase->name())->array().size();

size /= mesh.nents(dim);
oss << "(" << dim << ", " << tagbase->name().c_str() << ", " << size << ")\n";
printTagInfo<Omega_h::Real>(mesh, oss, dim, tag, "F64");
}

std::cout << oss.str();
Expand All @@ -72,5 +89,26 @@ int main(int argc, char** argv)
<< counts[3] << ")\n";
std::cout << oss.str();
}

if (argc > 3) {
std::string name = std::string(argv[3]);
int dim = atoi(argv[4]);
int value = atoi(argv[5]);
auto tagbase = mesh.get_tagbase(dim, name);
int numEq = 0;
if (tagbase->type() == OMEGA_H_I8)
numEq = getNumEq<Omega_h::I8>(mesh, name, dim, value);
Angelyr marked this conversation as resolved.
Show resolved Hide resolved
if (tagbase->type() == OMEGA_H_I32)
numEq = getNumEq<Omega_h::I32>(mesh, name, dim, value);
if (tagbase->type() == OMEGA_H_I64)
numEq = getNumEq<Omega_h::I64>(mesh, name, dim, value);
if (tagbase->type() == OMEGA_H_F64)
numEq = getNumEq<Omega_h::Real>(mesh, name, dim, value);

if (!rank) std::cout << "\nInput: (" << name << " " << dim << " " << value <<"), Output: (Rank, Num Entities Equal to Value)\n";
comm->barrier();
std::cout << "(" << rank << ", " << numEq << ")\n";
return 0;
}
return 0;
}
Loading