Skip to content

Commit

Permalink
enh: add support for multidomain mesh verification (#148)
Browse files Browse the repository at this point in the history
Added support for multidomain mesh verification (#107).
  • Loading branch information
xjrc committed Mar 14, 2017
1 parent 1e0aae3 commit 1077b0e
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 93 deletions.
111 changes: 108 additions & 3 deletions src/libs/blueprint/conduit_blueprint_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ using namespace conduit;
// access verify logging helpers
using namespace conduit::blueprint::utils;

namespace conduit { namespace blueprint { namespace mesh {
bool verify_single_domain(const conduit::Node &n, conduit::Node &info);
bool verify_multi_domain(const conduit::Node &n, conduit::Node &info);
} } }

//-----------------------------------------------------------------------------
// -- begin conduit:: --
Expand All @@ -73,7 +77,6 @@ namespace conduit
namespace blueprint
{


//-----------------------------------------------------------------------------
bool
mesh::verify(const std::string &protocol,
Expand Down Expand Up @@ -116,10 +119,11 @@ mesh::verify(const std::string &protocol,
return res;
}


//-----------------------------------------------------------------------------
bool
mesh::verify(const Node &n,
Node &info)
mesh::verify_single_domain(const Node &n,
Node &info)
{
info.reset();
bool res = true;
Expand Down Expand Up @@ -307,6 +311,105 @@ mesh::verify(const Node &n,
}


//-------------------------------------------------------------------------
bool mesh::verify_multi_domain(const Node &n,
Node &info)
{
info.reset();
bool res = true;

const std::string proto_name = "mesh";

if(!n.dtype().is_object() && !n.dtype().is_list())
{
log_error(info,proto_name,"not an object or a list");
res = false;
}
else
{
NodeConstIterator itr = n.children();
while(itr.has_next())
{
const Node &chld = itr.next();
std::string chld_name;
{
std::ostringstream oss;
if(n.dtype().is_object())
{
oss << itr.name();
}
else
{
oss << itr.index();
}
chld_name = oss.str();
}

if(!mesh::verify_single_domain(chld, info[chld_name]))
{
log_error(info,proto_name,
"child " + chld_name + " is not a valid mesh");
res = false;
}
}

log_info(info,proto_name,"is a multi domain mesh");
}

return res;
}


//-----------------------------------------------------------------------------
bool
mesh::verify(const Node &n,
Node &info)
{
info.reset();
bool res = true;

if(mesh::verify_multi_domain(n, info))
{
res = true;
}
else
{
info.reset();
res = mesh::verify_single_domain(n, info);
}

return res;
}


//-------------------------------------------------------------------------
bool mesh::is_multi_domain(const conduit::Node &n)
{
Node info;
return mesh::verify_multi_domain(n, info);
}


//-------------------------------------------------------------------------
bool mesh::to_multi_domain(const conduit::Node &n,
conduit::Node &dest)
{
dest.reset();

if(mesh::is_multi_domain(n))
{
dest.set_external(n);
}
else
{
conduit::Node& dest_dom = dest.append();
dest_dom.set_external(n);
}

return true;
}


//-----------------------------------------------------------------------------
std::string
identify_coord_sys_type(const Node &coords)
Expand Down Expand Up @@ -466,10 +569,12 @@ mesh::generate_index(const Node &mesh,
}
}


//-----------------------------------------------------------------------------
// blueprint::mesh::logical_dims protocol interface
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
bool
mesh::logical_dims::verify(const Node &dims,
Expand Down
14 changes: 14 additions & 0 deletions src/libs/blueprint/conduit_blueprint_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ bool CONDUIT_BLUEPRINT_API verify(const std::string &protocol,
bool CONDUIT_BLUEPRINT_API verify(const conduit::Node &n,
conduit::Node &info);


//-----------------------------------------------------------------------------
/// blueprint mesh property and transform methods
///
/// These methods can be called on any verified blueprint mesh.
//-----------------------------------------------------------------------------

//-------------------------------------------------------------------------
bool CONDUIT_BLUEPRINT_API is_multi_domain(const conduit::Node &n);

//-------------------------------------------------------------------------
bool CONDUIT_BLUEPRINT_API to_multi_domain(const conduit::Node &n,
conduit::Node &dest);

//-------------------------------------------------------------------------
void CONDUIT_BLUEPRINT_API generate_index(const conduit::Node &mesh,
const std::string &ref_path,
Expand Down

0 comments on commit 1077b0e

Please sign in to comment.