86 #include "../common/mfem-common.hpp"
95 const double sine = 0.25 *
std::sin(4 * M_PI * x(0)) +
97 return (x(1) >= sine + 0.5) ? -1.0 : 1.0;
105 const double xc = x(0) - 0.5, yc = x(1) - 0.5;
106 const double r =
sqrt(xc*xc + yc*yc);
107 return (r >= 0.4) ? -1.0 : 1.0;
111 const double xc = x(0) - 0.0, yc = x(1) - 0.0, zc = x(2) - 0.0;
112 const double r =
sqrt(xc*xc + yc*yc + zc*zc);
113 return (r >= 0.8) ? -1.0 : 1.0;
117 return (x(0) >= 0.5) ? -1.0 : 1.0;
123 const double period = 2.0 * M_PI;
124 double x=xx[0]*period;
125 double y=xx[1]*period;
141 for (
int i=0; i<xx.
Size(); i++)
146 return lvec[0]*lvec[0]+lvec[1]*lvec[1]+lvec[2]*lvec[2]-R*R;
158 for (
int i=0; i<xx.
Size(); i++)
163 vals[0]=
cos(lvec[0])*
cos(lvec[1])-
sin(lvec[2])*
sin(lvec[0]);
164 vals[1]=-
sin(lvec[0])*
sin(lvec[1])+
cos(lvec[1])*
cos(lvec[2]);
167 vals[2]=-
sin(lvec[1])*
sin(lvec[2])+
cos(lvec[2])*
cos(lvec[0]);
173 int main(
int argc,
char *argv[])
176 Mpi::Init(argc, argv);
177 int myid = Mpi::WorldRank();
181 const char *mesh_file =
"../../data/inline-quad.mesh";
186 double t_param = 1.0;
187 const char *device_config =
"cpu";
188 bool visualization =
true;
191 args.
AddOption(&mesh_file,
"-m",
"--mesh",
192 "Mesh file to use.");
193 args.
AddOption(&solver_type,
"-s",
"--solver",
197 args.
AddOption(&problem,
"-p",
"--problem",
199 "0: Point source\n\t"
200 "1: Circle / sphere level set in 2D / 3D\n\t"
201 "2: 2D sine-looking level set\n\t"
202 "3: Gyroid level set in 2D or 3D\n\t"
203 "4: Combo of a doughnut and swiss cheese shapes in 3D.");
204 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
205 "Number of times to refine the mesh uniformly in serial.");
207 "Finite element order (polynomial degree) or -1 for"
208 " isoparametric space.");
209 args.
AddOption(&t_param,
"-t",
"--t-param",
210 "Diffusion time step (scaled internally scaled by dx*dx).");
211 args.
AddOption(&device_config,
"-d",
"--device",
212 "Device configuration string, see Device::Configure().");
213 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
214 "--no-visualization",
215 "Enable or disable GLVis visualization.");
229 Device device(device_config);
230 if (myid == 0) { device.
Print(); }
233 Mesh mesh(mesh_file, 1, 1);
238 ParMesh pmesh(MPI_COMM_WORLD, mesh);
248 else if (problem == 1)
253 else if (problem == 2)
258 else if (problem == 3)
263 else if (problem == 4)
268 else { MFEM_ABORT(
"Unrecognized -problem option."); }
272 if (solver_type == 0)
277 ds->transform =
false;
279 ds->smooth_steps = smooth_steps;
280 ds->vis_glvis =
false;
283 else if (solver_type == 1)
286 const int newton_iter = 50;
290 else { MFEM_ABORT(
"Wrong solver option."); }
303 filter.
Filter(*ls_coeff, filt_gf);
321 "Input Level Set", 0, 0, size, size);
327 "Distance", size, 0, size, size,
334 "Directions", 2*size, 0, size, size,
335 "rRjmm********vveA");
348 const double s_norm = distance_s.ComputeL2Error(zero),
352 cout << fixed << setprecision(10) <<
"Norms: "
353 << s_norm <<
" " << v_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)
FDualNumber< tbase > cos(const FDualNumber< tbase > &f)
cos([dual number])
double p(const Vector &x, double t)
FDualNumber< tbase > sin(const FDualNumber< tbase > &f)
sin([dual number])
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)
virtual double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL) const
FDualNumber< tbase > sqrt(const FDualNumber< tbase > &f)
sqrt([dual number])
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.
double doughnut_cheese(const Vector &coord)
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