TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Beam_model.cpp
1/****************************************************************************
2* Copyright (c) 2021, 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 <Beam_model.h>
17#include <Domaine_ALE.h>
18#include <TRUSTVects.h>
19#include <TRUSTTabs.h>
20#include <Probleme_base.h>
21#include <Domaine_VEF.h>
22#include <Domaine_Cl_VEF.h>
23#include <Frontiere.h>
24#include <MD_Vector_tools.h>
25#include <MD_Vector_std.h>
26#include <Faces.h>
27#include <fstream>
28#include <iostream>
29#include <math.h> /* sin */
30#include <TRUST_Ref.h>
31#include <Domaine.h>
32
33#define PI 3.14159265
34
35using namespace std;
36
37
38Implemente_instanciable_sans_constructeur_ni_destructeur(Beam_model, "Beam_model", Interprete_geometrique_base ) ;
39
40// Syntaxe:
41// Beam_model NOMDOMAINE {
42// nb_beam
43// Name
44// nb_modes number of modes
45// longitudinal_axis x|y|z
46// bendingDirection x|y|z
47// nb_planes 1|2
48// NewmarkTimeScheme MA|FD|HHT
49// Mass_and_stiffness_file_name
50// Absc_file_name
51// Modal_deformation_file_name nb_modes files
52// [ Young_Module ]
53// { Rho_beam ]
54// [ BaseCenterCoordinates position ]
55// [ CI_file_name ]
56// [ Output_position_1D nb_points position ]
57// [ Output_position_3D nb_points position ]
58// [ Restart_file_name file ]
59//
60// }
61// XD Beam_model interprete Beam_model NO_BRACE Reduced mechanical model: a beam model. Resolution based on a modal
62// XD_CONT analysis. Temporal discretization: Newmark or Hilber-Hughes-Taylor (HHT)
63// XD attr dom ref_domaine dom REQ domain name
64// XD attr bloc bloc_lecture_beam_model bloc REQ not_set
65
66// XD bloc_lecture_beam_model objet_lecture nul NO_BRACE bloc
67// XD attr aco chaine(into=["{"]) aco REQ Opening curly bracket.
68// XD attr nb_beam chaine(into=["nb_beam"]) nb_beam REQ Keyword to specify the number of beams
69// XD attr nb_beam_val entier nb_beam_val REQ Number of beams
70// XD attr Name chaine(into=["name"]) BeamName REQ keyword to specify the Name of the beam (the name must match with the
71// XD_CONT name of the edge in the fluid domain)
72// XD attr Name_of_beam chaine Name_of_beam REQ keyword to specify the Name of the beam (the name must match with the
73// XD_CONT name of the edge in the fluid domain)
74// XD attr bloc bloc_poutre bloc REQ not_set
75// XD attr Name2 chaine(into=["name"]) BeamName2 OPT keyword to specify the Name of the beam (the name must match with
76// XD_CONT the name of the edge in the fluid domain)
77// XD attr Name_of_beam2 chaine Name_of_beam2 OPT keyword to specify the Name of the beam (the name must match with the
78// XD_CONT name of the edge in the fluid domain)
79// XD attr bloc2 bloc_poutre bloc2 OPT not_set
80// XD attr acof chaine(into=["}"]) acof REQ Closing curly bracket.
81
82// XD NewmarkTimeScheme_deriv objet_lecture NewmarkTimeScheme_deriv INHERITS_BRACE Solve the beam dynamics. Selection of
83// XD_CONT time integration scheme.
84// XD NewmarkTimeScheme_HHT NewmarkTimeScheme_deriv HHT NO_BRACE HHT alpha (Hilber-Hughes-Taylor, alpha usually -0.1 )
85// XD_CONT time integration scheme.
86// XD attr alpha floattant alpha OPT usually, alpha is set to -0.1
87// XD NewmarkTimeScheme_MA NewmarkTimeScheme_deriv MA NO_BRACE MA (Newmark mean acceleration) time integration scheme.
88// XD NewmarkTimeScheme_FD NewmarkTimeScheme_deriv FD NO_BRACE FD (Newmark finite differences) time integration scheme.
89// XD_CONT Warning: this scheme is conditionally stable. The time step should satisfy the corresponding stability
90// XD_CONT constraint, but this implementation does not automatically enforce it.The Newmark finite difference scheme is
91// XD_CONT retained primarily for advanced users and benchmarking purposes.
92
93// XD bloc_poutre objet_lecture nul BRACE Read poutre bloc
94// XD attr nb_modes entier n REQ Number of modes. If there are two planes, indicate the total for both planes.
95// XD attr longitudinal_axis chaine dir REQ x, y, z. Axis along the length of the beam
96// XD attr bendingDirection chaine dir_bending REQ x, y, z . Direction of bending. If two planes, give the first one,
97// XD_CONT the second direction is determine automatically
98// XD attr nb_planes entier nplanes REQ Number of planes used in the beam dynamic model
99// XD attr NewmarkTimeScheme NewmarkTimeScheme_deriv NewmarkTimeScheme REQ Solve the beam dynamics. Time integration
100// XD_CONT scheme: choice between MA (Newmark mean acceleration), FD (Newmark finite differences), and HHT alpha
101// XD_CONT (Hilber-Hughes-Taylor, alpha usually -0.1 )
102// XD attr Mass_and_stiffness_file_name chaine Mass_and_stiffness_file_name REQ Name of the file containing the diagonal
103// XD_CONT modal mass, stiffness, and damping matrices. The file must contain nb_modes lines. When several bending
104// XD_CONT planes are defined, the modes must be ordered plane-by-plane. The first modes_per_plane lines correspond to
105// XD_CONT plane 0, the next modes_per_plane lines correspond to plane 1.
106// XD attr Absc_file_name chaine Absc_file_name REQ Name of the file containing the coordinates of the Beam
107// XD attr Modal_deformation_file_name listchaine Modal_deformation_file_name REQ Name of the file containing the modal
108// XD_CONT deformation of the Beam (Two-column modal deformation file: W(X) modal displacement and the rotation dW/dX
109// XD_CONT modal rotation).
110// XD attr Young_Module floattant young OPT Young Module
111// XD attr Rho_beam floattant rho OPT Beam density
112// XD attr BaseCenterCoordinates listf pos_center OPT position of the base center coordinates on the Beam
113// XD attr CI_file_name chaine CI_file_name OPT Name of the file containing the initial condition of the Beam. The
114// XD_CONT initial condition file must contain nb_modes displacement values, one per line. When several bending planes
115// XD_CONT are defined, the modes must be ordered plane-by-plane. The first modes_per_plane lines correspond to plane 0,
116// XD_CONT the next modes_per_plane lines correspond to plane 1.
117// XD attr Restart_file_name chaine Restart_file_name OPT SaveBeamForRestart.txt file to restart the calculation. The
118// XD_CONT file must contain nb_modes displacement values, one per line. When several bending planes are defined, the
119// XD_CONT modes must be ordered plane-by-plane. The first modes_per_plane lines correspond to plane 0, the next
120// XD_CONT modes_per_plane lines correspond to plane 1.
121// XD attr Output_position_1D list pt1d OPT nb_points position Post-traitement of specific points on the Beam
122// XD attr Output_position_3D listpoints pt3d OPT nb_points position Post-traitement of specific points on the 3d FSI
123// XD_CONT boundary
124
126{
127
128 nbModes_=0;
129 nb_planes_=1;
131 bending_dir_.resize(1);
132 bending_dir_=-1;
133 young_=200.e+9;
134 rho_ = 8100.;
135 alpha_= 0.;
136 beta_= 0.25;
137 gamma_=0.5;
138 temps_ =0.;
139 dt_stab_ = 1.e+8;
140 output_position_1D_.resize(0);
142 output_position_3D_.resize(0);
144 fluidForceOnBeam_.resize(0);
147 x0_=0.;
148 y0_=0.;
149 z0_=0.;
150 mass_.reset();
151 stiffness_.reset();
152 damping_.reset();
153 abscissa_.reset();
154 qSpeed_.reset();
155 qAcceleration_.reset();
156 qDisplacement_.reset();
157 output_position_1D_.reset();
158 output_position_3D_.reset();
159 beamName_= Nom();
160}
165
167{
168 return Interprete::printOn(os);
169}
170
172{
173 return Interprete::readOn(is);
174}
175
177{
179 Domaine_ALE& dom=ref_cast(Domaine_ALE, domaine());
180 dom.reading_beam_model(is);
181 return is;
182}
183
184void Beam_model::readInputMassStiffnessFiles(Nom& masse_and_stiffness_file_name)
185{
186 Cerr << "Reading beam model coefficients from file: " << masse_and_stiffness_file_name << finl;
187
188
189 if (nbModes_ % nb_planes_ != 0)
190 {
191 Cerr << "ERROR: invalid configuration. The number of modes (" << nbModes_
192 << ") must be divisible by the number of planes (" << nb_planes_ << ")." << finl;
193 Cerr << "Each plane must have the same number of modes." << finl;
195 }
196
197 int modes_per_plane= nbModes_/nb_planes_;
198
199 mass_.resize(modes_per_plane, nb_planes_);
200 stiffness_.resize(modes_per_plane, nb_planes_);
201 damping_.resize(modes_per_plane, nb_planes_);
202
203 const std::string filename(masse_and_stiffness_file_name);
204 std::ifstream monFlux(filename.c_str());
205
206 if (!monFlux)
207 {
208 Cerr << "ERROR: Unable to open file '" << filename << "'." << finl;
210 }
211
212 std::string line;
213 int index = 0;
214 int lineNumber = 0;
215
216 while (std::getline(monFlux, line))
217 {
218 ++lineNumber;
219
220 // Skip empty or whitespace-only lines
221 bool empty = true;
222 for (char c : line)
223 {
224 if (!std::isspace(static_cast<unsigned char>(c))) { empty = false; break; }
225 }
226 if (empty) continue;
227
228 // Skip comment lines starting with '#' or header lines (first line non-numeric)
229 std::istringstream issCheck(line);
230 double dummy;
231 if (!(issCheck >> dummy)) continue;
232
233 if (index >= nbModes_)
234 {
235 Cerr << "ERROR: File '" << filename << "' contains more data lines than nb_modes = "
236 << nbModes_ << " (at line " << lineNumber << ")." << finl;
238 }
239
240 // Parse exactly three values
241 std::istringstream iss(line);
242 double mass, stiffness, damping;
243
244 if (!(iss >> mass >> stiffness >> damping))
245 {
246 Cerr << "ERROR: In file '" << filename << "', line " << lineNumber
247 << " does not contain exactly three numerical values." << finl;
248 Cerr << "Line content: [" << line << "]" << finl;
250 }
251
252 // Check if a fourth value exists
253 double extra;
254 if (iss >> extra)
255 {
256 Cerr << "ERROR: In file '" << filename << "', line " << lineNumber
257 << " contains more than three values." << finl;
258 Cerr << "Line content: [" << line << "]" << finl;
260 }
261
262 if (std::abs(mass) <= 1.e-16 || std::abs(stiffness) <= 1.e-16)
263 {
264 Cerr << "ERROR: Invalid mass or stiffness in file '" << filename
265 << "' at line " << lineNumber << "." << finl;
266 Cerr << "mass = " << mass << ", stiffness = " << stiffness
267 << ", damping = " << damping << finl;
269 }
270 // Store values
271 int p = index / modes_per_plane; // plane index
272 int m = index % modes_per_plane; // mode index
273 mass_(m, p) = mass;
274 stiffness_(m, p) = stiffness;
275 damping_(m, p) = damping;
276 ++index;
277 }
278
279 if (index < nbModes_)
280 {
281 Cerr << "ERROR: File '" << filename << "' contains too few data lines. "
282 << "Expected nb_modes = " << nbModes_ << ", but only " << index << " valid lines were read." << finl;
284 }
285
286 Cerr << "Beam coefficients successfully read from '" << filename
287 << "' (" << index << " modes)." << finl;
288}
289
291{
292 Cerr << "Reading initial beam conditions from file: " << CI_file_name << finl;
293
294 if (nbModes_ % nb_planes_ != 0)
295 {
296 Cerr << "ERROR: invalid configuration. nb_modes (" << nbModes_
297 << ") must be divisible by nb_planes (" << nb_planes_ << ")." << finl;
299 }
300
301 int modes_per_plane = nbModes_ / nb_planes_;
302
303 qSpeed_.resize(modes_per_plane, nb_planes_);
304 qAcceleration_.resize(modes_per_plane, nb_planes_);
305 qDisplacement_.resize(modes_per_plane, nb_planes_);
306 fluidForceOnBeam_.resize(modes_per_plane, nb_planes_);
307
308 qSpeed_ = 0.;
309 qAcceleration_ = 0.;
310 qDisplacement_ = 0.;
312
313 const std::string filename(CI_file_name);
314 std::ifstream monFlux(filename.c_str());
315
316 if (!monFlux)
317 {
318 Cerr << "ERROR: Unable to open file '" << filename << "'." << finl;
320 }
321
322 std::string line;
323 int index = 0;
324 int lineNumber = 0;
325
326 while (std::getline(monFlux, line))
327 {
328 ++lineNumber;
329
330 // Skip empty or whitespace-only
331 bool empty = true;
332 for (char c : line)
333 if (!std::isspace(static_cast<unsigned char>(c))) { empty = false; break; }
334 if (empty) continue;
335
336 // Skip comments
337 if (line[0] == '#') continue;
338
339 // Skip non-numeric header lines
340 std::istringstream issCheck(line);
341 double dummy;
342 if (!(issCheck >> dummy)) continue;
343
344 if (index >= nbModes_)
345 {
346 Cerr << "ERROR: File '" << filename
347 << "' contains more data than expected (nb_modes = " << nbModes_
348 << "), at line " << lineNumber << "." << finl;
350 }
351
352 std::istringstream iss(line);
353 double displacement;
354
355 if (!(iss >> displacement))
356 {
357 Cerr << "ERROR: Invalid displacement value at line "
358 << lineNumber << " in file '" << filename << "'." << finl;
359 Cerr << "Line content: [" << line << "]" << finl;
361 }
362
363 // Ensure only one value per line
364 double extra;
365 if (iss >> extra)
366 {
367 Cerr << "ERROR: Too many values at line " << lineNumber
368 << " in file '" << filename << "'." << finl;
369 Cerr << "Line content: [" << line << "]" << finl;
371 }
372
373 int p = index / modes_per_plane; // plane index
374 int m = index % modes_per_plane; // mode index
375
376 qDisplacement_(m, p) = displacement;
377
378 // Compute initial acceleration
379 qAcceleration_(m, p) =
380 fluidForceOnBeam_(m, p) - (stiffness_(m, p) / mass_(m, p)) * displacement;
381
382 ++index;
383 }
384
385 // Check file length
386 if (index < nbModes_)
387 {
388 Cerr << "ERROR: File '" << filename << "' contains too few data lines. "
389 << "Expected " << nbModes_ << ", but found " << index << "." << finl;
391 }
392
393 Cerr << "Initial beam conditions successfully read from '" << filename
394 << "' (" << index << " values)." << finl;
395}
396
397
398void Beam_model::readRestartFile(Nom& Restart_file_name)
399{
400 Cerr << "Reading restart file: " << Restart_file_name << finl;
401
402 int modes_per_plane = nbModes_ / nb_planes_;
403
404 // Resize 2D arrays
405 qDisplacement_.resize(modes_per_plane, nb_planes_);
406 qSpeed_.resize(modes_per_plane, nb_planes_);
407 qAcceleration_.resize(modes_per_plane, nb_planes_);
408
409 const std::string filename(Restart_file_name);
410 std::ifstream monFlux(filename.c_str());
411
412 if (!monFlux)
413 {
414 Cerr << "ERROR: Unable to open restart file '" << filename << "'." << finl;
416 }
417
418 std::string line;
419 int index = 0;
420 int lineNumber = 0;
421
422 while (std::getline(monFlux, line))
423 {
424 ++lineNumber;
425
426
427 // Read exactly 4 values
428 std::istringstream iss(line);
429 double temps, displacement, speed, acceleration;
430
431 if (!(iss >> temps >> displacement >> speed >> acceleration))
432 {
433 Cerr << "ERROR: Line " << lineNumber << " in file '" << filename
434 << "' does not contain exactly 4 numerical values." << finl;
435 Cerr << "Line content: [" << line << "]" << finl;
437 }
438
439 // Check for extra values
440 double extra;
441 if (iss >> extra)
442 {
443 Cerr << "ERROR: Line " << lineNumber << " in file '" << filename
444 << "' contains more than 4 values." << finl;
445 Cerr << "Line content: [" << line << "]" << finl;
447 }
448
449 int plane = index / modes_per_plane;
450 int mode = index % modes_per_plane;
451
452 temps_ = temps;
453 qDisplacement_(mode, plane) = displacement;
454 qSpeed_(mode, plane) = speed;
455 qAcceleration_(mode, plane) = acceleration;
456
457 ++index;
458 }
459
460 // Check that all modes were read
461 if (index < nbModes_)
462 {
463 Cerr << "ERROR: File '" << filename << "' contains too few valid data lines. "
464 << "Expected nb_modes = " << nbModes_ << ", but only " << index << " were read." << finl;
466 }
467
469 Cerr << "Restart file successfully read from '" << filename
470 << "' (" << index << " modes, " << nb_planes_ << " planes)." << finl;
471}
472
474{
475 Cerr << "Reading beam coordinates from file: " << absc_file_name << finl;
476
477 const std::string filename(absc_file_name);
478 std::ifstream monFlux(filename.c_str());
479 if (!monFlux)
480 {
481 Cerr << "ERROR: Unable to open file '" << filename << "'." << finl;
483 }
484
485 // ===== First pass: validate lines and count valid numeric values =====
486 std::string line;
487 int lineNumber = 0;
488 int nValues = 0;
489
490 while (std::getline(monFlux, line))
491 {
492 ++lineNumber;
493
494 // Skip empty lines
495 if (line.find_first_not_of(" \t\n\r") == std::string::npos) continue;
496
497 // Skip comment lines
498 if (line[0] == '#') continue;
499
500 // Skip non-numeric headers
501 std::istringstream iss(line);
502 double absc;
503 if (!(iss >> absc)) continue;
504
505 // Check that there’s exactly one value
506 double extra;
507 if (iss >> extra)
508 {
509 Cerr << "ERROR: In file '" << filename << "', line " << lineNumber
510 << " contains more than one value." << finl;
511 Cerr << "Line content: [" << line << "]" << finl;
513 }
514
515 ++nValues; // count valid numeric lines
516 }
517
518 if (nValues == 0)
519 {
520 Cerr << "ERROR: No valid numeric values found in file '" << filename << "'." << finl;
522 }
523
524 // ===== Resize the DoubleVect to hold all values =====
525 abscissa_.resize(nValues);
526
527 // ===== Second pass: read and store values =====
528 monFlux.clear();
529 monFlux.seekg(0);
530
531 lineNumber = 0;
532 int i = 0;
533 while (std::getline(monFlux, line))
534 {
535 ++lineNumber;
536
537 // Skip empty lines
538 if (line.find_first_not_of(" \t\n\r") == std::string::npos) continue;
539
540 // Skip comment lines
541 if (line[0] == '#') continue;
542
543 // Skip non-numeric headers
544 std::istringstream issCheck(line);
545 double absc;
546 if (!(issCheck >> absc)) continue;
547
548 // Read the value
549 std::istringstream iss(line);
550 if (!(iss >> absc))
551 {
552 Cerr << "ERROR: Unable to read numeric value in file '" << filename
553 << "' at line " << lineNumber << "." << finl;
554 Cerr << "Line content: [" << line << "]" << finl;
556 }
557
558 abscissa_[i] = absc;
559 ++i;
560 }
561
562 Cerr << "Beam coordinates successfully read from '" << filename
563 << "' (" << abscissa_.size() << " points)." << finl;
564}
565
566void Beam_model::readInputModalDeformation(Noms& modal_deformation_file_name)
567{
568 if (nbModes_ == 0)
569 {
570 Cerr << "Error: no deformation modes defined. Use 'nb_modes'.\n";
572 }
573
574 if (nbModes_ != modal_deformation_file_name.size())
575 {
576 Cerr << "Error: mismatch: nbModes = " << nbModes_
577 << " but " << modal_deformation_file_name.size()
578 << " files provided.\n";
580 }
581
582 Cerr << "Reading beam modal deformation from: "
583 << modal_deformation_file_name << finl;
584
585 const int nPoints = abscissa_.size();
586 const int modes_per_plane = nbModes_ / nb_planes_;
587
588 std::vector<DoubleVect> tmp_u(nbModes_);
589 std::vector<DoubleVect> tmp_R(nbModes_);
590
591
592 for (int global_mode = 0; global_mode < nbModes_; ++global_mode)
593 {
594 const std::string filename(modal_deformation_file_name[global_mode]);
595 std::ifstream monFlux(filename.c_str());
596 if (!monFlux)
597 {
598 Cerr << "ERROR: Cannot open '" << filename << "'" << finl;
600 }
601
602 DoubleVect u_vec(nPoints);
603 DoubleVect R_vec(nPoints);
604
605 std::string lineContent;
606 int lineNumber = 0;
607 int k = 0;
608
609 while (std::getline(monFlux, lineContent))
610 {
611 ++lineNumber;
612
613 if (lineContent.find_first_not_of(" \t\r\n") == std::string::npos) continue;
614 if (lineContent[0] == '#') continue;
615
616 std::istringstream issCheck(lineContent);
617 double dummy;
618 if (!(issCheck >> dummy)) continue;
619
620 std::istringstream iss(lineContent);
621 double disp, rot;
622 if (!(iss >> disp >> rot))
623 {
624 Cerr << "ERROR: '" << filename << "', line "
625 << lineNumber << " : could not read two numeric values.\n";
627 }
628
629 // Check for extra tokens
630 double extra;
631 if (iss >> extra)
632 {
633 Cerr << "ERROR: '" << filename << "', line "
634 << lineNumber << " : line contains more than two values.\n";
635 Cerr << "Line: [" << lineContent << "]\n";
637 }
638
639 if (k >= nPoints)
640 {
641 Cerr << "ERROR: file '" << filename
642 << "' has too many data lines (expected " << nPoints << ").\n";
644 }
645
646 u_vec(k) = disp;
647 R_vec(k) = rot;
648 ++k;
649 }
650
651 if (k != nPoints)
652 {
653 Cerr << "ERROR: file '" << filename
654 << "' contains " << k << " valid data rows, expected "
655 << nPoints << ".\n";
657 }
658
659 tmp_u[global_mode] = u_vec;
660 tmp_R[global_mode] = R_vec;
661
662 monFlux.close();
663 }
664
665 u_.vide();
666 R_.vide();
667
668
669 for (int mode = 0; mode < modes_per_plane; ++mode)
670 {
671 DoubleTab Ut(nPoints, nb_planes_);
672 DoubleTab Rt(nPoints, nb_planes_);
673
674 for (int plane = 0; plane < nb_planes_; ++plane)
675 {
676 int global = plane * modes_per_plane + mode;
677 for (int p = 0; p < nPoints; ++p)
678 {
679 Ut(p, plane) = tmp_u[global](p);
680 Rt(p, plane) = tmp_R[global](p);
681 }
682 }
683 u_.add(Ut);
684 R_.add(Rt);
685 }
686
687 Cerr << "Modal deformation successfully loaded for "
688 << nbModes_ << " modes over " << nb_planes_ << " planes." << finl;
689}
690
691
692
693void Beam_model::initialization(double displacement)
694{
695 int modes_per_plane = nbModes_ / nb_planes_;
696
697 qSpeed_.resize(modes_per_plane, nb_planes_);
698 qAcceleration_.resize(modes_per_plane, nb_planes_);
699 qDisplacement_.resize(modes_per_plane, nb_planes_);
700 fluidForceOnBeam_.resize(modes_per_plane, nb_planes_);
701
702 qSpeed_ = 0.;
703 qAcceleration_ = 0.;
704 qDisplacement_ = displacement;
706}
708{
709 int modes_per_plane = nbModes_ / nb_planes_;
710
711 qSpeed_.resize(modes_per_plane, nb_planes_);
712 qAcceleration_.resize(modes_per_plane, nb_planes_);
713 qDisplacement_.resize(modes_per_plane, nb_planes_);
714 fluidForceOnBeam_.resize(modes_per_plane, nb_planes_);
715
716 qSpeed_ = 0.;
717 qAcceleration_ = 0.;
718 qDisplacement_ = 0.;
720}
721
722void Beam_model::interpolationWeights(const double& x, const double& y, const double& z, int& i, int& j, double& alpha, double& betha) const
723{
724
725 double h = abscissa_[1] -abscissa_[0]; //1d mesh pitch
726 int abscissa_size = abscissa_.size();
727 double s = 0.0;
728
729 switch (longitudinal_axis_)
730 {
731 case 0:
732 s = x;
733 break;
734 case 1:
735 s = y;
736 break;
737 default:
738 s = z;
739 break;
740 }
741
742 i = int(s / h);
743 j = (i + 1 < abscissa_size) ? i + 1 : i;
744
745 //linear interpolation between points i and j
746 if (i==j)
747 {
748 alpha=1.;
749 betha=0.;
750 }
751 else if(abs(abscissa_[i] - s)< 1.e-4)
752 {
753 alpha=1.;
754 betha=0.;
755 }
756 else if (abs(abscissa_[j] - s)< 1.e-4)
757 {
758 alpha=0.;
759 betha=1.;
760 }
761 else
762 {
763 alpha = (abscissa_[j] - s)/h;
764 betha = (s - abscissa_[i])/h;
765 if(alpha <0.)
766 {
767 alpha=0.;
768 betha=1.;
769 }
770 else if (betha < 0.)
771 {
772 alpha=1.;
773 betha=0.;
774 }
775
776 }
777}
778
779
780double Beam_model::interpolationPhiOnThe3DSurface(const double& x, const double& y, const double& z, const int& comp, const DoubleTab& u) const
781{
782 double alpha=0.0, betha=0.0 ;
783 int i=0, j=0;
784 interpolationWeights(x,y,z, i, j, alpha, betha);
785 double phi=alpha*u(i, comp) + betha*u(j, comp);
786
787 return phi;
788}
789
790DoubleTab Beam_model::interpolationOnThe3DSurface(const double& x, const double& y, const double& z, const DoubleTab& u, const DoubleTab& R) const
791{
792
793 double alpha=0.0, betha=0.0 ;
794 int i=0, j=0;
795 interpolationWeights(x,y,z, i, j, alpha, betha);
796
797 DoubleTab u_interp(nb_planes_), R_interp(nb_planes_);
798 for (int plane = 0; plane < nb_planes_; ++plane)
799 {
800 u_interp[plane]=alpha*u(i, plane) + betha*u(j, plane);
801 R_interp[plane]=alpha*R(i, plane) + betha*R(j, plane);
802 }
803
804 DoubleTab phi(3, nb_planes_); // 3 components: axial + 2 transverse
805 phi = 0.;
806
807 DoubleVect pos(3);
808 pos(0) = x - x0_; // relative X position from beam axis
809 pos(1) = y - y0_; // relative Y position from beam axis
810 pos(2) = z - z0_; // relative Z position from beam axis
811
812 for (int plane = 0; plane < nb_planes_; ++plane)
813 {
814 int e_long = longitudinal_axis_; // main axis of the beam (0=x,1=y,2=z)
815 int e_trans = bending_dir_[plane]; // bending direction for this plane
816
817 double W = u_interp[plane]; // transverse displacement
818 double Rot = R_interp[plane]; // derivative of displacement (rotation)
819
820 // indices of the remaining axes for computing axial displacement
821 int idx1 = (e_long + 1) % 3;
822 int idx2 = (e_long + 2) % 3;
823
824 if (e_trans == idx1)
825 {
826 phi(e_long, plane) = Rot * pos(idx2);
827 phi(idx2, plane) = 0.0; // transverse component perpendicular to bending
828 phi(idx1, plane) = W; // transverse along bending
829 }
830 else if (e_trans == idx2)
831 {
832 phi(e_long, plane) = -Rot * pos(idx1);
833 phi(idx1, plane) = 0.0; // transverse component perpendicular to bending
834 phi(idx2, plane) = W; // transverse along bending
835 }
836 else
837 {
838 //bending direction equals longitudinal axis
839 phi(e_long, plane) = 0.0;
840 phi(idx1, plane) = 0.0;
841 phi(idx2, plane) = 0.0;
842 }
843
844 }
845 return phi;
846}
847
849{
850 if (!je_suis_maitre()) return;
851
852 const Nom filename = beamName_ + "SaveBeamForRestart.txt";
853 std::ofstream ofs_sauve(filename, std::ofstream::out | std::ofstream::trunc);
854 ofs_sauve.precision(32);
855
856 if (!ofs_sauve)
857 {
858 Cerr << "ERROR: Unable to open file '" << filename << "' for writing restart data." << finl;
860 }
861
862 int modes_per_plane = nbModes_ / nb_planes_;
863
864 for (int plane = 0; plane < nb_planes_; ++plane)
865 {
866 for (int mode = 0; mode < modes_per_plane; ++mode)
867 {
868 ofs_sauve << temps_ << " "
869 << qDisplacement_(mode, plane) << " "
870 << qSpeed_(mode, plane) << " "
871 << qAcceleration_(mode, plane) << std::endl;
872 }
873 }
874
875 ofs_sauve.close();
876 Cerr << "Beam state saved for restart in '" << filename << "' ("
877 << nbModes_ << " modes, " << nb_planes_ << " planes)." << finl;
878}
879
880
881void Beam_model::printOutputBeam1D(bool first_writing) const
882{
883 if (!je_suis_maitre()) return;
884
885 int nb_output_points = output_position_1D_.size();
886 int modes_per_plane = nbModes_ / nb_planes_;
887
888 for (int plane = 0; plane < nb_planes_; ++plane)
889 {
890 //Compute 1D fields
891 DoubleVect displacement(nb_output_points);
892 DoubleVect velocity(nb_output_points);
893 DoubleVect acceleration(nb_output_points);
894
895 displacement = 0.;
896 velocity = 0.;
897 acceleration = 0.;
898
899 for (int mode = 0; mode < modes_per_plane; ++mode)
900 {
901 const DoubleTab& u = u_(mode);
902
903 for (int k = 0; k < nb_output_points; ++k)
904 {
905 int idx = int(output_position_1D_[k]);
906 displacement[k] += qDisplacement_(mode, plane) * u(idx, plane);
907 velocity[k] += qSpeed_(mode, plane) * u(idx, plane);
908 acceleration[k] += qAcceleration_(mode, plane) *u(idx, plane);
909
910 }
911 }
912
913 // ======== DISPLACEMENT FILE ========
914 {
915 Nom filename = beamName_;
916 filename += "_Displacement1D_plane_";
917 filename += Nom(plane);
918 filename += ".out";
919
920 SFichier out;
921 out.ouvrir(filename, first_writing ? ios::out : ios::app);
922 out.setf(ios::scientific);
923
924 if (first_writing)
925 {
926 out << "# Plane " << plane
927 << " Beam 1D displacement: time x y z at points ";
928 for (int k = 0; k < nb_output_points; ++k)
929 out << output_position_1D_[k] << " ";
930 out << finl;
931 }
932
933 out << temps_ << " ";
934 for (int k = 0; k < nb_output_points; ++k)
935 out << displacement[k] << " ";
936 out << finl;
937 }
938
939 // ======== VELOCITY FILE ========
940 {
941 Nom filename = beamName_;
942 filename += "_Velocity1D_plane_";
943 filename += Nom(plane);
944 filename += ".out";
945
946 SFichier out;
947 out.ouvrir(filename, first_writing ? ios::out : ios::app);
948 out.setf(ios::scientific);
949
950 if (first_writing)
951 {
952 out << "# Plane " << plane
953 << " Beam 1D velocity: time x y z at points ";
954 for (int k = 0; k < nb_output_points; ++k)
955 out << output_position_1D_[k] << " ";
956 out << finl;
957 }
958
959 out << temps_ << " ";
960 for (int k = 0; k < nb_output_points; ++k)
961 out << velocity[k] << " ";
962 out << finl;
963 }
964
965 // ======== ACCELERATION FILE ========
966 {
967 Nom filename = beamName_;
968 filename += "_Acceleration1D_plane_";
969 filename += Nom(plane);
970 filename += ".out";
971
972 SFichier out;
973 out.ouvrir(filename, first_writing ? ios::out : ios::app);
974 out.setf(ios::scientific);
975
976 if (first_writing)
977 {
978 out << "# Plane " << plane
979 << " Beam 1D acceleration: time x y z at points ";
980 for (int k = 0; k < nb_output_points; ++k)
981 out << output_position_1D_[k] << " ";
982 out << finl;
983 }
984
985 out << temps_ << " ";
986 for (int k = 0; k < nb_output_points; ++k)
987 out << acceleration[k] << " ";
988 out << finl;
989 }
990 }
991}
992
993
994
995void Beam_model::printOutputBeam3D(bool first_writing) const
996{
997 if (!je_suis_maitre()) return;
998 const int nb_output_points = output_position_3D_.dimension(0);
999 DoubleTab displacement(nb_output_points, 3);
1000 DoubleTab velocity(nb_output_points, 3);
1001 DoubleTab acceleration(nb_output_points, 3);
1002
1003 displacement = 0.;
1004 velocity = 0.;
1005 acceleration = 0.;
1006
1007 const int modes_per_plane = qDisplacement_.dimension(0);
1008 const int nb_planes = qDisplacement_.dimension(1);
1009
1010 DoubleTab phi3D(3, nb_planes);
1011
1012 for (int p = 0; p < nb_planes; p++)
1013 {
1014 for (int m = 0; m < modes_per_plane; m++)
1015 {
1016 const DoubleTab& u = u_(m);
1017 const DoubleTab& R = R_(m);
1018
1019 for (int k = 0; k < nb_output_points; k++)
1020 {
1021
1025 u, R);
1026
1027 for (int i = 0; i < 3; i++)
1028 {
1029 displacement(k,i) += qDisplacement_(m,p) * phi3D(i,p);
1030 velocity(k,i) += qSpeed_(m,p) * phi3D(i,p);
1031 acceleration(k,i) += qAcceleration_(m,p) * phi3D(i,p);
1032 }
1033 }
1034 }
1035 }
1036
1037
1038
1039 Nom filename_disp(beamName_ + "_Displacement3D.out");
1040 Nom filename_speed(beamName_ + "_Velocity3D.out");
1041 Nom filename_acc(beamName_ + "_Acceleration3D.out");
1042
1043 if (!displacement_out_3d_.is_open())
1044 {
1045 displacement_out_3d_.ouvrir(filename_disp, (first_writing ? ios::out : ios::app));
1046 displacement_out_3d_.setf(ios::scientific);
1047 }
1048 if (!speed_out_3d_.is_open())
1049 {
1050 speed_out_3d_.ouvrir(filename_speed, (first_writing ? ios::out : ios::app));
1051 speed_out_3d_.setf(ios::scientific);
1052 }
1053 if (!acceleration_out_3d_.is_open())
1054 {
1055 acceleration_out_3d_.ouvrir(filename_acc, (first_writing ? ios::out : ios::app));
1056 acceleration_out_3d_.setf(ios::scientific);
1057 }
1058
1059 // --- HEADER ---
1060 if (first_writing)
1061 {
1062 displacement_out_3d_ << "# 3D beam displacement: time, (x,y,z) at each output point ";
1063 speed_out_3d_ << "# 3D beam velocity: time, (x,y,z) at each output point ";
1064 acceleration_out_3d_ << "# 3D beam acceleration: time, (x,y,z) at each output point ";
1065
1066 for (int k = 0; k < nb_output_points; k++)
1067 displacement_out_3d_ << "( " << output_position_3D_(k,0) << " " << output_position_3D_(k,1) << " " << output_position_3D_(k,2) << " ) ";
1068
1069 displacement_out_3d_ << finl;
1070
1071 for (int k = 0; k < nb_output_points; k++)
1072 speed_out_3d_ << "( " << output_position_3D_(k,0) << " " << output_position_3D_(k,1) << " " << output_position_3D_(k,2) << " ) ";
1073
1074 speed_out_3d_ << finl;
1075
1076 for (int k = 0; k < nb_output_points; k++)
1077 acceleration_out_3d_ << "( " << output_position_3D_(k,0) << " " << output_position_3D_(k,1) << " " << output_position_3D_(k,2) << " ) ";
1078
1079 acceleration_out_3d_ << finl;
1080 }
1081
1082 // --- WRITE VALUES ---
1083 displacement_out_3d_ << temps_ << " ";
1084 speed_out_3d_ << temps_ << " ";
1085 acceleration_out_3d_ << temps_ << " ";
1086
1087 for (int k = 0; k < nb_output_points; k++)
1088 {
1089 for (int i = 0; i < 3; i++)
1090 {
1091 displacement_out_3d_ << displacement(k,i) << " ";
1092 speed_out_3d_ << velocity(k,i) << " ";
1093 acceleration_out_3d_ << acceleration(k,i) << " ";
1094 }
1095 }
1096
1097 displacement_out_3d_ << finl;
1098 speed_out_3d_ << finl;
1099 acceleration_out_3d_ << finl;
1100
1101}
1102
1103void Beam_model::printOutputFluidForceOnBeam(bool first_writing) const
1104{
1105 if (!je_suis_maitre())
1106 return;
1107
1108 int modes_per_plane = nbModes_ / nb_planes_;
1109
1110 for (int plane = 0; plane < nb_planes_; ++plane)
1111 {
1112 // Build the filename for this plane
1113 Nom filename = beamName_;
1114 filename += "_ModalForceFluide1D_plane_";
1115 filename += Nom(plane);
1116 filename += ".out";
1117
1118 // Open the file: overwrite if first writing, append otherwise
1119 SFichier out;
1120 out.ouvrir(filename, (first_writing ? ios::out : ios::app));
1121 out.setf(ios::scientific);
1122
1123 // ===== Header =====
1124 if (first_writing)
1125 {
1126 out << "# Modal fluid force for plane " << plane << ": time ";
1127 for (int m = 0; m < modes_per_plane; ++m)
1128 out << "(mode " << m + 1 << ") ";
1129 out << finl;
1130 }
1131 else
1132 {
1133 // ===== Values =====
1134 out << temps_ << " ";
1135 for (int m = 0; m < modes_per_plane; ++m)
1136 out << fluidForceOnBeam_(m, plane) << " ";
1137 out << finl;
1138 }
1139 out.close();
1140 }
1141}
1142
1143
1144
1145void Beam_model::setCenterCoordinates(const double& x0,const double& y0, const double& z0)
1146{
1147 x0_=x0;
1148 y0_=y0;
1149 z0_=z0;
1150}
1151
1152DoubleTab& Beam_model::getVelocity(const double& tps, const double& dt)
1153{
1154 if(dt == 0.)
1155 {
1156 return qSpeed_;
1157 }
1158 else if(temps_!=tps) // update qSpeed_ only once per time step!
1159 {
1160 temps_=tps;
1161 return NewmarkScheme(dt);
1162
1163 }
1164 else
1165 return qSpeed_;
1166}
1167
1168//Solve the beam dynamics. Time integration scheme
1169DoubleTab& Beam_model::NewmarkScheme(const double& dt)
1170{
1171 double squareDt = dt * dt;
1172 int modes_per_plane = nbModes_ / nb_planes_;
1173
1174 // Loop over planes
1175 for (int plane = 0; plane < nb_planes_; ++plane)
1176 {
1177 for (int mode = 0; mode < modes_per_plane; ++mode)
1178 {
1179 // Predict displacement and speed
1180 double qDispl_pred = qDisplacement_(mode, plane) + dt * qSpeed_(mode, plane)
1181 + squareDt * (0.5 - beta_) * qAcceleration_(mode, plane);
1182 double qSpeed_pred = qSpeed_(mode, plane) + dt * (1. - gamma_) * qAcceleration_(mode, plane);
1183
1184 // Newmark coefficients
1185 double coeff1 = mass_(mode, plane)
1186 + dt * gamma_ * (1. + alpha_) * damping_(mode, plane)
1187 + squareDt * beta_ * (1. + alpha_) * stiffness_(mode, plane);
1188 double coeff2 = (1. + alpha_) * damping_(mode, plane) * qSpeed_pred;
1189 double coeff3 = (1. + alpha_) * stiffness_(mode, plane) * qDispl_pred;
1190 double coeff4 = alpha_ * stiffness_(mode, plane) * qDisplacement_(mode, plane);
1191 double coeff5 = alpha_ * damping_(mode, plane) * qSpeed_(mode, plane);
1192
1193 // Update acceleration, displacement, and speed
1194 qAcceleration_(mode, plane) = (fluidForceOnBeam_(mode, plane) - coeff2 - coeff3 + coeff4 + coeff5) / coeff1;
1195 qDisplacement_(mode, plane) = qDispl_pred + squareDt * beta_ * qAcceleration_(mode, plane);
1196 qSpeed_(mode, plane) = qSpeed_pred + dt * gamma_ * qAcceleration_(mode, plane);
1197 }
1198 }
1199
1201 if (output_position_1D_.size() > 0) printOutputBeam1D();
1202 if (output_position_3D_.size() > 0) printOutputBeam3D();
1203
1204 return qSpeed_;
1205}
1206
1207
1208
1210{
1211 Motcle open_brace("{");
1212 Motcle close_brace("}");
1213 Motcle motlu;
1214 Nom nomlu;
1215 Nom masse_and_stiffness_file_name;
1216 Noms phi_file_name;
1217 Nom absc_file_name;
1218 Nom CI_file_name="none";
1219 Nom Restart_file_name="none";
1220 int var_int=0;
1221 int nb_modes=0;
1222 int nb_output_points_1D=0;
1223 DoubleVect output_position_1D(nb_output_points_1D);
1224 int nb_output_points_3D=0;
1225 DoubleTab output_position_3D(nb_output_points_3D,0);
1226 double var_double;
1227 is >> motlu;
1228 if (motlu != open_brace)
1229 {
1230 Cerr << "Error while reading Beam\n";
1231 Cerr << "Expected a { but found: "<< motlu;
1232 Process::exit();
1233 }
1234 while(1)
1235 {
1236 // reading a boundary name or }
1237 is >> nomlu;
1238 motlu=nomlu;
1239 if(motlu=="nb_modes")
1240 {
1241 is >> nb_modes;
1242 nbModes_=nb_modes;
1243 Cerr << "Number of modes : " << nbModes_ << finl;
1244 }
1245 if(motlu=="nb_planes")
1246 {
1247 is >> var_int;
1248
1249 // Validate that number of planes is either 1 or 2
1250 if (var_int != 1 && var_int != 2)
1251 {
1252 Cerr << "ERROR: invalid number of beam planes: " << var_int << finl;
1253 Cerr << "Valid values are: 1 or 2." << finl;
1254 Process::exit();
1255 }
1256 nb_planes_=var_int;
1257 Cerr << "Number of planes : " << nb_planes_ << finl;
1258 }
1259 if(motlu=="longitudinal_axis")
1260 {
1261 is >> nomlu;
1262 if (nomlu == "x" || nomlu == "X")
1263 var_int = 0;
1264 else if (nomlu == "y" || nomlu == "Y")
1265 var_int = 1;
1266 else if (nomlu == "z" || nomlu == "Z")
1267 var_int = 2;
1268 else
1269 {
1270 Cerr << "ERROR: invalid main axis: " << nomlu
1271 << "'. Valid options are: x, y, or z." << finl;
1272 Process::exit();
1273 }
1274 longitudinal_axis_=var_int;
1275 Cerr << "Longitudinal axis : " << longitudinal_axis_ << finl;
1276 }
1277 if(motlu=="bendingDirection")
1278 {
1279 is >> nomlu;
1280 if (nomlu == "x" || nomlu == "X")
1281 var_int = 0;
1282 else if (nomlu == "y" || nomlu == "Y")
1283 var_int = 1;
1284 else if (nomlu == "z" || nomlu == "Z")
1285 var_int = 2;
1286 else
1287 {
1288 Cerr << "ERROR: invalid direction of bending: '" << nomlu
1289 << "'. Valid options are: x, y, or z." << finl;
1290 Process::exit();
1291 }
1292 bending_dir_[0]=var_int;
1293 Cerr << "Bending direction : " << bending_dir_ << finl;
1294 }
1295 if(motlu=="BaseCenterCoordinates")
1296 {
1297 is >> var_double;
1298 double x=var_double;
1299 is >> var_double;
1300 double y=var_double;
1301 is >> var_double;
1302 double z=var_double;
1303 setCenterCoordinates(x,y,z);
1304
1305 }
1306 if(motlu=="Young_Module")
1307 {
1308 is >> var_double;
1309 young_=var_double;
1310 Cerr << "Young module : " << young_ << finl;
1311 }
1312 if(motlu=="Rho_beam")
1313 {
1314 is >> var_double;
1315 rho_=var_double;
1316 Cerr << "Rho beam : " << rho_ << finl;
1317 }
1318 if(motlu=="Mass_and_stiffness_file_name")
1319 {
1320 is >> nomlu;
1321 masse_and_stiffness_file_name=nomlu;
1322
1323 }
1324 if(motlu=="Absc_file_name")
1325 {
1326 is >> nomlu;
1327 absc_file_name=nomlu;
1328
1329 }
1330 if(motlu=="CI_file_name")
1331 {
1332 is >> nomlu;
1333 CI_file_name=nomlu;
1334
1335 }
1336
1337 if(motlu=="Modal_deformation_file_name")
1338 {
1339 is >> var_int;
1340 for (int i=0; i< var_int; i ++)
1341 {
1342 is >>nomlu;
1343 phi_file_name.add(nomlu);
1344 }
1345 }
1346 if(motlu=="NewmarkTimeScheme")
1347 {
1348 is >> nomlu;
1349 double alpha=-0.1; //default value
1350 if(nomlu =="HHT")
1351 {
1352 is>>alpha;
1353 }
1354 setTimeScheme(nomlu, alpha);
1355
1356 }
1357 if(motlu=="Output_position_1D")
1358 {
1359 Cerr << "Beam Output_position_1D "<< finl;
1360 is>>nb_output_points_1D;
1361 output_position_1D.resize(nb_output_points_1D);
1362 double poz;
1363 for (int i=0; i< nb_output_points_1D; i ++)
1364 {
1365 is >>poz;
1366 output_position_1D[i]=poz;
1367 }
1368
1369 setOutputPosition1D(output_position_1D);
1370 }
1371 if(motlu=="Output_position_3D")
1372 {
1373 Cerr << "Beam Output_position_3D "<< finl;
1374 is>>nb_output_points_3D;
1375 output_position_3D.resize(nb_output_points_3D, 3);
1376 double poz=0.;
1377 for (int i=0; i< nb_output_points_3D; i ++)
1378 {
1379 for (int j=0; j< 3; j ++)
1380 {
1381 is >>poz;
1382 output_position_3D(i,j)=poz;
1383 }
1384 }
1385 setOutputPosition3D(output_position_3D);
1386 }
1387 if (motlu=="Restart_file_name")
1388 {
1389 is >> nomlu;
1390 Restart_file_name=nomlu;
1391 }
1392 if (motlu=="direction")
1393 {
1394 Cerr << "Error: Syntax changed in v1.9.7. You should now replace:" << finl;
1395 Cerr << " 'direction N'" << finl;
1396 Cerr << " by something like:" << finl;
1397 Cerr << " 'longitudinal_axis X'" << finl;
1398 Cerr << " 'bendingDirection Y'" << finl;
1399 Process::exit();
1400 }
1401
1402 if (motlu == close_brace)
1403 break;
1404 }
1405
1406 // Warning: Do NOT change the order of these function calls. The correct execution of the code depends on this sequence.
1407 if (longitudinal_axis_==-1)
1408 {
1409 Cerr << "ERROR: you must specify the axis along the length of the beam."<<finl;
1410 Process::exit();
1411 }
1412 if (bending_dir_[0] == -1)
1413 {
1414 Cerr << "ERROR: you must specify the bending direction."<<finl;
1415 Process::exit();
1416 }
1417
1418 // Check that the first bending direction is not the longitudinal axis
1420 {
1421 Cerr << "ERROR: invalid bendingDirection: it must be different from the longitudinal_axis."<<finl;
1422 Process::exit();
1423 }
1424
1425 // If there are two bending planes, determine the second direction automatically
1426 if (nb_planes_ == 2)
1427 {
1428 bending_dir_.resize(2);
1429
1430 // The second bending direction is the remaining axis among {0,1,2}
1431 for (int axis = 0; axis < 3; ++axis)
1432 {
1433 if (axis != longitudinal_axis_ && axis != bending_dir_[0])
1434 {
1435 bending_dir_[1] = axis;
1436 break;
1437 }
1438 }
1439 }
1440
1441 // Warning: Do NOT change the order of these function calls. The correct execution of the code depends on this sequence.
1442 readInputAbscFiles(absc_file_name);
1443 readInputMassStiffnessFiles(masse_and_stiffness_file_name);
1444 readInputModalDeformation(phi_file_name);
1445 if(CI_file_name!="none")
1446 {
1447 readInputCIFile(CI_file_name);
1448 }
1449 else
1450 {
1452 }
1453 if(Restart_file_name!="none")
1454 {
1455 readRestartFile(Restart_file_name);
1456 }
1457 else
1458 {
1459 if(je_suis_maitre())
1460 {
1461 bool first_writing=true;
1462 printOutputFluidForceOnBeam(first_writing);
1463 if (nb_output_points_1D>0)
1464 printOutputBeam1D(first_writing);
1465 if (nb_output_points_3D>0)
1466 printOutputBeam3D(first_writing);
1467 }
1468 }
1469}
1470
void setTimeScheme(const Nom &, double &)
Definition Beam_model.h:184
DoubleTab qDisplacement_
Definition Beam_model.h:110
double x0_
Definition Beam_model.h:124
double rho_
Definition Beam_model.h:101
void initialization()
double tempsComputeForceOnBeam_
Definition Beam_model.h:123
void readInputAbscFiles(Nom &absc_file_name)
DoubleTab & getVelocity(const double &tps, const double &dt)
void saveBeamForRestart() const
IntVect bending_dir_
Definition Beam_model.h:98
int nb_planes_
Definition Beam_model.h:99
void printOutputFluidForceOnBeam(bool first_writing=false) const
DoubleTab fluidForceOnBeam_
Definition Beam_model.h:122
void printOutputBeam1D(bool first_writing=false) const
Entree & interpreter_(Entree &) override
double temps_
Definition Beam_model.h:112
DoubleTab interpolationOnThe3DSurface(const double &x, const double &y, const double &z, const DoubleTab &u, const DoubleTab &R) const
double young_
Definition Beam_model.h:100
void readInputCIFile(Nom &CI_file_name)
void interpolationWeights(const double &, const double &, const double &, int &, int &, double &, double &) const
DoubleVect abscissa_
Definition Beam_model.h:105
DoubleTab qAcceleration_
Definition Beam_model.h:109
DoubleTab qSpeed_
Definition Beam_model.h:108
void setCenterCoordinates(const double &, const double &, const double &)
void setOutputPosition3D(const DoubleTab &)
Definition Beam_model.h:249
void printOutputBeam3D(bool first_writing=false) const
DoubleVect output_position_1D_
Definition Beam_model.h:113
double alpha_
Definition Beam_model.h:116
DoubleTab damping_
Definition Beam_model.h:104
double interpolationPhiOnThe3DSurface(const double &x, const double &y, const double &z, const int &comp, const DoubleTab &u) const
SFichier displacement_out_3d_
Definition Beam_model.h:127
double dt_stab_
Definition Beam_model.h:119
DoubleTab output_position_3D_
Definition Beam_model.h:114
void readRestartFile(Nom &Restart_file_name)
SFichier speed_out_3d_
Definition Beam_model.h:128
DoubleTab stiffness_
Definition Beam_model.h:103
SFichier acceleration_out_3d_
Definition Beam_model.h:129
DoubleTab & NewmarkScheme(const double &dt)
void read_beam(Entree &is)
double beta_
Definition Beam_model.h:117
void readInputMassStiffnessFiles(Nom &masse_and_stiffness_file_name)
void setOutputPosition1D(const DoubleVect &)
Definition Beam_model.h:244
DoubleTab mass_
Definition Beam_model.h:102
int longitudinal_axis_
Definition Beam_model.h:97
double y0_
Definition Beam_model.h:125
void readInputModalDeformation(Noms &modal_deformation_file_name)
double gamma_
Definition Beam_model.h:118
double z0_
Definition Beam_model.h:126
void reading_beam_model(Entree &is)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
friend class Entree
Definition Objet_U.h:76
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Definition Process.cpp:86
Cette classe est a la classe C++ ofstream ce que la classe Sortie est a la classe C++ ostream Elle re...
Definition SFichier.h:27
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
void setf(IOS_FORMAT code) override
Classe de base des flux de sortie.
Definition Sortie.h:52
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91