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

Add API to get fluid properties #17446

Closed
aprilnovak opened this issue Mar 29, 2021 · 1 comment · Fixed by #17496
Closed

Add API to get fluid properties #17446

aprilnovak opened this issue Mar 29, 2021 · 1 comment · Fixed by #17496
Assignees
Labels
C: Modules P: normal A defect affecting operation with a low possibility of significantly affects. T: task An enhancement to the software.

Comments

@aprilnovak
Copy link
Contributor

Reason

There are a number of different base classes in the fluid properties module that the fluid property user objects derive from - such as SinglePhaseFluidProperties and TwoPhaseFluidProperties. Various MOOSE apps may place specific requirements on which of these fluid property options are valid - for instance, Pronghorn restricts fluid properties to those deriving from SinglePhaseFluidProperties. However, to fully check that a user does not try to use a different fluid property base in Pronghorn, we need to downcast a FluidProperties * userobject in each and every Pronghorn class that uses fluid properties to make sure that the correct type was provided:

const FluidProperties * what_user_provided = getUserObject<GeneralUserObject>("fluid");
const SinglePhaseFluidProperties fluid = dynamic_cast<const SinglePhaseFluidProperties *>(what_user_provided);
if (!fluid)
  mooseError("Pronghorn needs SinglePhaseFluidProperties");

This is tedious and open to errors if you forget to perform this check in new classes. Further, the downcasting makes us use pointers, whereas MOOSE would like all MOOSE-based apps to use references whenever possible.

Design

Add a free function like getFluidProperties<T>("name") that automatically checks whether the correct fluid property type has been provided by the user, and error if not.

Impact

Better error checking and protecting Pronghorn users from accidentally using fluid properties that are incompatible with Pronghorn. Benefits to all other applications using fluid properties as well.

@aprilnovak aprilnovak added P: normal A defect affecting operation with a low possibility of significantly affects. T: task An enhancement to the software. labels Mar 29, 2021
@andrsd
Copy link
Contributor

andrsd commented Mar 29, 2021

Let's go with the other option, i.e. creating a class for this, so the design would be:

class FluidPropertyInterface {
public:
  FluidPropertyInterface(const MooseObject * moose_object);
  const T & getFluidProperties(const std::string & param_name);
};

The c-tor will save the reference to the MOOSE object, which we will then use to get the object name when reporting errors.
getFluidProperties will check the result of the downcast and report an error if the passed object in not of the requested type.

The impact on code interested in using this will be:

  1. add the interface class,
  2. change the getUserObject() call to getFluidProperties class.
  3. add the call to the FluidPropertyInterface::FluidPropertyInterface

aprilnovak added a commit to aprilnovak/moose that referenced this issue Apr 2, 2021
aprilnovak added a commit to aprilnovak/moose that referenced this issue Apr 2, 2021
aprilnovak added a commit to aprilnovak/moose that referenced this issue Apr 2, 2021
loganharbour pushed a commit to aprilnovak/moose that referenced this issue Apr 5, 2021
loganharbour added a commit to aprilnovak/moose that referenced this issue Apr 5, 2021
Co-authored-by: April Novak <novak@berkeley.edu>

refs idaholab#17446
loganharbour added a commit to aprilnovak/moose that referenced this issue Apr 5, 2021
Co-authored-by: April Novak <novak@berkeley.edu>

refs idaholab#17446
loganharbour added a commit to aprilnovak/moose that referenced this issue Apr 5, 2021
loganharbour added a commit to aprilnovak/moose that referenced this issue Apr 5, 2021
loganharbour added a commit to loganharbour/moose that referenced this issue Apr 13, 2021
aeslaughter pushed a commit to aeslaughter/moose that referenced this issue Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Modules P: normal A defect affecting operation with a low possibility of significantly affects. T: task An enhancement to the software.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants