On 13 September 2011 14:47, Anders Logg <[email protected]> wrote: > On Tue, Sep 13, 2011 at 02:40:04PM +0100, Garth N. Wells wrote: >> On 13 September 2011 14:31, Anders Logg <[email protected]> wrote: >> > Why was this changed? I thought we had agreed that (in C++), functions >> > that return data should be >> > >> > [const] Foo& foo() [const]; >> > >> > and in addition we offer >> > >> > boost::shared_ptr<[const] Foo> foo_shared_ptr() [const]; >> > >> >> I thought that we agreed to use a single function in place of two for >> low-level library functions to: >> >> - reduce the amount of code >> - avoid possible memory errors >> - avoid the need to ignore functions in the swig interface (which has >> been a source of bugs). > > Agree, in all places except a few that are most often exposed to > users. > >> I advocate the shared_ptr interface over extra work and complicated >> memory issues. I don't see an advantage to a reference version in >> parts of the code that only advanced users will see. > > Me neither, but isn't FunctionSpace::mesh() one of the more basic > calls that many users will see, like Function::vector(), > Function::function_space() and the like? >
Keeping a reference version for Function::vector() I agree with. I don't believe that many users are exposed to FunctionSpace::mesh(). In simple usage cases the user has the original mesh that was used to create a FunctionSpace in scope and readily accessible. If they don't have it in scope, then they're in trouble anyway with the simple interface because the FunctionSpace will have a dangling pointer to a Mesh. FunctionSpace::mesh(), unlike Function::vector(), is not exposed in any of the C++ demos. Garth > -- > Anders > > >> Garth >> >> > And in the Python interface, we ignore foo and map foo_shared_ptr to >> > foo. >> > >> > Accessing the mesh is very handy from C++ and this change will force >> > users of the C++ interface to use shared pointers which I think >> > should be optional. >> > >> > >> > >> > ---------- Forwarded message ---------- >> > From: [email protected] >> > To: Anders Logg <[email protected]> >> > Date: Tue, 13 Sep 2011 12:05:16 -0000 >> > Subject: [Branch ~dolfin-core/dolfin/main] Rev 6190: Return shared_ptr for >> > Mesh from FunctionSpace and regenerate form files. >> > ------------------------------------------------------------ >> > revno: 6190 >> > committer: Garth N. Wells <[email protected]> >> > branch nick: dolfin-main >> > timestamp: Tue 2011-09-13 12:34:53 +0100 >> > message: >> > Return shared_ptr for Mesh from FunctionSpace and regenerate form files. >> > modified: >> > bench/fem/assembly/cpp/forms/Elasticity3D.h >> > bench/fem/assembly/cpp/forms/NSEMomentum3D.h >> > bench/fem/assembly/cpp/forms/Poisson2DP1.h >> > bench/fem/assembly/cpp/forms/Poisson2DP2.h >> > bench/fem/assembly/cpp/forms/Poisson2DP3.h >> > bench/fem/assembly/cpp/forms/StabStokes2D.h >> > bench/fem/assembly/cpp/forms/THStokes2D.h >> > bench/fem/convergence/cpp/forms/Poisson2D_1.h >> > bench/fem/convergence/cpp/forms/Poisson2D_2.h >> > bench/fem/convergence/cpp/forms/Poisson2D_3.h >> > bench/fem/convergence/cpp/forms/Poisson2D_4.h >> > bench/fem/convergence/cpp/forms/Poisson2D_5.h >> > bench/fem/convergence/cpp/forms/Poisson3D_1.h >> > bench/fem/convergence/cpp/forms/Poisson3D_2.h >> > bench/fem/convergence/cpp/forms/Poisson3D_3.h >> > bench/fem/convergence/cpp/forms/Poisson3D_4.h >> > bench/fem/convergence/cpp/forms/Poisson3D_5.h >> > bench/fem/multicore/cpp/NavierStokes.h >> > bench/fem/multicore/cpp/Poisson.h >> > bench/fem/speedup/cpp/Poisson.h >> > bench/function/evaluation/cpp/P1.h >> > demo/la/eigenvalue/cpp/StiffnessMatrix.h >> > demo/pde/biharmonic/cpp/Biharmonic.h >> > demo/pde/cahn-hilliard/cpp/CahnHilliard2D.cpp >> > demo/pde/cahn-hilliard/cpp/CahnHilliard2D.h >> > demo/pde/cahn-hilliard/cpp/CahnHilliard3D.cpp >> > demo/pde/cahn-hilliard/cpp/CahnHilliard3D.h >> > demo/pde/hyperelasticity/cpp/HyperElasticity.h >> > demo/pde/mixed-poisson/cpp/MixedPoisson.h >> > demo/pde/navier-stokes/cpp/PressureUpdate.h >> > demo/pde/navier-stokes/cpp/TentativeVelocity.h >> > demo/pde/navier-stokes/cpp/VelocityUpdate.h >> > demo/pde/poisson/cpp/Poisson.h >> > demo/pde/stokes-iterative/cpp/Stokes.h >> > demo/pde/stokes-iterative/cpp/StokesPreconditioner.h >> > demo/undocumented/advection-diffusion/cpp/AdvectionDiffusion.h >> > demo/undocumented/advection-diffusion/cpp/Velocity.h >> > demo/undocumented/assembly/cpp/ReactionDiffusion.h >> > demo/undocumented/auto-adaptive-navier-stokes/cpp/AdaptiveNavierStokes.h >> > demo/undocumented/auto-adaptive-poisson/cpp/AdaptivePoisson.h >> > demo/undocumented/bcs/cpp/Poisson.h >> > demo/undocumented/block-matrix/cpp/StiffnessMatrix.h >> > demo/undocumented/conditional/cpp/Conditional.h >> > demo/undocumented/curl-curl/cpp/CurrentDensity.h >> > demo/undocumented/curl-curl/cpp/EddyCurrents.h >> > demo/undocumented/dg-advection-diffusion/cpp/AdvectionDiffusion.h >> > demo/undocumented/dg-advection-diffusion/cpp/Projection.h >> > demo/undocumented/dg-advection-diffusion/cpp/Velocity.h >> > demo/undocumented/dg-poisson/cpp/Poisson.h >> > demo/undocumented/elasticity/cpp/Elasticity.h >> > demo/undocumented/elastodynamics/cpp/DG0_eps_xx.h >> > demo/undocumented/elastodynamics/cpp/ElastoDynamics.h >> > demo/undocumented/eval/cpp/Projection.h >> > demo/undocumented/extrapolation/cpp/P1.h >> > demo/undocumented/extrapolation/cpp/P2.h >> > demo/undocumented/functional/cpp/EnergyNorm.h >> > demo/undocumented/lift-drag/cpp/Drag.h >> > demo/undocumented/lift-drag/cpp/Lift.h >> > demo/undocumented/lift-drag/cpp/Pressure.h >> > demo/undocumented/neumann-poisson/cpp/Poisson.h >> > demo/undocumented/nonlinear-poisson/cpp/NonlinearPoisson.h >> > demo/undocumented/nonmatching-interpolation/cpp/P1.h >> > demo/undocumented/nonmatching-interpolation/cpp/P3.h >> > demo/undocumented/nonmatching-projection/cpp/P1_projection.h >> > demo/undocumented/nonmatching-projection/cpp/P3.h >> > demo/undocumented/periodic/cpp/Poisson.h >> > demo/undocumented/poisson1D/cpp/Poisson.h >> > demo/undocumented/reaction-diffusion/cpp/ReactionDiffusion.h >> > demo/undocumented/simple/cpp/MassMatrix3D.h >> > demo/undocumented/simple/cpp/StiffnessMatrix3D.h >> > demo/undocumented/spatial-coordinates/cpp/SpatialCoordinates.h >> > demo/undocumented/stokes-stabilized/cpp/Stokes.h >> > demo/undocumented/stokes-taylor-hood/cpp/Stokes.h >> > demo/undocumented/sym-dirichlet-bc/cpp/Poisson.h >> > demo/undocumented/waveguide/cpp/Forms.h >> > dolfin/adaptivity/ErrorControl.cpp >> > dolfin/adaptivity/Extrapolation.cpp >> > dolfin/adaptivity/GenericAdaptiveVariationalSolver.cpp >> > dolfin/adaptivity/adapt.cpp >> > dolfin/ale/Poisson1D.h >> > dolfin/ale/Poisson2D.h >> > dolfin/ale/Poisson3D.h >> > dolfin/fem/BoundaryCondition.cpp >> > dolfin/fem/DirichletBC.cpp >> > dolfin/fem/Form.cpp >> > dolfin/fem/PeriodicBC.cpp >> > dolfin/fem/PointSource.cpp >> > dolfin/function/Function.cpp >> > dolfin/function/FunctionSpace.cpp >> > dolfin/function/FunctionSpace.h >> > dolfin/function/SubSpace.cpp >> > dolfin/io/RAWFile.cpp >> > dolfin/io/VTKFile.cpp >> > dolfin/io/VTKWriter.cpp >> > dolfin/io/XYZFile.cpp >> > dolfin/plot/plot.cpp >> > site-packages/dolfin_utils/wrappers/goalfunctional.py >> > test/unit/function/cpp/Projection.h >> > The size of the diff (167257 lines) is larger than your specified limit of >> > 1000 lines >> > >> > >> > Your team DOLFIN Core Team is subscribed to branch lp:dolfin. >> > To unsubscribe from this branch go to >> > https://code.launchpad.net/~dolfin-core/dolfin/main/+edit-subscription >> > >> > _______________________________________________ >> > Mailing list: https://launchpad.net/~dolfin >> > Post to : [email protected] >> > Unsubscribe : https://launchpad.net/~dolfin >> > More help : https://help.launchpad.net/ListHelp >> > >> > > _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : [email protected] Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp

