Skip to content

Commit

Permalink
[GeoMechanicsApplication] Initialize all entities (regardless of acti…
Browse files Browse the repository at this point in the history
…ve/inactive status) in the geo scheme (#13152)
  • Loading branch information
rfaasse authored Feb 21, 2025
1 parent c7ad72b commit a14ec2f
Show file tree
Hide file tree
Showing 11 changed files with 528 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ class GeoMechanicsTimeIntegrationScheme : public Scheme<TSparseSpace, TDenseSpac
KRATOS_CATCH("")
}

void InitializeElements(ModelPart& rModelPart) override
{
const ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo();
block_for_each(rModelPart.Elements(), [&r_current_process_info](auto& rElement) {
rElement.Initialize(r_current_process_info);
});
this->SetElementsAreInitialized();
}

void InitializeConditions(ModelPart& rModelPart) override
{
const ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo();
block_for_each(rModelPart.Conditions(), [r_current_process_info](auto& rCondition) {
rCondition.Initialize(r_current_process_info);
});
this->SetConditionsAreInitialized();
}

void Predict(ModelPart& rModelPart, DofsArrayType&, TSystemMatrixType&, TSystemVectorType&, TSystemVectorType&) override
{
this->UpdateVariablesDerivatives(rModelPart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ class GeoMechanicsSchemeTester
mModel.CreateModelPart("dummy", 2);
}

template <class T>
void TestFunctionCalledOnComponent_IsCalledOnActiveAndInactiveComponents()
template <class T, typename AddComponentToModelPartCallable, typename InitializeComponentsInModelPartCallable>
void TestFunctionCalledOnComponent_IsCalledOnActiveAndInactiveComponents(
const AddComponentToModelPartCallable& rAddComponentTo,
const InitializeComponentsInModelPartCallable& rInitializeComponentsInModelPart)
{
typename T::EquationIdVectorType r_equation_id_vector;
ProcessInfo r_process_info;
Expand All @@ -69,6 +71,10 @@ class GeoMechanicsSchemeTester
inactive_component->SetId(1);
inactive_component->Set(ACTIVE, false);

auto& r_model_part = mModel.GetModelPart("dummy");
rAddComponentTo(r_model_part, active_component);
rAddComponentTo(r_model_part, inactive_component);

EXPECT_CALL(*active_component, EquationIdVector(testing::_, testing::_)).Times(1);
mScheme.EquationId(*active_component.get(), r_equation_id_vector, r_process_info);

Expand All @@ -80,6 +86,10 @@ class GeoMechanicsSchemeTester

EXPECT_CALL(*inactive_component, GetDofList(testing::_, testing::_)).Times(1);
mScheme.GetDofList(*inactive_component.get(), r_dofs_vector, r_process_info);

EXPECT_CALL(*inactive_component, Initialize(testing::_)).Times(1);
EXPECT_CALL(*active_component, Initialize(testing::_)).Times(1);
rInitializeComponentsInModelPart(mScheme, r_model_part);
}

template <class T>
Expand Down Expand Up @@ -188,13 +198,17 @@ KRATOS_TEST_CASE_IN_SUITE(FunctionCalledOnCondition_IsCalledOnActiveAndInactiveC
KratosGeoMechanicsFastSuiteWithoutKernel)
{
GeoMechanicsSchemeTester tester;
tester.TestFunctionCalledOnComponent_IsCalledOnActiveAndInactiveComponents<SpyCondition>();
tester.TestFunctionCalledOnComponent_IsCalledOnActiveAndInactiveComponents<SpyCondition>(
[](auto& rModelPart, auto& rCondition) { rModelPart.AddCondition(rCondition); },
[](auto& rScheme, auto& rModelPart) { rScheme.InitializeConditions(rModelPart); });
}

KRATOS_TEST_CASE_IN_SUITE(FunctionCalledOnElement_IsCalledOnActiveAndInactiveElements, KratosGeoMechanicsFastSuiteWithoutKernel)
{
GeoMechanicsSchemeTester tester;
tester.TestFunctionCalledOnComponent_IsCalledOnActiveAndInactiveComponents<SpyElement>();
tester.TestFunctionCalledOnComponent_IsCalledOnActiveAndInactiveComponents<SpyElement>(
[](auto& rModelPart, auto& rElement) { rModelPart.AddElement(rElement); },
[](auto& rScheme, auto& rModelPart) { rScheme.InitializeElements(rModelPart); });
}

KRATOS_TEST_CASE_IN_SUITE(ForInvalidBufferSize_CheckGeoMechanicsTimeIntegrationScheme_Throws,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SpyCondition : public Condition

MOCK_METHOD(void, EquationIdVector, (EquationIdVectorType&, const ProcessInfo&), (const, override));
MOCK_METHOD(void, GetDofList, (DofsVectorType&, const ProcessInfo&), (const, override));
MOCK_METHOD(void, Initialize, (const ProcessInfo&), (override));

bool IsSolutionStepInitialized() const;
bool IsSolutionStepFinalized() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SpyElement : public Element

MOCK_METHOD(void, EquationIdVector, (EquationIdVectorType&, const ProcessInfo&), (const, override));
MOCK_METHOD(void, GetDofList, (DofsVectorType&, const ProcessInfo&), (const, override));
MOCK_METHOD(void, Initialize, (const ProcessInfo&), (override));

bool IsSolutionStepInitialized() const;
bool IsSolutionStepFinalized() const;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"properties" : [{
"model_part_name" : "PorousDomain.Soil",
"properties_id" : 1,
"Material" : {
"constitutive_law" : {
"name" : "GeoLinearElasticPlaneStrain2DLaw"
},
"Variables" : {
"IGNORE_UNDRAINED" : false,
"DENSITY_SOLID" : 2650,
"DENSITY_WATER" : 1000,
"POROSITY" : 0.3,
"BULK_MODULUS_SOLID" : 1000000000.0,
"BULK_MODULUS_FLUID" : 2000000.0,
"PERMEABILITY_XX" : 1.02e-11,
"PERMEABILITY_YY" : 1.02e-11,
"PERMEABILITY_XY" : 1.02e-11,
"DYNAMIC_VISCOSITY" : 8.9e-7,
"YOUNG_MODULUS" : 100000.0,
"POISSON_RATIO" : 0.0,
"BIOT_COEFFICIENT" : 1.0,
"RETENTION_LAW" : "SaturatedBelowPhreaticLevelLaw",
"SATURATED_SATURATION" : 1.0,
"RESIDUAL_SATURATION" : 1e-10,
"MINIMUM_RELATIVE_PERMEABILITY" : 0.0001
}
}
},{
"model_part_name" : "PorousDomain.truss",
"properties_id" : 2,
"Material" : {
"constitutive_law": {
"name" : "KratosMultiphysics.StructuralMechanicsApplication.TrussConstitutiveLaw"
},
"Variables": {
"YOUNG_MODULUS" : 50000.0,
"POISSON_RATIO" : 0.0,
"DENSITY" : 7850.0,
"CROSS_AREA" : 1.0,
"TRUSS_PRESTRESS_PK2" : 0.0
}
}
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"problem_data" : {
"problem_name" : "excavation_test_with_structural_elements",
"parallel_type" : "OpenMP",
"echo_level" : 1,
"start_time" : 0.0,
"end_time" : 1.0
},
"solver_settings" : {
"time_stepping" : {
"time_step" : 1.0,
"max_delta_time_factor" : 1000
},
"solver_type" : "U_Pw",
"solution_type" : "Quasi-static",
"strategy_type" : "newton_raphson",
"scheme_type" : "newmark",
"model_part_name" : "PorousDomain",
"domain_size" : 2,
"echo_level" : 0,
"model_import_settings" : {
"input_type" : "mdpa",
"input_filename" : "excavation_test_with_structural_elements"
},
"material_import_settings" : {
"materials_filename" : "Materials.json"
},
"buffer_size" : 2,
"clear_storage" : false,
"compute_reactions" : false,
"move_mesh_flag" : false,
"reform_dofs_at_each_step" : false,
"nodal_smoothing" : false,
"block_builder" : true,
"reset_displacements" : false,
"convergence_criterion" : "residual_criterion",
"residual_relative_tolerance" : 0.0001,
"residual_absolute_tolerance" : 1e-9,
"min_iterations" : 6,
"max_iterations" : 15,
"number_cycles" : 1,
"reduction_factor" : 0.5,
"increase_factor" : 2.0,
"desired_iterations" : 4,
"calculate_reactions" : false,
"rotation_dofs" : true,
"newmark_beta" : 0.25,
"newmark_gamma" : 0.5,
"newmark_theta" : 0.5,
"problem_domain_sub_model_part_list" : ["Soil","truss"],
"processes_sub_model_part_list" : ["BottomFixed", "NormalLoad"],
"body_domain_sub_model_part_list" : ["Soil","truss"],
"linear_solver_settings" : {
"solver_type" : "skyline_lu_factorization",
"scaling" : true
}
},
"processes" : {
"constraints_process_list" : [{
"python_module" : "apply_vector_constraint_table_process",
"kratos_module" : "KratosMultiphysics.GeoMechanicsApplication",
"process_name" : "ApplyVectorConstraintTableProcess",
"Parameters" : {
"model_part_name" : "PorousDomain.BottomFixed",
"variable_name" : "DISPLACEMENT",
"active" : [true,true,false],
"is_fixed" : [true,true,false],
"value" : [0.0,0.0,0.0],
"table" : [0,0,0]
}
},{
"python_module" : "apply_vector_constraint_table_process",
"kratos_module" : "KratosMultiphysics.GeoMechanicsApplication",
"process_name" : "ApplyVectorConstraintTableProcess",
"Parameters" : {
"model_part_name" : "PorousDomain.porous_computational_model_part",
"variable_name" : "DISPLACEMENT",
"active" : [true,false,false],
"is_fixed" : [true,false,false],
"value" : [0.0,0.0,0.0],
"table" : [0,0,0]
}
},{
"python_module" : "apply_scalar_constraint_table_process",
"kratos_module" : "KratosMultiphysics.GeoMechanicsApplication",
"process_name" : "ApplyScalarConstraintTableProcess",
"Parameters" : {
"model_part_name" : "PorousDomain",
"variable_name" : "WATER_PRESSURE",
"is_fixed" : true,
"table" : [0,0],
"fluid_pressure_type" : "Phreatic_Multi_Line",
"gravity_direction" : 1,
"out_of_plane_direction" : 2,
"x_coordinates" : [0.0,1.0],
"y_coordinates" : [1.0,1.0],
"z_coordinates" : [0.0,0.0],
"specific_weight" : 10000.0
}
},{
"python_module": "apply_excavation_process",
"kratos_module": "KratosMultiphysics.GeoMechanicsApplication",
"process_name": "ApplyExcavationProcess",
"Parameters": {
"model_part_name": "PorousDomain.truss",
"deactivate_soil_part": true
}
}]
},
"output_processes" : {
"gid_output" : [{
"python_module" : "gid_output_process",
"kratos_module" : "KratosMultiphysics",
"process_name" : "GiDOutputProcess",
"Parameters" : {
"model_part_name" : "PorousDomain.porous_computational_model_part",
"postprocess_parameters" : {
"result_file_configuration" : {
"gidpost_flags" : {
"GiDPostMode" : "GiD_PostAscii",
"WriteDeformedMeshFlag" : "WriteDeformed",
"WriteConditionsFlag" : "WriteConditions",
"MultiFileFlag" : "SingleFile"
},
"file_label" : "step",
"output_control_type" : "step",
"output_interval" : 1,
"body_output" : true,
"node_output" : false,
"skin_output" : false,
"plane_output" : [],
"nodal_results" : ["DISPLACEMENT"],
"nodal_nonhistorical_results" : [],
"gauss_point_results" : []
},
"point_data_configuration" : []
},
"output_name" : "excavation_test_with_structural_elements_Stage_1"
}
}]
}
}
Loading

0 comments on commit a14ec2f

Please sign in to comment.