$extrastylesheet
libMesh::CompositeFEMFunction< Output > Class Template Reference

#include <composite_fem_function.h>

Inheritance diagram for libMesh::CompositeFEMFunction< Output >:

List of all members.

Public Member Functions

 CompositeFEMFunction ()
 ~CompositeFEMFunction ()
void attach_subfunction (const FEMFunctionBase< Output > &f, const std::vector< unsigned int > &index_map)
virtual Output operator() (const FEMContext &c, const Point &p, const Real time=0)
virtual void operator() (const FEMContext &c, const Point &p, const Real time, DenseVector< Output > &output)
virtual Output component (const FEMContext &c, unsigned int i, const Point &p, Real time)
virtual UniquePtr
< FEMFunctionBase< Output > > 
clone () const
unsigned int n_subfunctions () const
unsigned int n_components () const
virtual void init_context (const FEMContext &)
void operator() (const FEMContext &, const Point &p, DenseVector< Output > &output)

Private Attributes

std::vector< FEMFunctionBase
< Output > * > 
subfunctions
std::vector< std::vector
< unsigned int > > 
index_maps
std::vector< std::pair
< unsigned int, unsigned int > > 
reverse_index_map

Detailed Description

template<typename Output = Number>
class libMesh::CompositeFEMFunction< Output >

Definition at line 36 of file composite_fem_function.h.


Constructor & Destructor Documentation

template<typename Output = Number>
libMesh::CompositeFEMFunction< Output >::CompositeFEMFunction ( ) [inline, explicit]

Definition at line 40 of file composite_fem_function.h.

Referenced by libMesh::CompositeFEMFunction< Output >::clone().

{}
template<typename Output = Number>
libMesh::CompositeFEMFunction< Output >::~CompositeFEMFunction ( ) [inline]

Definition at line 42 of file composite_fem_function.h.

References libMesh::CompositeFEMFunction< Output >::subfunctions.

  {
    for (unsigned int i=0; i != subfunctions.size(); ++i)
      delete subfunctions[i];
  }

Member Function Documentation

template<typename Output = Number>
void libMesh::CompositeFEMFunction< Output >::attach_subfunction ( const FEMFunctionBase< Output > &  f,
const std::vector< unsigned int > &  index_map 
) [inline]

Definition at line 51 of file composite_fem_function.h.

References libMesh::FEMFunctionBase< Output >::clone(), libMesh::CompositeFEMFunction< Output >::index_maps, libMesh::invalid_uint, libMesh::CompositeFEMFunction< Output >::reverse_index_map, and libMesh::CompositeFEMFunction< Output >::subfunctions.

Referenced by libMesh::CompositeFEMFunction< Output >::clone().

  {
    const unsigned int subfunction_index = subfunctions.size();
    libmesh_assert_equal_to(subfunctions.size(), index_maps.size());

    subfunctions.push_back(f.clone().release());
    index_maps.push_back(index_map);

    unsigned int max_index =
      *std::max_element(index_map.begin(), index_map.end());

    if (max_index >= reverse_index_map.size())
      reverse_index_map.resize
        (max_index+1, std::make_pair(libMesh::invalid_uint,
                                     libMesh::invalid_uint));

    for (unsigned int j=0; j != index_map.size(); ++j)
      {
        libmesh_assert_less(index_map[j], reverse_index_map.size());
        libmesh_assert_equal_to(reverse_index_map[index_map[j]].first,
                                libMesh::invalid_uint);
        libmesh_assert_equal_to(reverse_index_map[index_map[j]].second,
                                libMesh::invalid_uint);
        reverse_index_map[index_map[j]] =
          std::make_pair(subfunction_index, j);
      }
  }
template<typename Output = Number>
virtual UniquePtr<FEMFunctionBase<Output> > libMesh::CompositeFEMFunction< Output >::clone ( ) const [inline, virtual]

Returns a new copy of the function. The new copy should be as ``deep'' as necessary to allow independent destruction and simultaneous evaluations of the copies in different threads.

Implements libMesh::FEMFunctionBase< Output >.

Definition at line 130 of file composite_fem_function.h.

References libMesh::CompositeFEMFunction< Output >::attach_subfunction(), libMesh::CompositeFEMFunction< Output >::CompositeFEMFunction(), libMesh::CompositeFEMFunction< Output >::index_maps, and libMesh::CompositeFEMFunction< Output >::subfunctions.

                                                            {
    CompositeFEMFunction* returnval = new CompositeFEMFunction();
    for (unsigned int i=0; i != subfunctions.size(); ++i)
      returnval->attach_subfunction(*subfunctions[i], index_maps[i]);
    return UniquePtr<FEMFunctionBase<Output> > (returnval);
  }
