IFEM  90A354
SIMinput.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef _SIM_INPUT_H
15 #define _SIM_INPUT_H
16 
17 #include "SIMbase.h"
18 #include "TopologySet.h"
19 #include "Interface.h"
20 #include "Vec3.h"
21 
22 class ModelGenerator;
23 
24 namespace LR { struct RefineData; }
25 
26 
36 class SIMinput : public SIMbase
37 {
38 public:
40  struct ICInfo
41  {
42  int file_level;
43  int geo_level;
44  char basis;
45  char component;
46  std::string sim_field;
47  std::string file_basis;
48  std::string file_field;
49  std::string function;
50 
52  ICInfo() : file_level(-1), geo_level(0), basis(1), component(0) {}
54  explicit ICInfo(const std::string& f) : file_level(-1), geo_level(0),
55  basis(1), component(0),
56  sim_field(f), file_field(f) {}
57  };
58  typedef std::vector<ICInfo> InitialCondVec;
59  typedef std::vector<unsigned char> CharVec;
60  typedef std::pair<int,Vec3> IdxVec3;
61 
62 protected:
64  explicit SIMinput(IntegrandBase* itg);
65 
66 public:
68  virtual ~SIMinput() {}
69 
71  virtual const char** getPrioritizedTags() const;
72 
75  bool readTopologyOnly(const std::string& fileName);
76 
84  int getUniquePropertyCode(const std::string& setName, int comp = 0);
85 
91  size_t setVecProperty(int code, Property::Type ptype,
92  VecFunc* field = nullptr, int pflag = -1);
93 
98  bool setTracProperty(int code, Property::Type ptype,
99  TractionFunc* field = nullptr);
100 
101 private:
103  bool parseGeometryTag(const tinyxml2::XMLElement* elem);
105  bool parseBCTag(const tinyxml2::XMLElement* elem);
107  bool parseICTag(const tinyxml2::XMLElement* elem);
109  bool parseLinSolTag(const tinyxml2::XMLElement* elem);
110 
111 protected:
115  virtual bool parse(char* keyWord, std::istream& is);
116 
119  virtual bool parse(const tinyxml2::XMLElement* elem);
120 
122  virtual bool parseGeometryDimTag(const tinyxml2::XMLElement* elem) = 0;
124  bool parsePeriodic(const tinyxml2::XMLElement* elem);
126  virtual bool parseOutputTag(const tinyxml2::XMLElement* elem);
128  FunctionBase* parseDualTag(const tinyxml2::XMLElement* elem, int ftype = 1);
133  int parseMaterialSet(const tinyxml2::XMLElement* elem, int mindex);
137  bool parseTopologySet(const tinyxml2::XMLElement* elem,
138  std::vector<int>& patches) const;
142  bool parsePatchList(const tinyxml2::XMLElement* elem,
143  std::vector<int>& patches) const;
144 
148  bool createPropertySet(const std::string& setName, int pc);
149 
150 public:
156  size_t setPropertyType(int code, Property::Type ptype, int pindex = -1,
157  char basis = 1);
158 
164  bool setNeumann(const std::string& prop, const std::string& type,
165  int ndir, int code);
166 
170  std::vector<int> getFunctionsForElements(const std::vector<int>& elements);
171 
174  bool refine(const LR::RefineData& prm);
178  bool refine(const LR::RefineData& prm, Vector& sol);
182  bool refine(const LR::RefineData& prm, Vectors& sol);
183 
189  int refine(const RealFunc& refC, double refTol);
190 
194  bool readPatches(std::istream& isp, const char* whiteSpace = "");
195 
204  bool addConnection(int mst, int slv, int mIdx, int sIdx,
205  bool coordCheck = false, int dim = 1, int thick = 1)
206  {
207  return this->connectPatches(ASM::Interface{mst,slv,mIdx,sIdx,0,dim,0,thick},
208  coordCheck);
209  }
210 
212  const std::vector<ASM::Interface>& getInterfaces() const
213  { return myInterfaces; }
214 
215 protected:
219  static std::istream* getPatchStream(const char* tag, const char* patch);
220 
226  virtual ASMbase* readPatch(std::istream& isp, int pchInd,
227  const CharVec& unf = CharVec(),
228  const char* whiteSpace = "") const = 0;
229 
236  virtual bool readNodes(std::istream& isn, int pchInd, int basis = 0,
237  bool oneBased = false) { return false; }
240  virtual void readNodes(std::istream& isn) {}
241 
244  virtual ModelGenerator* getModelGenerator(const tinyxml2::XMLElement* geo) const = 0;
245 
249  virtual bool connectPatches(const ASM::Interface& ifc, bool coordCheck) = 0;
250 
251  typedef std::map<std::string,std::string> SerializeMap;
252 
255  bool saveBasis(SerializeMap& data) const;
256 
259  bool restoreBasis(const SerializeMap& data);
260 
261 public:
268  int restartBasis(const std::string& restartFile, int restartStep);
269 
272  virtual bool createFEMmodel(char resetNumb = 'y');
273 
275  virtual void clonePatches(const PatchVec&, const std::map<int,int>&) {}
276 
278  virtual bool hasIC(const std::string& name) const;
279 
283  bool setInitialConditions(SIMdependency* fieldHolder = nullptr);
284 
286  virtual bool deSerialize(const SerializeMap&);
287 
289  const TopEntity& getEntity(const std::string& name) const;
291  TopEntity& topology(const std::string& name) { return myEntitys[name]; }
293  const TopologySet& getTopology() const { return myEntitys; }
294 
296  bool getTopItemNodes(const TopItem& titem, std::vector<int>& glbNodes) const;
297 
299  IdxVec3* getDiscretePoint(int idx);
300 
302  virtual std::vector<std::vector<int>> getElmConnectivities() const;
303 
304 private:
309  bool setInitialCondition(SIMdependency* fieldHolder,
310  const std::string& fileName,
311  const InitialCondVec& info);
312 
313 protected:
315 
317 
318  std::vector<IdxVec3> myTopPts;
319 
320  std::vector<ASM::Interface> myInterfaces;
321 
322  std::map<std::string,InitialCondVec> myICs;
323 
324 private:
325  bool isReading;
326  bool isSaved;
327 };
328 
329 #endif
Representation of domain interfaces.
std::vector< Vector > Vectors
An array of real-valued vectors with algebraic operations.
Definition: MatVec.h:37
Base class for NURBS-based FEM simulators.
Representation of topological entities.
std::map< std::string, TopEntity > TopologySet
Named topology sets.
Definition: TopologySet.h:65
std::set< TopItem > TopEntity
Items defining a topological entity.
Definition: TopologySet.h:63
Representation of a point in 3D space with some basic operations.
Base class for spline-based finite element (FE) assembly drivers.
Definition: ASMbase.h:70
Base class for unary spatial functions of arbitrary result type.
Definition: Function.h:147
Base class representing a system level integrated quantity.
Definition: IntegrandBase.h:42
Base class for model generators for FEM simulators.
Definition: ModelGenerator.h:29
Scalar-valued unary function of a spatial point.
Definition: Function.h:193
Base class for NURBS-based FEM simulators.
Definition: SIMbase.h:72
Class administering inter-SIM field dependencies.
Definition: SIMdependency.h:30
std::vector< ASMbase * > PatchVec
Spline patch container.
Definition: SIMdependency.h:33
Sub-class with functionality for model input and setup.
Definition: SIMinput.h:37
bool parseBCTag(const tinyxml2::XMLElement *elem)
Parses a subelement of the boundaryconditions XML-tag.
Definition: SIMinput.C:419
std::vector< unsigned char > CharVec
Convenience declaration.
Definition: SIMinput.h:59
bool saveBasis(SerializeMap &data) const
Writes current basis to a serialization container.
Definition: SIMinput.C:1830
bool setInitialConditions(SIMdependency *fieldHolder=nullptr)
Sets the initial conditions.
Definition: SIMinput.C:1790
std::vector< IdxVec3 > myTopPts
Discrete points not belonging to any patch.
Definition: SIMinput.h:318
bool readTopologyOnly(const std::string &fileName)
Reads patch topology from the specified input file.
Definition: SIMinput.C:1064
TopEntity & topology(const std::string &name)
Returns access to a named topology entity (for model generators).
Definition: SIMinput.h:291
const TopologySet & getTopology() const
Returns the whole topology set container (for testing only).
Definition: SIMinput.h:293
virtual void readNodes(std::istream &isn)
Reads node numbers from given input stream.
Definition: SIMinput.h:240
virtual bool parse(char *keyWord, std::istream &is)
Parses a data section from an input stream.
Definition: SIMinput.C:1081
virtual bool readNodes(std::istream &isn, int pchInd, int basis=0, bool oneBased=false)
Reads global node data for a patch from given input stream.
Definition: SIMinput.h:236
virtual std::vector< std::vector< int > > getElmConnectivities() const
Returns the element-to-element connectivities.
Definition: SIMinput.C:1931
bool restoreBasis(const SerializeMap &data)
Restores the basis from a serialization container.
Definition: SIMinput.C:1849
bool parsePatchList(const tinyxml2::XMLElement *elem, std::vector< int > &patches) const
Parses a list of patch indices from an XML-tag.
Definition: SIMinput.C:1025
size_t setPropertyType(int code, Property::Type ptype, int pindex=-1, char basis=1)
Defines the type of a property set.
Definition: SIMinput.C:1419
int getUniquePropertyCode(const std::string &setName, int comp=0)
Returns a unique integer code for a Property set.
Definition: SIMinput.C:1363
bool parseTopologySet(const tinyxml2::XMLElement *elem, std::vector< int > &patches) const
Parses the "set" attribute of a refine/raiseorder XML-tag.
Definition: SIMinput.C:995
FunctionBase * parseDualTag(const tinyxml2::XMLElement *elem, int ftype=1)
Parses the dualfield tag.
Definition: SIMinput.C:777
bool readPatches(std::istream &isp, const char *whiteSpace="")
Reads patches from given input stream.
Definition: SIMinput.C:67
virtual bool parseGeometryDimTag(const tinyxml2::XMLElement *elem)=0
Parses a dimension-specific subelement of the geometry XML-tag.
virtual bool createFEMmodel(char resetNumb='y')
Creates the computational FEM model from the spline patches.
Definition: SIMinput.C:1330
virtual bool parseOutputTag(const tinyxml2::XMLElement *elem)
Parses a subelement of the resultoutput XML-tag.
Definition: SIMinput.C:727
size_t setVecProperty(int code, Property::Type ptype, VecFunc *field=nullptr, int pflag=-1)
Defines a vector field property.
Definition: SIMinput.C:1475
std::vector< ASM::Interface > myInterfaces
Topology interface descriptions.
Definition: SIMinput.h:320
bool parseLinSolTag(const tinyxml2::XMLElement *elem)
Parses a subelement of the linearsolver XML-tag.
Definition: SIMinput.C:712
bool getTopItemNodes(const TopItem &titem, std::vector< int > &glbNodes) const
Returns the node numbers associated with a topological item.
Definition: SIMinput.C:1981
virtual ModelGenerator * getModelGenerator(const tinyxml2::XMLElement *geo) const =0
Instantiates a FEM model generator.
bool setNeumann(const std::string &prop, const std::string &type, int ndir, int code)
Defines a Neumann boundary condition property by parsing a string.
Definition: SIMinput.C:1491
bool setTracProperty(int code, Property::Type ptype, TractionFunc *field=nullptr)
Defines a traction field property.
Definition: SIMinput.C:1483
bool createPropertySet(const std::string &setName, int pc)
Creates a set of Property objects.
Definition: SIMinput.C:1382
ModelGenerator * myGen
Model generator.
Definition: SIMinput.h:314
virtual void clonePatches(const PatchVec &, const std::map< int, int > &)
Creates the computational FEM model by copying the given patches.
Definition: SIMinput.h:275
virtual const char ** getPrioritizedTags() const
Returns a list of prioritized XML-tags.
Definition: SIMinput.C:1049
int restartBasis(const std::string &restartFile, int restartStep)
Handles application restarts by reading a serialized basis.
Definition: SIMinput.C:1880
bool parseICTag(const tinyxml2::XMLElement *elem)
Parses the initialconditions XML-tag.
Definition: SIMinput.C:653
const std::vector< ASM::Interface > & getInterfaces() const
Obtain a const reference to model topology.
Definition: SIMinput.h:212
std::map< std::string, std::string > SerializeMap
Convenience type.
Definition: SIMinput.h:251
bool isSaved
If true, the basis has been serialized.
Definition: SIMinput.h:326
std::vector< int > getFunctionsForElements(const std::vector< int > &elements)
Finds the set of basis functions with support on a set of elements.
Definition: SIMinput.C:1523
const TopEntity & getEntity(const std::string &name) const
Returns reference to a named topology entity.
Definition: SIMinput.C:1965
SIMinput(IntegrandBase *itg)
The constructor just forwards to the base class constructor.
Definition: SIMinput.C:39
std::map< std::string, InitialCondVec > myICs
Initial condition definitions.
Definition: SIMinput.h:322
virtual ~SIMinput()
Empty destructor.
Definition: SIMinput.h:68
IdxVec3 * getDiscretePoint(int idx)
Returns pointer to an indexed discrete point.
Definition: SIMinput.C:1975
bool refine(const LR::RefineData &prm)
Refines the mesh adaptively.
Definition: SIMinput.C:1580
virtual bool deSerialize(const SerializeMap &)
Deserialization support (for simulation restart).
Definition: SIMinput.C:1922
bool setInitialCondition(SIMdependency *fieldHolder, const std::string &fileName, const InitialCondVec &info)
Sets initial conditions from a file.
Definition: SIMinput.C:1723
bool parseGeometryTag(const tinyxml2::XMLElement *elem)
Parses a subelement of the geometry XML-tag.
Definition: SIMinput.C:95
virtual bool connectPatches(const ASM::Interface &ifc, bool coordCheck)=0
Connects two patches.
virtual ASMbase * readPatch(std::istream &isp, int pchInd, const CharVec &unf=CharVec(), const char *whiteSpace="") const =0
Reads a patch from given input stream.
virtual bool hasIC(const std::string &name) const
Checks whether a named initial condition is present.
Definition: SIMinput.C:1819
bool parsePeriodic(const tinyxml2::XMLElement *elem)
Parses the periodic XML-tag.
Definition: SIMinput.C:385
int parseMaterialSet(const tinyxml2::XMLElement *elem, int mindex)
Parses the "set" attribute of a material XML-tag.
Definition: SIMinput.C:978
static std::istream * getPatchStream(const char *tag, const char *patch)
Helper method returning a stream for patch geometry input.
Definition: SIMinput.C:46
std::pair< int, Vec3 > IdxVec3
Convenience declaration.
Definition: SIMinput.h:60
std::vector< ICInfo > InitialCondVec
Convenience declaration.
Definition: SIMinput.h:58
TopologySet myEntitys
Set of named topological entities.
Definition: SIMinput.h:316
bool addConnection(int mst, int slv, int mIdx, int sIdx, bool coordCheck=false, int dim=1, int thick=1)
Connects two patches.
Definition: SIMinput.h:204
bool isReading
If true, we are reading multiple patch tags.
Definition: SIMinput.h:325
Vector-valued binary function of a spatial point and normal vector.
Definition: Function.h:292
Vector-valued unary function of a spatial point.
Definition: Function.h:242
A vector class with some added algebraic operations.
Definition: matrix.h:64
Utilities for LR-splines.
Definition: AdaptiveSetup.h:22
Struct for representing a domain interface.
Definition: Interface.h:24
A struct of data to control the mesh refinement.
Definition: ASMunstruct.h:44
Type
The available property types.
Definition: Property.h:32
Struct holding information about an initial condition.
Definition: SIMinput.h:41
std::string file_basis
Basis for field on file.
Definition: SIMinput.h:47
ICInfo()
Default constructor.
Definition: SIMinput.h:52
int geo_level
The time level for the (adapted) geometry in the file.
Definition: SIMinput.h:43
char component
Component for field (for functions)
Definition: SIMinput.h:45
char basis
The basis to inject field into (for mixed)
Definition: SIMinput.h:44
std::string sim_field
The name of the field in the SIM class.
Definition: SIMinput.h:46
std::string file_field
The field name in the file or type of function.
Definition: SIMinput.h:48
ICInfo(const std::string &f)
Constructor providing the field name.
Definition: SIMinput.h:54
int file_level
The time level for the field in the file.
Definition: SIMinput.h:42
Struct for representing a topological item.
Definition: TopologySet.h:29