Page MenuHomec4science

field_collection.hh
No OneTemporary

File Metadata

Created
Fri, Nov 15, 22:54

field_collection.hh

/**
* file field_collection.hh
*
* @author Till Junge <till.junge@epfl.ch>
*
* @date 07 Sep 2017
*
* @brief Provides pixel-iterable containers for scalar and tensorial fields,
* addressable by field name
*
* @section LICENCE
*
* Copyright (C) 2017 Till Junge
*
* µSpectre is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3, or (at
* your option) any later version.
*
* µSpectre 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Emacs; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef FIELD_COLLECTION_H
#define FIELD_COLLECTION_H
#include "common/common.hh"
#include "system/field.hh"
#include <memory>
#include <exception>
#include <string>
#include "set"
namespace muSpectre {
class FieldCollectionError: public std::runtime_error {
public:
explicit FieldCollectionError(const std::string& what)
:std::runtime_error(what){}
explicit FieldCollectionError(const char * what)
:std::runtime_error(what){}
};
class FieldError: public FieldCollectionError {
using Parent = FieldCollectionError;
public:
explicit FieldError(const std::string& what)
:Parent(what){}
explicit FieldError(const char * what)
:Parent(what){}
};
class FieldInterpretationError: public FieldError
{
public:
explicit FieldInterpretationError(const std::string & what)
:FieldError(what){}
explicit FieldInterpretationError(const char * what)
:FieldError(what){}
};
/* ---------------------------------------------------------------------- */
//! DimS spatial dimension (dimension of problem
//! DimM material_dimension (dimension of constitutive law)
//! Global determines whether this field is present everywhere or per material
template <Dim_t DimS, Dim_t DimM, bool Global = true>
class FieldCollection
{
public:
using Field_p = std::shared_ptr<internal::FieldBase<FieldCollection>>;
using Ccoord = Ccoord_t<DimS>;
//! Default constructor
FieldCollection() = default;
//! Copy constructor
FieldCollection(const FieldCollection &other) = delete;
//! Move constructor
FieldCollection(FieldCollection &&other) noexcept = delete;
//! Destructor
virtual ~FieldCollection() noexcept = default;
//! Copy assignment operator
FieldCollection& operator=(const FieldCollection &other) = delete;
//! Move assignment operator
FieldCollection& operator=(FieldCollection &&other) noexcept = delete;
//! add a pixel/voxel to the field collection
template <bool NotGlobal = !Global>
std::enable_if_t<NotGlobal> add_pixel(const Ccoord & local_index);
//! allocate memory, etc
void initialise();
//! Register a new field
void register_field(Field_p field);
//! for return values of iterators
constexpr inline static Dim_t get_spatial_dim();
protected:
std::set<std::string> reserved_names;
bool is_initialised = false;
private:
};
/* ---------------------------------------------------------------------- */
template <Dim_t DimS, Dim_t DimM, bool Global>
constexpr Dim_t FieldCollection<DimS, DimM, Global>::get_spatial_dim() {
return DimS;
}
} // muSpectre
#endif /* FIELD_COLLECTION_H */

Event Timeline