*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit e21bd849 authored by Innerberger, Michael's avatar Innerberger, Michael
Browse files

Merge branch 'master' into documentation-paper

parents acfa28d8 f614fb82
No related branches found
No related tags found
No related merge requests found
Showing
with 150 additions and 137 deletions
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
classdef BilinearForm < handle classdef BilinearForm < handle
%% properties %% properties
properties (GetAccess='public', SetAccess='protected') properties (GetAccess=public, SetAccess=protected)
fes fes
end end
properties (Access='public') properties (Access=public)
a {mustBeEvaluableOrEmpty} = [] % Diffusion matrix (or scalar) a {mustBeEvaluableOrEmpty} = [] % Diffusion matrix (or scalar)
b {mustBeEvaluableOrEmpty} = [] % Convection vector field b {mustBeEvaluableOrEmpty} = [] % Convection vector field
c {mustBeEvaluableOrEmpty} = [] % Reaction coefficient c {mustBeEvaluableOrEmpty} = [] % Reaction coefficient
...@@ -33,11 +33,11 @@ classdef BilinearForm < handle ...@@ -33,11 +33,11 @@ classdef BilinearForm < handle
end end
end end
methods (Access='public') methods (Access=public)
mat = assemble(obj); mat = assemble(obj);
end end
methods (Static, Access='protected') methods (Static, Access=protected)
val = diffusionPart(a, Dphi); val = diffusionPart(a, Dphi);
val = convectionPart(b, Dphi, phi); val = convectionPart(b, Dphi, phi);
val = reactionPart(c, phi); val = reactionPart(c, phi);
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
classdef LinearForm < handle classdef LinearForm < handle
%% properties %% properties
properties (GetAccess='public', SetAccess='protected') properties (GetAccess=public, SetAccess=protected)
fes fes
end end
properties (Access='public') properties (Access=public)
f {mustBeEvaluableOrEmpty} = [] % Volume load f {mustBeEvaluableOrEmpty} = [] % Volume load
fvec {mustBeEvaluableOrEmpty} = [] % Generalized volume load fvec {mustBeEvaluableOrEmpty} = [] % Generalized volume load
robin {mustBeEvaluableOrEmpty} = [] % Robin boundary load robin {mustBeEvaluableOrEmpty} = [] % Robin boundary load
...@@ -33,11 +33,11 @@ classdef LinearForm < handle ...@@ -33,11 +33,11 @@ classdef LinearForm < handle
end end
end end
methods (Access='public') methods (Access=public)
vec = assemble(obj); vec = assemble(obj);
end end
methods (Static, Access='protected') methods (Static, Access=protected)
val = scalarPart(f, phi); val = scalarPart(f, phi);
val = vectorPart(fvec, Dphi); val = vectorPart(fvec, Dphi);
val = neumannPart(neumann, phi); val = neumannPart(neumann, phi);
......
...@@ -8,16 +8,16 @@ ...@@ -8,16 +8,16 @@
classdef Evaluable < handle classdef Evaluable < handle
%% properties %% properties
properties (Abstract, GetAccess='public', SetAccess='protected') properties (Abstract, GetAccess=public, SetAccess=protected)
mesh mesh
end end
%% methods %% methods
methods (Abstract, Access='public') methods (Abstract, Access=public)
eval(obj, bary, idx) eval(obj, bary, idx)
end end
methods (Access='public') methods (Access=public)
plot(obj, plotOptions) plot(obj, plotOptions)
evalEdge(obj, bary, idx) evalEdge(obj, bary, idx)
end end
......
...@@ -59,18 +59,17 @@ else ...@@ -59,18 +59,17 @@ else
warning('Custom plot options discarded due to subdivisions.') warning('Custom plot options discarded due to subdivisions.')
end end
for s = smin:smax for s = smin:smax
idx = find(subdivision == s); currentElems = find(subdivision == s);
if ~isempty(idx) if ~isempty(currentElems)
% subtriangles on one element % subtriangles on one element
bary = Barycentric2D(partition3(s)/s); bary = Barycentric2D(partition3(s)/s);
[elements, outerEdges] = getSubtriangles(s); [elements, outerEdges] = getSubtriangles(s);
nSubtriangles = size(elements, 1) * numel(idx);
% compute plot data % compute plot data
coordinates = mesh.elementwiseCoordinates(bary, idx); coordinates = mesh.elementwiseCoordinates(bary, currentElems);
Xel = splitFirstDimension(coordinates, elements); Xel = splitFirstDimension(coordinates, elements);
Xlin = splitFirstDimension(coordinates, outerEdges); Xlin = splitFirstDimension(coordinates, outerEdges);
data = guaranteeSize(eval(obj, bary, idx), mesh.nElements, bary.nNodes); data = guaranteeSize(eval(obj, bary, currentElems), numel(currentElems), bary.nNodes);
Zel = splitFirstDimension(data, elements); Zel = splitFirstDimension(data, elements);
Zlin = splitFirstDimension(data, outerEdges); Zlin = splitFirstDimension(data, outerEdges);
......
...@@ -13,14 +13,14 @@ ...@@ -13,14 +13,14 @@
classdef CompositeFunction < Evaluable classdef CompositeFunction < Evaluable
%% properties %% properties
properties (SetAccess='protected', GetAccess='public') properties (SetAccess=protected, GetAccess=public)
mesh mesh
functionHandle functionHandle
functionArguments functionArguments
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = CompositeFunction(functionHandle, functionArguments) function obj = CompositeFunction(functionHandle, functionArguments)
arguments arguments
functionHandle (1,1) function_handle functionHandle (1,1) function_handle
...@@ -44,7 +44,7 @@ classdef CompositeFunction < Evaluable ...@@ -44,7 +44,7 @@ classdef CompositeFunction < Evaluable
end end
end end
methods (Access='private') methods (Access=private)
function val = compositeEval(obj, evalMethod, bary, idx) function val = compositeEval(obj, evalMethod, bary, idx)
arguments arguments
obj obj
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
classdef Constant < Evaluable classdef Constant < Evaluable
%% properties %% properties
properties (GetAccess='public', SetAccess='protected') properties (GetAccess=public, SetAccess=protected)
mesh mesh
constantValue (:,1) double constantValue (:,1) double
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = Constant(mesh, value) function obj = Constant(mesh, value)
obj.mesh = mesh; obj.mesh = mesh;
obj.constantValue = value; obj.constantValue = value;
......
...@@ -19,19 +19,19 @@ ...@@ -19,19 +19,19 @@
classdef FeFunction < Evaluable classdef FeFunction < Evaluable
%% properties %% properties
properties (SetAccess='protected', GetAccess='public') properties (SetAccess=protected, GetAccess=public)
mesh mesh
fes fes
data (1,:) double data (1,:) double
dataIsValid (1,1) logical dataIsValid (1,1) logical
end end
properties (Access = 'private') properties (Access = private)
listenerHandle listenerHandle
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = FeFunction(fes) function obj = FeFunction(fes)
arguments arguments
fes (1,1) FeSpace fes (1,1) FeSpace
...@@ -43,7 +43,7 @@ classdef FeFunction < Evaluable ...@@ -43,7 +43,7 @@ classdef FeFunction < Evaluable
obj.dataIsValid = true; obj.dataIsValid = true;
% register FeFunction as an observer of mesh % register FeFunction as an observer of mesh
obj.listenerHandle = fes.mesh.listener('HasChanged', @obj.handleChangedMesh); obj.listenerHandle = fes.mesh.listener('JustRefined', @obj.handleChangedMesh);
end end
function setData(obj, data) function setData(obj, data)
...@@ -91,7 +91,7 @@ classdef FeFunction < Evaluable ...@@ -91,7 +91,7 @@ classdef FeFunction < Evaluable
end end
end end
methods (Access = 'private') methods (Access = private)
function handleChangedMesh(obj, ~, ~) function handleChangedMesh(obj, ~, ~)
obj.dataIsValid = false; obj.dataIsValid = false;
end end
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
classdef Gradient < Evaluable classdef Gradient < Evaluable
%% properties %% properties
properties (SetAccess='protected', GetAccess='public') properties (SetAccess=protected, GetAccess=public)
u u
mesh mesh
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = Gradient(u) function obj = Gradient(u)
arguments arguments
u (1,1) FeFunction u (1,1) FeFunction
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
classdef Hessian < Evaluable classdef Hessian < Evaluable
%% properties %% properties
properties (SetAccess='protected', GetAccess='public') properties (SetAccess=protected, GetAccess=public)
u u
mesh mesh
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = Hessian(u) function obj = Hessian(u)
arguments arguments
u (1,1) FeFunction u (1,1) FeFunction
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
classdef MeshFunction < Evaluable classdef MeshFunction < Evaluable
%% properties %% properties
properties (GetAccess='public', SetAccess='protected') properties (GetAccess=public, SetAccess=protected)
mesh mesh
functionHandle functionHandle
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = MeshFunction(mesh, functionHandle) function obj = MeshFunction(mesh, functionHandle)
arguments arguments
mesh (1,1) Mesh mesh (1,1) Mesh
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
classdef NormalVector < Evaluable classdef NormalVector < Evaluable
%% properties %% properties
properties (GetAccess='public', SetAccess='protected') properties (GetAccess=public, SetAccess=protected)
mesh mesh
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = NormalVector(mesh) function obj = NormalVector(mesh)
obj.mesh = mesh; obj.mesh = mesh;
end end
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
classdef TestFunction < Evaluable classdef TestFunction < Evaluable
%% properties %% properties
properties (SetAccess='protected', GetAccess='public') properties (SetAccess=protected, GetAccess=public)
fes fes
mesh mesh
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = TestFunction(fes) function obj = TestFunction(fes)
arguments arguments
fes (1,1) FeSpace fes (1,1) FeSpace
......
...@@ -10,13 +10,13 @@ ...@@ -10,13 +10,13 @@
classdef TestFunctionGradient < Evaluable classdef TestFunctionGradient < Evaluable
%% properties %% properties
properties (SetAccess='protected', GetAccess='public') properties (SetAccess=protected, GetAccess=public)
fes fes
mesh mesh
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = TestFunctionGradient(fes) function obj = TestFunctionGradient(fes)
arguments arguments
fes (1,1) FeSpace fes (1,1) FeSpace
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
classdef Mesh < handle classdef Mesh < handle
%% properties %% properties
properties (GetAccess = 'public', SetAccess = 'private') properties (GetAccess = public, SetAccess = private)
coordinates (2,:) double coordinates (2,:) double
elements (3,:) double elements (3,:) double
edges (2,:) double edges (2,:) double
...@@ -15,11 +15,6 @@ classdef Mesh < handle ...@@ -15,11 +15,6 @@ classdef Mesh < handle
boundaries (:,1) cell boundaries (:,1) cell
end end
properties (GetAccess = 'public', SetAccess = 'private', Hidden = true)
markedEdges (:,1) logical
bisecGroups (:,1) cell
end
%% dependent properties (computed from data) %% dependent properties (computed from data)
properties (Dependent) properties (Dependent)
nCoordinates nCoordinates
...@@ -29,18 +24,19 @@ classdef Mesh < handle ...@@ -29,18 +24,19 @@ classdef Mesh < handle
end end
%% private properties for caching purposes %% private properties for caching purposes
properties (Access = 'private') properties (Access = private)
trafo trafo
end end
%% events %% events
events events
IsAboutToRefine IsAboutToRefine
HasChanged JustRefined
RefineCompleted
end end
%% public methods %% public methods
methods (Access = 'public') methods (Access = public)
function obj = Mesh(coordinates, elements, boundaries) function obj = Mesh(coordinates, elements, boundaries)
% Construct Mesh object from given coordinate, element, and boundary % Construct Mesh object from given coordinate, element, and boundary
% arrays. % arrays.
...@@ -70,12 +66,13 @@ classdef Mesh < handle ...@@ -70,12 +66,13 @@ classdef Mesh < handle
saveTikzConforming(obj, varargin) saveTikzConforming(obj, varargin)
refineLocally(obj, marked, method) refineLocally(obj, marked, method)
refineUniform(obj, n, method) refineUniform(obj, n, method)
changeRefinementEdge(obj, newRefinementEdge)
edges = getCombinedBndEdges(obj, idx) edges = getCombinedBndEdges(obj, idx)
end end
%% protected methods %% protected methods
methods (Access='protected') methods (Access=protected)
updateData(obj) updateData(obj, bisecData)
end end
%% get methods for dependent data %% get methods for dependent data
......
% changeRefinementEdge Rotate internal data structures such that given
% edge is new refinement edge per element.
%
% mesh.changeRefinementEdge(newRefinementEdge) changes the elements,
% element2edges, and flipEdges data structures of the mesh such that the
% new edge is the edge given in newRefinementEdge per element. New edges
% are given as index in {1,2,3}, according to the old element2edges data
% structure.
function changeRefinementEdge(obj, newRefinementEdge)
arguments
obj
newRefinementEdge (1,:) double {mustBeInRange(newRefinementEdge, 1, 3)}
end
for k = 2:3
idx = find(newRefinementEdge == k);
obj.element2edges(:,idx) = circshift(obj.element2edges(:,idx), 4-k, 1);
obj.elements(:,idx) = circshift(obj.elements(:,idx), 4-k, 1);
obj.flipEdges(:,idx) = circshift(obj.flipEdges(:,idx), 4-k, 1);
end
end
\ No newline at end of file
...@@ -22,14 +22,14 @@ end ...@@ -22,14 +22,14 @@ end
%% prepare data for refinement and make it available to listeners %% prepare data for refinement and make it available to listeners
refinementAlgorithm = feval(method, obj); refinementAlgorithm = feval(method, obj);
[obj.markedEdges, obj.bisecGroups] = refinementAlgorithm.prepareRefinementData(marked); bisecData = refinementAlgorithm.prepareRefinementData(marked);
obj.notify('IsAboutToRefine') obj.notify('IsAboutToRefine', bisecData)
%% do actual refinement and clear data of old mesh %% do actual refinement and clear data of old mesh
obj.updateData(); obj.updateData(bisecData);
obj.markedEdges = [];
obj.bisecGroups = [];
obj.trafo = []; obj.trafo = [];
obj.notify('HasChanged'); obj.notify('JustRefined');
obj.notify('RefineCompleted')
end end
\ No newline at end of file
...@@ -5,80 +5,86 @@ ...@@ -5,80 +5,86 @@
% %
% See also Mesh % See also Mesh
function updateData(obj) function updateData(obj, bisecData)
%% create indices of ... %% create old-to-new connectivity
% new nodes oldEdge2parent = cumsum([1; 1+bisecData.bisectedEdges]);
edgeNodes = obj.nCoordinates + (1:nnz(obj.markedEdges))'; oldElement2parent = cumsum([1; getNChildrenPerElement(bisecData)]);
innerNodes = cumsum([edgeNodes(end); cellfun(@(x) x.nMembers*x.nInnerNodes, obj.bisecGroups)]);
% new edges
innerEdges = cumsum([obj.nEdges + nnz(obj.markedEdges); cellfun(@(x) x.nMembers*x.nInnerEdges, obj.bisecGroups)]);
nChildEdges = 1 + obj.markedEdges;
oldEdge2parent = cumsum([1; nChildEdges]);
% new elements
nChildElems = ones(obj.nElements, 1);
for k = 1:length(obj.bisecGroups)
nChildElems(obj.bisecGroups{k}.elementIdx) = obj.bisecGroups{k}.nDescendants;
end
oldElement2parent = cumsum([1; nChildElems]);
%% create new coordinates %% create new coordinates
newCoordinates = [obj.coordinates, ... % new nodes = old nodes | nodes on edges | interior nodes
edgewiseCoordinates(obj, [1;1]/2, obj.markedEdges), ... idxN = cumsum([1; obj.nCoordinates; nnz(bisecData.bisectedEdges); ...
zeros(2, innerNodes(end)-innerNodes(1))]; bisecData.nRefinedElements.*bisecData.nInnerNodes]);
for k = 1:numel(obj.bisecGroups) newCoordinates = zeros(2, idxN(end)-1);
if obj.bisecGroups{k}.nInnerNodes ~= 0 newCoordinates(:,idxN(1):idxN(2)-1) = obj.coordinates;
newCoordinates(:,innerNodes(k)+1:innerNodes(k+1)) = ... newCoordinates(:,idxN(2):idxN(3)-1) = edgewiseCoordinates(obj, [1;1]/2, bisecData.bisectedEdges);
elementwiseCoordinates(obj, obj.bisecGroups{k}.innerNodes, obj.bisecGroups{k}.elementIdx);
end for k = find(bisecData.nInnerNodes ~= 0)'
newCoordinates(:,idxN(k+2):idxN(k+3)-1) = ...
elementwiseCoordinates(obj, bisecData.bisection{k}.innerNodes, getRefinedElementIdx(bisecData, k));
end end
%% refine existing edges %% refine existing edges
newEdges = [moveParents(obj.edges, oldEdge2parent), ... % new edges = old edges + children | interior edges
zeros(2, innerEdges(end) - innerEdges(1))]; idxS = cumsum([1; obj.nEdges + nnz(bisecData.bisectedEdges); ...
bisecData.nRefinedElements.*bisecData.nInnerEdges]);
children = getChildIndices(oldEdge2parent(obj.markedEdges), 2); newEdges = zeros(2, idxS(end)-1);
newEdges(:,children) = [obj.edges(1,obj.markedEdges), edgeNodes'; ... newEdges(:,oldEdge2parent(1:(end-1))) = obj.edges;
edgeNodes', obj.edges(2,obj.markedEdges)];
edgeNodes = (idxN(2):idxN(3)-1)';
children = getChildIndices(oldEdge2parent(bisecData.bisectedEdges), 2);
newEdges(:,children) = [obj.edges(1,bisecData.bisectedEdges), edgeNodes'; ...
edgeNodes', obj.edges(2,bisecData.bisectedEdges)];
%% refine boundaries %% refine boundaries
newBoundaries = cell(obj.nBoundaries, 1); newBoundaries = cell(obj.nBoundaries, 1);
for k = 1:obj.nBoundaries for k = 1:obj.nBoundaries
newBoundaries{k} = oldEdge2parent(obj.boundaries{k}); newBoundaries{k} = oldEdge2parent(obj.boundaries{k});
bndChildren = newBoundaries{k}(obj.markedEdges(obj.boundaries{k})) + 1; bndChildren = newBoundaries{k}(bisecData.bisectedEdges(obj.boundaries{k})) + 1;
newBoundaries{k} = [newBoundaries{k}; bndChildren]; newBoundaries{k} = [newBoundaries{k}; bndChildren];
end end
%% allocate new element-wise arrays %% refine element data
oldEdgeNewIdx = oldEdge2parent(obj.element2edges); newElements = zeros(3, oldElement2parent(end)-1);
newElements = moveParents(obj.elements, oldElement2parent); newE2E = zeros(3, oldElement2parent(end)-1);
newE2E = moveParents(oldEdgeNewIdx, oldElement2parent); newFlip = false(3, oldElement2parent(end)-1);
newFlip = moveParents(obj.flipEdges, oldElement2parent);
%% generate bisection rule dependent data oldEdgeNewIdx = oldEdge2parent(obj.element2edges);
[left, right] = getLeftAndRightEdgePerElement(obj, oldEdgeNewIdx); elems = bisecData.getRefinedElementIdx(0);
newElements(:,oldElement2parent(elems)) = obj.elements(:,elems);
newE2E(:,oldElement2parent(elems)) = oldEdgeNewIdx(:,elems);
newFlip(:,oldElement2parent(elems)) = obj.flipEdges(:,elems);
%% get left and right edge per element
% here, we use the fact that left and right edge index only differ by 1
bisectedEdges = bisecData.bisectedEdges(obj.element2edges);
left = oldEdgeNewIdx.*bisectedEdges;
right = left + bisectedEdges;
left = left + obj.flipEdges;
right = right - obj.flipEdges;
%% refine elements + add inner edges
edgeMidPts = zeros(obj.nEdges,1); edgeMidPts = zeros(obj.nEdges,1);
edgeMidPts(obj.markedEdges) = edgeNodes; edgeMidPts(bisecData.bisectedEdges) = edgeNodes;
edgeMidPts = edgeMidPts(obj.element2edges); edgeMidPts = edgeMidPts(obj.element2edges);
for k = 1:length(obj.bisecGroups) for k = find(bisecData.nRefinedElements)'
idx = (innerEdges(k)+1):innerEdges(k+1); idx = idxS(k+1):idxS(k+2)-1;
intEdges = reshape(idx, [], obj.bisecGroups{k}.nInnerEdges)'; elems = getRefinedElementIdx(bisecData, k);
intNodes = reshape((innerNodes(k)+1:innerNodes(k+1))', obj.bisecGroups{k}.nInnerNodes, []); intEdges = reshape(idx, [], bisecData.nInnerEdges(k))';
intNodes = reshape((idxN(k+2):idxN(k+3)-1)', bisecData.nInnerNodes(k), []);
parentEdges = oldEdgeNewIdx(:, obj.bisecGroups{k}.elementIdx); parentEdges = oldEdgeNewIdx(:, elems);
parentElements = oldElement2parent(obj.bisecGroups{k}.elementIdx); parentElements = oldElement2parent(elems);
children = getChildIndices(parentElements, obj.bisecGroups{k}.nDescendants); children = getChildIndices(parentElements, bisecData.nDescendants(k));
arg = restrictTo(obj.bisecGroups{k}.elementIdx, ... arg = restrictTo(elems, obj.elements, edgeMidPts, left, right, obj.flipEdges);
obj.elements, edgeMidPts, left, right, obj.flipEdges);
newEdges(:,idx) = obj.bisecGroups{k}.createNewEdges(arg{1}, arg{2}, intNodes); newEdges(:,idx) = bisecData.bisection{k}.createNewEdges(arg{1}, arg{2}, intNodes);
newElements(:,children) = obj.bisecGroups{k}.refineElement(arg{1}, arg{2}, intNodes); newElements(:,children) = bisecData.bisection{k}.refineElement(arg{1}, arg{2}, intNodes);
newE2E(:,children) = obj.bisecGroups{k}.refineEdgeConnectivity(parentEdges, arg{3}, arg{4}, intEdges); newE2E(:,children) = bisecData.bisection{k}.refineEdgeConnectivity(parentEdges, arg{3}, arg{4}, intEdges);
newFlip(:,children) = obj.bisecGroups{k}.refineEdgeOrientation(arg{5}); newFlip(:,children) = bisecData.bisection{k}.refineEdgeOrientation(arg{5});
end end
%% assign new arrays %% assign new arrays
...@@ -96,20 +102,6 @@ function children = getChildIndices(parents, nDescendants) ...@@ -96,20 +102,6 @@ function children = getChildIndices(parents, nDescendants)
children = reshape((0:(nDescendants-1)) + parents, [], 1); children = reshape((0:(nDescendants-1)) + parents, [], 1);
end end
function newArray = moveParents(oldArray, parentPositions)
newArray = zeros(size(oldArray, Dim.Vector), parentPositions(end)-1, class(oldArray));
newArray(:,parentPositions(1:(end-1))) = oldArray;
end
function restrictedArrays = restrictTo(idx, varargin) function restrictedArrays = restrictTo(idx, varargin)
restrictedArrays = cellfun(@(x) x(:,idx), varargin, 'UniformOutput', false); restrictedArrays = cellfun(@(x) x(:,idx), varargin, 'UniformOutput', false);
end end
\ No newline at end of file
function [left, right] = getLeftAndRightEdgePerElement(mesh, oldEdgeNewIdx)
% here, we use the fact that left and right edge index only differ by 1
bisectedEdges = mesh.markedEdges(mesh.element2edges);
left = oldEdgeNewIdx.*bisectedEdges;
right = left + bisectedEdges;
left = left + mesh.flipEdges;
right = right - mesh.flipEdges;
end
...@@ -7,24 +7,24 @@ ...@@ -7,24 +7,24 @@
classdef NVB classdef NVB
%% properties %% properties
properties (GetAccess='public', SetAccess='protected') properties (GetAccess=public, SetAccess=protected)
mesh mesh
end end
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = NVB(mesh) function obj = NVB(mesh)
obj.mesh = mesh; obj.mesh = mesh;
end end
function [markedEdges, bisecGroups] = prepareRefinementData(obj, markedElements) function bisecData = prepareRefinementData(obj, markedElements)
markedEdges = obj.markedElementsToEdges(markedElements); markedEdges = obj.markedElementsToEdges(markedElements);
markedEdges = obj.meshClosure(markedEdges); markedEdges = obj.meshClosure(markedEdges);
bisecGroups = obj.groupElements(markedEdges, markedElements); bisecData = obj.groupElements(markedEdges, markedElements);
end end
end end
methods (Access='protected') methods (Access=protected)
function markedEdges = markedElementsToEdges(obj, markedElements) function markedEdges = markedElementsToEdges(obj, markedElements)
markedEdges = false(obj.mesh.nEdges,1); markedEdges = false(obj.mesh.nEdges,1);
markedEdges(obj.mesh.element2edges(:,markedElements)) = true; markedEdges(obj.mesh.element2edges(:,markedElements)) = true;
...@@ -39,13 +39,14 @@ classdef NVB ...@@ -39,13 +39,14 @@ classdef NVB
end end
end end
function bisecGroups = groupElements(obj, markedEdges, ~) function bisecData = groupElements(obj, markedEdges, ~)
% group elements according to their refinement pattern % group elements according to their refinement pattern
edge = reshape(markedEdges(obj.mesh.element2edges), size(obj.mesh.element2edges)); edge = reshape(markedEdges(obj.mesh.element2edges), size(obj.mesh.element2edges));
bisecGroups{1} = Bisec1 ( find( edge(1,:) & ~edge(2,:) & ~edge(3,:) ) ); bisecData = BisectionEventData(obj.mesh.nElements, markedEdges, ...
bisecGroups{2} = Bisec12 ( find( edge(1,:) & edge(2,:) & ~edge(3,:) ) ); Bisec1, find(edge(1,:) & ~edge(2,:) & ~edge(3,:)), ...
bisecGroups{3} = Bisec13 ( find( edge(1,:) & ~edge(2,:) & edge(3,:) ) ); Bisec12, find(edge(1,:) & edge(2,:) & ~edge(3,:)), ...
bisecGroups{4} = Bisec123( find( edge(1,:) & edge(2,:) & edge(3,:) ) ); Bisec13, find(edge(1,:) & ~edge(2,:) & edge(3,:)), ...
Bisec123, find(edge(1,:) & edge(2,:) & edge(3,:)));
end end
end end
end end
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
classdef NVB1 < NVB classdef NVB1 < NVB
%% methods %% methods
methods (Access='public') methods (Access=public)
function obj = NVB1(mesh) function obj = NVB1(mesh)
obj = obj@NVB(mesh); obj = obj@NVB(mesh);
end end
end end
methods (Access='protected') methods (Access=protected)
function markedEdges = markedElementsToEdges(obj, markedElements) function markedEdges = markedElementsToEdges(obj, markedElements)
markedEdges = false(1,obj.mesh.nEdges); markedEdges = false(1,obj.mesh.nEdges);
markedEdges(obj.mesh.element2edges(1,markedElements)) = true; markedEdges(obj.mesh.element2edges(1,markedElements)) = true;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
classdef NVB3 < NVB classdef NVB3 < NVB
%% public methods %% public methods
methods (Access='public') methods (Access=public)
function obj = NVB3(mesh) function obj = NVB3(mesh)
obj = obj@NVB(mesh); obj = obj@NVB(mesh);
end end
end end
end end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment