OOFEM 3.0
Loading...
Searching...
No Matches
integral.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#ifndef integral_h
35#define integral_h
36
37#include "mpm.h"
38#include "set.h"
39#include "intarray.h"
40#include "domain.h"
41#include "sparsemtrx.h"
42
43namespace oofem {
44
49 class Integral {
50 public:
51
53 int setIndex=0;
54 const Term *term;
56 double factor;
61 Integral (Domain* d, Set* set, const Term* t ) : set(set), term(t), factor(1.0) {
62 this->domain = d;
63 }
64 void initializeFrom (InputRecord &ir, EngngModel *emodel);
66 void initialize() {
67 if (this->set == nullptr) {
68 this->set = this->domain->giveSet(this->setIndex);
69 }
70 for (auto i: this->set->giveElementList()) { // loop over elements
71 // introduce necessary dofs and set-up integration rules
72 this->term->initializeCell(*(domain->giveElement(i)));
73 }
74 }
75 // evaluate term contribution to weak form on given cell at given point
76 void assemble_lhs (SparseMtrx& dest, const UnknownNumberingScheme &s, TimeStep* tStep) const {
77 IntArray locr, locc;
78
79 for (auto i: this->set->giveElementList()) { // loop over elements
80 MPElement *e = dynamic_cast<MPElement*>(this->domain->giveElement(i));
81 if (e) {
82 FloatMatrix contrib;
83 this->getElementTermCodeNumbers(locr, locc, e, *this->term, s);
84 // determine integration rule (this has to be set up on element, as we need to track history there)
85 // the IR is created by term.initialize, we just need mechanism to get this IR
86 // specific terms can have specific integration requirements (reduced integration, etc)
87 // at the same time same rules should be shared between terms->
88 // ->need to querry/store/identify element IR based on NIP.
90 e->integrateTerm_dw(contrib, *this->term, ir, tStep); // @todo IR
91 contrib.times(this->factor);
92 // assemble
93 dest.assemble (locr, locc, contrib);
94 }
95 }
96 }
97 // evaluate contribution (all vars known) on given cell
98 void assemble_rhs (FloatArray& dest, const UnknownNumberingScheme &s, TimeStep* tstep, FloatArray* eNorms=NULL ) const {
99 IntArray locr, locc, dofIDs;
100
101 for (auto i: this->set->giveElementList()) { // loop over elements
102 MPElement *e = dynamic_cast<MPElement*>(this->domain->giveElement(i));
103 if (e) {
104 FloatArray contrib;
105 this->getElementTermCodeNumbers(locr, locc, e, *this->term, s, &dofIDs);
106 // determine integration rule (this has to be set up on element, as we need to track history there)
107 // the IR is created by term.initialize, we just need mechanism to get this IR
108 // specific terms can have specific integration requirements (reduced integration, etc)
109 // at the same time same rules should be shared between terms->
110 // ->need to querry/store/identify element IR based on NIP.
111 IntegrationRule* ir = this->term->giveElementIntegrationRule(e);
112 e->integrateTerm_c(contrib, *this->term, ir, tstep); // @todo IR
113 contrib.times(this->factor);
114 // assemble
115 dest.assemble (contrib, locr);
116 if ( eNorms ) {
117 eNorms->assembleSquared(contrib, dofIDs);
118 }
119 }
120 }
121
122
123 }
124 void getElementTermCodeNumbers (IntArray &locr, IntArray &locc, Element* e, const Term& t, const UnknownNumberingScheme &s, IntArray* rowDofIDs=NULL) const {
125 IntArray nodes, internalDofMans, loc, masterDofIDs;
126 locr.resize(0);
127 locc.resize(0);
128 // term.field and its interpolation determines column code numbers
129 // from interpolation get node and internalDofMan lists
130 t.field->interpolation->giveCellDofMans(nodes, internalDofMans, e);
131 // loop over dof managers to get code numbers
132 for (int i: nodes) {
133 // get mode dofID mask
135 locc.followedBy(loc);
136 }
137 for (int i: internalDofMans) {
139 locc.followedBy(loc);
140 }
141
142 if ( rowDofIDs ) {
143 rowDofIDs->clear();
144 }
145 // term.testField and its interpolation determines row code numbers
146 // from interpolation get node and internalDofMan lists
147 t.testField->interpolation->giveCellDofMans(nodes, internalDofMans, e);
148 // loop over dof managers to get code numbers
149 for (int i: nodes) {
150 // get mode dofID mask
152 locr.followedBy(loc);
153 if ( rowDofIDs ) {
155 rowDofIDs->followedBy(masterDofIDs);
156 }
157 }
158 for (int i: internalDofMans) {
160 locr.followedBy(loc);
161 if ( rowDofIDs ) {
163 rowDofIDs->followedBy(masterDofIDs);
164 }
165 }
166 }
167 };
168
169} // namespace oofem
170
171#endif // integral_h
void giveLocationArray(const IntArray &dofIDArry, IntArray &locationArray, const UnknownNumberingScheme &s) const
Definition dofmanager.C:185
void giveMasterDofIDArray(const IntArray &dofIDArry, IntArray &masterDofIDs) const
Definition dofmanager.C:217
Set * giveSet(int n)
Definition domain.C:366
Element * giveElement(int n)
Definition domain.C:165
virtual DofManager * giveInternalDofManager(int i) const
Definition element.h:249
DofManager * giveDofManager(int i) const
Definition element.C:553
virtual void giveCellDofMans(IntArray &nodes, IntArray &internalDofMans, Element *elem) const
Returns list of element nodes (and list of internal dof managers) (including on edges and surfaces) d...
Definition feinterpol.h:208
void assemble(const FloatArray &fe, const IntArray &loc)
Definition floatarray.C:616
void times(double s)
Definition floatarray.C:834
void times(double f)
void followedBy(const IntArray &b, int allocChunk=0)
Definition intarray.C:94
void resize(int n)
Definition intarray.C:73
const Term * term
Definition integral.h:54
void initialize()
Initialize the integral domain.
Definition integral.h:66
Domain * domain
Definition integral.h:55
Integral(Domain *d, Set *set, const Term *t)
Constructor, creates an integral of given term over entities in given set.
Definition integral.h:61
void assemble_lhs(SparseMtrx &dest, const UnknownNumberingScheme &s, TimeStep *tStep) const
Definition integral.h:76
void initializeFrom(InputRecord &ir, EngngModel *emodel)
Definition integral.C:44
void assemble_rhs(FloatArray &dest, const UnknownNumberingScheme &s, TimeStep *tstep, FloatArray *eNorms=NULL) const
Definition integral.h:98
double factor
Definition integral.h:56
void getElementTermCodeNumbers(IntArray &locr, IntArray &locc, Element *e, const Term &t, const UnknownNumberingScheme &s, IntArray *rowDofIDs=NULL) const
Definition integral.h:124
Base class for elements based on mp (multi-physics) concept.
Definition mpm.h:282
void integrateTerm_c(FloatArray &answer, const Term &term, IntegrationRule *iRule, TimeStep *tstep)
Definition mpm.h:305
void integrateTerm_dw(FloatMatrix &answer, const Term &term, IntegrationRule *iRule, TimeStep *tstep)
Definition mpm.h:293
const IntArray & giveElementList()
Definition set.C:158
virtual int assemble(const IntArray &loc, const FloatMatrix &mat)=0
Class representing a weak form expression to be evaluated (integrated). It defines two key methods:
Definition mpm.h:134
virtual IntegrationRule * giveElementIntegrationRule(Element *e) const
Definition mpm.h:150
const Variable * field
Definition mpm.h:136
const Variable * testField
Definition mpm.h:137
virtual void initializeCell(Element &cell) const =0
const IntArray & getDofManDofIDs() const
Returns DodIF mask in node; need generalization (which dofMan).
Definition mpm.h:121
const FEInterpolation * interpolation
Definition mpm.h:94

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