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

New coupling assembly computations #1970

Merged
merged 25 commits into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e70228a
Added a boolean member to class Process to distinguish the monolithic…
wenqing Oct 10, 2017
d12f49c
[Coupling] Modified Process::constructDofTable() for the assembly of …
wenqing Oct 11, 2017
c2db4b3
[HT] Use the forward declaration of a class in HTProcess.h
wenqing Oct 11, 2017
58d5c91
[Coupling] Modified the process definitions in Process/HT for the ass…
wenqing Oct 11, 2017
8a8ff3e
[Couping] Modified the settings of IC for the staggered scheme
wenqing Oct 12, 2017
7baa747
[Coupling] Modified some members of Process for setting the coupled term
wenqing Oct 12, 2017
2ffa66c
[Coupling] Removed the coupled process members
wenqing Oct 12, 2017
6990343
[HT] Use the forward delaration of HTMaterialProperties
wenqing Oct 16, 2017
4c3bc22
[HT] Added two parameters of the solid thermal expansion in the flow …
wenqing Oct 16, 2017
90ef9f1
[Coupling] Added local assemblers to HT for the staggered scheme
wenqing Oct 13, 2017
0017c43
[HT] Set thermal dispersivity as an optional input
wenqing Oct 18, 2017
cba5e24
[HT] Moved the computation of the coefficients of the heat transport …
wenqing Oct 18, 2017
12519e6
[HT] Modified the velocity calculation in order that it can be used f…
wenqing Oct 18, 2017
fe86513
[HT] Removed an unused member, fluid_reference_density
wenqing Oct 18, 2017
f1ccca4
[Coupling] Removed the coupling calculation from the classes of singl…
wenqing Oct 18, 2017
e910a89
[Coupling] Modified outpout and initial condition members for the sta…
wenqing Oct 19, 2017
e1dad8c
[Coupling] Made CoupledSolutionsOfPreviousTimeStep be local accessibl…
wenqing Oct 20, 2017
6cf73d7
[HT] Added two boolean members to HTMaterialProperties
wenqing Oct 23, 2017
7b71f23
[PCS] Separate the process variables, BCs and STs by process in class…
wenqing Nov 13, 2017
ce79f15
[PCS] Changed the type of the process class member of process variables
wenqing Nov 10, 2017
6e00c5f
[PCS] Add an option to separate the process variables by process
wenqing Nov 13, 2017
3943c5b
[PCS] Changed process variable storage for single process classes
wenqing Nov 13, 2017
4c88ef1
[Test] Added a new test to solve the HT monolithic test with the stag…
wenqing Oct 25, 2017
e79b9a2
Code modernization by clang-tidy
wenqing Dec 4, 2017
42be673
Improvement in the coding according to Dima's comments
wenqing Dec 4, 2017
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
@@ -0,0 +1,2 @@
Parameters of solid thermal expansion in flow process.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Line thermal expansion of solid.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An optional input to select the coupling scheme. The variable is 'staggered'.
If this input is omitted, the coupling scheme is the monolithic scheme by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Optional input for thermal dispersion properties.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An optional input to select the coupling scheme. So far, only the monolithic
scheme is available for HYDRO_MECHANICS, and this input can be omitted.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An optional input to select the coupling scheme. So far, only the monolithic
scheme is available for HYDRO_MECHANICS_WITH_LIE, and this input can be omitted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An optional input to select the coupling scheme. So far, only the monolithic
scheme is available for PHASE_FIELD, and this input can be omitted.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
An optional input to select the coupling scheme. So far, only the monolithic
scheme is available for RichardsComponentTransport, and this input can be
omitted.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An optional input to select the coupling scheme. So far, only the monolithic
scheme is available for THERMO_MECHANICS, and this input can be omitted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion ProcessLib/AbstractJacobianAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class AbstractJacobianAssembler
//! \f$b\f$ with coupling.
virtual void assembleWithJacobianAndCoupling(
LocalAssemblerInterface& /*local_assembler*/, double const /*t*/,
std::vector<double> const& /*local_x*/,
std::vector<double> const& /*local_xdot*/, const double /*dxdot_dx*/,
const double /*dx_dx*/, std::vector<double>& /*local_M_data*/,
std::vector<double>& /*local_K_data*/,
Expand Down
14 changes: 11 additions & 3 deletions ProcessLib/ComponentTransport/ComponentTransportProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ ComponentTransportProcess::ComponentTransportProcess(
std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
unsigned const integration_order,
std::vector<std::reference_wrapper<ProcessVariable>>&& process_variables,
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
process_variables,
ComponentTransportProcessData&& process_data,
SecondaryVariableCollection&& secondary_variables,
NumLib::NamedFunctionCaller&& named_function_caller)
NumLib::NamedFunctionCaller&& named_function_caller,
bool const use_monolithic_scheme)
: Process(mesh, std::move(jacobian_assembler), parameters,
integration_order, std::move(process_variables),
std::move(secondary_variables), std::move(named_function_caller)),
std::move(secondary_variables), std::move(named_function_caller),
use_monolithic_scheme),
_process_data(std::move(process_data))
{
}
Expand Down Expand Up @@ -59,6 +62,8 @@ void ComponentTransportProcess::assembleConcreteProcess(
GlobalVector& b)
{
DBUG("Assemble ComponentTransportProcess.");
if (!_use_monolithic_scheme)
setCoupledSolutionsOfPreviousTimeStep();

// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberDereferenced(
Expand All @@ -73,6 +78,9 @@ void ComponentTransportProcess::assembleWithJacobianConcreteProcess(
{
DBUG("AssembleWithJacobian ComponentTransportProcess.");

if (!_use_monolithic_scheme)
setCoupledSolutionsOfPreviousTimeStep();

// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assembleWithJacobian,
Expand Down
5 changes: 3 additions & 2 deletions ProcessLib/ComponentTransport/ComponentTransportProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ class ComponentTransportProcess final : public Process
jacobian_assembler,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
unsigned const integration_order,
std::vector<std::reference_wrapper<ProcessVariable>>&&
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
process_variables,
ComponentTransportProcessData&& process_data,
SecondaryVariableCollection&& secondary_variables,
NumLib::NamedFunctionCaller&& named_function_caller);
NumLib::NamedFunctionCaller&& named_function_caller,
bool const use_monolithic_scheme);

//! \name ODESystem interface
//! @{
Expand Down
39 changes: 32 additions & 7 deletions ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,43 @@ std::unique_ptr<Process> createComponentTransportProcess(
config.checkConfigParameter("type", "ComponentTransport");

DBUG("Create ComponentTransportProcess.");
auto const staggered_scheme =
//! \ogs_file_param{prj__processes__process__coupling_scheme}
config.getConfigParameterOptional<std::string>("coupling_scheme");
const bool use_monolithic_scheme =
(staggered_scheme && (*staggered_scheme == "staggered")) ? false : true;

// Process variable.

//! \ogs_file_param{prj__processes__process__ComponentTransport__process_variables}
auto const pv_config = config.getConfigSubtree("process_variables");

auto process_variables = findProcessVariables(
variables, pv_config,
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
process_variables;
if (use_monolithic_scheme) // monolithic scheme.
{
auto per_process_variables = findProcessVariables(
variables, pv_config,
{
//! \ogs_file_param_special{prj__processes__process__ComponentTransport__process_variables__concentration}
"concentration",
//! \ogs_file_param_special{prj__processes__process__ComponentTransport__process_variables__pressure}
"pressure"});
process_variables.push_back(std::move(per_process_variables));
}
else // staggered scheme.
{
std::array<std::string, 2> variable_names = {
{"concentration",
"pressure"}}; // double-braces required in C++11 (not in C++14)

for (int i = 0; i < 2; i++)
{
//! \ogs_file_param_special{prj__processes__process__ComponentTransport__process_variables__concentration}
"concentration",
//! \ogs_file_param_special{prj__processes__process__ComponentTransport__process_variables__pressure}
"pressure"});
auto per_process_variables =
findProcessVariables(variables, pv_config, {variable_names[i]});
process_variables.push_back(std::move(per_process_variables));
Copy link
Member

@endJunction endJunction Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The for loop could be a for-range, because i is not used but to access the variable_names.
This should work w/o variable_names array:

using std::string_literals;
for (auto const& variable_name : {"concentration"s, "pressure"s}
{
   // ...
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed accordingly.

}
}

MaterialLib::PorousMedium::PorousMediaProperties porous_media_properties{
MaterialLib::PorousMedium::createPorousMediaProperties(
Expand Down Expand Up @@ -144,7 +168,8 @@ std::unique_ptr<Process> createComponentTransportProcess(
return std::make_unique<ComponentTransportProcess>(
mesh, std::move(jacobian_assembler), parameters, integration_order,
std::move(process_variables), std::move(process_data),
std::move(secondary_variables), std::move(named_function_caller));
std::move(secondary_variables), std::move(named_function_caller),
use_monolithic_scheme);
}

} // namespace ComponentTransport
Expand Down
56 changes: 26 additions & 30 deletions ProcessLib/CoupledSolutionsForStaggeredScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,44 @@
namespace ProcessLib
{
CoupledSolutionsForStaggeredScheme::CoupledSolutionsForStaggeredScheme(
std::unordered_map<std::type_index, Process const&> const&
coupled_processes_,
std::unordered_map<std::type_index, GlobalVector const&> const& coupled_xs_,
const double dt_)
: coupled_processes(coupled_processes_), coupled_xs(coupled_xs_), dt(dt_)
std::vector<std::reference_wrapper<GlobalVector const>> const& coupled_xs_,
const double dt_, const int process_id_)
: coupled_xs(coupled_xs_), dt(dt_), process_id(process_id_)
{
for (auto const& coupled_x_pair : coupled_xs)
for (auto const& coupled_x : coupled_xs)
{
auto const& coupled_x = coupled_x_pair.second;
MathLib::LinAlg::setLocalAccessibleVector(coupled_x);
MathLib::LinAlg::setLocalAccessibleVector(coupled_x.get());
}
}

std::vector<std::vector<double>> getPreviousLocalSolutions(
const CoupledSolutionsForStaggeredScheme& cpl_xs,
const std::vector<GlobalIndexType>& indices)
{
const auto number_of_coupled_solutions = cpl_xs.coupled_xs.size();
std::vector<std::vector<double>> local_xs_t0;
local_xs_t0.reserve(number_of_coupled_solutions);

for (auto const& coupled_process_pair : coupled_processes)
for (auto const& x_t0 : cpl_xs.coupled_xs_t0)
{
auto const& coupled_pcs = coupled_process_pair.second;
auto const prevous_time_x = coupled_pcs.getPreviousTimeStepSolution();
if (prevous_time_x)
{
MathLib::LinAlg::setLocalAccessibleVector(*prevous_time_x);
}
local_xs_t0.emplace_back(x_t0->get(indices));
}
return local_xs_t0;
}

std::unordered_map<std::type_index, const std::vector<double>>
getCurrentLocalSolutionsOfCoupledProcesses(
const std::unordered_map<std::type_index, GlobalVector const&>&
global_coupled_xs,
std::vector<std::vector<double>> getCurrentLocalSolutions(
const CoupledSolutionsForStaggeredScheme& cpl_xs,
const std::vector<GlobalIndexType>& indices)
{
std::unordered_map<std::type_index, const std::vector<double>>
local_coupled_xs;
const auto number_of_coupled_solutions = cpl_xs.coupled_xs.size();
std::vector<std::vector<double>> local_xs_t1;
local_xs_t1.reserve(number_of_coupled_solutions);

// Get local nodal solutions of the coupled equations.
for (auto const& global_coupled_x_pair : global_coupled_xs)
for (auto const& x_t1 : cpl_xs.coupled_xs)
{
auto const& coupled_x = global_coupled_x_pair.second;
auto const local_coupled_x = coupled_x.get(indices);
BaseLib::insertIfTypeIndexKeyUniqueElseError(
local_coupled_xs, global_coupled_x_pair.first, local_coupled_x,
"local_coupled_x");
local_xs_t1.emplace_back(x_t1.get().get(indices));
}
return local_coupled_xs;
return local_xs_t1;
}

} // end of ProcessLib
} // namespace ProcessLib
69 changes: 27 additions & 42 deletions ProcessLib/CoupledSolutionsForStaggeredScheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@

#pragma once

#include <unordered_map>
#include <typeindex>
#include <functional>
#include <utility>
#include <vector>

#include "MathLib/LinAlg/GlobalMatrixVectorTypes.h"

namespace ProcessLib
{
class Process;

/**
* A struct to keep the references of the coupled processes and the references
* of the current solutions of the equations of the coupled processes.
* A struct to keep the references of the current solutions of the equations of
* the coupled processes.
*
* During staggered coupling iteration, an instance of this struct is created
* and passed through interfaces to global and local assemblers for each
Expand All @@ -32,68 +31,54 @@ class Process;
struct CoupledSolutionsForStaggeredScheme
{
CoupledSolutionsForStaggeredScheme(
std::unordered_map<std::type_index, Process const&> const&
coupled_processes_,
std::unordered_map<std::type_index, GlobalVector const&> const&
std::vector<std::reference_wrapper<GlobalVector const>> const&
coupled_xs_,
const double dt_);

/// References to the coupled processes are distinguished by the keys of
/// process types.
std::unordered_map<std::type_index, Process const&> const&
coupled_processes;
const double dt_, const int process_id_);

/// References to the current solutions of the coupled processes.
/// The coupled solutions are distinguished by the keys of process types.
std::unordered_map<std::type_index, GlobalVector const&> const& coupled_xs;
std::vector<std::reference_wrapper<GlobalVector const>> const& coupled_xs;

/// Pointers to the vector of the solutions of the previous time step.
std::vector<GlobalVector*> coupled_xs_t0;

const double dt; ///< Time step size.
const int process_id;
};

/**
* A struct to keep the references of the coupled processes, and local element
* solutions of the current and previous time step solutions of the equations
* of the coupled processes.
* A struct to keep the references to the local element solutions of the
* current and previous time step solutions of the equations of the coupled
* processes.
*
* During the global assembly loop, an instance of this struct is created for
* each element and it is then passed to local assemblers.
*/
struct LocalCoupledSolutions
{
LocalCoupledSolutions(
const double dt_,
std::unordered_map<std::type_index, Process const&> const&
coupled_processes_,
std::unordered_map<std::type_index, const std::vector<double>>&&
local_coupled_xs0_,
std::unordered_map<std::type_index, const std::vector<double>>&&
local_coupled_xs_)
LocalCoupledSolutions(const double dt_, const int process_id_,
std::vector<std::vector<double>>&& local_coupled_xs0_,
std::vector<std::vector<double>>&& local_coupled_xs_)
: dt(dt_),
coupled_processes(coupled_processes_),
process_id(process_id_),
local_coupled_xs0(std::move(local_coupled_xs0_)),
local_coupled_xs(std::move(local_coupled_xs_))
{
}

const double dt; ///< Time step size.

/// References to the coupled processes are distinguished by the keys of
/// process types.
std::unordered_map<std::type_index, Process const&> const&
coupled_processes;
const int process_id;

/// Local solutions of the previous time step.
std::unordered_map<std::type_index, const std::vector<double>> const
local_coupled_xs0;
std::vector<std::vector<double>> const local_coupled_xs0;
/// Local solutions of the current time step.
std::unordered_map<std::type_index, const std::vector<double>> const
local_coupled_xs;
std::vector<std::vector<double>> const local_coupled_xs;
};

std::unordered_map<std::type_index, const std::vector<double>>
getCurrentLocalSolutionsOfCoupledProcesses(
const std::unordered_map<std::type_index, GlobalVector const&>&
global_coupled_xs,
std::vector<std::vector<double>> getPreviousLocalSolutions(
const CoupledSolutionsForStaggeredScheme& cpl_xs,
const std::vector<GlobalIndexType>& indices);

std::vector<std::vector<double>> getCurrentLocalSolutions(
const CoupledSolutionsForStaggeredScheme& cpl_xs,
const std::vector<GlobalIndexType>& indices);
} // end of ProcessLib
5 changes: 4 additions & 1 deletion ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ std::unique_ptr<Process> createGroundwaterFlowProcess(
//! \ogs_file_param{prj__processes__process__GROUNDWATER_FLOW__process_variables}
auto const pv_config = config.getConfigSubtree("process_variables");

auto process_variables = findProcessVariables(
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
process_variables;
auto per_process_variables = findProcessVariables(
variables, pv_config,
{//! \ogs_file_param_special{prj__processes__process__GROUNDWATER_FLOW__process_variables__process_variable}
"process_variable"});
process_variables.push_back(std::move(per_process_variables));

// Hydraulic conductivity parameter.
auto& hydraulic_conductivity = findParameter<double>(
Expand Down
3 changes: 2 additions & 1 deletion ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ GroundwaterFlowProcess::GroundwaterFlowProcess(
std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
unsigned const integration_order,
std::vector<std::reference_wrapper<ProcessVariable>>&& process_variables,
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
process_variables,
GroundwaterFlowProcessData&& process_data,
SecondaryVariableCollection&& secondary_variables,
NumLib::NamedFunctionCaller&& named_function_caller,
Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GroundwaterFlowProcess final : public Process
jacobian_assembler,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
unsigned const integration_order,
std::vector<std::reference_wrapper<ProcessVariable>>&&
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
process_variables,
GroundwaterFlowProcessData&& process_data,
SecondaryVariableCollection&& secondary_variables,
Expand Down
Loading