-
Notifications
You must be signed in to change notification settings - Fork 261
[GeoMechanicsApplication] Include variable prediction in all newmark schemes #13449
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
Open
rfaasse
wants to merge
7
commits into
master
Choose a base branch
from
geo/11957-include-variable-prediction-in-all-newmark-schemes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f795b45
Moved the predict from dynamic to the generalized newmark scheme
rfaasse b890fdc
Added prediction of first order scalar variable when dt_variable is n…
rfaasse 2ccf9eb
Added prediction of first order scalar variable when dt_variable is f…
rfaasse 13e86d3
Fixed unit test by fixing logic (if -> else if)
rfaasse 6ccec00
Minor refactoring
rfaasse 78b5a69
Changed predict of quasistatic UPw scheme, such that it does not pred…
rfaasse 2855780
Merge remote-tracking branch 'origin/master' into geo/11957-include-v…
rfaasse 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
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ class GeneralizedNewmarkScheme : public GeoMechanicsTimeIntegrationScheme<TSpars | |
using BaseType = Scheme<TSparseSpace, TDenseSpace>; | ||
using TSystemMatrixType = typename BaseType::TSystemMatrixType; | ||
using TSystemVectorType = typename BaseType::TSystemVectorType; | ||
using DofsArrayType = typename BaseType::DofsArrayType; | ||
|
||
GeneralizedNewmarkScheme(const std::vector<FirstOrderScalarVariable>& rFirstOrderScalarVariables, | ||
const std::vector<SecondOrderVectorVariable>& rSecondOrderVectorVariables, | ||
|
@@ -105,6 +106,17 @@ class GeneralizedNewmarkScheme : public GeoMechanicsTimeIntegrationScheme<TSpars | |
KRATOS_CATCH("") | ||
} | ||
|
||
void Predict(ModelPart& rModelPart, DofsArrayType& rDofSet, TSystemMatrixType& A, TSystemVectorType& Dx, TSystemVectorType& b) override | ||
{ | ||
KRATOS_TRY | ||
|
||
PredictVariables(rModelPart); | ||
// Update (Angular) Acceleration, (Angular) Velocity and DtPressure | ||
this->UpdateVariablesDerivatives(rModelPart); | ||
|
||
KRATOS_CATCH("") | ||
} | ||
|
||
protected: | ||
inline void SetTimeFactors(ModelPart& rModelPart) override | ||
{ | ||
|
@@ -181,6 +193,87 @@ class GeneralizedNewmarkScheme : public GeoMechanicsTimeIntegrationScheme<TSpars | |
} | ||
|
||
private: | ||
void PredictVariables(const ModelPart& rModelPart) | ||
{ | ||
block_for_each(rModelPart.Nodes(), [this](Node& rNode) { PredictVariablesForNode(rNode); }); | ||
} | ||
|
||
void PredictVariablesForNode(Node& rNode) | ||
{ | ||
for (const auto& r_first_order_scalar_variable : this->GetFirstOrderScalarVariables()) { | ||
if (!rNode.SolutionStepsDataHas(r_first_order_scalar_variable.instance)) continue; | ||
PredictFirstOrderScalarVariableForNode(rNode, r_first_order_scalar_variable); | ||
} | ||
|
||
for (const auto& r_second_order_vector_variable : this->GetSecondOrderVectorVariables()) { | ||
if (!rNode.SolutionStepsDataHas(r_second_order_vector_variable.instance)) continue; | ||
PredictSecondOrderVectorVariableForNode(rNode, r_second_order_vector_variable); | ||
} | ||
} | ||
|
||
void PredictFirstOrderScalarVariableForNode(Node& rNode, const FirstOrderScalarVariable& rFirstOrderScalarVariable) | ||
{ | ||
const double previous_variable = | ||
rNode.FastGetSolutionStepValue(rFirstOrderScalarVariable.instance, 1); | ||
const double previous_first_time_derivative = | ||
rNode.FastGetSolutionStepValue(rFirstOrderScalarVariable.first_time_derivative, 1); | ||
const double current_first_time_derivative = | ||
rNode.FastGetSolutionStepValue(rFirstOrderScalarVariable.first_time_derivative, 0); | ||
|
||
if (rNode.IsFixed(rFirstOrderScalarVariable.first_time_derivative)) { | ||
rNode.FastGetSolutionStepValue(rFirstOrderScalarVariable.instance) = | ||
previous_variable + (1 - this->GetTheta()) * this->GetDeltaTime() * previous_first_time_derivative + | ||
current_first_time_derivative * this->GetTheta() * this->GetDeltaTime(); | ||
} else if (!rNode.IsFixed(rFirstOrderScalarVariable.instance)) { | ||
rNode.FastGetSolutionStepValue(rFirstOrderScalarVariable.instance) = | ||
previous_variable + this->GetDeltaTime() * previous_first_time_derivative; | ||
} | ||
} | ||
|
||
void PredictSecondOrderVectorVariableForNode(Node& rNode, const SecondOrderVectorVariable& rSecondOrderVectorVariable) | ||
{ | ||
const std::vector<std::string> components = {"X", "Y", "Z"}; | ||
|
||
for (const auto& component : components) { | ||
const auto& instance_component = VariablesUtilities::GetComponentFromVectorVariable( | ||
rSecondOrderVectorVariable.instance.Name(), component); | ||
|
||
if (!rNode.HasDofFor(instance_component)) continue; | ||
|
||
const auto& first_time_derivative_component = VariablesUtilities::GetComponentFromVectorVariable( | ||
rSecondOrderVectorVariable.first_time_derivative.Name(), component); | ||
const auto& second_time_derivative_component = VariablesUtilities::GetComponentFromVectorVariable( | ||
rSecondOrderVectorVariable.second_time_derivative.Name(), component); | ||
|
||
const double previous_variable = rNode.FastGetSolutionStepValue(instance_component, 1); | ||
const double current_first_time_derivative = | ||
rNode.FastGetSolutionStepValue(first_time_derivative_component, 0); | ||
const double previous_first_time_derivative = | ||
rNode.FastGetSolutionStepValue(first_time_derivative_component, 1); | ||
const double current_second_time_derivative = | ||
rNode.FastGetSolutionStepValue(second_time_derivative_component, 0); | ||
const double previous_second_time_derivative = | ||
rNode.FastGetSolutionStepValue(second_time_derivative_component, 1); | ||
if (rNode.IsFixed(second_time_derivative_component)) { | ||
rNode.FastGetSolutionStepValue(instance_component) = | ||
previous_variable + this->GetDeltaTime() * previous_first_time_derivative + | ||
this->GetDeltaTime() * this->GetDeltaTime() * | ||
((0.5 - this->GetBeta()) * previous_second_time_derivative + | ||
this->GetBeta() * current_second_time_derivative); | ||
} else if (rNode.IsFixed(first_time_derivative_component)) { | ||
rNode.FastGetSolutionStepValue(instance_component) = | ||
previous_variable + | ||
this->GetDeltaTime() * ((this->GetBeta() / this->GetGamma()) * | ||
(current_first_time_derivative - previous_first_time_derivative) + | ||
previous_first_time_derivative); | ||
} else if (!rNode.IsFixed(instance_component)) { | ||
rNode.FastGetSolutionStepValue(instance_component) = | ||
previous_variable + this->GetDeltaTime() * previous_first_time_derivative + | ||
0.5 * this->GetDeltaTime() * this->GetDeltaTime() * previous_second_time_derivative; | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of this just moved from the dynamic scheme, the only new part is the |
||
|
||
std::optional<double> mBeta; | ||
std::optional<double> mGamma; | ||
std::optional<double> mTheta; | ||
|
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WPK4FEM should I move this part (for the
SecondOrderVectorVariables
) back to the dynamic version of the newmark scheme, since only there we have non-zero accelerations/velocities?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, at least the part for acceleration.
The newmark_quasistatic_damped_U_Pw_scheme has no acceleration, but has velocities and a damping matrix, so would have a Predict without accelerations, but with prescribed velocities.