TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Rotation.cpp
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Rotation.h>
17
18Implemente_instanciable(Rotation,"Rotation",Transformer);
19// XD rotation interprete rotation INHERITS_BRACE Keyword to rotate the geometry of an arbitrary angle around an axis
20// XD_CONT aligned with Ox, Oy or Oz axis.
21// XD attr domain_name ref_domaine domain_name REQ Name of domain to wich the transformation is applied.
22// XD attr dir chaine(into=["X","Y","Z"]) dir REQ X, Y or Z to indicate the direction of the rotation axis
23// XD attr coord1 floattant coord1 REQ coordinates of the center of rotation in the plane orthogonal to the rotation
24// XD_CONT axis. These coordinates must be specified in the direct triad sense.
25// XD attr coord2 floattant coord2 REQ not_set
26// XD attr angle floattant angle REQ angle of rotation (in degrees)
27
28
29/*! @brief Simple call to: Transformer::printOn(Sortie&)
30 *
31 * @param (Sortie& os) an output stream
32 * @return (Sortie&) the modified output stream
33 */
35{
36 return Transformer::printOn(os);
37}
38
39/*! @brief Simple call to: Transformer::ReadOn(Sortie&)
40 *
41 * @param (Entree& is) an input stream
42 * @return (Entree&) the modified input stream
43 */
45{
46 return Transformer::readOn(is);
47}
48
50{
53
54 Noms les_fcts;
55 les_fcts.dimensionner(dimension);
56
57 int dir_axe,dir1,dir2;
58 double coor1,coor2,angle;
59 Nom axe_direction,nomc1,nomc2,nomang;
60 Nom var1,var2,var_axe;
61 double pi = M_PI;
62 is>>axe_direction;
63 ////is>>dir_axe;
64 dir_axe=-1;
65 if (Motcle(axe_direction)=="X")
66 dir_axe=0;
67 else if (Motcle(axe_direction)=="Y")
68 dir_axe=1;
69 else if (Motcle(axe_direction)=="Z")
70 dir_axe=2;
71 else
72 {
73 Cerr<<"The direction of the rotation axis must be specified by X, Y or Z"<<finl;
74 exit();
75 }
76
77 is>>coor1>>coor2>>angle;
78 angle = (2*pi)*(angle/360.);
79 nomc1 = Nom(coor1);
80 nomc2 = Nom(coor2);
81 nomang = Nom(angle);
82
83 dir1=-1;
84 dir2=-1;
85 if (dimension==3)
86 {
87 if (dir_axe==0)
88 {
89 var1="(y-";
90 var2="(z-";
91 var_axe="x";
92 dir1=1;
93 dir2=2;
94 }
95 else if (dir_axe==1)
96 {
97 var1="(z-";
98 var2="(x-";
99 var_axe="y";
100 dir1=2;
101 dir2=0;
102 }
103 else if (dir_axe==2)
104 {
105 var1="(x-";
106 var2="(y-";
107 var_axe="z";
108 dir1=0;
109 dir2=1;
110 }
111
112 les_fcts[dir_axe] = var_axe;
113 }
114 else
115 {
116 var1="(x-";
117 var2="(y-";
118 dir1=0;
119 dir2=1;
120 }
121
122 les_fcts[dir1] = var1;
123 les_fcts[dir1] += "(";
124 les_fcts[dir1] += nomc1;
125 les_fcts[dir1] += ")";
126 les_fcts[dir1] += ")*cos(";
127 les_fcts[dir1] += nomang;
128 les_fcts[dir1] += ")-";
129 les_fcts[dir1] += var2;
130 les_fcts[dir1] += "(";
131 les_fcts[dir1] += nomc2;
132 les_fcts[dir1] += ")";
133 les_fcts[dir1] += ")*sin(";
134 les_fcts[dir1] += nomang;
135 les_fcts[dir1] += ")";
136 les_fcts[dir1] += "+(";
137 les_fcts[dir1] += nomc1;
138 les_fcts[dir1] += ")";
139
140 les_fcts[dir2] = var1;
141 les_fcts[dir2] += "(";
142 les_fcts[dir2] += nomc1;
143 les_fcts[dir2] += ")";
144 les_fcts[dir2] += ")*sin(";
145 les_fcts[dir2] += nomang;
146 les_fcts[dir2] += ")+";
147 les_fcts[dir2] += var2;
148 les_fcts[dir2] += "(";
149 les_fcts[dir2] += nomc2;
150 les_fcts[dir2] += ")";
151 les_fcts[dir2] += ")*cos(";
152 les_fcts[dir2] += nomang;
153 les_fcts[dir2] += ")";
154 les_fcts[dir2] += "+(";
155 les_fcts[dir2] += nomc2;
156 les_fcts[dir2] += ")";
157
158 transformation_complete(les_fcts);
159 return is;
160}
161
162
163
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
static int dimension
Definition Objet_U.h:94
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Class Rotation Applies a rotation around an axis aligned with one of the coordinate axes.
Definition Rotation.h:34
Entree & interpreter_(Entree &) override
Definition Rotation.cpp:49
Base class for output streams.
Definition Sortie.h:52
void transformation_complete(Noms &les_fcts)