Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
4dbe92fe
Commit
4dbe92fe
authored
13 years ago
by
Matti Pellika
Browse files
Options
Downloads
Patches
Plain Diff
pruneMeshVertexAssociations, no not save 0- and highest dim-chains
parent
9dcd522a
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Geo/GModel.cpp
+19
-8
19 additions, 8 deletions
Geo/GModel.cpp
Geo/GModel.h
+6
-0
6 additions, 0 deletions
Geo/GModel.h
Geo/Homology.cpp
+6
-112
6 additions, 112 deletions
Geo/Homology.cpp
Geo/Homology.h
+4
-1
4 additions, 1 deletion
Geo/Homology.h
with
35 additions
and
121 deletions
Geo/GModel.cpp
+
19
−
8
View file @
4dbe92fe
...
@@ -969,14 +969,7 @@ void GModel::storeChain(int dim,
...
@@ -969,14 +969,7 @@ void GModel::storeChain(int dim,
{
{
// create new discrete entities that have no associated MVertices
// create new discrete entities that have no associated MVertices
_storeElementsInEntities
(
entityMap
);
_storeElementsInEntities
(
entityMap
);
// give them physical tags
_storePhysicalTagsInEntities
(
dim
,
physicalMap
);
_storePhysicalTagsInEntities
(
dim
,
physicalMap
);
// For some weird reason, mesh element color by elementary/physical
// entity causes crashes when drawing mesh elements of the new discrete
// entities
// (somehow related to MVertex.onWhat() as MVertices are unaware of the
// new discrete entities)
CTX
::
instance
()
->
mesh
.
colorCarousel
=
0
;
// color by element type
}
}
template
<
class
T
>
template
<
class
T
>
...
@@ -1113,6 +1106,23 @@ void GModel::_storeVerticesInEntities(std::vector<MVertex*> &vertices)
...
@@ -1113,6 +1106,23 @@ void GModel::_storeVerticesInEntities(std::vector<MVertex*> &vertices)
}
}
}
}
void
GModel
::
_pruneMeshVertexAssociations
()
{
std
::
vector
<
GEntity
*>
entities
;
std
::
vector
<
MVertex
*>
vertices
;
getEntities
(
entities
);
for
(
unsigned
int
i
=
0
;
i
<
entities
.
size
();
i
++
)
{
for
(
unsigned
int
j
=
0
;
j
<
entities
[
i
]
->
mesh_vertices
.
size
();
j
++
)
{
MVertex
*
v
=
entities
[
i
]
->
mesh_vertices
[
j
];
v
->
setEntity
(
0
);
vertices
.
push_back
(
v
);
}
entities
[
i
]
->
mesh_vertices
.
clear
();
}
_associateEntityWithMeshVertices
();
_storeVerticesInEntities
(
vertices
);
}
void
GModel
::
checkMeshCoherence
(
double
tolerance
)
void
GModel
::
checkMeshCoherence
(
double
tolerance
)
{
{
int
numEle
=
getNumMeshElements
();
int
numEle
=
getNumMeshElements
();
...
@@ -2752,7 +2762,7 @@ void GModel::computeHomology()
...
@@ -2752,7 +2762,7 @@ void GModel::computeHomology()
std
::
multimap
<
dpair
,
std
::
string
>::
iterator
>
itp
=
std
::
multimap
<
dpair
,
std
::
string
>::
iterator
>
itp
=
_homologyRequests
.
equal_range
(
*
it
);
_homologyRequests
.
equal_range
(
*
it
);
Homology
*
homology
=
new
Homology
(
this
,
itp
.
first
->
first
.
first
,
Homology
*
homology
=
new
Homology
(
this
,
itp
.
first
->
first
.
first
,
itp
.
first
->
first
.
second
);
itp
.
first
->
first
.
second
,
false
);
CellComplex
*
cellcomplex
=
homology
->
createCellComplex
();
CellComplex
*
cellcomplex
=
homology
->
createCellComplex
();
if
(
cellcomplex
->
getSize
(
0
)){
if
(
cellcomplex
->
getSize
(
0
)){
for
(
std
::
multimap
<
dpair
,
std
::
string
>::
iterator
itt
=
itp
.
first
;
for
(
std
::
multimap
<
dpair
,
std
::
string
>::
iterator
itt
=
itp
.
first
;
...
@@ -2767,6 +2777,7 @@ void GModel::computeHomology()
...
@@ -2767,6 +2777,7 @@ void GModel::computeHomology()
else
else
Msg
::
Error
(
"Unknown type of homology computation: %s"
,
type
.
c_str
());
Msg
::
Error
(
"Unknown type of homology computation: %s"
,
type
.
c_str
());
}
}
_pruneMeshVertexAssociations
();
}
}
delete
cellcomplex
;
delete
cellcomplex
;
delete
homology
;
delete
homology
;
...
...
This diff is collapsed.
Click to expand it.
Geo/GModel.h
+
6
−
0
View file @
4dbe92fe
...
@@ -102,6 +102,12 @@ class GModel
...
@@ -102,6 +102,12 @@ class GModel
void
_storeVerticesInEntities
(
std
::
map
<
int
,
MVertex
*>
&
vertices
);
void
_storeVerticesInEntities
(
std
::
map
<
int
,
MVertex
*>
&
vertices
);
void
_storeVerticesInEntities
(
std
::
vector
<
MVertex
*>
&
vertices
);
void
_storeVerticesInEntities
(
std
::
vector
<
MVertex
*>
&
vertices
);
// remove all mesh vertex associations to geometrical entities and
// remove vertices from geometrical entities, then
// _associateEntityWithMeshVertices and _storeVerticesInEntities
// are called to rebuild the associations
void
_pruneMeshVertexAssociations
();
// store the physical tags in the geometrical entities
// store the physical tags in the geometrical entities
void
_storePhysicalTagsInEntities
(
int
dim
,
void
_storePhysicalTagsInEntities
(
int
dim
,
std
::
map
<
int
,
std
::
map
<
int
,
std
::
string
>
>
&
map
);
std
::
map
<
int
,
std
::
map
<
int
,
std
::
string
>
>
&
map
);
...
...
This diff is collapsed.
Click to expand it.
Geo/Homology.cpp
+
6
−
112
View file @
4dbe92fe
...
@@ -15,10 +15,10 @@
...
@@ -15,10 +15,10 @@
#if defined(HAVE_KBIPACK)
#if defined(HAVE_KBIPACK)
Homology
::
Homology
(
GModel
*
model
,
std
::
vector
<
int
>
physicalDomain
,
Homology
::
Homology
(
GModel
*
model
,
std
::
vector
<
int
>
physicalDomain
,
std
::
vector
<
int
>
physicalSubdomain
,
std
::
vector
<
int
>
physicalSubdomain
,
bool
save0N
,
bool
combine
,
bool
omit
,
bool
smoothen
)
:
bool
combine
,
bool
omit
,
bool
smoothen
)
:
_model
(
model
),
_domain
(
physicalDomain
),
_subdomain
(
physicalSubdomain
),
_model
(
model
),
_domain
(
physicalDomain
),
_subdomain
(
physicalSubdomain
),
_combine
(
combine
),
_omit
(
omit
),
_smoothen
(
smoothen
)
_save0N
(
save0N
),
_combine
(
combine
),
_omit
(
omit
),
_smoothen
(
smoothen
)
{
{
_fileName
=
""
;
_fileName
=
""
;
...
@@ -137,6 +137,8 @@ void Homology::findGenerators(CellComplex* cellComplex)
...
@@ -137,6 +137,8 @@ void Homology::findGenerators(CellComplex* cellComplex)
t2
=
Cpu
();
t2
=
Cpu
();
Msg
::
StatusBar
(
2
,
true
,
"Done computing homology spaces (%g s)"
,
t2
-
t1
);
Msg
::
StatusBar
(
2
,
true
,
"Done computing homology spaces (%g s)"
,
t2
-
t1
);
int
dim
=
cellComplex
->
getDim
();
int
HRank
[
4
];
int
HRank
[
4
];
for
(
int
j
=
0
;
j
<
4
;
j
++
){
for
(
int
j
=
0
;
j
<
4
;
j
++
){
HRank
[
j
]
=
0
;
HRank
[
j
]
=
0
;
...
@@ -165,7 +167,7 @@ void Homology::findGenerators(CellComplex* cellComplex)
...
@@ -165,7 +167,7 @@ void Homology::findGenerators(CellComplex* cellComplex)
// FIXME: Cell* and CellComplex* pointers should not outlive
// FIXME: Cell* and CellComplex* pointers should not outlive
// the objects, don't store Chains containing them for now
// the objects, don't store Chains containing them for now
//_basisChains[chain->createPGroup()] = chain;
//_basisChains[chain->createPGroup()] = chain;
chain
->
createPGroup
();
if
(
!
_save0N
&&
(
j
!=
0
&&
j
!=
dim
))
chain
->
createPGroup
();
delete
chain
;
delete
chain
;
}
}
}
}
...
@@ -246,7 +248,7 @@ void Homology::findDualGenerators(CellComplex* cellComplex)
...
@@ -246,7 +248,7 @@ void Homology::findDualGenerators(CellComplex* cellComplex)
// FIXME: Cell* and CellComplex* pointers should not outlive
// FIXME: Cell* and CellComplex* pointers should not outlive
// the objects, don't store Chains containing them for now
// the objects, don't store Chains containing them for now
//_basisChains[chain->createPGroup()] = chain;
//_basisChains[chain->createPGroup()] = chain;
chain
->
createPGroup
();
if
(
!
_save0N
&&
(
j
!=
0
&&
j
!=
dim
))
chain
->
createPGroup
();
delete
chain
;
delete
chain
;
}
}
}
}
...
@@ -266,114 +268,6 @@ void Homology::findDualGenerators(CellComplex* cellComplex)
...
@@ -266,114 +268,6 @@ void Homology::findDualGenerators(CellComplex* cellComplex)
HRank
[
0
],
HRank
[
1
],
HRank
[
2
],
HRank
[
3
]);
HRank
[
0
],
HRank
[
1
],
HRank
[
2
],
HRank
[
3
]);
}
}
/*void Homology::findHomSequence(){
CellComplex* cellComplex = createCellComplex(_domainEntities,
_subdomainEntities);
Msg::StatusBar(2, true, "Reducing cell complex...");
double t1 = Cpu();
cellComplex->reduceComplex();
double t2 = Cpu();
Msg::StatusBar(2, true, "Done reducing cell complex (%g s)", t2 - t1);
Msg::Info("%d volumes, %d faces, %d edges and %d vertices",
cellComplex->getSize(3), cellComplex->getSize(2),
cellComplex->getSize(1), cellComplex->getSize(0));
Msg::StatusBar(2, true, "Computing homology spaces...");
t1 = Cpu();
ChainComplex* subcomplex = new ChainComplex(cellComplex, 2);
ChainComplex* complex = new ChainComplex(cellComplex, 1);
ChainComplex* relcomplex = new ChainComplex(cellComplex, 0);
subcomplex->computeHomology();
complex->computeHomology();
relcomplex->computeHomology();
t2 = Cpu();
Msg::StatusBar(2, true, "Done compuring homology spaces (%g s)", t2 - t1);
Msg::StatusBar(2, true, "Computing homology sequence...");
HomologySequence* seq = new HomologySequence(subcomplex,
complex, relcomplex);
t1 = Cpu();
Msg::StatusBar(2, true, "Done computing homology sequence (%g s)", t1 - t2);
for(int task = 0; task < 3; task++){
ChainComplex* chains;
std::string domainString = "";
std::vector<int> empty;
if(task == 0) {
chains = subcomplex;
domainString = getDomainString(_subdomain, empty);
}
else if(task == 1) {
chains = complex;
domainString = getDomainString(_domain, empty);
}
else{
chains = relcomplex;
domainString = getDomainString(_domain, _subdomain);
}
int HRank[4];
for(int j = 0; j < 4; j++){
HRank[j] = 0;
std::string dimension = "";
convert(j, dimension);
for(int i = 1; i <= chains->getBasisSize(j, 3); i++){
std::string generator = "";
convert(i, generator);
std::string name = "H" + dimension + domainString + generator;
std::map<Cell*, int, Less_Cell> protoChain;
chains->getBasisChain(protoChain, i, j, 3, true);
Chain* chain = new Chain(protoChain, cellComplex, _model, name,
chains->getTorsion(j,i));
if(chain->getSize() == 0) {
delete chain;
continue;
}
HRank[j] = HRank[j] + 1;
if(chain->getTorsion() != 1){
Msg::Warning("H%d %d has torsion coefficient %d!",
j, i, chain->getTorsion());
}
_generators.push_back(chain->createPGroup());
delete chain;
}
}
if(task == 0){
Msg::Info("Ranks of relative homology spaces:");
}
if(task == 1){
Msg::Info("Ranks of absolute homology spaces:");
}
if(task == 2){
Msg::Info("Ranks of absolute homology spaces of relative subdomain:");
}
Msg::Info("H0 = %d", HRank[0]);
Msg::Info("H1 = %d", HRank[1]);
Msg::Info("H2 = %d", HRank[2]);
Msg::Info("H3 = %d", HRank[3]);
Msg::StatusBar(2, false, "H0: %d, H1: %d, H2: %d, H3: %d",
HRank[0], HRank[1], HRank[2], HRank[3]);
}
delete subcomplex;
delete complex;
delete relcomplex;
if(_fileName != "") writeGeneratorsMSH();
delete cellComplex;
delete seq;
}
*/
std
::
string
Homology
::
getDomainString
(
const
std
::
vector
<
int
>&
domain
,
std
::
string
Homology
::
getDomainString
(
const
std
::
vector
<
int
>&
domain
,
const
std
::
vector
<
int
>&
subdomain
)
const
std
::
vector
<
int
>&
subdomain
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Geo/Homology.h
+
4
−
1
View file @
4dbe92fe
...
@@ -50,6 +50,9 @@ class Homology
...
@@ -50,6 +50,9 @@ class Homology
// use chain smoothning
// use chain smoothning
bool
_smoothen
;
bool
_smoothen
;
// save chains of 0 and highest dimension
bool
_save0N
;
int
_maxdomain
;
int
_maxdomain
;
int
_maxnum
;
int
_maxnum
;
...
@@ -61,7 +64,7 @@ class Homology
...
@@ -61,7 +64,7 @@ class Homology
public:
public:
Homology
(
GModel
*
model
,
std
::
vector
<
int
>
physicalDomain
,
Homology
(
GModel
*
model
,
std
::
vector
<
int
>
physicalDomain
,
std
::
vector
<
int
>
physicalSubdomain
,
std
::
vector
<
int
>
physicalSubdomain
,
bool
save0N
=
false
,
bool
combine
=
true
,
bool
omit
=
true
,
bool
smoothen
=
true
);
bool
combine
=
true
,
bool
omit
=
true
,
bool
smoothen
=
true
);
~
Homology
();
~
Homology
();
...
...
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