Skip to content

Commit 51d8d1d

Browse files
Nightly Botcwsmith
Nightly Bot
authored andcommitted
Merging develop into master
2 parents 9afeb19 + 313f5f3 commit 51d8d1d

19 files changed

+485
-64
lines changed

Diff for: apf_sim/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ set(USE_FIELDSIM FALSE)
2727
if( ${SIMMODSUITE_SimField_FOUND} AND ENABLE_FIELDSIM )
2828
set(USE_FIELDSIM TRUE)
2929
endif()
30+
set(USE_SIM_ADVMESHING ${HAVE_SIMADVMESHING})
31+
3032
configure_file(
3133
"${CMAKE_CURRENT_SOURCE_DIR}/apf_simConfig.h.in"
3234
"${CMAKE_CURRENT_BINARY_DIR}/apf_simConfig.h")

Diff for: apf_sim/apfSIM.cc

+2
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,8 @@ void MeshSIM::writeNative(const char* fileName)
896896

897897
void MeshSIM::destroyNative()
898898
{
899+
while(this->countFields())
900+
apf::destroyField(this->getField(0));
899901
M_release(mesh);
900902
}
901903

Diff for: apf_sim/apfSIMDataOf.h

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class SIMDataOf : public FieldDataOf<T>
2020
fd = fd_in;
2121
pf = static_cast<pPolyField>(Field_def(fd));
2222
}
23+
~SIMDataOf()
24+
{
25+
Field_release(fd);
26+
FieldDef_delete(pf);
27+
}
2328
virtual void init(FieldBase * f)
2429
{
2530
FieldData::field = f;

Diff for: apf_sim/apf_simConfig.h.in

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
#cmakedefine USE_FIELDSIM
2+
#cmakedefine USE_SIM_ADVMESHING

Diff for: gmi_sim/gmi_sim.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,22 @@ static gmi_set* edge_regions(pGEdge e)
193193
pPList list = GE_faces((pGEdge)e);
194194

195195
std::set<pGRegion> rgns;
196-
gmi_set* regions_set;
197196
for (int i = 0; i < PList_size(list); i++) {
198-
regions_set = face_regions((pGFace)PList_item(list, i));
197+
gmi_set* regions_set = face_regions((pGFace)PList_item(list, i));
199198
for (int j = 0; j < regions_set->n; j++) {
200199
rgns.insert( (pGRegion) regions_set->e[j] );
201200
}
201+
gmi_free_set(regions_set);
202202
}
203+
PList_delete(list);
203204

204205
int count = 0;
205206
gmi_set* s = gmi_make_set(rgns.size());
206207
for (std::set<pGRegion>::iterator it=rgns.begin(); it!=rgns.end(); ++it) {
207208
s->e[count] = (gmi_ent*)*it;
208209
count++;
209210
}
211+
rgns.clear();
210212

211213
return s;
212214
}

Diff for: phasta/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ if(ENABLE_SIMMETRIX)
4343
phAttrib.cc
4444
phSnap.cc
4545
phMeshQuality.cc
46+
phRigidBody.cc
4647
)
4748
endif()
4849

@@ -62,6 +63,8 @@ set(HEADERS
6263
phstream.h
6364
phiotimer.h
6465
phastaChef.h
66+
phBC.h
67+
ph.h
6568
)
6669

6770
# Add the ph library

Diff for: phasta/phGeomBC.cc

+1
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ void writeGeomBC(Output& o, std::string path, int timestep)
335335
params[1] = 3;
336336
ph_write_ints(f, "m2g classification", o.arrays.m2gClsfcn,
337337
params[0] * params[1], 2, params);
338+
params[0] = m->count(0);
338339
params[1] = 2;
339340
ph_write_doubles(f, "m2g parametric coordinate", o.arrays.m2gParCoord,
340341
params[0] * params[1], 2, params);

