-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13358 from andrsd/uos-in-scalar-initial-conds
UserObjects can be retrieved in scalar initial conditions
- Loading branch information
Showing
14 changed files
with
214 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
# InitialCondition | |||
|
|||
Base class for defining field initial conditions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
# ScalarInitialCondition | |||
|
|||
Base class for defining scalar initial conditions. |
8 changes: 8 additions & 0 deletions
8
framework/doc/content/source/userobject/UserObjectInterface.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
# UserObjectInterface | |||
|
|||
`UserObjectInterface` is a class that allows to bring user objects into MOOSE systems. | |||
|
|||
The following APIs are available: | |||
|
|||
* `getUserObject` - Bring an user object using the parameter name | |||
* `getUserObjectByName` - Bring an user object knowing its actual name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
//* This file is part of the MOOSE framework | |||
//* https://www.mooseframework.org | |||
//* | |||
//* All rights reserved, see COPYRIGHT for full restrictions | |||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | |||
//* | |||
//* Licensed under LGPL 2.1, please see LICENSE for details | |||
//* https://www.gnu.org/licenses/lgpl-2.1.html | |||
|
|||
#pragma once | |||
|
|||
#include "MooseObjectWarehouseBase.h" | |||
#include "MooseTypes.h" | |||
|
|||
class ScalarInitialCondition; | |||
|
|||
/** | |||
* Warehouse for storing scalar initial conditions | |||
*/ | |||
class ScalarInitialConditionWarehouse : public MooseObjectWarehouseBase<ScalarInitialCondition> | |||
{ | |||
public: | |||
ScalarInitialConditionWarehouse(); | |||
|
|||
/** | |||
* Initial setup | |||
*/ | |||
void initialSetup(); | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
//* This file is part of the MOOSE framework | |||
//* https://www.mooseframework.org | |||
//* | |||
//* All rights reserved, see COPYRIGHT for full restrictions | |||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | |||
//* | |||
//* Licensed under LGPL 2.1, please see LICENSE for details | |||
//* https://www.gnu.org/licenses/lgpl-2.1.html | |||
|
|||
#include "ScalarInitialConditionWarehouse.h" | |||
#include "ScalarInitialCondition.h" | |||
|
|||
ScalarInitialConditionWarehouse::ScalarInitialConditionWarehouse() | |||
: MooseObjectWarehouseBase<ScalarInitialCondition>(false) | |||
{ | |||
} | |||
|
|||
void | |||
ScalarInitialConditionWarehouse::initialSetup() | |||
{ | |||
MooseObjectWarehouseBase<ScalarInitialCondition>::sort(); | |||
for (const auto & ic : _active_objects[0]) | |||
ic->initialSetup(); | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
//* This file is part of the MOOSE framework | |||
//* https://www.mooseframework.org | |||
//* | |||
//* All rights reserved, see COPYRIGHT for full restrictions | |||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | |||
//* | |||
//* Licensed under LGPL 2.1, please see LICENSE for details | |||
//* https://www.gnu.org/licenses/lgpl-2.1.html | |||
|
|||
#pragma once | |||
|
|||
#include "ScalarInitialCondition.h" | |||
|
|||
class ScalarUOIC; | |||
class MTUserObject; | |||
|
|||
template <> | |||
InputParameters validParams<ScalarUOIC>(); | |||
|
|||
/** | |||
* Scalar initial condition for setting values from a user object | |||
*/ | |||
class ScalarUOIC : public ScalarInitialCondition | |||
{ | |||
public: | |||
ScalarUOIC(const InputParameters & parameters); | |||
|
|||
virtual Real value() override; | |||
|
|||
protected: | |||
const MTUserObject & _uo; | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
//* This file is part of the MOOSE framework | |||
//* https://www.mooseframework.org | |||
//* | |||
//* All rights reserved, see COPYRIGHT for full restrictions | |||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | |||
//* | |||
//* Licensed under LGPL 2.1, please see LICENSE for details | |||
//* https://www.gnu.org/licenses/lgpl-2.1.html | |||
|
|||
#include "ScalarUOIC.h" | |||
#include "MTUserObject.h" | |||
|
|||
registerMooseObject("MooseTestApp", ScalarUOIC); | |||
|
|||
template <> | |||
InputParameters | |||
validParams<ScalarUOIC>() | |||
{ | |||
InputParameters params = validParams<ScalarInitialCondition>(); | |||
params.addRequiredParam<UserObjectName>("user_object", | |||
"The MTUserObject to be coupled into this IC"); | |||
return params; | |||
} | |||
|
|||
ScalarUOIC::ScalarUOIC(const InputParameters & parameters) | |||
: ScalarInitialCondition(parameters), _uo(getUserObject<MTUserObject>("user_object")) | |||
{ | |||
} | |||
|
|||
Real | |||
ScalarUOIC::value() | |||
{ | |||
return _uo.doSomething(); | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
time,a | |||
0,-2 | |||
1,-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,49 @@ | |||
# This test sets an initial condition of a scalar variable from an user object | |||
|
|||
[Mesh] | |||
type = GeneratedMesh | |||
dim = 2 | |||
nx = 8 | |||
ny = 8 | |||
|
|||
# We are testing geometric ghosted functors | |||
# so we have to use distributed mesh | |||
parallel_type = distributed | |||
[] | |||
|
|||
[Variables] | |||
[./u] | |||
[../] | |||
|
|||
[./a] | |||
family = SCALAR | |||
order = FIRST | |||
[../] | |||
[] | |||
|
|||
[ICs] | |||
[./ghost_ic] | |||
type = ScalarUOIC | |||
variable = a | |||
user_object = scalar_uo | |||
[../] | |||
[] | |||
|
|||
[UserObjects] | |||
[./scalar_uo] | |||
type = MTUserObject | |||
[../] | |||
[] | |||
|
|||
[Executioner] | |||
type = Steady | |||
[] | |||
|
|||
[Outputs] | |||
csv = true | |||
show = 'a' | |||
[] | |||
|
|||
[Problem] | |||
kernel_coverage_check = false | |||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters