diff --git a/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp b/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp index 914064a0d54b703726a45c1c2132f0f65547363d..10b7789fa69d820f284320b246f067352945e4e6 100644 --- a/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp +++ b/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp @@ -185,7 +185,8 @@ std::unique_ptr<Process> createThermoMechanicsProcess( materialIDs(mesh), std::move(solid_constitutive_relations), reference_solid_density, linear_thermal_expansion_coefficient, specific_heat_capacity, thermal_conductivity, - specific_body_force, nonequilibrium_stress}; + specific_body_force, nonequilibrium_stress, + mechanics_process_id, heat_conduction_process_id}; SecondaryVariableCollection secondary_variables; @@ -199,8 +200,7 @@ std::unique_ptr<Process> createThermoMechanicsProcess( std::move(name), 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), use_monolithic_scheme, - mechanics_process_id, heat_conduction_process_id); + std::move(named_function_caller), use_monolithic_scheme); } template std::unique_ptr<Process> createThermoMechanicsProcess<2>( diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h index 61123ecd14255339e149648b6b151c9df62b97fe..cfd6b0048b0ab49daa48ec549d5d9b857ccb23f2 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM-impl.h @@ -35,7 +35,8 @@ void ThermoMechanicsLocalAssembler<ShapeFunction, IntegrationMethod, const LocalCoupledSolutions& local_coupled_solutions) { // For the equations with pressure - if (local_coupled_solutions.process_id == _heat_conduction_process_id) + if (local_coupled_solutions.process_id == + _process_data.heat_conduction_process_id) { assembleWithJacobianForHeatConductionEquations( t, local_xdot, dxdot_dx, dx_dx, local_M_data, local_K_data, @@ -62,7 +63,8 @@ void ThermoMechanicsLocalAssembler<ShapeFunction, IntegrationMethod, const LocalCoupledSolutions& local_coupled_solutions) { auto const& local_T_vector = - local_coupled_solutions.local_coupled_xs[_heat_conduction_process_id]; + local_coupled_solutions + .local_coupled_xs[_process_data.heat_conduction_process_id]; assert(local_T_vector.size() == temperature_size); auto const local_T = Eigen::Map<typename ShapeMatricesType::template VectorType< @@ -75,7 +77,8 @@ void ThermoMechanicsLocalAssembler<ShapeFunction, IntegrationMethod, temperature_size> const>(local_T0_vector.data(), temperature_size); auto const& local_u_vector = - local_coupled_solutions.local_coupled_xs[_mechanics_process_id]; + local_coupled_solutions + .local_coupled_xs[_process_data.mechanics_process_id]; assert(local_u_vector.size() == displacement_size); auto const u = Eigen::Map<typename ShapeMatricesType::template VectorType< displacement_size> const>(local_u_vector.data(), displacement_size); @@ -200,7 +203,8 @@ void ThermoMechanicsLocalAssembler<ShapeFunction, IntegrationMethod, const LocalCoupledSolutions& local_coupled_solutions) { auto const& local_T_vector = - local_coupled_solutions.local_coupled_xs[_heat_conduction_process_id]; + local_coupled_solutions + .local_coupled_xs[_process_data.heat_conduction_process_id]; assert(local_T_vector.size() == temperature_size); auto const local_T = Eigen::Map<typename ShapeMatricesType::template VectorType< @@ -213,16 +217,14 @@ void ThermoMechanicsLocalAssembler<ShapeFunction, IntegrationMethod, Eigen::Map<typename ShapeMatricesType::template VectorType< temperature_size> const>(local_T0_vector.data(), temperature_size); - auto local_Jac = - MathLib::createZeroedMatrix < + auto local_Jac = MathLib::createZeroedMatrix< typename ShapeMatricesType::template MatrixType<temperature_size, temperature_size>>( - local_Jac_data, temperature_size, temperature_size); + local_Jac_data, temperature_size, temperature_size); - auto local_rhs = - MathLib::createZeroedVector < + auto local_rhs = MathLib::createZeroedVector< typename ShapeMatricesType::template VectorType<temperature_size>>( - local_b_data, temperature_size); + local_b_data, temperature_size); typename ShapeMatricesType::NodalMatrixType mass; mass.setZero(temperature_size, temperature_size); diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h index abe68094841adbf6da3d81b04868ba77a151c1bc..14daca7fd8ca9b35cc9b7c71f90ee892aefea208 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h @@ -119,15 +119,11 @@ public: std::size_t const /*local_matrix_size*/, bool const is_axially_symmetric, unsigned const integration_order, - ThermoMechanicsProcessData<DisplacementDim>& process_data, - int const mechanics_process_id, - int const heat_conduction_process_id) + ThermoMechanicsProcessData<DisplacementDim>& process_data) : _process_data(process_data), _integration_method(integration_order), _element(e), - _is_axially_symmetric(is_axially_symmetric), - _mechanics_process_id(mechanics_process_id), - _heat_conduction_process_id(heat_conduction_process_id) + _is_axially_symmetric(is_axially_symmetric) { unsigned const n_integration_points = _integration_method.getNumberOfPoints(); @@ -736,12 +732,6 @@ private: SecondaryData<typename ShapeMatrices::ShapeType> _secondary_data; bool const _is_axially_symmetric; - /// ID of the mechanical process. - int const _mechanics_process_id; - - /// ID of heat conduction process. - int const _heat_conduction_process_id; - static const int temperature_index = 0; static const int temperature_size = ShapeFunction::NPOINTS; static const int displacement_index = ShapeFunction::NPOINTS; diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp index 7882fedd29a3a8705de2eb631ee2afcb93fc238f..ec69da0d59d60c76a31e5f50e6735c86aeb1abcd 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.cpp @@ -34,15 +34,12 @@ ThermoMechanicsProcess<DisplacementDim>::ThermoMechanicsProcess( ThermoMechanicsProcessData<DisplacementDim>&& process_data, SecondaryVariableCollection&& secondary_variables, NumLib::NamedFunctionCaller&& named_function_caller, - bool const use_monolithic_scheme, int const mechanics_process_id, - int const heat_conduction_process_id) + bool const use_monolithic_scheme) : Process(std::move(name), 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)), - _mechanics_process_id(mechanics_process_id), - _heat_conduction_process_id(heat_conduction_process_id) + _process_data(std::move(process_data)) { _nodal_forces = MeshLib::getOrCreateMeshProperty<double>( mesh, "NodalForces", MeshLib::MeshItemType::Node, DisplacementDim); @@ -124,7 +121,8 @@ ThermoMechanicsProcess<DisplacementDim>::getMatrixSpecifications( { // For the monolithic scheme or the M process (deformation) in the staggered // scheme. - if (_use_monolithic_scheme || process_id == _mechanics_process_id) + if (_use_monolithic_scheme || + process_id == _process_data.mechanics_process_id) { auto const& l = *_local_to_global_index_map; return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(), @@ -147,6 +145,8 @@ void ThermoMechanicsProcess<DisplacementDim>::constructDofTable() _mesh_subset_all_nodes = std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh.getNodes()); + // TODO move the two data members somewhere else. + // for extrapolation of secondary variables of stress or strain std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{ *_mesh_subset_all_nodes}; _local_to_global_index_map_single_component.reset( @@ -180,15 +180,16 @@ void ThermoMechanicsProcess<DisplacementDim>::constructDofTable() { // Collect the mesh subsets in a vector for each variable components for // the mechanical process. - std::generate_n(std::back_inserter(all_mesh_subsets), - _process_variables[_mechanics_process_id][0] - .get() - .getNumberOfComponents(), - [&]() { return *_mesh_subset_all_nodes; }); + std::generate_n( + std::back_inserter(all_mesh_subsets), + _process_variables[_process_data.mechanics_process_id][0] + .get() + .getNumberOfComponents(), + [&]() { return *_mesh_subset_all_nodes; }); // Create a vector of the number of variable components. vec_var_n_components.push_back( - _process_variables[_mechanics_process_id][0] + _process_variables[_process_data.mechanics_process_id][0] .get() .getNumberOfComponents()); @@ -211,8 +212,7 @@ void ThermoMechanicsProcess<DisplacementDim>::initializeConcreteProcess( ProcessLib::SmallDeformation::createLocalAssemblers< DisplacementDim, ThermoMechanicsLocalAssembler>( mesh.getElements(), dof_table, _local_assemblers, - mesh.isAxiallySymmetric(), integration_order, _process_data, - _mechanics_process_id, _heat_conduction_process_id); + mesh.isAxiallySymmetric(), integration_order, _process_data); _secondary_variables.addSecondaryVariable( "sigma", @@ -296,11 +296,11 @@ void ThermoMechanicsProcess<DisplacementDim>::initializeBoundaryConditions() // for the equations of heat conduction initializeProcessBoundaryConditionsAndSourceTerms( *_local_to_global_index_map_single_component, - _heat_conduction_process_id); + _process_data.heat_conduction_process_id); // for the equations of deformation. initializeProcessBoundaryConditionsAndSourceTerms( - *_local_to_global_index_map, _mechanics_process_id); + *_local_to_global_index_map, _process_data.mechanics_process_id); } template <int DisplacementDim> @@ -346,7 +346,8 @@ void ThermoMechanicsProcess<DisplacementDim>:: else { // For the staggered scheme - if (_coupled_solutions->process_id == _heat_conduction_process_id) + if (_coupled_solutions->process_id == + _process_data.heat_conduction_process_id) { DBUG( "Assemble the Jacobian equations of heat conduction process in " @@ -360,7 +361,7 @@ void ThermoMechanicsProcess<DisplacementDim>:: } // For the flexible appearance order of processes in the coupling. - if (_heat_conduction_process_id == + if (_process_data.heat_conduction_process_id == 0) // First: the heat conduction process { dof_tables.emplace_back( @@ -402,12 +403,13 @@ void ThermoMechanicsProcess<DisplacementDim>:: } }; if (_use_monolithic_scheme || - _coupled_solutions->process_id == _heat_conduction_process_id) + _coupled_solutions->process_id == + _process_data.heat_conduction_process_id) { copyRhs(0, *_heat_flux); } if (_use_monolithic_scheme || - _coupled_solutions->process_id == _mechanics_process_id) + _coupled_solutions->process_id == _process_data.mechanics_process_id) { copyRhs(1, *_nodal_forces); } @@ -427,7 +429,8 @@ void ThermoMechanicsProcess<DisplacementDim>::preTimestepConcreteProcess( assert(process_id < 2); - if (_use_monolithic_scheme || process_id == _mechanics_process_id) + if (_use_monolithic_scheme || + process_id == _process_data.mechanics_process_id) { GlobalExecutor::executeSelectedMemberOnDereferenced( &ThermoMechanicsLocalAssemblerInterface::preTimestep, @@ -456,7 +459,7 @@ void ThermoMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess( GlobalVector const& x, const double /*t*/, const double /*delta_t*/, int const process_id) { - if (process_id == _heat_conduction_process_id) + if (process_id != _process_data.mechanics_process_id) return; DBUG("PostTimestep ThermoMechanicsProcess."); @@ -481,7 +484,7 @@ template <int DisplacementDim> NumLib::LocalToGlobalIndexMap const& ThermoMechanicsProcess<DisplacementDim>::getDOFTable(const int process_id) const { - if (_mechanics_process_id == process_id) + if (_process_data.mechanics_process_id == process_id) { return *_local_to_global_index_map; } diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.h b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.h index 17b2663f50af546d1be2408eae3faf0a70faa392..7e9fa0e02391f693ee3d1f0b0e91ca1a0f0fc01d 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsProcess.h @@ -74,9 +74,7 @@ public: ThermoMechanicsProcessData<DisplacementDim>&& process_data, SecondaryVariableCollection&& secondary_variables, NumLib::NamedFunctionCaller&& named_function_caller, - bool const use_monolithic_scheme, - int const mechanics_process_id, - int const heat_conduction_process_id); + bool const use_monolithic_scheme); //! \name ODESystem interface //! @{ @@ -141,12 +139,6 @@ private: MeshLib::PropertyVector<double>* _nodal_forces = nullptr; MeshLib::PropertyVector<double>* _heat_flux = nullptr; - /// ID of the mechanical process. - int const _mechanics_process_id; - - /// ID of heat conduction process. - int const _heat_conduction_process_id; - /// Temperature of the previous time step for staggered scheme. std::unique_ptr<GlobalVector> _previous_T; diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsProcessData.h b/ProcessLib/ThermoMechanics/ThermoMechanicsProcessData.h index 1bad1df1c11f485abf80b1e25458c7464969893f..f8607deef3d832e78d2c310f9c0de2281914f3f4 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsProcessData.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsProcessData.h @@ -33,17 +33,16 @@ struct ThermoMechanicsProcessData { ThermoMechanicsProcessData( MeshLib::PropertyVector<int> const* const material_ids_, - std::map<int, - std::unique_ptr< - MaterialLib::Solids::MechanicsBase<DisplacementDim>>>&& - solid_materials_, + std::map<int, std::unique_ptr<MaterialLib::Solids::MechanicsBase< + DisplacementDim>>>&& solid_materials_, ParameterLib::Parameter<double> const& reference_solid_density_, ParameterLib::Parameter<double> const& linear_thermal_expansion_coefficient_, ParameterLib::Parameter<double> const& specific_heat_capacity_, ParameterLib::Parameter<double> const& thermal_conductivity_, Eigen::Matrix<double, DisplacementDim, 1> const& specific_body_force_, - ParameterLib::Parameter<double> const* const nonequilibrium_stress_) + ParameterLib::Parameter<double> const* const nonequilibrium_stress_, + int const mechanics_process_id_, int const heat_conduction_process_id_) : material_ids(material_ids_), solid_materials{std::move(solid_materials_)}, reference_solid_density(reference_solid_density_), @@ -52,7 +51,10 @@ struct ThermoMechanicsProcessData specific_heat_capacity(specific_heat_capacity_), thermal_conductivity(thermal_conductivity_), specific_body_force(specific_body_force_), - nonequilibrium_stress(nonequilibrium_stress_) + nonequilibrium_stress(nonequilibrium_stress_), + mechanics_process_id(mechanics_process_id_), + heat_conduction_process_id(heat_conduction_process_id_) + { } @@ -70,9 +72,8 @@ struct ThermoMechanicsProcessData MeshLib::PropertyVector<int> const* const material_ids; /// The constitutive relation for the mechanical part. - std::map< - int, - std::unique_ptr<MaterialLib::Solids::MechanicsBase<DisplacementDim>>> + std::map<int, std::unique_ptr< + MaterialLib::Solids::MechanicsBase<DisplacementDim>>> solid_materials; ParameterLib::Parameter<double> const& reference_solid_density; @@ -85,6 +86,12 @@ struct ThermoMechanicsProcessData double dt = 0; double t = 0; + /// ID of the mechanical process. + int const mechanics_process_id; + + /// ID of heat conduction process. + int const heat_conduction_process_id; + EIGEN_MAKE_ALIGNED_OPERATOR_NEW; };