Diff for: phasta/phGrowthCurves.cc

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ void getGrowthCurves(Output& o)
7373
break;
7474
}
7575
}
76+
VIter_delete(vIter);
7677

7778
if(isBoundaryLayerFace){
7879
// Add gFace to gEntities
@@ -104,6 +105,7 @@ void getGrowthCurves(Output& o)
104105
}
105106
}
106107
}
108+
GFIter_delete(gFIter);
107109

108110
// get seeds of all growth curves
109111
pPList allSeeds = PList_new();
@@ -175,6 +177,7 @@ void getGrowthCurves(Output& o)
175177
//Append seeds to allSeeds
176178
PList_appPList(allSeeds,seeds);
177179
}
180+
VIter_delete(vIter);
178181
}
179182

180183
// get info of growth curves

Diff for: phasta/phInput.cc

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ static void setDefaults(Input& in)
7979
in.betaSize = 2e-5;
8080
in.gammaDist = 3e-6;
8181
in.gammaSize = 3e-5;
82+
in.nRigidBody = 0;
83+
in.nRBParam = 12;
8284
}
8385

8486
Input::Input()
@@ -157,6 +159,8 @@ static void formMaps(Input& in, StringMap& stringMap, IntMap& intMap, DblMap& db
157159
dblMap["betaSize"] = &in.betaSize;
158160
dblMap["gammaDist"] = &in.gammaDist;
159161
dblMap["gammaSize"] = &in.gammaSize;
162+
intMap["nRigidBody"] = &in.nRigidBody;
163+
intMap["nRBParam"] = &in.nRBParam;
160164
}
161165

162166
template <class T>

Diff for: phasta/phInput.h

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
#include <string>
14+
#include <vector>
1415

1516
struct RStream;
1617

@@ -170,6 +171,12 @@ class Input
170171
double gammaDist;
171172
/** \brief absolute isotropic size within [betaDist:gammDist) of zero level set */
172173
double gammaSize;
174+
/** \brief number of rigid bodies */
175+
int nRigidBody;
176+
/** \brief number of parameters for each rigid body */
177+
int nRBParam;
178+
/** \brief parameter data for rigid body */
179+
std::vector<double> rbParamData;
173180
};
174181

175182
int countNaturalBCs(Input& in);

Diff for: phasta/phMeshQuality.cc

+133-21
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,61 @@
88
#include <apfMatrix.h>
99
#include <maSize.h>
1010
#include <maShape.h>
11+
//#include "apf_simConfig.h"
12+
13+
#ifdef HAVE_SIMMETRIX
1114
#include <SimUtil.h>
1215
#include <SimModel.h>
1316
#include <SimPartitionedMesh.h>
1417
#include <SimMeshTools.h>
18+
//#ifdef HAVE_SIMADVMESHING
19+
#include <SimAdvMeshing.h>
20+
//#endif
21+
#endif
1522

23+
#include <PCU.h>
1624
#include <pcu_util.h>
1725
#include <cstdio>
1826

