Skip to content

Commit

Permalink
Merge branch 'import_media_to_BC' into 'master'
Browse files Browse the repository at this point in the history
[WellboreSimulator-part2] Import media into BC implementation.

See merge request ogs/ogs!4659
  • Loading branch information
endJunction committed Aug 15, 2023
2 parents 828e4e0 + 303e7a4 commit 25782d0
Show file tree
Hide file tree
Showing 28 changed files with 123 additions and 62 deletions.
6 changes: 6 additions & 0 deletions Applications/ApplicationsLib/ProjectData.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ class ProjectData final

MeshLib::Mesh* getMesh(std::string const& mesh_name) const;

std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
getMedia() const
{
return _media;
}

private:
/// Parses the process variables configuration and creates new variables for
/// each variable entry passing the corresponding subtree to the process
Expand Down
2 changes: 1 addition & 1 deletion Applications/ApplicationsLib/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void Simulation::initializeDataStructures(
INFO("Initialize processes.");
for (auto& p : project_data->getProcesses())
{
p->initialize();
p->initialize(project_data->getMedia());
}

// Check intermediately that config parsing went fine.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ void BoundaryConditionCollection::addBCsForProcessVariables(
std::vector<std::reference_wrapper<ProcessVariable>> const&
process_variables,
NumLib::LocalToGlobalIndexMap const& dof_table,
unsigned const integration_order, Process const& process)
unsigned const integration_order, Process const& process,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
for (int variable_id = 0;
variable_id < static_cast<int>(process_variables.size());
++variable_id)
{
ProcessVariable& pv = process_variables[variable_id];
auto bcs = pv.createBoundaryConditions(dof_table, variable_id,
integration_order, _parameters,
process, process_variables);
auto bcs = pv.createBoundaryConditions(
dof_table, variable_id, integration_order, _parameters, process,
process_variables, media);

std::move(bcs.begin(), bcs.end(),
std::back_inserter(_boundary_conditions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once

#include "BoundaryCondition.h"
#include "MaterialLib/MPL/Medium.h"
#include "NumLib/IndexValueVector.h"
#include "ProcessLib/ProcessVariable.h"

Expand Down Expand Up @@ -47,7 +48,9 @@ class BoundaryConditionCollection final
std::vector<std::reference_wrapper<ProcessVariable>> const&
process_variables,
NumLib::LocalToGlobalIndexMap const& dof_table,
unsigned const integration_order, Process const& process);
unsigned const integration_order, Process const& process,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media);

void addBoundaryCondition(std::unique_ptr<BoundaryCondition>&& bc)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ std::unique_ptr<BoundaryCondition> createBoundaryCondition(
const std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters,
const Process& process,
[[maybe_unused]] std::vector<std::reference_wrapper<ProcessVariable>> const&
all_process_variables_for_this_process)
all_process_variables_for_this_process,
std::map<int,
std::shared_ptr<MaterialPropertyLib::Medium>> const& /*media*/)
{
// Surface mesh and bulk mesh must have equal axial symmetry flags!
if (config.boundary_mesh.isAxiallySymmetric() !=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <memory>
#include <vector>

#include "MaterialLib/MPL/CreateMaterialSpatialDistributionMap.h"
namespace MeshLib
{
class Mesh;
Expand Down Expand Up @@ -41,6 +42,7 @@ std::unique_ptr<BoundaryCondition> createBoundaryCondition(
const std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters,
const Process& process,
std::vector<std::reference_wrapper<ProcessVariable>> const&
all_process_variables_for_this_process);
all_process_variables_for_this_process,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);

} // namespace ProcessLib
10 changes: 6 additions & 4 deletions ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,26 +258,28 @@ void HydroMechanicsProcess<DisplacementDim>::initializeConcreteProcess(
}

template <int DisplacementDim>
void HydroMechanicsProcess<DisplacementDim>::initializeBoundaryConditions()
void HydroMechanicsProcess<DisplacementDim>::initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
if (_process_data.isMonolithicSchemeUsed())
{
const int process_id_of_hydromechanics = 0;
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map, process_id_of_hydromechanics);
*_local_to_global_index_map, process_id_of_hydromechanics, media);
return;
}

// Staggered scheme:
// for the equations of pressure
const int hydraulic_process_id = 0;
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map_with_base_nodes, hydraulic_process_id);
*_local_to_global_index_map_with_base_nodes, hydraulic_process_id,
media);

// for the equations of deformation.
const int mechanical_process_id = 1;
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map, mechanical_process_id);
*_local_to_global_index_map, mechanical_process_id, media);
}

