Re: [Ffc] Status
On Wed, Jan 06, 2010 at 04:25:30PM +0100, Marie Rognes wrote: > Anders Logg wrote: > >We've come pretty far on the rewrite of FFC and only a few functions > >remain. As far as I can see, it remains to implement code generation > >for the following functions: > > > >Kristian: > > > > code["evaluate_basis_all"] = not_implemented > > code["evaluate_basis_derivatives"] = not_implemented > > code["evaluate_basis_derivatives_all"] = not_implemented > > > >Marie: > > > > code["tabulate_entity_dofs"] = not_implemented # Marie doesn't know what > > this function should do > > > Evidently, my comment was unclear ;) > > Should it look like this for CG_1? > > /// Tabulate the local-to-local mapping of dofs on entity (d, i) > virtual void tabulate_entity_dofs(unsigned int* dofs, >unsigned int d, unsigned int i) const > { > dofs[0] = i } Yes, this function should return an array of the dofs (dof indices) for the dofs associated with entity number i of dimension d. But perhaps we should check the d and the i as well to make sure that d == 0 and i <= d + 1? Here's another example of what should happen for P3 in 2D. switch (d) { case 0: if (i > 2) throw std::runtime_error("Sensible error message."); dofs[0] = i; case 1: if (i > 2) throw std::runtime_error("Sensible error message."); dofs[0] = 3 + 2*i; dofs[1] = 3 + 2*i + 1; case 2: if (i > 0) throw std::runtime_error("Sensible error message."); dofs[0] = 10; default: throw std::runtime_error("Sensible error message."); } The corresponding function num_entity_dofs should return the size of the dofs array for each dimension so it should return 0, 2 and 1 in the above case for d = 0, 1, 2. > > code["tabulate_coordinates"] = not_implemented # Marie doesn't believe in > > this function > > > > > What should this function do for the integral moment dofs, where > there are more than one point per dof? I guess we need to throw an exception and think about possibly extending the UFC interface with this extra information. -- Anders > >Marie or Kristian: > > > > code["interpolate_vertex_values"] = not_implemented > > > > Can fix. > > signature.asc Description: Digital signature ___ Mailing list: https://launchpad.net/~ffc Post to : ffc@lists.launchpad.net Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp
[Ffc] [nore...@launchpad.net: [Branch ~ffc-core/ffc/dev] Rev 1412: Implemented interpolate_vertex_values for scalar CG_1.]
Which ones need to be cleaned up? I'll be working on getting tabulate_tensor working. Let me know if I should help with the cleaning up. -- Anders --- Begin Message --- revno: 1412 committer: Marie E. Rognes branch nick: ffc-unstable timestamp: Thu 2010-01-07 14:16:49 +0100 message: Implemented interpolate_vertex_values for scalar CG_1. Time to do some clean-ups with regard to code generation utilities before continuing. modified: ffc/codegeneration.py ffc/fiatinterface.py ffc/representation.py -- lp:~ffc-core/ffc/dev https://code.launchpad.net/~ffc-core/ffc/dev You are subscribed to branch lp:~ffc-core/ffc/dev. To unsubscribe from this branch go to https://code.launchpad.net/~ffc-core/ffc/dev/+edit-subscription. === modified file 'ffc/codegeneration.py' --- ffc/codegeneration.py 2010-01-06 18:32:59 + +++ ffc/codegeneration.py 2010-01-07 13:16:49 + @@ -11,7 +11,7 @@ __copyright__ = "Copyright (C) 2009 " + __author__ __license__ = "GNU GPL version 3 or any later version" -# Last changed: 2010-01-06 +# Last changed: 2010-01-07 # FFC modules from ffc.log import begin, end, debug_code @@ -20,6 +20,7 @@ # FFC code generation modules from ffc.evaluatebasis import _evaluate_basis from ffc.evaluatedof import _evaluate_dof, _evaluate_dofs, affine_weights +from ffc.codesnippets import jacobian # FFC specialized code generation modules #from ffc.quadrature import generate_quadrature_integrals @@ -98,7 +99,7 @@ code["evaluate_basis_derivatives_all"] = not_implemented code["evaluate_dof"] = _evaluate_dof(ir["evaluate_dof"]) code["evaluate_dofs"] = _evaluate_dofs(ir["evaluate_dofs"]) -code["interpolate_vertex_values"] = not_implemented +code["interpolate_vertex_values"] = _interpolate_vertex_values(ir["interpolate_vertex_values"]) code["num_sub_elements"] = ret(ir["num_sub_elements"]) code["create_sub_element"] = _create_foo(ir["create_sub_element"], prefix, "finite_element") @@ -264,31 +265,64 @@ def _tabulate_coordinates(ir): +# Raise error if tabulate_coordinates is ill-defined if ir is None: return "// Raise error here" # Extract formats: -add = format["add"] -multiply = format["multiply"] +add, multiply = format["add"], format["multiply"] precision = format["float"] # Extract coordinates and cell dimension -coordinates = ir -cell_dim = len(coordinates[0]) +cell_dim = len(ir[0]) # Aid mapping points from reference to physical element coefficients = affine_weights(cell_dim) +# Generate code for each point and each component code = ["const double * const * x = c.coordinates;"] - -for (i, c) in enumerate(coordinates): -w = coefficients(c) +for (i, coordinate) in enumerate(ir): +w = coefficients(coordinate) for j in range(cell_dim): value = add([multiply([precision(w[k]), "x[%d][%d]" % (k, j)]) for k in range(cell_dim + 1)]) code += ["coordinates[%d][%d] = %s;" % (i, j, value)] return "\n".join(code) +def _interpolate_vertex_values(ir): + +code = [] + +# Add code for Jacobian if necessary +if ir["needs_jacobian"]: +code += [jacobian(ir["cell_dim"])] + +# Extract formats +add, multiply = format["add"], format["multiply"] +precision = format["float"] + +# Iterate over the elements +for (k, data) in enumerate(ir["element_data"]): + +# Extract vertex values for all basis functions +vertex_values = data["basis_values"] + +# Create code for each vertex +for j in range(len(vertex_values)): + +# Map basis values according to mapping +vertex_value = [precision(v) for v in vertex_values[j]] + +# Contract basis values and coefficients +value = add([multiply(["dof_values[%d]" % i, v]) + for (i, v) in enumerate(vertex_value)]) + +# Construct correct vertex value label +name = "vertex_values[%d]" % j +code += [name + " = " + value + ";"] + +return "\n".join(code) + #--- Utility functioins --- def _create_foo(numbers, prefix, class_name): === modified file 'ffc/fiatinterface.py' --- ffc/fiatinterface.py 2010-01-04 12:48:48 + +++ ffc/fiatinterface.py 2010-01-07 13:16:49 + @@ -5,7 +5,7 @@ # Modified by Garth N. Wells, 2009. # Modified by Marie Rognes, 2009-2010. -# Last changed: 2010-01-04 +# Last changed: 2010-01-07 # UFL modules from ufl import FiniteElement as UFLFiniteElement @@ -44,6 +44,11 @@ # Mapping from dimension to number of mesh sub-entities: entities_per_dim = {1: [2, 1], 2: [3, 3, 1], 3: [4, 6, 4, 1]} +def reference_cell(dim): +if isinstance(dim, int): +return ufc_simplex(dim) +else: +return ufc_simplex(domain2dim[dim]) def create_element(ufl_element): @@ -70,7 +75,7 @@
Re: [Ffc] Status
Anders Logg wrote: On Wed, Jan 06, 2010 at 04:25:30PM +0100, Marie Rognes wrote: Anders Logg wrote: We've come pretty far on the rewrite of FFC and only a few functions remain. As far as I can see, it remains to implement code generation for the following functions: Kristian: code["evaluate_basis_all"] = not_implemented code["evaluate_basis_derivatives"] = not_implemented code["evaluate_basis_derivatives_all"] = not_implemented Marie: code["tabulate_entity_dofs"] = not_implemented # Marie doesn't know what this function should do Evidently, my comment was unclear ;) Should it look like this for CG_1? /// Tabulate the local-to-local mapping of dofs on entity (d, i) virtual void tabulate_entity_dofs(unsigned int* dofs, unsigned int d, unsigned int i) const { dofs[0] = i } Yes, this function should return an array of the dofs (dof indices) for the dofs associated with entity number i of dimension d. But perhaps we should check the d and the i as well to make sure that d == 0 and i <= d + 1? Here's another example of what should happen for P3 in 2D. switch (d) { case 0: if (i > 2) throw std::runtime_error("Sensible error message."); dofs[0] = i; case 1: if (i > 2) throw std::runtime_error("Sensible error message."); dofs[0] = 3 + 2*i; dofs[1] = 3 + 2*i + 1; case 2: if (i > 0) throw std::runtime_error("Sensible error message."); dofs[0] = 10; default: throw std::runtime_error("Sensible error message."); } Ok! The corresponding function num_entity_dofs should return the size of the dofs array for each dimension so it should return 0, 2 and 1 in the above case for d = 0, 1, 2. Fixed already. code["tabulate_coordinates"] = not_implemented # Marie doesn't believe in this function What should this function do for the integral moment dofs, where there are more than one point per dof? I guess we need to throw an exception and think about possibly extending the UFC interface with this extra information. Will throw. -- Marie -- Anders Marie or Kristian: code["interpolate_vertex_values"] = not_implemented Can fix. ___ Mailing list: https://launchpad.net/~ffc Post to : ffc@lists.launchpad.net Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp
Re: [Ffc] [nore...@launchpad.net: [Branch ~ffc-core/ffc/dev] Rev 1412: Implemented interpolate_vertex_values for scalar CG_1.]
Anders Logg wrote: Which ones need to be cleaned up? I'll be working on getting tabulate_tensor working. Let me know if I should help with the cleaning up. I'm boldly throwing away anything that seems obsolete -- Marie -- Anders Subject: [Branch ~ffc-core/ffc/dev] Rev 1412: Implemented interpolate_vertex_values for scalar CG_1. From: nore...@launchpad.net Date: Thu, 07 Jan 2010 13:19:14 - To: Anders Logg To: Anders Logg revno: 1412 committer: Marie E. Rognes branch nick: ffc-unstable timestamp: Thu 2010-01-07 14:16:49 +0100 message: Implemented interpolate_vertex_values for scalar CG_1. Time to do some clean-ups with regard to code generation utilities before continuing. modified: ffc/codegeneration.py ffc/fiatinterface.py ffc/representation.py -- lp:~ffc-core/ffc/dev https://code.launchpad.net/~ffc-core/ffc/dev You are subscribed to branch lp:~ffc-core/ffc/dev. To unsubscribe from this branch go to https://code.launchpad.net/~ffc-core/ffc/dev/+edit-subscription. ___ Mailing list: https://launchpad.net/~ffc Post to : ffc@lists.launchpad.net Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~ffc Post to : ffc@lists.launchpad.net Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp
Re: [Ffc] Status
On Thu, Jan 07, 2010 at 03:04:35PM +0100, Marie Rognes wrote: > Anders Logg wrote: > >On Wed, Jan 06, 2010 at 04:25:30PM +0100, Marie Rognes wrote: > >>Anders Logg wrote: > >>>We've come pretty far on the rewrite of FFC and only a few functions > >>>remain. As far as I can see, it remains to implement code generation > >>>for the following functions: > >>> > >>>Kristian: > >>> > >>> code["evaluate_basis_all"] = not_implemented > >>> code["evaluate_basis_derivatives"] = not_implemented > >>> code["evaluate_basis_derivatives_all"] = not_implemented > >>> > >>>Marie: > >>> > >>> code["tabulate_entity_dofs"] = not_implemented # Marie doesn't know what > >>> this function should do > >>Evidently, my comment was unclear ;) > >> > >>Should it look like this for CG_1? > >> > >> /// Tabulate the local-to-local mapping of dofs on entity (d, i) > >> virtual void tabulate_entity_dofs(unsigned int* dofs, > >> unsigned int d, unsigned int i) const > >> { > >> dofs[0] = i } > > > >Yes, this function should return an array of the dofs (dof indices) for > >the dofs associated with entity number i of dimension d. > > > >But perhaps we should check the d and the i as well to make sure that > >d == 0 and i <= d + 1? > > > >Here's another example of what should happen for P3 in 2D. > > > > switch (d) > > { > > case 0: > >if (i > 2) > > throw std::runtime_error("Sensible error message."); > >dofs[0] = i; > > case 1: > >if (i > 2) > > throw std::runtime_error("Sensible error message."); > >dofs[0] = 3 + 2*i; > >dofs[1] = 3 + 2*i + 1; > > case 2: > >if (i > 0) > > throw std::runtime_error("Sensible error message."); > >dofs[0] = 10; > > default: > >throw std::runtime_error("Sensible error message."); > > } > > > > Ok! > > >The corresponding function num_entity_dofs should return the size of > >the dofs array for each dimension so it should return 0, 2 and 1 in > >the above case for d = 0, 1, 2. > > > > Fixed already. Nice! :-) -- Anders > >>> code["tabulate_coordinates"] = not_implemented # Marie doesn't believe in > >>> this function > >>> > >>What should this function do for the integral moment dofs, where > >>there are more than one point per dof? > > > >I guess we need to throw an exception and think about possibly extending the > >UFC interface with this extra information. > > > > Will throw. > > -- > Marie > > > >-- > >Anders > > > > > >>>Marie or Kristian: > >>> > >>> code["interpolate_vertex_values"] = not_implemented > >>> > >>Can fix. > >> > >> > signature.asc Description: Digital signature ___ Mailing list: https://launchpad.net/~ffc Post to : ffc@lists.launchpad.net Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp
Re: [Ffc] [nore...@launchpad.net: [Branch ~ffc-core/ffc/dev] Rev 1412: Implemented interpolate_vertex_values for scalar CG_1.]
On Thu, Jan 07, 2010 at 03:07:28PM +0100, Marie Rognes wrote: > Anders Logg wrote: > >Which ones need to be cleaned up? > > > >I'll be working on getting tabulate_tensor working. Let me know if I > >should help with the cleaning up. > > > > I'm boldly throwing away anything that seems obsolete Good! -- Anders signature.asc Description: Digital signature ___ Mailing list: https://launchpad.net/~ffc Post to : ffc@lists.launchpad.net Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp
Re: [Ffc] [Branch ~ffc-core/ffc/main] Rev 1332: Add new operators for the symbolics classes and rearrange unit tests for maintainability.
I haven't looked very closely at the symbolic stuff before, but it seems a bit strange to have so much symbolic classes in FFC when we have UFL as a symbolic backend. Could this functionality be added to UFL instead? -- Anders On Thu, Jan 07, 2010 at 05:48:17PM -, nore...@launchpad.net wrote: > > revno: 1332 > committer: Kristian B. Ølgaard > branch nick: ffc > timestamp: Thu 2010-01-07 18:45:09 +0100 > message: > Add new operators for the symbolics classes and rearrange unit tests for > maintainability. > removed: > test/unit/test_symbolics.py > added: > test/unit/symbolics/ > test/unit/symbolics/testdgelastodyn.py > test/unit/symbolics/testelasticity2d.py > test/unit/symbolics/testelasticityterm.py > test/unit/symbolics/testelasweighted.py > test/unit/symbolics/testelasweighted2.py > test/unit/symbolics/testexpandoperations.py > test/unit/symbolics/testfloat.py > test/unit/symbolics/testfloatoperators.py > test/unit/symbolics/testfraction.py > test/unit/symbolics/testfractionoperators.py > test/unit/symbolics/testmixedsymbols.py > test/unit/symbolics/testnotfinished.py > test/unit/symbolics/testpoisson.py > test/unit/symbolics/testproduct.py > test/unit/symbolics/testproductoperators.py > test/unit/symbolics/testrealexamples.py > test/unit/symbolics/testreducegip.py > test/unit/symbolics/testreduceoperations.py > test/unit/symbolics/testreducevartype.py > test/unit/symbolics/testsum.py > test/unit/symbolics/testsumoperators.py > test/unit/symbolics/testsymbol.py > test/unit/symbolics/testsymbolics.py > test/unit/symbolics/testsymboloperators.py > modified: > AUTHORS > ffc/log.py > ffc/quadrature/floatvalue.py > ffc/quadrature/fraction.py > ffc/quadrature/product.py > ffc/quadrature/sumobj.py > ffc/quadrature/symbol.py > test/unit/test.py > The size of the diff (6018 lines) is larger than your specified limit of 1000 > lines > signature.asc Description: Digital signature ___ Mailing list: https://launchpad.net/~ffc Post to : ffc@lists.launchpad.net Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp