Skip to content
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

Geo/11721 fix settlement output #11728

Merged
merged 102 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
8c1fa6a
WPK first attempt time loop executor
WPK4FEM Sep 29, 2023
294c2ff
also complementary to WPK first attempt time loop executor
WPK4FEM Sep 29, 2023
bdcadbc
Removed yet unused things. Added first unit test: TimeLoopReturnsPerf…
WPK4FEM Oct 9, 2023
9f47ad5
Added a StrategyWrapper with an always converging solver strategy for…
WPK4FEM Oct 9, 2023
0bfebf1
Added constructor with convergence argument to DummySolverStrategy. A…
WPK4FEM Oct 9, 2023
afb17c5
Give time loop executor a TimeStepEndState to start from. Keep track …
WPK4FEM Oct 9, 2023
81000b3
Use the time step executor. ( only one available so default construct…
WPK4FEM Oct 10, 2023
767fb7c
Keep track of used number of cycles. Added tests using a test time in…
WPK4FEM Oct 10, 2023
5476cbd
Removed a few unused dummy classes for testing
avdg81 Oct 10, 2023
e74ad60
Test the time loop executor using a prescribed time incrementor
avdg81 Oct 10, 2023
3f491e8
Added the strategy wrapper as a member of the time loop executor
avdg81 Oct 10, 2023
712c6c0
When running the time loop, increment the step number
avdg81 Oct 10, 2023
79147cd
Added test for and implementation of CloneTimeStep, in the strategy w…
WPK4FEM Oct 11, 2023
ba64d48
Merge branch 'master' into settlement_test
rfaasse Oct 11, 2023
916242f
Added method and tests for RestorePositionsAndDOFVectorToStartOfStep …
WPK4FEM Oct 11, 2023
6bc0546
First implementation of the strategy wrapper implementation
rfaasse Oct 11, 2023
10cab94
Added unit tests for all non-trivial functionality of the wrapper
rfaasse Oct 12, 2023
4b42c62
Fix pipeline build
rfaasse Oct 12, 2023
9753302
SaveTotalDisplacementFieldAtStartOfStage and AccumulateTotalDisplacem…
WPK4FEM Oct 12, 2023
9ba7a26
OutputProcess implementation and unit test added to time_loop_executor.
WPK4FEM Oct 12, 2023
f98bb53
FinalizeSolutionStep should be called outside the cycle loop. This ch…
WPK4FEM Oct 12, 2023
19d600f
Small things from review by Richard adapted.
WPK4FEM Oct 12, 2023
90a341d
Pass on process observables from TimeLoopExecutor to TimeStepExecutor.
WPK4FEM Oct 12, 2023
46b2597
Less code repetition in test_time_loop_executor
WPK4FEM Oct 12, 2023
c071354
interface class for TimeLoopExecutor as requested in review by Richard.
WPK4FEM Oct 12, 2023
16eb498
merge from master
WPK4FEM Oct 12, 2023
a0feda0
Added all the new strategy wrapper functions
rfaasse Oct 12, 2023
b832147
forgotten interface.h
WPK4FEM Oct 12, 2023
588b0ed
Code smell remarks from SonarCloud almost all resolved
WPK4FEM Oct 13, 2023
5795628
Added UTs for Getters, setters and Save and Accumulate
rfaasse Oct 13, 2023
c76b7ff
Added output process to strategy wrapper
rfaasse Oct 13, 2023
ae70275
Added functionality for restore positions and dof vector
rfaasse Oct 13, 2023
dfcdffb
Implemented suggestions from review by Anne.
WPK4FEM Oct 13, 2023
e8d0b77
Last? SonarCloud code smell fixed
WPK4FEM Oct 13, 2023
82c2fa8
Added unit test Restoring DoFs
rfaasse Oct 13, 2023
a047569
Merge branch 'geo/time-step-loop' into geo/strategy_wrapper_implement…
rfaasse Oct 13, 2023
5c2fead
Merge time loop executor work into feature branch
rfaasse Oct 13, 2023
90bdea4
Added test
rfaasse Oct 13, 2023
4029007
Merge branch 'settlement_test' into geo/strategy_wrapper_implementation
rfaasse Oct 13, 2023
b2d1fe4
Added integration tests
rfaasse Oct 13, 2023
beb7582
Merge branch 'master' into geo/strategy_wrapper_implementation
Oct 16, 2023
afc373d
Add logging when new time step is executed
Oct 16, 2023
6e0e3f8
Added linear solvers application link to settlement and geomechanics
rfaasse Oct 16, 2023
87d09f8
Several small improvements
avdg81 Oct 13, 2023
209d454
Extracted copying of nodal solution step values
avdg81 Oct 14, 2023
663570c
Refactored and improved some unit tests
avdg81 Oct 14, 2023
163cd5a
Refactored and improved some unit tests
avdg81 Oct 14, 2023
6abdd37
Added the adaptive time incrementor to the settlement workflow
avdg81 Oct 14, 2023
1dd5fe1
Added a working solving strategy wrapper to the settlement workflow
avdg81 Oct 16, 2023
86ae6f4
The settlement workflow now tries to run the time loop executor
avdg81 Oct 16, 2023
8275307
Corrected a mistake when creating the linear solvers application
avdg81 Oct 16, 2023
28c7e23
Add degrees of freedom to after reading the `.mdpa` file
avdg81 Oct 16, 2023
7249981
Print lots of debug messages and fixed a few minor issues
avdg81 Oct 18, 2023
e83c1bd
Added missing gauss parameters to writing the output. The settlement …
rfaasse Oct 18, 2023
f5b66d9
Restored the conditions and several submodel parts
avdg81 Oct 18, 2023
da618e8
Made fix for option to omit hydraulic head at nodes and removed log f…
rfaasse Oct 18, 2023
2329d33
Added python res files
rfaasse Oct 18, 2023
596f7d4
Removed logging from core library
rfaasse Oct 20, 2023
de91a14
reverting core files to master state
rfaasse Oct 20, 2023
299df85
Create a computational model part
avdg81 Oct 19, 2023
9dfeef2
Fixed the times written to the GiD output files
avdg81 Oct 20, 2023
c6db0ff
Fix GCC build
rfaasse Oct 20, 2023
c96d8f6
Removed unnecessary logging
rfaasse Oct 20, 2023
4ac479b
Extracted duplicate code to fix build
rfaasse Oct 20, 2023
3049f37
Merge branch 'master' into geo/strategy_wrapper_implementation
rfaasse Oct 20, 2023
7f2c85b
Small fix after merge
rfaasse Oct 20, 2023
716abae
Introduced the spatial tables of Marjan into the settlement test model
WPK4FEM Oct 20, 2023
69160f6
Merge remote-tracking branch 'refs/remotes/origin/geo/strategy_wrappe…
WPK4FEM Oct 20, 2023
b0332f4
Reduced code smells
rfaasse Oct 20, 2023
b3a942e
GeoElementUtilities::CalculateNodalHydraulicHeadFromWaterPressures no…
WPK4FEM Oct 20, 2023
bb1d0f5
Merge remote-tracking branch 'refs/remotes/origin/geo/strategy_wrappe…
WPK4FEM Oct 20, 2023
f710f4e
Fixed several code smells reported by SonarQube
avdg81 Oct 20, 2023
1ed4d3e
Remove redundant print statement
rfaasse Oct 20, 2023
7c35575
Merge branch 'geo/strategy_wrapper_implementation' of github.com:Krat…
avdg81 Oct 20, 2023
cfd0b8f
Simplified the writing of integration point (and nodal) results
avdg81 Oct 20, 2023
0aa408f
Added copying properties
rfaasse Oct 23, 2023
6a126bc
removed redundant log file
rfaasse Oct 23, 2023
2b51bc5
Removed a redundant blank line
avdg81 Oct 23, 2023
568103c
Cleaning up
rfaasse Oct 23, 2023
41ead0a
Merge branch 'geo/strategy_wrapper_implementation' of https://github.…
rfaasse Oct 23, 2023
529506f
Moved settlement workflow test to integration suite of cpp tests
rfaasse Oct 23, 2023
fd90b0e
Reordered a few lines to make the flow more logical
avdg81 Oct 23, 2023
b57a5b6
Removing SQ issues
rfaasse Oct 23, 2023
9c5b4c1
Merge remote-tracking branch 'origin/geo/strategy_wrapper_implementat…
rfaasse Oct 23, 2023
9b119b2
Two minor enhancements
avdg81 Oct 23, 2023
1cb6b02
Removed several log statements
avdg81 Oct 23, 2023
5084658
Removed a redundant statement
avdg81 Oct 23, 2023
362af55
Removed a redundant destructor
avdg81 Oct 23, 2023
cd1e427
Added test for saving total replacements twice and other minor fixes
rfaasse Oct 23, 2023
cc0cc0a
Fix Codacy complaint
rfaasse Oct 23, 2023
708c35c
Fix UT
rfaasse Oct 23, 2023
3522d0f
Only run stage 1-3 in the workflow test, since stage 4 has known issues
rfaasse Oct 23, 2023
2c3373a
Merge branch 'master' into geo/strategy_wrapper_implementation
rfaasse Oct 24, 2023
60492ee
Possible fix for pipeline test failure
rfaasse Oct 25, 2023
c33b4de
Another attempt at fixing the pipeline test
rfaasse Oct 25, 2023
f6d565b
Skipping workflow test temporarily due to discussed pipeline issues
rfaasse Oct 25, 2023
7018f20
Fixing normal load
rfaasse Oct 25, 2023
8a86b4e
Merge branch 'master' into geo/11721-fix-settlement-output
rfaasse Oct 26, 2023
0ddff31
Minor change to test and fixed the displacement for excavated part of…
rfaasse Oct 26, 2023
6a73f78
Fixed writing multiple time steps in one file
rfaasse Oct 26, 2023
cd2ad1b
Code cleanup and minor corrections
avdg81 Oct 27, 2023
8d08a1b
Updated the settlement workflow "unit test"
avdg81 Oct 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ namespace Kratos
if (!hasPiping)
{
MainExecution(model_part, processes, p_solving_strategy, 0.0, 1.0, 1);
GeoOutputWriter::WriteGiDOutput(model_part, projectfile, rWorkingDirectory);
const auto gid_output_settings = projectfile["output_processes"]["gid_output"][0]["Parameters"];
GeoOutputWriter writer{gid_output_settings, rWorkingDirectory, model_part};
writer.WriteGiDOutput(model_part, gid_output_settings);
}
else
{
Expand Down Expand Up @@ -473,7 +475,9 @@ namespace Kratos
break;
}

GeoOutputWriter::WriteGiDOutput(model_part, projectfile, rWorkingDirectory);
const auto gid_output_settings = projectfile["output_processes"]["gid_output"][0]["Parameters"];
GeoOutputWriter writer{gid_output_settings, rWorkingDirectory, model_part};
writer.WriteGiDOutput(model_part, gid_output_settings);

// Update boundary conditions for next search head.
if (RiverBoundary->Info() == "ApplyConstantScalarValueProcess")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "input_output/logger.h"
#include "time_loop_executor_interface.h"

#include "utilities/variable_utils.h"

#include "custom_processes/apply_scalar_constraint_table_process.h"
#include "custom_processes/apply_normal_load_table_process.h"
#include "custom_processes/apply_vector_constraint_table_process.h"
Expand All @@ -29,6 +27,8 @@
#include "spaces/ublas_space.h"
#include "solving_strategy_wrapper.hpp"
#include "adaptive_time_incrementor.h"
#include "custom_processes/find_neighbour_elements_of_conditions_process.hpp"
#include "custom_processes/deactivate_conditions_on_inactive_elements_process.hpp"

namespace
{
Expand Down Expand Up @@ -88,7 +88,6 @@ bool GetResetDisplacementsFrom(const Parameters& rProjectParameters)
}



namespace Kratos
{

Expand All @@ -99,7 +98,7 @@ KratosGeoSettlement::KratosGeoSettlement(std::unique_ptr<InputUtility> pInputUti
mpProcessInfoParser{std::move(pProcessInfoParser)},
mpTimeLoopExecutor{std::move(pTimeLoopExecutorInterface)}
{
mKernel.GetApplicationsList().clear();
Kernel::GetApplicationsList().clear();
mModel.Reset();
KRATOS_INFO("KratosGeoSettlement") << "Setting up Kratos" << std::endl;
KRATOS_ERROR_IF_NOT(mpInputUtility) << "Invalid Input Utility";
Expand Down Expand Up @@ -135,7 +134,7 @@ void KratosGeoSettlement::InitializeProcessFactory()
mProcessFactory->AddCreator("ApplyNormalLoadTableProcess",
[this](const Parameters& rParameters)
{
return std::make_unique<ApplyNormalLoadTableProcess>(mModel.GetModelPart(mModelPartName),
return std::make_unique<ApplyNormalLoadTableProcess>(GetMainModelPart(),
rParameters);
});

Expand Down Expand Up @@ -216,6 +215,7 @@ int KratosGeoSettlement::RunStage(const std::filesystem::path& rWorki

std::vector<std::shared_ptr<Process>> processes = GetProcesses(project_parameters);
std::vector<std::weak_ptr<Process>> process_observables(processes.begin(), processes.end());

for (const auto& process : processes) {
process->ExecuteInitialize();
}
Expand All @@ -231,9 +231,14 @@ int KratosGeoSettlement::RunStage(const std::filesystem::path& rWorki
mpTimeLoopExecutor->SetSolverStrategyWrapper(MakeStrategyWrapper(project_parameters,
rWorkingDirectory));
// For now, pass a dummy state. THIS PROBABLY NEEDS TO BE REFINED AT SOME POINT!
TimeStepEndState dummy_state;
dummy_state.convergence_state = TimeStepEndState::ConvergenceState::converged;
mpTimeLoopExecutor->Run(dummy_state);
TimeStepEndState start_of_loop_state;
start_of_loop_state.convergence_state = TimeStepEndState::ConvergenceState::converged;
start_of_loop_state.time = GetStartTimeFrom(project_parameters);
avdg81 marked this conversation as resolved.
Show resolved Hide resolved
mpTimeLoopExecutor->Run(start_of_loop_state);
}

for (const auto& process : processes) {
process->ExecuteFinalize();
}

FlushLoggingOutput(rLogCallback, logger_output, kratos_log_buffer);
Expand Down Expand Up @@ -348,11 +353,25 @@ std::unique_ptr<TimeIncrementor> KratosGeoSettlement::MakeTimeIncrementor(const
std::shared_ptr<StrategyWrapper> KratosGeoSettlement::MakeStrategyWrapper(const Parameters& rProjectParameters,
const std::filesystem::path& rWorkingDirectory)
{
auto& main_model_part = mModel.GetModelPart(mModelPartName);
auto solving_strategy = SolvingStrategyFactoryType::Create(rProjectParameters["solver_settings"],
main_model_part.GetSubModelPart(mComputationalSubModelPartName));
GetComputationalModelPart());
KRATOS_ERROR_IF_NOT(solving_strategy) << "No solving strategy was created!" << std::endl;

solving_strategy->Initialize();
GetMainModelPart().CloneTimeStep();

if (rProjectParameters["solver_settings"]["reset_displacements"].GetBool()) {
constexpr auto source_index = std::size_t{0};
constexpr auto destination_index = std::size_t{1};
RestoreValuesOfNodalVariable(DISPLACEMENT, source_index, destination_index);
RestoreValuesOfNodalVariable(ROTATION, source_index, destination_index);

VariableUtils{}.UpdateCurrentToInitialConfiguration(GetComputationalModelPart().Nodes());
}

FindNeighbourElementsOfConditionsProcess{GetComputationalModelPart()}.Execute();
DeactivateConditionsOnInactiveElements{GetComputationalModelPart()}.Execute();

// For now, we can create solving strategy wrappers only
using SolvingStrategyWrapperType = SolvingStrategyWrapper<SparseSpaceType, DenseSpaceType>;
return std::make_shared<SolvingStrategyWrapperType>(std::move(solving_strategy),
Expand All @@ -363,23 +382,28 @@ std::shared_ptr<StrategyWrapper> KratosGeoSettlement::MakeStrategyWrapper(const

void KratosGeoSettlement::PrepareModelPart(const Parameters& rSolverSettings)
{
auto& main_model_part = mModel.GetModelPart(mModelPartName);
auto& main_model_part = GetMainModelPart();
if (!main_model_part.HasSubModelPart(mComputationalSubModelPartName)) {
main_model_part.CreateSubModelPart(mComputationalSubModelPartName);
}
auto& computing_model_part = main_model_part.GetSubModelPart(mComputationalSubModelPartName);

if (rSolverSettings.Has("nodal_smoothing"))
{
main_model_part.GetProcessInfo().SetValue(NODAL_SMOOTHING, rSolverSettings["nodal_smoothing"].GetBool());
}

// Note that the computing part and the main model part _share_ their process info and properties
computing_model_part.SetProcessInfo(main_model_part.GetProcessInfo());
GetComputationalModelPart().SetProcessInfo(main_model_part.GetProcessInfo());
for (auto i = ModelPart::SizeType{0}; i < main_model_part.NumberOfMeshes(); ++i)
{
auto& mesh = main_model_part.GetMesh(i);
for (const auto& property : mesh.Properties())
{
computing_model_part.AddProperties( mesh.pGetProperties(property.GetId()));
GetComputationalModelPart().AddProperties( mesh.pGetProperties(property.GetId()));
}
}

computing_model_part.Set(ACTIVE);
GetComputationalModelPart().Set(ACTIVE);

const auto problem_domain_sub_model_part_list = rSolverSettings["problem_domain_sub_model_part_list"];
std::vector<std::string> domain_part_names;
Expand All @@ -395,7 +419,7 @@ void KratosGeoSettlement::PrepareModelPart(const Parameters& rSolverSettings)
node_id_set.insert(node.Id());
}
}
computing_model_part.AddNodes(std::vector<Node::IndexType>{node_id_set.begin(), node_id_set.end()});
GetComputationalModelPart().AddNodes(std::vector<Node::IndexType>{node_id_set.begin(), node_id_set.end()});

std::set<IndexedObject::IndexType> element_id_set;
for (const auto& name : domain_part_names) {
Expand All @@ -404,7 +428,7 @@ void KratosGeoSettlement::PrepareModelPart(const Parameters& rSolverSettings)
element_id_set.insert(element.Id());
}
}
computing_model_part.AddElements(std::vector<IndexedObject::IndexType>{element_id_set.begin(), element_id_set.end()});
GetComputationalModelPart().AddElements(std::vector<IndexedObject::IndexType>{element_id_set.begin(), element_id_set.end()});

const auto processes_sub_model_part_list = rSolverSettings["processes_sub_model_part_list"];
std::vector<std::string> domain_condition_names;
Expand All @@ -419,12 +443,22 @@ void KratosGeoSettlement::PrepareModelPart(const Parameters& rSolverSettings)
condition_id_set.insert(condition.Id());
}
}
computing_model_part.AddConditions(std::vector<IndexedObject::IndexType>{condition_id_set.begin(), condition_id_set.end()});
GetComputationalModelPart().AddConditions(std::vector<IndexedObject::IndexType>{condition_id_set.begin(), condition_id_set.end()});

// NOTE TO SELF: here we don't yet "Adding Computing Sub Sub Model Parts" (see check_and_prepare_model_process_geo.py)
// We are not sure yet whether that piece of code is relevant or not.
}

ModelPart& KratosGeoSettlement::GetMainModelPart()
{
return mModel.GetModelPart(mModelPartName);
}

ModelPart& KratosGeoSettlement::GetComputationalModelPart()
{
return GetMainModelPart().GetSubModelPart(mComputationalSubModelPartName);
}

// This default destructor is added in the cpp to be able to forward member variables in a unique_ptr
KratosGeoSettlement::~KratosGeoSettlement() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "geo_mechanics_application.h"
#include "linear_solvers_application.h"
#include "utilities/variable_utils.h"

namespace Kratos
{
Expand Down Expand Up @@ -55,6 +56,9 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) KratosGeoSettlement
ModelPart& AddNewModelPart(const std::string& rModelPartName);
void PrepareModelPart(const Parameters& rSolverSettings);

ModelPart& GetMainModelPart();
ModelPart& GetComputationalModelPart();

static void AddNodalSolutionStepVariablesTo(ModelPart& rModelPart);
static void AddDegreesOfFreedomTo(ModelPart& rModelPart);
void InitializeProcessFactory();
Expand All @@ -65,6 +69,22 @@ class KRATOS_API(GEO_MECHANICS_APPLICATION) KratosGeoSettlement
LoggerOutput::Pointer CreateLoggingOutput(std::stringstream& rKratosLogBuffer) const;
void FlushLoggingOutput(const std::function<void(const char*)>& rLogCallback, LoggerOutput::Pointer pLoggerOutput, const std::stringstream& rKratosLogBuffer) const;

template <typename TVariableType>
void RestoreValuesOfNodalVariable(const TVariableType& rVariable,
Node::IndexType SourceIndex,
Node::IndexType DestinationIndex)
{
if (!GetComputationalModelPart().HasNodalSolutionStepVariable(rVariable))
return;

VariableUtils{}.SetHistoricalVariableToZero(rVariable, GetComputationalModelPart().Nodes());

block_for_each(GetComputationalModelPart().Nodes(),
[&rVariable, SourceIndex, DestinationIndex](auto& node) {
node.GetSolutionStepValue(rVariable, DestinationIndex) = node.GetSolutionStepValue(rVariable, SourceIndex);
});
}

Kernel mKernel;
Model mModel;
std::string mModelPartName;
Expand Down
Loading
Loading