Skip to content
Snippets Groups Projects
Commit 08f2f608 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[PL] TM: Move process implementation into cpp.

parent e13ab2d7
No related branches found
No related tags found
No related merge requests found
/**
* \file
*
* \copyright
* Copyright (c) 2012-2018, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include <cassert>
#include "BaseLib/Functional.h"
#include "ProcessLib/SmallDeformation/CreateLocalAssemblers.h"
#include "ThermoMechanicsFEM.h"
namespace ProcessLib
{
namespace ThermoMechanics
{
template <int DisplacementDim>
ThermoMechanicsProcess<DisplacementDim>::ThermoMechanicsProcess(
MeshLib::Mesh& mesh,
std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
unsigned const integration_order,
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
process_variables,
ThermoMechanicsProcessData<DisplacementDim>&& process_data,
SecondaryVariableCollection&& secondary_variables,
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),
use_monolithic_scheme),
_process_data(std::move(process_data))
{
}
template <int DisplacementDim>
bool ThermoMechanicsProcess<DisplacementDim>::isLinear() const
{
return false;
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::initializeConcreteProcess(
NumLib::LocalToGlobalIndexMap const& dof_table,
MeshLib::Mesh const& mesh,
unsigned const integration_order)
{
ProcessLib::SmallDeformation::createLocalAssemblers<
DisplacementDim, ThermoMechanicsLocalAssembler>(
mesh.getElements(), dof_table, _local_assemblers,
mesh.isAxiallySymmetric(), integration_order, _process_data);
// TODO move the two data members somewhere else.
// for extrapolation of secondary variables
std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
all_mesh_subsets_single_component.emplace_back(
_mesh_subset_all_nodes.get());
_local_to_global_index_map_single_component.reset(
new NumLib::LocalToGlobalIndexMap(
std::move(all_mesh_subsets_single_component),
// by location order is needed for output
NumLib::ComponentOrder::BY_LOCATION));
Base::_secondary_variables.addSecondaryVariable(
"sigma_xx",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaXX));
Base::_secondary_variables.addSecondaryVariable(
"sigma_yy",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaYY));
Base::_secondary_variables.addSecondaryVariable(
"sigma_zz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaZZ));
Base::_secondary_variables.addSecondaryVariable(
"sigma_xy",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaXY));
if (DisplacementDim == 3)
{
Base::_secondary_variables.addSecondaryVariable(
"sigma_xz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaXZ));
Base::_secondary_variables.addSecondaryVariable(
"sigma_yz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaYZ));
}
Base::_secondary_variables.addSecondaryVariable(
"epsilon_xx",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonXX));
Base::_secondary_variables.addSecondaryVariable(
"epsilon_yy",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonYY));
Base::_secondary_variables.addSecondaryVariable(
"epsilon_zz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonZZ));
Base::_secondary_variables.addSecondaryVariable(
"epsilon_xy",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonXY));
if (DisplacementDim == 3)
{
Base::_secondary_variables.addSecondaryVariable(
"epsilon_yz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonYZ));
Base::_secondary_variables.addSecondaryVariable(
"epsilon_xz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonXZ));
}
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::assembleConcreteProcess(
const double t, GlobalVector const& x, GlobalMatrix& M, GlobalMatrix& K,
GlobalVector& b)
{
DBUG("Assemble ThermoMechanicsProcess.");
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
dof_table, t, x, M, K, b, _coupled_solutions);
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::
assembleWithJacobianConcreteProcess(const double t, GlobalVector const& x,
GlobalVector const& xdot,
const double dxdot_dx,
const double dx_dx, GlobalMatrix& M,
GlobalMatrix& K, GlobalVector& b,
GlobalMatrix& Jac)
{
DBUG("AssembleJacobian ThermoMechanicsProcess.");
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assembleWithJacobian,
_local_assemblers, dof_table, t, x, xdot, dxdot_dx,
dx_dx, M, K, b, Jac, _coupled_solutions);
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::preTimestepConcreteProcess(
GlobalVector const& x, double const t, double const dt,
const int /*process_id*/)
{
DBUG("PreTimestep ThermoMechanicsProcess.");
_process_data.dt = dt;
_process_data.t = t;
GlobalExecutor::executeMemberOnDereferenced(
&ThermoMechanicsLocalAssemblerInterface::preTimestep, _local_assemblers,
*_local_to_global_index_map, x, t, dt);
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess(
GlobalVector const& x, int const /*process_id*/)
{
DBUG("PostTimestep ThermoMechanicsProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&ThermoMechanicsLocalAssemblerInterface::postTimestep,
_local_assemblers, *_local_to_global_index_map, x);
}
} // namespace ThermoMechanics
} // namespace ProcessLib
...@@ -8,12 +8,204 @@ ...@@ -8,12 +8,204 @@
*/ */
#include "ThermoMechanicsProcess.h" #include "ThermoMechanicsProcess.h"
#include "ThermoMechanicsProcess-impl.h"
#include <cassert>
#include "BaseLib/Functional.h"
#include "ProcessLib/SmallDeformation/CreateLocalAssemblers.h"
#include "ThermoMechanicsFEM.h"
namespace ProcessLib namespace ProcessLib
{ {
namespace ThermoMechanics namespace ThermoMechanics
{ {
template <int DisplacementDim>
ThermoMechanicsProcess<DisplacementDim>::ThermoMechanicsProcess(
MeshLib::Mesh& mesh,
std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
std::vector<std::unique_ptr<ParameterBase>> const& parameters,
unsigned const integration_order,
std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
process_variables,
ThermoMechanicsProcessData<DisplacementDim>&& process_data,
SecondaryVariableCollection&& secondary_variables,
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),
use_monolithic_scheme),
_process_data(std::move(process_data))
{
}
template <int DisplacementDim>
bool ThermoMechanicsProcess<DisplacementDim>::isLinear() const
{
return false;
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::initializeConcreteProcess(
NumLib::LocalToGlobalIndexMap const& dof_table,
MeshLib::Mesh const& mesh,
unsigned const integration_order)
{
ProcessLib::SmallDeformation::createLocalAssemblers<
DisplacementDim, ThermoMechanicsLocalAssembler>(
mesh.getElements(), dof_table, _local_assemblers,
mesh.isAxiallySymmetric(), integration_order, _process_data);
// TODO move the two data members somewhere else.
// for extrapolation of secondary variables
std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component;
all_mesh_subsets_single_component.emplace_back(
_mesh_subset_all_nodes.get());
_local_to_global_index_map_single_component.reset(
new NumLib::LocalToGlobalIndexMap(
std::move(all_mesh_subsets_single_component),
// by location order is needed for output
NumLib::ComponentOrder::BY_LOCATION));
Base::_secondary_variables.addSecondaryVariable(
"sigma_xx",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaXX));
Base::_secondary_variables.addSecondaryVariable(
"sigma_yy",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaYY));
Base::_secondary_variables.addSecondaryVariable(
"sigma_zz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaZZ));
Base::_secondary_variables.addSecondaryVariable(
"sigma_xy",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaXY));
if (DisplacementDim == 3)
{
Base::_secondary_variables.addSecondaryVariable(
"sigma_xz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaXZ));
Base::_secondary_variables.addSecondaryVariable(
"sigma_yz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtSigmaYZ));
}
Base::_secondary_variables.addSecondaryVariable(
"epsilon_xx",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonXX));
Base::_secondary_variables.addSecondaryVariable(
"epsilon_yy",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonYY));
Base::_secondary_variables.addSecondaryVariable(
"epsilon_zz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonZZ));
Base::_secondary_variables.addSecondaryVariable(
"epsilon_xy",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonXY));
if (DisplacementDim == 3)
{
Base::_secondary_variables.addSecondaryVariable(
"epsilon_yz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonYZ));
Base::_secondary_variables.addSecondaryVariable(
"epsilon_xz",
makeExtrapolator(
1, getExtrapolator(), _local_assemblers,
&ThermoMechanicsLocalAssemblerInterface::getIntPtEpsilonXZ));
}
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::assembleConcreteProcess(
const double t, GlobalVector const& x, GlobalMatrix& M, GlobalMatrix& K,
GlobalVector& b)
{
DBUG("Assemble ThermoMechanicsProcess.");
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
dof_table, t, x, M, K, b, _coupled_solutions);
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::
assembleWithJacobianConcreteProcess(const double t, GlobalVector const& x,
GlobalVector const& xdot,
const double dxdot_dx,
const double dx_dx, GlobalMatrix& M,
GlobalMatrix& K, GlobalVector& b,
GlobalMatrix& Jac)
{
DBUG("AssembleJacobian ThermoMechanicsProcess.");
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assembleWithJacobian,
_local_assemblers, dof_table, t, x, xdot, dxdot_dx,
dx_dx, M, K, b, Jac, _coupled_solutions);
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::preTimestepConcreteProcess(
GlobalVector const& x, double const t, double const dt,
const int /*process_id*/)
{
DBUG("PreTimestep ThermoMechanicsProcess.");
_process_data.dt = dt;
_process_data.t = t;
GlobalExecutor::executeMemberOnDereferenced(
&ThermoMechanicsLocalAssemblerInterface::preTimestep, _local_assemblers,
*_local_to_global_index_map, x, t, dt);
}
template <int DisplacementDim>
void ThermoMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess(
GlobalVector const& x, int const /*process_id*/)
{
DBUG("PostTimestep ThermoMechanicsProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&ThermoMechanicsLocalAssemblerInterface::postTimestep,
_local_assemblers, *_local_to_global_index_map, x);
}
template class ThermoMechanicsProcess<2>; template class ThermoMechanicsProcess<2>;
template class ThermoMechanicsProcess<3>; template class ThermoMechanicsProcess<3>;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment