YieldSurfaceCombinationManager.h
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------
2  * _
3  * _ __ ___ __ _ _ __ _ __ ___ ___ | |_
4  * | '_ ` _ \ / _` | '__| '_ ` _ \ / _ \| __|
5  * | | | | | | (_| | | | | | | | | (_) | |_
6  * |_| |_| |_|\__,_|_| |_| |_| |_|\___/ \__|
7  *
8  * Unit of Strength of Materials and Structural Analysis
9  * University of Innsbruck,
10  * 2020 - today
11  *
12  * festigkeitslehre@uibk.ac.at
13  *
14  * Matthias Neuner matthias.neuner@uibk.ac.at
15  *
16  * This file is part of the MAteRialMOdellingToolbox (marmot).
17  *
18  * This library is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU Lesser General Public
20  * License as published by the Free Software Foundation; either
21  * version 2.1 of the License, or (at your option) any later version.
22  *
23  * The full text of the license can be found in the file LICENSE.md at
24  * the top level directory of marmot.
25  * ---------------------------------------------------------------------
26  */
27 
28 #pragma once
29 #include "Marmot/MarmotTypedefs.h"
30 
31 namespace Marmot {
32  namespace NumericalAlgorithms {
36  template < int nYieldSurfaces >
39  const int idxUsedFlag;
40 
41  public:
43  Eigen::Array< bool, ( 1 << nYieldSurfaces ) - 1, ( nYieldSurfaces + 1 ) > yieldSurfaceCombinations;
45  typedef Eigen::Array< bool, 1, nYieldSurfaces > YieldSurfFlagArr;
47  typedef Eigen::Array< double, 1, nYieldSurfaces > YieldSurfResArr;
48 
51  bool getAnotherYieldFlagCombination( YieldSurfFlagArr& activeSurfaces );
53  void markYieldFlagCombinationAsUsed( const YieldSurfFlagArr& activeSurfaces );
56  };
57  } // namespace NumericalAlgorithms
58 } // namespace Marmot
59 
60 namespace Marmot {
61  namespace NumericalAlgorithms {
62  template < int n >
64  {
65  yieldSurfaceCombinations.setZero();
66  const int numRows = ( 1 << n ) - 1;
67  const int numCols = n;
68 
69  for ( int row = 0; row < numRows; row++ )
70  for ( int col = 0; col < numCols; col++ )
71  yieldSurfaceCombinations( row, col ) = ( row + 1 ) & 1 << ( col );
72  return;
73  }
74 
75  template < int n >
77  {
78  for ( int i = 0; i < yieldSurfaceCombinations.rows(); i++ ) {
79  bool alreadyUsed = yieldSurfaceCombinations.row( i )( idxUsedFlag );
80  YieldSurfFlagArr combinationCandidate = yieldSurfaceCombinations.row( i ).head( n );
81  if ( !alreadyUsed && ( combinationCandidate == true ).any() ) {
82  activeSurfaces = combinationCandidate;
83  return true;
84  }
85  }
86  return false;
87  }
88 
89  template < int n >
91  {
92  yieldSurfaceCombinations.col( idxUsedFlag ).setConstant( false );
93  }
94 
95  template < int n >
97  {
98  for ( int i = 0; i < yieldSurfaceCombinations.rows(); i++ )
99  if ( ( yieldSurfaceCombinations.row( i ).head( n ) == activeSurfaces ).all() )
100  yieldSurfaceCombinations.row( i )( idxUsedFlag ) = true;
101  }
102  } // namespace NumericalAlgorithms
103 } // namespace Marmot
Marmot::NumericalAlgorithms::YieldSurfaceCombinationManager::markYieldFlagCombinationAsUsed
void markYieldFlagCombinationAsUsed(const YieldSurfFlagArr &activeSurfaces)
set the current combination as used
Definition: YieldSurfaceCombinationManager.h:96
Marmot::NumericalAlgorithms::YieldSurfaceCombinationManager::YieldSurfaceCombinationManager
YieldSurfaceCombinationManager()
Definition: YieldSurfaceCombinationManager.h:63
Marmot::NumericalAlgorithms::YieldSurfaceCombinationManager::getAnotherYieldFlagCombination
bool getAnotherYieldFlagCombination(YieldSurfFlagArr &activeSurfaces)
get another unused combination of yield surfaces
Definition: YieldSurfaceCombinationManager.h:76
MarmotTypedefs.h
Marmot::NumericalAlgorithms::YieldSurfaceCombinationManager::YieldSurfFlagArr
Eigen::Array< bool, 1, nYieldSurfaces > YieldSurfFlagArr
An array to carry active/nonactive states of yield surfaces.
Definition: YieldSurfaceCombinationManager.h:45
Marmot::NumericalAlgorithms::YieldSurfaceCombinationManager::yieldSurfaceCombinations
Eigen::Array< bool,(1<< nYieldSurfaces) - 1,(nYieldSurfaces+1) > yieldSurfaceCombinations
An array which contains every possible (reasonable) combination of yield surfaces.
Definition: YieldSurfaceCombinationManager.h:43
Marmot::NumericalAlgorithms::YieldSurfaceCombinationManager
Definition: YieldSurfaceCombinationManager.h:37
Marmot
This file includes functions needed for calculations with stress and strain tensors written in voigt ...
Definition: MarmotTesting.h:30
Marmot::NumericalAlgorithms::YieldSurfaceCombinationManager::resetUsedYieldFlagCombinations
void resetUsedYieldFlagCombinations()
reset all yieldsurfaces as unused
Definition: YieldSurfaceCombinationManager.h:90
Marmot::NumericalAlgorithms::YieldSurfaceCombinationManager::YieldSurfResArr
Eigen::Array< double, 1, nYieldSurfaces > YieldSurfResArr
An array to carry values of yield functions.
Definition: YieldSurfaceCombinationManager.h:47
Marmot::NumericalAlgorithms::YieldSurfaceCombinationManager::idxUsedFlag
const int idxUsedFlag
Column in the YieldSurfFlagArr for marking a combination as used.
Definition: YieldSurfaceCombinationManager.h:39