17using namespace common;
25 const real_t xc = x(0) - 0.5, yc = x(1) - 0.5;
26 const real_t r = sqrt(xc*xc + yc*yc);
31 const real_t xc = x(0) - 0.5, yc = x(1) - 0.5, zc = x(2) - 0.5;
32 const real_t r = sqrt(xc*xc + yc*yc + zc*zc);
40 x_current -= x_center;
57 return (phi_t <= 0.0) ? 1.0 : -1.0;
62 real_t phi_p1 = (x(0)-h-
t/2) - k*x(1)*x(1);
63 real_t phi_p2 = (x(0)-h+
t/2) - k*x(1)*x(1);
64 return (phi_p1 <= 0.0 && phi_p2 >= 0.0) ? 1.0 : -1.0;
69 real_t dx = std::abs(x(0) - xc);
70 real_t dy = std::abs(x(1) - yc);
71 return (dx <= w/2 && dy <= h/2) ? 1.0 : -1.0;
87 real_t return_val = max(in_circle1_val, in_trapezium_val);
93 return_val = max(return_val, in_parabola_val);
96 return_val = max(return_val, in_rectangle_val);
99 return_val = max(return_val, in_rectangle_val2);
106 real_t dx = std::abs(x(0) - xc);
107 real_t dy = std::abs(x(1) - yc);
108 real_t dz = std::abs(x(2) - zc);
109 return (dx <= lx/2 && dy <= ly/2 && dz <= lz/2) ? 1.0 : -1.0;
115 Vector x_pipe_copy = x_pipe_center;
117 x_pipe_copy(pipedir-1) = 0.0;
120 if (dist < radius && xv > minv && xv < maxv)
124 else if (dist ==
radius || (xv == minv && dist <
radius) || (xv == maxv &&
135 return r1 + r2 - std::pow(r1*r1 + r2*r2, 0.5);
140 return r1 + r2 + std::pow(r1*r1 + r2*r2, 0.5);
156 real_t in_cube_val =
in_cube(x, xcc(0), xcc(1), xcc(2), cube_x, cube_y, cube_z);
161 real_t sphere_radius = 0.30;
163 real_t in_return_val = std::min(in_cube_val, in_sphere_val);
168 real_t xmin = 0.5-sphere_radius;
169 real_t xmax = 0.5+sphere_radius;
170 real_t pipe_radius = 0.075;
171 real_t in_pipe_x =
in_pipe(x, pipedir, x_pipe_center, pipe_radius, xmin, xmax);
173 in_return_val = std::min(in_return_val, -1*in_pipe_x);
176 in_pipe_x =
in_pipe(x, pipedir, x_pipe_center, pipe_radius, xmin, xmax);
177 in_return_val = std::min(in_return_val, -1*in_pipe_x);
180 in_pipe_x =
in_pipe(x, pipedir, x_pipe_center, pipe_radius, xmin, xmax);
181 in_return_val = std::min(in_return_val, -1*in_pipe_x);
183 return in_return_val;
190 for (
int i = 0; i < pmesh->
GetNBE(); i++)
198 for (
int j = 0; j < dofs.
Size(); j++)
200 for (
int d = 0; d <
dim; d++)
206 dof_xyz_compare = dof_xyz;
211 for (
int d = 0; d <
dim; d++)
213 if (std::abs(dof_xyz(d)-dof_xyz_compare(d)) < 1.e-10)
222 if (xyz_check[0] == dofs.
Size())
226 else if (xyz_check[1] == dofs.
Size())
237 if (xyz_check[0] == dofs.
Size())
241 else if (xyz_check[1] == dofs.
Size())
245 else if (xyz_check[2] == dofs.
Size())
264 for (
int e = 0; e < pmesh->
GetNE(); e++)
277 int diff_attr_count = 0;
281 bool bdr_element =
false;
282 element_attr[e] = attr1;
283 int target_attr = -1;
284 for (
int f = 0;
f < faces.
Size();
f++)
289 attr2 = elem1 == e ? (int)(mat(elem2)) : (int)(mat(elem1));
290 if (attr1 != attr2 && attr1 == attr_to_switch)
292 diff_attr_count += 1;
304 attr2 = (int)(dof_vals(0));
305 if (attr1 != attr2 && attr1 == attr_to_switch)
307 diff_attr_count += 1;
318 if (diff_attr_count == faces.
Size()-1 && !bdr_element)
320 element_attr[e] = target_attr;
323 for (
int e = 0; e < pmesh->
GetNE(); e++)
325 mat(e) = element_attr[e];
336 const int quad_order = 5,
356 for (
int iter = 0; iter < amr_iter; iter++)
359 for (
int e = 0; e < pmesh.
GetNE(); e++)
371 if (min_val < 0 && max_val >= 0)
373 el_to_refine(e) = 1.0;
378 for (
int inner_iter = 0; inner_iter < 2; inner_iter++)
383 for (
int e = 0; e < pmesh.
GetNE(); e++)
394 el_to_refine(e) = 1.0;
401 for (
int e = 0; e < el_to_refine.
Size(); e++)
403 if (el_to_refine(e) > 0.0)
405 el_to_refine_list.
Append(e);
409 int loc_count = el_to_refine_list.
Size();
410 int glob_count = loc_count;
411 MPI_Allreduce(&loc_count, &glob_count, 1, MPI_INT, MPI_SUM,
433 if (pgf_to_update != NULL)
435 for (
int i = 0; i < pgf_to_update->Size(); i++)
437 (*pgf_to_update)[i]->ParFESpace()->Update();
438 (*pgf_to_update)[i]->Update();
447 const int nDiffuse = 2,
448 const int pLapOrder = 5,
449 const int pLapNewton = 50)
469 filter.
Filter(ls_coeff, filt_gf);
int Size() const
Return the logical size of the array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
Data type dense matrix using column-major storage.
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
const FiniteElementCollection * FEColl() const
Mesh * GetMesh() const
Returns the mesh.
DofTransformation * GetBdrElementDofs(int bel, Array< int > &dofs) const
Returns indices of degrees of freedom for boundary element 'bel'. The returned indices are offsets in...
int DofToVDof(int dof, int vd, int ndofs=-1) const
Compute a single vdof corresponding to the index dof and the vector index vd.
A general function coefficient.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
void SetFromTrueVector()
Shortcut for calling SetFromTrueDofs() with GetTrueVector() as argument.
Arbitrary order H1-conforming (continuous) finite elements.
Class for an integration rule - an Array of IntegrationPoint.
Container class for integration rules.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
Arbitrary order "L2-conforming" discontinuous finite elements.
void GetFaceInfos(int Face, int *Inf1, int *Inf2) const
void GeneralRefinement(const Array< Refinement > &refinements, int nonconforming=-1, int nc_limit=0)
Geometry::Type GetElementGeometry(int i) const
const FiniteElementSpace * GetNodalFESpace() const
void SetAttribute(int i, int attr)
Set the attribute of element i.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void GetFaceElements(int Face, int *Elem1, int *Elem2) const
void GetElementFaces(int i, Array< int > &faces, Array< int > &ori) const
Return the indices and the orientations of all faces of element i.
int GetNBE() const
Returns number of boundary elements.
void GetElementEdges(int i, Array< int > &edges, Array< int > &cor) const
Return the indices and the orientations of all edges of element i.
void SetBdrAttribute(int i, int attr)
Set the attribute of boundary element i.
Abstract parallel finite element space.
void GetElementDofs(int i, Array< int > &dofs, DofTransformation &doftrans) const override
The same as GetElementDofs(), but with a user-allocated DofTransformation object. doftrans must be al...
void Update(bool want_transform=true) override
Class for parallel grid function.
void ExchangeFaceNbrData()
void ProjectDiscCoefficient(VectorCoefficient &coeff) override
Project a discontinuous vector coefficient as a grid function on a continuous finite element space....
ParFiniteElementSpace * ParFESpace() const
void ProjectCoefficient(Coefficient &coeff) override
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
void Update() override
Transform by the Space UpdateMatrix (e.g., on Mesh change).
void GetElementDofValues(int el, Vector &dof_vals) const override
Class for parallel meshes.
void SetAttributes() override
Determine the sets of unique attribute values in domain and boundary elements.
real_t Norml2() const
Returns the l2 norm of the vector.
real_t Max() const
Returns the maximal element of the vector.
int Size() const
Returns the size of the vector.
real_t Min() const
Returns the minimal element of the vector.
void Filter(ParGridFunction &func, ParGridFunction &ffield)
void ComputeScalarDistance(Coefficient &func, ParGridFunction &fdist)
real_t in_trapezium(const Vector &x, real_t a, real_t b, real_t l)
real_t reactor(const Vector &x)
real_t in_pipe(const Vector &x, int pipedir, Vector x_pipe_center, real_t radius, real_t minv, real_t maxv)
real_t in_cube(const Vector &x, real_t xc, real_t yc, real_t zc, real_t lx, real_t ly, real_t lz)
real_t in_circle(const Vector &x, const Vector &x_center, real_t radius)
real_t in_rectangle(const Vector &x, real_t xc, real_t yc, real_t w, real_t h)
real_t r_intersect(real_t r1, real_t r2)
real_t csg_cubecylsph(const Vector &x)
real_t r_remove(real_t r1, real_t r2)
void ModifyBoundaryAttributesForNodeMovement(ParMesh *pmesh, ParGridFunction &x)
void ModifyAttributeForMarkingDOFS(ParMesh *pmesh, ParGridFunction &mat, int attr_to_switch)
real_t in_parabola(const Vector &x, real_t h, real_t k, real_t t)
void OptimizeMeshWithAMRAroundZeroLevelSet(ParMesh &pmesh, FunctionCoefficient &ls_coeff, int amr_iter, ParGridFunction &distance_s, const int quad_order=5, Array< ParGridFunction * > *pgf_to_update=NULL)
void ComputeScalarDistanceFromLevelSet(ParMesh &pmesh, FunctionCoefficient &ls_coeff, ParGridFunction &distance_s, const int nDiffuse=2, const int pLapOrder=5, const int pLapNewton=50)
real_t circle_level_set(const Vector &x)
real_t r_union(real_t r1, real_t r2)
real_t AvgElementSize(ParMesh &pmesh)
void DiffuseField(ParGridFunction &field, int smooth_steps)
std::function< real_t(const Vector &)> f(real_t mass_coeff)