Skip to content

Commit 46090cc

Browse files
committed
Add missing processes and schemes to dgeosettlement workflow
1 parent 0deb41c commit 46090cc

File tree

3 files changed

+249
-13
lines changed

3 files changed

+249
-13
lines changed

applications/GeoMechanicsApplication/custom_utilities/scheme_factory.hpp

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
#pragma once
1414

1515
#include "custom_strategies/schemes/backward_euler_quasistatic_U_Pw_scheme.hpp"
16+
#include "custom_strategies/schemes/backward_euler_quasistatic_Pw_scheme.hpp"
1617
#include "custom_strategies/schemes/load_stepping_scheme.hpp"
1718
#include "custom_strategies/schemes/newmark_dynamic_U_Pw_scheme.hpp"
19+
#include "custom_strategies/schemes/newmark_quasistatic_damped_U_Pw_scheme.hpp"
20+
#include "custom_strategies/schemes/newmark_quasistatic_Pw_scheme.hpp"
21+
#include "custom_strategies/schemes/newmark_quasistatic_U_Pw_scheme.hpp"
1822
#include "solving_strategies/schemes/scheme.h"
1923
#include <memory>
2024

@@ -34,12 +38,28 @@ class SchemeFactory
3438
KRATOS_ERROR_IF_NOT(rSolverSettings.Has("solution_type"))
3539
<< "solution_type is not defined, aborting";
3640

