Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
fracture-flow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
benchmarks
fracture-flow
Commits
199b97f7
Commit
199b97f7
authored
8 years ago
by
Ivar Stefansson
Browse files
Options
Downloads
Patches
Plain Diff
Upload new file
parent
cec7b618
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/line_norm.m
+100
-0
100 additions, 0 deletions
scripts/line_norm.m
with
100 additions
and
0 deletions
scripts/line_norm.m
0 → 100644
+
100
−
0
View file @
199b97f7
function
[
relativeError
,
errorSquared
,
normalizationSquared
]
=
...
line_norm
(
fracXAndP
,
p
,
t
,
x
,
FRAC
)
%line_norm calculates the error for a single line
% For the format of fracXAndP, see the Description file. p, t and x are
% the reference pressure, triangulation and point list, respectively.
boundary_line
=
false
;
if
fracXAndP
(
1
)
==
fracXAndP
(
2
)
endPoints
=
[
fracXAndP
(
1
),
min
(
fracXAndP
(:,
2
));
...
fracXAndP
(
1
),
max
(
fracXAndP
(:,
2
))];
a
=
endPoints
(
1
);
b
=
0
;
isVertical
=
true
;
fractureLength
=
endPoints
(
4
)
-
endPoints
(
3
);
else
[
x1
,
iMin
]
=
min
(
fracXAndP
(:,
1
));
[
x2
,
iMax
]
=
max
(
fracXAndP
(:,
1
));
endPoints
=
[
x1
,
fracXAndP
(
iMin
,
2
);
x2
,
fracXAndP
(
iMax
,
2
)];
a
=
(
endPoints
(
2
,
2
)
-
endPoints
(
1
,
2
))
/
(
endPoints
(
2
,
1
)
-
endPoints
(
1
,
1
));
b
=
endPoints
(
1
,
2
)
-
a
*
endPoints
(
1
,
1
);
isVertical
=
false
;
fractureLength
=
hypot
(
abs
(
endPoints
(
1
)
-
endPoints
(
2
)),
abs
(
endPoints
(
3
)
-
endPoints
(
4
)));
end
[
verticesNorthWest
,
verticesOn
]
=
check_points
(
x
,
a
,
b
,
isVertical
);
if
~
FRAC
[
VerticesNorthWest
,
VerticesOn
]
=
check_points
(
X
,
a
,
b
,
isVertical
);
end
% The code must unfortunately allow for cells with different number of vertices
% both for fine grid and coarse for generality.
% Therefore, cellPointsOn is a CELL with nVertices(c) pointer extracted
% from t. cellPointsNorthWestOn is the corresponding logical northWest
% cell, true for points north west of the fracture.
% Triangulation faces might coincide with the fracture:
[
cellPointsOn
,
pOn
,
cellPointsNorthWestOn
,
cellVerticesOn
,
verticesP
]
=
...
find_on_line
(
t
,
x
,
verticesNorthWest
,
verticesOn
,
p
);
if
~
FRAC
[
CellPointsOn
,
POn
,
CellPointsNorthWestOn
,
CellVerticesOn
,
VerticesP
]
=
...
find_on_line
(
T
,
X
,
VerticesNorthWest
,
VerticesOn
,
P
);
else
CellVerticesOn
=
[];
VerticesP
=
[];
end
% Those faces will not be unique. The values corresponding to the two
% neighbouring cells are merged:
if
~
boundary_line
&&
~
isempty
(
cellVerticesOn
)
[
cellVerticesOn
,
verticesP
]
=
combine_faces
(
cellVerticesOn
,
verticesP
,
isVertical
);
end
if
~
boundary_line
&&
~
isempty
(
CellVerticesOn
)
[
CellVerticesOn
,
VerticesP
]
=
combine_faces
(
CellVerticesOn
,
VerticesP
,
isVertical
);
end
% Find the points where the line intersects each of the fine and coarse
% cells, respectively. Format intersectionPoints(c,:) = [x1,y1,x2,y2] for the
% two points for cell c.
[
intersectionPoints
]
=
intersections_of_cells
(
endPoints
,
isVertical
,
...
cellPointsOn
,
cellPointsNorthWestOn
);
if
FRAC
nCells
=
size
(
fracXAndP
,
1
);
ind_two
=
linspace
(
2
,
nCells
,
nCells
/
2
);
ind_one
=
ind_two
-
1
;
IntersectionPoints
=
[
fracXAndP
(
ind_one
,
1
:
2
),
fracXAndP
(
ind_two
,
1
:
2
)];
POn
=
fracXAndP
(
ind_two
,
3
);
else
[
IntersectionPoints
]
=
intersections_of_cells
(
endPoints
,
isVertical
,
...
CellPointsOn
,
CellPointsNorthWestOn
);
end
% Add the values for the faces coinciding with the line:
if
~
isempty
(
cellVerticesOn
)
intersectionPoints
=
[
intersectionPoints
;
cellVerticesOn
];
pOn
=
[
pOn
;
verticesP
];
end
if
~
isempty
(
CellVerticesOn
)
IntersectionPoints
=
[
IntersectionPoints
;
CellVerticesOn
];
POn
=
[
POn
;
VerticesP
];
end
% Loop through large cells, find smalls cells (partly) inside and evaluate
% norms in evaluate_norm:
errorSquared
=
evaluate_norm
(
IntersectionPoints
,
intersectionPoints
,
POn
,
pOn
,
isVertical
,
endPoints
);
normalizationSquared
=
(
max
(
p
)
-
min
(
p
))
^
2
*
fractureLength
;
relativeError
=
sqrt
((
errorSquared
)/(
normalizationSquared
));
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment