From 0650d54f4070cb93a506e3263b33391acb4ea203 Mon Sep 17 00:00:00 2001 From: Hailong Chen Date: Wed, 10 Oct 2018 16:14:33 -0400 Subject: [PATCH] Updated PeridynamicsTestApp and ModulesApp, fixed issue of peridynamics userobject for multi-threading (#11561) --- modules/module_loader/src/ModulesApp.C | 4 ++ .../NodalAuxVariableUserObjectBasePD.h | 2 +- .../NodalAuxVariableUserObjectBasePD.C | 13 ---- .../test/include/base/PeridynamicsTestApp.h | 1 + .../test/src/base/PeridynamicsTestApp.C | 63 ++++++------------- 5 files changed, 26 insertions(+), 57 deletions(-) diff --git a/modules/module_loader/src/ModulesApp.C b/modules/module_loader/src/ModulesApp.C index 918c70399f1b..2e77883cd55b 100644 --- a/modules/module_loader/src/ModulesApp.C +++ b/modules/module_loader/src/ModulesApp.C @@ -352,6 +352,10 @@ ModulesApp::registerAll(Factory & f, ActionFactory & af, Syntax & s) NavierStokesApp::registerAll(f, af, s); #endif +#ifdef PERIDYNAMICS_ENABLED + PeridynamicsApp::registerAll(f, af, s); +#endif + #ifdef PHASE_FIELD_ENABLED PhaseFieldApp::registerAll(f, af, s); #endif diff --git a/modules/peridynamics/include/userobjects/NodalAuxVariableUserObjectBasePD.h b/modules/peridynamics/include/userobjects/NodalAuxVariableUserObjectBasePD.h index 2c09616f2e15..2ce776c92605 100644 --- a/modules/peridynamics/include/userobjects/NodalAuxVariableUserObjectBasePD.h +++ b/modules/peridynamics/include/userobjects/NodalAuxVariableUserObjectBasePD.h @@ -28,7 +28,7 @@ class NodalAuxVariableUserObjectBasePD : public ElementUserObjectBasePD virtual void initialize() override; virtual void execute() override; - virtual void threadJoin(const UserObject & uo) override; + virtual void threadJoin(const UserObject & /*uo*/) override{}; virtual void finalize() override; protected: diff --git a/modules/peridynamics/src/userobjects/NodalAuxVariableUserObjectBasePD.C b/modules/peridynamics/src/userobjects/NodalAuxVariableUserObjectBasePD.C index 2faa9a035b27..e2f1fad1fabd 100644 --- a/modules/peridynamics/src/userobjects/NodalAuxVariableUserObjectBasePD.C +++ b/modules/peridynamics/src/userobjects/NodalAuxVariableUserObjectBasePD.C @@ -50,19 +50,6 @@ NodalAuxVariableUserObjectBasePD::execute() } } -void -NodalAuxVariableUserObjectBasePD::threadJoin(const UserObject & uo) -{ - const NodalAuxVariableUserObjectBasePD & navuob = - static_cast(uo); - for (unsigned int i = 0; i < 2; ++i) - { - dof_id_type dof = _current_elem->get_node(i)->dof_number(_aux.number(), _aux_var->number(), 0); - - _aux_sln.add(dof, navuob._aux_sln(dof)); - } -} - void NodalAuxVariableUserObjectBasePD::finalize() { diff --git a/modules/peridynamics/test/include/base/PeridynamicsTestApp.h b/modules/peridynamics/test/include/base/PeridynamicsTestApp.h index c9ddafa9d8ba..a49a94c8c2a6 100644 --- a/modules/peridynamics/test/include/base/PeridynamicsTestApp.h +++ b/modules/peridynamics/test/include/base/PeridynamicsTestApp.h @@ -23,6 +23,7 @@ class PeridynamicsTestApp : public MooseApp virtual ~PeridynamicsTestApp(); static void registerApps(); + static void registerAll(Factory & f, ActionFactory & af, Syntax & s, bool use_test_objs = false); static void registerObjects(Factory & factory); static void associateSyntax(Syntax & syntax, ActionFactory & action_factory); static void registerExecFlags(Factory & factory); diff --git a/modules/peridynamics/test/src/base/PeridynamicsTestApp.C b/modules/peridynamics/test/src/base/PeridynamicsTestApp.C index 2e7691051389..3f5a984c964e 100644 --- a/modules/peridynamics/test/src/base/PeridynamicsTestApp.C +++ b/modules/peridynamics/test/src/base/PeridynamicsTestApp.C @@ -20,30 +20,27 @@ validParams() return params; } +registerKnownLabel("PeridynamicsTestApp"); + PeridynamicsTestApp::PeridynamicsTestApp(InputParameters parameters) : MooseApp(parameters) { - Moose::registerObjects(_factory); - PeridynamicsApp::registerObjectDepends(_factory); - PeridynamicsApp::registerObjects(_factory); - - Moose::associateSyntax(_syntax, _action_factory); - PeridynamicsApp::associateSyntaxDepends(_syntax, _action_factory); - PeridynamicsApp::associateSyntax(_syntax, _action_factory); + PeridynamicsTestApp::registerAll( + _factory, _action_factory, _syntax, getParam("allow_test_objects")); +} - Moose::registerExecFlags(_factory); - PeridynamicsApp::registerExecFlags(_factory); +PeridynamicsTestApp::~PeridynamicsTestApp() {} - bool use_test_objs = getParam("allow_test_objects"); +void +PeridynamicsTestApp::registerAll(Factory & f, ActionFactory & af, Syntax & s, bool use_test_objs) +{ + PeridynamicsApp::registerAll(f, af, s); if (use_test_objs) { - PeridynamicsTestApp::registerObjects(_factory); - PeridynamicsTestApp::associateSyntax(_syntax, _action_factory); - PeridynamicsTestApp::registerExecFlags(_factory); + Registry::registerObjectsTo(f, {"PeridynamicsTestApp"}); + Registry::registerActionsTo(af, {"PeridynamicsTestApp"}); } } -PeridynamicsTestApp::~PeridynamicsTestApp() {} - void PeridynamicsTestApp::registerApps() { @@ -52,50 +49,30 @@ PeridynamicsTestApp::registerApps() } void -PeridynamicsTestApp::registerObjects(Factory & /*factory*/) +PeridynamicsTestApp::registerObjects(Factory & factory) { - /* Uncomment Factory parameter and register your new test objects here! */ + Registry::registerObjectsTo(factory, {"PeridynamicsTestApp"}); } void -PeridynamicsTestApp::associateSyntax(Syntax & /*syntax*/, ActionFactory & /*action_factory*/) +PeridynamicsTestApp::associateSyntax(Syntax & /*syntax*/, ActionFactory & action_factory) { - /* Uncomment Syntax and ActionFactory parameters and register your new test objects here! */ + Registry::registerActionsTo(action_factory, {"PeridynamicsTestApp"}); } void PeridynamicsTestApp::registerExecFlags(Factory & /*factory*/) { - /* Uncomment Factory parameter and register your new execute flags here! */ -} - -/*************************************************************************************************** - *********************** Dynamic Library Entry Points - DO NOT MODIFY ****************************** - **************************************************************************************************/ -// External entry point for dynamic application loading -extern "C" void -PeridynamicsTestApp__registerApps() -{ - PeridynamicsTestApp::registerApps(); -} - -// External entry point for dynamic object registration -extern "C" void -PeridynamicsTestApp__registerObjects(Factory & factory) -{ - PeridynamicsTestApp::registerObjects(factory); } -// External entry point for dynamic syntax association extern "C" void -PeridynamicsTestApp__associateSyntax(Syntax & syntax, ActionFactory & action_factory) +PeridynamicsTestApp__registerAll(Factory & f, ActionFactory & af, Syntax & s) { - PeridynamicsTestApp::associateSyntax(syntax, action_factory); + PeridynamicsTestApp::registerAll(f, af, s); } -// External entry point for dynamic execute flag registration extern "C" void -PeridynamicsTestApp__registerExecFlags(Factory & factory) +PeridynamicsTestApp__registerApps() { - PeridynamicsTestApp::registerExecFlags(factory); + PeridynamicsTestApp::registerApps(); }