-
Notifications
You must be signed in to change notification settings - Fork 5
Add RBE Constraint #40
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,3 +90,6 @@ UK Atomic Energy Authority | |
|
|
||
| Alexander Whittle, | ||
| UK Atomic Energy Authority | ||
|
|
||
| Bill Ellis, | ||
| UK Atomic Energy Authority | ||
This file contains hidden or 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 | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #pragma once | ||
| #include "NodalConstraint.h" | ||
|
|
||
| class RBEConstraint : public NodalConstraint | ||
| { | ||
| public: | ||
| static InputParameters validParams(); | ||
| RBEConstraint(const InputParameters & parameters); | ||
|
|
||
| protected: | ||
| virtual Real computeQpResidual(Moose::ConstraintType type) override; | ||
| virtual Real computeQpJacobian(Moose::ConstraintJacobianType type) override; | ||
| std::string _primary_node_set_id; | ||
| std::string _secondary_node_set_id; | ||
| Real _penalty; | ||
| Real _primary_size; | ||
| }; |
This file contains hidden or 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 | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| #include "RBEConstraint.h" | ||
| #include "MooseMesh.h" | ||
|
|
||
| registerMooseObject("ProteusApp", RBEConstraint); | ||
|
|
||
| InputParameters | ||
| RBEConstraint::validParams() | ||
| { | ||
| InputParameters params = NodalConstraint::validParams(); | ||
| params.addClassDescription( | ||
| "Constrains secondary node to move as a linear combination of primary nodes."); | ||
| params.addRequiredParam<BoundaryName>("primary_node_set", | ||
| "The boundary ID associated with the primary nodes."); | ||
| params.addRequiredParam<BoundaryName>("secondary_node_set", | ||
| "The boundary ID associated with the secondary side."); | ||
ajdubas marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| params.addRequiredParam<Real>("penalty", "The penalty used for the boundary term."); | ||
ajdubas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| params.addRequiredParam<Real>("primary_size", "The number of nodes in the primary node set."); | ||
| return params; | ||
| } | ||
|
|
||
| RBEConstraint::RBEConstraint(const InputParameters & parameters) | ||
| : NodalConstraint(parameters), | ||
| _primary_node_set_id(getParam<BoundaryName>("primary_node_set")), | ||
| _secondary_node_set_id(getParam<BoundaryName>("secondary_node_set")), | ||
| _penalty(getParam<Real>("penalty")), | ||
| _primary_size(getParam<Real>("primary_size")) | ||
| { | ||
| const auto & lm_mesh = _mesh.getMesh(); | ||
|
|
||
| // Get secondary nodes | ||
| std::vector<dof_id_type> nodelist = | ||
| _mesh.getNodeList(_mesh.getBoundaryID(_secondary_node_set_id)); | ||
| std::vector<dof_id_type>::iterator in; | ||
|
|
||
| for (in = nodelist.begin(); in != nodelist.end(); ++in) | ||
| { | ||
| const Node * const node = lm_mesh.query_node_ptr(*in); | ||
| if (node && node->processor_id() == _subproblem.processor_id()) | ||
| _connected_nodes.push_back(*in); | ||
| } | ||
|
|
||
| // Get primary nodes | ||
| std::vector<dof_id_type> primary_nodelist = | ||
| _mesh.getNodeList(_mesh.getBoundaryID(_primary_node_set_id)); | ||
|
|
||
| const auto & node_to_elem_map = _mesh.nodeToElemMap(); | ||
|
|
||
| for (in = primary_nodelist.begin(); in != primary_nodelist.end(); ++in) | ||
| { | ||
| auto node_to_elem_pair = node_to_elem_map.find(*in); | ||
| if (node_to_elem_pair == node_to_elem_map.end()) | ||
| continue; | ||
|
|
||
| _primary_node_vector.push_back(*in); | ||
| const std::vector<dof_id_type> & elems = node_to_elem_pair->second; | ||
| for (const auto & elem_id : elems) | ||
| { | ||
| _subproblem.addGhostedElem(elem_id); | ||
| } | ||
| } | ||
| _weights = std::vector<Real>(_primary_size, 1.0/_primary_size); | ||
| } | ||
|
|
||
| Real | ||
| RBEConstraint::computeQpResidual(Moose::ConstraintType type) | ||
| { | ||
| /* | ||
| Secondary residual is u_secondary - weights[1]*u_primary[1] | ||
| - weights[2]*u_primary[2] - u_primary[n]*weights[n] | ||
| However, computeQpResidual is calculated for only a combination of one | ||
| primary and one secondary node at a time. To get around this, the residual is | ||
| split up such that the final secondary residual resembles the above expression. | ||
| */ | ||
| unsigned int primary_size = _primary_size; | ||
|
|
||
| switch (type) | ||
| { | ||
| case Moose::Primary: | ||
| return (_u_primary[_j] * _weights[_j] - _u_secondary[_i] / primary_size) | ||
| * _penalty; | ||
| case Moose::Secondary: | ||
| return (_u_secondary[_i] / primary_size - _u_primary[_j] * _weights[_j]) | ||
| * _penalty; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| Real | ||
| RBEConstraint::computeQpJacobian(Moose::ConstraintJacobianType type) | ||
| { | ||
| unsigned int primary_size = _primary_size; | ||
|
|
||
| switch (type) | ||
| { | ||
| case Moose::PrimaryPrimary: | ||
| return _penalty * _weights[_j]; | ||
| case Moose::PrimarySecondary: | ||
| return -_penalty / primary_size; | ||
| case Moose::SecondarySecondary: | ||
| return _penalty / primary_size; | ||
| case Moose::SecondaryPrimary: | ||
| return -_penalty * _weights[_j]; | ||
| default: | ||
| mooseError("Unsupported type"); | ||
| } | ||
| return 0; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.