OOFEM 3.0
Loading...
Searching...
No Matches
dg.h
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
35#ifndef dg_h
36#define dg_h
37
38#include "engngm.h"
39#include "sparselinsystemnm.h"
41#include "sparsemtrx.h"
42#include "primaryfield.h"
43#include "function.h"
45#include "mpm.h"
46
48
49#define _IFT_DGProblem_Name "dgproblem"
50#define _IFT_DGProblem_initt "initt"
51#define _IFT_DGProblem_deltat "deltat"
52#define _IFT_DGProblem_deltatfunction "deltatfunction"
53#define _IFT_DGProblem_prescribedtimes "prescribedtimes"
54#define _IFT_DGProblem_alpha "alpha"
55#define _IFT_DGProblem_keepTangent "keeptangent"
56#define _IFT_DGProblem_exportFields "exportfields"
57#define _IFT_DGProblem_problemType "ptype"
58#define _IFT_DGProblem_preprocessFEM2DG "fem2dg"
61#define _IFT_DGProblem_sets2preprocess "boundarysets"
62#define _IFT_DGProblem_targetBoundaryNodeSets "targetboundarynodesets"
64#define _IFT_DGProblem_targetAllNodeSet "targetallnodeset"
65#define _IFT_DGProblem_targetAllElementSet "targetallelementset"
66
68
69namespace oofem {
70
76{
77protected:
78 double alpha;
79 double deltaT;
81
82public:
84 void matrixFromElement(FloatMatrix &mat, Element &element, TimeStep *tStep) const override;
85};
86
92{
93protected:
94 double alpha;
95 double deltaT;
97
98public:
100 void vectorFromElement(FloatArray &mat, Element &element, TimeStep *tStep, ValueModeType mode) const override;
101};
102
103
105{
106protected:
107 int master; // master DofManager
108
109public:
110 ClonedDofManager(int i, Domain * d, int master) : DofManager(i, d), master(master) { }
111 int giveMasterNumber() { return master; }
112 void printOutputAt(FILE *file, TimeStep *tStep) override;
113 const char *giveClassName() const override { return "ClonedDofManager"; }
114 const char *giveInputRecordName() const override { return NULL; }
115 bool isDofTypeCompatible(dofType type) const override { return ( type == DT_master || type == DT_simpleSlave || type == DT_active ); }
116
117
118
119};
120
121
130class DGProblem : public EngngModel
131{
132protected:
133
134 Variable::VariableQuantity unknownQuantity = Variable::VariableQuantity::VolumeFraction;
135
138 std :: unique_ptr< DofDistributedPrimaryField > field;
139
140 std :: unique_ptr< SparseMtrx > lhsMatrix;
141 std :: unique_ptr< SparseMtrx > rhsMatrix;
142
146
148 std :: unique_ptr< SparseLinearSystemNM > nMethod;
149
151 double initT = 0.;
153 double deltaT = 0.;
154 double alpha = 0.;
156 int dtFunction = 0;
159 bool keepTangent = false, hasTangent = false;
162 std::string problemType;
164 bool preprocessFEM2DG = false;
171
172
173 // class representing boundary entity (edge, surface, etc.)
175 {
176 public:
177 IntArray elements; // list of elements sharing entity (size should be 1 or 2)
178 IntArray elementBoundaryIDs; // list of boundary IDs of elements sharing entity
180 virtual ~DGBoundaryEntity() { }
181 void addElement(int elem, int boundaryID) { elements.followedBy(elem); elementBoundaryIDs.followedBy(boundaryID); }
182 };
183
184 // list of boundary entities
185 std :: vector< std::unique_ptr<DGBoundaryEntity>> boundaryEntities;
186
187
188
189public:
190 DGProblem(int i, EngngModel * _master);
191
193
194 void solveYourselfAt(TimeStep *tStep) override;
195 void updateComponent(TimeStep *tStep, NumericalCmpn cmpn, Domain *d) override;
196 bool newDofHandling() override { return true; }
197 void updateSolution(FloatArray &solutionVector, TimeStep *tStep, Domain *d) override;
198 void updateInternalRHS(FloatArray &answer, TimeStep *tStep, Domain *d, FloatArray *eNorm) override;
199 void updateMatrix(SparseMtrx &mat, TimeStep *tStep, Domain *d) override;
200 double giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) override;
201 void saveContext(DataStream &stream, ContextMode mode) override;
202 void restoreContext(DataStream &stream, ContextMode mode) override;
203 void postInitialize() override;
204
205 virtual void applyIC();
206
208 int giveUnknownDictHashIndx(ValueModeType mode, TimeStep *tStep) override;
209 void updateDomainLinks() override;
210
212 double giveDeltaT(int n);
213 double giveDiscreteTime(int iStep);
214
215 TimeStep *giveNextStep() override;
216 TimeStep *giveSolutionStepWhenIcApply(bool force = false) override;
218
219 void initializeFrom(InputRecord &ir) override;
220
221 bool requiresEquationRenumbering(TimeStep *tStep) override;
222 int forceEquationNumbering() override;
223
224 void printOutputAt(FILE *file, TimeStep *tStep) override;
225
226 void updateYourself(TimeStep *tStep) override;
227
228 int checkConsistency() override;
229 FieldPtr giveField (FieldType key, TimeStep *tStep) override;
230 // identification
231 const char *giveInputRecordName() const { return _IFT_DGProblem_Name; }
232 const char *giveClassName() const override { return "DGProblem"; }
233 fMode giveFormulation() override { return TL; }
234
235
236 double giveFinalTime() override
237 {
238 if(prescribedTimes.giveSize()) {
239 return prescribedTimes.at(prescribedTimes.giveSize());
240 } else {
241 return deltaT * numberOfSteps;
242 }
243 }
244 protected:
245 std::unique_ptr< Element> CreateBoundaryElement( Element_Geometry_Type egt, int elemNum, Domain *domain, IntArray &bentityNodes) const;
246 void assembleDirichletBcRhsVector(FloatArray &answer, TimeStep *tStep, ValueModeType mode,
247 const UnknownNumberingScheme &ns, Domain *d) const;
248};
249
250} // end namespace oofem
251#endif // dg_h
bool isDofTypeCompatible(dofType type) const override
Returns true if dof of given type is allowed to be associated to receiver.
Definition dg.h:115
const char * giveClassName() const override
Definition dg.h:113
ClonedDofManager(int i, Domain *d, int master)
Definition dg.h:110
const char * giveInputRecordName() const override
Definition dg.h:114
void printOutputAt(FILE *file, TimeStep *tStep) override
Definition dg.C:143
int giveMasterNumber()
Definition dg.h:111
void addElement(int elem, int boundaryID)
Definition dg.h:181
double initT
Initial time from which the computation runs. Default is zero.
Definition dg.h:151
IntArray exportFields
Definition dg.h:160
double alpha
Definition dg.h:154
void solveYourselfAt(TimeStep *tStep) override
Definition dg.C:578
FloatArray prescribedTimes
Specified times where the problem is solved.
Definition dg.h:158
int dtFunction
Associated time function for time step increment.
Definition dg.h:156
FloatArray internalForces
Definition dg.h:144
TimeStep * giveSolutionStepWhenIcApply(bool force=false) override
Definition dg.C:288
void updateInternalRHS(FloatArray &answer, TimeStep *tStep, Domain *d, FloatArray *eNorm) override
Definition dg.C:633
int checkConsistency() override
Definition dg.C:746
double giveFinalTime() override
Definition dg.h:236
TimeStep * giveNextStep() override
Returns next time step (next to current step) of receiver.
Definition dg.C:273
SparseMtrxType sparseMtrxType
Definition dg.h:137
double giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) override
Definition dg.C:241
int giveUnknownDictHashIndx(ValueModeType mode, TimeStep *tStep) override
Definition dg.C:733
LinSystSolverType solverType
Definition dg.h:136
fMode giveFormulation() override
Definition dg.h:233
FieldPtr giveField(FieldType key, TimeStep *tStep) override
Definition dg.C:760
virtual void applyIC()
Definition dg.C:650
std ::unique_ptr< SparseLinearSystemNM > nMethod
Numerical method used to solve the problem.
Definition dg.h:148
DGProblem(int i, EngngModel *_master)
Definition dg.C:153
int requiresUnknownsDictionaryUpdate() override
Definition dg.C:740
void updateDomainLinks() override
Definition dg.C:753
const char * giveInputRecordName() const
Definition dg.h:231
std ::unique_ptr< DofDistributedPrimaryField > field
Definition dg.h:138
std::unique_ptr< Element > CreateBoundaryElement(Element_Geometry_Type egt, int elemNum, Domain *domain, IntArray &bentityNodes) const
Definition dg.C:500
bool keepTangent
Definition dg.h:159
void updateYourself(TimeStep *tStep) override
Definition dg.C:711
bool preprocessFEM2DG
flag indicating whether the FEM input should be preprocessed to DG problem input (boundary entity gen...
Definition dg.h:164
bool hasTangent
Definition dg.h:159
int targetAllNodeSet
int target sets for all nodes and all elements
Definition dg.h:170
IntArray sets2preprocess
array of sets to process to generate boundary node sets
Definition dg.h:166
std ::vector< std::unique_ptr< DGBoundaryEntity > > boundaryEntities
Definition dg.h:185
NumericalMethod * giveNumericalMethod(MetaStep *mStep) override
Returns reference to receiver's numerical method.
Definition dg.C:158
FloatArray solution
Definition dg.h:143
Function * giveDtFunction()
double deltaT
Length of time step.
Definition dg.h:153
void restoreContext(DataStream &stream, ContextMode mode) override
Definition dg.C:725
Variable::VariableQuantity unknownQuantity
Definition dg.h:134
void printOutputAt(FILE *file, TimeStep *tStep) override
Definition dg.C:700
std ::unique_ptr< SparseMtrx > lhsMatrix
Definition dg.h:140
int forceEquationNumbering() override
Definition dg.C:691
void updateSolution(FloatArray &solutionVector, TimeStep *tStep, Domain *d) override
Definition dg.C:622
double giveDiscreteTime(int iStep)
Definition dg.C:260
void constructBoundaryEntities()
Definition dg.C:305
IntArray targetBoundaryNodeSets
array of target sets (same size as sets2preprocess) to store the generated boundary node sets
Definition dg.h:168
void saveContext(DataStream &stream, ContextMode mode) override
Definition dg.C:717
const char * giveClassName() const override
Returns class name of the receiver.
Definition dg.h:232
bool requiresEquationRenumbering(TimeStep *tStep) override
Definition dg.C:668
void updateMatrix(SparseMtrx &mat, TimeStep *tStep, Domain *d) override
Definition dg.C:638
FloatArray eNorm
Definition dg.h:145
std::string problemType
identifies what problem to solve (UP, UPV, etc)
Definition dg.h:162
void updateComponent(TimeStep *tStep, NumericalCmpn cmpn, Domain *d) override
Definition dg.C:643
void postInitialize() override
Definition dg.C:518
std ::unique_ptr< SparseMtrx > rhsMatrix
Definition dg.h:141
void initializeFrom(InputRecord &ir) override
Definition dg.C:179
bool newDofHandling() override
Definition dg.h:196
int targetAllElementSet
Definition dg.h:170
void assembleDirichletBcRhsVector(FloatArray &answer, TimeStep *tStep, ValueModeType mode, const UnknownNumberingScheme &ns, Domain *d) const
Definition dg.C:787
DofManager(int n, Domain *aDomain)
Definition dofmanager.C:71
double giveDeltaT()
Returns time step size from the time step controlelr.
Definition engngm.h:424
EngngModel(int i, EngngModel *_master=NULL)
Definition engngm.C:99
int numberOfSteps
Total number of time steps.
Definition engngm.h:219
void matrixFromElement(FloatMatrix &mat, Element &element, TimeStep *tStep) const override
Definition dg.C:70
Variable::VariableQuantity q
Definition dg.h:80
ScalarAdvectionLhsAssembler(double alpha, double deltaT, Variable::VariableQuantity q)
Definition dg.C:63
Variable::VariableQuantity q
Definition dg.h:96
void vectorFromElement(FloatArray &mat, Element &element, TimeStep *tStep, ValueModeType mode) const override
Definition dg.C:105
ScalarAdvectionRhsAssembler(double alpha, double deltaT, Variable::VariableQuantity q)
Definition dg.C:98
oofem::VariableQuantity VariableQuantity
Definition mpm.h:92
#define _IFT_DGProblem_Name
Definition dg.h:49
long ContextMode
Definition contextmode.h:43
fMode
Definition fmode.h:42
@ TL
Total Lagrange.
Definition fmode.h:44
FieldType
Physical type of field.
Definition field.h:64
dofType
Dof Type, determines the type of DOF created.
Definition doftype.h:48
@ SMT_Skyline
Symmetric skyline.
std::shared_ptr< Field > FieldPtr
Definition field.h:78

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