-
Notifications
You must be signed in to change notification settings - Fork 1
/
ReflectionBoundaryConditions.m
48 lines (34 loc) · 1.21 KB
/
ReflectionBoundaryConditions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
classdef ReflectionBoundaryConditions <BoundaryConditions
% boundary conditions requiring vertices to satisfy v=Rv where R is a
% reflection matrix. Essentialy this means that v lies on the inifinite
% plane that R maps to itself, defined by a normal.
properties
normal;
inds;
end
methods
function obj=ReflectionBoundaryConditions(normal,inds)
if size(normal,1)~=1
normal=normal';
end
if size(inds,1)==1
inds=inds';
end
obj.normal=normal/norm(normal);
obj.inds=inds;
end
function [A,b]=constraints(obj,NV)
I=repmat((1:length(obj.inds))',1,3)';
J=[obj.inds*3-2 obj.inds*3-1 obj.inds*3]';
V=repmat(obj.normal,length(obj.inds),1)';
I=I(:);
J=J(:);
V=V(:);
A=sparse(I,J,V,max(I),NV*3);
b=zeros(size(A,1),1);
end
function good=validSolution(obj,V)
good=max(abs(V(obj.inds,:)*obj.normal'));
end
end
end