9 #ifndef _snl_fei_Constraint_hpp_
10 #define _snl_fei_Constraint_hpp_
12 #include <fei_macros.hpp>
13 #include <fei_fwd.hpp>
14 #include <fei_VectorSpace.hpp>
15 #include <snl_fei_RecordCollection.hpp>
22 template<
class RecordType>
26 Constraint(
int id=0,
bool isPenaltyConstr=
false);
38 int offsetIntoSlaveField,
39 const double* weights,
66 void setIsPenalty(
bool isPenaltyConstr) { isPenalty_ = isPenaltyConstr; }
86 RecordType
getSlave() {
return getRecordCollection()->getRecordWithLocalID(slave_); }
148 int offsetIntoSlaveField_;
150 std::vector<int> masters_;
151 std::vector<int> masterIDTypes_;
152 std::vector<snl_fei::RecordCollection*> masterRecordCollections_;
153 std::vector<int> masterFields_;
154 std::vector<double> masterWeights_;
161 #include <snl_fei_Constraint.hpp>
164 template<
class RecordType>
168 recordCollection_(NULL),
169 isPenalty_(isPenaltyConstr),
174 offsetIntoSlaveField_(0),
177 masterRecordCollections_(),
185 template<
class RecordType>
187 int constraintIDType,
189 bool isPenaltyConstr,
195 int offsetIntoSlaveField,
196 const double* weights,
200 idType_(constraintIDType),
201 recordCollection_(NULL),
202 isPenalty_(isPenaltyConstr),
207 offsetIntoSlaveField_(offsetIntoSlaveField),
210 masterRecordCollections_(),
221 int constraintIDType,
223 bool isPenaltyConstr,
229 int offsetIntoSlaveField,
230 const double* weights,
234 idType_(constraintIDType),
235 recordCollection_(NULL),
236 isPenalty_(isPenaltyConstr),
241 offsetIntoSlaveField_(offsetIntoSlaveField),
244 masterRecordCollections_(),
249 int weightsOffset = 0;
252 recordCollection_ = recordCollection;
253 for(
int i=0; i<numIDs; ++i) {
255 masterRecordCollections_.push_back(recordCollection);
257 vspace->
addDOFs(fieldIDs[i], idTypes[i], 1, &(IDs[i]));
258 int rec_local_id = recordCollection->getLocalID(IDs[i]);
259 fei::Record<int>* rec = recordCollection->getRecordWithLocalID(rec_local_id);
263 if (isSlave && i == offsetOfSlave) {
264 rec->hasSlaveDof(
true);
268 weightsOffset += fieldSize;
275 if (weights != NULL) {
276 for(
unsigned j=0; j<fieldSize; ++j) {
277 masterWeights_.push_back(weights[weightsOffset++]);
287 template<
class RecordType>
296 offsetIntoSlaveField_(0),
299 masterRecordCollections_(),
307 template<
class RecordType>
313 template<
class RecordType>
316 if (constraintID_ != rhs.constraintID_ ||
317 idType_ != rhs.idType_ ||
318 isPenalty_ != rhs.isPenalty_ ||
319 eqnNumber_ != rhs.eqnNumber_ ||
320 blkEqnNumber_ != rhs.blkEqnNumber_ ||
321 slaveField_ != rhs.slaveField_ ||
322 offsetIntoSlaveField_ != rhs.offsetIntoSlaveField_ ||
323 rhsValue_ != rhs.rhsValue_) {
327 if (masters_ != rhs.masters_)
return(
true);
329 if (masterIDTypes_ != rhs.masterIDTypes_)
return(
true);
331 if (masterFields_ != rhs.masterFields_)
return(
true);
333 if (masterWeights_ != rhs.masterWeights_)
return(
true);
339 template<
class RecordType>
342 if (constraintID_ != rhs.constraintID_ ||
343 idType_ != rhs.idType_ ||
344 isPenalty_ != rhs.isPenalty_ ||
345 eqnNumber_ != rhs.eqnNumber_ ||
346 blkEqnNumber_ != rhs.blkEqnNumber_ ||
347 slaveField_ != rhs.slaveField_ ||
348 offsetIntoSlaveField_ != rhs.offsetIntoSlaveField_) {
352 if (masters_ != rhs.masters_)
return(
false);
354 if (masterIDTypes_ != rhs.masterIDTypes_)
return(
false);
356 if (masterFields_ != rhs.masterFields_)
return(
false);
361 #endif // _snl_fei_Constraint_hpp_
bool operator!=(const Constraint< RecordType > &rhs)
std::vector< int > & getMasterFieldIDs()
double getRHSValue() const
void setEqnNumber(int eqn)
void setConstraintID(int id)
int addDOFs(int fieldID, int idType, int numIDs, const int *IDs)
bool structurallySame(const Constraint< RecordType > &rhs)
int getSlaveFieldID() const
Constraint(int id=0, bool isPenaltyConstr=false)
void setBlkEqnNumber(int blkEqn)
std::vector< double > & getMasterWeights()
int getConstraintID() const
void setRHSValue(double rhs)
void setIDType(int idType)
void setOffsetIntoSlaveField(int offset)
int getOffsetIntoSlaveField() const
void setSlaveFieldID(int f)
void setIsPenalty(bool isPenaltyConstr)
unsigned getFieldSize(int fieldID)
std::vector< snl_fei::RecordCollection * > & getMasterRecordCollections()
int getBlkEqnNumber() const
std::vector< int > & getMasters()
int getRecordCollection(int idType, snl_fei::RecordCollection *&records)
std::vector< int > & getMasterIDTypes()