1 /* ----------------------------------------------------------------------
2     This is the
3 
4     ██╗     ██╗ ██████╗  ██████╗  ██████╗ ██╗  ██╗████████╗███████╗
5     ██║     ██║██╔════╝ ██╔════╝ ██╔════╝ ██║  ██║╚══██╔══╝██╔════╝
6     ██║     ██║██║  ███╗██║  ███╗██║  ███╗███████║   ██║   ███████╗
7     ██║     ██║██║   ██║██║   ██║██║   ██║██╔══██║   ██║   ╚════██║
8     ███████╗██║╚██████╔╝╚██████╔╝╚██████╔╝██║  ██║   ██║   ███████║
9     ╚══════╝╚═╝ ╚═════╝  ╚═════╝  ╚═════╝ ╚═╝  ╚═╝   ╚═╝   ╚══════╝®
10 
11     DEM simulation engine, released by
12     DCS Computing Gmbh, Linz, Austria
13     http://www.dcs-computing.com, office@dcs-computing.com
14 
15     LIGGGHTS® is part of CFDEM®project:
16     http://www.liggghts.com | http://www.cfdem.com
17 
18     Core developer and main author:
19     Christoph Kloss, christoph.kloss@dcs-computing.com
20 
21     LIGGGHTS® is open-source, distributed under the terms of the GNU Public
22     License, version 2 or later. It is distributed in the hope that it will
23     be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
24     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have
25     received a copy of the GNU General Public License along with LIGGGHTS®.
26     If not, see http://www.gnu.org/licenses . See also top-level README
27     and LICENSE files.
28 
29     LIGGGHTS® and CFDEM® are registered trade marks of DCS Computing GmbH,
30     the producer of the LIGGGHTS® software and the CFDEM®coupling software
31     See http://www.cfdem.com/terms-trademark-policy for details.
32 
33 -------------------------------------------------------------------------
34     Contributing author and copyright for this file:
35     (if not contributing author is listed, this file has been contributed
36     by the core developer)
37 
38     Christoph Kloss (DCS Computing GmbH, Linz)
39     Christoph Kloss (JKU Linz)
40     Andreas Aigner (DCS Computing GmbH, JKU Linz)
41     Arno Mayrhofer (DCS Computing GmbH)
42 
43     Copyright 2012-     DCS Computing GmbH, Linz
44     Copyright 2009-2012 JKU Linz
45 ------------------------------------------------------------------------- */
46 
47 #ifdef MESHMODULE_CLASS
48 
49 MeshModuleStyle(servo,MeshModuleStressServo)
50 
51 #else
52 
53 #ifndef LMP_MESH_MODULE_STRESS_SERVO_H
54 #define LMP_MESH_MODULE_STRESS_SERVO_H
55 
56 #include "fix.h"
57 #include "input.h"
58 #include <cmath>
59 #include "mesh_module_stress.h"
60 #include "mesh_module.h"
61 
62 namespace LAMMPS_NS
63 {
64 
65   class MeshModuleStressServo : public MeshModule
66   {
67 
68   public:
69 
70     MeshModuleStressServo(LAMMPS *lmp, int &iarg_, int narg, char **arg, FixMeshSurface *fix_mesh);
71     virtual ~MeshModuleStressServo();
72 
73     virtual void post_create_pre_restart();
74     virtual void post_create();
75 
76     void init();
77     int setmask();
78 
79     virtual void setup_pre_force(int vflag);
80     void initial_integrate(int vflag);
81     void add_particle_contribution(int ip, double *frc,
82                                    double *delta, int iTri, double *v_wall);
83     void final_integrate();
84 
85     void reset_dt();
86     double compute_vector(int n);
87 
88     inline int get_num_vector_components() const
89     { return 3; }
90 
91   private:
92 
93     void init_defaults();
94     void error_checks();
95 
96     void limit_vel();
97     void update_mass();
98     void set_v_node();
99     void set_v_node_rotate();
100     double getMaxRad();
101     int modify_param(int, char **);
102     void resetIntegrator() {sum_err_ = 0;}
103 
104     // properties of mesh
105 
106     VectorContainer<double,3> &xcm_;
107     VectorContainer<double,3> &vcm_;
108     VectorContainer<double,3> &omegacm_;
109     VectorContainer<double,3> &xcm_orig_;
110 
111     // position and velocity for each node
112 
113     MultiVectorContainer<double,3,3> *v_;
114 
115     // servo settings and controller
116 
117     double axis_[3],totalPhi_;
118     double *ctrl_op_,*pv_vec_;
119     double vel_max_,vel_min_,ctrl_op_max_,ctrl_op_min_,ratio_;
120     double sp_mag_,sp_mag_inv_;
121     double pv_mag_,old_pv_mag_;
122     double err_, sum_err_;
123     double kp_,ki_,kd_;
124 
125     // variable set point
126     int sp_var_, sp_style_;
127     char *sp_str_;
128 
129     // flags
130     bool int_flag_;
131     bool mode_flag_;
132     int ctrl_style_;
133 
134     // timesteps
135     double dtf_,dtv_;
136 
137     // for area calculation
138     class ModifiedAndrew *mod_andrew_;
139 
140     // signum function
141     template <typename T> int sgn(T val) {
142       return (T(0) < val) - (val < T(0));
143     }
144 
145     MeshModuleStress *mm_stress;
146 
147   }; //end class
148 
149 }
150 
151 #endif
152 #endif
153