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
22class ModelGenerator;
23class IntFunc;
24
25namespace LR { struct RefineData; }
26
27
37class SIMinput : public SIMbase
38{
39public:
41 struct ICInfo
42 {
45 char basis;
46 char component;
47 std::string sim_field;
48 std::string file_basis;
49 std::string file_field;
50 std::string function;
51
53 ICInfo() : file_level(-1), geo_level(0), basis(1), component(0) {}
55 explicit ICInfo(const std::string& f) : file_level(-1), geo_level(0),
56 basis(1), component(0),
57 sim_field(f), file_field(f) {}
58 };
59 typedef std::vector<ICInfo> InitialCondVec;
60 typedef std::vector<unsigned char> CharVec;
61 typedef std::pair<int,Vec3> IdxVec3;
62
63protected:
65 explicit SIMinput(IntegrandBase* itg);
66
67public:
69 virtual ~SIMinput() {}
70
72 virtual const char** getPrioritizedTags() const;
73
76 bool readTopologyOnly(const std::string& fileName);
77
85 int getUniquePropertyCode(const std::string& setName, int comp = 0);
86
92 size_t setVecProperty(int code, Property::Type ptype,
93 VecFunc* field = nullptr, int pflag = -1);
94
99 bool setTracProperty(int code, Property::Type ptype,
100 TractionFunc* field = nullptr);
101
102private:
104 bool parseGeometryTag(const tinyxml2::XMLElement* elem);
106 bool parseBCTag(const tinyxml2::XMLElement* elem);
108 bool parseICTag(const tinyxml2::XMLElement* elem);
110 bool parseLinSolTag(const tinyxml2::XMLElement* elem);
111
112protected:
116 virtual bool parse(char* keyWord, std::istream& is);
117
120 virtual bool parse(const tinyxml2::XMLElement* elem);
121
123 virtual bool parseGeometryDimTag(const tinyxml2::XMLElement* elem) = 0;
125 bool parsePeriodic(const tinyxml2::XMLElement* elem);
127 virtual bool parseOutputTag(const tinyxml2::XMLElement* elem);
129 FunctionBase* parseDualTag(const tinyxml2::XMLElement* elem, int ftype = 1);
134 int parseMaterialSet(const tinyxml2::XMLElement* elem, int mindex);
138 bool parseTopologySet(const tinyxml2::XMLElement* elem,
139 std::vector<int>& patches) const;
143 bool parsePatchList(const tinyxml2::XMLElement* elem,
144 std::vector<int>& patches) const;
145
147 virtual IntFunc* parseElemActivator(const std::string&,
148 const std::string&) const;
149
153 bool createPropertySet(const std::string& setName, int pc);
154
155public:
161 size_t setPropertyType(int code, Property::Type ptype, int pindex = -1,
162 char basis = 1);
163
169 bool setNeumann(const std::string& prop, const std::string& type,
170 int ndir, int code);
171
175 std::vector<int> getFunctionsForElements(const std::vector<int>& elements);
176
179 bool refine(const LR::RefineData& prm);
183 bool refine(const LR::RefineData& prm, Vector& sol);
187 bool refine(const LR::RefineData& prm, Vectors& sol);
188
194 int refine(const RealFunc& refC, double refTol);
195
199 bool readPatches(std::istream& isp, const char* whiteSpace = "");
200
209 bool addConnection(int mst, int slv, int mIdx, int sIdx,
210 bool coordCheck = false, int dim = 1, int thick = 1)
211 {
212 return this->connectPatches(ASM::Interface{mst,slv,mIdx,sIdx,0,dim,0,thick},
213 coordCheck);
214 }
215
217 const std::vector<ASM::Interface>& getInterfaces() const
218 { return myInterfaces; }
219
220protected:
224 static std::istream* getPatchStream(const char* tag, const char* patch);
225
231 virtual ASMbase* readPatch(std::istream& isp, int pchInd,
232 const CharVec& unf = CharVec(),
233 const char* whiteSpace = "") const = 0;
234
241 virtual bool readNodes(std::istream& isn, int pchInd, int basis = 0,
242 bool oneBased = false) { return false; }
245 virtual void readNodes(std::istream& isn) {}
246
249 virtual ModelGenerator* getModelGenerator(const tinyxml2::XMLElement* geo) const = 0;
250
254 virtual bool connectPatches(const ASM::Interface& ifc, bool coordCheck) = 0;
255
256 typedef std::map<std::string,std::string> SerializeMap;
257
260 bool saveBasis(SerializeMap& data) const;
261
264 bool restoreBasis(const SerializeMap& data);
265
266public:
273 int restartBasis(const std::string& restartFile, int restartStep);
274
277 virtual bool createFEMmodel(char resetNumb = 'y');
278
280 virtual void clonePatches(const PatchVec&, const std::map<int,int>&) {}
281
283 virtual bool hasIC(const std::string& name) const;
284
288 bool setInitialConditions(SIMdependency* fieldHolder = nullptr);
289
291 virtual bool deSerialize(const SerializeMap&);
292
294 const TopEntity& getEntity(const std::string& name) const;
296 TopEntity& topology(const std::string& name) { return myEntitys[name]; }
298 const TopologySet& getTopology() const { return myEntitys; }
299
301 bool getTopItemNodes(const TopItem& titem, std::vector<int>& glbNodes) const;
302
304 IdxVec3* getDiscretePoint(int idx);
305
307 virtual std::vector<std::vector<int>> getElmConnectivities() const;
308
309private:
314 bool setInitialCondition(SIMdependency* fieldHolder,
315 const std::string& fileName,
316 const InitialCondVec& info);
317
318protected:
320
322
323 std::vector<IdxVec3> myTopPts;
324
325 std::vector<ASM::Interface> myInterfaces;
326
327 std::map<std::string,InitialCondVec> myICs;
328
329private:
331 bool isSaved;
332};
333
334#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:72
Base class for unary spatial functions of arbitrary result type.
Definition Function.h:147
A real-valued integer function.
Definition Functions.h:617
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:38
bool parseBCTag(const tinyxml2::XMLElement *elem)
Parses a subelement of the boundaryconditions XML-tag.
Definition SIMinput.C:410
std::vector< unsigned char > CharVec
Convenience declaration.
Definition SIMinput.h:60
const TopologySet & getTopology() const
Returns the whole topology set container (for testing only).
Definition SIMinput.h:298
bool saveBasis(SerializeMap &data) const
Writes current basis to a serialization container.
Definition SIMinput.C:1842
bool setInitialConditions(SIMdependency *fieldHolder=nullptr)
Sets the initial conditions.
Definition SIMinput.C:1802
std::vector< IdxVec3 > myTopPts
Discrete points not belonging to any patch.
Definition SIMinput.h:323
bool readTopologyOnly(const std::string &fileName)
Reads patch topology from the specified input file.
Definition SIMinput.C:1075
virtual void readNodes(std::istream &isn)
Reads node numbers from given input stream.
Definition SIMinput.h:245
virtual bool parse(char *keyWord, std::istream &is)
Parses a data section from an input stream.
Definition SIMinput.C:1103
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:241
virtual std::vector< std::vector< int > > getElmConnectivities() const
Returns the element-to-element connectivities.
Definition SIMinput.C:1943
bool restoreBasis(const SerializeMap &data)
Restores the basis from a serialization container.
Definition SIMinput.C:1861
virtual ASMbase * readPatch(std::istream &isp, int pchInd, const CharVec &unf=CharVec(), const char *whiteSpace="") const =0
Reads a patch from given input stream.
bool parsePatchList(const tinyxml2::XMLElement *elem, std::vector< int > &patches) const
Parses a list of patch indices from an XML-tag.
Definition SIMinput.C:1036
size_t setPropertyType(int code, Property::Type ptype, int pindex=-1, char basis=1)
Defines the type of a property set.
Definition SIMinput.C:1438
int getUniquePropertyCode(const std::string &setName, int comp=0)
Returns a unique integer code for a Property set.
Definition SIMinput.C:1383
bool parseTopologySet(const tinyxml2::XMLElement *elem, std::vector< int > &patches) const
Parses the "set" attribute of a refine/raiseorder XML-tag.
Definition SIMinput.C:1006
FunctionBase * parseDualTag(const tinyxml2::XMLElement *elem, int ftype=1)
Parses the dualfield tag.
Definition SIMinput.C:788
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:1351
virtual bool parseOutputTag(const tinyxml2::XMLElement *elem)
Parses a subelement of the resultoutput XML-tag.
Definition SIMinput.C:738
size_t setVecProperty(int code, Property::Type ptype, VecFunc *field=nullptr, int pflag=-1)
Defines a vector field property.
Definition SIMinput.C:1494
std::vector< ASM::Interface > myInterfaces
Topology interface descriptions.
Definition SIMinput.h:325
bool parseLinSolTag(const tinyxml2::XMLElement *elem)
Parses a subelement of the linearsolver XML-tag.
Definition SIMinput.C:723
bool getTopItemNodes(const TopItem &titem, std::vector< int > &glbNodes) const
Returns the node numbers associated with a topological item.
Definition SIMinput.C:1993
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:1510
bool setTracProperty(int code, Property::Type ptype, TractionFunc *field=nullptr)
Defines a traction field property.
Definition SIMinput.C:1502
bool createPropertySet(const std::string &setName, int pc)
Creates a set of Property objects.
Definition SIMinput.C:1402
ModelGenerator * myGen
Model generator.
Definition SIMinput.h:319
virtual void clonePatches(const PatchVec &, const std::map< int, int > &)
Creates the computational FEM model by copying the given patches.
Definition SIMinput.h:280
const std::vector< ASM::Interface > & getInterfaces() const
Obtain a const reference to model topology.
Definition SIMinput.h:217
virtual const char ** getPrioritizedTags() const
Returns a list of prioritized XML-tags.
Definition SIMinput.C:1060
virtual IntFunc * parseElemActivator(const std::string &, const std::string &) const
Parses an element activation function.
Definition SIMinput.C:1096
virtual ModelGenerator * getModelGenerator(const tinyxml2::XMLElement *geo) const =0
Instantiates a FEM model generator.
int restartBasis(const std::string &restartFile, int restartStep)
Handles application restarts by reading a serialized basis.
Definition SIMinput.C:1892
bool parseICTag(const tinyxml2::XMLElement *elem)
Parses the initialconditions XML-tag.
Definition SIMinput.C:664
std::map< std::string, std::string > SerializeMap
Convenience type.
Definition SIMinput.h:256
bool isSaved
If true, the basis has been serialized.
Definition SIMinput.h:331
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:1542
const TopEntity & getEntity(const std::string &name) const
Returns reference to a named topology entity.
Definition SIMinput.C:1977
std::map< std::string, InitialCondVec > myICs
Initial condition definitions.
Definition SIMinput.h:327
virtual ~SIMinput()
Empty destructor.
Definition SIMinput.h:69
IdxVec3 * getDiscretePoint(int idx)
Returns pointer to an indexed discrete point.
Definition SIMinput.C:1987
bool refine(const LR::RefineData &prm)
Refines the mesh adaptively.
Definition SIMinput.C:1596
virtual bool deSerialize(const SerializeMap &)
Deserialization support (for simulation restart).
Definition SIMinput.C:1934
bool setInitialCondition(SIMdependency *fieldHolder, const std::string &fileName, const InitialCondVec &info)
Sets initial conditions from a file.
Definition SIMinput.C:1735
bool parseGeometryTag(const tinyxml2::XMLElement *elem)
Parses a subelement of the geometry XML-tag.
Definition SIMinput.C:92
virtual bool connectPatches(const ASM::Interface &ifc, bool coordCheck)=0
Connects two patches.
virtual bool hasIC(const std::string &name) const
Checks whether a named initial condition is present.
Definition SIMinput.C:1831
bool parsePeriodic(const tinyxml2::XMLElement *elem)
Parses the periodic XML-tag.
Definition SIMinput.C:377
int parseMaterialSet(const tinyxml2::XMLElement *elem, int mindex)
Parses the "set" attribute of a material XML-tag.
Definition SIMinput.C:989
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:61
TopEntity & topology(const std::string &name)
Returns access to a named topology entity (for model generators).
Definition SIMinput.h:296
std::vector< ICInfo > InitialCondVec
Convenience declaration.
Definition SIMinput.h:59
TopologySet myEntitys
Set of named topological entities.
Definition SIMinput.h:321
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:209
bool isReading
If true, we are reading multiple patch tags.
Definition SIMinput.h:330
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:24
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:42
std::string file_basis
Basis for field on file.
Definition SIMinput.h:48
ICInfo()
Default constructor.
Definition SIMinput.h:53
int geo_level
The time level for the (adapted) geometry in the file.
Definition SIMinput.h:44
char component
Component for field (for functions)
Definition SIMinput.h:46
char basis
The basis to inject field into (for mixed)
Definition SIMinput.h:45
std::string sim_field
The name of the field in the SIM class.
Definition SIMinput.h:47
std::string file_field
The field name in the file or type of function.
Definition SIMinput.h:49
ICInfo(const std::string &f)
Constructor providing the field name.
Definition SIMinput.h:55
std::string function
Function expression if given in function form.
Definition SIMinput.h:50
int file_level
The time level for the field in the file.
Definition SIMinput.h:43
Struct for representing a topological item.
Definition TopologySet.h:29