Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Yuhao Liu
ogs
Commits
cf33160e
Commit
cf33160e
authored
11 years ago
by
Karsten Rink
Browse files
Options
Downloads
Patches
Plain Diff
setting status based on mat id and returning active elements for a node
parent
5b187888
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MeshLib/ElementStatus.cpp
+36
-0
36 additions, 0 deletions
MeshLib/ElementStatus.cpp
MeshLib/ElementStatus.h
+2
-2
2 additions, 2 deletions
MeshLib/ElementStatus.h
with
38 additions
and
2 deletions
MeshLib/ElementStatus.cpp
+
36
−
0
View file @
cf33160e
...
...
@@ -51,6 +51,34 @@ std::vector<unsigned> ElementStatus::getActiveNodes() const
return
active_nodes
;
}
std
::
vector
<
MeshLib
::
Element
*>
ElementStatus
::
getActiveElementsAtNode
(
unsigned
node_id
)
const
{
const
unsigned
nElems
(
_mesh
->
getNode
(
node_id
)
->
getNElements
());
const
unsigned
nActiveElements
(
_active_nodes
[
node_id
]);
const
std
::
vector
<
Element
*>
&
elements
(
_mesh
->
getNode
(
node_id
)
->
getElements
());
std
::
vector
<
MeshLib
::
Element
*>
active_elements
;
active_elements
.
reserve
(
nActiveElements
);
for
(
unsigned
i
=
0
;
i
<
nElems
;
++
i
)
{
// if all active elements are found, the test can be cancelled for the rest of the connected elements
if
(
active_elements
.
size
()
==
nActiveElements
)
return
active_elements
;
const
unsigned
nElemNodes
(
elements
[
i
]
->
getNNodes
());
MeshLib
::
Node
const
*
const
*
const
nodes
=
elements
[
i
]
->
getNodes
();
bool
isActive
(
true
);
for
(
unsigned
j
=
0
;
j
<
nElemNodes
;
++
j
)
if
(
_active_nodes
[
nodes
[
j
]
->
getID
()]
==
0
)
{
isActive
=
false
;
break
;
}
if
(
isActive
)
active_elements
.
push_back
(
elements
[
i
]);
}
return
active_elements
;
}
unsigned
ElementStatus
::
getNActiveNodes
()
const
{
return
_active_nodes
.
size
()
-
std
::
count
(
_active_nodes
.
begin
(),
_active_nodes
.
end
(),
0
);
...
...
@@ -74,5 +102,13 @@ void ElementStatus::setElementStatus(unsigned i, bool status)
}
}
void
ElementStatus
::
setMaterialStatus
(
unsigned
material_id
,
bool
status
)
{
const
std
::
size_t
nElems
(
_mesh
->
getNElements
());
for
(
std
::
size_t
i
=
0
;
i
<
nElems
;
++
i
)
if
(
_mesh
->
getElement
(
i
)
->
getValue
()
==
material_id
)
this
->
setElementStatus
(
i
,
status
);
}
}
This diff is collapsed.
Click to expand it.
MeshLib/ElementStatus.h
+
2
−
2
View file @
cf33160e
...
...
@@ -41,7 +41,7 @@ public:
bool
getElementStatus
(
unsigned
i
)
const
{
return
_element_status
[
i
];
}
/// Returns a vector of active elements connected to a node
std
::
vector
<
MeshLib
::
Element
*>
getActiveElements
(
unsigned
node_id
)
const
{}
;
std
::
vector
<
MeshLib
::
Element
*>
getActiveElements
AtNode
(
unsigned
node_id
)
const
;
/// Returns the total number of active nodes
unsigned
getNActiveNodes
()
const
;
...
...
@@ -56,7 +56,7 @@ public:
void
setElementStatus
(
unsigned
i
,
bool
status
);
/// Sets the status of material group i
void
setMaterialStatus
(
unsigned
i
,
bool
status
)
{}
;
void
setMaterialStatus
(
unsigned
material_id
,
bool
status
);
~
ElementStatus
()
{};
...
...
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