-
Notifications
You must be signed in to change notification settings - Fork 246
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
[GeoMechanicsApplication] Adopt structural truss element with reset displacement #12531
Changes from all commits
de688de
c761c43
aff7e42
738fe5f
26487fb
67b861d
bc04d72
4e3a1b9
a41948a
5fe7582
e24927d
f5146fc
c2f6e8f
c7ca4f6
fc3efcf
1e3aeba
5cf54c1
8d97f3b
8464a53
394bf15
e3fc32e
00a92dc
ef86dd0
c316255
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// KRATOS___ | ||
// // ) ) | ||
// // ___ ___ | ||
// // ____ //___) ) // ) ) | ||
// // / / // // / / | ||
// ((____/ / ((____ ((___/ / MECHANICS | ||
// | ||
// License: geo_mechanics_application/license.txt | ||
// | ||
// Main authors: Richard Faasse | ||
// | ||
|
||
#include "reset_displacement_process.h" | ||
#include "includes/initial_state.h" | ||
#include "includes/kratos_parameters.h" | ||
#include "includes/model_part.h" | ||
#include "includes/ublas_interface.h" | ||
#include "includes/variables.h" | ||
|
||
#include <vector> | ||
|
||
namespace Kratos | ||
{ | ||
|
||
ResetDisplacementProcess::ResetDisplacementProcess(ModelPart& rModelPart, const Parameters&) | ||
: mrModelPart(rModelPart) | ||
{ | ||
} | ||
|
||
void ResetDisplacementProcess::ExecuteInitialize() | ||
{ | ||
block_for_each(mrModelPart.Elements(), [this](Element& rElement) { | ||
std::vector<Vector> stresses_on_integration_points; | ||
rElement.CalculateOnIntegrationPoints(PK2_STRESS_VECTOR, stresses_on_integration_points, | ||
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. As discussed, for now the PK2_STRESS_VECTOR is the right choice for structural elements (please correct me if I'm wrong @WPK4FEM) 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. Yes. |
||
mrModelPart.GetProcessInfo()); | ||
std::vector<ConstitutiveLaw::Pointer> constitutive_laws; | ||
rElement.CalculateOnIntegrationPoints(CONSTITUTIVE_LAW, constitutive_laws, mrModelPart.GetProcessInfo()); | ||
|
||
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. Shouldn't we check here whether
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. Agreed, added some checks |
||
CheckRetrievedElementData(constitutive_laws, stresses_on_integration_points, rElement.GetId()); | ||
|
||
for (auto i = std::size_t{0}; i < constitutive_laws.size(); ++i) { | ||
auto p_initial_state = make_intrusive<InitialState>(); | ||
p_initial_state->SetInitialStressVector(stresses_on_integration_points[i]); | ||
p_initial_state->SetInitialStrainVector(ZeroVector{constitutive_laws[i]->GetStrainSize()}); | ||
constitutive_laws[i]->SetInitialState(p_initial_state); | ||
} | ||
}); | ||
} | ||
|
||
int ResetDisplacementProcess::Check() | ||
{ | ||
KRATOS_ERROR_IF_NOT(mrModelPart.GetProcessInfo()[IS_RESTARTED]) | ||
<< "The IS_RESTARTED flag must be set to true in the ProcessInfo of the " | ||
"model part. Please use the \"rest\" option for the model input type"; | ||
|
||
return 0; | ||
} | ||
|
||
void ResetDisplacementProcess::CheckRetrievedElementData(const std::vector<ConstitutiveLaw::Pointer>& rConstitutiveLaws, | ||
const std::vector<Vector>& rStressesOnIntegrationPoints, | ||
IndexType ElementId) | ||
{ | ||
KRATOS_ERROR_IF(rConstitutiveLaws.empty()) | ||
<< "The constitutive laws on the integration points could not be retrieved for element " | ||
<< ElementId << std::endl; | ||
KRATOS_ERROR_IF(rStressesOnIntegrationPoints.empty()) | ||
<< "The stress vectors on the integration points could not be retrieved for element " | ||
<< ElementId << std::endl; | ||
KRATOS_ERROR_IF(rStressesOnIntegrationPoints.size() != rConstitutiveLaws.size()) | ||
<< "Number of retrieved stress vectors (" << rStressesOnIntegrationPoints.size() | ||
<< ") does not match the number of constitutive laws (" << rConstitutiveLaws.size() | ||
<< ") for element " << ElementId << std::endl; | ||
} | ||
|
||
} // namespace Kratos |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// KRATOS___ | ||
// // ) ) | ||
// // ___ ___ | ||
// // ____ //___) ) // ) ) | ||
// // / / // // / / | ||
// ((____/ / ((____ ((___/ / MECHANICS | ||
// | ||
// License: geo_mechanics_application/license.txt | ||
// | ||
// Main authors: Richard Faasse | ||
// | ||
|
||
#pragma once | ||
|
||
#include "includes/constitutive_law.h" | ||
#include "processes/process.h" | ||
|
||
namespace Kratos | ||
{ | ||
|
||
class ModelPart; | ||
class Parameters; | ||
class Element; | ||
|
||
class KRATOS_API(GEO_MECHANICS_APPLICATION) ResetDisplacementProcess : public Process | ||
{ | ||
public: | ||
KRATOS_CLASS_POINTER_DEFINITION(ResetDisplacementProcess); | ||
ResetDisplacementProcess(ModelPart& rModelPart, const Parameters&); | ||
~ResetDisplacementProcess() override = default; | ||
|
||
ResetDisplacementProcess(const ResetDisplacementProcess&) = delete; | ||
ResetDisplacementProcess& operator=(const ResetDisplacementProcess&) = delete; | ||
|
||
void ExecuteInitialize() override; | ||
int Check() override; | ||
|
||
private: | ||
ModelPart& mrModelPart; | ||
|
||
static void CheckRetrievedElementData(const std::vector<ConstitutiveLaw::Pointer>& rConstitutiveLaws, | ||
const std::vector<Vector>& rStressesOnIntegrationPoints, | ||
IndexType ElementId); | ||
}; | ||
|
||
} // namespace Kratos |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
import KratosMultiphysics.StructuralMechanicsApplication as StructuralMechanicsApplication | ||
import KratosMultiphysics.GeoMechanicsApplication as GeoMechanicsApplication | ||
|
||
import json | ||
|
||
def CreateSolver(model, custom_settings): | ||
return GeoMechanicalSolver(model, custom_settings) | ||
|
||
|
@@ -205,6 +207,14 @@ def PrepareModelPart(self): | |
self.settings["nodal_smoothing"].GetBool()) | ||
|
||
self.main_model_part.ProcessInfo.SetValue(KratosMultiphysics.STEP, 0) | ||
self.computing_model_part_name = "porous_computational_model_part" | ||
|
||
sub_model_part_names = [f"sub_{name.GetString()}" for name in self.settings["body_domain_sub_model_part_list"]] | ||
self.body_domain_sub_sub_model_part_list = KratosMultiphysics.Parameters(json.dumps(sub_model_part_names)) | ||
|
||
sub_model_part_names = [f"sub_{name.GetString()}" for name in self.settings["loads_sub_model_part_list"]] | ||
self.loads_sub_sub_model_part_list = KratosMultiphysics.Parameters(json.dumps(sub_model_part_names)) | ||
|
||
if not self.main_model_part.ProcessInfo[KratosMultiphysics.IS_RESTARTED]: | ||
## Executes the check and prepare model process (Create computing_model_part and set constitutive law) | ||
self._ExecuteCheckAndPrepare() | ||
Comment on lines
218
to
220
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. This is the switch that is important ( retain the previous constitutive law for a while ). Please explain that in the readme file. 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. Added it to the readme, please let me know if it's clear |
||
|
@@ -402,22 +412,6 @@ def _GetLinearSolver(self): | |
return self.linear_solver | ||
|
||
def _ExecuteCheckAndPrepare(self): | ||
|
||
self.computing_model_part_name = "porous_computational_model_part" | ||
|
||
# Create list of sub sub model parts (it is a copy of the standard lists with a different name) | ||
import json | ||
|
||
self.body_domain_sub_sub_model_part_list = [] | ||
for i in range(self.settings["body_domain_sub_model_part_list"].size()): | ||
self.body_domain_sub_sub_model_part_list.append("sub_"+self.settings["body_domain_sub_model_part_list"][i].GetString()) | ||
self.body_domain_sub_sub_model_part_list = KratosMultiphysics.Parameters(json.dumps(self.body_domain_sub_sub_model_part_list)) | ||
|
||
self.loads_sub_sub_model_part_list = [] | ||
for i in range(self.settings["loads_sub_model_part_list"].size()): | ||
self.loads_sub_sub_model_part_list.append("sub_"+self.settings["loads_sub_model_part_list"][i].GetString()) | ||
self.loads_sub_sub_model_part_list = KratosMultiphysics.Parameters(json.dumps(self.loads_sub_sub_model_part_list)) | ||
|
||
# Auxiliary parameters object for the CheckAndPepareModelProcess | ||
params = KratosMultiphysics.Parameters("{}") | ||
params.AddEmptyValue("computing_model_part_name").SetString(self.computing_model_part_name) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import KratosMultiphysics as Core | ||
import KratosMultiphysics.GeoMechanicsApplication as Geo | ||
|
||
|
||
def Factory(settings, model): | ||
if not isinstance(settings, Core.Parameters): | ||
raise TypeError("expected input shall be a Parameters object, encapsulating a json string") | ||
|
||
model_part = model[settings["Parameters"]["model_part_name"].GetString()] | ||
return Geo.ResetDisplacementProcess(model_part, settings["Parameters"]) |
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.
Are the initial strains ( or strain like variables ) independent of this?
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.
I have to define something for the initial strains, since if they aren't defined, we get a hard crash (the issue we saw after bringing this branch up to date with master). At this moment, I hardcode the initial strains to be zero vectors. We could discuss if this is always the desired behavior.