def CellSize(mesh): """A symbolic representation of the cell size of a mesh. :arg mesh: the mesh for which to calculate the cell size. """ mesh.init() return 2.0 * ufl.Circumradius(mesh)
def adaptform_OLD(form, mesh, adapt_coefficients=False): oldmesh = form.domain().data() if (oldmesh.id() == mesh.id()): return form # define new domain newdomain = mesh.ufl_domain() # adapt meshfunctions newsubdata = form.subdomain_data().values()[0] # assuming single domain for k, meshfunction in newsubdata.items(): newsubdata[k] = adaptmeshfunction(meshfunction, mesh) # replace domain, meshfunctions in integrals integrals = [] for itg in form.integrals(): newitg = itg.reconstruct( domain=newdomain, subdomain_data=newsubdata[itg.integral_type()]) integrals.append(newitg) newform = ufl.Form(integrals) # replace arguments and coefficients in form mapping = {} # adapt arguments for argument in form.arguments(): newargument = adaptargument(argument, mesh) mapping[argument] = newargument if (adapt_coefficients): # adapt coefficients for coeff in form.coefficients(): adaptcoefficient(coeff, mesh) #MOD #newcoeff = adaptcoefficient(coeff,mesh) #mapping[coeff] = newcoeff # TODO: is there more? is there a better way to ensure everything is adapted? # adapt FacetNormal mapping[FacetNormal(oldmesh)] = FacetNormal(mesh) # adapt CellSize -- have to use ufl.Circumradius or replace() complains mapping[ufl.Circumradius(oldmesh)] = ufl.Circumradius(mesh) newform = replace(newform, mapping) return newform
def Circumradius(mesh: cpp.mesh.Mesh) -> ufl.Circumradius: """Return symbolic cell circumradius for given mesh. *Example of usage* .. code-block:: python mesh = UnitSquare(4,4) R = Circumradius(mesh) """ return ufl.Circumradius(mesh.ufl_domain())
def Circumradius(mesh): """Return symbolic cell circumradius for given mesh. *Arguments* mesh a :py:class:`Mesh <dolfin.cpp.Mesh>`. *Example of usage* .. code-block:: python mesh = UnitSquare(4,4) R = Circumradius(mesh) """ return ufl.Circumradius(_mesh2domain(mesh))
def CellSize(mesh): """Return function cell size for given mesh. *Arguments* mesh a :py:class:`Mesh <dolfin.cpp.Mesh>`. *Example of usage* .. code-block:: python mesh = UnitSquare(4,4) h = CellSize(mesh) """ return 2.0 * ufl.Circumradius(_mesh2domain(mesh))
def CellSize(mesh): mesh.init() return 2.0 * ufl.Circumradius(mesh)