template <int DisplacementDim>
Expand Down
4 changes: 3 additions & 1 deletion ProcessLib/HydroMechanics/HydroMechanicsProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class HydroMechanicsProcess final : public Process
MeshLib::Mesh const& mesh,
unsigned const integration_order) override;

void initializeBoundaryConditions() override;
void initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media) override;

void assembleConcreteProcess(const double t, double const /*dt*/,
std::vector<GlobalVector*> const& x,
Expand Down
8 changes: 5 additions & 3 deletions ProcessLib/PhaseField/PhaseFieldProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,19 @@ void PhaseFieldProcess<DisplacementDim>::initializeConcreteProcess(
}

template <int DisplacementDim>
void PhaseFieldProcess<DisplacementDim>::initializeBoundaryConditions()
void PhaseFieldProcess<DisplacementDim>::initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
// Staggered scheme:
// for the equations of deformation.
const int mechanical_process_id = 0;
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map, mechanical_process_id);
*_local_to_global_index_map, mechanical_process_id, media);
// for the phase field
const int phasefield_process_id = 1;
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map_single_component, phasefield_process_id);
*_local_to_global_index_map_single_component, phasefield_process_id,
media);
}

template <int DisplacementDim>
Expand Down
4 changes: 3 additions & 1 deletion ProcessLib/PhaseField/PhaseFieldProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class PhaseFieldProcess final : public Process

void constructDofTable() override;

void initializeBoundaryConditions() override;
void initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media) override;

void initializeConcreteProcess(
NumLib::LocalToGlobalIndexMap const& dof_table,
Expand Down
15 changes: 9 additions & 6 deletions ProcessLib/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,22 @@ Process::Process(
}

void Process::initializeProcessBoundaryConditionsAndSourceTerms(
const NumLib::LocalToGlobalIndexMap& dof_table, const int process_id)
const NumLib::LocalToGlobalIndexMap& dof_table, const int process_id,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
auto const& per_process_variables = _process_variables[process_id];
auto& per_process_BCs = _boundary_conditions[process_id];

per_process_BCs.addBCsForProcessVariables(per_process_variables, dof_table,
_integration_order, *this);
_integration_order, *this, media);

auto& per_process_sts = _source_term_collections[process_id];
per_process_sts.addSourceTermsForProcessVariables(
per_process_variables, dof_table, _integration_order);
}

void Process::initializeBoundaryConditions()
void Process::initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
// The number of processes is identical to the size of _process_variables,
// the vector contains variables for different processes. See the
Expand All @@ -90,11 +92,12 @@ void Process::initializeBoundaryConditions()
for (std::size_t pcs_id = 0; pcs_id < number_of_processes; pcs_id++)
{
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map, pcs_id);
*_local_to_global_index_map, pcs_id, media);
}
}

void Process::initialize()
void Process::initialize(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
DBUG("Initialize process.");

Expand All @@ -111,7 +114,7 @@ void Process::initialize()
_integration_order);

DBUG("Initialize boundary conditions.");
initializeBoundaryConditions();
initializeBoundaryConditions(media);
}

void Process::setInitialConditions(
Expand Down
13 changes: 10 additions & 3 deletions ProcessLib/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <tuple>

#include "AbstractJacobianAssembler.h"
#include "MaterialLib/MPL/Medium.h"
#include "MathLib/LinAlg/GlobalMatrixVectorTypes.h"
#include "MeshLib/Utils/IntegrationPointWriter.h"
#include "NumLib/ODESolver/NonlinearSolver.h"
Expand Down Expand Up @@ -87,7 +88,9 @@ class Process

NumLib::IterationResult postIteration(GlobalVector const& x) final;

void initialize();
void initialize(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media);

void setInitialConditions(
std::vector<GlobalVector*>& process_solutions,
Expand Down Expand Up @@ -205,7 +208,9 @@ class Process
* initializeBoundaryConditions().
*/
void initializeProcessBoundaryConditionsAndSourceTerms(
const NumLib::LocalToGlobalIndexMap& dof_table, const int process_id);
const NumLib::LocalToGlobalIndexMap& dof_table, const int process_id,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media);

private:
/// Process specific initialization called by initialize().
Expand All @@ -216,7 +221,9 @@ class Process

/// Member function to initialize the boundary conditions for all coupled
/// processes. It is called by initialize().
virtual void initializeBoundaryConditions();
virtual void initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media);

