OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
stokesflowvelocityhomogenization.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  * OOFEM : Object Oriented Finite Element Code
11  *
12  * Copyright (C) 1993 - 2013 Borek Patzak
13  *
14  *
15  *
16  * Czech Technical University, Faculty of Civil Engineering,
17  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
18  *
19  * This library is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU Lesser General Public
21  * License as published by the Free Software Foundation; either
22  * version 2.1 of the License, or (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27  * Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public
30  * License along with this library; if not, write to the Free Software
31  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32  */
33 
35 #include "classfactory.h"
36 #include "dofmanager.h"
37 #include "gausspoint.h"
38 #include "feinterpol.h"
39 #include "unknownnumberingscheme.h"
40 #include "sparsemtrx.h"
41 #include "deadweight.h"
42 #include "mathfem.h"
43 
44 namespace oofem {
45 REGISTER_EngngModel(StokesFlowVelocityHomogenization);
46 
48 {
49 }
50 
52 { }
53 
54 
55 double
57 {
59 
60  min = * this->giveDomain(1)->giveDofManager(1)->giveCoordinates();
61  max = * this->giveDomain(1)->giveDofManager(1)->giveCoordinates();
62 
63  for ( auto &node : this->giveDomain(1)->giveDofManagers() ) {
64  min.beMinOf( min, * node->giveCoordinates() );
65  max.beMaxOf( max, * node->giveCoordinates() );
66  }
67 
68  max.subtract(min);
69  return max.product();
70 }
71 
72 
73 void
75 {
76  FloatMatrix N;
77  FloatArray v_hatTemp, unknowns;
78 
79  v.clear();
80 
81  for ( auto &elem : this->giveDomain(1)->giveElements() ) {
82  this->integrateNMatrix(N, *elem, tStep);
83  elem->computeVectorOf({V_u, V_v, V_w}, VM_Total, tStep, unknowns);
84  v_hatTemp.beProductOf(N, unknowns);
85  v.add(v_hatTemp);
86  }
87 
88  v.times( 1. / this->giveAreaOfRVE() );
89 }
90 
91 
92 void
94 {
95  IntArray loc, col;
96 
97  Domain *domain = this->giveDomain(1);
98  int nsd = domain->giveNumberOfSpatialDimensions();
100 
101  // Build F matrix
102  IntArray dofs(nsd);
103  for ( int i = 0; i < nsd; ++i ) {
104  dofs[i] = V_u + i;
105  }
106  FloatMatrix F(ndof, nsd), Fe, N;
107  col.enumerate(nsd);
108 
109  for ( auto &elem : domain->giveElements() ) {
110 
111  this->integrateNMatrix(N, *elem, tStep);
112 
113  elem->giveLocationArray( loc, dofs, EModelDefaultEquationNumbering() );
114  Fe.beTranspositionOf(N);
115  F.assemble(Fe, loc, col);
116  }
117 
118  FloatMatrix H;
119 
120  std :: unique_ptr< SparseLinearSystemNM > solver( classFactory.createSparseLinSolver(solverType, this->giveDomain(1), this) );
121 
122  H.resize( F.giveNumberOfRows(), F.giveNumberOfColumns() );
123  H.zero();
124 
125  // For correct homogenization, the tangent at the converged values should be used
126  // (the one from the Newton iterations from solveYourselfAt is not updated to contain the latest values).
127  SparseMtrxType stype = solver->giveRecommendedMatrix(true);
128  std :: unique_ptr< SparseMtrx > Kff( classFactory.createSparseMtrx( stype ) );
129  Kff->buildInternalStructure(this, domain->giveNumber(), EModelDefaultEquationNumbering() );
130  this->assemble(*Kff, tStep, TangentAssembler(TangentStiffness), EModelDefaultEquationNumbering(), domain);
131  solver->solve(*Kff, F, H);
132 
133  answer.beTProductOf(H, F);
134  answer.times( 1. / this->giveAreaOfRVE() );
135 }
136 
137 
138 void
140 {
141  FloatArray n, n2;
142 
143  for ( GaussPoint *gp: *elem.giveDefaultIntegrationRulePtr() ) {
144  const FloatArray &lcoords = gp->giveNaturalCoordinates();
145 
147  elem.giveInterpolation()->evalN( n, lcoords, FEIElementGeometryWrapper(&elem) );
148  double detJ = fabs( elem.giveInterpolation()->giveTransformationJacobian( lcoords, FEIElementGeometryWrapper(&elem) ) );
149  n2.add(gp->giveWeight() * detJ, n);
150  }
151 
152  N.beNMatrixOf(n2, this->giveDomain(1)->giveNumberOfSpatialDimensions());
153 }
154 
155 
156 void
158 {
159  FloatArray components = grad;
160  components.negated();
161 
163  for ( auto &bc : this->giveDomain(1)->giveBcs() ) {
164  DeadWeight *load = dynamic_cast< DeadWeight* >( bc.get() );
165  if ( load ) {
166  load->setDeadWeighComponents(components);
167  break;
168  }
169  }
170 }
171 
172 }
The representation of EngngModel default unknown numbering.
void enumerate(int maxVal)
Resizes receiver and enumerates from 1 to the maximum value given.
Definition: intarray.C:136
void subtract(const FloatArray &src)
Subtracts array src to receiver.
Definition: floatarray.C:258
StokesFlowVelocityHomogenization(int i, EngngModel *_master=NULL)
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)=0
Evaluates the array of interpolation functions (shape functions) at given point.
Class and object Domain.
Definition: domain.h:115
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Access method for default integration rule.
Definition: element.h:822
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Returns number of equations for given domain in active (current time step) time step.
Definition: engngm.C:391
virtual double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the determinant of the transformation.
Definition: feinterpol.C:43
SparseMtrx * createSparseMtrx(SparseMtrxType type)
Creates new instance of sparse matrix corresponding to given keyword.
Definition: classfactory.C:105
int max(int i, int j)
Returns bigger value form two given decimals.
Definition: mathfem.h:71
void clear()
Clears receiver (zero size).
Definition: floatarray.h:206
void integrateNMatrix(FloatMatrix &N, Element &elem, TimeStep *tStep)
virtual FloatArray * giveCoordinates()
Definition: dofmanager.h:382
Implementation for assembling tangent matrices in standard monolithic FE-problems.
Abstract base class for all finite elements.
Definition: element.h:145
int giveNumber()
Returns domain number.
Definition: domain.h:266
int giveNumberOfSpatialDimensions()
Returns number of spatial dimensions.
Definition: domain.C:1067
REGISTER_EngngModel(ProblemSequence)
double product() const
Computes the product of receiver values.
Definition: floatarray.C:858
Class implementing an array of integers.
Definition: intarray.h:61
virtual FEInterpolation * giveInterpolation() const
Definition: element.h:629
void beMaxOf(const FloatArray &a, const FloatArray &b)
Sets receiver to maximum of a or b&#39;s respective elements.
Definition: floatarray.C:288
This class implements a gravity-like load, or internal source (heat etc.) for transport problems...
Definition: deadweight.h:52
void computeSeepage(FloatArray &v, TimeStep *tStep)
Computes the mean velocity and pressure gradient.
virtual void assemble(SparseMtrx &answer, TimeStep *tStep, const MatrixAssembler &ma, const UnknownNumberingScheme &s, Domain *domain)
Assembles characteristic matrix of required type into given sparse matrix.
Definition: engngm.C:803
void beMinOf(const FloatArray &a, const FloatArray &b)
Sets receiver to be minimum of a or b&#39;s respective elements.
Definition: floatarray.C:315
LinSystSolverType solverType
Linear solver type.
Definition: stokesflow.h:75
SparseMtrxType
Enumerative type used to identify the sparse matrix type.
void times(double f)
Multiplies receiver by factor f.
Definition: floatmatrix.C:1594
Wrapper around element definition to provide FEICellGeometry interface.
Definition: feinterpol.h:95
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Receiver becomes the result of the product of aMatrix and anArray.
Definition: floatarray.C:676
#define N(p, q)
Definition: mdm.C:367
double giveAreaOfRVE()
Compute area of domain (includes holes)
Implements the engineering model to solve incompressible Stokes flow.
Definition: stokesflow.h:63
void beNMatrixOf(const FloatArray &n, int nsd)
Assigns the receiver to be a repeated diagonal matrix.
Definition: floatmatrix.C:505
void computeTangent(FloatMatrix &answer, TimeStep *tStep)
void setDeadWeighComponents(FloatArray newComponents)
Definition: deadweight.C:48
Class representing vector of real numbers.
Definition: floatarray.h:82
SparseLinearSystemNM * createSparseLinSolver(LinSystSolverType st, Domain *d, EngngModel *m)
Creates new instance of SparseLinearSystemNM corresponding to given type.
Definition: classfactory.C:120
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
void beTProductOf(const FloatMatrix &a, const FloatMatrix &b)
Assigns to the receiver product of .
Definition: floatmatrix.C:367
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
void beTranspositionOf(const FloatMatrix &src)
Assigns to the receiver the transposition of parameter.
Definition: floatmatrix.C:323
ClassFactory & classFactory
Definition: classfactory.C:59
void zero()
Zeroes all coefficient of receiver.
Definition: floatmatrix.C:1326
int min(int i, int j)
Returns smaller value from two given decimals.
Definition: mathfem.h:59
std::vector< std::unique_ptr< Element > > & giveElements()
Definition: domain.h:279
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
the oofem namespace is to define a context or scope in which all oofem names are defined.
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Definition: engngm.C:1720
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
Definition: domain.C:314
void negated()
Switches the sign of every coefficient of receiver.
Definition: floatarray.C:739
Class representing integration point in finite element program.
Definition: gausspoint.h:93
Class representing solution step.
Definition: timestep.h:80
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:31 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011