def solve(self): """Solve for and return the computed displacement field, u""" # Create solver formulation = self.parameters['solver_parameters']['problem_formulation'] if formulation == 'displacement': self.solver = StaticMomentumBalanceSolver_U(self, self.parameters["solver_parameters"]) elif formulation == 'mixed_up': self.solver = StaticMomentumBalanceSolver_UP(self, self.parameters['solver_parameters']) elif formulation == 'incompressible': self.solver = StaticMomentumBalanceSolver_Incompressible(self, self.parameters['solver_parameters']) # Call solver return self.solver.solve()
class StaticHyperelasticity(CBCProblem): """Base class for all static hyperelasticity problems""" def __init__(self): """Create the static hyperelasticity problem""" # Set up parameters self.parameters = Parameters("problem_parameters") self.parameters.add(solver_parameters()) def solve(self): """Solve for and return the computed displacement field, u""" # Create solver formulation = self.parameters['solver_parameters']['problem_formulation'] if formulation == 'displacement': self.solver = StaticMomentumBalanceSolver_U(self, self.parameters["solver_parameters"]) elif formulation == 'mixed_up': self.solver = StaticMomentumBalanceSolver_UP(self, self.parameters['solver_parameters']) elif formulation == 'incompressible': self.solver = StaticMomentumBalanceSolver_Incompressible(self, self.parameters['solver_parameters']) # Call solver return self.solver.solve() def body_force(self): """Return body force, B""" return [] def body_force_u(self, u): # FIXME: This is currently only implemented for the cG(1) solver """Return body force, B, depending on displacement u""" return [] def dirichlet_values(self): """Return Dirichlet boundary conditions for the displacment field""" return [] def dirichlet_boundaries(self): """Return boundaries over which Dirichlet conditions act""" return [] def neumann_conditions(self): """Return Neumann boundary conditions for the stress field""" return [] def neumann_boundaries(self): """Return boundaries over which Neumann conditions act""" return [] def material_model(self): pass def first_pk_stress(self, u): """Return the first Piola-Kirchhoff stress tensor, P, given a displacement field, u""" return self.material_model().FirstPiolaKirchhoffStress(u) def second_pk_stress(self, u): """Return the second Piola-Kirchhoff stress tensor, S, given a displacement field, u""" return self.material_model().SecondPiolaKirchhoffStress(u) def strain_energy(self, u): """Return the strain (potential) energy given a displacement field, u""" S = self.material_model().SecondPiolaKirchhoffStress(u) E = GreenLagrangeStrain(u) psi = assemble(0.5*inner(S, E)*dx, mesh=u.function_space().mesh()) return psi def functional(self, u): """Return value of goal functional""" return None def reference(self): """Return reference value for the goal functional""" return None def __str__(self): """Return a short description of the problem""" return "Static hyperelasticity problem"