OGS
ProcessLib::SmallDeformation Namespace Reference

Namespaces

 detail
 

Classes

struct  MaterialForcesInterface
 
struct  SmallDeformationLocalAssemblerInterface
 
struct  IntegrationPointData
 
struct  SecondaryData
 
class  SmallDeformationLocalAssembler
 
class  SmallDeformationProcess
 
struct  SmallDeformationProcessData
 

Functions

template<int DisplacementDim, typename ShapeFunction , typename ShapeMatricesType , typename NodalForceVectorType , typename NodalDisplacementVectorType , typename GradientVectorType , typename GradientMatrixType , typename IPData , typename IntegrationMethod >
std::vector< double > const & getMaterialForces (std::vector< double > const &local_x, std::vector< double > &nodal_values, IntegrationMethod const &_integration_method, IPData const &_ip_data, MeshLib::Element const &element, bool const is_axially_symmetric)
 
template<typename LocalAssemblerInterface >
void writeMaterialForces (std::unique_ptr< GlobalVector > &material_forces, std::vector< std::unique_ptr< LocalAssemblerInterface >> const &local_assemblers, NumLib::LocalToGlobalIndexMap const &local_to_global_index_map, GlobalVector const &x)
 
template<int GlobalDim, template< typename, typename, int > class LocalAssemblerImplementation, typename LocalAssemblerInterface , typename... ExtraCtorArgs>
void createLocalAssemblers (std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< std::unique_ptr< LocalAssemblerInterface >> &local_assemblers, ExtraCtorArgs &&... extra_ctor_args)
 
