12#ifndef MFEM_MTOP_SOLVERS_HPP
13#define MFEM_MTOP_SOLVERS_HPP
40 constexpr auto Lambda = [](
const real_t E,
const real_t nu)
42 return E * nu / (1.0 + nu) / (1.0 - 2.0 * nu);
44 return Lambda(EE, nn);
67 constexpr auto Shear = [](
const real_t E,
const real_t nu)
69 return E / (2.0 * (1.0 + nu));
87 bool pa =
false,
bool dfem =
false);
121 if (spaceDim == 3) { vec[2] = fz; }
123 if (load_coeff.find(
id) != load_coeff.end()) {
delete load_coeff[id]; }
130 surf_loads[id] = &ff;
189 delete bf; bf=
nullptr;
219 const int dim, spaceDim;
249 std::unique_ptr<mfem::Solver> lor_pa_prec;
250 std::unique_ptr<mfem::ParLORDiscretization> lor_disc;
251 std::unique_ptr<mfem::ElasticityIntegrator> lor_integrator;
252 std::unique_ptr<mfem::ParFiniteElementSpace> lor_scalar_fespace;
253 std::unique_ptr<mfem::BlockDiagonalPreconditioner> lor_blockDiag;
254 std::vector<std::unique_ptr<mfem::ParBilinearForm>> lor_bilinear_forms;
255 std::vector<std::unique_ptr<mfem::HypreParMatrix>> lor_block;
256 std::vector<std::unique_ptr<mfem::HypreBoomerAMG>> lor_amg_blocks;
265 using VectorCoefficientPtrMap = std::map<int, mfem::VectorCoefficient *>;
266 VectorCoefficientPtrMap load_coeff;
267 VectorCoefficientPtrMap surf_loads;
270 std::unique_ptr<SurfaceLoad> lcsurf_load;
271 std::unique_ptr<SurfaceLoad> glsurf_load;
274 using ConstantCoefficientMap = std::map<int, mfem::ConstantCoefficient>;
275 ConstantCoefficientMap bcx, bcy, bcz;
278 using CoefficientPtrMap = std::map<int, mfem::Coefficient *>;
279 CoefficientPtrMap bccx, bccy, bccz;
289 std::unique_ptr<mfem::OperatorHandle> Kh;
290 std::unique_ptr<mfem::HypreParMatrix> K, Ke;
296 static constexpr int U = 0, Coords = 1, LCoeff = 2, MuCoeff = 3;
303 NqptUniformParameterSpace Lambda_ps, Mu_ps;
304 std::unique_ptr<mfem::CoefficientVector> Lambda_cv, Mu_cv;
305 std::unique_ptr<mfem::future::DifferentiableOperator> dop;
312 VectorCoefficientPtrMap *map;
314 SurfaceLoad(
int dim, VectorCoefficientPtrMap &cmap):
327 if (it != map->end()) { it->second->Eval(V, T, ip); }
The IsoElasticityLambdaCoeff class converts E modulus of elasticity and Poisson's ratio to Lame's lam...
IsoElasticityLambdaCoeff(mfem::Coefficient *E, mfem::Coefficient *nu)
Constructor - takes as inputs E modulus and Poisson's ratio.
real_t Eval(mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip) override
Evaluates the Lame's lambda coefficient.
The IsoElasticityShearCoeff class converts E modulus of elasticity and Poisson's ratio to Shear coeff...
real_t Eval(mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip) override
Evaluates the shear coefficient.
IsoElasticityShearCoeff(mfem::Coefficient *E_, mfem::Coefficient *nu_)
Constructor - takes as inputs E modulus and Poisson's ratio.
The IsoLinElasticSolver class provides a solver for linear isotropic elasticity. The solver provides ...
void SetEssTDofs(mfem::Vector &bsol, mfem::Array< int > &ess_dofs)
void AddDispBC(int id, int dir, real_t val)
Adds displacement BC in direction 0(x), 1(y), 2(z), or -1(all).
mfem::Vector & GetAdjointSolutionVector()
Returns the adjoint solution vector.
void FSolve()
Solves the forward problem.
void SetVolForce(real_t fx, real_t fy, real_t fz=0.0)
Set the values of the volumetric force.
void Mult(const mfem::Vector &x, mfem::Vector &y) const override
Forward solve with given RHS. x is the RHS vector.
void SetMaterial(mfem::Coefficient &E_, mfem::Coefficient &nu_)
Set material.
void GetAdj(mfem::ParGridFunction &agf)
Returns the adjoint displacements.
mfem::ParGridFunction & GetDisplacements()
Returns the displacements.
void GetSol(mfem::ParGridFunction &sgf)
Returns the displacements.
void SetLinearSolver(real_t rtol=1e-8, real_t atol=1e-12, int miter=200)
void AddSurfLoad(int id, real_t fx, real_t fy, real_t fz=0.0)
Add surface load.
IsoLinElasticSolver(mfem::ParMesh *mesh, int vorder=1, bool pa=false, bool dfem=false)
mfem::Vector & GetSolutionVector()
Returns the solution vector.
~IsoLinElasticSolver()
Destructor of the solver.
mfem::ParGridFunction & GetADisplacements()
Returns the adjoint displacements.
void AddSurfLoad(int id, mfem::VectorCoefficient &ff)
Add surface load.
void MultTranspose(const mfem::Vector &x, mfem::Vector &y) const override
void DelDispBC()
Clear all displacement BC.
Conjugate gradient method.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
Square Operator for imposing essential boundary conditions using only the action, Mult(),...
int nqpt
Number of quadrature points. When mode is TENSOR, this is the 1D number.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Abstract class for all finite elements.
The BoomerAMG solver in hypre.
Class for integration point with weight.
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract parallel finite element space.
Class for parallel grid function.
void SetFromTrueDofs(const Vector &tv) override
Set the GridFunction from the given true-dof vector.
void SetSpace(FiniteElementSpace *f) override
Associate a new FiniteElementSpace with the ParGridFunction.
Class for parallel meshes.
Class representing the storage layout of a QuadratureFunction.
Base class for vector Coefficients that optionally depend on time and space.
int GetVDim()
Returns dimension of the vector.
VectorCoefficient(int vd)
Initialize the VectorCoefficient with vector dimension vd.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
Vector coefficient that is constant in space and time.
void SetSize(int s)
Resize the vector to size s.
std::array< int, NCMesh::MaxFaceNodes > nodes