17void ElasticityOperator::Init()
20 fec =
new H1_FECollection(order,
dim);
25 auto ref_func = [](
const Vector & x, Vector & y) { y = x; };
26 VectorFunctionCoefficient ref_cf(
dim,ref_func);
27 ParGridFunction xr(fes); xr.ProjectCoefficient(ref_cf);
33void ElasticityOperator::SetEssentialBC()
41 Array<int> ess_tdof_list_temp;
42 for (
int i = 0; i < ess_bdr_attr.
Size(); i++ )
44 ess_bdr[ess_bdr_attr[i]-1] = 1;
46 ess_tdof_list.
Append(ess_tdof_list_temp);
47 ess_bdr[ess_bdr_attr[i]-1] = 0;
51void ElasticityOperator::SetUpOperator()
53 x.SetSpace(fes); x = 0.0;
54 b =
new ParLinearForm(fes);
57 material_model =
new NeoHookeanModel(c1_cf, c2_cf);
58 op =
new ParNonlinearForm(fes);
59 dynamic_cast<ParNonlinearForm*
>(op)->AddDomainIntegrator(
60 new HyperelasticNLFIntegrator(material_model));
61 dynamic_cast<ParNonlinearForm*
>(op)->SetEssentialTrueDofs(ess_tdof_list);
65 op =
new ParBilinearForm(fes);
66 dynamic_cast<ParBilinearForm*
>(op)->AddDomainIntegrator(
67 new ElasticityIntegrator(c1_cf,c2_cf));
68 K =
new HypreParMatrix();
69 dynamic_cast<ParBilinearForm*
>(op)->Assemble();
70 dynamic_cast<ParBilinearForm*
>(op)->FormSystemMatrix(ess_tdof_list,*K);
77 : nonlinear(nonlinear_), pmesh(pmesh_), ess_bdr_attr(ess_bdr_attr_),
78 ess_bdr_attr_comp(ess_bdr_attr_comp_)
88 MFEM_VERIFY(E.
Size() == n,
"Incorrect parameter size E");
89 MFEM_VERIFY(nu.
Size() == n,
"Incorrect parameter size nu");
94 for (
int i = 0; i<n; i++)
96 c1(i) = 0.5*E(i) / (1+nu(i));
97 c2(i) = E(i)/(1.0-2.0*nu(i))/3.0;
102 for (
int i = 0; i<n; i++)
104 c1(i) = E(i) * nu(i) / ( (1+nu(i)) * (1-2*nu(i)) );
105 c2(i) = 0.5 * E(i)/(1+nu(i));
124 x.ProjectBdrCoefficient(delta_cf,essbdr);
139 dynamic_cast<ParBilinearForm*
>(op)->ParallelEliminateTDofsInRHS(ess_tdof_list,
210 if (material_model) {
delete material_model; }
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
A coefficient that is constant across space and time.
ElasticityOperator(ParMesh *pmesh_, Array< int > &ess_bdr_attr_, Array< int > &ess_bdr_attr_comp_, const Vector &E, const Vector &nu, bool nonlinear_=false)
Construct an ElasticityOperator.
void FormLinearSystem()
Assemble and form the linear system (matrix and RHS).
void UpdateRHS()
Reset and reassemble the RHS linear form.
void SetNeumanPressureData(ConstantCoefficient &f, Array< int > &bdr_marker)
Apply Neumann (pressure) boundary condition on a set of boundary markers.
~ElasticityOperator()
Destructor (cleans up FE space, operator, and material model).
void GetGradient(const Vector &u, Vector &gradE) const
Compute the gradient of the energy functional at a given displacement vector.
void SetParameters(const Vector &E, const Vector &nu)
Set material parameters from vectors of Young’s modulus (E) and Poisson’s ratio (ν).
HypreParMatrix * GetHessian(const Vector &u)
Get the Hessian (stiffness matrix) at a given displacement vector.
virtual void Mult(const Vector &U, Vector &Y) const override
Compute the residual Y = R(U) representing the elasticity equation with a material model chosen by ca...
void SetDisplacementDirichletData(const Vector &delta, Array< int > essbdr)
Apply Dirichlet (displacement) boundary condition on a set of boundary markers.
real_t GetEnergy(const Vector &u) const
Compute the elastic energy functional at a given displacement vector.
Wrapper for hypre's ParCSR matrix class.
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y, real_t alpha=1.0, real_t beta=0.0) const
Computes y = alpha * A * x + beta * y.
A class to initialize the size of a Tensor.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
int Dimension() const
Dimension of the reference space used within the elements.
Array< int > attributes
A list of all unique element attributes used by the Mesh.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
void UpdateConstants(Vector &c)
Update the constants with vector c.
void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const override
HYPRE_BigInt GlobalTrueVSize() const
int GetTrueVSize() const override
Return the number of local vector true dofs.
Class for parallel grid function.
void SetFromTrueDofs(const Vector &tv) override
Set the GridFunction from the given true-dof vector.
Class for parallel meshes.
void SetNodalFESpace(FiniteElementSpace *nfes) override
Vector coefficient that is constant in space and time.
void SetSubVector(const Array< int > &dofs, const real_t value)
Set the entries listed in dofs to the given value.
int Size() const
Returns the size of the vector.
void SetSize(int s)
Resize the vector to size s.
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va
real_t u(const Vector &xvec)
real_t InnerProduct(HypreParVector *x, HypreParVector *y)
std::function< real_t(const Vector &)> f(real_t mass_coeff)