template<int DisplacementDim>
std::unique_ptr< ProcesscreateSmallDeformationProcess (std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
 
template std::unique_ptr< ProcesscreateSmallDeformationProcess< 2 > (std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
 
template std::unique_ptr< ProcesscreateSmallDeformationProcess< 3 > (std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
 

Function Documentation

◆ createLocalAssemblers()

template<int GlobalDim, template< typename, typename, int > class LocalAssemblerImplementation, typename LocalAssemblerInterface , typename... ExtraCtorArgs>
void ProcessLib::SmallDeformation::createLocalAssemblers ( std::vector< MeshLib::Element * > const &  mesh_elements,
NumLib::LocalToGlobalIndexMap const &  dof_table,
std::vector< std::unique_ptr< LocalAssemblerInterface >> &  local_assemblers,
ExtraCtorArgs &&...  extra_ctor_args 
)

Creates local assemblers for each element of the given mesh.

Template Parameters
LocalAssemblerImplementationthe individual local assembler type
LocalAssemblerInterfacethe general local assembler interface
ExtraCtorArgstypes of additional constructor arguments. Those arguments will be passed to the constructor of LocalAssemblerImplementation.

The first two template parameters cannot be deduced from the arguments. Therefore they always have to be provided manually.

Definition at line 67 of file CreateLocalAssemblers.h.

72 {
73  DBUG("Create local assemblers.");
74 
75  detail::createLocalAssemblers<GlobalDim, LocalAssemblerImplementation>(
76  dof_table, mesh_elements, local_assemblers,
77  std::forward<ExtraCtorArgs>(extra_ctor_args)...);
78 }
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27

References DBUG().

Referenced by ProcessLib::PhaseField::PhaseFieldProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::SmallDeformation::SmallDeformationProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::ThermoMechanicalPhaseField::ThermoMechanicalPhaseFieldProcess< DisplacementDim >::initializeConcreteProcess(), and ProcessLib::ThermoMechanics::ThermoMechanicsProcess< DisplacementDim >::initializeConcreteProcess().

◆ createSmallDeformationProcess()

template<int DisplacementDim>
std::unique_ptr< Process > ProcessLib::SmallDeformation::createSmallDeformationProcess ( std::string  name,
MeshLib::Mesh mesh,
std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&  jacobian_assembler,
std::vector< ProcessVariable > const &  variables,
std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &  parameters,
std::optional< ParameterLib::CoordinateSystem > const &  local_coordinate_system,
unsigned const  integration_order,
BaseLib::ConfigTree const &  config 
)
Input File Parameter:
prj__processes__process__type
Input File Parameter:
prj__processes__process__SMALL_DEFORMATION__process_variables
Input File Parameter:
prj__processes__process__SMALL_DEFORMATION__process_variables__process_variable
Input File Parameter:
prj__processes__process__SMALL_DEFORMATION__solid_density
Input File Parameter:
prj__processes__process__SMALL_DEFORMATION__specific_body_force
Input File Parameter:
prj__processes__process__SMALL_DEFORMATION__reference_temperature
Input File Parameter:
prj__processes__process__SMALL_DEFORMATION__initial_stress

Definition at line 27 of file CreateSmallDeformationProcess.cpp.

37 {
39  config.checkConfigParameter("type", "SMALL_DEFORMATION");
40  DBUG("Create SmallDeformationProcess.");
41 
42  // Process variable.
43 
45  auto const pv_config = config.getConfigSubtree("process_variables");
46 
47  auto per_process_variables = findProcessVariables(
48  variables, pv_config,
49  {
50  "process_variable"});
51 
52  DBUG("Associate displacement with process variable '{:s}'.",
53  per_process_variables.back().get().getName());
54 
55  if (per_process_variables.back().get().getNumberOfGlobalComponents() !=
56  DisplacementDim)
57  {
58  OGS_FATAL(
59  "Number of components of the process variable '{:s}' is different "
60  "from the displacement dimension: got {:d}, expected {:d}",
61  per_process_variables.back().get().getName(),
62  per_process_variables.back().get().getNumberOfGlobalComponents(),
63  DisplacementDim);
64  }
65  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
66  process_variables;
67  process_variables.push_back(std::move(per_process_variables));
68 
69  auto solid_constitutive_relations =
70  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
71  parameters, local_coordinate_system, config);
72 
73  // Solid density
74  auto const& solid_density = ParameterLib::findParameter<double>(
75  config,
77  "solid_density", parameters, 1, &mesh);
78  DBUG("Use '{:s}' as solid density parameter.", solid_density.name);
79 
80  // Specific body force
81  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
82  {
83  std::vector<double> const b =
85  config.getConfigParameter<std::vector<double>>(
86  "specific_body_force");
87  if (b.size() != DisplacementDim)
88  {
89  OGS_FATAL(
90  "The size of the specific body force vector does not match the "
91  "displacement dimension. Vector size is {:d}, displacement "
92  "dimension is {:d}",
93  b.size(), DisplacementDim);
94  }
95 
96  std::copy_n(b.data(), b.size(), specific_body_force.data());
97  }
98 
99  // Reference temperature
101  double>(
103  config, "reference_temperature", parameters, 1, &mesh);
105  {
106  DBUG("Use '{:s}' as reference temperature parameter.",
107  (*reference_temperature).name);
108  }
109 
110  // Initial stress conditions
111  auto const initial_stress = ParameterLib::findOptionalTagParameter<double>(
113  config, "initial_stress", parameters,
114  // Symmetric tensor size, 4 or 6, not a Kelvin vector.
116  &mesh);
117 
118  SmallDeformationProcessData<DisplacementDim> process_data{
119  materialIDs(mesh), std::move(solid_constitutive_relations),
120  initial_stress, solid_density,
121  specific_body_force, reference_temperature};
122 
123  SecondaryVariableCollection secondary_variables;
124 
125  ProcessLib::createSecondaryVariables(config, secondary_variables);
126 
127  return std::make_unique<SmallDeformationProcess<DisplacementDim>>(
128  std::move(name), mesh, std::move(jacobian_assembler), parameters,
129  integration_order, std::move(process_variables),
130  std::move(process_data), std::move(secondary_variables));
131 }
#define OGS_FATAL(...)
Definition: Error.h:26
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
Definition: KelvinVector.h:23
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:258
Parameter< ParameterDataType > * findOptionalTagParameter(BaseLib::ConfigTree const &process_config, std::string const &tag, std::vector< std::unique_ptr< ParameterBase >> const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition: Utils.h:163
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)

References BaseLib::ConfigTree::checkConfigParameter(), ProcessLib::createSecondaryVariables(), DBUG(), ParameterLib::findOptionalTagParameter(), ProcessLib::findProcessVariables(), BaseLib::ConfigTree::getConfigParameter(), BaseLib::ConfigTree::getConfigSubtree(), MathLib::KelvinVector::kelvin_vector_dimensions(), MeshLib::materialIDs(), MaterialPropertyLib::name, OGS_FATAL, and MaterialPropertyLib::reference_temperature.

◆ createSmallDeformationProcess< 2 >()

template std::unique_ptr< Process > ProcessLib::SmallDeformation::createSmallDeformationProcess< 2 > ( std::string  name,
MeshLib::Mesh mesh,
std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&  jacobian_assembler,
std::vector< ProcessVariable > const &  variables,
std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &  parameters,
std::optional< ParameterLib::CoordinateSystem > const &  local_coordinate_system,
unsigned const  integration_order,
BaseLib::ConfigTree const &  config 
)

◆ createSmallDeformationProcess< 3 >()

template std::unique_ptr< Process > ProcessLib::SmallDeformation::createSmallDeformationProcess< 3 > ( std::string  name,
MeshLib::Mesh mesh,
std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&  jacobian_assembler,
std::vector< ProcessVariable > const &  variables,
std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &  parameters,
std::optional< ParameterLib::CoordinateSystem > const &  local_coordinate_system,
unsigned const  integration_order,
BaseLib::ConfigTree const &  config 
)

◆ getMaterialForces()

template<int DisplacementDim, typename ShapeFunction , typename ShapeMatricesType , typename NodalForceVectorType , typename NodalDisplacementVectorType , typename GradientVectorType , typename GradientMatrixType , typename IPData , typename IntegrationMethod >
std::vector<double> const& ProcessLib::SmallDeformation::getMaterialForces ( std::vector< double > const &  local_x,
std::vector< double > &  nodal_values,
IntegrationMethod const &  _integration_method,
IPData const &  _ip_data,
MeshLib::Element const &  element,
bool const  is_axially_symmetric 
)

Definition at line 41 of file MaterialForces.h.

45 {
46  unsigned const n_integration_points =
47  _integration_method.getNumberOfPoints();
48 
49  nodal_values.clear();
50  auto local_b = MathLib::createZeroedVector<NodalDisplacementVectorType>(
51  nodal_values, ShapeFunction::NPOINTS * DisplacementDim);
52 
53  for (unsigned ip = 0; ip < n_integration_points; ip++)
54  {
55  auto const& sigma = _ip_data[ip].sigma;
56  auto const& N = _ip_data[ip].N;
57  auto const& dNdx = _ip_data[ip].dNdx;
58 
59  auto const& psi = _ip_data[ip].free_energy_density;
60 
61  auto const x_coord =
62  NumLib::interpolateXCoordinate<ShapeFunction, ShapeMatricesType>(
63  element, _ip_data[ip].N);
64 
65  // For the 2D case the 33-component is needed (and the four entries
66  // of the non-symmetric matrix); In 3d there are nine entries.
67  GradientMatrixType G(
68  DisplacementDim * DisplacementDim + (DisplacementDim == 2 ? 1 : 0),
69  ShapeFunction::NPOINTS * DisplacementDim);
70  Deformation::computeGMatrix<DisplacementDim, ShapeFunction::NPOINTS>(
71  dNdx, G, is_axially_symmetric, N, x_coord);
72 
73  GradientVectorType const grad_u =
74  G * Eigen::Map<NodalForceVectorType const>(
75  local_x.data(), ShapeFunction::NPOINTS * DisplacementDim);
76 
77  GradientVectorType eshelby_stress;
78  eshelby_stress.setZero(DisplacementDim * DisplacementDim +
79  (DisplacementDim == 2 ? 1 : 0));
80 
81  if (DisplacementDim == 3)
82  {
83  eshelby_stress[0] = eshelby_stress[DisplacementDim + 1] =
84  eshelby_stress[8] = psi;
85 
86  eshelby_stress[0] -= sigma[0] * grad_u[0] +
87  sigma[3] / std::sqrt(2) * grad_u[3] +
88  sigma[5] / std::sqrt(2) * grad_u[6];
89 
90  eshelby_stress[1] -= sigma[3] / std::sqrt(2) * grad_u[0] +
91  sigma[1] * grad_u[3] +
92  sigma[4] / std::sqrt(2) * grad_u[6];
93 
94  eshelby_stress[2] -= sigma[5] / std::sqrt(2) * grad_u[0] +
95  sigma[4] / std::sqrt(2) * grad_u[3] +
96  sigma[2] * grad_u[6];
97 
98  eshelby_stress[3] -= sigma[0] * grad_u[1] +
99  sigma[3] / std::sqrt(2) * grad_u[4] +
100  sigma[5] / std::sqrt(2) * grad_u[7];
101 
102  eshelby_stress[4] -= sigma[3] / std::sqrt(2) * grad_u[1] +
103  sigma[1] * grad_u[4] +
104  sigma[4] / std::sqrt(2) * grad_u[7];
105 
106  eshelby_stress[5] -= sigma[5] / std::sqrt(2) * grad_u[1] +
107  sigma[4] / std::sqrt(2) * grad_u[4] +
108  sigma[2] * grad_u[7];
109 
110  eshelby_stress[6] -= sigma[0] * grad_u[2] +
111  sigma[3] / std::sqrt(2) * grad_u[5] +
112  sigma[5] / std::sqrt(2) * grad_u[8];
113 
114  eshelby_stress[7] -= sigma[3] / std::sqrt(2) * grad_u[2] +
115  sigma[1] * grad_u[5] +
116  sigma[4] / std::sqrt(2) * grad_u[8];
117 
118  eshelby_stress[8] -= sigma[5] / std::sqrt(2) * grad_u[2] +
119  sigma[4] / std::sqrt(2) * grad_u[5] +
120  sigma[2] * grad_u[8];
121  }
122  else if (DisplacementDim == 2)
123  {
124  eshelby_stress[0] = eshelby_stress[DisplacementDim + 1] =
125  eshelby_stress[4] = psi;
126 
127  eshelby_stress[0] -=
128  sigma[0] * grad_u[0] + sigma[3] / std::sqrt(2) * grad_u[2];
129 
130  eshelby_stress[1] -=
131  sigma[3] / std::sqrt(2) * grad_u[0] + sigma[1] * grad_u[2];
132 
133  eshelby_stress[2] -=
134  sigma[0] * grad_u[1] + sigma[3] / std::sqrt(2) * grad_u[3];
135 
136  eshelby_stress[3] -=
137  sigma[3] / std::sqrt(2) * grad_u[1] + sigma[1] * grad_u[3];
138 
139  // for axial-symmetric case the following is not zero in general
140  eshelby_stress[4] -= sigma[2] * grad_u[4];
141  }
142  else
143  {
144  OGS_FATAL(
145  "Material forces not implemented for displacement "
146  "dimension "
147  "other than 2 and 3.");
148  }
149 
150  auto const& w = _ip_data[ip].integration_weight;
151  local_b += G.transpose() * eshelby_stress * w;
152  }
153 
154  return nodal_values;
155 }

References OGS_FATAL.

Referenced by ProcessLib::SmallDeformation::SmallDeformationLocalAssembler< ShapeFunction, IntegrationMethod, DisplacementDim >::getMaterialForces().

◆ writeMaterialForces()

template<typename LocalAssemblerInterface >
void ProcessLib::SmallDeformation::writeMaterialForces ( std::unique_ptr< GlobalVector > &  material_forces,
std::vector< std::unique_ptr< LocalAssemblerInterface >> const &  local_assemblers,
NumLib::LocalToGlobalIndexMap const &  local_to_global_index_map,
GlobalVector const &  x 
)

Definition at line 158 of file MaterialForces.h.

164 {
165  DBUG("Compute material forces for small deformation process.");
166 
167  // Prepare local storage and fetch values.
169 
170  if (!material_forces)
171  {
172  material_forces =
174  }
175 
176  MathLib::LinAlg::set(*material_forces, 0);
177 
179  [](const std::size_t mesh_item_id,
180  LocalAssemblerInterface& local_assembler,
181  const NumLib::LocalToGlobalIndexMap& dof_table,
182  GlobalVector const& x,
183  GlobalVector& node_values) {
184  auto const indices = NumLib::getIndices(mesh_item_id, dof_table);
185  std::vector<double> local_data;
186  auto const local_x = x.get(indices);
187 
188  local_assembler.getMaterialForces(local_x, local_data);
189 
190  assert(local_data.size() == indices.size());
191  node_values.add(indices, local_data);
192  },
193  local_assemblers, local_to_global_index_map, x, *material_forces);
194  MathLib::LinAlg::finalizeAssembly(*material_forces);
195 }
Global vector based on Eigen vector.
Definition: EigenVector.h:26
void add(IndexType rowId, double v)
add entry
Definition: EigenVector.h:80
double get(IndexType rowId) const
get entry
Definition: EigenVector.h:62
void finalizeAssembly(PETScMatrix &A)
Definition: LinAlg.cpp:162
void setLocalAccessibleVector(PETScVector const &x)
Definition: LinAlg.cpp:27
void set(PETScVector &x, double const a)
Definition: LinAlg.cpp:32
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
static void executeDereferenced(F const &f, C const &c, Args_ &&... args)

References MathLib::EigenVector::add(), DBUG(), NumLib::SerialExecutor::executeDereferenced(), MathLib::LinAlg::finalizeAssembly(), MathLib::EigenVector::get(), NumLib::getIndices(), MathLib::LinAlg::set(), and MathLib::LinAlg::setLocalAccessibleVector().

Referenced by ProcessLib::SmallDeformation::SmallDeformationProcess< DisplacementDim >::postTimestepConcreteProcess().