Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F87394460
field.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Oct 12, 10:41
Size
4 KB
Mime Type
text/x-c
Expires
Mon, Oct 14, 10:41 (2 d)
Engine
blob
Format
Raw Data
Handle
21590335
Attached To
rMSPPROTO µSpectre prototype implementation
field.hh
View Options
/**
* file field.hh
*
* @author Till Junge <till.junge@epfl.ch>
*
* @date 07 Sep 2017
*
* @brief header-only implementation of a field for field collections
*
* @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_H
#define FIELD_H
#include <string>
#include <typeinfo>
#include <Eigen/Dense>
namespace muSpectre {
namespace internal {
/* ---------------------------------------------------------------------- */
template <class FieldCollection>
class FieldBase
{
public:
protected:
//! constructor
//! unique name (whithin Collection)
//! number of components
//! collection to which this field belongs (eg, material, system)
FieldBase(std::string unique_name, Uint nb_components,
const FieldCollection & collection);
//! Copy constructor
FieldBase(const FieldBase &other) = delete;
//! Move constructor
FieldBase(FieldBase &&other) noexcept = delete;
//! Destructor
virtual ~FieldBase() noexcept = default;
//! Copy assignment operator
FieldBase& operator=(const FieldBase &other) = delete;
//! Move assignment operator
FieldBase& operator=(FieldBase &&other) noexcept = delete;
/* ---------------------------------------------------------------------- */
//! allocate memory etc
inline void initialise(Uint size);
/* ---------------------------------------------------------------------- */
//!Identifying accessors
//! returns tensorial order of field
inline const Uint & get_nb_components() const;
//! return field name
inline const std::string & get_name() const;
//! return field type
//inline const Field_t & get_type() const;
//! return my collection (for iterating)
inline const FieldCollection & get_collection() const;
//! return type_id of stored type
virtual const std::type_info & get_stored_typeid() const = 0;
protected:
const std::string name;
const Uint nb_components;
const FieldCollection & collection;
const std::type_info & type_id;
private:
};
/* ---------------------------------------------------------------------- */
template <class FieldCollection, Uint NbComponents, typename T>
class TypedFieldBase
{
public:
TypedFieldBase(std::string unique_name,
const FieldCollection& collection);
virtual ~TypedFieldBase();
inline const T* get_ptr_to_entry(Uint index);
};
/* ---------------------------------------------------------------------- */
template <Dim_t DimM, class FieldCollection, Uint order, Uint dim, typename T>
class TensorField: public FieldBase<FieldCollection>
{
public:
using component_type = T;
//! constructor
TensorField(std::string unique_name, const FieldCollection & collection);
//! Copy constructor
TensorField(const TensorField &other) = delete;
//! Move constructor
TensorField(TensorField &&other) noexcept = delete;
//! Destructor
virtual ~TensorField() noexcept = default;
//! Copy assignment operator
TensorField& operator=(const TensorField &other) = delete;
//! Move assignment operator
TensorField& operator=(TensorField &&other) noexcept = delete;
//! return type_id of stored type
virtual const std::type_info & get_stored_typeid() = 0;
//! accessors
inline const Uint & get_order() const;
inline const Uint & get_dim() const;
protected:
private:
};
} // internal
} // muSpectre
#endif /* FIELD_H */
Event Timeline
Log In to Comment