b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2node.H
Go to the documentation of this file.
1//------------------------------------------------------------------------
2// b2node.H --
3//
4//
5// written by Mathias Doreille
6//
7// Copyright (c) 2004-2012,2017
8// SMR Engineering & Development SA
9// 2502 Bienne, Switzerland
10//
11// All Rights Reserved. Proprietary source code. The contents of
12// this file may not be disclosed to third parties, copied or
13// duplicated in any form, in whole or in part, without the prior
14// written permission of SMR.
15//------------------------------------------------------------------------
16
17#ifndef __B2NODE_H__
18#define __B2NODE_H__
19
20#include <utility>
21#include <vector>
22
23#include "b2ppconfig.h"
25#include "model/b2referential.H"
26#include "utils/b2exception.H"
27#include "utils/b2linear_algebra.H"
28#include "utils/b2module.H"
29#include "utils/b2object.H"
30#include "utils/b2type.H"
31
38namespace b2000 {
39
53class Node : public DegreesOfFreedom {
54public:
60 Node() : id(0), object_name("???") {}
61
67 size_t get_id() const { return id; }
68
72 void set_id(size_t id_) { id = id_; }
73
79 const std::string& get_object_name() const override { return object_name; }
80
86 void set_object_name(const std::string& name) { object_name = name; }
87
91 virtual void init() {}
92
101 virtual int get_number_of_coor() const = 0;
102
110 virtual void set_coor(const double* coor) = 0;
111
112 virtual void set_coor(const b2000::csda<double>* coor) = 0;
113
118 template <typename T>
119 std::pair<int, const T*> get_coor() const;
120
122 virtual std::pair<int, const double*> get_coor_double() const = 0;
123
125 virtual std::pair<int, const b2000::csda<double>*> get_coor_csda() const = 0;
126
137 virtual double* get_coor(double* c) const = 0;
138
139 virtual b2000::csda<double>* get_coor(b2000::csda<double>* c) const = 0;
140
156 static double* get_coor_s(double* c, const Node* node) { return node->get_coor(c); }
157
158 static b2000::csda<double>* get_coor_s(b2000::csda<double>* c, const Node* node) {
159 return node->get_coor(c);
160 }
161
166 virtual void set_weight(const double& weight) = 0;
167
168 virtual void set_weight(const b2000::csda<double>& weight) = 0;
169
174 virtual double get_weight() const = 0;
175
176 virtual b2000::csda<double> get_weight_csda() const = 0;
177
201 static size_t* get_global_dof_numbering_s(size_t* index, const Node* node) {
202 return node->get_global_dof_numbering(index);
203 }
204
209 virtual void get_common_dofs(const Node& node, std::vector<std::pair<int, int> >& cdofs) const {
211 }
212
220 virtual bool is_subnode(const Node* node) const { return true; }
221
222 typedef ObjectTypeIncomplete<Node> type_t;
223
224 virtual type_t* get_object_type() { return &type; }
225
226 static type_t type;
227 static double one;
228
229private:
230 size_t id;
231 std::string object_name;
232
233 std::pair<int, const double*> get_coor_py() { return get_coor_double(); }
234
235 void set_coor_py(std::pair<int, const double*> coor) {
236 if (coor.first != get_number_of_coor()) { Exception() << THROW; }
237 set_coor(coor.second);
238 }
239};
240
241template <>
242inline std::pair<int, const double*> Node::get_coor<double>() const {
243 return get_coor_double();
244}
245
246template <>
247inline std::pair<int, const b2000::csda<double>*> Node::get_coor<b2000::csda<double> >() const {
248 return get_coor_csda();
249}
250
251template <typename DOF_TYPE>
252class TypedNode : public Node {
253public:
254 virtual void get_d_gdof_d_ldof(
255 const Transformation3D<double>& ltog,
256 b2linalg::Matrix<double, b2linalg::Mcompressed_col>& m) const = 0;
257
258 virtual void get_d_gdof_d_ldof(
259 const Transformation3D<b2000::csda<double> >& ltog,
260 b2linalg::Matrix<b2000::csda<double>, b2linalg::Mcompressed_col>& m) const = 0;
261
262 static DOF_TYPE* get_dof_s(const DOF_TYPE* global_dof, DOF_TYPE* local_dof, const Node* node) {
263 return node->get_dof(global_dof, local_dof);
264 }
265};
266
267struct NodeListNull {
268 template <typename NODE>
269 static double* get_coor(double* coor, NODE** node) {
270 return coor;
271 }
272 template <typename NODE>
273 static size_t get_number_of_dof(NODE** node_) {
274 return 0;
275 }
276 template <typename NODE>
277 static size_t* get_global_dof_numbering(size_t* index, NODE** node) {
278 return index;
279 }
280 template <typename NODE, typename DOF_TYPE>
281 static DOF_TYPE* get_dof(const DOF_TYPE* global_dof, DOF_TYPE* local_dof, NODE** node) {
282 return local_dof;
283 }
284};
285
286template <typename NODE_TYPE, typename NODE_LIST = NodeListNull>
287struct NodeList {
288 typedef typename NODE_TYPE::value_type value_type;
289
290 template <typename NODE>
291 static double* get_coor(double* coor, NODE** node) {
292 coor = NODE_TYPE::get_coor_s(coor, *node);
293 return NODE_LIST::get_coor(coor, ++node);
294 }
295
296 template <typename NODE>
297 static b2000::csda<double>* get_coor(b2000::csda<double>* coor, NODE** node) {
298 coor = NODE_TYPE::get_coor_s(coor, *node);
299 return NODE_LIST::get_coor(coor, ++node);
300 }
301
302 template <typename NODE>
303 static size_t get_number_of_dof(NODE** node) {
304 const size_t tmp = NODE_TYPE::get_number_of_dof_s(*node);
305 return tmp + NODE_LIST::get_number_of_dof(++node);
306 }
307 template <typename NODE>
308 static size_t* get_global_dof_numbering(size_t* index, NODE** node) {
309 index = NODE_TYPE::get_global_dof_numbering_s(index, *node);
310 return NODE_LIST::get_global_dof_numbering(index, ++node);
311 }
312
313 template <typename NODE, typename DOF_TYPE>
314 static DOF_TYPE* get_dof(const DOF_TYPE* global_dof, DOF_TYPE* local_dof, NODE** node) {
315 local_dof = NODE_TYPE::get_dof_s(global_dof, local_dof, *node);
316 return NODE_LIST::get_dof(global_dof, local_dof, ++node);
317 }
318};
319
320namespace node {
321extern Module module;
322}
323
324} // namespace b2000
325
326#endif
#define THROW
Definition b2exception.H:198
Definition b2degrees_of_freedom.H:57
virtual std::pair< size_t, size_t > get_global_dof_numbering() const
Definition b2degrees_of_freedom.H:111
Definition b2node.H:53
virtual bool is_subnode(const Node *node) const
Definition b2node.H:220
virtual int get_number_of_coor() const =0
std::pair< int, const T * > get_coor() const
size_t get_id() const
Definition b2node.H:67
virtual std::pair< int, const b2000::csda< double > * > get_coor_csda() const =0
virtual double get_weight() const =0
const std::string & get_object_name() const override
Definition b2node.H:79
virtual void init()
Definition b2node.H:91
void set_id(size_t id_)
Definition b2node.H:72
virtual double * get_coor(double *c) const =0
static double * get_coor_s(double *c, const Node *node)
Definition b2node.H:156
static size_t * get_global_dof_numbering_s(size_t *index, const Node *node)
Definition b2node.H:201
virtual void set_weight(const double &weight)=0
virtual std::pair< int, const double * > get_coor_double() const =0
virtual void set_coor(const double *coor)=0
void set_object_name(const std::string &name)
Definition b2node.H:86
Definition b2object.H:340
Contains the base classes for implementing Finite Elements.
Definition b2boundary_condition.H:32
GenericException< UnimplementedError_name > UnimplementedError
Definition b2exception.H:314