83 #include "../common/mfem-common.hpp"
90 const double sine = 0.25 * std::sin(4 * M_PI * x(0)) +
91 0.05 * std::sin(16 * M_PI * x(0));
92 return (x(1) >= sine + 0.5) ? -1.0 : 1.0;
100 const double xc = x(0) - 0.5, yc = x(1) - 0.5;
101 const double r = sqrt(xc*xc + yc*yc);
102 return (r >= 0.4) ? -1.0 : 1.0;
106 const double xc = x(0) - 0.0, yc = x(1) - 0.0, zc = x(2) - 0.0;
107 const double r = sqrt(xc*xc + yc*yc + zc*zc);
108 return (r >= 0.8) ? -1.0 : 1.0;
112 return (x(0) >= 0.5) ? -1.0 : 1.0;
118 const double period = 2.0 * M_PI;
119 double x=xx[0]*period;
120 double y=xx[1]*period;
126 return std::sin(x)*std::cos(y) +
127 std::sin(y)*std::cos(z) +
128 std::sin(z)*std::cos(x);
136 for (
int i=0; i<xx.
Size(); i++)
141 return lvec[0]*lvec[0]+lvec[1]*lvec[1]+lvec[2]*lvec[2]-R*R;
153 for (
int i=0; i<xx.
Size(); i++)
158 vals[0]=cos(lvec[0])*cos(lvec[1])-sin(lvec[2])*sin(lvec[0]);
159 vals[1]=-sin(lvec[0])*sin(lvec[1])+cos(lvec[1])*cos(lvec[2]);
162 vals[2]=-sin(lvec[1])*sin(lvec[2])+cos(lvec[2])*cos(lvec[0]);
168 int main(
int argc,
char *argv[])
172 MPI_Init(&argc, &argv);
173 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
174 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
177 const char *mesh_file =
"../../data/inline-quad.mesh";
182 double t_param = 1.0;
183 const char *device_config =
"cpu";
184 bool visualization =
true;
187 args.
AddOption(&mesh_file,
"-m",
"--mesh",
188 "Mesh file to use.");
189 args.
AddOption(&solver_type,
"-s",
"--solver",
193 args.
AddOption(&problem,
"-p",
"--problem",
195 "0: Point source\n\t"
196 "1: Circle / sphere level set in 2D / 3D\n\t"
197 "2: 2D sine-looking level set\n\t"
198 "3: Gyroid level set in 2D or 3D");
199 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
200 "Number of times to refine the mesh uniformly in serial.");
202 "Finite element order (polynomial degree) or -1 for"
203 " isoparametric space.");
204 args.
AddOption(&t_param,
"-t",
"--t-param",
205 "Diffusion time step (scaled internally scaled by dx*dx).");
206 args.
AddOption(&device_config,
"-d",
"--device",
207 "Device configuration string, see Device::Configure().");
208 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
209 "--no-visualization",
210 "Enable or disable GLVis visualization.");
225 Device device(device_config);
226 if (myid == 0) { device.
Print(); }
229 Mesh mesh(mesh_file, 1, 1);
234 ParMesh pmesh(MPI_COMM_WORLD, mesh);
244 else if (problem == 1)
249 else if (problem == 2)
262 if (solver_type == 0)
267 ds->transform =
false;
269 ds->smooth_steps = smooth_steps;
270 ds->vis_glvis =
false;
273 else if (solver_type == 1)
276 const int newton_iter = 50;
280 else { MFEM_ABORT(
"Wrong solver option."); }
293 filter->
Filter(*ls_coeff, filt_gf);
312 "Input Level Set", 0, 0, size, size);
318 "Distance", size, 0, size, size,
325 "Directions", 2*size, 0, size, size,
326 "rRjmm********vveA");
339 const double d_norm = distance_s.ComputeL2Error(zero);
342 cout << fixed << setprecision(10) <<
"Norm: " << d_norm << std::endl;
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
A coefficient that is constant across space and time.
void SetSize(int s)
Resize the vector to size s.
Helper class for ParaView visualization data.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Delta function coefficient optionally multiplied by a weight coefficient and a scaled time dependent ...
int Size() const
Returns the size of the vector.
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
Abstract parallel finite element space.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
double sine_ls(const Vector &x)
double Sph(const mfem::Vector &xx)
double sphere_ls(const Vector &x)
void VisualizeField(socketstream &sock, const char *vishost, int visport, ParGridFunction &gf, const char *title, int x=0, int y=0, int w=400, int h=400, bool vec=false)
void PrintUsage(std::ostream &out) const
Print the usage message.
void SetTime(double t)
Set physical time (for time-dependent simulations)
double p(const Vector &x, double t)
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
virtual void ComputeVectorDistance(Coefficient &zero_level_set, ParGridFunction &distance)
void DGyroid(const mfem::Vector &xx, mfem::Vector &vals)
void PrintOptions(std::ostream &out) const
Print the options.
void SetLevelsOfDetail(int levels_of_detail_)
void Clear()
Clear the contents of the Mesh.
A general function coefficient.
Arbitrary order H1-conforming (continuous) finite elements.
virtual void Save() override
Class for parallel grid function.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
double Gyroid(const Vector &xx)
Class for parallel meshes.
void Filter(ParGridFunction &func, ParGridFunction &ffield)
double AvgElementSize(ParMesh &pmesh)
bool Good() const
Return true if the command line options were parsed successfully.
virtual void ComputeScalarDistance(Coefficient &zero_level_set, ParGridFunction &distance)=0