Skip to content

Commit

Permalink
ENH: Expose anisotropic interface with simple hardcoded size_scale an…
Browse files Browse the repository at this point in the history
…d size_frame
  • Loading branch information
zhang-alvin committed Aug 9, 2017
1 parent 283ca0a commit b6ea6dd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
4 changes: 3 additions & 1 deletion proteus/MeshAdaptPUMI/MeshFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ int MeshAdaptPUMIDrvr::transferFieldToPUMI(const char* name, double const* inArr
assert(f);
}
if (!f) {
assert(nVar == 1 || nVar == 3);
assert(nVar == 1 || nVar == 3 || nVar == 9);
int valueType;
if (nVar == 1)
valueType = apf::SCALAR;
else if(nVar == 9)
valueType = apf::MATRIX;
else
valueType = apf::VECTOR;
f = apf::createFieldOn(m, name, valueType);
Expand Down
8 changes: 5 additions & 3 deletions proteus/MeshAdaptPUMI/cMeshAdaptPUMI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ int MeshAdaptPUMIDrvr::adaptPUMIMesh()
calculateSizeField();
else if (size_field_config == "isotropicProteus")
size_iso = m->findField("proteus_size");
else if (size_field_config == "anisotropicProteus"){
size_frame = m->findField("proteus_sizeFrame");
size_scale = m->findField("proteus_sizeScale");
adapt_type_config = "anisotropic";
}
else {
std::cerr << "unknown size field config " << size_field_config << '\n';
abort();
Expand Down Expand Up @@ -394,9 +399,6 @@ int MeshAdaptPUMIDrvr::adaptPUMIMesh()
ma::adapt(in);
double t2 = PCU_Time();

freeField(size_iso);
freeField(size_frame);
freeField(size_scale);
m->verify();
double mass_after = getTotalMass();
PCU_Add_Doubles(&mass_before,1);
Expand Down
22 changes: 22 additions & 0 deletions proteus/NumericalSolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ def __init__(self,so,pList,nList,sList,opts,simFlagsList=None):
try:
if (nList[0].MeshAdaptMesh.size_field_config() == 'isotropicProteus'):
mlMesh.meshList[0].subdomainMesh.size_field = numpy.ones((mlMesh.meshList[0].subdomainMesh.nNodes_global,1),'d')*1.0e-1
if (nList[0].MeshAdaptMesh.size_field_config() == 'anisotropicProteus'):
mlMesh.meshList[0].subdomainMesh.size_scale = numpy.ones((mlMesh.meshList[0].subdomainMesh.nNodes_global,3),'d')
mlMesh.meshList[0].subdomainMesh.size_frame = numpy.ones((mlMesh.meshList[0].subdomainMesh.nNodes_global,9),'d')
except:
pass
Profiling.memory("Mesh")
Expand Down Expand Up @@ -720,6 +723,10 @@ def PUMI2Proteus(self,mesh):
self.mlMesh_nList.append(mlMesh)
if (p0.domain.PUMIMesh.size_field_config() == "isotropicProteus"):
mlMesh.meshList[0].subdomainMesh.size_field = numpy.ones((mlMesh.meshList[0].subdomainMesh.nNodes_global,1),'d')*1.0e-1
if (p0.domain.PUMIMesh.size_field_config() == 'anisotropicProteus'):
mlMesh.meshList[0].subdomainMesh.size_scale = numpy.ones((mlMesh.meshList[0].subdomainMesh.nNodes_global,3),'d')
mlMesh.meshList[0].subdomainMesh.size_frame = numpy.ones((mlMesh.meshList[0].subdomainMesh.nNodes_global,9),'d')

#may want to trigger garbage collection here
modelListOld = self.modelList
logEvent("Allocating models on new mesh")
Expand Down Expand Up @@ -940,6 +947,21 @@ def PUMI_estimateError(self):
if (p0.domain.PUMIMesh.size_field_config() == "isotropicProteus"):
p0.domain.PUMIMesh.transferFieldToPUMI("proteus_size",
self.modelList[0].levelModelList[0].mesh.size_field)
if (p0.domain.PUMIMesh.size_field_config() == 'anisotropicProteus'):
#Insert a function to define the size_scale/size_frame fields here.
#For a given vertex, the i-th size_scale is roughly the desired edge length along the i-th direction specified by the size_frame
for i in range(len(self.modelList[0].levelModelList[0].mesh.size_scale)):
self.modelList[0].levelModelList[0].mesh.size_scale[i,0] = 1e-1
self.modelList[0].levelModelList[0].mesh.size_scale[i,1] = (self.modelList[0].levelModelList[0].mesh.nodeArray[i,1]/0.584)*1e-1
for j in range(3):
for k in range(3):
if(j==k):
self.modelList[0].levelModelList[0].mesh.size_frame[i,3*j+k] = 1.0
else:
self.modelList[0].levelModelList[0].mesh.size_frame[i,3*j+k] = 0.0
self.modelList[0].levelModelList[0].mesh.size_scale
p0.domain.PUMIMesh.transferFieldToPUMI("proteus_sizeScale", self.modelList[0].levelModelList[0].mesh.size_scale)
p0.domain.PUMIMesh.transferFieldToPUMI("proteus_sizeFrame", self.modelList[0].levelModelList[0].mesh.size_frame)
p0.domain.PUMIMesh.transferFieldToPUMI("coordinates",
self.modelList[0].levelModelList[0].mesh.nodeArray)
logEvent("Copying DOF and parameters to PUMI")
Expand Down

0 comments on commit b6ea6dd

Please sign in to comment.