template<typename Output = Number>
virtual Output libMesh::CompositeFEMFunction< Output >::component ( const FEMContext c,
unsigned int  i,
const Point p,
Real  time 
) [inline, virtual]
Returns:
the vector component i at coordinate p and time time.

Reimplemented from libMesh::FEMFunctionBase< Output >.

Definition at line 113 of file composite_fem_function.h.

References libMesh::invalid_uint, libMesh::CompositeFEMFunction< Output >::reverse_index_map, and libMesh::CompositeFEMFunction< Output >::subfunctions.

Referenced by libMesh::CompositeFEMFunction< Output >::operator()().

  {
    if (i >= reverse_index_map.size() ||
        reverse_index_map[i].first == libMesh::invalid_uint)
      return 0;

    libmesh_assert_less(reverse_index_map[i].first,
                        subfunctions.size());
    libmesh_assert_not_equal_to(reverse_index_map[i].second,
                                libMesh::invalid_uint);
    return subfunctions[reverse_index_map[i].first]->
      component(c, reverse_index_map[i].second, p, time);
  }
template<typename Output = Number>
virtual void libMesh::FEMFunctionBase< Output >::init_context ( const FEMContext ) [inline, virtual, inherited]

Prepares a context object for use.

Most problems will want to reimplement this for efficiency, in order to call FE::get_*() as their particular function requires.

Reimplemented in libMesh::ParsedFEMFunction< Output >.

Definition at line 68 of file fem_function_base.h.

{}
template<typename Output = Number>
unsigned int libMesh::CompositeFEMFunction< Output >::n_components ( ) const [inline]
template<typename Output = Number>
unsigned int libMesh::CompositeFEMFunction< Output >::n_subfunctions ( ) const [inline]

Definition at line 137 of file composite_fem_function.h.

References libMesh::CompositeFEMFunction< Output >::subfunctions.

                                       {
    return subfunctions.size();
  }
template<typename Output = Number>
virtual Output libMesh::CompositeFEMFunction< Output >::operator() ( const FEMContext ,
const Point p,
const Real  time = 0 
) [inline, virtual]
Returns:
the scalar value at coordinate p and time time, which defaults to zero. Purely virtual, so you have to overload it. Note that this cannot be a const method, check MeshFunction.

Implements libMesh::FEMFunctionBase< Output >.

Definition at line 80 of file composite_fem_function.h.

References libMesh::CompositeFEMFunction< Output >::component().

  {
    return this->component(c,0,p,time);
  }
template<typename Output = Number>
virtual void libMesh::CompositeFEMFunction< Output >::operator() ( const FEMContext ,
const Point p,
const Real  time,
DenseVector< Output > &  output 
) [inline, virtual]

Return function for vectors. Returns in output the values of the data at the coordinate p and for time time. Purely virtual, so you have to overload it. Note that this cannot be a const method, check MeshFunction.

Implements libMesh::FEMFunctionBase< Output >.

Definition at line 87 of file composite_fem_function.h.

References libMesh::CompositeFEMFunction< Output >::index_maps, libMesh::DenseVector< T >::resize(), libMesh::CompositeFEMFunction< Output >::reverse_index_map, libMesh::DenseVector< T >::size(), libMesh::CompositeFEMFunction< Output >::subfunctions, and libMesh::DenseVector< T >::zero().

  {
    libmesh_assert_greater_equal (output.size(),
                                  reverse_index_map.size());

    // Necessary in case we have output components not covered by
    // any subfunctions
    output.zero();

    DenseVector<Output> temp;
    for (unsigned int i=0; i != subfunctions.size(); ++i)
      {
        temp.resize(index_maps[i].size());
        (*subfunctions[i])(c, p, time, temp);
        for (unsigned int j=0; j != temp.size(); ++j)
          output(index_maps[i][j]) = temp(j);
      }
  }
template<typename Output >
void libMesh::FEMFunctionBase< Output >::operator() ( const FEMContext context,
const Point p,
DenseVector< Output > &  output 
) [inline, inherited]

Return function for vectors. Returns in output the values of the data at the coordinate p.

Definition at line 137 of file fem_function_base.h.

{
  // Call the time-dependent function with t=0.
  this->operator()(context, p, 0., output);
}

Member Data Documentation

template<typename Output = Number>
std::vector<std::vector<unsigned int> > libMesh::CompositeFEMFunction< Output >::index_maps [private]

The documentation for this class was generated from the following file: