def damage(eps_eqv, mesh, E, f_t, G_f): h_cb = ufl.CellVolume(mesh) ** (1 / 3) eps0 = f_t / E eps_f = G_f / 1.0e+6 / (f_t * h_cb) + eps0 / 2 dmg = ufl.Min(1.0 - eps0 / eps_eqv * ufl.exp(- (eps_eqv - eps0) / (eps_f - eps0)), 1.0 - dmg_eps) return ufl.conditional(eps_eqv <= eps0, 0.0, 0.0 if args.damage_off else dmg)
def CellVolume(mesh: cpp.mesh.Mesh) -> ufl.CellVolume: """Return symbolic cell volume for given mesh. *Example of usage* .. code-block:: python mesh = UnitSquare(4,4) vol = CellVolume(mesh) """ return ufl.CellVolume(mesh.ufl_domain())
def CellVolume(mesh): """Return symbolic cell volume for given mesh. *Arguments* mesh a :py:class:`Mesh <dolfin.cpp.Mesh>`. *Example of usage* .. code-block:: python mesh = UnitSquare(4,4) vol = CellVolume(mesh) """ return ufl.CellVolume(_mesh2domain(mesh))
def CellVolume(mesh): # TODO: Remove this when we can pass mesh directly to ufl.CellVolume """ Return cell volume function for given mesh. *Arguments* mesh a :py:class:`Mesh <dolfin.cpp.Mesh>`. *Example of usage* .. code-block:: python mesh = UnitSquare(4,4) vol = CellVolume(mesh) """ return ufl.CellVolume(ufl.as_domain(mesh))
def get_areas2d(mesh, python=False): """ Computes the area of each cell in a 2D triangular mesh :arg mesh: the input mesh to do computations on :kwarg python: compute the measure using Python? :rtype: firedrake.function.Function areas with area data """ P0 = firedrake.FunctionSpace(mesh, "DG", 0) if python: areas = firedrake.interpolate(ufl.CellVolume(mesh), P0) else: coords = mesh.coordinates areas = firedrake.Function(P0) op2.par_loop( get_pyop2_kernel("get_area", 2), mesh.cell_set, areas.dat(op2.WRITE, areas.cell_node_map()), coords.dat(op2.READ, coords.cell_node_map()), ) return areas
def get_volumes3d(mesh, python=False): """ Computes the volume of each cell in a 3D tetrahedral mesh :arg mesh: the input mesh to do computations on :kwarg python: compute the measure using Python? :rtype: firedrake.function.Function volumes with volume data """ P0 = firedrake.FunctionSpace(mesh, "DG", 0) if python: volumes = firedrake.interpolate(ufl.CellVolume(mesh), P0) else: coords = mesh.coordinates volumes = firedrake.Function(P0) op2.par_loop( get_pyop2_kernel("get_volume", 3), mesh.cell_set, volumes.dat(op2.WRITE, volumes.cell_node_map()), coords.dat(op2.READ, coords.cell_node_map()), ) return volumes
def CellSize(mesh): """A symbolic representation of the cell size of a mesh. :arg mesh: the mesh for which to calculate the cell size. """ return ufl.CellVolume(mesh)