fix_boundary

PURPOSE ^

FIX_BOUNDARY Orient boundary triangles consistently

SYNOPSIS ^

function mdl = fix_boundary(mdl)

DESCRIPTION ^

FIX_BOUNDARY Orient boundary triangles consistently
 mdl = FIX_BOUNDARY(mdl) changes or adds mdl.boundary to an eidors
  fwd_model
 
 See also FIX_MODEL

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mdl = fix_boundary(mdl)
0002 %FIX_BOUNDARY Orient boundary triangles consistently
0003 % mdl = FIX_BOUNDARY(mdl) changes or adds mdl.boundary to an eidors
0004 %  fwd_model
0005 %
0006 % See also FIX_MODEL
0007 
0008 % (C) 2015-2016 Bartlomiej Grychtol. License: GPL version 2 or 3
0009 % $Id: fix_boundary.m 6926 2024-05-31 15:34:13Z bgrychtol $
0010 
0011 opt.elem2face  = 1;
0012 opt.boundary_face = 1;
0013 opt.inner_normal = 1;
0014 tmp = fix_model(mdl,opt);
0015 flip = tmp.elem2face(logical(tmp.boundary_face(tmp.elem2face).*tmp.inner_normal));
0016 tmp.faces(flip,:) = tmp.faces(flip,[1 3 2]);
0017 tmp.normals(flip,:) = -tmp.normals(flip,:);
0018 
0019 % don't pollute the model, but make existing relevant fields consistent
0020 fields = {'faces', 'normals', 'inner_normal', 'boundary_face'};
0021 for i = 1:numel(fields)
0022    if isfield(mdl, fields{i})
0023       mdl.(fields{i}) = tmp.(fields{i}); 
0024    end
0025 end
0026 mdl.boundary = tmp.faces(tmp.boundary_face,:);
0027 
0028 mdl = eidors_obj('set', mdl);

Generated on Sun 29-Dec-2024 11:41:59 by m2html © 2005