OOFEM 3.0
Loading...
Searching...
No Matches
domaintransactionmanager.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 "dofmanager.h"
38#include "element.h"
39#include "domain.h"
40
41namespace oofem {
42DomainTransactionManager :: DomainTransactionManager(Domain *d)
43{
44 this->domain = d;
45}
46
47DomainTransactionManager :: ~DomainTransactionManager()
48{
49 if ( !( dofmanTransactions.empty() && elementTransactions.empty() ) ) {
50 OOFEM_WARNING("uncommited transactions exist");
51 }
52}
53
54void
55DomainTransactionManager :: initialize()
56{ }
57
58int
59DomainTransactionManager :: addDofManTransaction(DomainTransactionType dtt, int label, DofManager *obj)
60{
61 if ( dtt == DTT_Remove ) {
62 obj = NULL;
63 }
64
65 if ( dofmanTransactions.find(label) != dofmanTransactions.end() ) {
66 // local enry exist
67 // delete previous record
68 if ( dofmanTransactions [ label ] ) {
69 delete dofmanTransactions [ label ];
70 }
71 }
72
73 // set new record
74 dofmanTransactions [ label ] = obj;
75
76 return 1;
77}
78
79int
80DomainTransactionManager :: addElementTransaction(DomainTransactionType dtt, int label, Element *obj)
81{
82 if ( dtt == DTT_Remove ) {
83 obj = NULL;
84 }
85
86 if ( elementTransactions.find(label) != elementTransactions.end() ) {
87 // local enry exist
88 // delete previous record
89 if ( elementTransactions [ label ] ) {
90 delete elementTransactions [ label ];
91 }
92 }
93
94 // set new record
95 elementTransactions [ label ] = obj;
96
97 return 1;
98}
99
100
101DofManager *DomainTransactionManager :: giveDofManager(int label)
102{
103 if ( dofmanTransactions.find(label) != dofmanTransactions.end() ) {
104 // if modified record exist return it
105 return dofmanTransactions [ label ];
106 } else {
107 // no modification recorded -> return NULL
108 return NULL;
109 }
110}
111
112
113Element *DomainTransactionManager :: giveElement(int label)
114{
115 if ( elementTransactions.find(label) != elementTransactions.end() ) {
116 // if modified record exist return it
117 return elementTransactions [ label ];
118 } else {
119 // no modification recorded -> return NULL
120 return NULL;
121 }
122}
123
124
125int
126DomainTransactionManager :: commitTransactions()
127{
128 return domain->commitTransactions(this);
129}
130} // end namespace oofem
std ::map< int, DofManager * > dofmanTransactions
std ::map< int, Element * > elementTransactions
#define OOFEM_WARNING(...)
Definition error.h:80

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