KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AFEMConfig.m
Go to the documentation of this file.
1 namespace fem{
2 
3 
4 /* (Autoinserted by mtoc++)
5  * This source code has been filtered by the mtoc++ executable,
6  * which generates code that can be processed by the doxygen documentation tool.
7  *
8  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
9  * Except for the comments, the function bodies of your M-file functions are untouched.
10  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
11  * attached source files that are highly readable by humans.
12  *
13  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
14  * the correct locations in the source code browser.
15  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
16  */
17 
19  :public handle {
26  public:
27 
28  FEM;
29 
30 
32 
33 
35 
36 
37  public:
38 
61 
62 
63  public:
64 
73  private:
74 
75  iP;
76 
77  optArgs = {""};
78 
79 
80  public:
81 
83  this.optArgs= varargin;
84 
85 
86  i.KeepUnmatched= true;
87  this.iP= i;
88 
89  this.addOption(" GeoNr ",1);
90  mc = metaclass(this);
91  this.addOption(" Tag ",mc.Name);
92  }
93 
94 
96  this.Model= model;
97  }
107  function configureModelFinal() {
108  }
109 
110 
111  function prepareSimulation(colvec<double> mu,integer inputidx) {
112 
113  /* do nothing by default */
114  }
127  function P = getBoundaryPressure(elemidx,faceidx) {
128  P = [];
129  }
145  function str = getOptionStr(withtag) {
146  if nargin < 2
147  withtag = true;
148  end
149  o = this.Options;
150  fieldnames = fields(o);
151  strs = [];
152  for k=1:length(fieldnames)
153  if (withtag || ~strcmp(fieldnames[k]," Tag ")) && ~isempty(o.(fieldnames[k]))
154  fmt = " %s-%g ";
155  if isa(o.(fieldnames[k])," char ")
156  fmt = " %s-%s ";
157  end
158  strs[end+1] = sprintf(fmt,fieldnames[k],o.(fieldnames[k]));/* #ok */
159 
160  end
161  end
162  str = Utils.implode(strs," _ ");
163  }
164 
165 
166  function plotGeometryInfo(allnode,elemnr) {
167  if nargin < 3
168  elemnr = 1;
169  if nargin < 2
170  allnode = false;
171  end
172  end
173  g = this.FEM.Geometry;
174  g.plot(allnode,elemnr);
175  }
176 
177 
178  protected:
179 
180 
181  function init() {
182  this.iP.parse(this.optArgs[:]);
183  this.Options= this.iP.Results;
184 
185  /* % Get the geometry */
186  geo = this.getGeometry;
187  if isa(geo," fem.geometry.Cube27Node ")
188  this.FEM= fem.HexahedronTriquadratic(geo);
189  elseif isa(geo," fem.geometry.Cube20Node ")
190  this.FEM= fem.HexahedronSerendipity(geo);
191  elseif isa(geo," fem.geometry.Cube8Node ")
192  this.FEM= fem.HexahedronTrilinear(geo);
193  end
194  this.Geometry= geo;
195  }
202  function [velo_dir , velo_dir_val ] = setVelocityDirichletBC(velo_dir,velo_dir_val) {
203  }
217  protected: /* ( Sealed ) */
218 
219  function addOption(name,default,varargin) {
220  this.iP.addParamValue(name, default, varargin[:]);
221  }
222 
223 
224  protected: /* ( Abstract ) */
225 
226  virtual function displ_dir = setPositionDirichletBC(displ_dir) = 0;
227 
228 
229  virtual function geo = getGeometry() = 0;
239  public: /* ( Sealed ) */
240 
241  function [displ_dir , velo_dir , velo_dir_val ] = getBC() {
242  N = this.Geometry.NumNodes;
243  displ_dir = false(3,N);
244  displ_dir = this.setPositionDirichletBC(displ_dir);
245  velo_dir = false(3,N);
246  velo_dir_val = zeros(3,N);
247  [velo_dir, velo_dir_val] = this.setVelocityDirichletBC(velo_dir, velo_dir_val);
248 
249  if any(any(displ_dir & velo_dir))
250  error(" Cannot impose displacement and velocity dirichlet conditions on same DoF ");
251  end
252  }
253 
254 
255  function [force , nodeidx , faceswithforce ] = getSpatialExternalForces() {
256  fe = this.FEM;
257  geo = fe.Geometry;
258  ngp = fe.GaussPointsPerElemFace;
259  force = zeros(geo.NumNodes * 3,1);
260  faceswithforce = false(1,geo.NumFaces);
261 
262  globalcoord = strcmp(this.NeumannCoordinateSystem," global ");
263  for fn = 1:geo.NumFaces
264  elemidx = geo.Faces(1,fn);
265  faceidx = geo.Faces(2,fn);
266  masterfacenodeidx = geo.MasterFaces(faceidx,:);
267  /* So far: Constant pressure on all gauss points! */
268  P = this.getBoundaryPressure(elemidx, faceidx);
269  if ~isempty(P)
270  faceswithforce(fn) = true;
271  integrand = zeros(3,geo.NodesPerFace);
272  if globalcoord
273  N = geo.FaceNormals(:,faceidx);
274  end
275  for gi = 1:ngp
276  if ~globalcoord
277  N = fe.NormalsOnFaceGP(:,gi,fn);
278  end
279  PN = (P * N) * fe.Ngpface(:,gi,fn)^t;
280  integrand = integrand + fe.FaceGaussWeights(gi)*PN*fe.face_detjac(fn,gi);
281  end
282  facenodeidx = geo.Elements(elemidx,masterfacenodeidx);
283  facenodeidx = (facenodeidx-1)*3+1;
284  facenodeidx = [facenodeidx; facenodeidx+1; facenodeidx+2];/* #ok */
285 
286  force(facenodeidx(:)) = force(facenodeidx(:)) + integrand(:);
287  end
288  end
289  /* Augment to u,v,w vector */
290  nodeidx = find(force);
291  }
292 
293 
294 
295 };
296 }
297 
298 
299 
function init()
% Parse the options
Definition: AFEMConfig.m:181
Collection of generally useful functions.
Definition: Utils.m:17
function addOption(name, default, varargin)
Definition: AFEMConfig.m:219
function configureModelFinal()
Definition: AFEMConfig.m:107
fields
Returns a cell array of string containing the names of public properties.
function [ displ_dir , velo_dir , velo_dir_val ] = getBC()
Definition: AFEMConfig.m:241
The base class for any KerMor detailed model.
Definition: BaseFullModel.m:18
function plotGeometryInfo(allnode, elemnr)
Definition: AFEMConfig.m:166
function [ velo_dir , velo_dir_val ] = setVelocityDirichletBC(velo_dir, velo_dir_val)
Determines the dirichlet velocities.
Definition: AFEMConfig.m:202
virtual function displ_dir = setPositionDirichletBC(displ_dir)
function [ force , nodeidx , faceswithforce ] = getSpatialExternalForces()
Definition: AFEMConfig.m:255
An integer value.
function prepareSimulation(colvec< double > mu,integer inputidx)
Overload this method to initialize model-specific quantities that are fixed for each simulation...
Definition: AFEMConfig.m:111
Matlab's base handle class (documentation generation substitute)
function str = getOptionStr(withtag)
Definition: AFEMConfig.m:145
A variable number of input arguments.
fieldnames
Returns a cell array of string containing the names of public properties. See the MATLAB fieldnames f...
AFEMConfig(varargin)
Definition: AFEMConfig.m:82
AModelConfig.
Definition: AFEMConfig.m:18
VelocityBCTimeFun
Velocity conditions application function.
Definition: AFEMConfig.m:65
function configureModel(models.BaseFullModel model)
Overload this method to set model-specific quantities like simulation time etc.
Definition: AFEMConfig.m:95
virtual function geo = getGeometry()
Returns the intended geometry for this model config.
static function char str = implode(char|rowvec data,char glue,char format)
Implodes the elements of data using glue.
Definition: Utils.m:208
A MatLab character array.
function P = getBoundaryPressure(elemidx, faceidx)
Determines the neumann forces on the boundary.
Definition: AFEMConfig.m:127
char NeumannCoordinateSystem
The coordinate system in which to interpret the applied pressure of neumann boundary conditions...
Definition: AFEMConfig.m:39