diff --git a/applications/GeoMechanicsApplication/custom_workflows/dgeoflow.cpp b/applications/GeoMechanicsApplication/custom_workflows/dgeoflow.cpp index de225a473e6b..74433c33bb54 100644 --- a/applications/GeoMechanicsApplication/custom_workflows/dgeoflow.cpp +++ b/applications/GeoMechanicsApplication/custom_workflows/dgeoflow.cpp @@ -35,7 +35,7 @@ class GeoFlowApplyConstantScalarValueProcess : public Kratos::ApplyConstantScala : Kratos::ApplyConstantScalarValueProcess(rModelPart, rVariable, DoubleValue, MeshId, rOptions) {} - bool hasWaterPressure() + bool hasWaterPressure() const { return mvariable_name == "WATER_PRESSURE"; } @@ -59,7 +59,7 @@ class GeoFlowApplyConstantHydrostaticPressureProcess : public Kratos::ApplyConst return mrModelPart; } - double GetReferenceCoord() + double GetReferenceCoord() const { return mReferenceCoordinate; } @@ -69,7 +69,7 @@ class GeoFlowApplyConstantHydrostaticPressureProcess : public Kratos::ApplyConst mReferenceCoordinate = value; } - bool hasWaterPressure() + bool hasWaterPressure() const { return mVariableName == "WATER_PRESSURE"; } @@ -82,14 +82,14 @@ namespace Kratos { KRATOS_INFO("KratosExecute") << "Setting Up Kratos" << std::endl; - if (!kernel.IsImported("GeoMechanicsApplication")) + if (!mKernel.IsImported("GeoMechanicsApplication")) { KRATOS_INFO("KratosExecute") << "Importing GeoMechanicsApplication" << std::endl; - geoApp = Kratos::make_shared(); - kernel.ImportApplication(geoApp); + mpGeoApp = Kratos::make_shared(); + mKernel.ImportApplication(mpGeoApp); } - Kratos::OpenMPUtils::SetNumThreads(1); + ParallelUtilities::SetNumThreads(1); if (this->GetEchoLevel() > 0) { Kratos::OpenMPUtils::PrintOMPInfo(); @@ -100,18 +100,18 @@ namespace Kratos int KratosExecute::GetEchoLevel() const { - return echoLevel; + return mEchoLevel; } void KratosExecute::SetEchoLevel(int level) { - echoLevel = level; + mEchoLevel = level; } void KratosExecute::ResetModelParts() { KRATOS_INFO("Resetting Model") << "Setting Up Execution" << std::endl; - current_model.Reset(); + mCurrentModel.Reset(); } KratosExecute::ConvergenceCriteriaType::Pointer KratosExecute::setup_criteria_dgeoflow() @@ -120,7 +120,7 @@ namespace Kratos const double abs_tol = 1.0e-9; VariableData *p_water_pres = &WATER_PRESSURE; KratosExecute::ConvergenceVariableListType convergence_settings{std::make_tuple(p_water_pres, rel_tol, abs_tol)}; - return KratosExecute::ConvergenceCriteriaType::Pointer(new KratosExecute::MixedGenericCriteriaType(convergence_settings)); + return std::make_shared(convergence_settings); } KratosExecute::LinearSolverType::Pointer KratosExecute::setup_solver_dgeoflow() @@ -128,7 +128,7 @@ namespace Kratos return Kratos::make_shared(); } - KratosExecute::GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer KratosExecute::setup_strategy_dgeoflow(ModelPart &model_part) + KratosExecute::GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer KratosExecute::setup_strategy_dgeoflow(ModelPart& rModelPart) { // Create the linear strategy auto p_solver = setup_solver_dgeoflow(); @@ -162,8 +162,8 @@ namespace Kratos bool ReformDofSetAtEachStep = false; bool MoveMeshFlag = false; - auto p_solving_strategy = Kratos::make_unique>( - model_part, + auto pSolvingStrategy = Kratos::make_unique>( + rModelPart, p_scheme, p_solver, p_criteria, @@ -171,16 +171,14 @@ namespace Kratos p_parameters, MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag); - p_solving_strategy->Check(); - return p_solving_strategy; + pSolvingStrategy->Check(); + return pSolvingStrategy; } - std::vector> KratosExecute::parseProcess(ModelPart &model_part, Parameters projFile) + void KratosExecute::ParseProcesses(ModelPart& rModelPart, Parameters projFile) { // Currently: In DGeoflow only fixed hydrostatic head has been , also need load of gravity. - std::vector> processes; - auto constraints_processes = projFile["processes"]["constraints_process_list"]; for (Parameters process : constraints_processes) { @@ -191,18 +189,18 @@ namespace Kratos std::size_t found = name.find_last_of('.'); std::string subname = name.substr(found + 1); - ModelPart &part = model_part.GetSubModelPart(subname); + ModelPart &part = rModelPart.GetSubModelPart(subname); if (pressure_type == "Uniform") { auto value = process["Parameters"]["value"].GetDouble(); - processes.push_back(make_shared(part, WATER_PRESSURE, value, 0, ApplyConstantScalarValueProcess::VARIABLE_IS_FIXED)); + mProcesses.push_back(make_shared(part, WATER_PRESSURE, value, 0, ApplyConstantScalarValueProcess::VARIABLE_IS_FIXED)); } else if (pressure_type == "Hydrostatic") { auto cProcesses = process.Clone(); cProcesses["Parameters"].RemoveValue("fluid_pressure_type"); - processes.push_back(make_shared(part, cProcesses["Parameters"])); + mProcesses.push_back(make_shared(part, cProcesses["Parameters"])); } else { @@ -215,34 +213,32 @@ namespace Kratos auto name = loads_processes.GetArrayItem(0)["Parameters"]["model_part_name"].GetString(); std::size_t found = name.find_last_of('.'); std::string subname = name.substr(found + 1); - ModelPart &part = model_part.GetSubModelPart(subname); - processes.push_back(make_shared(ApplyConstantScalarValueProcess(part, VOLUME_ACCELERATION_X, - 0.0, 0, ApplyConstantScalarValueProcess::VARIABLE_IS_FIXED))); + ModelPart &part = rModelPart.GetSubModelPart(subname); + mProcesses.push_back(make_shared(part, VOLUME_ACCELERATION_X, + 0.0, 0, ApplyConstantScalarValueProcess::VARIABLE_IS_FIXED)); - processes.push_back(make_shared(ApplyConstantScalarValueProcess(part, VOLUME_ACCELERATION_Y, -9.81, - 0, ApplyConstantScalarValueProcess::VARIABLE_IS_FIXED))); + mProcesses.push_back(make_shared(part, VOLUME_ACCELERATION_Y, -9.81, + 0, ApplyConstantScalarValueProcess::VARIABLE_IS_FIXED)); - processes.push_back(make_shared(ApplyConstantScalarValueProcess(part, VOLUME_ACCELERATION_Z, 0.0, - 0, ApplyConstantScalarValueProcess::VARIABLE_IS_FIXED))); + mProcesses.push_back(make_shared(part, VOLUME_ACCELERATION_Z, 0.0, + 0, ApplyConstantScalarValueProcess::VARIABLE_IS_FIXED)); - return processes; } - int KratosExecute::MainExecution(ModelPart& rModelPart, - const std::vector>& rProcesses, - const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer& rpSolvingStrategy, - double Time, - double DeltaTime, - unsigned int NumberOfIterations) + int KratosExecute::MainExecution(ModelPart& rModelPart, + const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer rpSolvingStrategy, + double Time, + double DeltaTime, + unsigned int NumberOfIterations) const { // Initialize - for (const auto& process : rProcesses) + for (const auto& process : mProcesses) { process->ExecuteInitialize(); } - for (const auto& process : rProcesses) + for (const auto& process : mProcesses) { process->ExecuteBeforeSolutionLoop(); } @@ -254,7 +250,7 @@ namespace Kratos rpSolvingStrategy->Initialize(); rpSolvingStrategy->InitializeSolutionStep(); - for (const auto& process : rProcesses) + for (const auto& process : mProcesses) { process->ExecuteInitializeSolutionStep(); } @@ -262,7 +258,7 @@ namespace Kratos rpSolvingStrategy->Predict(); rpSolvingStrategy->SolveSolutionStep(); - for (const auto& process : rProcesses) + for (const auto& process : mProcesses) { process->ExecuteFinalizeSolutionStep(); } @@ -270,7 +266,7 @@ namespace Kratos rpSolvingStrategy->FinalizeSolutionStep(); } - for (const auto& process : rProcesses) + for (const auto& process : mProcesses) { process->ExecuteFinalize(); } @@ -278,343 +274,380 @@ namespace Kratos return 0; } - int KratosExecute::ExecuteFlowAnalysis(const std::string& rWorkingDirectory, - const std::string& rProjectParamsFileName, - double minCriticalHead, - double maxCriticalHead, - double stepCriticalHead, - const std::string& rCriticalHeadBoundaryModelPartName, - const std::function& rLogCallback, - const std::function& rReportProgress, - const std::function& rReportTextualProgress, - const std::function& rShouldCancel) + int KratosExecute::ExecuteFlowAnalysis(std::string_view WorkingDirectory, + const std::string& rProjectParamsFileName, + const CriticalHeadInfo& rCriticalHeadInfo, + std::string_view CriticalHeadBoundaryModelPartName, + const CallBackFunctions& rCallBackFunctions) { + mWorkingDirectory = WorkingDirectory; + mCriticalHeadBoundaryModelPartName = CriticalHeadBoundaryModelPartName; + + this->SetEchoLevel(1); - std::stringstream kratosLogBuffer; - LoggerOutput::Pointer p_output(new LoggerOutput(kratosLogBuffer)); - Logger::AddOutput(p_output); - + std::stringstream kratos_log_buffer; + auto pOutput = std::make_shared(kratos_log_buffer); + Logger::AddOutput(pOutput); + try { - rReportProgress(0.0); + rCallBackFunctions.ReportProgress(0.0); - std::string projectpath = rWorkingDirectory + "/" + rProjectParamsFileName; + std::string projectpath = mWorkingDirectory + "/" + rProjectParamsFileName; const FileInputUtility input_utility; auto projectfile = input_utility.ProjectParametersFromFile(projectpath); auto materialname = projectfile["solver_settings"]["material_import_settings"]["materials_filename"].GetString(); - std::string materialpath = rWorkingDirectory + "/" + materialname; + std::string materialpath = mWorkingDirectory + "/" + materialname; auto modelName = projectfile["solver_settings"]["model_part_name"].GetString(); - ModelPart &model_part = current_model.CreateModelPart(modelName); - model_part.SetBufferSize(2); + ModelPart& rModelPart = mCurrentModel.CreateModelPart(modelName); + rModelPart.SetBufferSize(2); - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Working Directory: " << rWorkingDirectory << std::endl; + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Working Directory: " << mWorkingDirectory << std::endl; KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Project Name: " << rProjectParamsFileName << std::endl; - const auto p_solving_strategy = setup_strategy_dgeoflow(model_part); - p_solving_strategy->SetEchoLevel(0); + const auto pSolvingStrategy = setup_strategy_dgeoflow(rModelPart); + pSolvingStrategy->SetEchoLevel(0); KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Setup Solving Strategy" << std::endl; - model_part.AddNodalSolutionStepVariable(VELOCITY); - model_part.AddNodalSolutionStepVariable(ACCELERATION); - - // Displacement - model_part.AddNodalSolutionStepVariable(DISPLACEMENT); - model_part.AddNodalSolutionStepVariable(TOTAL_DISPLACEMENT); - model_part.AddNodalSolutionStepVariable(REACTION); - model_part.AddNodalSolutionStepVariable(POINT_LOAD); - model_part.AddNodalSolutionStepVariable(LINE_LOAD); - model_part.AddNodalSolutionStepVariable(SURFACE_LOAD); - model_part.AddNodalSolutionStepVariable(VOLUME_ACCELERATION); - model_part.AddNodalSolutionStepVariable(NORMAL_CONTACT_STRESS); - model_part.AddNodalSolutionStepVariable(TANGENTIAL_CONTACT_STRESS); - - // Water - model_part.AddNodalSolutionStepVariable(WATER_PRESSURE); - model_part.AddNodalSolutionStepVariable(REACTION_WATER_PRESSURE); - model_part.AddNodalSolutionStepVariable(DT_WATER_PRESSURE); - model_part.AddNodalSolutionStepVariable(NORMAL_FLUID_FLUX); - model_part.AddNodalSolutionStepVariable(HYDRAULIC_DISCHARGE); - - // Smoothing - model_part.AddNodalSolutionStepVariable(NODAL_AREA); - model_part.AddNodalSolutionStepVariable(NODAL_CAUCHY_STRESS_TENSOR); - model_part.AddNodalSolutionStepVariable(NODAL_DAMAGE_VARIABLE); - model_part.AddNodalSolutionStepVariable(NODAL_JOINT_AREA); - model_part.AddNodalSolutionStepVariable(NODAL_JOINT_WIDTH); - model_part.AddNodalSolutionStepVariable(NODAL_JOINT_DAMAGE); + AddNodalSolutionStepVariables(rModelPart); + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Nodal Solution Variables Added" << std::endl; // Don't include the file extension of the mesh file name, since that is automatically appended by the // constructor of class ModelPartIO const auto mesh_file_name = projectfile["solver_settings"]["model_import_settings"]["input_filename"].GetString(); - const auto mesh_file_path = rWorkingDirectory + "/" + mesh_file_name; + const auto mesh_file_path = mWorkingDirectory + "/" + mesh_file_name; ModelPartIO reader{mesh_file_path}; - reader.ReadModelPart(model_part); + reader.ReadModelPart(rModelPart); KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Parsed Mesh" << std::endl; - input_utility.AddMaterialsFromFile(materialpath, current_model); + input_utility.AddMaterialsFromFile(materialpath, mCurrentModel); KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Parsed Material" << std::endl; // Dofs for Water Pressure - VariableUtils().AddDofWithReaction(WATER_PRESSURE, REACTION_WATER_PRESSURE, model_part); - VariableUtils().AddDof(VOLUME_ACCELERATION_X, model_part); - VariableUtils().AddDof(VOLUME_ACCELERATION_Y, model_part); - VariableUtils().AddDof(VOLUME_ACCELERATION_Z, model_part); + VariableUtils().AddDofWithReaction(WATER_PRESSURE, REACTION_WATER_PRESSURE, rModelPart); + VariableUtils().AddDof(VOLUME_ACCELERATION_X, rModelPart); + VariableUtils().AddDof(VOLUME_ACCELERATION_Y, rModelPart); + VariableUtils().AddDof(VOLUME_ACCELERATION_Z, rModelPart); KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Added DoF" << std::endl; - std::vector> processes = parseProcess(model_part, projectfile); + ParseProcesses(rModelPart, projectfile); KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Parsed Process Data" << std::endl; - bool hasPiping = stepCriticalHead != 0; + bool has_piping = rCriticalHeadInfo.stepCriticalHead != 0; - if (rShouldCancel()) + if (rCallBackFunctions.ShouldCancel()) { - rLogCallback(kratosLogBuffer.str().c_str()); - Logger::RemoveOutput(p_output); - ResetModelParts(); + HandleCleanUp(rCallBackFunctions, pOutput); + return 0; } - if (!hasPiping) + const auto rGidOutputSettings = projectfile["output_processes"]["gid_output"][0]["Parameters"]; + + if (has_piping) { - MainExecution(model_part, processes, p_solving_strategy, 0.0, 1.0, 1); - 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); + ExecuteWithPiping(rModelPart, rGidOutputSettings, rCriticalHeadInfo, pOutput, rCallBackFunctions, pSolvingStrategy); } else { - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head search started." << std::endl; - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head min head: " << minCriticalHead << std::endl; - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head max head: " << maxCriticalHead << std::endl; - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head step size: " << stepCriticalHead << std::endl; + ExecuteWithoutPiping(rModelPart, rGidOutputSettings, pSolvingStrategy); + } - shared_ptr RiverBoundary; - if (rCriticalHeadBoundaryModelPartName.empty()) - { - RiverBoundary = FindRiverBoundaryAutomatically(p_solving_strategy, processes); - } - else - { - RiverBoundary = FindRiverBoundaryByName(rCriticalHeadBoundaryModelPartName, processes); - } + HandleCleanUp(rCallBackFunctions, pOutput); - if (!RiverBoundary) - { - throw std::logic_error("No river boundary found."); - } + return 0; + } + catch (const std::exception &exc) + { + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << exc.what(); - double criticalHead; - double currentHead; - bool pipingSuccess = false; + HandleCleanUp(rCallBackFunctions, pOutput); - auto currentProcess = std::static_pointer_cast(RiverBoundary); - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "River boundary name: " << currentProcess->GetName() << std::endl; + return 1; + } + } - currentProcess->SetReferenceCoord(minCriticalHead); - currentHead = minCriticalHead; - criticalHead = currentHead; + void KratosExecute::ExecuteWithoutPiping(ModelPart& rModelPart, + const Kratos::Parameters& rGidOutputSettings, + const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer pSolvingStrategy) const + { + MainExecution(rModelPart, pSolvingStrategy, 0.0, 1.0, 1); - std::vector pipeElements; - pipeElements = p_solving_strategy->GetPipingElements(); - const auto noPipeElements = pipeElements.size(); + GeoOutputWriter writer{rGidOutputSettings, mWorkingDirectory, rModelPart}; + writer.WriteGiDOutput(rModelPart, rGidOutputSettings); + } - int step = 1; - const auto maxSteps = static_cast(std::ceil((maxCriticalHead - minCriticalHead) / stepCriticalHead)) + 2; + int KratosExecute::ExecuteWithPiping(ModelPart& rModelPart, + const Kratos::Parameters& rGidOutputSettings, + const CriticalHeadInfo& rCriticalHeadInfo, + LoggerOutput::Pointer pOutput, + const CallBackFunctions& rCallBackFunctions, + const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer pSolvingStrategy) + { + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head search started." << std::endl; + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head min head: " << rCriticalHeadInfo.minCriticalHead << std::endl; + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head max head: " << rCriticalHeadInfo.maxCriticalHead << std::endl; + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head step size: " << rCriticalHeadInfo.stepCriticalHead << std::endl; - while (true) - { - if (maxCriticalHead - criticalHead < -1e-9) - { - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head undetermined at " << criticalHead << ", max search head reached: " << maxCriticalHead << std::endl; - break; - } - - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Searching at head: " << currentHead << std::endl; - - std::ostringstream currentHeadStream; - currentHeadStream << std::setprecision(8) << std::noshowpoint << currentHead; - std::string currentHeadString = currentHeadStream.str(); - - std::string progress = "Calculating head level " + currentHeadString + "m (" + std::to_string(step) + "/" + std::to_string(maxSteps) + ")"; - rReportTextualProgress(progress.data()); - rReportProgress(((double)step) / ((double)maxSteps)); - - MainExecution(model_part, processes, p_solving_strategy, 0.0, 1.0, 1); - - auto count = std::size_t{0}; - for (Element *element : pipeElements) - { - if (element->GetValue(PIPE_ACTIVE)) - count += 1; - } - - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Open pipe elements: " << count << std::endl; - - if (count == noPipeElements) - { - if (abs(currentHead - minCriticalHead) < 1e-9) - { - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head undetermined: All pipe elements open at initial search value :" << minCriticalHead << std::endl; - } - else - { - pipingSuccess = true; - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head found: " << criticalHead << std::endl; - } - break; - } - - 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") - { - ResetModelParts(); - throw std::logic_error("ApplyConstantScalarValueProcess process search is not Implemented"); - } - - if (RiverBoundary->Info() == "ApplyConstantHydrostaticPressureProcess") - { - criticalHead = currentProcess->GetReferenceCoord(); - currentHead = criticalHead + stepCriticalHead; - currentProcess->SetReferenceCoord(currentHead); - step++; - } - - if (rShouldCancel()) - { - rLogCallback(kratosLogBuffer.str().c_str()); - Logger::RemoveOutput(p_output); - ResetModelParts(); - return 0; - } - } + shared_ptr p_river_boundary; + if (mCriticalHeadBoundaryModelPartName.empty()) + { + p_river_boundary = FindRiverBoundaryAutomatically(pSolvingStrategy); + } + else + { + p_river_boundary = FindRiverBoundaryByName(mCriticalHeadBoundaryModelPartName); + } - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Writing result to: " << rWorkingDirectory << "\\criticalHead.json" << std::endl; + if (!p_river_boundary) + { + KRATOS_ERROR << "No river boundary found."; + } - // output critical head_json - std::ofstream CriticalHeadFile(rWorkingDirectory + "\\criticalHead.json"); + FindCriticalHead(rModelPart, rGidOutputSettings, rCriticalHeadInfo, pOutput, p_river_boundary, + pSolvingStrategy, rCallBackFunctions); - CriticalHeadFile << "{\n"; - CriticalHeadFile << "\t \"PipeData\":\t{\n"; - if (pipingSuccess) - { - CriticalHeadFile << "\t\t \"Success\": \"True\",\n"; - CriticalHeadFile << "\t\t \"CriticalHead\": \"" + std::to_string(criticalHead) + "\"\n"; - } - else - { - CriticalHeadFile << "\t\t \"Success\": \"False\"\n"; - } - CriticalHeadFile << "\t }\n"; - CriticalHeadFile << "}\n"; + WriteCriticalHeadResultToFile(); - // Close the file - CriticalHeadFile.close(); + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Finished writing result" << std::endl; + return 0; + } - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Finished writing result" << std::endl; - } + void KratosExecute::WriteCriticalHeadResultToFile() const + { + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Writing result to: " << mWorkingDirectory << "\\criticalHead.json" << std::endl; - rLogCallback(kratosLogBuffer.str().c_str()); - Logger::RemoveOutput(p_output); + // output critical head_json + std::ofstream critical_head_file(mWorkingDirectory + "\\criticalHead.json"); - ResetModelParts(); - return 0; + critical_head_file << "{\n"; + critical_head_file << "\t \"PipeData\":\t{\n"; + if (mPipingSuccess) + { + critical_head_file << "\t\t \"Success\": \"True\",\n"; + critical_head_file << "\t\t \"CriticalHead\": \"" + std::to_string(mCriticalHead) + "\"\n"; } - catch (const std::exception &exc) + else { - KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << exc.what(); + critical_head_file << "\t\t \"Success\": \"False\"\n"; + } + critical_head_file << "\t }\n"; + critical_head_file << "}\n"; - rLogCallback(kratosLogBuffer.str().c_str()); - Logger::RemoveOutput(p_output); + critical_head_file.close(); + } - ResetModelParts(); - return 1; + void KratosExecute::AddNodalSolutionStepVariables(ModelPart& rModelPart) const + { + rModelPart.AddNodalSolutionStepVariable(VELOCITY); + rModelPart.AddNodalSolutionStepVariable(ACCELERATION); + + // Displacement + rModelPart.AddNodalSolutionStepVariable(DISPLACEMENT); + rModelPart.AddNodalSolutionStepVariable(TOTAL_DISPLACEMENT); + rModelPart.AddNodalSolutionStepVariable(REACTION); + rModelPart.AddNodalSolutionStepVariable(POINT_LOAD); + rModelPart.AddNodalSolutionStepVariable(LINE_LOAD); + rModelPart.AddNodalSolutionStepVariable(SURFACE_LOAD); + rModelPart.AddNodalSolutionStepVariable(VOLUME_ACCELERATION); + rModelPart.AddNodalSolutionStepVariable(NORMAL_CONTACT_STRESS); + rModelPart.AddNodalSolutionStepVariable(TANGENTIAL_CONTACT_STRESS); + + // Water + rModelPart.AddNodalSolutionStepVariable(WATER_PRESSURE); + rModelPart.AddNodalSolutionStepVariable(REACTION_WATER_PRESSURE); + rModelPart.AddNodalSolutionStepVariable(DT_WATER_PRESSURE); + rModelPart.AddNodalSolutionStepVariable(NORMAL_FLUID_FLUX); + rModelPart.AddNodalSolutionStepVariable(HYDRAULIC_DISCHARGE); + + // Smoothing + rModelPart.AddNodalSolutionStepVariable(NODAL_AREA); + rModelPart.AddNodalSolutionStepVariable(NODAL_CAUCHY_STRESS_TENSOR); + rModelPart.AddNodalSolutionStepVariable(NODAL_DAMAGE_VARIABLE); + rModelPart.AddNodalSolutionStepVariable(NODAL_JOINT_AREA); + rModelPart.AddNodalSolutionStepVariable(NODAL_JOINT_WIDTH); + rModelPart.AddNodalSolutionStepVariable(NODAL_JOINT_DAMAGE); + } + + int KratosExecute::FindCriticalHead(ModelPart& rModelPart, + const Kratos::Parameters& rGidOutputSettings, + const CriticalHeadInfo& rCriticalHeadInfo, + LoggerOutput::Pointer pOutput, + const shared_ptr& pRiverBoundary, + const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer pSolvingStrategy, + const CallBackFunctions& rCallBackFunctions) + { + + auto current_process = std::static_pointer_cast(pRiverBoundary); + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "River boundary name: " << current_process->GetName() << std::endl; + + current_process->SetReferenceCoord(rCriticalHeadInfo.minCriticalHead); + mCurrentHead = rCriticalHeadInfo.minCriticalHead; + mCriticalHead = mCurrentHead; + + std::vector pipe_elements; + pipe_elements = pSolvingStrategy->GetPipingElements(); + const auto noPipeElements = pipe_elements.size(); + + int step = 1; + const auto max_steps = static_cast(std::ceil((rCriticalHeadInfo.maxCriticalHead - rCriticalHeadInfo.minCriticalHead) / rCriticalHeadInfo.stepCriticalHead)) + 2; + + while (!AreExceedingMaxCriticalHead(mCurrentHead, rCriticalHeadInfo.maxCriticalHead)) + { + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Searching at head: " << mCurrentHead << std::endl; + + std::ostringstream current_head_stream; + current_head_stream << std::setprecision(8) << std::noshowpoint << mCurrentHead; + std::string current_head_string = current_head_stream.str(); + + std::string progress = "Calculating head level " + current_head_string + "m (" + std::to_string(step) + "/" + std::to_string(max_steps) + ")"; + rCallBackFunctions.ReportTextualProgress(progress.data()); + rCallBackFunctions.ReportProgress(((double)step) / ((double)max_steps)); + + MainExecution(rModelPart, pSolvingStrategy, 0.0, 1.0, 1); + + auto count = std::size_t{0}; + for (Element *element : pipe_elements) + { + if (element->GetValue(PIPE_ACTIVE)) + count += 1; + } + + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Open pipe elements: " << count << std::endl; + + if (count == noPipeElements) + { + HandleCriticalHeadFound(rCriticalHeadInfo); + break; + } + + GeoOutputWriter writer{rGidOutputSettings, mWorkingDirectory, rModelPart}; + writer.WriteGiDOutput(rModelPart, rGidOutputSettings); + + // Update boundary conditions for next search head. + if (pRiverBoundary->Info() == "ApplyConstantScalarValueProcess") + { + ResetModelParts(); + KRATOS_ERROR << "ApplyConstantScalarValueProcess process search is not implemented."; + } + + if (pRiverBoundary->Info() == "ApplyConstantHydrostaticPressureProcess") + { + mCriticalHead = current_process->GetReferenceCoord(); + mCurrentHead = mCriticalHead + rCriticalHeadInfo.stepCriticalHead; + current_process->SetReferenceCoord(mCurrentHead); + step++; + } + + if (rCallBackFunctions.ShouldCancel()) + { + HandleCleanUp(rCallBackFunctions, pOutput); + + return 0; + } + } + return 0; + } + + void KratosExecute::HandleCriticalHeadFound(const CriticalHeadInfo& rCriticalHeadInfo) + { + if (std::abs(mCurrentHead - rCriticalHeadInfo.minCriticalHead) < 1e-9) + { + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head undetermined: All pipe elements open at initial search value :" << rCriticalHeadInfo.minCriticalHead << std::endl; + } + else + { + mPipingSuccess = true; + KRATOS_INFO_IF("GeoFlowKernel", this->GetEchoLevel() > 0) << "Critical head found: " << mCriticalHead << std::endl; } } - shared_ptr KratosExecute::FindRiverBoundaryByName(const std::string& rCriticalHeadBoundaryModelPartName, - const std::vector>& rProcesses) + void KratosExecute::HandleCleanUp(const CallBackFunctions& rCallBackFunctions, + LoggerOutput::Pointer pOutput) { - shared_ptr RiverBoundary; + std::stringstream kratos_log_buffer; - for (const auto& process : rProcesses) + rCallBackFunctions.LogCallback(kratos_log_buffer.str().c_str()); + Logger::RemoveOutput(pOutput); + ResetModelParts(); + } + + bool KratosExecute::AreExceedingMaxCriticalHead(double CurrentHead, + double MaxCriticalHead) const + { + const auto result = (CurrentHead > MaxCriticalHead + 1e-9); + KRATOS_INFO_IF("GeoFlowKernel", result && (this->GetEchoLevel() > 0)) << "Critical head undetermined at " << CurrentHead << ", max search head reached: " << MaxCriticalHead << std::endl; + return result; + } + + shared_ptr KratosExecute::FindRiverBoundaryByName(const std::string& CriticalHeadBoundaryModelPartName) const + { + shared_ptr p_river_boundary; + + for (const auto& process : mProcesses) { if (process->Info() == "ApplyConstantHydrostaticPressureProcess") { auto current_process = std::static_pointer_cast(process); if (current_process->hasWaterPressure() && - (current_process->GetName() == rCriticalHeadBoundaryModelPartName)) + (current_process->GetName() == CriticalHeadBoundaryModelPartName)) { - RiverBoundary = current_process; + p_river_boundary = current_process; } } } - if (!RiverBoundary) - { - std::cerr << "No boundary found with the model part name " << rCriticalHeadBoundaryModelPartName << "." << std::endl; - return nullptr; - } + KRATOS_ERROR_IF_NOT(p_river_boundary) << "No boundary found with the model part name " << CriticalHeadBoundaryModelPartName << "." << std::endl; - return RiverBoundary; + return p_river_boundary; } - shared_ptr KratosExecute::FindRiverBoundaryAutomatically(const KratosExecute::GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer& rpSolvingStrategy, - const std::vector>& rProcesses) + shared_ptr KratosExecute::FindRiverBoundaryAutomatically(const KratosExecute::GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer rpSolvingStrategy) const { - shared_ptr RiverBoundary; + shared_ptr p_river_boundary; - std::vector pipeElements; - pipeElements = rpSolvingStrategy->GetPipingElements(); + std::vector pipe_elements; + pipe_elements = rpSolvingStrategy->GetPipingElements(); - double firstNode_A = pipeElements.front()->GetGeometry().GetPoint(0).X0(); - double firstNode_B = pipeElements.front()->GetGeometry().GetPoint(1).X0(); - double lastNode_A = pipeElements.back()->GetGeometry().GetPoint(0).X0(); + double firstNode_A = pipe_elements.front()->GetGeometry().GetPoint(0).X0(); + double firstNode_B = pipe_elements.front()->GetGeometry().GetPoint(1).X0(); + double lastNode_A = pipe_elements.back()->GetGeometry().GetPoint(0).X0(); IndexType RiverNode; if ((firstNode_A < lastNode_A) && (firstNode_A < firstNode_B)) { - RiverNode = pipeElements.back()->GetGeometry().GetPoint(1).Id(); + RiverNode = pipe_elements.back()->GetGeometry().GetPoint(1).Id(); } else { - RiverNode = pipeElements.back()->GetGeometry().GetPoint(0).Id(); + RiverNode = pipe_elements.back()->GetGeometry().GetPoint(0).Id(); } // Get Find boundary in Processes - for (const auto& process : rProcesses) + for (const auto& process : mProcesses) { - ModelPart *currentModelPart; + ModelPart *currentModelPart = nullptr; if (process->Info() == "ApplyConstantScalarValueProcess") { auto current_process = std::static_pointer_cast(process); + currentModelPart = ¤t_process->GetModelPart(); if (current_process->hasWaterPressure()) { - currentModelPart = ¤t_process->GetModelPart(); - try - { - currentModelPart->GetNode(RiverNode); - RiverBoundary = current_process; - } - catch (...) - { - } + currentModelPart->GetNode(RiverNode); + p_river_boundary = current_process; } } else if (process->Info() == "ApplyConstantHydrostaticPressureProcess") @@ -623,24 +656,15 @@ namespace Kratos currentModelPart = ¤t_process->GetModelPart(); if (current_process->hasWaterPressure()) { - try - { - currentModelPart->GetNode(RiverNode); - RiverBoundary = current_process; - } - catch (...) - { - } + currentModelPart->GetNode(RiverNode); + p_river_boundary = current_process; } } } - if (!RiverBoundary) - { - std::cerr << "No boundary found on the river side at node " << RiverNode << "." << std::endl; - return nullptr; - } + KRATOS_ERROR_IF_NOT(p_river_boundary) << "No boundary found on the river side at node " << RiverNode << "." << std::endl; - return RiverBoundary; + return p_river_boundary; } + } diff --git a/applications/GeoMechanicsApplication/custom_workflows/dgeoflow.h b/applications/GeoMechanicsApplication/custom_workflows/dgeoflow.h index 3543473fe873..0fed3fdd1b6f 100644 --- a/applications/GeoMechanicsApplication/custom_workflows/dgeoflow.h +++ b/applications/GeoMechanicsApplication/custom_workflows/dgeoflow.h @@ -46,75 +46,130 @@ namespace Kratos { + class KRATOS_API(GEO_MECHANICS_APPLICATION) KratosExecute { public: KratosExecute(); - int ExecuteFlowAnalysis(const std::string& rWorkingDirectory, - const std::string& rProjectParamsFileName, - double minCriticalHead, - double maxCriticalHead, - double stepCriticalHead, - const std::string& rCriticalHeadBoundaryModelPartName, - const std::function& rLogCallback, - const std::function& rReportProgress, - const std::function& rReportTextualProgress, - const std::function& rShouldCancel); - - typedef Node NodeType; - typedef Geometry GeometryType; - typedef UblasSpace SparseSpaceType; - typedef UblasSpace LocalSpaceType; + using NodeType = Node; + using SparseSpaceType = UblasSpace; + using LocalSpaceType = UblasSpace; // The direct solver - typedef LinearSolver LinearSolverType; - typedef SkylineLUFactorizationSolver SkylineLUFactorizationSolverType; + using LinearSolverType = LinearSolver; + using SkylineLUFactorizationSolverType = SkylineLUFactorizationSolver; // The convergence criteria type - typedef ConvergenceCriteria ConvergenceCriteriaType; - typedef MixedGenericCriteria MixedGenericCriteriaType; - typedef typename MixedGenericCriteriaType::ConvergenceVariableListType ConvergenceVariableListType; + using ConvergenceCriteriaType = ConvergenceCriteria; + using MixedGenericCriteriaType = MixedGenericCriteria; + using ConvergenceVariableListType = typename MixedGenericCriteriaType::ConvergenceVariableListType; - typedef GeoMechanicsNewtonRaphsonErosionProcessStrategy - GeoMechanicsNewtonRaphsonErosionProcessStrategyType; + using GeoMechanicsNewtonRaphsonErosionProcessStrategyType = + GeoMechanicsNewtonRaphsonErosionProcessStrategy; // Dof arrays - typedef SetIdentityFunction> result_type; - typedef PointerVectorSet, SetIdentityFunction>, std::less, - std::equal_to, Dof *> - DofsArrayType; + using result_type = SetIdentityFunction>; + static ConvergenceCriteriaType::Pointer setup_criteria_dgeoflow(); static LinearSolverType::Pointer setup_solver_dgeoflow(); - static GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer setup_strategy_dgeoflow(ModelPart &model_part); - static std::vector> parseProcess(ModelPart &model_part, Parameters projFile); + static GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer setup_strategy_dgeoflow(ModelPart& rModelPart); + void ParseProcesses(ModelPart& rModelPart, Parameters projFile); + + + struct CriticalHeadInfo + { + double minCriticalHead = 0.0; + double maxCriticalHead = 0.0; + double stepCriticalHead = 0.0; + + CriticalHeadInfo(double minCriticalHead, double maxCriticalHead, double stepCriticalHead) : + minCriticalHead(minCriticalHead), maxCriticalHead(maxCriticalHead), stepCriticalHead(stepCriticalHead) + {} + }; + + struct CallBackFunctions + { + std::function LogCallback; + std::function ReportProgress; + std::function ReportTextualProgress; + std::function ShouldCancel; + + CallBackFunctions(std::function LogCallback, + std::function ReportProgress, + std::function ReportTextualProgress, + std::function ShouldCancel) : + LogCallback(std::move(LogCallback)), ReportProgress(std::move(ReportProgress)), ReportTextualProgress(std::move(ReportTextualProgress)), + ShouldCancel(std::move(ShouldCancel)) + {} + }; + + int ExecuteFlowAnalysis(std::string_view WorkingDirectory, + const std::string& rProjectParamsFileName, + const CriticalHeadInfo& rCriticalHeadInfo, + std::string_view CriticalHeadBoundaryModelPartName, + const CallBackFunctions& rCallBackFunctions); + + void ExecuteWithoutPiping(ModelPart& rModelPart, + const Kratos::Parameters& rGidOutputSettings, + const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer pSolvingStrategy) const; + + int ExecuteWithPiping(ModelPart& rModelPart, + const Kratos::Parameters& rGidOutputSettings, + const CriticalHeadInfo& rCriticalHeadInfo, + LoggerOutput::Pointer pOutput, + const CallBackFunctions& rCallBackFunctions, + const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer pSolvingStrategy); + + void WriteCriticalHeadResultToFile() const; + + void AddNodalSolutionStepVariables(ModelPart& rModelPart) const; + + int FindCriticalHead(ModelPart& rModelPart, + const Kratos::Parameters& rGidOutputSettings, + const CriticalHeadInfo& rCriticalHeadInfo, + LoggerOutput::Pointer pOutput, + const shared_ptr& pRiverBoundary, + const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer pSolvingStrategy, + const CallBackFunctions& rCallBackFunctions); + + void HandleCriticalHeadFound(const CriticalHeadInfo& rCriticalHeadInfo); + + void HandleCleanUp(const CallBackFunctions& rCallBackFunctions, + LoggerOutput::Pointer pOutput); + private: // Initial Setup - Model current_model; - Kernel kernel; - KratosGeoMechanicsApplication::Pointer geoApp; - - void ResetModelParts(); + Model mCurrentModel; + Kernel mKernel; + KratosGeoMechanicsApplication::Pointer mpGeoApp; + std::string mWorkingDirectory; + std::string mCriticalHeadBoundaryModelPartName; + bool mPipingSuccess = false; + double mCriticalHead = 0.0; + double mCurrentHead = 0.0; + std::vector> mProcesses; + int mEchoLevel = 1; - int echoLevel = 1; + void ResetModelParts(); [[nodiscard]] int GetEchoLevel() const; void SetEchoLevel(int level); - static shared_ptr FindRiverBoundaryByName(const std::string& rCriticalHeadBoundaryModelPartName, - const std::vector>& rProcesses); + shared_ptr FindRiverBoundaryByName(const std::string& CriticalHeadBoundaryModelPartName) const; + + shared_ptr FindRiverBoundaryAutomatically(const KratosExecute::GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer rpSolvingStrategy) const; - static shared_ptr FindRiverBoundaryAutomatically(const KratosExecute::GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer& rpSolvingStrategy, - const std::vector>& rProcesses); + int MainExecution(ModelPart& rModelPart, + const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer rpSolvingStrategy, + double Time, + double DeltaTime, + unsigned int NumberOfIterations) const; - static int MainExecution(ModelPart& rModelPart, - const std::vector>& rProcesses, - const GeoMechanicsNewtonRaphsonErosionProcessStrategyType::Pointer& rpSolvingStrategy, - double Time, - double DeltaTime, - unsigned int NumberOfIterations); + bool AreExceedingMaxCriticalHead(double CurrentHead, + double MaxCriticalHead) const; }; } \ No newline at end of file diff --git a/applications/GeoMechanicsApplication/external_bindings/kratos_external_bindings.cpp b/applications/GeoMechanicsApplication/external_bindings/kratos_external_bindings.cpp index fe491463d27a..321c4c5389c0 100644 --- a/applications/GeoMechanicsApplication/external_bindings/kratos_external_bindings.cpp +++ b/applications/GeoMechanicsApplication/external_bindings/kratos_external_bindings.cpp @@ -24,17 +24,17 @@ extern "C" void __stdcall reportTextualProgress(const char*), bool __stdcall shouldCancel()) { - int errorCode = instance->ExecuteFlowAnalysis(workingDirectory, + const Kratos::KratosExecute::CriticalHeadInfo critical_head_info(minCriticalHead, maxCriticalHead, stepCriticalHead); + const Kratos::KratosExecute::CallBackFunctions call_back_functions(logCallback, + reportProgress, + reportTextualProgress, + shouldCancel); + + return instance->ExecuteFlowAnalysis(workingDirectory, projectFile, - minCriticalHead, - maxCriticalHead, - stepCriticalHead, + critical_head_info, criticalHeadBoundaryModelPartName, - logCallback, - reportProgress, - reportTextualProgress, - shouldCancel); - return errorCode; + call_back_functions); } EXPORT Kratos::KratosGeoSettlement* KratosGeoSettlement_CreateInstance() diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_GeoMechanicsNewtonRaphsonErosionProcessStrategy.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_GeoMechanicsNewtonRaphsonErosionProcessStrategy.cpp index 3600560171f7..36c5fecd8281 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_GeoMechanicsNewtonRaphsonErosionProcessStrategy.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_GeoMechanicsNewtonRaphsonErosionProcessStrategy.cpp @@ -34,9 +34,14 @@ KRATOS_TEST_CASE_IN_SUITE(ErosionProcessStrategy, KratosGeoMechanicsIntegrationS auto projectFile = "ProjectParameters.json"; auto execute = KratosExecute(); - int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, 3, 4, 0.1, "PorousDomain.Left_head", - &flow_stubs::emptyLog, &flow_stubs::emptyProgress, - &flow_stubs::emptyLog, &flow_stubs::emptyCancel); + const Kratos::KratosExecute::CriticalHeadInfo critical_head_info(3, 4, 0.1); + const Kratos::KratosExecute::CallBackFunctions call_back_functions(&flow_stubs::emptyLog, + &flow_stubs::emptyProgress, + &flow_stubs::emptyLog, + &flow_stubs::emptyCancel); + + const int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, critical_head_info, "PorousDomain.Left_head", call_back_functions); + KRATOS_EXPECT_EQ(status, 0); } @@ -66,9 +71,13 @@ KRATOS_TEST_CASE_IN_SUITE(ErosionProcessStrategyTextualProgressReport, KratosGeo } }; - int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, 3, 4, 0.1, "PorousDomain.Left_head", - &flow_stubs::emptyLog, &flow_stubs::emptyProgress, - reportTextualProgress, &flow_stubs::emptyCancel); + const Kratos::KratosExecute::CriticalHeadInfo critical_head_info(3, 4, 0.1); + const Kratos::KratosExecute::CallBackFunctions call_back_functions(&flow_stubs::emptyLog, + &flow_stubs::emptyProgress, + reportTextualProgress, + &flow_stubs::emptyCancel); + + const int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, critical_head_info, "PorousDomain.Left_head", call_back_functions); KRATOS_EXPECT_EQ(status, 0); KRATOS_EXPECT_EQ(firstMessageFound, true); @@ -101,9 +110,14 @@ KRATOS_TEST_CASE_IN_SUITE(ErosionProcessStrategyProgressReport, KratosGeoMechani } }; - int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, 3, 4, 0.1, "PorousDomain.Left_head", - &flow_stubs::emptyLog, reportProgress, &flow_stubs::emptyLog, - &flow_stubs::emptyCancel); + const Kratos::KratosExecute::CriticalHeadInfo critical_head_info(3, 4, 0.1); + const Kratos::KratosExecute::CallBackFunctions call_back_functions(&flow_stubs::emptyLog, + reportProgress, + &flow_stubs::emptyLog, + &flow_stubs::emptyCancel); + + const int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, critical_head_info, "PorousDomain.Left_head", call_back_functions); + KRATOS_EXPECT_EQ(status, 0); KRATOS_EXPECT_EQ(startProgressFound, true); diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_head_extrapolation_flow_workflow.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_head_extrapolation_flow_workflow.cpp index 75e07292fc88..abd680161467 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_head_extrapolation_flow_workflow.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_head_extrapolation_flow_workflow.cpp @@ -29,10 +29,14 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateExtrapolatedHeadFlow_1, KratosGeoMechanicsInt auto projectFile = "ProjectParameters_1.json"; auto execute = Kratos::KratosExecute(); - int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, - 0, 0, 0, - "", &flow_stubs::emptyLog, &flow_stubs::emptyProgress, - &flow_stubs::emptyLog, &flow_stubs::emptyCancel); + + const Kratos::KratosExecute::CriticalHeadInfo critical_head_info(0, 0, 0); + const Kratos::KratosExecute::CallBackFunctions call_back_functions(&flow_stubs::emptyLog, + &flow_stubs::emptyProgress, + &flow_stubs::emptyLog, + &flow_stubs::emptyCancel); + + const int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, critical_head_info, "", call_back_functions); KRATOS_EXPECT_EQ(status, 0); @@ -49,10 +53,14 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateExtrapolatedHeadFlow_1, KratosGeoMechanicsInt auto projectFile = "ProjectParameters_2.json"; auto execute = Kratos::KratosExecute(); - int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, - 0, 0, 0, - "", &flow_stubs::emptyLog, &flow_stubs::emptyProgress, - &flow_stubs::emptyLog, &flow_stubs::emptyCancel); + + const Kratos::KratosExecute::CriticalHeadInfo critical_head_info(0, 0, 0); + const Kratos::KratosExecute::CallBackFunctions call_back_functions(&flow_stubs::emptyLog, + &flow_stubs::emptyProgress, + &flow_stubs::emptyLog, + &flow_stubs::emptyCancel); + + const int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, critical_head_info, "", call_back_functions); KRATOS_EXPECT_EQ(status, 0); @@ -69,10 +77,14 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateExtrapolatedHeadFlow_3, KratosGeoMechanicsInt auto projectFile = "ProjectParameters_3.json"; auto execute = Kratos::KratosExecute(); - int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, - 0, 0, 0, - "", &flow_stubs::emptyLog, &flow_stubs::emptyProgress, - &flow_stubs::emptyLog, &flow_stubs::emptyCancel); + + const Kratos::KratosExecute::CriticalHeadInfo critical_head_info(0, 0, 0); + const Kratos::KratosExecute::CallBackFunctions call_back_functions(&flow_stubs::emptyLog, + &flow_stubs::emptyProgress, + &flow_stubs::emptyLog, + &flow_stubs::emptyCancel); + + const int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, critical_head_info, "", call_back_functions); KRATOS_EXPECT_EQ(status, 0); @@ -89,10 +101,14 @@ KRATOS_TEST_CASE_IN_SUITE(CalculateExtrapolatedHeadFlow_4, KratosGeoMechanicsInt auto projectFile = "ProjectParameters_4.json"; auto execute = Kratos::KratosExecute(); - int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, - 0, 0, 0, - "", &flow_stubs::emptyLog, &flow_stubs::emptyProgress, - &flow_stubs::emptyLog, &flow_stubs::emptyCancel); + + const Kratos::KratosExecute::CriticalHeadInfo critical_head_info(0, 0, 0); + const Kratos::KratosExecute::CallBackFunctions call_back_functions(&flow_stubs::emptyLog, + &flow_stubs::emptyProgress, + &flow_stubs::emptyLog, + &flow_stubs::emptyCancel); + + const int status = execute.ExecuteFlowAnalysis(workingDirectory, projectFile, critical_head_info, "", call_back_functions); KRATOS_EXPECT_EQ(status, 0);