OOFEM 3.0
Loading...
Searching...
No Matches
sparsenonlinsystemnm.C
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
36#include "error.h"
37#include "domain.h"
38#include "node.h"
40
41namespace oofem {
42
43void
44SparseNonLinearSystemNM :: initializeFrom(InputRecord &ir)
45{
48 if ( randPertAmplitude < 0. ) {
49 throw ValueInputException(ir, _IFT_NonLinearStatic_randPertAmplitude, "Random pertubation amplitude can not be negative");
50 }
51 randSeed = 0;
53
54 // optional parameters related to perturbations of the initial guess (first iteration)
57 igp_PertWeightArray.clear();
59 if ( igp_PertDmanDofSrcArray.giveSize() ) {
60 if ( ( igp_PertDmanDofSrcArray.giveSize() % 2 ) != 0 ) {
61 throw ValueInputException(ir, _IFT_NonLinearStatic_pert, "Pert map size must be an even number, it contains pairs <node, nodeDof>");
62 }
63 int nsize = igp_PertDmanDofSrcArray.giveSize() / 2;
64 if ( igp_PertWeightArray.giveSize() != nsize ) {
65 throw ValueInputException(ir, _IFT_NonLinearStatic_pert, "Pert map size and weight array size mismatch");
66 }
67 pert_init_needed = true;
68 } else {
69 pert_init_needed = false;
70 }
71}
72
73void
74SparseNonLinearSystemNM :: convertPertMap()
75{
77 int count = 0, ndofman = this -> domain -> giveNumberOfDofManagers();
78 int size = igp_PertDmanDofSrcArray.giveSize() / 2;
79 igp_Map.resize(size);
80 igp_Weight.resize(size);
81
82 for ( int j = 1; j <= ndofman; j++ ) {
83 int jglobnum = this->domain->giveNode(j)->giveLabel();
84 for ( int i = 1; i <= size; i++ ) {
85 int inode = igp_PertDmanDofSrcArray.at(2 * i - 1);
86 int idof = igp_PertDmanDofSrcArray.at(2 * i);
87 if ( inode == jglobnum ) {
88 igp_Map.at(++count) = this -> domain ->giveNode(j)->giveDofWithID(idof)->giveEquationNumber(dn);
89 igp_Weight.at(count) = igp_PertWeightArray.at(i);
90 continue;
91 }
92 }
93 }
94}
95
96void
97SparseNonLinearSystemNM :: applyPerturbation(FloatArray* displacement)
98{
99 int nsize;
100
101 // First type of perturbation - random perturbation with uniform probability density
102 // over the interval (-randPertAmplitude,randPertAmplitude) applied on each unknown.
103 if (randPertAmplitude > 0.) {
104 nsize = displacement -> giveSize();
105 srand(randSeed);
106 for ( int i = 1; i <= nsize; i++ ) {
107 double pert = randPertAmplitude * (2. * rand() / RAND_MAX - 1.);
108 displacement->at(i) += pert;
109 }
110 }
111
112 // Second type of perturbation - only selected unknowns perturbed by the amount specified by the user.
113 if ( pert_init_needed ) {
115 pert_init_needed = false;
116 }
117
118 nsize = igp_Weight.giveSize();
119 for ( int i = 1; i <= nsize; i++ ) {
120 int iDof = igp_Map.at(i);
121 double w = igp_Weight.at(i);
122 displacement->at(iDof) += w;
123 }
124}
125
126} // end namespace oofem
double & at(Index i)
Definition floatarray.h:202
Domain * domain
Pointer to domain.
Definition nummet.h:84
double randPertAmplitude
Amplitude of a random perturbation applied on the solution before the iteration process.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define _IFT_NonLinearStatic_randPertAmplitude
#define _IFT_NonLinearStatic_pert
#define _IFT_NonLinearStatic_pertw
#define _IFT_NonLinearStatic_randSeed

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011