Hi Kurt,

In some cases where we need to obtain derivatives at a boundary, it is useful to
define an expansion containing only the elements close to this boundary. We can
then calculate the derivatives using this expansion and extract the values
at the boundary. This expansion is what is refered in the code as BndElmtExp.
For example, in 2D with a mesh of quadrilateral elements, BndCondExp contains
the segments on the boundary while BndElmtExp contains the quads in contact with
these segments.

There are a few functions for working with BndElmtExp and BndCondExp:

- GetBndElmtExpansion(n, BndElmtExp, DeclareCoeffPhysArrays)
    This creates the BndElmtExp for boundary n. If DeclareCoeffPhysArrays is
    true the m_phys and m_coeffs of the field are extracted to the m_phys and 
    m_coeffs of BndElmtExp.

- ExtractPhysToBndElmt(n, phys, bndElmt)
    Given a phys array for the whole expansion, this extracts the value at
    the BndElmtExp for boundary n.
    
- ExtractElmtToBndPhys(n, element, boundary)
    This extracts values from BndElmtExp to the corresponding BndCondExp.
    
- ExtractPhysToBnd(n, phys, bnd)
    This extracts values from the whole expansion to BndCondExp.
    
I think the flowrate branch should be using ExtractPhysToBnd instead of
ExtractElmtToBndPhys. The idea in this case is to take the latest velocity
solution (in phys) and extract the values at the desired boundary (in bnd).

If you just want to take the values in physical space corresponding to the 
coefficients that are already in the BndCondExp (as your code suggests), you
could just perform a BwdTrans using something like:
    Array<OneD, Array<OneD, NekDouble> > boundary(m_spacedim);
    MultiRegions::ExpListSharedPtr  BndCondExp;
    for(int i = 0; i < m_spacedim; i++)
    {
        BndCondExp  = m_fields[i]->GetBndCondExpansions()[boundaryID];
        boundary[i] = Array<OneD, NekDouble> (BndCondExp->GetTotPoints());
        BndCondExp->BwdTrans(BndCondExp->GetCoeffs(), boundary[i]);
    }

Cheers,
Douglas

2017-08-14 14:07 GMT-03:00 Kurt Sansom <kayarre@gmail.com>:
Hi I am trying to understand the following operation.

void Nektar::MultiRegions::ExpList::ExtractElmtToBndPhys(int i,
ArrayOneDNekDouble > & elmt,
ArrayOneDNekDouble > & boundary 
)

however the documentation doesn't give it a description. I am trying evaluate the flow rate through a boundary and there is something similar in the feature/flowrate branch that uses this operation, but it is unclear to me what it is doing.

I believe it is extracting the physical values from a boundary and placing them in the boundary variable but I am not sure what the element array variable is for, can it be an empty array or does it need to be populated with something?

I am trying to do something like this.
 MultiRegions::ExpListSharedPtr  BndCondExp;
        BndCondExp   = m_fields[fldid]->GetBndCondExpansions()[bndid];
        Array<OneD, Array<OneD, NekDouble> > flux(m_spacedim);

        //m_fields[0]->GetBndElmtExpansion(n, BndElmtExp, false);

        // extract the boundary coefficients
        int i;
        for(i = 0; i < m_spacedim; i++)
        {
            flux[i] = m_fields[i]->GetBndCondExpansions()[boundaryID]->GetCoeffs();
        }

        NekDouble flowrate = 0.0;
        Array<OneD, Array<OneD, NekDouble> > boundary(m_spacedim);

        for (i = 0; i < m_spacedim; ++i)
        {
            m_fields[i]->ExtractElmtToBndPhys(
                bndid, flux[i], boundary[i]);
        }

        flowrate = BndCondExp->VectorFlux(boundary);
        m_comm->AllReduce(flowrate, LibUtilities::ReduceSum);

        flowrate = flowrate / m_RCParams[fldid][bndid]->m_FlowRateArea;


--
Kurt Sansom

_______________________________________________
Nektar-users mailing list
Nektar-users@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/nektar-users