1 //#**************************************************************
2 //#
3 //# filename:             FieldVariableDescriptor.h
4 //#
5 //# author:               Yury Vetyukov
6 //#
7 //# generated:						November 2010
8 //# description:          FieldVariableDescriptor
9 //# remarks:
10 //#
11 //# Copyright (c) 2003-2013 Johannes Gerstmayr, Linz Center of Mechatronics GmbH, Austrian
12 //# Center of Competence in Mechatronics GmbH, Institute of Technical Mechanics at the
13 //# Johannes Kepler Universitaet Linz, Austria. All rights reserved.
14 //#
15 //# This file is part of HotInt.
16 //# HotInt is free software: you can redistribute it and/or modify it under the terms of
17 //# the HOTINT license. See folder 'licenses' for more details.
18 //#
19 //# bug reports are welcome!!!
20 //# WWW:		www.hotint.org
21 //# email:	bug_reports@hotint.org or support@hotint.org
22 //#**************************************************************
23 
24 #pragma once
25 
26 #include "mystring.h"
27 #include "tarray.h"
28 
29 class Vector3D;
30 class Vector2D;
31 class Matrix3D;
32 class Matrix2D;
33 
34 // functions, which compute values of field variables,
35 // should return this constant to indicate that the value could not actuallu be computed;
36 // in the future this may affect processing of the values
37 const double FIELD_VARIABLE_NO_VALUE = 0;
38 
39 // - this structure identifies a single post-processing field value for contour plotting and sensors.
40 // - elements (mainly finite elements) provide lists of relevant FieldVariableDescriptors
41 //   depending on their settings (i.e. inelastic_strain will appear only
42 //   when a corresponding material is selected). this affects user interface
43 //   (only the relevant options will appear in the selection).
44 // - while drawing, the elements have access to the actually selected FieldVariableDescriptor,
45 //   and plot the corresponding variable.
46 // - each value is defined by its type and, possibly, one or two identifiers of the components.
47 // - there exists a possibility to define a non-standard variable for post-processing.
48 struct FieldVariableDescriptor
49 {
50 public:
51 	// these are the most common (standard) variable types for post-processing;
52 	// adding a new standard type should be completed by adding its textual identifier in the constructor
53 	enum FieldVariableType
54 	{
55 		// kinematic value types
56 		FVT_displacement = 0,						// vector, 3 components in the reference basis
57 		FVT_position,								// vector, 3 components in the reference basis, not for plotting
58 		FVT_velocity,								// vector, 3 components in the reference basis
59 		FVT_acceleration,						// vector, 3 components in the reference basis
60 		// kinematic values in the local basis
61 		FVT_displacement_local_basis,						// vector, 3 components in the local basis
62 		FVT_velocity_local_basis,								// vector, 3 components in the local basis
63 		FVT_acceleration_local_basis,						// vector, 3 components in the local basis
64 
65 		FVT_bryant_angle, 							//$ DR 2012-12-12 added according to JG (rotation x-y-z) //$ DR 2012-12-14 renamed
66 		// r = A*r_bar with A = A3*A2*A1 and Ai is the rotation matrix around axis i
67 
68 		FVT_angular_velocity,							//$ DR 2012-12-12 added according to JG
69 		FVT_angular_velocity_local_basis, //$ DR 2012-12-12 added according to JG
70 
71 		FVT_angular_acceleration,		//$ SW 2013-10-21: added
72 
73 		// density
74 		FVT_density,								// scalar       //PG newly added
75 		FVT_pressure,								// scalar       //PG newly added
76 
77 		// deformations
78 		FVT_total_strain,						// tensor, 6 symmetric components in the reference basis
79 
80 		FVT_inelastic_strain,				// tensor, 6 symmetric components in the reference basis
81 		FVT_hardening_parameter,		// scalar value, (linear isotropic) hardening law parameter
82 		FVT_yield_function,					// scalar value, always <= 0, defines plastic flow law
83 		FVT_initial_strain,					// tensor, 6 symmetric components in the reference basis
84 
85 		FVT_beam_curvature_Y,					// Y component in the local (rotating) basis
86 		FVT_beam_curvature_Z,					// Z component in the local (rotating) basis
87 		FVT_beam_torsion,						// scalar value
88 
89 		FVT_beam_shear_Y,							// Y component in the local (rotating) basis
90 		FVT_beam_shear_Z,							// Z component in the local (rotating) basis
91 		FVT_beam_axial_extension,		// scalar value
92 
93 		//+++++++++++++++++++++++++++++++++++++++++++
94 		//depricated:
95 		FVT_beam_curvature,					// component in the local (rotating) basis
96 		FVT_beam_shear,							// component in the local (rotating) basis
97 		FVT_beam_moment_bending,	  // component in the local (rotating) basis
98 		FVT_beam_force_transversal,	// component in the local (rotating) basis
99 
100 		//+++++++++++++++++++++++++++++++++++++++++++
101 
102 		// stresses in 3D
103 		FVT_stress,									// tensor, 6 symmetric components in the reference basis
104 		FVT_stress_mises,						// scalar value - synonim for stress magnitude
105 		// stress resultants for a 1D continuum (beam, rod)
106 		FVT_beam_force,							// vector, 3 components in the reference basis
107 		FVT_beam_force_axial,				// scalar value
108 		FVT_beam_force_transversal_Y,	// Y component in the local (rotating) basis
109 		FVT_beam_force_transversal_Z,	// Z component in the local (rotating) basis
110 		FVT_beam_moment,						// vector, 3 components in the reference basis
111 		FVT_beam_moment_torsional,	// scalar value
112 		FVT_beam_moment_bending_Y,	   // Y component in the local (rotating) basis
113 		FVT_beam_moment_bending_Z,	   // Z component in the local (rotating) basis
114 		// stress resultants for a 2D continuum (plate, shell)
115 		FVT_shell_force_in_plane,		// in-plane tensor with components xx, xy, yy in the local
116 		FVT_shell_force_transversal,	// in-plane vector with 2 components in the local basis
117 		FVT_shell_moment,						// in-plane tensor with components xx, xy, yy in the local basis
118 		// "user-defined" value type for particular problems (contact stress, etc.)
119 		FVT_problem_specific
120 	};
121 	// identifier of the components of a variable
122 	enum FieldVariableComponentIndex
123 	{
124 		FVCI_none = 0,	// this component is not relevant
125 		FVCI_x = 1,
126 		FVCI_y = 2,
127 		FVCI_z = 3,
128 		FVCI_magnitude = 4		// norm of a vector or a tensor (root of the inner product with itself), should not be used for the second component
129 	};
130 	// possible dimensions of the variables - will be used in the plot legend
131 	enum FieldVariableDimensionality
132 	{
133 		FVD_none,				// non-dimensional, for strains
134 		FVD_length,			// for displacements etc., length
135 		FVD_density,
136 		FVD_pressure,
137 		FVD_velocity,
138 		FVD_acceleration,
139 		FVD_force,
140 		FVD_force_per_length,		// force / length
141 		FVD_force_per_length_square,		// for stresses etc., force / length / length
142 		FVD_force_length,			// moment, force*length
143 		FVD_1_per_length		// curvature etc., 1 / length
144 	};
145 
146 private:
147 	// actual data
148 	FieldVariableType variable_type;
149 	FieldVariableComponentIndex component_index_1;
150 	FieldVariableComponentIndex component_index_2;
151 	bool is_not_for_plotting;	// this variable should not be available for the contour plotting
152 	//$EK 2012-11-07 dangerous use due to wrong use of copy constructer (only pointer is set -> also in operator=)
153 	const char * problem_specific_textual_identifier_without_components;
154 
155 public:
156 	// creation of a standard value info
157 	FieldVariableDescriptor(
158 		FieldVariableType variable_type,
159 		FieldVariableComponentIndex component_index_1 = FVCI_none,
160 		FieldVariableComponentIndex component_index_2 = FVCI_none
161 		);
162 	// creation of a problem specific value info;
163 	// the textual identifier will be saved; the string should not contain the components;
164 	// the string pointer will be saved, so that it must be constant
165 	// and valid during the life cycle of this FieldVariableDescriptor
166 	FieldVariableDescriptor(
167 		const char * textual_identifier,
168 		FieldVariableComponentIndex component_index_1 = FVCI_none,
169 		FieldVariableComponentIndex component_index_2 = FVCI_none
170 		);
171 	// copy constructor
172 	FieldVariableDescriptor(const FieldVariableDescriptor & fvd);
173 
174 	// when this function is called with true, the variable is marked to be unavailable for contout plotting
175 	void SetNotForPlotting(bool is_not_for_plotting_ = true) { is_not_for_plotting = is_not_for_plotting_; }
176 
177 	// actual variable type
VariableTypeFieldVariableDescriptor178 	FieldVariableType VariableType() const { return variable_type; }
179 	// actual components
ComponentIndex1FieldVariableDescriptor180 	FieldVariableComponentIndex ComponentIndex1() const { return component_index_1; }
ComponentIndex2FieldVariableDescriptor181 	FieldVariableComponentIndex ComponentIndex2() const { return component_index_2; }
182 	// whether this variable should not be available for the contour plotting
IsNotForPlottingFieldVariableDescriptor183 	bool IsNotForPlotting() const { return is_not_for_plotting; }
184 
185 	// these functions provide a short informative text description
186 	// for the user interface - with and without the notion of components
187 	mystr GetTextualIdentifier() const;		// full name - with components
188 	const char * GetTextualIdentifierWithoutComponents() const;
189 	const char * GetTextualIdentifierComponentsOnly() const;
190 	void InitializeFromTextualIdentifier(mystr & textualIdentifier);		// restores the state from the textual identifier
191 
192 	// dimensionality of the variable - evaluated depending on the FieldVariableType;
193 	// problem specific types are not supported in the present implementation
194 	virtual FieldVariableDimensionality GetDimensionality() const;
195 
196 private:
197 	// comparison for sorting to the desired order,
198 	// in which variables should appear in the user interface.
199 	// the functions returns -1 if "this" variable should go first, 0 if the variables are the same and +1 otherwise.
200 	int Compare(const FieldVariableDescriptor & fvd_another) const;
201 
202 public:
203 	bool operator==(const FieldVariableDescriptor & fvd) const
204 	{
205 		int rv = Compare(fvd);
206 		if(rv==0)
207 		{
208 			return true;
209 		}
210 		return false;
211 		//return
212 		//	variable_type == FVD.variable_type &&
213 		//	component_index_1 == FVD.component_index_1 &&
214 		//	component_index_2 == FVD.component_index_2;
215 	}
216 
217 public:
218 	// helper functions, which should be used to simplify the usage of this class:
219 
220 	// the contents of the array source will be merged to the contents of the array dest such,
221 	// that dest will contain only the unique elements in the order, determined by the Compare() function.
222 	static void MergeArrays(TArray<FieldVariableDescriptor> & dest, const TArray<FieldVariableDescriptor> & source);
223 	// adds to the array family of variable descriptors with the same main type;
224 	// when components are relevant, then the magnitude of the variable will be added.
225 	static void AddTypeIntoArray(
226 		TArray<FieldVariableDescriptor> & dest,														// array
227 		FieldVariableType variable_type,																	// type of the added variables
228 		FieldVariableComponentIndex component_index_range = FVCI_none,		// range of the components (if relevant)
229 		bool two_components_symbol = false,																// true - tensor (2-indexed-symbol), false - vector (1-indexed-symbol)
230 		bool symmetric = true																							// for tensors (2-indexed-symbols): if true, only the symmetric components will be added
231 		);
232 	// the same as before for problem specific types
233 	static void AddTypeIntoArray(
234 		TArray<FieldVariableDescriptor> & dest,														// array
235 		//$EK changed to const
236 		const char * textual_identifier,																				// string of text, which identifies the problem specific type
237 		FieldVariableComponentIndex component_index_range = FVCI_none,		// range of the components (if relevant)
238 		bool two_components_symbol = false,																// true - tensor (2-indexed-symbol), false - vector (1-indexed-symbol)
239 		bool symmetric = true																							// for tensors (2-indexed-symbols): if true, only the symmetric components will be added
240 		);
241 	// looks, if a type of variable descriptor is found in the array;
242 	// returns position of first occurence in the array, and returns 0 if not found.
243 	static int FindTypeInArray(
244 		TArray<FieldVariableDescriptor> & fvd_array,											// array
245 		FieldVariableType variable_type,																	// type of the added variables
246 		FieldVariableComponentIndex component_index_1,										// component 1
247 		FieldVariableComponentIndex component_index_2 = FVCI_none					// component 2 (if relevant)
248 		);
249 
250 	// the following functions compute corresponding components or magnitudes of a vector or a matrix
251 	double GetComponent(const Vector3D & v) const;
252 	double GetComponent(const Vector2D & v) const;
253 	double GetComponent(const Matrix3D & m) const;
254 	double GetComponent(const Matrix2D & m) const;
255 
256 private:
257 	// initializer
258 	void Initialize(FieldVariableType variable_type, FieldVariableComponentIndex component_index_1, FieldVariableComponentIndex component_index_2);
259 
260 public:
261 	void operator=(const FieldVariableDescriptor & fvd);
FieldVariableDescriptorFieldVariableDescriptor262 	FieldVariableDescriptor() {}
263 
264 	static char GetComponentsDelimiter();
265 };