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
Refactoring problem creation to allow custom actions to create special problems #12060
Conversation
0bbd1ce
to
ab844d0
Compare
I do not understand why this PR runs fine on my local mac but fails on test boxes with this weird null feproblem pointer error... |
Job Documentation on 060981b wanted to post the following: View the site here This comment will be updated on new commits. |
oh, crap, I forgot check in two new files... |
b61de47
to
2b3c28f
Compare
Job Precheck on b61de47 wanted to post the following: Your code requires style changes. A patch was auto generated and copied here
Alternatively, with your repository up to date and in the top level of your repository:
|
You might consider grabbing the tests that I created. You'll have to modify the CreateSpecialProblemAction so that it just creates a problem but the rest of that should be good. |
Yes, working on that. I also need to add all tests to meet the requirements you proposed. |
2b3c28f
to
3f025ce
Compare
This should be it. We possibly still need to polish it a little. The other few requirements without custom action has been tested by other tests so we do not need to test them here. |
framework/src/base/MooseApp.C
Outdated
// Set the object parameters | ||
InputParameters & params = action->getObjectParams(); | ||
params.set<bool>("solve") = false; | ||
_action_factory.create("CreateProblemDefaultAction", "Problem", action_params)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strange, this should fail because CreateProblemDefaultAction is no longer a moose object action. I will spend some time this weekend to polish this PR...
f8a5d36
to
e162b60
Compare
Rattlesnake fails because it adds a new action task after |
I don't immediately see why this is failing. My PR worked fine with Bighorn without changing any input files. The kernel coverage check should be fine being moved up into the Problem class. |
Right, even the default value in |
@@ -218,6 +222,9 @@ addActionTypes(Syntax & syntax) | |||
"(setup_mesh_complete)" | |||
"(determine_system_type)" | |||
"(create_problem)" | |||
"(create_problem_custom)" | |||
"(create_problem_default)" | |||
"(create_problem_complete)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I create a [Problem]
block, it seems like the first action would always create the problem with this design. The custom task would run after that and wouldn't take effect. How does this work?
If the design is to allow parameters from the [Problem]
to be applied to a custom problem, I don't see how this is working. Should custom be first?
if (_problem) | ||
{ | ||
// problem has been created by CreateProblemAction | ||
if (_problem->type() != "MooseTestProblem") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this looks right to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this particular action answers your question before. I think we want the input syntax to win always, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also means that the custom action needs to follow the similar pattern here for creating problems.
Another thing I want to bring up is that maybe we want a normal action like |
I still think that problem parameters should be with the
Now because, the |
I agree with @andrsd. This was one of the requirements for this redesign: #12055 (comment) We already have a |
A simple approach is to modify
Then |
Just added one more commit. I think this works better.
I can add this during addressing your possible other comments. |
7a0586b
to
313d6aa
Compare
@permcody can you review this? I want this to be pushed in and removed from my plate soon. |
This is looking pretty good. I looked at Bighorn and it can be patched easily. I have one question on design. Do we really need all these tasks? In Can the custom problem just fire on |
|
A side note is that |
En, |
003cff6
to
e60d038
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, my only nitpick is that new method. I don't like that it only gives back one Action. I'd suggest returning the whole container, or just use the existing iterators to get back the items one at a time. I'd rather not create a new interface to maintain in the ActionWarehouse if it can be avoided.
* @return The action pointer. Null means that such an action does not exist. | ||
*/ | ||
template <class T> | ||
const T * getActionByTask(const std::string & task) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method isn't very useful. There are often several Actions for a single task with the same type. This only return the first one. Why not return a container of all the converted ones? A better solution might be to just use the existing iterator (which can be captured and turned into a range trivially) and just loop over them yourself on the receiving side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I was not thinking something like AddMaterialAction
, although the use case in this PR always only have one action. Without this helper function, the same functionality has to be repeated several places, like checking the existence of a task, loop through actions on the task. How about I have a check in this function to make sure there is only one action, otherwise throw an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this look like?
/**
* Retrieve an action on a specific task with its type.
* Error will be thrown if more than one action is found.
* @param name The task name.
* @return The action pointer. Null means that such an action does not exist.
*/
template <class T>
const T * getActionByTask(const std::string & task)
{
const auto it = _action_blocks.find(task);
if (it == _action_blocks.end())
return nullptr;
T * p = nullptr;
for (const auto & action : it->second)
{
T * tp = dynamic_cast<T *>(action);
if (tp)
{
if (p)
mooseError("More than one actions have been detected in getActionByTask");
else
p = tp;
}
}
return p;
}
e60d038
to
1bd5636
Compare
@permcody I hope you are satisfied. I have been waiting on this too long... |
@andrsd - This will require another Relap-7 patch. Please review. I already have a Bighorn patch ready. |
The patch is now ready. Also, thanks for patching bighorn. |
Thanks, I will address the comments shortly. Just a question to @permcody on factory creating object. |
1bd5636
to
060981b
Compare
@andrsd Your comments are addressed. I think this is ready. Thanks guys. |
Thanks! |
Both Rattlesnake and Mammoth have been patched. The fix are all on their devel, because from devel to master is controlled by Civet and Civet will not do it due to App test failure. Looks R7 and Bighorn also have been patched. We will need to do submodule update in Sabertooth and Crab. Then we will back to normal. |
Close #12002.
I still need to add tests and docs. But want to test this and let you see what is in my mind. Tag @permcody @andrsd .