virtual void setInitialConditionsConcreteProcess(
std::vector<GlobalVector*>& /*x*/,
Expand Down
5 changes: 3 additions & 2 deletions ProcessLib/ProcessVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ ProcessVariable::createBoundaryConditions(
std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
Process const& process,
std::vector<std::reference_wrapper<ProcessVariable>> const&
all_process_variables_for_this_process)
all_process_variables_for_this_process,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
std::vector<std::unique_ptr<BoundaryCondition>> bcs;
bcs.reserve(_bc_configs.size());
Expand All @@ -235,7 +236,7 @@ ProcessVariable::createBoundaryConditions(
auto bc = createBoundaryCondition(
config, dof_table, _mesh, variable_id, integration_order,
_shapefunction_order, parameters, process,
all_process_variables_for_this_process);
all_process_variables_for_this_process, media);
#ifdef USE_PETSC
if (bc == nullptr)
{
Expand Down
5 changes: 4 additions & 1 deletion ProcessLib/ProcessVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <vector>

#include "BaseLib/ConfigTree-fwd.h"
#include "MaterialLib/MPL/Medium.h"

namespace MathLib
{
Expand Down Expand Up @@ -98,7 +99,9 @@ class ProcessVariable
parameters,
Process const& process,
std::vector<std::reference_wrapper<ProcessVariable>> const&
all_process_variables_for_this_process);
all_process_variables_for_this_process,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media);

std::vector<std::unique_ptr<SourceTerm>> createSourceTerms(
const NumLib::LocalToGlobalIndexMap& dof_table, const int variable_id,
Expand Down
10 changes: 6 additions & 4 deletions ProcessLib/RichardsMechanics/RichardsMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,26 +290,28 @@ void RichardsMechanicsProcess<DisplacementDim>::initializeConcreteProcess(
}

template <int DisplacementDim>
void RichardsMechanicsProcess<DisplacementDim>::initializeBoundaryConditions()
void RichardsMechanicsProcess<DisplacementDim>::initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
if (_use_monolithic_scheme)
{
const int monolithic_process_id = 0;
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map, monolithic_process_id);
*_local_to_global_index_map, monolithic_process_id, media);
return;
}

// Staggered scheme:
// for the equations of pressure
const int hydraulic_process_id = 0;
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map_with_base_nodes, hydraulic_process_id);
*_local_to_global_index_map_with_base_nodes, hydraulic_process_id,
media);

// for the equations of deformation.
const int mechanical_process_id = 1;
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map, mechanical_process_id);
*_local_to_global_index_map, mechanical_process_id, media);
}

template <int DisplacementDim>
Expand Down
4 changes: 3 additions & 1 deletion ProcessLib/RichardsMechanics/RichardsMechanicsProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class RichardsMechanicsProcess final : public Process
MeshLib::Mesh const& mesh,
unsigned const integration_order) override;

void initializeBoundaryConditions() override;
void initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media) override;

void setInitialConditionsConcreteProcess(std::vector<GlobalVector*>& x,
double const t,
Expand Down
5 changes: 3 additions & 2 deletions ProcessLib/StokesFlow/StokesFlowProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ void StokesFlowProcess<GlobalDim>::initializeConcreteProcess(
}

template <int GlobalDim>
void StokesFlowProcess<GlobalDim>::initializeBoundaryConditions()
void StokesFlowProcess<GlobalDim>::initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
assert(_use_monolithic_scheme);
{
int const process_id = 0;
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map, process_id);
*_local_to_global_index_map, process_id, media);
}
}

Expand Down
4 changes: 3 additions & 1 deletion ProcessLib/StokesFlow/StokesFlowProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class StokesFlowProcess final : public Process
MeshLib::Mesh const& mesh,
unsigned const integration_order) override;

void initializeBoundaryConditions() override;
void initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media) override;

void assembleConcreteProcess(const double t, double const dt,
std::vector<GlobalVector*> const& x,
Expand Down
5 changes: 3 additions & 2 deletions ProcessLib/TH2M/TH2MProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,13 @@ void TH2MProcess<DisplacementDim>::initializeConcreteProcess(
}

template <int DisplacementDim>
void TH2MProcess<DisplacementDim>::initializeBoundaryConditions()
void TH2MProcess<DisplacementDim>::initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
{
if (_use_monolithic_scheme)
{
initializeProcessBoundaryConditionsAndSourceTerms(
*_local_to_global_index_map, monolithic_process_id);
*_local_to_global_index_map, monolithic_process_id, media);
return;
}

Expand Down
4 changes: 3 additions & 1 deletion ProcessLib/TH2M/TH2MProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class TH2MProcess final : public Process,
MeshLib::Mesh const& mesh,
unsigned const integration_order) override;

void initializeBoundaryConditions() override;
void initializeBoundaryConditions(
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
media) override;

void setInitialConditionsConcreteProcess(std::vector<GlobalVector*>& x,
double const t,
Expand Down
Loading

0 comments on commit 25782d0

Please sign in to comment.