183 function
plot(withdofnr,elem,pm) {
198 h = pm.nextPlot(
" geometry ",sprintf(
" Geometry (%s) ",
class(
this)),
" x [mm] ",
" y [mm] ");
199 plot3(h,p(1,:),p(2,:),p(3,:),
" k. ",
" MarkerSize ",14);
201 for k = 1:length(elem)
204 text(center(1),center(2),center(3),sprintf(
" E_{%d} ",elem(
k)),
" Parent ",h,
" Color ",
" m ");
209 text(off+p(1,el(i)),off+p(2,el(i)),off+p(3,el(i)),sprintf(
" %d ",i),
" Parent ",h,
" Color ",
" r ");
213 mid = mean(facenodes,2);
214 text(mid(1),mid(2),mid(3),sprintf(
" F_%d ",i),
" Parent ",h,
" Color ",
" k ");
220 plot3(h,[p(1,eg(i,1)) p(1,eg(i,2))],[p(2,eg(i,1)) p(2,eg(i,2))],[p(3,eg(i,1)) p(3,eg(i,2))],
" r ");
224 text(p(1,k),p(2,k),p(3,k),sprintf(
" %d ",k),
" Parent ",h,
" Color ",
" k ");
242 m = min(this.
Nodes,[],2)*marginfac;
243 M = max(this.
Nodes,[],2)*marginfac;
244 bounds = [m(1) M(1) m(2) M(2) m(3) M(3)];
254 error(
" not implemented ");
259 mc = metaclass(
this);
260 pts = this.
Nodes * factor;
262 eval(sprintf(
" copy = %s(pts,cubes); ",mc.Name));
271 function [sub , nodeidx , faces ] =
getSubMesh(elems,faces) {
273 nodeidx = unique(newelems(:),
" stable ");
274 newnodes = this.
Nodes(:,nodeidx);
277 invidx(nodeidx) = 1:length(nodeidx);
278 newelems = invidx(newelems)^
t;
280 sub = eval([
class(
this)
" (newnodes, newelems) "]);
285 isface =
false(1,size(this.
NumFaces,2));
287 isface = isface | this.
Faces(1,:) ==
k;
289 faces = find(isface);
291 sub.Faces= this.
Faces(:,faces);
295 invidx(elems) = 1:length(elems);
296 sub.Faces(1,:) = invidx(sub.Faces(1,:));
297 sub.faceComputations;
303 name =
" musclegeom ";
309 exnode = fullfile(folder,[name
" .exnode "]);
310 f = fopen(exnode,
" w+ ");
311 fprintf(f,
" Group name : %s\n ",name);
312 fprintf(f,
" #Fields=1\n ");
313 fprintf(f,
" 1) coordinates, coordinate, rectangular cartesian, #Components=3\n ");
314 fprintf(f,
" x. Value index= 1, #Derivatives= 0\n ");
315 fprintf(f,
" y. Value index= 2, #Derivatives= 0\n ");
316 fprintf(f,
" z. Value index= 3, #Derivatives= 0\n ");
318 fprintf(f,
" Node:\t%d\n ",n);
319 fprintf(f,
" %E\n ",this.
Nodes(:,n));
324 exelem = fullfile(folder,[name
" .exelem "]);
325 f = fopen(exelem,
" w+ ");
326 fprintf(f,
" Group name : %s\n ",name);
330 fprintf(f,
" Shape. Dimension=1\n ");
331 for e = 1:size(this.
Edges,1)
332 fprintf(f,
" Element: 0 0 %d\n ",e);
336 fprintf(f,
" Shape. Dimension=2\n ");
337 for fa = 1:size(this.
Faces,2)
338 fprintf(f,
" Element: 0 %d 0\n ",fa);
339 fprintf(f,
" Faces:\n ");
340 elem = this.
Faces(1,fa);
345 facenodeidx =
sort([facenodeidx; facenodeidx(2:end) facenodeidx(1)]);
347 fprintf(f,
" 0 0 %d\n ",edgenumbers);
351 fprintf(f,
" Shape. Dimension=3\n ");
352 fprintf(f,
" #Scale factor sets=0\n ");
353 fprintf(f,
" #Nodes=0\n ");
355 fprintf(f,
" #Fields=0\n ");
361 fprintf(f,
" Element: %d 0 0\n ",m);
363 facesofelem = find(this.
Faces(1,:) == m);
364 if ~isempty(facesofelem)
365 fprintf(f,
" Faces:\n ");
366 fprintf(f,
" 0 %d 0\n ",facesofelem);
368 fprintf(f,
" Nodes: %s\n ",sprintf(
" %d\t ",this.
Elements(m,:)));
383 if Afaceidx ~= Bfaceidx
389 opposing = sum(abs(A - circshift(B,
l-1)),2) == 0;
391 opposedto = circshift(opposing,-(
l-1));
392 inner(opposing, Afaceidx) = find(opposedto);
393 inner(opposedto, Bfaceidx) = find(opposing);
399 [elemnr, facenr] = find(inner == 0);
400 faces = [elemnr facenr]^
t;
403 faces = [ones(1,mf); 1:mf];
433 pos = (face-1)*ppf + (1:ppf);
456 this.reverseElementAxis(dim, e);
459 [ip,jp] = find(chk > 0);
460 [in,jn] = find(chk < 0);
461 [is,js] = find(chk == 0);
463 errel = this.
Elements(e,oi(js,[is is+1]^
t,dim));
464 fprintf(
" \n%s: Degenerate element nr %3d in dimension %d: %3d equal! Nodes %s (%s)\n ",...
465 class(
this),e,dim,length(is),int2str(errel),num2str(this.
Nodes(dim,errel)));
467 if length(ip) > length(in)
476 errel = this.
Elements(e,oi(j,[i i+1],dim));
477 fprintf(
" \n%s: Opposite orientation in dimension %d in mainly %s oriented element nr %3d (%3d pos/%3d neg): Nodes %s (%s)\n ",...
478 class(
this),dim,str,e,length(ip),length(in),int2str(errel),num2str(this.
Nodes(dim,errel)));
480 this.reverseElementAxis(dim, e);
494 function reverseElementAxis(dim,e) {
502 #if 0 //mtoc++: 'get.NumElements'
511 #if 0 //mtoc++: 'get.NumNodes'
513 nc = size(this.
Nodes,2);
520 #if 0 //mtoc++: 'get.NumFaces'
522 nf = size(this.
Faces,2);
530 #if 0 //mtoc++: 'get.NodesPerFace'
539 #if 0 //mtoc++: 'get.Width'
540 function w =
Width() {
541 w = max(this.
Nodes(1,:))-min(this.
Nodes(1,:));
548 #if 0 //mtoc++: 'get.Depth'
549 function w =
Depth() {
550 w = max(this.
Nodes(2,:))-min(this.
Nodes(2,:));
557 #if 0 //mtoc++: 'get.Height'
559 w = max(this.
Nodes(3,:))-min(this.
Nodes(3,:));
568 fem.geometry.RegularHex8Grid(1:3);
569 fem.geometry.RegularHex8Grid(1:3,1:4);
570 fem.geometry.RegularHex8Grid(1:3,1:4,-1:3);
571 fem.geometry.RegularHex8Grid(1:3,1:4,-1:3,.2);
572 fem.geometry.RegularHex20Grid(1:2);
573 fem.geometry.RegularHex20Grid(1:2,0:2);
574 fem.geometry.RegularHex20Grid(-1:1,1:3,-1:1);
575 fem.geometry.RegularHex20Grid(-1:1,1:2,-1:1,.2);
581 g = fem.geometry.RegularHex27Grid(-1:1,1:2,-1:1,.2);
582 [sg, node] = g.getSubMesh(1:3:g.NumElements);
584 g = fem.geometry.RegularHex8Grid(-20:1,1:4,-1:1,.2);
585 [sg, node] = g.getSubMesh([1 5 9 10 15 56 79 99]);
Collection of generally useful functions.
function checkOrientation()
Elements
m x p index vector for all p nodes of m elements
static function res = test_DemoGrids()
Nodes
n x 3 position vector of nodes
function copy = scale(factor)
PatchFacesIdx
The indices of the nodes suitable for creating a patch surface object.
function commonidx = getCommonNodesWith(other)
static function idx = findVecInMatrix(A, b)
Finds column vectors inside a matrix.
function bounds = getBoundingBox(marginfac)
function toCMGUI(folder, name)
sort
ort the handle objects in any array in ascending or descending order.
reshape
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape ...
Depth
Returns the Depth of the geometry (y-range)
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
Matlab's base handle class (documentation generation substitute)
logical LeaveOpen
Flag indicating if the plots should be left open once the PlotManager is deleted (as variable) ...
Height
Returns the Height of the geometry (z-range)
Edges
2 x k index vector for edges between two points
static function test_subMesh()
function faceComputations(faces)
% Also compute the PatchFaces index matrix
function faces = computeFaces()
Computes the outward faces of this fem.geometry.
FaceNormals
Faces are: Idx : 1 2 3 4 5 6 Face: X- X+ Y- Y+ Z- Z+ Pos: Left Right Front Rear Bottom Top...
Width
Returns the width of the geometry (x-range)
Faces
A 2 x N_F vector containing the element number in the first row and the face number on that element i...
function [ sub , nodeidx , faces ] = getSubMesh(elems, faces)
function reverseAxis(dim)
function plot(withdofnr, elem, pm)
ProcessIndicator: A simple class that indicates process either via waitbar or text output...