Skip to content

Commit

Permalink
Change to fit Amanzi Mesh Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienLoiseau committed Jul 19, 2023
1 parent 9130163 commit 5904c9b
Show file tree
Hide file tree
Showing 110 changed files with 1,245 additions and 1,373 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ EvaluatorColumnIntegrator<Parser, Integrator>::EnsureCompatibility_ToDeps_(State
my_keys_.front().second);
if (fac.Mesh() != Teuchos::null) {
CompositeVectorSpace dep_fac;
dep_fac.SetMesh(fac.Mesh()->parent())
dep_fac.SetMesh(fac.Mesh()->getParentMesh())
->SetGhosted(true)
->AddComponent("cell", AmanziMesh::CELL, 1);
->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1);

for (const auto& dep : dependencies_) {
if (Keys::getDomain(dep.first) == Keys::getDomain(my_keys_.front().first)) {
Expand Down Expand Up @@ -122,7 +122,7 @@ EvaluatorColumnIntegrator<Parser, Integrator>::Evaluate_(
deps.emplace_back(
S.Get<CompositeVector>(dep.first, dep.second).ViewComponent("cell", false).get());
}
auto mesh = result[0]->Mesh()->parent();
auto mesh = result[0]->Mesh()->getParentMesh();
Integrator integrator(plist_, deps, &*mesh);

Epetra_MultiVector& res = *result[0]->ViewComponent("cell", false);
Expand All @@ -131,7 +131,7 @@ EvaluatorColumnIntegrator<Parser, Integrator>::Evaluate_(
// for each column, loop over cells calling the integrator until stop is
// requested or the column is complete
AmanziGeometry::Point val(0., 0.);
auto& col_cell = mesh->cells_of_column(col);
auto col_cell = mesh->columns.getCells(col);
for (int i = 0; i != col_cell.size(); ++i) {
bool completed = integrator.scan(col, col_cell[i], val);
if (completed) break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ IntegratorActiveLayerAverageTemp::scan(AmanziMesh::Entity_ID col,
AmanziGeometry::Point& p)
{
if ((*temp_)[0][c] >= trans_temp_) {
double cv = mesh_->cell_volume(c);
double cv = mesh_->getCellVolume(c);
p[0] += (*temp_)[0][c] * cv;
p[1] += cv;
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ExtractionEvaluator::Evaluate_(const State& S, const std::vector<CompositeVector

for (int j = 0; j != result_c.NumVectors(); ++j) {
for (int i = 0; i != result_c.MyLength(); ++i) {
result_c[j][i] = parent_vector_c[j][mesh->entity_get_parent(entity, i)];
result_c[j][i] = parent_vector_c[j][mesh->getEntityParent(entity, i)];
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ SubgridAggregateEvaluator::Evaluate_(const State& S, const std::vector<Composite
S.Get<CompositeVector>(dep->first, dep->second).ViewComponent("cell", false).get());
++dep;
}
ds->DoImport(sources, result_v);
ds->doImport(sources, result_v);
}

void
Expand All @@ -65,7 +65,7 @@ SubgridAggregateEvaluator::EnsureEvaluators(State& S)
if (dependencies_.size() == 0) {
auto ds = S.GetDomainSet(source_domain_);
Tag dep_tag = Keys::readTag(plist_, my_keys_.front().second);
if (ds->get_referencing_parent() == Teuchos::null) {
if (ds->getReferencingParent() == Teuchos::null) {
Errors::Message msg;
msg << "SubgridAggregateEvaluator: DomainSet \"" << source_domain_
<< "\" does not have a referencing parent but must have one to aggregate.";
Expand All @@ -92,8 +92,8 @@ SubgridAggregateEvaluator::EnsureCompatibility_Structure_(State& S)
if (dep_fac.HasComponent("cell")) {
S.Require<CompositeVector, CompositeVectorSpace>(my_keys_.front().first,
my_keys_.front().second)
.SetMesh(ds->get_referencing_parent())
->AddComponent("cell", AmanziMesh::CELL, dep_fac.NumVectors("cell"));
.SetMesh(ds->getReferencingParent())
->AddComponent("cell", AmanziMesh::Entity_kind::CELL, dep_fac.NumVectors("cell"));
}

if (S.GetRecordSet(dependencies_.front().first).subfieldnames()) {
Expand All @@ -116,7 +116,7 @@ SubgridAggregateEvaluator::EnsureCompatibility_ToDeps_(State& S)
"cell",
},
{
AmanziMesh::CELL,
AmanziMesh::Entity_kind::CELL,
},
{
num_vectors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SubgridDisaggregateEvaluator::Evaluate_(const State& S, const std::vector<Compos
{
auto tag = my_keys_.front().second;
auto ds = S.GetDomainSet(domain_set_);
ds->DoExport(domain_index_,
ds->doExport(domain_index_,
*S.Get<CompositeVector>(source_key_, tag).ViewComponent("cell", false),
*result[0]->ViewComponent("cell", false));
}
Expand All @@ -64,7 +64,7 @@ SubgridDisaggregateEvaluator::EnsureCompatibility_ToDeps_(State& S)
if (my_fac.HasComponent("cell")) {
int num_vectors = my_fac.NumVectors("cell");
CompositeVectorSpace fac;
fac.SetMesh(S.GetMesh(source_domain_))->AddComponent("cell", AmanziMesh::CELL, num_vectors);
fac.SetMesh(S.GetMesh(source_domain_))->AddComponent("cell", AmanziMesh::Entity_kind::CELL, num_vectors);
EvaluatorSecondaryMonotypeCV::EnsureCompatibility_ToDeps_(S, fac);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,21 @@ OverlandSourceFromSubsurfaceFluxEvaluator::IdentifyFaceAndDirection_(const State
Teuchos::RCP<const AmanziMesh::Mesh> surface = S.GetMesh(domain_surf_);

// allocate space for face IDs and directions
int ncells = surface->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED);
int ncells = surface->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED);
face_and_dirs_ = Teuchos::rcp(new std::vector<FaceDir>(ncells));

for (int c = 0; c != ncells; ++c) {
// Get the face on the subsurface mesh corresponding to the cell
// of the surface mesh.
AmanziMesh::Entity_ID domain_face = surface->entity_get_parent(AmanziMesh::CELL, c);
AmanziMesh::Entity_ID domain_face = surface->getEntityParent(AmanziMesh::Entity_kind::CELL, c);

// Get the direction corresponding to that face wrt its only cell.
// -- get the cell
AmanziMesh::Entity_ID_List cells;
subsurface->face_get_cells(domain_face, AmanziMesh::Parallel_type::OWNED, &cells);
auto cells = subsurface->getFaceCells(domain_face, AmanziMesh::Parallel_kind::OWNED);
AMANZI_ASSERT(cells.size() == 1);

// -- Get directions
AmanziMesh::Entity_ID_List faces;
std::vector<int> fdirs;
subsurface->cell_get_faces_and_dirs(cells[0], &faces, &fdirs);
const auto& [faces, fdirs] = subsurface->getCellFacesAndDirections(cells[0]);
int index = std::find(faces.begin(), faces.end(), domain_face) - faces.begin();

// Put (face,dir) into cached data.
Expand All @@ -121,9 +118,8 @@ OverlandSourceFromSubsurfaceFluxEvaluator::Evaluate_(const State& S,

int ncells = result[0]->size("cell", false);
for (int c = 0; c != ncells; ++c) {
AmanziMesh::Entity_ID_List cells;
subsurface->face_get_cells(
(*face_and_dirs_)[c].first, AmanziMesh::Parallel_type::OWNED, &cells);
auto cells = subsurface->getFaceCells(
(*face_and_dirs_)[c].first, AmanziMesh::Parallel_kind::OWNED);
AMANZI_ASSERT(cells.size() == 1);

res_v[0][c] =
Expand All @@ -132,9 +128,8 @@ OverlandSourceFromSubsurfaceFluxEvaluator::Evaluate_(const State& S,
} else {
int ncells = result[0]->size("cell", false);
for (int c = 0; c != ncells; ++c) {
AmanziMesh::Entity_ID_List cells;
subsurface->face_get_cells(
(*face_and_dirs_)[c].first, AmanziMesh::Parallel_type::OWNED, &cells);
auto cells = subsurface->getFaceCells(
(*face_and_dirs_)[c].first, AmanziMesh::Parallel_kind::OWNED);
AMANZI_ASSERT(cells.size() == 1);

res_v[0][c] = flux[0][(*face_and_dirs_)[c].first] * (*face_and_dirs_)[c].second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ SurfaceTopCellsEvaluator::Evaluate_(const State& S, const std::vector<CompositeV


int ncells_surf =
result[0]->Mesh()->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED);
result[0]->Mesh()->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED);
for (unsigned int c = 0; c != ncells_surf; ++c) {
// get the face on the subsurface mesh
AmanziMesh::Entity_ID f = result[0]->Mesh()->entity_get_parent(AmanziMesh::CELL, c);
AmanziMesh::Entity_ID f = result[0]->Mesh()->getEntityParent(AmanziMesh::Entity_kind::CELL, c);

// get the cell interior to the face
AmanziMesh::Entity_ID_List cells;
sub_vector->Mesh()->face_get_cells(f, AmanziMesh::Parallel_type::ALL, &cells);
auto cells = sub_vector->Mesh()->getFaceCells(f, AmanziMesh::Parallel_kind::ALL);
AMANZI_ASSERT(cells.size() == 1);

result_cells[0][c] = sub_vector_cells[0][cells[0]];
Expand All @@ -70,7 +69,7 @@ SurfaceTopCellsEvaluator::EnsureCompatibility_ToDeps_(State& S)
auto domain_name = Keys::getDomain(my_keys_.front().first);

CompositeVectorSpace fac;
fac.SetMesh(S.GetMesh(domain_name)->parent())->AddComponent("cell", AmanziMesh::CELL, 1);
fac.SetMesh(S.GetMesh(domain_name)->getParentMesh())->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1);
EvaluatorSecondaryMonotypeCV::EnsureCompatibility_ToDeps_(S, fac);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ TopCellsSurfaceEvaluator::Evaluate_(const State& S, const std::vector<CompositeV
Epetra_MultiVector& result_cells = *result[0]->ViewComponent("cell", false);

int ncells_surf =
surf_vector->Mesh()->num_entities(AmanziMesh::CELL, AmanziMesh::Parallel_type::OWNED);
surf_vector->Mesh()->getNumEntities(AmanziMesh::Entity_kind::CELL, AmanziMesh::Parallel_kind::OWNED);
for (unsigned int c = 0; c != ncells_surf; ++c) {
// get the face on the subsurface mesh
AmanziMesh::Entity_ID f = surf_vector->Mesh()->entity_get_parent(AmanziMesh::CELL, c);
AmanziMesh::Entity_ID f = surf_vector->Mesh()->getEntityParent(AmanziMesh::Entity_kind::CELL, c);

// get the cell interior to the face
AmanziMesh::Entity_ID_List cells;
result[0]->Mesh()->face_get_cells(f, AmanziMesh::Parallel_type::ALL, &cells);
auto cells = result[0]->Mesh()->getFaceCells(f, AmanziMesh::Parallel_kind::ALL);
AMANZI_ASSERT(cells.size() == 1);

result_cells[0][cells[0]] = surf_vector_cells[0][c];
Expand All @@ -68,7 +67,7 @@ void
TopCellsSurfaceEvaluator::EnsureCompatibility_ToDeps_(State& S)
{
CompositeVectorSpace fac;
fac.SetMesh(S.GetMesh(domain_surf_))->AddComponent("cell", AmanziMesh::CELL, 1);
fac.SetMesh(S.GetMesh(domain_surf_))->AddComponent("cell", AmanziMesh::Entity_kind::CELL, 1);
EvaluatorSecondaryMonotypeCV::EnsureCompatibility_ToDeps_(S, fac);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ Volumetric_FluxEvaluator::Evaluate_(const State& S, const std::vector<CompositeV
Epetra_MultiVector& res_v = *result[0]->ViewComponent("face", false);

const auto& mesh = *result[0]->Mesh();
int nfaces_owned = mesh.num_entities(AmanziMesh::FACE, AmanziMesh::Parallel_type::OWNED);
AmanziMesh::Entity_ID_List cells;
int nfaces_owned = mesh.getNumEntities(AmanziMesh::Entity_kind::FACE, AmanziMesh::Parallel_kind::OWNED);
for (int f = 0; f < nfaces_owned; f++) {
mesh.face_get_cells(f, AmanziMesh::Parallel_type::ALL, &cells);
auto cells = mesh.getFaceCells(f, AmanziMesh::Parallel_kind::ALL);
double n_liq = 0.;
for (int c = 0; c < cells.size(); c++) n_liq += molar_density[0][c];
n_liq /= cells.size();
Expand Down
1 change: 0 additions & 1 deletion src/executables/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ set(amanzi_link_libs
dbg
data_structures
mesh
mesh_audit
mesh_functions
functions
geometry
Expand Down

0 comments on commit 5904c9b

Please sign in to comment.