Loading...
Searching...
No Matches
FunctionAssigner.h
// Copyright (C) 2013 Johan Hake
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// First added: 2013-09-20
// Last changed: 2013-11-11
#ifndef __DOLFIN_FUNCTION_ASSIGNER_H
#define __DOLFIN_FUNCTION_ASSIGNER_H
#include <vector>
#include <memory>
namespace dolfin
{
class Function;
class FunctionSpace;
class Mesh;
class FunctionAssigner
{
public:
FunctionAssigner(std::shared_ptr<const FunctionSpace> receiving_space,
std::shared_ptr<const FunctionSpace> assigning_space);
FunctionAssigner(std::vector<std::shared_ptr<const FunctionSpace>> receiving_spaces,
std::shared_ptr<const FunctionSpace> assigning_space);
FunctionAssigner(std::shared_ptr<const FunctionSpace> receiving_space,
std::vector<std::shared_ptr<const FunctionSpace>> assigning_spaces);
void assign(std::shared_ptr<Function> receiving_func,
std::shared_ptr<const Function> assigning_func) const;
void assign(std::shared_ptr<Function> receiving_func,
std::vector<std::shared_ptr<const Function>> assigning_funcs) const;
void assign(std::vector<std::shared_ptr<Function>> receiving_funcs,
std::shared_ptr<const Function> assigning_func) const;
~FunctionAssigner();
inline std::size_t num_assigning_functions() const
{ return _assigning_spaces.size(); }
inline std::size_t num_receiving_functions() const
{ return _receiving_spaces.size(); }
private:
// Utility function to actually do the assignment
void _assign(std::vector<std::shared_ptr<Function>> receiving_funcs,
std::vector<std::shared_ptr<const Function>> assigning_funcs) const;
// Check the compatibility of the meshes and return a reference to
// the mesh
const Mesh& _get_mesh() const;
// Check the compatibility of the arguments to the constructor and
// build indices for assignment
void _check_and_build_indices(const Mesh& mesh,
const std::vector<std::shared_ptr<const FunctionSpace> >& receiving_spaces,
const std::vector<std::shared_ptr<const FunctionSpace> >& assigning_spaces);
// Shared pointers to the original FunctionSpaces
std::vector<std::shared_ptr<const FunctionSpace>> _receiving_spaces;
std::vector<std::shared_ptr<const FunctionSpace>> _assigning_spaces;
// Indices for accessing values to receiving Functions
std::vector<std::vector<la_index>> _receiving_indices;
// Indices for accessing values from assigning Functions
std::vector<std::vector<la_index>> _assigning_indices;
// Vector for value transfer between assigning and receiving Function
mutable std::vector<std::vector<double> > _transfer;
};
}
#endif
dolfin::FunctionAssigner::~FunctionAssigner
~FunctionAssigner()
Destructor.
Definition FunctionAssigner.cpp:113
dolfin::FunctionAssigner::num_receiving_functions
std::size_t num_receiving_functions() const
Return the number of receiving functions.
Definition FunctionAssigner.h:126
dolfin::FunctionAssigner::FunctionAssigner
FunctionAssigner(std::shared_ptr< const FunctionSpace > receiving_space, std::shared_ptr< const FunctionSpace > assigning_space)
Definition FunctionAssigner.cpp:36
dolfin::FunctionAssigner::assign
void assign(std::shared_ptr< Function > receiving_func, std::shared_ptr< const Function > assigning_func) const
Definition FunctionAssigner.cpp:119
dolfin::FunctionAssigner::num_assigning_functions
std::size_t num_assigning_functions() const
Return the number of assigning functions.
Definition FunctionAssigner.h:122
dolfin::FunctionSpace
Definition FunctionSpace.h:54
dolfin::Function
Definition Function.h:66
dolfin::Mesh
Definition Mesh.h:84
dolfin
Definition adapt.h:30