[dune-fem] Extraction and modification of DoF for Dune::AdaptiveDiscreteFunction

Sacconi, Andrea a.sacconi11 at imperial.ac.uk
Tue May 29 13:14:12 CEST 2012


Hi everyone,

I have some questions about how to manage the degrees of freedom for a Dune::AdaptiveDiscreteFunction < DiscreteFunctionSpaceImp > instance.

1) Suppose I need to set all the DoF to 1; how can I do?
I tried in this way:

const DiscreteFunctionType::DofIteratorType end = function.dend();
int count_dof = 0;
        for( DiscreteFunctionType::DofIteratorType it = function.dbegin(); it != end; ++it )
        {
            count_dof += 1;
            std::cout << "D.o.f. " << count_dof << "-th: " << (* it) << "." << std::endl;
            (* it) = 1.;
        }

but I notice that for a P1 Lagrange, scalar function the counter "count_dof" arrives to 162 or similar, and not to 3, as I may expect.
Where am I wrong?

I tried something with the method leakPointer (which "returns pointer to underlying array") but I got a compilation error.
Any ideas?

2) suppose I want to set to 1 the dof corresponding to the constant basis function, and 0 all the others.
Which is the dof corresponding to the constant basis function? How can I access it?

3) suppose I need to build a matrix, obtained by an outer (or tensor) product of two vectors, representing the dof of two scalar functions. Is it possible to do it directly?
Or do I have to initialise a matrix with right dimensions, and then, entry by entry, perform the outer product extracting the right components from the two vectors (here question 1 is crucial!)?

Many thanks for your help!

Andrea

__________________________________________________________

Andrea Sacconi
PhD student, Applied Mathematics
AMMP Section, Department of Mathematics, Imperial College London,
London SW7 2AZ, UK
a.sacconi11 at imperial.ac.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dune-project.org/pipermail/dune-fem/attachments/20120529/1cafb1e3/attachment.htm>


More information about the dune-fem mailing list