GEOS
PhaseFieldFractureSolver.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
21 #ifndef GEOS_PHYSICSSOLVERS_MULTIPHYSICS_PHASEFIELDFRACTURESOLVER_HPP_
22 #define GEOS_PHYSICSSOLVERS_MULTIPHYSICS_PHASEFIELDFRACTURESOLVER_HPP_
23 
27 
28 namespace geos
29 {
30 
31 class PhaseFieldFractureSolver : public CoupledSolver< SolidMechanicsLagrangianFEM, PhaseFieldDamageFEM >
32 {
33 public:
34 
36  using Base::m_solvers;
37  using Base::m_dofManager;
38  using Base::m_localMatrix;
39  using Base::m_rhs;
40  using Base::m_solution;
41 
47  PhaseFieldFractureSolver( const string & name,
48  Group * const parent );
49 
51  ~PhaseFieldFractureSolver() override = default;
52 
57  static string catalogName()
58  {
59  return "PhaseFieldFracture";
60  }
64  string getCatalogName() const override { return catalogName(); }
65 
67  static string coupledSolverAttributePrefix() { return "PhaseFieldFracture"; }
68 
69  enum class SolverType : integer
70  {
71  SolidMechanics = 0,
72  Damage = 1
73  };
74 
75  virtual void postInputInitialization() override final;
76 
82  {
83  return std::get< toUnderlying( SolverType::SolidMechanics ) >( m_solvers );
84  }
85 
91  {
92  return std::get< toUnderlying( SolverType::Damage ) >( m_solvers );
93  }
94 
95  virtual void mapSolutionBetweenSolvers( DomainPartition & domain, integer const solverType ) override final;
96 
97 protected:
98 
99  virtual void initializePostInitialConditionsPreSubGroups() override final {}
100 
101 private:
102 
107  void mapDamageToQuadrature( DomainPartition & domain );
108 
109 };
110 
111 
112 template< typename FE_TYPE >
114 {
115  DamageInterpolationKernel( CellElementSubRegion const & subRegion ):
116  m_numElems( subRegion.size() )
117  {}
118 
119  void interpolateDamageAndGradient( arrayView2d< localIndex const, cells::NODE_MAP_USD > const elemToNodes,
121  arrayView1d< real64 const > const nodalDamage,
122  arrayView2d< real64 > damageFieldOnMaterial,
123  arrayView3d< real64 > damageGradOnMaterial )
124  {
125  forAll< parallelDevicePolicy<> >( m_numElems, [=] GEOS_HOST_DEVICE ( localIndex const k )
126  {
127  constexpr localIndex numNodesPerElement = FE_TYPE::numNodes;
128  constexpr localIndex n_q_points = FE_TYPE::numQuadraturePoints;
129 
130  real64 xLocal[ numNodesPerElement ][ 3 ];
131  real64 nodalDamageLocal[ numNodesPerElement ];
132 
133  for( localIndex a = 0; a < numNodesPerElement; ++a )
134  {
135  localIndex const localNodeIndex = elemToNodes( k, a );
136 
137  for( int dim=0; dim < 3; ++dim )
138  {
139  xLocal[a][dim] = xNodes[ localNodeIndex ][dim];
140  }
141 
142  nodalDamageLocal[ a ] = nodalDamage[ localNodeIndex ];
143  }
144 
145  for( localIndex q = 0; q < n_q_points; ++q )
146  {
147  real64 N[ numNodesPerElement ];
148  FE_TYPE::calcN( q, N );
149 
150  real64 dNdX[ numNodesPerElement ][ 3 ];
151  real64 const detJ = FE_TYPE::calcGradN( q, xLocal, dNdX );
152 
153  GEOS_UNUSED_VAR( detJ );
154 
155  real64 qDamage = 0.0;
156  real64 qDamageGrad[3] = {0, 0, 0};
157  finiteElement::feOps::valueAndGradient( N, dNdX, nodalDamageLocal, qDamage, qDamageGrad );
158 
159  damageFieldOnMaterial( k, q ) = qDamage;
160 
161  for( int dim=0; dim < 3; ++dim )
162  {
163  damageGradOnMaterial[k][q][dim] = qDamageGrad[dim];
164  }
165  }
166 
167  } );
168  }
169 
170  localIndex m_numElems;
171 };
172 
173 } /* namespace geos */
174 
175 #endif /* GEOS_PHYSICSSOLVERS_MULTIPHYSICS_PHASEFIELDFRACTURESOLVER_HPP_ */
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
std::tuple< SOLVERS *... > m_solvers
Pointers of the single-physics solvers.
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
SolidMechanicsLagrangianFEM * solidMechanicsSolver() const
accessor for the pointer to the solid mechanics solver
static string coupledSolverAttributePrefix()
String used to form the solverName used to register solvers in CoupledSolver.
virtual void postInputInitialization() override final
PhaseFieldDamageFEM * damageSolver() const
accessor for the pointer to the damage solver
PhaseFieldFractureSolver(const string &name, Group *const parent)
main constructor for PhaseFieldFractureSolver objects
virtual void initializePostInitialConditionsPreSubGroups() override final
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
~PhaseFieldFractureSolver() override=default
Destructor for the class.
static string catalogName()
name of the solver in the object catalog
virtual void mapSolutionBetweenSolvers(DomainPartition &domain, integer const solverType) override final
Maps the solution obtained from one solver to the fields used by the other solver(s)
CRSMatrix< real64, globalIndex > m_localMatrix
Local system matrix and rhs.
DofManager m_dofManager
Data structure to handle degrees of freedom.
ParallelVector m_solution
System solution vector.
ParallelVector m_rhs
System right-hand side vector.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Definition: Group.hpp:1315
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:195
int integer
Signed integer type.
Definition: DataTypes.hpp:81
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Definition: DataTypes.hpp:211