-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLSLocateGasInterface.cpp
More file actions
112 lines (92 loc) · 4.45 KB
/
LSLocateGasInterface.cpp
File metadata and controls
112 lines (92 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// ---------------------------------------------------------------------
//
// Copyright (c) 2019 - 2022 by the IBAMR developers
// All rights reserved.
//
//
// IBAMR is free software and is distributed under the 3-clause BSD
// license. The full text of the license can be found in the file
// COPYRIGHT at the top level directory of IBAMR.
//
// ---------------------------------------------------------------------
// Filename LSLocateGasInterface.cpp
// Created on Nov 15, 2017 by Nishant Nangia
#include <ibamr/app_namespaces.h>
#include <ibtk/HierarchyMathOps.h>
#include "LSLocateGasInterface.h"
#include <CartesianGridGeometry.h>
/////////////////////////////// STATIC ///////////////////////////////////////
void
callLSLocateGasInterfaceCallbackFunction(int D_idx,
Pointer<HierarchyMathOps> hier_math_ops,
double time,
bool initial_time,
void* ctx)
{
// Set the level set information
static LSLocateGasInterface* ptr_LSLocateGasInterface = static_cast<LSLocateGasInterface*>(ctx);
ptr_LSLocateGasInterface->setLevelSetPatchData(D_idx, hier_math_ops, time, initial_time);
return;
} // callLSLocateGasInterfaceCallbackFunction
/////////////////////////////// PUBLIC //////////////////////////////////////
LSLocateGasInterface::LSLocateGasInterface(const std::string& object_name,
Pointer<AdvDiffHierarchyIntegrator> adv_diff_solver,
Pointer<CellVariable<NDIM, double> > ls_var,
const double init_height)
: d_object_name(object_name), d_adv_diff_solver(adv_diff_solver), d_ls_var(ls_var), d_init_height(init_height)
{
// intentionally left blank
return;
} // LSLocateGasInterface
void
LSLocateGasInterface::setLevelSetPatchData(int D_idx,
Pointer<HierarchyMathOps> hier_math_ops,
double /*time*/,
bool initial_time)
{
Pointer<PatchHierarchy<NDIM> > patch_hierarchy = hier_math_ops->getPatchHierarchy();
const int coarsest_ln = 0;
const int finest_ln = patch_hierarchy->getFinestLevelNumber();
// If not the intial time, set the level set to the current value maintained by the integrator
if (!initial_time)
{
VariableDatabase<NDIM>* var_db = VariableDatabase<NDIM>::getDatabase();
const int ls_current_idx =
var_db->mapVariableAndContextToIndex(d_ls_var, d_adv_diff_solver->getCurrentContext());
HierarchyCellDataOpsReal<NDIM, double> hier_cc_data_ops(patch_hierarchy, coarsest_ln, finest_ln);
hier_cc_data_ops.copyData(D_idx, ls_current_idx);
return;
}
// Set the initial condition for locating the interface
const double H = d_init_height;
for (int ln = coarsest_ln; ln <= finest_ln; ++ln)
{
Pointer<PatchLevel<NDIM> > level = patch_hierarchy->getPatchLevel(ln);
for (PatchLevel<NDIM>::Iterator p(level); p; p++)
{
Pointer<Patch<NDIM> > patch = level->getPatch(p());
const Box<NDIM>& patch_box = patch->getBox();
Pointer<CellData<NDIM, double> > D_data = patch->getPatchData(D_idx);
for (Box<NDIM>::Iterator it(patch_box); it; it++)
{
CellIndex<NDIM> ci(it());
// Get physical coordinates
IBTK::Vector coord = IBTK::Vector::Zero();
Pointer<CartesianPatchGeometry<NDIM> > patch_geom = patch->getPatchGeometry();
const double* patch_X_lower = patch_geom->getXLower();
const hier::Index<NDIM>& patch_lower_idx = patch_box.lower();
const double* const patch_dx = patch_geom->getDx();
for (int d = 0; d < NDIM; ++d)
{
coord[d] = patch_X_lower[d] + patch_dx[d] * (static_cast<double>(ci(d) - patch_lower_idx(d)) + 0.5);
}
const double distance = NDIM < 3 ? coord[1] - H : coord[2] - H;
// Initialize the locator data to be zero on the interface,
// negative inside, and positive outside
(*D_data)(ci) = -distance;
}
}
}
return;
} // setLevelSetPatchData
/////////////////////////////// PRIVATE //////////////////////////////////////