Page MenuHomec4science

ref_node_continuum.hh
No OneTemporary

File Metadata

Created
Sun, Nov 17, 07:15

ref_node_continuum.hh

/**
* @file ref_node_continuum.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Wed Jan 22 17:41:05 2014
*
* @brief This is the mother of all mesh node reference
*
* @section LICENSE
*
* Copyright INRIA and CEA
*
* The LibMultiScale is a C++ parallel framework for the multiscale
* coupling methods dedicated to material simulations. This framework
* provides an API which makes it possible to program coupled simulations
* and integration of already existing codes.
*
* This Project was initiated in a collaboration between INRIA Futurs Bordeaux
* within ScAlApplix team and CEA/DPTA Ile de France.
* The project is now continued at the Ecole Polytechnique Fédérale de Lausanne
* within the LSMS/ENAC laboratory.
*
* This software is governed by the CeCILL-C license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL-C
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*
*/
#ifndef __LIBMULTISCALE_REF_NODE_CONTINUUM_HH__
#define __LIBMULTISCALE_REF_NODE_CONTINUUM_HH__
/* -------------------------------------------------------------------------- */
#define DECLARE_ACCESOR(name, func) \
inline void get##name(Real * x){ \
for (UInt i = 0; i < Dim; ++i) { \
x[i] = func(i); \
} \
}
/* -------------------------------------------------------------------------- */
#include "cube.hh"
#include "ref_point.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
template <UInt Dim> class RefNode;
/* -------------------------------------------------------------------------- */
template <UInt Dim,FieldType ftype>
class AccessorNodalDof {
public:
AccessorNodalDof(RefNode<Dim> & nd, UInt i);
inline operator Real() const{return nd;}
template <typename T> inline Real & operator =(const T & val){
nd = val;
return nd;
}
private:
Real & nd;
};
/* -------------------------------------------------------------------------- */
/**
* Class RefNode
* Generic class to represent nodal reference
* \todo interface should provide more functions. The actual
* aspect is due that only libmesh implements FE in LibMultiScale.
*/
template <UInt Dim>
class RefNode : public RefPoint<RefNode,Dim>
{
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
RefNode():standard_weight(1){};
virtual ~RefNode(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
//! return residual value for dimension coord
virtual Real & force(UInt coord)=0;
//! return applied force value for dimension coord
virtual Real & appliedForce(UInt coord){LM_TOIMPLEMENT;}
//! return acceleration value for dimension coord
virtual Real & acceleration(UInt coord)=0;
//! return initial position value for dimension coord
virtual Real & position0(UInt coord)=0;
//! return current position value for dimension coord
virtual AccessorNodalDof<Dim,_position> position(UInt coord)=0;
//! return displacement value for dimension coord
virtual Real & displacement(UInt coord)=0;
//! return velocity value for dimension coord
virtual Real & velocity(UInt coord)=0;
//! return mass value
virtual Real & mass()=0;
//! return internal id
virtual UInt id()=0;
//! return temperature value
virtual Real & temperature(){LM_TOIMPLEMENT;};
//! return temperature variation value
virtual Real & temperatureVar(){LM_TOIMPLEMENT;};
//! return the external (applied) heat rate
virtual Real & externalHeatRate(){LM_TOIMPLEMENT;};
//! return the heat rate (residual)
virtual Real & heatRate(){LM_TOIMPLEMENT;};
//! return heat capacity
virtual Real & capacity(){LM_TOIMPLEMENT;};
//! weigthing function
virtual Real & alpha(){return standard_weight;};
// function to switch heat transfer flag
virtual void setHeatTransferFlag(bool flag){LM_TOIMPLEMENT;};
//! Method to allow reading or setting the boundary value of a node
virtual bool & boundary(UInt coord)=0;
template<FieldType ftype> AccessorNodalDof<Dim,ftype> field(UInt i);
DECLARE_ACCESOR(Positions, position);
DECLARE_ACCESOR(Positions0, position0);
DECLARE_ACCESOR(Velocities, velocity);
DECLARE_ACCESOR(Displacements, displacement);
template <FieldType ftype>
inline void getField(Real * x){
for (UInt i = 0; i < Dim; ++i) {
x[i] = field<ftype>(i);
}
};
public:
static const UInt dim = Dim;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
Real standard_weight;
};
/* -------------------------------------------------------------------------- */
template <UInt Dim>
template <FieldType ftype>
AccessorNodalDof<Dim,ftype> RefNode<Dim>::field(UInt i){
AccessorNodalDof<Dim,ftype> acc(*this,i);
return acc;
}
/* -------------------------------------------------------------------------- */
template <UInt Dim,FieldType ftype>
inline AccessorNodalDof<Dim,ftype>::AccessorNodalDof(RefNode<Dim> & nd, UInt i):nd(nd.displacement(i)){
LM_TOIMPLEMENT;
}
template <>
inline AccessorNodalDof<1,_position0>::AccessorNodalDof(RefNode<1> & nd, UInt i):nd(nd.position0(i)){}
template <>
inline AccessorNodalDof<2,_position0>::AccessorNodalDof(RefNode<2> & nd, UInt i):nd(nd.position0(i)){}
template <>
inline AccessorNodalDof<3,_position0>::AccessorNodalDof(RefNode<3> & nd, UInt i):nd(nd.position0(i)){}
template <>
inline AccessorNodalDof<1,_displacement>::AccessorNodalDof(RefNode<1> & nd, UInt i):nd(nd.displacement(i)){}
template <>
inline AccessorNodalDof<2,_displacement>::AccessorNodalDof(RefNode<2> & nd, UInt i):nd(nd.displacement(i)){}
template <>
inline AccessorNodalDof<3,_displacement>::AccessorNodalDof(RefNode<3> & nd, UInt i):nd(nd.displacement(i)){}
template <>
inline AccessorNodalDof<1,_velocity>::AccessorNodalDof(RefNode<1> & nd, UInt i):nd(nd.velocity(i)){}
template <>
inline AccessorNodalDof<2,_velocity>::AccessorNodalDof(RefNode<2> & nd, UInt i):nd(nd.velocity(i)){}
template <>
inline AccessorNodalDof<3,_velocity>::AccessorNodalDof(RefNode<3> & nd, UInt i):nd(nd.velocity(i)){}
template <>
inline AccessorNodalDof<1,_force>::AccessorNodalDof(RefNode<1> & nd, UInt i):nd(nd.force(i)){}
template <>
inline AccessorNodalDof<2,_force>::AccessorNodalDof(RefNode<2> & nd, UInt i):nd(nd.force(i)){}
template <>
inline AccessorNodalDof<3,_force>::AccessorNodalDof(RefNode<3> & nd, UInt i):nd(nd.force(i)){}
template <>
inline AccessorNodalDof<1,_temperature>::AccessorNodalDof(RefNode<1> & nd, UInt i):nd(nd.temperature()){}
template <>
inline AccessorNodalDof<2,_temperature>::AccessorNodalDof(RefNode<2> & nd, UInt i):nd(nd.temperature()){}
template <>
inline AccessorNodalDof<3,_temperature>::AccessorNodalDof(RefNode<3> & nd, UInt i):nd(nd.temperature()){}
template <>
inline AccessorNodalDof<1,_mass>::AccessorNodalDof(RefNode<1> & nd, UInt i):nd(nd.mass()){}
template <>
inline AccessorNodalDof<2,_mass>::AccessorNodalDof(RefNode<2> & nd, UInt i):nd(nd.mass()){}
template <>
inline AccessorNodalDof<3,_mass>::AccessorNodalDof(RefNode<3> & nd, UInt i):nd(nd.mass()){}
/* -------------------------------------------------------------------------- */
template <UInt Dim>
class AccessorNodalDof<Dim,_position> {
public:
AccessorNodalDof(RefNode<Dim> & nd, UInt i):nd(nd),i(i){};
inline operator Real() const{
return nd.position0(i) + nd.displacement(i);
};
template <typename T>
inline const T & operator =(const T & val){
position = val;
nd.displacement(i) = position - nd.position0(i);
return position;
};
template <typename T>
inline const T & operator +=(const T & val){
position = nd.displacement(i)+nd.position0(i) + val;
nd.displacement(i) = position - nd.position0(i);
return position;
}
RefNode<Dim> & nd;
UInt i;
Real position;
};
/* -------------------------------------------------------------------------- */
__END_LIBMULTISCALE__
#endif /* __LIBMULTISCALE_REF_NODE_CONTINUUM_HH__ */

Event Timeline