Permalink
Browse files

Merge pull request #12643 from permcody/inactive_multiapp

Inactive Initial MultiApp
  • Loading branch information...
moosebuild committed Jan 7, 2019
2 parents 4c85bb2 + 31c9d1c commit 394592d34f769c29b2d5589554bd2b53dc247442
@@ -28,6 +28,7 @@ class MooseObjectWarehouse : public MooseObjectWarehouseBase<T>
{
public:
using MooseObjectWarehouseBase<T>::checkThreadID;
using MooseObjectWarehouseBase<T>::_all_objects;
using MooseObjectWarehouseBase<T>::_active_objects;
using MooseObjectWarehouseBase<T>::hasActiveBlockObjects;
using MooseObjectWarehouseBase<T>::getActiveBlockObjects;
@@ -142,7 +143,8 @@ void
MooseObjectWarehouse<T>::initialSetup(THREAD_ID tid /* = 0*/) const
{
checkThreadID(tid);
for (const auto & object : _active_objects[tid])
// Initial Setup should be called on all objects because they may become active later
for (const auto & object : _all_objects[tid])
object->initialSetup();
}

@@ -87,6 +87,7 @@ class MooseObjectWarehouseBase
/**
* Convenience functions for determining if objects exist.
*/
bool hasObjects(THREAD_ID tid = 0) const;
bool hasActiveObjects(THREAD_ID tid = 0) const;
bool hasActiveBlockObjects(THREAD_ID tid = 0) const;
bool hasActiveBlockObjects(SubdomainID id, THREAD_ID tid = 0) const;
@@ -104,6 +105,7 @@ class MooseObjectWarehouseBase
* Convenience functions for checking/getting specific objects
*/
bool hasActiveObject(const std::string & name, THREAD_ID tid = 0) const;
std::shared_ptr<T> getObject(const std::string & name, THREAD_ID tid = 0) const;
std::shared_ptr<T> getActiveObject(const std::string & name, THREAD_ID tid = 0) const;
///@}

@@ -400,6 +402,14 @@ MooseObjectWarehouseBase<T>::getActiveBlockObjects(SubdomainID id, THREAD_ID tid
return iter->second;
}

template <typename T>
bool
MooseObjectWarehouseBase<T>::hasObjects(THREAD_ID tid /* = 0*/) const
{
checkThreadID(tid);
return !_all_objects[tid].empty();
}

template <typename T>
bool
MooseObjectWarehouseBase<T>::hasActiveObjects(THREAD_ID tid /* = 0*/) const
@@ -459,6 +469,17 @@ MooseObjectWarehouseBase<T>::hasActiveObject(const std::string & name, THREAD_ID
return false;
}

template <typename T>
std::shared_ptr<T>
MooseObjectWarehouseBase<T>::getObject(const std::string & name, THREAD_ID tid /* = 0*/) const
{
checkThreadID(tid);
for (const auto & object : _all_objects[tid])
if (object->name() == name)
return object;
mooseError("Unable to locate object: ", name, ".");
}

template <typename T>
std::shared_ptr<T>
MooseObjectWarehouseBase<T>::getActiveObject(const std::string & name, THREAD_ID tid /* = 0*/) const
@@ -797,7 +797,7 @@ FEProblemBase::initialSetup()
// restored

// Call initialSetup on the MultiApps
if (_multi_apps.hasActiveObjects())
if (_multi_apps.hasObjects())
{
_console << COLOR_CYAN << "Initializing MultiApps" << COLOR_DEFAULT << std::endl;
_multi_apps.initialSetup();
@@ -3476,7 +3476,7 @@ FEProblemBase::hasMultiApp(const std::string & multi_app_name) const
std::shared_ptr<MultiApp>
FEProblemBase::getMultiApp(const std::string & multi_app_name) const
{
return _multi_apps.getActiveObject(multi_app_name);
return _multi_apps.getObject(multi_app_name);
}

void
Binary file not shown.
@@ -0,0 +1,74 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[Variables]
[./u]
[../]
[]

[Kernels]
[./diff]
type = Diffusion
variable = u
[../]
[./td]
type = TimeDerivative
variable = u
[../]
[]

[BCs]
[./left]
type = DirichletBC
variable = u
boundary = left
value = 0
[../]
[./right]
type = DirichletBC
variable = u
boundary = right
value = 1
[../]
[]

[Executioner]
type = Transient
num_steps = 10
dt = 0.2

solve_type = 'PJFNK'

petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]

[Outputs]
exodus = true
[]

[MultiApps]
[./sub]
positions = '0 0 0'
type = TransientMultiApp
input_files = 'sub.i'
app_type = MooseTestApp
enable = false # Start with a multiapp that's disabled up front
sub_cycling = true
[../]
[]

[Controls]
[./multiapp_enable]
type = TimePeriod
disable_objects = 'MultiApps::sub'
start_time = 0
end_time = 1.3
execute_on = 'timestep_begin'
set_outside_of_range = true
[../]
[]
@@ -0,0 +1,52 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[Variables]
[./u]
[../]
[]

[Kernels]
[./diff]
type = Diffusion
variable = u
[../]
[./td]
type = TimeDerivative
variable = u
[../]
[]

[BCs]
[./left]
type = DirichletBC
variable = u
boundary = left
value = 0
[../]
[./right]
type = DirichletBC
variable = u
boundary = right
value = 1
[../]
[]

[Executioner]
type = Transient
num_steps = 10
dt = 1 # This will be constrained by the master solve

solve_type = 'PJFNK'

petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]

[Outputs]
exodus = true
[]
@@ -0,0 +1,11 @@
[Tests]
[./initial_inactive]
type = 'Exodiff'
input = 'master.i'
exodiff = 'master_out_sub0.e'

design = 'TransientMultiApp.md'
issues = '#12642'
requirement = 'The system shall support creating a Multiapp that is not initially enabled'
[../]
[]

0 comments on commit 394592d

Please sign in to comment.