-
Notifications
You must be signed in to change notification settings - Fork 284
[Core] Add PMultigridBuilderAndSolver
#13276
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
Merged
Merged
Changes from all commits
Commits
Show all changes
151 commits
Select commit
Hold shift + click to select a range
eee0b78
add constraint assembler interface
matekelemen fb5fac0
add interface for multifreedom constraints
matekelemen a14f613
add linear multifreedom constraint
matekelemen a198982
add dummy constraint assembler
matekelemen 7aa8eda
add master-slave constraint assembler
matekelemen 2819cbc
add augmented lagrange constraint assembler
matekelemen 9d36f12
add utilities for ublas sparse matrices
matekelemen ee5d873
add utility functions for system scaling
matekelemen 12cbe77
add factory for constraint assemblers
matekelemen c48afcb
add utilities for p-coarsening
matekelemen bce87b8
add coarse grids
matekelemen 47c6707
add b&s for p-multigrid
matekelemen c2cedc3
Merge branch 'core/register-float-solvers' into core/p-multigrid
matekelemen 92fb9bc
expose linear multifreedom constraint to python
matekelemen 2938413
expose PMultigridBuilderAndSolver to python
matekelemen ed9e1e9
Merge branch 'core/initialize-constraints' into core/p-multigrid
matekelemen c6d2466
expose linear multifreedom constraint to the serializer
matekelemen ecce8b7
Merge branch 'structural/builder-and-solver-settings' into core/p-mul…
matekelemen 37eca59
extend builder and solver options in structural mechanics solver
matekelemen f24354b
Merge branch 'structural/builder-and-solver-settings' into core/p-mul…
matekelemen 5f97354
suppress unused capture warning
matekelemen f4a100a
remove unnecessary checks
matekelemen d8aadfa
'not' => '!' because MSVC refuses to conform to standards
matekelemen 4dc9019
Merge branch 'core/initialize-constraints' into core/p-multigrid
matekelemen 2e910ec
Merge branch 'master' of https://github.com/KratosMultiphysics/Kratos…
matekelemen 64e3c35
fix residual formatting
matekelemen 7db0ce4
gcc hates doxygen ...
matekelemen a6a0725
msvc and logical operators ...
matekelemen 49d18af
Merge branch 'structural/builder-and-solver-settings' into core/p-mul…
matekelemen d688e8c
remove unused lambda capture
matekelemen a212885
handholding for poor old, senile MSVC
matekelemen a1289d7
export symbols for PMultigridBuilderAndSolver
matekelemen bc814a5
I guess I have to work around decade-old compiler bugs if I want my s…
matekelemen 60195d2
attempt to appease rocky linux' ancient gcc
matekelemen d353b03
msvc and logical operators ...
matekelemen 81913aa
attempt to appease rocky linux' ancient gcc. round 2
matekelemen 0962e30
msvc and logical operators ...
matekelemen 4ea9661
has gcc 8.5 never heard of move semantics?
matekelemen ff261cd
fix PointerVectorSet::count
matekelemen 3ab7c25
shove operations on system vectors into one loop
matekelemen 080550c
maybe explicitly noexcept defaulted constructors/assignment operators…
matekelemen 8aa9305
remove obsolete container
matekelemen bd5ad29
attempt to appease rocky linux' ancient gcc. vol3
matekelemen fa35892
explicitly export symbols from BuilderAndSolver
matekelemen fcc9d8f
Revert "explicitly export symbols from BuilderAndSolver"
matekelemen 712d64e
don't expose any symbols then?
matekelemen 2b7b515
Revert "don't expose any symbols then?"
matekelemen 7d16e25
Reapply "explicitly export symbols from BuilderAndSolver"
matekelemen f3d4584
ばんさくつきた
matekelemen 49aa389
Merge branch 'geo/avoid-derived-template-param' into core/p-multigrid
matekelemen a267d40
add missing copy constructor definition for NodalData
matekelemen d8f1237
pull index set into a type alias
matekelemen 4fbb6a3
pull node index locator into free-float function
matekelemen 2301dab
lock mutexes for every DoF separately (massive performance improvement)
matekelemen 94c2554
include all heap containers in thread-local vars
matekelemen df96c56
Merge branch 'hdf5/traceback' into core/p-multigrid
matekelemen e39a390
improve status reports
matekelemen 1c0fcac
move constraint utilities
matekelemen 224d5a2
dynamic penalty factors and diagonal scales
matekelemen 6ad494f
replace pair with struct to help rocky?
matekelemen 9be5cbb
Merge branch 'master' of https://github.com/kratosmultiphysics/kratos…
matekelemen 837d39a
remove unused include
matekelemen 479191f
Merge branch 'master' of https://github.com/KratosMultiphysics/Kratos…
matekelemen dd4768a
minor optimizations in sparse utilities
matekelemen c9c304a
remove junk from AugmentedLagrangeConstraintAssembler
matekelemen 37d8c2b
Merge branch 'core/p-multigrid' of https://github.com/kratosmultiphys…
matekelemen 8fdebe9
Merge branch 'master' of https://github.com/kratosmultiphysics/kratos…
matekelemen 8c310e4
pimpl master slave constraint assembler
matekelemen f822f7c
fix integer mismatch in BalancedProduct
matekelemen ecb578b
write constraint equations if requested
matekelemen b313b6c
forbid ConstraintAssembler from being moved
matekelemen b494ecd
pass the parent's constraint assembler during coarsening
matekelemen 67b9f8c
source bashrc on rocky (should probably be /etc/profile)
matekelemen e4e8fb5
Merge branch 'master' of https://github.com/KratosMultiphysics/Kratos…
matekelemen a130137
Merge branch 'core/p-multigrid' of https://github.com/kratosmultiphys…
matekelemen 12828bd
explicitly source the gcc-11 toolchain
matekelemen 6102498
update ci rocky image reference
matekelemen 38c8956
Revert "explicitly source the gcc-11 toolchain"
matekelemen b45091c
Revert "source bashrc on rocky (should probably be /etc/profile)"
matekelemen 3fe4f7c
Reapply "source bashrc on rocky (should probably be /etc/profile)"
matekelemen 7f8007d
source /etc/bashrc in the rocky CI
matekelemen ac60143
add docs for PMultigridBuilderAndSolver and PGrid
matekelemen 0f5dc94
add docs for utilities
matekelemen 4cba87a
add docs for constraints
matekelemen 4fe757d
add docs for constraint assemblers
matekelemen 3321333
Merge branch 'master' of https://github.com/KratosMultiphysics/Kratos…
matekelemen 37d151c
extend docs for ConstraintAssemblerFactory
matekelemen 9271289
Merge branch 'master' of https://github.com/KratosMultiphysics/Kratos…
matekelemen 9581c01
fix status stream header
matekelemen 44f8eb8
consistent index types
matekelemen 1635f17
remove the linear solver type from PMultigridBuilderAndSolver's templ…
matekelemen faf8660
add infrastructure for constraints' hessians
matekelemen 3bbcd45
add link constraint
matekelemen 68c27db
expose LinkConstraint to python
matekelemen 7460d2b
remove the linear solver type from PMultigridBuilderAndSolver's templ…
matekelemen d34079b
Merge branch 'core/pmg-hessian' into structural/link-constraint-pr
matekelemen 55a304a
add python process for constructing LinkConstraints
matekelemen 6482876
add tests for LinkConstraint
matekelemen 3ef0667
update docs
matekelemen 8165fab
explicitly delete copy/move constructor and assignment operator
matekelemen a8933e3
fix linear solver config
matekelemen 661b465
add support for intermediate solution/residual outputs
matekelemen 5570366
resolve merge conflicts
matekelemen 75dccc3
Merge branch 'core/pmg-hessian' into structural/link-constraint-pr
matekelemen d0742f0
fix delegating constructor
matekelemen 4dbda6a
My bad. I guess it's too much to ask of MSVC to support C++17 in 2025.
matekelemen 3e8796d
extend docs
matekelemen 46e469d
try working around yet another MSVC ICE
matekelemen f5e343e
try working around yet another MSVC ICE; round 2
matekelemen 33198c7
Merge branch 'master' of https://github.com/kratosmultiphysics/kratos…
matekelemen e8777cc
improve status logs
matekelemen 0b38806
resolve merge conflicts
matekelemen d0d97ce
Merge branch 'core/pmg-hessian' into structural/link-constraint-pr
matekelemen e741e60
remove godbolt link
matekelemen 21e9726
change annotation blocks from C++ style to old C style
matekelemen 0a5a095
extend docs about verbosity level 5
matekelemen 5cf6e48
include whitespace in JSON strings
matekelemen ae314ec
Merge pull request #13348 from KratosMultiphysics/structural/link-con…
matekelemen a50b928
Merge pull request #13345 from KratosMultiphysics/core/pmg-hessian
matekelemen 2050106
initialize the LinkConstraint's DataValueContainer at construction
matekelemen 8e780c6
fix indexing bug
matekelemen d13f992
CI trigger
matekelemen 9871049
fix operator checks
matekelemen ceae677
fix compound variables
matekelemen b708dc4
Merge branch 'master' of https://github.com/kratosmultiphysics/kratos…
matekelemen 7f567ad
extend binding docs
matekelemen 1b77f80
add sanity checks
matekelemen c69adba
remove support for nonzero initial lagrange multipliers
matekelemen d22a90c
Merge branch 'master' of https://github.com/kratosmultiphysics/kratos…
matekelemen ad4ca25
add utility classes for equality comparison and ordering
matekelemen 4894b71
add tests for equality comparisons and orderings
matekelemen 0fb562d
Merge branch 'master' of https://github.com/kratosmultiphysics/kratos…
matekelemen 638f752
resolve merge conflicts
matekelemen 99c6e29
implicitly assume that norm always refers to the 2-norm
matekelemen be285e7
pass preserve = false to ublas resizing functions
matekelemen 6c708b3
add MPI support for finding an available ID
matekelemen b3fd289
apply suggestion
matekelemen 3d365a7
replace CaseWorkingDirectory with WorkFolderScope
matekelemen b26d015
compute node distances in 3D even if the analysis is in 2D
matekelemen b7c0208
update docs
matekelemen 8e1a5da
add docs for ProcessMasterSlaveConstraint and ProcessMultifreedomCons…
matekelemen 8e8a3cc
add docs for NoOpConstraintAssembler
matekelemen af17a0c
remove leftover comments
matekelemen a407fe6
fix docs
matekelemen 040b6fc
fix docs
matekelemen 0d7d15e
remove unused include
matekelemen c071bce
Merge branch 'master' of https://github.com/KratosMultiphysics/Kratos…
matekelemen 89d4bea
replace explicit fills with ZeroMatrix and ZeroVector
matekelemen 27a4014
Merge branch 'master' of https://github.com/kratosmultiphysics/kratos…
matekelemen 94266e0
resolve merge conflicts
matekelemen 76ebd40
oopsies
matekelemen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
323 changes: 323 additions & 0 deletions
323
applications/StructuralMechanicsApplication/custom_constraints/link_constraint.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,323 @@ | ||
| // | / | | ||
| // ' / __| _` | __| _ \ __| | ||
| // . \ | ( | | ( |\__ ` | ||
| // _|\_\_| \__,_|\__|\___/ ____/ | ||
| // Multi-Physics | ||
| // | ||
| // License: BSD License | ||
| // Kratos default license: kratos/license.txt | ||
| // | ||
| // Main authors: Máté Kelemen | ||
| // | ||
|
|
||
| // Project includes | ||
| #include "custom_constraints/link_constraint.hpp" // LinkConstraint | ||
| #include "includes/define.h" | ||
| #include "includes/process_info.h" | ||
| #include "includes/variables.h" // DISPLACEMENT_X, DISPLACEMENT_Y, DISPLACEMENT_Z | ||
| #include "includes/serializer.h" // Serializer | ||
| #include "includes/variables.h" // CONSTITUTIVE_MATRIX, INTERNAL_FORCES_VECTOR | ||
|
|
||
| // STL includes | ||
| #include <algorithm> // std::max_element, std::equal, std::transform | ||
|
|
||
|
|
||
| namespace Kratos { | ||
|
|
||
|
|
||
| struct LinkConstraint::Impl | ||
| { | ||
| using ValueType = double; | ||
|
|
||
| static void ComputeRelationMatrix(LinkConstraint::MatrixType& rRelationMatrix, | ||
| LinkConstraint::MatrixType& rHessian, | ||
| LinkConstraint::VectorType& rConstraintGaps, | ||
| const std::array<ValueType,6>& rLastPositions, | ||
| const std::array<ValueType,6>& rLastDisplacements, | ||
| const unsigned Dimensions) | ||
| { | ||
| // Set output sizes. | ||
| rRelationMatrix = ZeroMatrix(1, 2 * Dimensions); | ||
| rHessian = ZeroMatrix(2 * Dimensions, 2 * Dimensions); | ||
| rConstraintGaps = ZeroVector(1); | ||
|
|
||
| // Compute constraint violation. | ||
| double current_norm_square = 0.0; | ||
| for (std::size_t i_component=0ul; i_component<Dimensions; ++i_component) { | ||
| const auto current_diff = rLastPositions[i_component] - rLastPositions[i_component + Dimensions] | ||
| + rLastDisplacements[i_component] - rLastDisplacements[i_component + Dimensions]; | ||
| current_norm_square += current_diff * current_diff; | ||
| } // for i_component in range(Dimensions) | ||
|
|
||
| KRATOS_ERROR_IF_NOT(current_norm_square) << "degenerate link constraint"; | ||
| const auto current_norm = std::sqrt(current_norm_square); | ||
|
|
||
| // Dof order: | ||
| // {u^0_x, ..., u^0_w, u^1_x, ..., u^1_w} | ||
| // Where w is the axis with the highest index for the provided dimensions | ||
| // (e.g.: z-axis in 3 dimensions). | ||
|
|
||
| for (std::size_t i_component=0u; i_component<Dimensions; ++i_component) { | ||
| const auto current_diff = rLastPositions[i_component] - rLastPositions[i_component + Dimensions] | ||
| + rLastDisplacements[i_component] - rLastDisplacements[i_component + Dimensions]; | ||
|
|
||
| rRelationMatrix(0, i_component) = current_diff / current_norm; | ||
| rRelationMatrix(0, i_component + Dimensions) = -rRelationMatrix(0, i_component); | ||
|
|
||
| const auto hessian_entry = (current_norm - current_diff * current_diff / current_norm) / current_norm; | ||
|
|
||
| rHessian(i_component, i_component) = hessian_entry; | ||
| rHessian(i_component, i_component + Dimensions) = -hessian_entry; | ||
| rHessian(i_component + Dimensions, i_component) = -hessian_entry; | ||
| rHessian(i_component + Dimensions, i_component + Dimensions) = hessian_entry; | ||
| } // for i_component in range(mDimensions) | ||
| } | ||
|
|
||
|
|
||
| static LinkConstraint::DofPointerVectorType CollectDofs(Node& rFirst, | ||
| Node& rSecond, | ||
| const std::size_t Dimensions) | ||
| { | ||
| DofPointerVectorType dofs; | ||
|
|
||
| KRATOS_TRY | ||
| using ValueType = double; | ||
|
|
||
| const std::array<const Variable<ValueType>*,3> displacement_components { | ||
| &DISPLACEMENT_X, | ||
| &DISPLACEMENT_Y, | ||
| &DISPLACEMENT_Z | ||
| }; | ||
|
|
||
| std::array<Node*, 2> nodes {&rFirst, &rSecond}; | ||
| dofs.resize(2 * Dimensions); | ||
|
|
||
| // Collect dofs from nodes in the following order: | ||
| // {u^0_x, ..., u^0_w, u^1_x, ..., u^1_w} | ||
| // Where w is the axis with the highest index for the provided dimensions | ||
| // (e.g.: z-axis in 3 dimensions). | ||
| for (std::size_t i_dimension=0ul; i_dimension<Dimensions; ++i_dimension) { | ||
| const auto component_id = displacement_components[i_dimension]->Key(); | ||
|
|
||
| for (std::size_t i_node=0ul; i_node<2; ++i_node) { | ||
| Node& r_node = *nodes[i_node]; | ||
| const auto it_dof = std::find_if(r_node.GetDofs().begin(), | ||
| r_node.GetDofs().end(), | ||
| [component_id](auto& rp_dof){ | ||
| return rp_dof->GetVariable().Key() == component_id; | ||
| }); | ||
| KRATOS_ERROR_IF(it_dof == r_node.GetDofs().end()) | ||
| << "cannot find DoF " << displacement_components[i_dimension]->Name() | ||
| << " in node " << r_node.Id(); | ||
| dofs[i_node * Dimensions + i_dimension] = it_dof->get(); | ||
| } // for i_node in range(2) | ||
| } // for i_dimension in range(Dimensions) | ||
| KRATOS_CATCH("") | ||
|
|
||
| return dofs; | ||
| } | ||
|
|
||
|
|
||
| void FetchNodePositions(std::array<ValueType,6>& rPositions, | ||
| std::array<ValueType,6>& rDisplacements) const { | ||
| KRATOS_TRY | ||
|
|
||
| const std::array<const Variable<Impl::ValueType>*,3> displacement_components { | ||
| &DISPLACEMENT_X, | ||
| &DISPLACEMENT_Y, | ||
| &DISPLACEMENT_Z | ||
| }; | ||
|
|
||
| for (std::size_t i_component=0u; i_component<mDimensions; ++i_component) { | ||
| for (std::size_t i_node=0u; i_node<2; ++i_node) { | ||
| const std::size_t i_dof = i_component + (i_node ? mDimensions : 0u); | ||
| rPositions[i_dof] = mNodePair[i_node]->Coordinates()[i_component]; | ||
| rDisplacements[i_dof] = mNodePair[i_node]->GetSolutionStepValue(*displacement_components[i_component]); | ||
| } // for i_node in range(2) | ||
| } // for i_component in range(mDimensions) | ||
|
|
||
| KRATOS_CATCH("") | ||
| } | ||
|
|
||
|
|
||
| std::size_t mDimensions; | ||
|
|
||
| bool mIsMeshMoved; | ||
|
|
||
| /// @details MasterSlaveConstraint::GetSlaveDofsVector and MasterSlaveConstraint::GetMasterDofsVector | ||
| /// require arrays of mutable Dof pointers, which are only obtainable from mutable nodes, | ||
| /// so the nodes' pointers stored here cannot be immutable. Risky business. | ||
| std::array<Node*,2> mNodePair; | ||
|
|
||
| std::array<ValueType,6> mLastPositions; | ||
|
|
||
| std::array<ValueType,6> mLastDisplacements; | ||
| }; // struct LinkConstraint::Impl | ||
|
|
||
|
|
||
| LinkConstraint::LinkConstraint(const IndexType Id, | ||
| Node& rFirst, | ||
| Node& rSecond, | ||
| const std::size_t Dimensions, | ||
| bool IsMeshMoved) | ||
| : MultifreedomConstraint(/*Id : */Id, | ||
| /*rDofs : */Impl::CollectDofs(rFirst, rSecond, Dimensions), | ||
| /*rConstraintLabels: */std::vector<std::size_t> {Id}), | ||
| mpImpl(new Impl{/*mDimensions : */Dimensions, | ||
| /*mIsMeshMoved : */IsMeshMoved, | ||
| /*mNodePair : */{&rFirst, &rSecond}, | ||
| /*mLastPositions : */{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, | ||
| /*mLastDisplacements : */{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}) | ||
| { | ||
| this->Data().GetValue(CONSTITUTIVE_MATRIX) = ZeroMatrix(0); | ||
| this->Data().GetValue(INTERNAL_FORCES_VECTOR) = ZeroVector(0); | ||
| } | ||
|
|
||
|
|
||
| LinkConstraint::~LinkConstraint() = default; | ||
|
|
||
|
|
||
| MasterSlaveConstraint::Pointer LinkConstraint::Clone(IndexType NewId) const | ||
| { | ||
| KRATOS_TRY | ||
| auto p_other = LinkConstraint::Pointer( | ||
| new LinkConstraint(NewId, | ||
| *mpImpl->mNodePair.front(), | ||
| *mpImpl->mNodePair.back(), | ||
| mpImpl->mDimensions, | ||
| mpImpl->mIsMeshMoved) | ||
| ); | ||
| return p_other; | ||
| KRATOS_CATCH("") | ||
| } | ||
|
|
||
|
|
||
| void LinkConstraint::Initialize([[maybe_unused]] const ProcessInfo&) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| void LinkConstraint::InitializeSolutionStep(const ProcessInfo&) | ||
| { | ||
| KRATOS_TRY | ||
| // Store displacements before nonlinear iterations begin. | ||
| // At this point, displacements are at their last converged | ||
| // state, when the constraint is supposed to be still satisfied. | ||
| mpImpl->FetchNodePositions(mpImpl->mLastPositions, | ||
| mpImpl->mLastDisplacements); | ||
|
|
||
| if (!mpImpl->mIsMeshMoved) | ||
| for (std::size_t i_component=0ul; i_component<mpImpl->mLastPositions.size(); ++i_component) | ||
| mpImpl->mLastPositions[i_component] += mpImpl->mLastDisplacements[i_component]; | ||
|
|
||
| Impl::ComputeRelationMatrix(this->Data().GetValue(CONSTITUTIVE_MATRIX), | ||
| this->GetHessian(), | ||
| this->Data().GetValue(INTERNAL_FORCES_VECTOR), | ||
| mpImpl->mLastPositions, | ||
| mpImpl->mLastDisplacements, | ||
| mpImpl->mDimensions); | ||
| KRATOS_CATCH("") | ||
| } | ||
|
|
||
|
|
||
| void LinkConstraint::InitializeNonLinearIteration(const ProcessInfo&) | ||
| { | ||
| KRATOS_TRY | ||
| [[maybe_unused]] std::array<Impl::ValueType,6> dummy; | ||
| mpImpl->FetchNodePositions(dummy, mpImpl->mLastDisplacements); | ||
|
|
||
| Impl::ComputeRelationMatrix(this->Data().GetValue(CONSTITUTIVE_MATRIX), | ||
| this->GetHessian(), | ||
| this->Data().GetValue(INTERNAL_FORCES_VECTOR), | ||
| mpImpl->mLastPositions, | ||
| mpImpl->mLastDisplacements, | ||
| mpImpl->mDimensions); | ||
| KRATOS_CATCH("") | ||
| } | ||
|
|
||
|
|
||
| void LinkConstraint::FinalizeNonLinearIteration(const ProcessInfo& rProcessInfo) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| void LinkConstraint::FinalizeSolutionStep(const ProcessInfo&) | ||
| { | ||
| this->Data().GetValue(CONSTITUTIVE_MATRIX).clear(); | ||
| this->Data().GetValue(INTERNAL_FORCES_VECTOR).clear(); | ||
| } | ||
|
|
||
|
|
||
| void LinkConstraint::Finalize(const ProcessInfo&) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| void LinkConstraint::CalculateLocalSystem(MatrixType& rRelationMatrix, | ||
| VectorType& rConstraintGaps, | ||
| [[maybe_unused]] const ProcessInfo& rProcessInfo) const | ||
| { | ||
| rRelationMatrix = this->GetData().GetValue(CONSTITUTIVE_MATRIX); | ||
| rConstraintGaps = this->GetData().GetValue(INTERNAL_FORCES_VECTOR); | ||
| } | ||
|
|
||
|
|
||
| int LinkConstraint::Check(const ProcessInfo& rProcessInfo) const | ||
| { | ||
| // Check whatever the base class checks. | ||
| MasterSlaveConstraint::Check(rProcessInfo); | ||
|
|
||
| // Restrict dimensions to 1, 2, or 3. | ||
| KRATOS_ERROR_IF_NOT(0 < mpImpl->mDimensions || mpImpl->mDimensions <= 3) << "unsupported dimensions (" << mpImpl->mDimensions << ")"; | ||
|
|
||
| // Make sure that the nodes have the necessary Dofs. | ||
| const std::array<const Variable<Impl::ValueType>*,3> displacement_components { | ||
| &DISPLACEMENT_X, | ||
| &DISPLACEMENT_Y, | ||
| &DISPLACEMENT_Z | ||
| }; | ||
|
|
||
| for (unsigned i_component=0u; i_component<mpImpl->mDimensions; ++i_component) { | ||
| for (unsigned i_node=0u; i_node<2; ++i_node) { | ||
| KRATOS_ERROR_IF_NOT(mpImpl->mNodePair[i_node]->HasDofFor(*displacement_components[i_component])) | ||
| << "node " << mpImpl->mNodePair[i_node]->Id() | ||
| << " has no Dof for " << displacement_components[i_component]->Name(); | ||
| } // for i_node in range(2) | ||
| } // for i_component in range(mDimensions) | ||
|
|
||
| // Check for overlapping nodes. | ||
| constexpr Impl::ValueType tolerance = 1e-16; | ||
| KRATOS_ERROR_IF(norm_2(mpImpl->mNodePair.front()->Coordinates() - mpImpl->mNodePair.back()->Coordinates()) < tolerance) | ||
| << "coincident nodes in LinkConstraint"; | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
|
|
||
| void LinkConstraint::save(Serializer& rSerializer) const | ||
| { | ||
| KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, MultifreedomConstraint); | ||
| rSerializer.save("Dimensions", mpImpl->mDimensions); | ||
| rSerializer.save("Nodes", mpImpl->mNodePair); | ||
| // The rest of the private members should be computed/cached after restarting. | ||
| } | ||
|
|
||
|
|
||
| void LinkConstraint::load(Serializer& rDeserializer) | ||
| { | ||
| KRATOS_SERIALIZE_LOAD_BASE_CLASS(rDeserializer, MultifreedomConstraint); | ||
| rDeserializer.load("Dimensions", mpImpl->mDimensions); | ||
| rDeserializer.load("Nodes", mpImpl->mNodePair); | ||
| } | ||
|
|
||
|
|
||
| std::ostream& operator<<(std::ostream& rStream, const LinkConstraint& rInstance) | ||
| { | ||
| return rStream << "LinkConstraint between nodes " | ||
| << rInstance.mpImpl->mNodePair.front()->Id() | ||
| << " and " | ||
| << rInstance.mpImpl->mNodePair.back()->Id(); | ||
| } | ||
|
|
||
|
|
||
| } // namespace Kratos |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.