Skip to content

Commit

Permalink
Remove <RESIDUAL> from --json
Browse files Browse the repository at this point in the history
(refs #12960)
  • Loading branch information
aeslaughter authored and milljm committed Sep 10, 2019
1 parent aeeb288 commit 79663f4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
21 changes: 12 additions & 9 deletions framework/src/parser/Parser.C
Expand Up @@ -710,6 +710,7 @@ Parser::buildJsonSyntaxTree(JsonSyntaxTree & root) const
// restricted
// in any way by the user.
const std::vector<std::string> & buildable_types = action_obj_params.getBuildableTypes();
std::string moose_obj_name = moose_obj->first;

// See if the current Moose Object syntax belongs under this Action's block
if ((buildable_types.empty() || // Not restricted
Expand All @@ -719,7 +720,7 @@ Parser::buildJsonSyntaxTree(JsonSyntaxTree & root) const
_syntax.verifyMooseObjectTask(moose_obj_params.get<std::string>("_moose_base"),
task) && // and that base is associated
action_obj_params.mooseObjectSyntaxVisibility() && // and the Action says it's visible
moose_obj->first.find("<JACOBIAN>") ==
moose_obj_name.find("<JACOBIAN>") ==
std::string::npos) // And it is not a Jacobian templated AD object
{
std::string name;
Expand All @@ -731,27 +732,29 @@ Parser::buildJsonSyntaxTree(JsonSyntaxTree & root) const
pos = act_name.size();

if (!action_obj_params.collapseSyntaxNesting())
name = act_name.substr(0, pos - 1) + moose_obj->first;
name = act_name.substr(0, pos - 1) + moose_obj_name;
else
{
name = act_name.substr(0, pos - 1) + "/<type>/" + moose_obj->first;
name = act_name.substr(0, pos - 1) + "/<type>/" + moose_obj_name;
is_action_params = true;
}
}
else
{
name = act_name + "/<type>/" + moose_obj->first;
name = act_name + "/<type>/" + moose_obj_name;
is_type = true;
}
moose_obj_params.set<std::string>("type") = moose_obj_name;

moose_obj_params.set<std::string>("type") = moose_obj->first;

auto lineinfo = _factory.getLineInfo(moose_obj->first);
std::string classname = _factory.associatedClassName(moose_obj->first);
auto lineinfo = _factory.getLineInfo(moose_obj_name);
std::string classname = _factory.associatedClassName(moose_obj_name);
name = name.substr(0, name.find("<RESIDUAL>"));
moose_obj_name = moose_obj_name.substr(0, moose_obj_name.find("<RESIDUAL>"));
classname = classname.substr(0, classname.find("<RESIDUAL>"));
root.addParameters(act_name,
name,
is_type,
moose_obj->first,
moose_obj_name,
is_action_params,
&moose_obj_params,
lineinfo,
Expand Down
11 changes: 9 additions & 2 deletions framework/src/utils/JsonSyntaxTree.C
Expand Up @@ -43,7 +43,13 @@ JsonSyntaxTree::JsonSyntaxTree(const std::string & search_string) : _search(sear
name = obj._alias;
if (name.empty())
name = obj._classname;
_object_label_map[name] = std::make_pair(entry.first, obj._file);

// Skip <JACOBIAN> instances and remove <RESIDUAL> from name
if (name.find("<JACOBIAN>") == std::string::npos)
{
name = name.substr(0, name.find("<RESIDUAL>"));
_object_label_map[name] = std::make_pair(entry.first, obj._file);
}
}
}

Expand Down Expand Up @@ -302,7 +308,8 @@ JsonSyntaxTree::buildOutputString(
for (auto & ch : tmp_str)
if (ch == '\n')
ch = ' ';
return tmp_str;

return tmp_str.substr(0, tmp_str.find("<RESIDUAL>"));
}

void
Expand Down
7 changes: 7 additions & 0 deletions python/MooseDocs/test/tree/test_syntax_tree.py
Expand Up @@ -61,5 +61,12 @@ def testAlias(self):
self.assertEqual(node.fullpath, '/VectorPostprocessors/VolumeHistogram')
self.assertEqual(node.alias, '/VPP/VolumeHistogram')

def testADObject(self):
location = os.path.join(MooseDocs.MOOSE_DIR, 'test')
exe = mooseutils.find_moose_executable(location)
root = app_syntax(exe)
node = anytree.search.find_by_attr(root, '/Kernels/ADDiffusion', name='fullpath')
self.assertEqual(node.fullpath, '/Kernels/ADDiffusion')

if __name__ == '__main__':
unittest.main(verbosity=2)
6 changes: 0 additions & 6 deletions python/MooseDocs/tree/app_syntax.py
Expand Up @@ -87,12 +87,6 @@ def app_syntax(exe, remove=None, allow_test_objects=False, hide=None, alias=None
if node.fullpath == k:
node.alias = str(v)

# Remove <RESIDUAL>
for node in anytree.PreOrderIter(root):
if node.name.endswith('<RESIDUAL>'):
node.alias = node.fullpath
node.name = node.name[:-10]

return root

def __add_moose_object_helper(name, parent, item):
Expand Down

0 comments on commit 79663f4

Please sign in to comment.