1927
namespace ph {
2028

29+
static void initArray(double array[3][3]) {
30+
for(int i = 0; i < 3; i++) {
31+
for(int j = 0; j < 3; j++) {
32+
array[i][j] = 0.0;
33+
}
34+
}
35+
}
36+
2137
void attachSIMSizeField(apf::Mesh2* m, apf::Field* sf_mag, apf::Field* sf_dir) {
2238
// loop over all vertices
2339
double size[1];
2440
double anisosize[3][3];
2541
apf::MeshEntity* v;
2642
apf::MeshIterator* vit = m->begin(0);
2743
while ((v = m->iterate(vit))) {
44+
#ifdef HAVE_SIMMETRIX
2845
// get sim size field
2946
// this is for simmetrix mesh, should be generalized
30-
pVertex meshVertex = reinterpret_cast<pVertex>(v);
31-
int sztype = V_size(meshVertex, size, anisosize);
32-
PCU_ALWAYS_ASSERT(sztype == 1 || sztype == 2);
33-
34-
// consider iso size field as anisotropic size field
35-
if (sztype == 1) {
36-
for(int i = 0; i < 3; i++) {
37-
for(int j = 0; j < 3; j++) {
38-
if (i==j)
39-
anisosize[i][j] = size[0];
40-
else
41-
anisosize[i][j] = 0.0;
42-
}
47+
{
48+
pVertex meshVertex = reinterpret_cast<pVertex>(v);
49+
int sztype = V_size(meshVertex, size, anisosize);
50+
PCU_ALWAYS_ASSERT(sztype == 1 || sztype == 2);
51+
52+
// consider iso size field as anisotropic size field
53+
if (sztype == 1) {
54+
initArray(anisosize);
55+
anisosize[0][0] = size[0];
56+
anisosize[1][1] = size[0];
57+
anisosize[2][2] = size[0];
4358
}
4459
}
60+
#else
61+
{
62+
PCU_ALWAYS_ASSERT_VERBOSE(0,
63+
"please turn on Simmetrix and re-compile the code.\n");
64+
}
65+
#endif
4566

4667
// transfer to apf field sf_mag and sf_dir
4768
/* note that the frame in Simmetrix is stored by row
@@ -76,14 +97,22 @@ extern"C"{
7697
/* input x1,x2,x3 are current coordinates of mesh in phasta
7798
output minq is the minimum quality of mesh */
7899
void core_measure_mesh (double x1[], double x2[], double x3[], int numnp,
79-
double& minq) {
100+
double& minvq, double& minfq) {
101+
double** op = (double**)malloc(sizeof(double*) * numnp);
102+
for (int i = 0; i < numnp; i++)
103+
op[i] = (double*)malloc(sizeof(double) * 3);
80104
// loop over all vertices
81105
int counter = 0;
106+
apf::Vector3 p;
82107
apf::MeshEntity* v;
83108
apf::MeshIterator* vit = m->begin(0);
84109
while ((v = m->iterate(vit))) {
110+
// get original mesh coordinates
111+
m->getPoint(v, 0, p);
112+
op[counter][0] = p[0];
113+
op[counter][1] = p[1];
114+
op[counter][2] = p[2];
85115
// update the coordinates of current mesh
86-
apf::Vector3 p;
87116
p[0] = x1[counter];
88117
p[1] = x2[counter];
89118
p[2] = x3[counter];
@@ -96,24 +125,107 @@ void core_measure_mesh (double x1[], double x2[], double x3[], int numnp,
96125
// transfer to apf sizefield
97126
if(m->findField("sizes")) apf::destroyField(m->findField("sizes"));
98127
if(m->findField("frames")) apf::destroyField(m->findField("frames"));
99-
// this is for simmetrix mesh, should be generalized
100128
apf::Field* sf_mag = apf::createSIMFieldOn(m, "sizes", apf::VECTOR);
101129
apf::Field* sf_dir = apf::createSIMFieldOn(m, "frames", apf::MATRIX);
130+
// this is for simmetrix mesh, should be generalized
131+
PCU_ALWAYS_ASSERT_VERBOSE(in.simmetrixMesh, "core_measure_mesh only supports Simmetrix mesh!\n");
102132
ph::attachSIMSizeField(m, sf_mag, sf_dir);
103133
ma::SizeField* sf = ma::makeSizeField(m, sf_mag, sf_dir);
104134

105-
// measure
106-
minq = 1.0;
135+
// measure mesh region
136+
minvq = 1.0;
107137
apf::MeshEntity* e;
108138
apf::MeshIterator* eit = m->begin(m->getDimension());
109139
while( (e = m->iterate(eit)) ) {
110140
if (! m->isOwned(e))
111141
continue;
112-
double q = ma::measureElementQuality(m, sf, e);
113-
if (q < minq)
114-
minq = q;
142+
/* not support other mesh region type */
143+
if (m->getType(e) != apf::Mesh::TET)
144+
continue;
145+
#ifdef HAVE_SIMMETRIX
146+
if (EN_isBLEntity(reinterpret_cast<pEntity>(e)))
147+
continue;
148+
#endif
149+
double vq = ma::measureElementQuality(m, sf, e); // cubic mean ratio
150+
vq = cbrt(vq); // mean ratio
151+
if (vq < minvq)
152+
minvq = vq;
115153
}
116154
m->end(eit);
155+
156+
// measure mesh face in layered mesh
157+
minfq = 1.0;
158+
#ifdef HAVE_SIMMETRIX
159+
if (in.simmetrixMesh == 1) {
160+
// get simmetrix mesh
161+
apf::MeshSIM* apf_msim = dynamic_cast<apf::MeshSIM*>(m);
162+
pParMesh pmesh = apf_msim->getMesh();
163+
pMesh mesh = PM_mesh(pmesh,0);
164+
165+
// get simmetrix model
166+
gmi_model* gmiModel = apf_msim->getModel();
167+
pGModel model = gmi_export_sim(gmiModel);
168+
169+
// measure triangles
170+
pGFace gFace;
171+
pFace meshFace;
172+
pEntity seedRegion;
173+
pPList growthRegion = PList_new();
174+
pPList growthLayerFace = PList_new();
175+
GFIter gFIter = GM_faceIter(model);
176+
while((gFace = GFIter_next(gFIter))){
177+
FIter fIter = M_classifiedFaceIter(mesh, gFace, 1);
178+
while((meshFace = FIter_next(fIter))){
179+
if(BL_isBaseEntity(meshFace,gFace) == 1){
180+
for (int fromSide = 0; fromSide < 2; fromSide++) {
181+
int hasSeed = BL_stackSeedEntity(meshFace,gFace,fromSide,NULL,&seedRegion);
182+
PCU_ALWAYS_ASSERT_VERBOSE(hasSeed >= 0, "BL blending is not supported!\n");
183+
if (hasSeed == 0)
184+
continue;
185+
PCU_ALWAYS_ASSERT(BL_growthRegionsAndLayerFaces
186+
((pRegion)seedRegion,growthRegion,growthLayerFace,Layer_Entity) == 1);
187+
for (int iglf = 0; iglf < PList_size(growthLayerFace); iglf++) {
188+
pFace blFace = (pFace)PList_item(growthLayerFace, iglf);
189+
double fq = ma::measureElementQuality(m, sf, reinterpret_cast<apf::MeshEntity*> (blFace)); // squared mean ratio
190+
fq = (fq > 0) ? sqrt(fq) : -sqrt(-fq); // mean ratio
191+
if (fq < minfq)
192+
minfq = fq;
193+
}
194+
PList_clear(growthRegion);
195+
PList_clear(growthLayerFace);
196+
}
197+
}
198+
}
199+
FIter_delete(fIter);
200+
}
201+
GFIter_delete(gFIter);
202+
PList_delete(growthRegion);
203+
PList_delete(growthLayerFace);
204+
}
205+
else
206+
#endif
207+
{
208+
printf("PUMI-based mesh doesn't have BL info. minfq is set to be 1.0\n");
209+
}
210+
211+
// restore mesh
212+
counter = 0;
213+
vit = m->begin(0);
214+
while ((v = m->iterate(vit))) {
215+
// use the original coordinates
216+
p[0] = op[counter][0];
217+
p[1] = op[counter][1];
218+
p[2] = op[counter][2];
219+
m->setPoint(v, 0, p);
220+
counter++;
221+
}
222+
m->end(vit);
223+
PCU_ALWAYS_ASSERT(counter==numnp);
224+
225+
// free op
226+
for (int i = 0; i < numnp; i++)
227+
free(op[i]);
228+
free(op);
117229
}
118230

119231
#ifdef __cplusplus

0 commit comments

Comments
 (0)