41 mfem_error(
"UniformKnotVector: ncp should be at least order + 1");
45 for (
int i = 0; i < order+1; i++)
49 for (
int i = order+1; i < ncp; i++)
51 (*kv)[i] = (i-order)/
real_t(ncp-order);
53 for (
int i = ncp ; i < ncp + order + 1; i++)
60int main(
int argc,
char *argv[])
69 bool ifbspline =
true;
70 bool visualization =
true;
73 args.
AddOption(&l,
"-l",
"--box-side-length",
74 "Height and width of the box");
76 "Amplitude of the fitted sine function.");
78 "Number of control points used over four box sides.");
80 "Order of the NURBSPatch");
81 args.
AddOption(&ifbspline,
"-uw",
"--unit-weight",
"-nw",
83 "Use a unit-weight for B-splines (default) or not: for general NURBS");
84 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
86 "Enable or disable GLVis visualization. This is a dummy option to enable testing.");
87 args.
AddOption(&visit,
"-visit",
"--visit",
"-no-visit",
"--no-visit",
88 "Enable or disable VisIt visualization.");
99 if (order < 2 && ifbspline ==
false)
101 mfem_error(
"For a non unity weight, the order should be at least 2.");
111 for (
int j = 0; j < 2; j++)
112 for (
int i = 0; i < 2; i++)
118 patch(0,0,0) = -0.5*l;
119 patch(0,0,1) = -0.5*l;
121 patch(1,0,0) = 0.5*l;
122 patch(1,0,1) = -0.5*l;
124 patch(0,1,0) = -0.5*l;
125 patch(0,1,1) = 0.5*l;
127 patch(1,1,0) = 0.5*l;
128 patch(1,1,1) = 0.5*l;
144 patch(1,0,2) = sqrt(2)/2;
157 for (
int i = 0; i < ncp; i++)
159 (*xy[0])[i] = u_args[i]*l;
160 (*xy[1])[i] =
a * sin((*xy[0])[i]/l*2*M_PI)-0.5*l;
161 (*xy[0])[i] -= 0.5*l;
167 for (
int i = 0; i < ncp; i++)
169 patch(i,0,0) = (*xy[0])[i];
170 patch(i,0,1) = (*xy[1])[i];
177 for (
int i = 0; i < ncp; i++)
179 patch(i,0,0) *= patch(i,0,2);
180 patch(i,0,1) *= patch(i,0,2);
189 string mesh_file(
"sin-fit.mesh");
190 ofstream output(mesh_file.c_str());
192 output<<
"MFEM NURBS mesh v1.0"<<endl;
193 output<< endl <<
"# Square nurbs mesh with a sine fitted at its bottom edge" <<
195 output<<
"dimension"<<endl;
199 output<<
"elements"<<endl;
201 output<<
"1 3 0 1 2 3"<<endl;
204 output<<
"boundary"<<endl;
208 output <<
"edges" <<endl;
209 output <<
"4" <<endl;
210 output <<
"0 0 1"<<endl;
211 output <<
"0 3 2"<<endl;
212 output <<
"1 0 3"<<endl;
213 output <<
"1 1 2"<<endl;
216 output <<
"vertices" << endl;
219 output<<
"patches"<<endl;
222 output <<
"# Patch 1 " << endl;
227 cout <<
"=========================================================="<< endl;
228 cout <<
" Attempting to read mesh: " <<mesh_file.c_str()<< endl ;
229 cout <<
"=========================================================="<< endl;
230 Mesh *mesh =
new Mesh(mesh_file.c_str(), 1, 1);
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
void SetTime(real_t t)
Set physical time (for time-dependent simulations)
void SetPrefixPath(const std::string &prefix)
Set the path where the DataCollection will be saved.
void FindMaxima(Array< int > &ks, Vector &xi, Vector &u) const
void FindInterpolant(Array< Vector * > &x)
virtual void PrintInfo(std::ostream &os=mfem::out)
In serial, this method calls PrintCharacteristics(). In parallel, additional information about the pa...
void KnotInsert(int dir, const KnotVector &knot)
Insert knots from knot determined by Difference, in direction dir.
void Print(std::ostream &os) const
void DegreeElevate(int dir, int t)
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
Data collection with VisIt I/O routines.
virtual void Save() override
Save the collection and a VisIt root file.
void mfem_error(const char *msg)
KnotVector * UniformKnotVector(int order, int ncp)