37-
if (rSolverSettings["scheme_type"].GetString() == "Backward_Euler" &&
38-
rSolverSettings["solution_type"].GetString() == "Quasi-Static") {
39-
return std::make_shared<BackwardEulerQuasistaticUPwScheme<TSparseSpace, TDenseSpace>>();
41+
const auto scheme_type = rSolverSettings["scheme_type"].GetString();
42+
const auto solution_type = rSolverSettings["solution_type"].GetString();
43+
44+
// Determine the solver type (Pw or U_Pw)
45+
std::string solver_type = "U_Pw";
46+
if (rSolverSettings.Has("solver_type")) {
47+
solver_type = rSolverSettings["solver_type"].GetString();
4048
}
4149

42-
if (rSolverSettings["scheme_type"].GetString() == "Newmark") {
50+
// Backward Euler schemes
51+
if (scheme_type == "Backward_Euler") {
52+
if (solution_type == "Quasi-Static") {
53+
if (solver_type == "Pw") {
54+
return std::make_shared<BackwardEulerQuasistaticPwScheme<TSparseSpace, TDenseSpace>>();
55+
}
56+
// Default to U-Pw scheme
57+
return std::make_shared<BackwardEulerQuasistaticUPwScheme<TSparseSpace, TDenseSpace>>();
58+
}
59+
}
60+
61+
// Newmark schemes
62+
if (scheme_type == "Newmark") {
4363
KRATOS_ERROR_IF_NOT(rSolverSettings.Has("newmark_beta"))
4464
<< "'newmark_beta' is not defined, aborting";
4565
KRATOS_ERROR_IF_NOT(rSolverSettings.Has("newmark_gamma"))
@@ -50,25 +70,39 @@ class SchemeFactory
5070
const auto beta = rSolverSettings["newmark_beta"].GetDouble();
5171
const auto gamma = rSolverSettings["newmark_gamma"].GetDouble();
5272
const auto theta = rSolverSettings["newmark_theta"].GetDouble();
53-
if (rSolverSettings["solution_type"].GetString() == "dynamic") {
73+
74+
if (solution_type == "dynamic") {
5475
return std::make_shared<NewmarkDynamicUPwScheme<TSparseSpace, TDenseSpace>>(beta, gamma, theta);
5576
}
56-
if (rSolverSettings["solution_type"].GetString() == "Quasi-Static") {
57-
return std::make_shared<NewmarkQuasistaticUPwScheme<TSparseSpace, TDenseSpace>>(
58-
beta, gamma, theta);
77+
78+
if (solution_type == "Quasi-Static") {
79+
if (solver_type == "Pw") {
80+
return std::make_shared<NewmarkQuasistaticPwScheme<TSparseSpace, TDenseSpace>>(theta);
81+
}
82+
83+
const auto rayleigh_m = rSolverSettings.Has("rayleigh_m") ? rSolverSettings["rayleigh_m"].GetDouble() : 0.0;
84+
const auto rayleigh_k = rSolverSettings.Has("rayleigh_k") ? rSolverSettings["rayleigh_k"].GetDouble() : 0.0;
85+
86+
if (rayleigh_m < 1.0e-20 && rayleigh_k < 1.0e-20) {
87+
return std::make_shared<NewmarkQuasistaticUPwScheme<TSparseSpace, TDenseSpace>>(
88+
beta, gamma, theta);
89+
} else {
90+
return std::make_shared<NewmarkQuasistaticDampedUPwScheme<TSparseSpace, TDenseSpace>>(
91+
beta, gamma, theta);
92+
}
5993
}
6094
}
6195

62-
if (rSolverSettings["solution_type"].GetString() == "static") {
63-
if (rSolverSettings["scheme_type"].GetString() == "load_stepping") {
96+
// Static schemes
97+
if (solution_type == "static") {
98+
if (scheme_type == "load_stepping") {
6499
return std::make_shared<LoadSteppingScheme<TSparseSpace, TDenseSpace>>();
65100
}
66101
return std::make_shared<GeoMechanicsStaticScheme<TSparseSpace, TDenseSpace>>();
67102
}
68103

69-
KRATOS_ERROR << "Specified combination of solution_type ("
70-
<< rSolverSettings["solution_type"].GetString() << ") and scheme_type ("
71-
<< rSolverSettings["scheme_type"].GetString() << ") is not supported, aborting";
104+
KRATOS_ERROR << "Specified combination of solution_type (" << solution_type
105+
<< ") and scheme_type (" << scheme_type << ") is not supported, aborting";
72106
}
73107
};
74108

applications/GeoMechanicsApplication/custom_workflows/dgeosettlement.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
#include "custom_processes/apply_vector_constraint_table_process.h"
2727
#include "custom_processes/fix_water_pressures_above_phreatic_line.h"
2828
#include "custom_processes/set_parameter_field_process.hpp"
29+
#include "custom_processes/apply_c_phi_reduction_process.h"
30+
#include "custom_processes/apply_component_table_process.h"
31+
#include "custom_processes/apply_constant_interpolate_line_pressure_process.hpp"
32+
#include "custom_processes/apply_constant_phreatic_multi_line_pressure_process.h"
33+
#include "custom_processes/apply_final_stresses_of_previous_stage_to_initial_state.h"
34+
#include "custom_processes/apply_initial_uniform_stress_field.h"
35+
#include "custom_processes/apply_write_result_scalar_process.hpp"
36+
#include "custom_processes/calculate_incremental_motion_process.h"
37+
#include "custom_processes/calculate_total_motion_process.h"
38+
#include "custom_processes/geo_apply_constant_scalar_value_process.h"
39+
#include "custom_processes/set_absorbing_boundary_parameters_process.hpp"
40+
#include "custom_processes/set_multiple_moving_loads.h"
2941

3042
#include "adaptive_time_incrementor.h"
3143
#include "custom_processes/deactivate_conditions_on_inactive_elements_process.hpp"
@@ -161,6 +173,25 @@ void KratosGeoSettlement::InitializeProcessFactory()
161173
MakeCreatorFor<GeoExtrapolateIntegrationPointValuesToNodesProcess>());
162174
mProcessFactory->AddCreator("FixWaterPressuresAbovePhreaticLineProcess",
163175
MakeCreatorFor<FixWaterPressuresAbovePhreaticLineProcess>());
176+
mProcessFactory->AddCreator("ApplyComponentTableProcess",
177+
MakeCreatorFor<ApplyComponentTableProcess>());
178+
mProcessFactory->AddCreator("ApplyConstantPhreaticMultiLinePressureProcess",
179+
MakeCreatorFor<ApplyConstantPhreaticMultiLinePressureProcess>());
180+
mProcessFactory->AddCreator("ApplyFinalStressesOfPreviousStageToInitialState",
181+
MakeCreatorFor<ApplyFinalStressesOfPreviousStageToInitialState>());
182+
mProcessFactory->AddCreator("ApplyInitialUniformStressField", MakeCreatorFor<ApplyInitialUniformStressField>());
183+
mProcessFactory->AddCreator("ApplyWriteScalarProcess", MakeCreatorFor<ApplyWriteScalarProcess>());
184+
mProcessFactory->AddCreator("CalculateIncrementalMotionProcess",
185+
MakeCreatorFor<CalculateIncrementalMotionProcess>());
186+
mProcessFactory->AddCreator("CalculateTotalMotionProcess", MakeCreatorFor<CalculateTotalMotionProcess>());
187+
mProcessFactory->AddCreator("GeoApplyConstantScalarValueProcess",
188+
MakeCreatorFor<GeoApplyConstantScalarValueProcess>());
189+
mProcessFactory->AddCreator("SetMultipleMovingLoadsProcess", MakeCreatorFor<SetMultipleMovingLoadsProcess>());
190+
mProcessFactory->AddCreator("ApplyCPhiReductionProcess", MakeCreatorFor<ApplyCPhiReductionProcess>());
191+
mProcessFactory->AddCreator("ApplyConstantInterpolateLinePressureProcess",
192+
MakeCreatorFor<ApplyConstantInterpolateLinePressureProcess>());
193+
mProcessFactory->AddCreator("SetAbsorbingBoundaryParametersProcess",
194+
MakeCreatorFor<SetAbsorbingBoundaryParametersProcess>());
164195
mProcessFactory->SetCallBackWhenProcessIsUnknown([](const std::string& rProcessName) {
165196
KRATOS_ERROR << "Unexpected process (" << rProcessName << "), calculation is aborted";
166197
});

applications/GeoMechanicsApplication/tests/cpp_tests/custom_utilities/test_scheme_factory.cpp

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,175 @@ KRATOS_TEST_CASE_IN_SUITE(CreateScheme_ReturnsCorrectScheme_ForBackwardEulerQuas
8484
KRATOS_EXPECT_NE(backward_euler_scheme, nullptr);
8585
}
8686

87+
KRATOS_TEST_CASE_IN_SUITE(CreateScheme_ReturnsCorrectScheme_ForBackwardEulerQuasiStaticPw,
88+
KratosGeoMechanicsFastSuiteWithoutKernel)
89+
{
90+
const auto parameters =
91+
R"(
92+
{
93+
"scheme_type" : "Backward_Euler",
94+
"solution_type" : "Quasi-Static",
95+
"solver_type" : "Pw"
96+
}
97+
)";
98+
99+
const auto scheme = SchemeFactoryType::Create(Parameters{parameters});
100+
const auto backward_euler_scheme =
101+
dynamic_cast<const BackwardEulerQuasistaticPwScheme<SparseSpaceType, LocalSpaceType>*>(
102+
scheme.get());
103+
104+
KRATOS_EXPECT_NE(backward_euler_scheme, nullptr);
105+
}
106+
107+
KRATOS_TEST_CASE_IN_SUITE(CreateScheme_ReturnsCorrectScheme_ForNewmarkDynamic,
108+
KratosGeoMechanicsFastSuiteWithoutKernel)
109+
{
110+
const auto parameters =
111+
R"(
112+
{
113+
"scheme_type" : "Newmark",
114+
"solution_type" : "dynamic",
115+
"newmark_beta" : 0.25,
116+
"newmark_gamma" : 0.5,
117+
"newmark_theta" : 0.5
118+
}
119+
)";
120+
121+
const auto scheme = SchemeFactoryType::Create(Parameters{parameters});
122+
const auto newmark_scheme =
123+
dynamic_cast<const NewmarkDynamicUPwScheme<SparseSpaceType, LocalSpaceType>*>(
124+
scheme.get());
125+
126+
KRATOS_EXPECT_NE(newmark_scheme, nullptr);
127+
}
128+
129+
KRATOS_TEST_CASE_IN_SUITE(CreateScheme_ReturnsCorrectScheme_ForNewmarkQuasiStaticUndamped,
130+
KratosGeoMechanicsFastSuiteWithoutKernel)
131+
{
132+
const auto parameters =
133+
R"(
134+
{
135+
"scheme_type" : "Newmark",
136+
"solution_type" : "Quasi-Static",
137+
"newmark_beta" : 0.25,
138+
"newmark_gamma" : 0.5,
139+
"newmark_theta" : 0.5
140+
}
141+
)";
142+
143+
const auto scheme = SchemeFactoryType::Create(Parameters{parameters});
144+
const auto newmark_scheme =
145+
dynamic_cast<const NewmarkQuasistaticUPwScheme<SparseSpaceType, LocalSpaceType>*>(
146+
scheme.get());
147+
148+
KRATOS_EXPECT_NE(newmark_scheme, nullptr);
149+
}
150+
151+
KRATOS_TEST_CASE_IN_SUITE(CreateScheme_ReturnsCorrectScheme_ForNewmarkQuasiStaticDamped,
152+
KratosGeoMechanicsFastSuiteWithoutKernel)
153+
{
154+
const auto parameters =
155+
R"(
156+
{
157+
"scheme_type" : "Newmark",
158+
"solution_type" : "Quasi-Static",
159+
"newmark_beta" : 0.25,
160+
"newmark_gamma" : 0.5,
161+
"newmark_theta" : 0.5,
162+
"rayleigh_m" : 0.1
163+
}
164+
)";
165+
166+
const auto scheme = SchemeFactoryType::Create(Parameters{parameters});
167+
const auto newmark_scheme =
168+
dynamic_cast<const NewmarkQuasistaticDampedUPwScheme<SparseSpaceType, LocalSpaceType>*>(
169+
scheme.get());
170+
171+
KRATOS_EXPECT_NE(newmark_scheme, nullptr);
172+
}
173+
174+
KRATOS_TEST_CASE_IN_SUITE(CreateScheme_ReturnsCorrectScheme_ForNewmarkQuasiStaticDampedWithK,
175+
KratosGeoMechanicsFastSuiteWithoutKernel)
176+
{
177+
const auto parameters =
178+
R"(
179+
{
180+
"scheme_type" : "Newmark",
181+
"solution_type" : "Quasi-Static",
182+
"newmark_beta" : 0.25,
183+
"newmark_gamma" : 0.5,
184+
"newmark_theta" : 0.5,
185+
"rayleigh_k" : 1.0e-5
186+
}
187+
)";
188+
189+
const auto scheme = SchemeFactoryType::Create(Parameters{parameters});
190+
const auto newmark_scheme =
191+
dynamic_cast<const NewmarkQuasistaticDampedUPwScheme<SparseSpaceType, LocalSpaceType>*>(
192+
scheme.get());
193+
194+
KRATOS_EXPECT_NE(newmark_scheme, nullptr);
195+
}
196+
197+
KRATOS_TEST_CASE_IN_SUITE(CreateScheme_ReturnsCorrectScheme_ForNewmarkQuasiStaticPw,
198+
KratosGeoMechanicsFastSuiteWithoutKernel)
199+
{
200+
const auto parameters =
201+
R"(
202+
{
203+
"scheme_type" : "Newmark",
204+
"solution_type" : "Quasi-Static",
205+
"newmark_beta" : 0.25,
206+
"newmark_gamma" : 0.5,
207+
"newmark_theta" : 0.5,
208+
"solver_type" : "Pw"
209+
}
210+
)";
211+
212+
const auto scheme = SchemeFactoryType::Create(Parameters{parameters});
213+
const auto newmark_scheme =
214+
dynamic_cast<const NewmarkQuasistaticPwScheme<SparseSpaceType, LocalSpaceType>*>(
215+
scheme.get());
216+
217+
KRATOS_EXPECT_NE(newmark_scheme, nullptr);
218+
}
219+
220+
KRATOS_TEST_CASE_IN_SUITE(CreateScheme_ReturnsCorrectScheme_ForStaticLoadStepping,
221+
KratosGeoMechanicsFastSuiteWithoutKernel)
222+
{
223+
const auto parameters =
224+
R"(
225+
{
226+
"scheme_type" : "load_stepping",
227+
"solution_type" : "static"
228+
}
229+
)";
230+
231+
const auto scheme = SchemeFactoryType::Create(Parameters{parameters});
232+
const auto load_stepping_scheme =
233+
dynamic_cast<const LoadSteppingScheme<SparseSpaceType, LocalSpaceType>*>(
234+
scheme.get());
235+
236+
KRATOS_EXPECT_NE(load_stepping_scheme, nullptr);
237+
}
238+
239+
KRATOS_TEST_CASE_IN_SUITE(CreateScheme_ReturnsCorrectScheme_ForStaticDefault,
240+
KratosGeoMechanicsFastSuiteWithoutKernel)
241+
{
242+
const auto parameters =
243+
R"(
244+
{
245+
"scheme_type" : "some_scheme",
246+
"solution_type" : "static"
247+
}
248+
)";
249+
250+
const auto scheme = SchemeFactoryType::Create(Parameters{parameters});
251+
const auto static_scheme =
252+
dynamic_cast<const GeoMechanicsStaticScheme<SparseSpaceType, LocalSpaceType>*>(
253+
scheme.get());
254+
255+
KRATOS_EXPECT_NE(static_scheme, nullptr);
256+
}
257+
87258
} // namespace Kratos::Testing

0 commit comments

Comments
 (0)