OOFEM 3.0
Loading...
Searching...
No Matches
dofmanvalfield.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
35#include "dofmanvalfield.h"
36#include "domain.h"
37#include "spatiallocalizer.h"
38#include "element.h"
39#include "crosssection.h"
40#include "timestep.h"
41#include "util.h"
42#include "classfactory.h"
43#include "dofmanager.h"
44#include "feinterpol.h"
45#include "problemmode.h"
46#include "nodalrecoverymodel.h"
47#include "vtkbaseexportmodule.h"
48#include "octreelocalizer.h"
49
50
51namespace oofem {
53{
54 int ndofman = d->giveNumberOfDofManagers();
55 this->domain = d;
56 this->dmanvallist.resize(ndofman);
57}
58
59DofManValueField::DofManValueField(FieldType ft, int nNodes, int nElements, const std::string engngModel = "transienttransport", const std::string domainDofsDefaults = "heattransfer") : Field(ft), dmanvallist()
60{
61 //ft FieldType::FT_Unknown
62 this->eModel = classFactory.createEngngModel(engngModel.c_str(), 1, NULL);
63 if ( !this->eModel ) {
64 OOFEM_ERROR("Couldn't create EngngModel\n");
65 }
66 eModel->Instanciate_init();//create one domain
67 this->domain = eModel->giveDomain(1);
68 this->domain->resolveDomainDofsDefaults(domainDofsDefaults.c_str() );
69 this->domain->dofManagerList.clear();
70 this->domain->dofManagerList.resize(nNodes);
71 dmanvallist.resize(nNodes);
72 this->domain->elementList.clear();
73 this->domain->elementList.resize(nElements);
74 this->crossSect = classFactory.createCrossSection("emptycs", 1, this->domain);//create one dummy cross-section
75 this->domain->crossSectionList.clear();
76 this->domain->crossSectionList.resize(1);
77 this->domain->crossSectionList[0] = std::move(this->crossSect);
78 std::unique_ptr< SpatialLocalizer > spatialLocalizer;
79 spatialLocalizer = std::make_unique<OctreeSpatialLocalizer>(this->domain);
80 spatialLocalizer->init();
81 this->domain->setSpatialLocalizer(std::move(spatialLocalizer));
82}
83
84
85void DofManValueField::addNode(int i, const FloatArray &coords) {
86 std::unique_ptr< DofManager >dman(classFactory.createDofManager("node", i, eModel->giveDomain(1) ) );
87 if ( !dman ) {
88 OOFEM_ERROR("Couldn't create node %d\n", i);
89 }
90 dman->setCoordinates(coords);
91 dman->setGlobalNumber(i);
92 this->domain->dofManagerList [ i - 1 ] = std::move(dman);
93}
94
95
96void
97DofManValueField::addElement(int i, const char *name, const IntArray &nodes) {
98 std::unique_ptr< Element >elem(classFactory.createElement(name, i, this->domain) );
99 if ( !elem ) {
100 OOFEM_ERROR("Couldn't create element %d: %s\n", i, name);
101 }
102
103 elem->setDofManagers(nodes);
104 elem->setGlobalNumber(i);
105 elem->setCrossSection(1);
106 this->domain->elementList [ i - 1 ] = std::move(elem);
107}
108
109
110int
111DofManValueField::evaluateAt(FloatArray &answer, const FloatArray &coords, ValueModeType mode, TimeStep *tStep)
112{
113 int result = 0; // assume ok
114 FloatArray lc, n;
115 answer.resize(0);
116
117 // request element containing target point
118 Element *elem = this->domain->giveSpatialLocalizer()->giveElementContainingPoint(coords);
119 if ( elem ) { // ok element containing target point found
120 FEInterpolation *interp = elem->giveInterpolation();
121 if ( interp ) {
122 // map target point to element local coordinates
123 if ( interp->global2local(lc, coords, FEIElementGeometryWrapper(elem) ) ) {
124 // evaluate interpolation functions at target point
125 interp->evalN(n, lc, FEIElementGeometryWrapper(elem) );
126 // loop over element nodes
127 for ( int i = 1; i <= n.giveSize(); i++ ) {
128 // multiply nodal value by value of corresponding shape function and add this to answer
129 answer.add(n.at(i), this->dmanvallist [ elem->giveDofManagerNumber(i) - 1 ]);
130 }
131 } else { // mapping from global to local coordinates failed
132 OOFEM_ERROR("Error in mapping from global to local coordinates\n");
133 }
134 } else { // element without interpolation
135 OOFEM_ERROR("Error in element without interpolation\n");
136 }
137 } else { // no element containing given point found
138 OOFEM_ERROR("Point out of defined elements\n");
139 }
140 return result;
141}
142
143
144int
145DofManValueField::evaluateAt(FloatArray &answer, DofManager *dman, ValueModeType mode, TimeStep *tStep)
146{
147 answer = this->dmanvallist [ dman->giveNumber() - 1 ];
148 return 1;
149}
150
151void
153{
154 this->dmanvallist [ dofMan - 1 ] = std::move(value);
155}
156
158{
159 return this->domain->dofManagerList [ i - 1 ]->giveCoordinates();
160}
161
162
163void
166
167void
170} // end namespace oofem
Domain * domain
Associated domain (need its elements to interpolate).
void addNode(int i, const FloatArray &coords)
void saveContext(DataStream &stream) override
const FloatArray & getNodeCoordinates(int i)
void addElement(int i, const char *name, const IntArray &nodes)
std::vector< FloatArray > dmanvallist
Array of dofman values.
DofManValueField(FieldType ft, Domain *d)
std::unique_ptr< EngngModel > eModel
Pointer to engineering model.
void restoreContext(DataStream &stream) override
int evaluateAt(FloatArray &answer, const FloatArray &coords, ValueModeType mode, TimeStep *tStep) override
void setDofManValue(int dofMan, FloatArray value)
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Definition domain.h:461
virtual FEInterpolation * giveInterpolation() const
Definition element.h:648
int giveDofManagerNumber(int i) const
Definition element.h:609
virtual int global2local(FloatArray &answer, const FloatArray &gcoords, const FEICellGeometry &cellgeo) const =0
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo) const =0
int giveNumber() const
Definition femcmpnn.h:104
Field(FieldType b=FieldType::FT_Unknown)
Definition field.h:95
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void add(const FloatArray &src)
Definition floatarray.C:218
#define OOFEM_ERROR(...)
Definition error.h:79
FieldType
Physical type of field.
Definition field.h:64
ClassFactory & classFactory

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