Skip to content

Commit

Permalink
Added generalisation of png metadata handler (#1199)
Browse files Browse the repository at this point in the history
* Added generialisation of png metadata handler

* Added check allowing any domain to set metadata
  • Loading branch information
WillTrojak authored Oct 5, 2023
1 parent 0aa0f18 commit 883aef9
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions src/libs/ascent/runtimes/ascent_main_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ AscentRuntime::Initialize(const conduit::Node &options)
}

if(options.has_path("ghost_field_names"))
{
{
if(!options["ghost_field_names"].dtype().is_list())
{
ASCENT_ERROR("ghost_field_names is not a list");
Expand Down Expand Up @@ -432,7 +432,7 @@ AscentRuntime::AddPublishedMeshInfo()
#ifdef ASCENT_MPI_ENABLED
int comm_id = flow::Workspace::default_mpi_comm();
MPI_Comm mpi_comm = MPI_Comm_f2c(comm_id);

Node n_src, n_reduce;
n_src = src_tbytes;
// all reduce to get total number of bytes across mpi tasks
Expand Down Expand Up @@ -509,33 +509,6 @@ AscentRuntime::Cleanup()
void
AscentRuntime::Publish(const conduit::Node &data)
{
// Process the comments.
m_comments.reset();
if(data.has_path("state/software"))
{
m_comments.append() = "Software";
m_comments.append() = data["state/software"].as_string();
}
if(data.has_path("state/source"))
{
m_comments.append() = "Source";
m_comments.append() = data["state/source"].as_string();
}
if(data.has_path("state/title"))
{
m_comments.append() = "Title";
m_comments.append() = data["state/title"].as_string();
}
if(data.has_path("state/info"))
{
m_comments.append() = "Description";
m_comments.append() = data["state/info"].as_string();
}
if(data.has_path("state/comment"))
{
m_comments.append() = "Comment";
m_comments.append() = data["state/comment"].as_string();
}

blueprint::mesh::to_multi_domain(data, m_source);
EnsureDomainIds();
Expand Down Expand Up @@ -1387,10 +1360,35 @@ AscentRuntime::PopulateMetadata()
const int num_domains = m_source.number_of_children();
int cycle = -1;
float time = -1.f;
bool metadata_set = false;

for(int i = 0; i < num_domains; ++i)
{
const conduit::Node &dom = m_source.child(i);
if (!metadata_set && dom.has_path("state"))
{
m_comments.reset();
conduit::NodeConstIterator itr = dom["state"].children();

while(itr.has_next())
{
const conduit::Node &cld = itr.next();
if(cld.has_path("keyword") && cld.has_path("data"))
{
metadata_set = true;
m_comments.append() = cld["keyword"].as_string();
try
{
m_comments.append() = cld["data"].as_string();
}
catch(const conduit::Error)
{
m_comments.append() = cld["data"].to_string();
}
}
}
}

if(dom.has_path("state/cycle"))
{
cycle = dom["state/cycle"].to_int32();
Expand All @@ -1401,7 +1399,6 @@ AscentRuntime::PopulateMetadata()
}
}


if(cycle != -1)
{
Metadata::n_metadata["cycle"] = cycle;
Expand Down Expand Up @@ -2062,7 +2059,7 @@ AscentRuntime::Execute(const conduit::Node &actions)
{
SaveInfo();
}

}
// --- close try --- //

Expand Down Expand Up @@ -2180,7 +2177,7 @@ void AscentRuntime::SourceFieldFilter()

// if all fields were removed - also remove the fields node
// or else blueprint verify will fail
//
//
// (this can happen when some domains do not have selected fields)
//
if(dom["fields"].number_of_children() == 0)
Expand Down

0 comments on commit 883aef9

Please sign in to comment.